@lovrabet/rabetbase-cli 2.5.13 → 2.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -17
- package/lib/api/api-doc.js +3 -1
- package/lib/api/api-group.js +3 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +8 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +2 -1
- package/lib/api/model-registry-file.js +11 -1
- package/lib/api/model-registry-scaffold.js +2 -1
- package/lib/api/model-source.js +3 -1
- package/lib/auth/auth-server-ui.js +2 -1
- package/lib/auth/auth-server.js +5 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +3 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +5 -1
- package/lib/commands/api/generate.js +4 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +2 -1
- package/lib/commands/api/pull.js +10 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/detail.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +5 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +4 -1
- package/lib/commands/app-config/delete.js +2 -1
- package/lib/commands/app-config/get.js +2 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +2 -1
- package/lib/commands/app-config/set.js +3 -1
- package/lib/commands/app-config/shared.d.ts +9 -2
- package/lib/commands/app-config/shared.js +6 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +11 -1
- package/lib/commands/bff/delete.js +6 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +4 -1
- package/lib/commands/bff/pull.js +22 -1
- package/lib/commands/bff/push.js +16 -1
- package/lib/commands/bff/status.js +3 -1
- package/lib/commands/cli-skill/index.js +2 -1
- package/lib/commands/cli-update.js +7 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +4 -1
- package/lib/commands/common/app-selector.js +4 -1
- package/lib/commands/common/async-task.js +2 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +3 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +2 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +5 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +4 -1
- package/lib/commands/config/shared.js +2 -1
- package/lib/commands/dataset/batch-design.js +9 -1
- package/lib/commands/dataset/business-group-update.js +10 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +3 -1
- package/lib/commands/dataset/cross-relation-create.js +2 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +2 -1
- package/lib/commands/dataset/cross-relation-shared.js +10 -1
- package/lib/commands/dataset/cross-relation-update.js +2 -1
- package/lib/commands/dataset/delete.js +6 -1
- package/lib/commands/dataset/design-context.js +1 -1
- package/lib/commands/dataset/design-start.js +1 -1
- package/lib/commands/dataset/design-status.js +1 -1
- package/lib/commands/dataset/design-sync-retry.js +1 -1
- package/lib/commands/dataset/design-sync-status.js +1 -1
- package/lib/commands/dataset/design-validate.js +1 -1
- package/lib/commands/dataset/detail.js +5 -1
- package/lib/commands/dataset/extend-update.js +7 -1
- package/lib/commands/dataset/field-restore.js +7 -1
- package/lib/commands/dataset/field-update.js +7 -1
- package/lib/commands/dataset/generate.js +19 -1
- package/lib/commands/dataset/index.js +3 -1
- package/lib/commands/dataset/list.js +2 -1
- package/lib/commands/dataset/operations.js +2 -1
- package/lib/commands/dataset/relation-audit.js +7 -1
- package/lib/commands/dataset/relation-create.js +3 -1
- package/lib/commands/dataset/relation-delete.js +3 -1
- package/lib/commands/dataset/relation-shared.js +21 -1
- package/lib/commands/dataset/relation-update.js +4 -1
- package/lib/commands/dataset/relations.js +7 -1
- package/lib/commands/dataset/rename.js +4 -1
- package/lib/commands/dataset/restore.js +7 -1
- package/lib/commands/dataset/user-deleted-field-list.js +3 -1
- package/lib/commands/db/analysis-batching.js +3 -1
- package/lib/commands/db/analyze-batch-plan.js +2 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +3 -1
- package/lib/commands/db/analyze-status.js +6 -1
- package/lib/commands/db/create.js +4 -1
- package/lib/commands/db/cross-db-analysis-shared.js +3 -1
- package/lib/commands/db/cross-db-analyze-latest.js +1 -1
- package/lib/commands/db/cross-db-analyze-start.js +2 -1
- package/lib/commands/db/cross-db-analyze-status.js +1 -1
- package/lib/commands/db/delete.js +3 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +2 -1
- package/lib/commands/db/diff.js +3 -1
- package/lib/commands/db/index.js +2 -1
- package/lib/commands/db/list.js +2 -1
- package/lib/commands/db/shared.js +3 -1
- package/lib/commands/db/table-diff-shared.js +2 -1
- package/lib/commands/db/tables.js +2 -1
- package/lib/commands/db/test.js +2 -1
- package/lib/commands/db/update.js +4 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +3 -1
- package/lib/commands/deployment/sync-jobs.js +2 -1
- package/lib/commands/deployment/sync-status.js +2 -1
- package/lib/commands/doctor.js +12 -1
- package/lib/commands/file/index.js +3 -1
- package/lib/commands/flow/create.js +2 -1
- package/lib/commands/flow/detail.js +3 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +2 -1
- package/lib/commands/flow/page-list.js +2 -1
- package/lib/commands/flow/publish.js +2 -1
- package/lib/commands/flow/runtime-resources-shared.js +3 -1
- package/lib/commands/flow/runtime-role-list.js +2 -1
- package/lib/commands/flow/runtime-role-user-list.js +2 -1
- package/lib/commands/flow/runtime-user-search.js +2 -1
- package/lib/commands/flow/shared.js +6 -1
- package/lib/commands/flow/update.js +4 -1
- package/lib/commands/flow/validate.js +2 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +2 -1
- package/lib/commands/instant-api-policy/publish.js +5 -1
- package/lib/commands/instant-api-policy/pull.js +2 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +5 -1
- package/lib/commands/instant-api-policy/shared.js +5 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/context.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +2 -1
- package/lib/commands/issue/report.js +5 -1
- package/lib/commands/kb/create.js +5 -1
- package/lib/commands/kb/delete.js +5 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/import-api.d.ts +3 -0
- package/lib/commands/kb/import-api.js +1 -0
- package/lib/commands/kb/import-resume.d.ts +2 -0
- package/lib/commands/kb/import-resume.js +2 -0
- package/lib/commands/kb/import-shared.d.ts +69 -0
- package/lib/commands/kb/import-shared.js +9 -0
- package/lib/commands/kb/import-status.d.ts +2 -0
- package/lib/commands/kb/import-status.js +1 -0
- package/lib/commands/kb/import.d.ts +2 -0
- package/lib/commands/kb/import.js +3 -0
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +3 -1
- package/lib/commands/kb/shared.js +9 -1
- package/lib/commands/kb/update.js +7 -1
- package/lib/commands/logs/index.js +2 -1
- package/lib/commands/menu/asset-update.js +8 -1
- package/lib/commands/menu/delete.js +15 -1
- package/lib/commands/menu/external-link-create.js +16 -1
- package/lib/commands/menu/external-link-update.js +10 -1
- package/lib/commands/menu/group-create.js +8 -1
- package/lib/commands/menu/group-update.js +6 -1
- package/lib/commands/menu/index.js +2 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +6 -1
- package/lib/commands/menu/regroup-start.js +11 -1
- package/lib/commands/menu/rename.js +9 -1
- package/lib/commands/menu/shared/compare-table.js +2 -1
- package/lib/commands/menu/shared/delete-plan.js +13 -1
- package/lib/commands/menu/shared/facts.js +5 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +4 -1
- package/lib/commands/menu/shared/local-pages.js +5 -1
- package/lib/commands/menu/shared/logic.js +3 -1
- package/lib/commands/menu/shared/mutations.js +9 -1
- package/lib/commands/menu/shared/path.js +1 -1
- package/lib/commands/menu/shared/service.js +4 -1
- package/lib/commands/menu/shared/subapp-assets.js +4 -1
- package/lib/commands/menu/shared/sync-core.js +7 -1
- package/lib/commands/menu/shared/types.js +1 -1
- package/lib/commands/menu/shared/update-core.js +8 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.js +1 -1
- package/lib/commands/menu/subapp-assets-update.js +7 -1
- package/lib/commands/menu/sync.js +7 -1
- package/lib/commands/menu/visibility-update.js +13 -1
- package/lib/commands/metric/contract.d.ts +8 -0
- package/lib/commands/metric/contract.js +5 -0
- package/lib/commands/metric/definition.d.ts +43 -0
- package/lib/commands/metric/definition.js +4 -0
- package/lib/commands/metric/delete.d.ts +2 -0
- package/lib/commands/metric/delete.js +3 -0
- package/lib/commands/metric/detail.d.ts +2 -0
- package/lib/commands/metric/detail.js +1 -0
- package/lib/commands/metric/example.d.ts +2 -0
- package/lib/commands/metric/example.js +1 -0
- package/lib/commands/metric/index.d.ts +2 -0
- package/lib/commands/metric/index.js +1 -0
- package/lib/commands/metric/list.d.ts +2 -0
- package/lib/commands/metric/list.js +2 -0
- package/lib/commands/metric/publication-diff.d.ts +8 -0
- package/lib/commands/metric/publication-diff.js +1 -0
- package/lib/commands/metric/publish.d.ts +2 -0
- package/lib/commands/metric/publish.js +4 -0
- package/lib/commands/metric/schema.d.ts +2 -0
- package/lib/commands/metric/schema.js +1 -0
- package/lib/commands/metric/shared.d.ts +14 -0
- package/lib/commands/metric/shared.js +2 -0
- package/lib/commands/metric/validate.d.ts +2 -0
- package/lib/commands/metric/validate.js +1 -0
- package/lib/commands/notification/config-create.js +4 -1
- package/lib/commands/notification/config-delete.js +4 -1
- package/lib/commands/notification/config-list.js +2 -1
- package/lib/commands/notification/config-update.js +4 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +18 -1
- package/lib/commands/ocr/index.js +4 -1
- package/lib/commands/page/create.js +6 -1
- package/lib/commands/page/custom/detail.js +2 -1
- package/lib/commands/page/custom/list.js +2 -1
- package/lib/commands/page/custom/publish.js +3 -1
- package/lib/commands/page/custom/shared.js +3 -1
- package/lib/commands/page/custom/syntax.js +2 -1
- package/lib/commands/page/custom/update.js +3 -1
- package/lib/commands/page/data-list-status.js +2 -1
- package/lib/commands/page/generate-start.js +5 -1
- package/lib/commands/page/generate-status.js +4 -1
- package/lib/commands/page/index.js +2 -1
- package/lib/commands/page/pull.js +6 -1
- package/lib/commands/page/push.js +11 -1
- package/lib/commands/page/relation-audit.js +15 -1
- package/lib/commands/page/restore.js +5 -1
- package/lib/commands/page/shared.js +16 -1
- package/lib/commands/page/sync.js +2 -1
- package/lib/commands/project/api-architecture-upgrade.js +11 -1
- package/lib/commands/project/create/enhanced-guided-create.js +2 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +13 -1
- package/lib/commands/project/create/materialize-project-template.js +12 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +5 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +2 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +4 -1
- package/lib/commands/project/upgrade.js +7 -1
- package/lib/commands/registry.js +10 -1
- package/lib/commands/role/delete.js +2 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +2 -1
- package/lib/commands/role/shared.js +8 -1
- package/lib/commands/role/update.js +3 -1
- package/lib/commands/role/user-add.js +2 -1
- package/lib/commands/role/user-remove.js +2 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +7 -1
- package/lib/commands/rule/shared.js +4 -1
- package/lib/commands/run/index.js +5 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +7 -1
- package/lib/commands/sql/delete.js +4 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +2 -1
- package/lib/commands/sql/pull.js +10 -1
- package/lib/commands/sql/push.js +9 -1
- package/lib/commands/sql/shared.js +5 -1
- package/lib/commands/sql/status.js +3 -1
- package/lib/commands/sql/validate.js +5 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +2 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +2 -1
- package/lib/commands/tenant/shared.js +2 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +2 -1
- package/lib/commands/user-account/feishu-bind.js +2 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +7 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +8 -1
- package/lib/config/project-domain-routing.js +3 -1
- package/lib/config/region-config.js +2 -1
- package/lib/config/schema.js +7 -1
- package/lib/constant/cdn.js +2 -1
- package/lib/constant/cli.js +8 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +4 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +7 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +7 -1
- package/lib/context.js +9 -1
- package/lib/core/alias-resolver.js +5 -1
- package/lib/core/api-client.d.ts +14 -7
- package/lib/core/api-client.js +69 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +6 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +9 -1
- package/lib/core/bff/lock.js +2 -1
- package/lib/core/bff/types.js +1 -1
- package/lib/core/bff/utils.js +3 -1
- package/lib/core/cross-db-analysis.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +2 -1
- package/lib/core/flow-config.js +49 -1
- package/lib/core/instant-api-policy/config.js +7 -1
- package/lib/core/instant-api-policy/endpoints.js +1 -1
- package/lib/core/kb-management-client.d.ts +11 -0
- package/lib/core/kb-management-client.js +4 -1
- package/lib/core/kb-search-client.js +3 -1
- package/lib/core/page/file-system.js +2 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +2 -1
- package/lib/core/page/lr-smart-jsx.js +4 -1
- package/lib/core/page/types.js +1 -1
- package/lib/core/sql-index-auditor.js +14 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +3 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +2 -1
- package/lib/core/sql-sync/types.js +1 -1
- package/lib/core/sql-sync/utils.js +2 -1
- package/lib/core/sql-validator.js +15 -1
- package/lib/errors.js +3 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +2 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +2 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +2 -1
- package/lib/framework/runner.js +9 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +2 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +3 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/runtime/confirmation.js +2 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +4 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +2 -1
- package/lib/runtime/types.js +1 -1
- package/lib/services/dataset-design/checkpoint.js +2 -1
- package/lib/services/dataset-design/commands.js +14 -1
- package/lib/services/dataset-design/contract.js +8 -1
- package/lib/skills/builtin-skill.js +8 -1
- package/lib/skills/install-updated-skill.d.ts +8 -0
- package/lib/skills/install-updated-skill.js +3 -0
- package/lib/skills/local-skills-installer.d.ts +2 -0
- package/lib/skills/local-skills-installer.js +1 -0
- package/lib/skills/main.js +2 -1
- package/lib/skills/npx-skills-add.d.ts +6 -6
- package/lib/skills/npx-skills-add.js +5 -1
- package/lib/skills/skill-presence.d.ts +1 -30
- package/lib/skills/skill-presence.js +2 -1
- package/lib/telemetry/cli-command-trace.js +2 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/types/index.js +1 -1
- package/lib/utils/ai_config.js +3 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +5 -1
- package/lib/utils/cli-version-check.js +4 -1
- package/lib/utils/cli-version-policy.js +3 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +3 -1
- package/lib/utils/http-client.js +2 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +3 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +5 -1
- package/lib/utils/update-notice.js +3 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +10 -7
- package/skills/rabetbase/SKILL.md +11 -7
- package/skills/rabetbase/guides/backend-function.md +3 -1
- package/skills/rabetbase/guides/data-api-guidelines.md +1 -1
- package/skills/rabetbase/guides/frontend-development.md +1 -0
- package/skills/rabetbase/guides/metric-development.md +185 -0
- package/skills/rabetbase/references/rabetbase-app-config.md +4 -3
- package/skills/rabetbase/references/rabetbase-cli-skill-install.md +5 -5
- package/skills/rabetbase/references/rabetbase-dataset-design.md +1 -1
- package/skills/rabetbase/references/rabetbase-kb.md +16 -0
- package/skills/rabetbase/references/rabetbase-metric.md +119 -0
- package/skills/rabetbase/references/rabetbase-update.md +7 -5
- package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
- package/skills/rabetbase-dataset-generation/references/workflow.md +1 -1
- package/skills/rabetbase-metrics-generation/SKILL.md +22 -0
- package/skills/rabetbase-metrics-generation/references/verification.md +19 -0
- package/skills/rabetbase-metrics-generation/references/workflow.md +41 -0
- package/skills/rabetbase-metrics-generation/templates/statistics-delivery.md +11 -0
- package/skills/rabetbase-page-generation/SKILL.md +1 -1
- package/skills/rabetbase-page-generation/references/generation.md +1 -1
- package/skills/rabetbase.manifest.json +5 -3
- package/templates/metrics/definition.json +78 -0
- package/templates/metrics/metric-definition.schema.json +136 -0
- package/lib/postinstall.d.ts +0 -3
- package/lib/postinstall.js +0 -1
- package/scripts/postinstall.mjs +0 -24
|
@@ -1 +1,18 @@
|
|
|
1
|
-
const a197_0x41795d=a197_0x46fb;(function(_0x55d60e,_0x5d7e8e){const _0x27b46a=a197_0x46fb,_0x2c40a9=_0x55d60e();while(!![]){try{const _0x433950=parseInt(_0x27b46a(0x176))/0x1*(parseInt(_0x27b46a(0x1cb))/0x2)+parseInt(_0x27b46a(0x18c))/0x3+parseInt(_0x27b46a(0x1aa))/0x4+-parseInt(_0x27b46a(0x199))/0x5*(parseInt(_0x27b46a(0x16d))/0x6)+-parseInt(_0x27b46a(0x1c7))/0x7+-parseInt(_0x27b46a(0x196))/0x8+parseInt(_0x27b46a(0x1b8))/0x9*(-parseInt(_0x27b46a(0x175))/0xa);if(_0x433950===_0x5d7e8e)break;else _0x2c40a9['push'](_0x2c40a9['shift']());}catch(_0x2d1e5c){_0x2c40a9['push'](_0x2c40a9['shift']());}}}(a197_0x5280,0xf1799));import{readFile}from'node:fs/promises';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{getNotificationChannelConfig}from'../../core/api-client.js';import{CliError,CliErrors}from'../../errors.js';export const NOTIFICATION_CHANNEL_TYPES=[a197_0x41795d(0x1a3),'FEISHU',a197_0x41795d(0x163),a197_0x41795d(0x1c2),a197_0x41795d(0x1a1)];export const DEFAULT_NOTIFICATION_CONNECT_TIMEOUT=0x1388;export const DEFAULT_NOTIFICATION_READ_TIMEOUT=0x2710;const ALLOWED_INPUT_FIELDS=new Set([a197_0x41795d(0x198),a197_0x41795d(0x1a4),'endpointUrl',a197_0x41795d(0x166),'description',a197_0x41795d(0x15c),a197_0x41795d(0x1c6)]),FORBIDDEN_IDENTITY_FIELDS=new Set(['id',a197_0x41795d(0x177),a197_0x41795d(0x19e),a197_0x41795d(0x18b)]),EMAIL_RECIPIENT_FIELDS=new Set(['emailTargets',a197_0x41795d(0x167),a197_0x41795d(0x159),a197_0x41795d(0x14e),a197_0x41795d(0x178),'subjectPrefix',a197_0x41795d(0x1b2),'to','cc']);export const NOTIFICATION_INPUT_FLAGS=[{'name':a197_0x41795d(0x150),'type':a197_0x41795d(0x1a8),'required':![],'description':a197_0x41795d(0x155)},{'name':'stdin','type':a197_0x41795d(0x16e),'required':![],'default':![],'description':a197_0x41795d(0x185)},{'name':'from-env','type':a197_0x41795d(0x1a8),'required':![],'description':a197_0x41795d(0x19b)}];export const NOTIFICATION_ID_FLAG={'name':'id','type':a197_0x41795d(0x195),'required':!![],'description':a197_0x41795d(0x1ac)};export const NOTIFICATION_APP_FLAG=APPCODE_FLAG_OPTIONAL;export function notificationError(_0x2d0865,_0x1204dd,_0x7677e1){return new CliError(_0x2d0865,0x1,_0x1204dd,_0x7677e1);}export function readNotificationId(_0x5b82d5){const _0x181c0e=a197_0x41795d,_0x34512b=_0x5b82d5[_0x181c0e(0x1a7)]('id');if(!Number['isSafeInteger'](_0x34512b)||_0x34512b<=0x0)throw notificationError(_0x181c0e(0x16c),'--id\x20must\x20be\x20a\x20positive\x20safe\x20integer.');return _0x34512b;}export function requireNotificationExplicitYes(_0x345755){const _0x19ac48=a197_0x41795d;if(_0x345755[_0x19ac48(0x160)](_0x19ac48(0x15a))||_0x345755[_0x19ac48(0x160)](_0x19ac48(0x19d)))return;throw notificationError(_0x19ac48(0x169),_0x19ac48(0x1c0),_0x19ac48(0x187));}export function readNotificationChannelType(_0x5b83f9,_0x471631=a197_0x41795d(0x174),_0x5833f7=a197_0x41795d(0x1a3)){const _0x1860cd=a197_0x41795d,_0x5501dc=_0x5b83f9[_0x1860cd(0x170)](_0x471631)[_0x1860cd(0x17c)]()||_0x5833f7;if(!NOTIFICATION_CHANNEL_TYPES['includes'](_0x5501dc))throw CliErrors[_0x1860cd(0x171)](_0x1860cd(0x1be)+_0x471631+':\x20'+_0x5501dc,_0x1860cd(0x1af)+NOTIFICATION_CHANNEL_TYPES[_0x1860cd(0x18f)](',\x20')+'.');return _0x5501dc;}export function assertSingleNotificationSource(_0x29222d){const _0x28cbf8=a197_0x41795d,_0x2fb1bf=[],_0x5a5261=_0x29222d[_0x28cbf8(0x170)](_0x28cbf8(0x150))['trim']();if(_0x5a5261)_0x2fb1bf[_0x28cbf8(0x162)]({'kind':'file','path':_0x5a5261});if(_0x29222d['bool'](_0x28cbf8(0x18e)))_0x2fb1bf[_0x28cbf8(0x162)]({'kind':'stdin'});const _0x19f58d=_0x29222d['str']('from-env')[_0x28cbf8(0x17c)]();if(_0x19f58d)_0x2fb1bf[_0x28cbf8(0x162)]({'kind':_0x28cbf8(0x1c9),'name':_0x19f58d});if(_0x2fb1bf['length']===0x0)throw CliErrors[_0x28cbf8(0x171)]('Missing\x20notification\x20JSON\x20source.',_0x28cbf8(0x1c1));if(_0x2fb1bf[_0x28cbf8(0x1ad)]>0x1)throw CliErrors[_0x28cbf8(0x171)](_0x28cbf8(0x153),'Use\x20exactly\x20one\x20of\x20--file\x20<path>,\x20--stdin,\x20or\x20--from-env\x20<NAME>.');return _0x2fb1bf[0x0];}export async function readNotificationDocument(_0x1b311b,_0x5da2de){const _0x2170f4=a197_0x41795d,_0x48af3b=assertSingleNotificationSource(_0x1b311b),_0x15c956=_0x48af3b[_0x2170f4(0x184)]===_0x2170f4(0x150)?_0x2170f4(0x156)+_0x48af3b[_0x2170f4(0x1ca)]:_0x48af3b[_0x2170f4(0x184)]===_0x2170f4(0x1c9)?_0x2170f4(0x1b1)+_0x48af3b[_0x2170f4(0x17a)]:_0x2170f4(0x18e);let _0x37631c;try{if(_0x48af3b[_0x2170f4(0x184)]===_0x2170f4(0x150))_0x37631c=await readFile(_0x48af3b['path'],_0x2170f4(0x1a6));else{if(_0x48af3b[_0x2170f4(0x184)]==='env'){if(!(_0x48af3b[_0x2170f4(0x17a)]in process.env))throw notificationError('notification_config_source_unavailable',_0x2170f4(0x168)+_0x48af3b[_0x2170f4(0x17a)]);_0x37631c=process.env[_0x48af3b.name]??'';}else _0x37631c=await readStdin();}}catch(_0x4b56a4){if(_0x4b56a4 instanceof CliError)throw _0x4b56a4;throw notificationError(_0x2170f4(0x183),_0x2170f4(0x14f)+_0x15c956+'.');}let _0xbe5036;try{_0xbe5036=JSON[_0x2170f4(0x19f)](_0x37631c);}catch{throw notificationError(_0x2170f4(0x15f),_0x2170f4(0x1bf)+_0x15c956+_0x2170f4(0x193),_0x2170f4(0x161));}if(!isJsonObject(_0xbe5036))throw notificationError('notification_config_json_invalid',_0x2170f4(0x1bf)+_0x15c956+'\x20must\x20be\x20an\x20object.');return validateNotificationDocument(_0xbe5036,_0x5da2de);}export function projectNotificationListConfig(_0x214a5e,_0x5e49ba){const _0x2e3d53=a197_0x41795d;return{'id':typeof _0x214a5e['id']==='number'?_0x214a5e['id']:null,'configCode':requireResponseString(_0x214a5e['configCode'],_0x2e3d53(0x19e),_0x5e49ba),'configName':requireResponseString(_0x214a5e[_0x2e3d53(0x198)],_0x2e3d53(0x198),_0x5e49ba),'channelType':requireResponseString(_0x214a5e[_0x2e3d53(0x1a4)],_0x2e3d53(0x1a4),_0x5e49ba),'description':normalizeNullableString(_0x214a5e[_0x2e3d53(0x14b)]),'createTime':normalizeNullableString(_0x214a5e[_0x2e3d53(0x1b6)]),'updateTime':normalizeNullableString(_0x214a5e[_0x2e3d53(0x1b0)])};}export function normalizeExactNotificationConfig(_0x549c0c,_0x362618,_0x6b4140){const _0x1627d1=a197_0x41795d;if(!Number[_0x1627d1(0x1c5)](_0x549c0c['id'])||_0x549c0c['id']!==_0x362618)throw notificationError(_0x1627d1(0x1bd),_0x1627d1(0x1ae)+_0x362618+'.');if(_0x549c0c[_0x1627d1(0x177)]!==_0x6b4140)throw notificationError('notification_config_response_invalid',_0x1627d1(0x197)+_0x362618+_0x1627d1(0x17f));const _0xb8168a=requireExactString(_0x549c0c[_0x1627d1(0x198)],_0x1627d1(0x198),_0x362618),_0x4a8348=requireExactString(_0x549c0c[_0x1627d1(0x19e)],_0x1627d1(0x19e),_0x362618),_0x128109=requireExactString(_0x549c0c['channelType'],_0x1627d1(0x1a4),_0x362618);if(!NOTIFICATION_CHANNEL_TYPES[_0x1627d1(0x181)](_0x128109))throw notificationError('notification_config_response_invalid',_0x1627d1(0x197)+_0x362618+_0x1627d1(0x172));const _0x4edfb3=responseNullableString(_0x549c0c[_0x1627d1(0x1a5)],_0x1627d1(0x1a5),_0x362618),_0x4c6fd2=responseNullableString(_0x549c0c['channelConfig'],'channelConfig',_0x362618),_0x1d2128=responseNullableString(_0x549c0c[_0x1627d1(0x14b)],_0x1627d1(0x14b),_0x362618),_0x4a3691=responseNullableTimeout(_0x549c0c[_0x1627d1(0x15c)],'connectTimeout',_0x362618),_0x39de41=responseNullableTimeout(_0x549c0c[_0x1627d1(0x1c6)],_0x1627d1(0x1c6),_0x362618);return{'id':_0x362618,'appCode':_0x6b4140,'configCode':_0x4a8348,'configName':_0xb8168a,'channelType':_0x128109,'endpointUrl':redactSensitive(_0x4edfb3),'channelConfig':redactSensitive(_0x4c6fd2),'description':_0x1d2128,'connectTimeout':_0x4a3691,'readTimeout':_0x39de41,'endpointUrlRaw':_0x4edfb3,'channelConfigRaw':_0x4c6fd2};}export async function requireExactNotificationConfig(_0x4b601b,_0x5c8e4d,_0x19e6ed){const _0x236ce9=a197_0x41795d;let _0x15d303;try{_0x15d303=await getNotificationChannelConfig(_0x5c8e4d,_0x4b601b);}catch{throw safeApiFailure(_0x19e6ed,_0x236ce9(0x14c),'Inspect\x20with\x20rabetbase\x20notification\x20config-list\x20--appcode\x20'+_0x4b601b+_0x236ce9(0x18a));}return normalizeExactNotificationConfig(_0x15d303,_0x5c8e4d,_0x4b601b);}export function projectNotificationConfig(_0x5d6c77){const _0x2579ea=a197_0x41795d;return{'id':_0x5d6c77['id']??null,'appCode':_0x5d6c77['appCode'],'configCode':_0x5d6c77['configCode']??null,'configName':_0x5d6c77['configName'],'channelType':_0x5d6c77[_0x2579ea(0x1a4)],'endpointUrl':redactSensitive(_0x5d6c77[_0x2579ea(0x1a5)]),'channelConfig':redactSensitive(_0x5d6c77[_0x2579ea(0x166)]),'description':_0x5d6c77[_0x2579ea(0x14b)]??null,'connectTimeout':_0x5d6c77[_0x2579ea(0x15c)]??null,'readTimeout':_0x5d6c77[_0x2579ea(0x1c6)]??null};}export function notificationSelector(_0x368c26){const _0x42cd3f=a197_0x41795d;return{'appCode':_0x368c26[_0x42cd3f(0x177)],'id':_0x368c26['id'],'configCode':_0x368c26['configCode'],'configName':_0x368c26['configName'],'channelType':_0x368c26[_0x42cd3f(0x1a4)]};}export function createMutationInput(_0x4f1e6b,_0x4b5c92){const _0x209755=a197_0x41795d;return{'appCode':_0x4f1e6b,'configName':_0x4b5c92[_0x209755(0x198)],'channelType':_0x4b5c92[_0x209755(0x1a4)],...hasOwn(_0x4b5c92,'endpointUrl')?{'endpointUrl':_0x4b5c92[_0x209755(0x1a5)]}:{},...hasOwn(_0x4b5c92,_0x209755(0x166))?{'channelConfig':serializeChannelConfig(_0x4b5c92[_0x209755(0x166)])}:{},...hasOwn(_0x4b5c92,'description')?{'description':_0x4b5c92[_0x209755(0x14b)]}:{},...hasOwn(_0x4b5c92,'connectTimeout')?{'connectTimeout':_0x4b5c92[_0x209755(0x15c)]}:{},...hasOwn(_0x4b5c92,_0x209755(0x1c6))?{'readTimeout':_0x4b5c92[_0x209755(0x1c6)]}:{}};}function a197_0x46fb(_0x36859b,_0x539fb1){_0x36859b=_0x36859b-0x14b;const _0x5280a1=a197_0x5280();let _0x46fbe8=_0x5280a1[_0x36859b];return _0x46fbe8;}export function mergeUpdateInput(_0x4683ae,_0x85ddf8){const _0x398a1e=a197_0x41795d;return{'id':_0x4683ae['id'],'appCode':_0x4683ae['appCode'],'configName':_0x85ddf8[_0x398a1e(0x198)]??_0x4683ae[_0x398a1e(0x198)],'channelType':_0x85ddf8['channelType']??_0x4683ae[_0x398a1e(0x1a4)],'endpointUrl':hasOwn(_0x85ddf8,_0x398a1e(0x1a5))?_0x85ddf8[_0x398a1e(0x1a5)]:_0x4683ae[_0x398a1e(0x164)],'channelConfig':hasOwn(_0x85ddf8,_0x398a1e(0x166))?serializeChannelConfig(_0x85ddf8[_0x398a1e(0x166)]):_0x4683ae[_0x398a1e(0x173)],'description':hasOwn(_0x85ddf8,_0x398a1e(0x14b))?_0x85ddf8['description']:_0x4683ae['description'],'connectTimeout':hasOwn(_0x85ddf8,_0x398a1e(0x15c))?_0x85ddf8['connectTimeout']:_0x4683ae['connectTimeout'],'readTimeout':hasOwn(_0x85ddf8,'readTimeout')?_0x85ddf8[_0x398a1e(0x1c6)]:_0x4683ae['readTimeout']};}export function plannedUpdateProjection(_0x4baea2,_0x253138){const _0x95066f=a197_0x41795d;return projectNotificationConfig({'id':_0x4baea2['id'],'appCode':_0x4baea2[_0x95066f(0x177)],'configCode':_0x4baea2[_0x95066f(0x19e)],'configName':_0x253138[_0x95066f(0x198)]??_0x4baea2[_0x95066f(0x198)],'channelType':_0x253138['channelType']??_0x4baea2[_0x95066f(0x1a4)],'endpointUrl':hasOwn(_0x253138,_0x95066f(0x1a5))?_0x253138['endpointUrl']:_0x4baea2[_0x95066f(0x164)],'channelConfig':hasOwn(_0x253138,_0x95066f(0x166))?_0x253138[_0x95066f(0x166)]:_0x4baea2['channelConfigRaw'],'description':hasOwn(_0x253138,_0x95066f(0x14b))?_0x253138[_0x95066f(0x14b)]:_0x4baea2[_0x95066f(0x14b)],'connectTimeout':hasOwn(_0x253138,_0x95066f(0x15c))?_0x253138[_0x95066f(0x15c)]??DEFAULT_NOTIFICATION_CONNECT_TIMEOUT:_0x4baea2['connectTimeout'],'readTimeout':hasOwn(_0x253138,_0x95066f(0x1c6))?_0x253138[_0x95066f(0x1c6)]??DEFAULT_NOTIFICATION_READ_TIMEOUT:_0x4baea2[_0x95066f(0x1c6)]});}export function requestedSafeFieldsMatch(_0x3e258f,_0x2dacb2,_0x13795c){const _0x19f83c=a197_0x41795d,_0x5137a9=[],_0x25f0f8=[],_0x21f084=[];for(const _0x4821e9 of[_0x19f83c(0x198),_0x19f83c(0x1a4),_0x19f83c(0x14b)]){if(!hasOwn(_0x13795c,_0x4821e9))continue;_0x21f084['push'](_0x4821e9),_0x5137a9[_0x19f83c(0x162)](_0x2dacb2[_0x4821e9]===_0x13795c[_0x4821e9]),_0x25f0f8['push'](_0x3e258f[_0x4821e9]!==_0x13795c[_0x4821e9]&&_0x2dacb2[_0x4821e9]===_0x13795c[_0x4821e9]);}for(const _0x1c0d1c of['connectTimeout',_0x19f83c(0x1c6)]){if(!hasOwn(_0x13795c,_0x1c0d1c))continue;const _0x36a5f8=_0x13795c[_0x1c0d1c]??(_0x1c0d1c===_0x19f83c(0x15c)?DEFAULT_NOTIFICATION_CONNECT_TIMEOUT:DEFAULT_NOTIFICATION_READ_TIMEOUT);_0x21f084[_0x19f83c(0x162)](_0x1c0d1c),_0x5137a9['push'](_0x2dacb2[_0x1c0d1c]===_0x36a5f8),_0x25f0f8[_0x19f83c(0x162)](_0x3e258f[_0x1c0d1c]!==_0x36a5f8&&_0x2dacb2[_0x1c0d1c]===_0x36a5f8);}return hasOwn(_0x13795c,_0x19f83c(0x1a5))&&_0x13795c[_0x19f83c(0x1a5)]===null&&(_0x21f084[_0x19f83c(0x162)](_0x19f83c(0x17b)),_0x5137a9['push'](_0x2dacb2[_0x19f83c(0x164)]===null||_0x2dacb2[_0x19f83c(0x164)]===''),_0x25f0f8['push'](_0x3e258f[_0x19f83c(0x164)]!==null&&_0x3e258f['endpointUrlRaw']!==''&&(_0x2dacb2[_0x19f83c(0x164)]===null||_0x2dacb2[_0x19f83c(0x164)]===''))),{'allMatch':_0x5137a9[_0x19f83c(0x188)](Boolean),'provesChange':_0x25f0f8[_0x19f83c(0x1c4)](Boolean),'verifiedFields':_0x21f084};}export function validateNotificationDeleteReadback(_0x237998,_0x41dfbe,_0x1d9307){const _0x100bfe=a197_0x41795d;for(const [_0x55ea53,_0xac9274]of _0x237998['entries']()){if(!Number[_0x100bfe(0x1c5)](_0xac9274['id'])||_0xac9274['id']<=0x0)throw notificationError(_0x100bfe(0x1bd),_0x100bfe(0x192)+(_0x55ea53+0x1)+_0x100bfe(0x17e));if(_0xac9274[_0x100bfe(0x177)]!==_0x41dfbe)throw notificationError('notification_config_response_invalid',_0x100bfe(0x192)+(_0x55ea53+0x1)+'\x20has\x20an\x20invalid\x20appCode.');if(_0xac9274['channelType']!==_0x1d9307)throw notificationError(_0x100bfe(0x1bd),_0x100bfe(0x192)+(_0x55ea53+0x1)+'\x20has\x20an\x20invalid\x20channelType.');}}export function safeApiFailure(_0x522cd5,_0xdb0bd7,_0x938470){const _0x24a7cc=a197_0x41795d;return notificationError(_0x24a7cc(0x1b3)+_0x522cd5+'_'+(_0xdb0bd7==='mutation'?_0x24a7cc(0x1bb):_0xdb0bd7+_0x24a7cc(0x18d)),_0x24a7cc(0x197)+_0x522cd5+'\x20'+_0xdb0bd7+_0x24a7cc(0x1b5),_0x938470);}export function notificationLookupCommand(_0x315ed8,_0x3339f7){const _0x4518e8=a197_0x41795d;return _0x4518e8(0x1b7)+_0x315ed8+_0x4518e8(0x1b9)+_0x3339f7+_0x4518e8(0x182);}function validateNotificationDocument(_0xeb57fc,_0x5670ac){const _0xe99308=a197_0x41795d;for(const _0x30dd77 of Object[_0xe99308(0x15e)](_0xeb57fc)){if(FORBIDDEN_IDENTITY_FIELDS[_0xe99308(0x1a0)](_0x30dd77))throw notificationError('notification_config_field_forbidden',_0xe99308(0x157)+_0x30dd77+_0xe99308(0x1bc));if(!ALLOWED_INPUT_FIELDS[_0xe99308(0x1a0)](_0x30dd77))throw notificationError('notification_config_field_unknown',_0xe99308(0x14d)+_0x30dd77+'\x22.');}if(_0x5670ac===_0xe99308(0x16b)&&Object[_0xe99308(0x15e)](_0xeb57fc)[_0xe99308(0x1ad)]===0x0)throw notificationError(_0xe99308(0x151),'Update\x20JSON\x20must\x20contain\x20at\x20least\x20one\x20allowed\x20field.');const _0x2ff35a={};if(hasOwn(_0xeb57fc,_0xe99308(0x198)))_0x2ff35a[_0xe99308(0x198)]=validateRequiredString(_0xeb57fc['configName'],_0xe99308(0x198),0x80);else{if(_0x5670ac===_0xe99308(0x1a2))throw notificationError(_0xe99308(0x19c),_0xe99308(0x186)+'\x22configName\x22.');}if(hasOwn(_0xeb57fc,'channelType')){if(typeof _0xeb57fc[_0xe99308(0x1a4)]!==_0xe99308(0x1a8))throw invalidFieldType('channelType',_0xe99308(0x1ab));const _0x44eada=_0xeb57fc['channelType'][_0xe99308(0x17c)]();if(!NOTIFICATION_CHANNEL_TYPES[_0xe99308(0x181)](_0x44eada))throw notificationError('notification_config_field_invalid',_0xe99308(0x17d),'Allowed\x20values:\x20'+NOTIFICATION_CHANNEL_TYPES[_0xe99308(0x18f)](',\x20')+'.');_0x2ff35a[_0xe99308(0x1a4)]=_0x44eada;}else{if(_0x5670ac==='create')throw notificationError('notification_config_field_required',_0xe99308(0x186)+'\x22channelType\x22.');}for(const [_0x45b0f9,_0x83d050]of[['endpointUrl',0x200],[_0xe99308(0x14b),0x100]]){if(!hasOwn(_0xeb57fc,_0x45b0f9))continue;const _0x33c01f=_0xeb57fc[_0x45b0f9];if(_0x33c01f!==null&&typeof _0x33c01f!==_0xe99308(0x1a8))throw invalidFieldType(_0x45b0f9,_0xe99308(0x1ba));if(typeof _0x33c01f==='string'&&_0x33c01f[_0xe99308(0x1ad)]>_0x83d050)throw notificationError(_0xe99308(0x191),'Notification\x20JSON\x20field\x20\x22'+_0x45b0f9+'\x22\x20cannot\x20exceed\x20'+_0x83d050+_0xe99308(0x179));_0x2ff35a[_0x45b0f9]=_0x33c01f;}if(hasOwn(_0xeb57fc,_0xe99308(0x166))){const _0x301174=_0xeb57fc[_0xe99308(0x166)];if(_0x301174===null&&_0x5670ac==='create')throw invalidFieldType(_0xe99308(0x166),_0xe99308(0x194));if(_0x301174!==null&&!isJsonObject(_0x301174))throw invalidFieldType(_0xe99308(0x166),_0x5670ac===_0xe99308(0x16b)?_0xe99308(0x1c3):_0xe99308(0x194));_0x301174!==null&&validateChannelConfigFields(_0x2ff35a[_0xe99308(0x1a4)],_0x301174),_0x2ff35a[_0xe99308(0x166)]=_0x301174;}for(const _0x1b187a of['connectTimeout',_0xe99308(0x1c6)]){if(!hasOwn(_0xeb57fc,_0x1b187a))continue;const _0x2c796c=_0xeb57fc[_0x1b187a];if(_0x2c796c!==null&&(!Number[_0xe99308(0x1c5)](_0x2c796c)||_0x2c796c<0x0))throw notificationError(_0xe99308(0x191),_0xe99308(0x157)+_0x1b187a+'\x22\x20must\x20be\x20a\x20non-negative\x20safe\x20integer\x20or\x20null.');_0x2ff35a[_0x1b187a]=_0x2c796c;}return _0x2ff35a;}function validateRequiredString(_0x5a4c0b,_0x3bd401,_0x2915a8){const _0x22a5ab=a197_0x41795d;if(typeof _0x5a4c0b!==_0x22a5ab(0x1a8))throw invalidFieldType(_0x3bd401,'a\x20non-empty\x20string');const _0x58a146=_0x5a4c0b['trim']();if(!_0x58a146)throw notificationError(_0x22a5ab(0x191),_0x22a5ab(0x157)+_0x3bd401+_0x22a5ab(0x158));if(_0x58a146['length']>_0x2915a8)throw notificationError(_0x22a5ab(0x191),_0x22a5ab(0x157)+_0x3bd401+_0x22a5ab(0x190)+_0x2915a8+_0x22a5ab(0x179));return _0x58a146;}function validateChannelConfigFields(_0x2c386b,_0x1a180a){const _0x3da98c=a197_0x41795d;if(hasOwn(_0x1a180a,_0x3da98c(0x152)))throw forbiddenChannelConfigField(_0x3da98c(0x152));if(_0x2c386b===_0x3da98c(0x1a3))for(const _0x456a62 of EMAIL_RECIPIENT_FIELDS){if(hasOwn(_0x1a180a,_0x456a62))throw forbiddenChannelConfigField(_0x456a62);}}function forbiddenChannelConfigField(_0x257924){const _0x107db5=a197_0x41795d;return notificationError(_0x107db5(0x15b),_0x107db5(0x1c8)+_0x257924+_0x107db5(0x180));}function a197_0x5280(){const _0x273d80=['stringify','7828368KtMnNx','a\x20supported\x20string','Application-level\x20notification\x20config\x20ID','length','Notification\x20config\x20detail\x20did\x20not\x20contain\x20the\x20requested\x20ID\x20','Allowed\x20values:\x20','updateTime','environment\x20variable\x20','fromName','notification_config_','\x22\x20must\x20be\x20','\x20failed.','createTime','rabetbase\x20notification\x20config-list\x20--appcode\x20','9ZcaANs','\x20--type\x20','a\x20string\x20or\x20null','failed','\x22\x20is\x20controlled\x20by\x20the\x20CLI\x20or\x20server\x20and\x20is\x20forbidden.','notification_config_response_invalid','Invalid\x20--','Notification\x20JSON\x20from\x20','This\x20notification\x20config\x20mutation\x20requires\x20explicit\x20--yes.','Use\x20exactly\x20one\x20of\x20--file\x20<path>,\x20--stdin,\x20or\x20--from-env\x20<NAME>.','WECOM','a\x20JSON\x20object\x20or\x20null','some','isSafeInteger','readTimeout','3163657NhpqzH','Notification\x20JSON\x20channelConfig\x20field\x20\x22','env','path','2TFZCMA','description','preflight','Unknown\x20notification\x20JSON\x20field\x20\x22','bccList','Unable\x20to\x20read\x20notification\x20JSON\x20from\x20','file','notification_config_update_empty','messageTemplate','Notification\x20JSON\x20source\x20is\x20ambiguous.','object','Read\x20the\x20notification\x20JSON\x20document\x20from\x20a\x20UTF-8\x20file','file\x20','Notification\x20JSON\x20field\x20\x22','\x22\x20must\x20be\x20a\x20non-empty\x20string.','ccList','dry-run','notification_config_channel_field_forbidden','connectTimeout','<redacted>','keys','notification_config_json_invalid','bool','Provide\x20one\x20valid\x20JSON\x20object;\x20source\x20contents\x20are\x20not\x20included\x20in\x20errors.','push','DINGTALK','endpointUrlRaw','Item\x20','channelConfig','recipients','Notification\x20JSON\x20environment\x20variable\x20is\x20not\x20set:\x20','notification_config_confirmation_required','\x20has\x20invalid\x20field\x20\x22','update','notification_config_id_invalid','343968fJntGK','boolean','setEncoding','str','validation','\x20has\x20an\x20unsupported\x20channelType.','channelConfigRaw','type','5680880sbASeM','1638363ZVItYY','appCode','replyTo','\x20characters.','name','endpointUrl:null','trim','Notification\x20JSON\x20field\x20\x22channelType\x22\x20is\x20unsupported.','\x20has\x20an\x20invalid\x20id.','\x20does\x20not\x20belong\x20to\x20the\x20resolved\x20app.','\x22\x20is\x20forbidden.','includes','\x20--format\x20compress','notification_config_source_unavailable','kind','Read\x20the\x20notification\x20JSON\x20document\x20from\x20stdin','Create\x20JSON\x20requires\x20field\x20','Run\x20the\x20command\x20with\x20--dry-run\x20first,\x20then\x20add\x20--yes\x20after\x20reviewing\x20the\x20plan.','every','apiError','\x20--type\x20<CHANNEL_TYPE>\x20--format\x20compress;\x20no\x20mutation\x20was\x20submitted.','channelCode','1381737lSwXBy','_unavailable','stdin','join','\x22\x20cannot\x20exceed\x20','notification_config_field_invalid','Notification\x20config\x20list\x20item\x20','\x20is\x20invalid.','a\x20JSON\x20object','number','12247696AfiUpT','Notification\x20config\x20','configName','45eCAlSx','\x20is\x20missing\x20required\x20field\x20\x22','Read\x20the\x20notification\x20JSON\x20document\x20from\x20a\x20named\x20environment\x20variable','notification_config_field_required','yes','configCode','parse','has','WEBHOOK','create','EMAIL','channelType','endpointUrl','utf8','num','string'];a197_0x5280=function(){return _0x273d80;};return a197_0x5280();}function invalidFieldType(_0x3f3f37,_0x20d7bc){const _0x5be43a=a197_0x41795d;return notificationError(_0x5be43a(0x191),_0x5be43a(0x157)+_0x3f3f37+_0x5be43a(0x1b4)+_0x20d7bc+'.');}function serializeChannelConfig(_0x1e4e59){const _0xdabaed=a197_0x41795d;return _0x1e4e59===null||_0x1e4e59===undefined?null:JSON[_0xdabaed(0x1a9)](_0x1e4e59);}function redactSensitive(_0x2a9eb4){const _0x51a735=a197_0x41795d;return _0x2a9eb4===null||_0x2a9eb4===undefined||_0x2a9eb4===''?null:_0x51a735(0x15d);}function requireResponseString(_0x225fbf,_0xe4e08a,_0xc13c12){const _0x53780c=a197_0x41795d;if(typeof _0x225fbf!==_0x53780c(0x1a8)||_0x225fbf[_0x53780c(0x17c)]()==='')throw CliErrors[_0x53780c(0x189)]('Invalid\x20notification\x20config\x20response.',_0x53780c(0x165)+(_0xc13c12+0x1)+_0x53780c(0x19a)+_0xe4e08a+'\x22.');return _0x225fbf[_0x53780c(0x17c)]();}function requireExactString(_0x47b521,_0x158320,_0x58d922){const _0x5eb795=a197_0x41795d;if(typeof _0x47b521!==_0x5eb795(0x1a8)||_0x47b521[_0x5eb795(0x17c)]()==='')throw notificationError(_0x5eb795(0x1bd),'Notification\x20config\x20'+_0x58d922+'\x20is\x20missing\x20required\x20field\x20\x22'+_0x158320+'\x22.');return _0x47b521[_0x5eb795(0x17c)]();}function responseNullableString(_0x1f3b3b,_0x1ac541,_0x38c539){const _0x197b1e=a197_0x41795d;if(_0x1f3b3b===undefined||_0x1f3b3b===null)return null;if(typeof _0x1f3b3b!==_0x197b1e(0x1a8))throw notificationError(_0x197b1e(0x1bd),'Notification\x20config\x20'+_0x38c539+_0x197b1e(0x16a)+_0x1ac541+'\x22.');return _0x1f3b3b;}function responseNullableTimeout(_0x4c6198,_0x116a2c,_0xb9025f){const _0x534cde=a197_0x41795d;if(_0x4c6198===undefined||_0x4c6198===null)return null;if(!Number[_0x534cde(0x1c5)](_0x4c6198)||_0x4c6198<0x0)throw notificationError('notification_config_response_invalid',_0x534cde(0x197)+_0xb9025f+_0x534cde(0x16a)+_0x116a2c+'\x22.');return _0x4c6198;}function normalizeNullableString(_0x445d92){return typeof _0x445d92==='string'?_0x445d92:null;}function isJsonObject(_0xd7df19){const _0x56f489=a197_0x41795d;return _0xd7df19!==null&&typeof _0xd7df19===_0x56f489(0x154)&&!Array['isArray'](_0xd7df19);}function hasOwn(_0x21be1c,_0x15262f){return Object['prototype']['hasOwnProperty']['call'](_0x21be1c,_0x15262f);}async function readStdin(){const _0x3e83ff=a197_0x41795d;let _0x201536='';process['stdin'][_0x3e83ff(0x16f)](_0x3e83ff(0x1a6));for await(const _0x3d1dab of process['stdin'])_0x201536+=_0x3d1dab;return _0x201536;}
|
|
1
|
+
import{readFile}from"node:fs/promises";import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{getNotificationChannelConfig}from"../../core/api-client.js";import{CliError,CliErrors}from"../../errors.js";export const NOTIFICATION_CHANNEL_TYPES=["EMAIL","FEISHU","DINGTALK","WECOM","WEBHOOK"];export const DEFAULT_NOTIFICATION_CONNECT_TIMEOUT=5e3;export const DEFAULT_NOTIFICATION_READ_TIMEOUT=1e4;const ALLOWED_INPUT_FIELDS=new Set(["configName","channelType","endpointUrl","channelConfig","description","connectTimeout","readTimeout"]);const FORBIDDEN_IDENTITY_FIELDS=new Set(["id","appCode","configCode","channelCode"]);const EMAIL_RECIPIENT_FIELDS=new Set(["emailTargets","recipients","ccList","bccList","replyTo","subjectPrefix","fromName","to","cc"]);export const NOTIFICATION_INPUT_FLAGS=[{name:"file",type:"string",required:false,description:"Read the notification JSON document from a UTF-8 file"},{name:"stdin",type:"boolean",required:false,default:false,
|
|
2
|
+
description:"Read the notification JSON document from stdin"},{name:"from-env",type:"string",required:false,description:"Read the notification JSON document from a named environment variable"}];export const NOTIFICATION_ID_FLAG={name:"id",type:"number",required:true,description:"Application-level notification config ID"};export const NOTIFICATION_APP_FLAG=APPCODE_FLAG_OPTIONAL;export function notificationError(code,message,hint){return new CliError(code,1,message,hint)}export function readNotificationId(ctx){const id=ctx.num("id");if(!Number.isSafeInteger(id)||id<=0){throw notificationError("notification_config_id_invalid","--id must be a positive safe integer.")}return id}export function requireNotificationExplicitYes(ctx){if(ctx.bool("dry-run")||ctx.bool("yes"))return;throw notificationError("notification_config_confirmation_required","This notification config mutation requires explicit --yes.","Run the command with --dry-run first, then add --yes after reviewing the plan.")}
|
|
3
|
+
export function readNotificationChannelType(ctx,flagName="type",fallback="EMAIL"){const value=ctx.str(flagName).trim()||fallback;if(!NOTIFICATION_CHANNEL_TYPES.includes(value)){throw CliErrors.validation(`Invalid --${flagName}: ${value}`,`Allowed values: ${NOTIFICATION_CHANNEL_TYPES.join(", ")}.`)}return value}export function assertSingleNotificationSource(ctx){const sources=[];const filePath=ctx.str("file").trim();if(filePath)sources.push({kind:"file",path:filePath});if(ctx.bool("stdin"))sources.push({kind:"stdin"});const envName=ctx.str("from-env").trim();if(envName)sources.push({kind:"env",name:envName});if(sources.length===0){throw CliErrors.validation("Missing notification JSON source.","Use exactly one of --file <path>, --stdin, or --from-env <NAME>.")}if(sources.length>1){throw CliErrors.validation("Notification JSON source is ambiguous.","Use exactly one of --file <path>, --stdin, or --from-env <NAME>.")}return sources[0]}
|
|
4
|
+
export async function readNotificationDocument(ctx,mode){const source=assertSingleNotificationSource(ctx);const sourceLabel=source.kind==="file"?`file ${source.path}`:source.kind==="env"?`environment variable ${source.name}`:"stdin";let raw;try{if(source.kind==="file"){raw=await readFile(source.path,"utf8")}else if(source.kind==="env"){if(!(source.name in process.env)){throw notificationError("notification_config_source_unavailable",`Notification JSON environment variable is not set: ${source.name}`)}raw=process.env[source.name]??""}else{raw=await readStdin()}}catch(error){if(error instanceof CliError)throw error;throw notificationError("notification_config_source_unavailable",`Unable to read notification JSON from ${sourceLabel}.`)}let parsed;try{parsed=JSON.parse(raw)}catch{throw notificationError("notification_config_json_invalid",`Notification JSON from ${sourceLabel} is invalid.`,"Provide one valid JSON object; source contents are not included in errors.")}
|
|
5
|
+
if(!isJsonObject(parsed)){throw notificationError("notification_config_json_invalid",`Notification JSON from ${sourceLabel} must be an object.`)}return validateNotificationDocument(parsed,mode)}export function projectNotificationListConfig(item,index){return{id:typeof item.id==="number"?item.id:null,configCode:requireResponseString(item.configCode,"configCode",index),configName:requireResponseString(item.configName,"configName",index),channelType:requireResponseString(item.channelType,"channelType",index),description:normalizeNullableString(item.description),createTime:normalizeNullableString(item.createTime),updateTime:normalizeNullableString(item.updateTime)}}export function normalizeExactNotificationConfig(item,expectedId,expectedAppCode){if(!Number.isSafeInteger(item.id)||item.id!==expectedId){throw notificationError("notification_config_response_invalid",`Notification config detail did not contain the requested ID ${expectedId}.`)}if(item.appCode!==expectedAppCode){
|
|
6
|
+
throw notificationError("notification_config_response_invalid",`Notification config ${expectedId} does not belong to the resolved app.`)}const configName=requireExactString(item.configName,"configName",expectedId);const configCode=requireExactString(item.configCode,"configCode",expectedId);const channelTypeRaw=requireExactString(item.channelType,"channelType",expectedId);if(!NOTIFICATION_CHANNEL_TYPES.includes(channelTypeRaw)){throw notificationError("notification_config_response_invalid",`Notification config ${expectedId} has an unsupported channelType.`)}const endpointUrlRaw=responseNullableString(item.endpointUrl,"endpointUrl",expectedId);const channelConfigRaw=responseNullableString(item.channelConfig,"channelConfig",expectedId);const description=responseNullableString(item.description,"description",expectedId);const connectTimeout=responseNullableTimeout(item.connectTimeout,"connectTimeout",expectedId)
|
|
7
|
+
;const readTimeout=responseNullableTimeout(item.readTimeout,"readTimeout",expectedId);return{id:expectedId,appCode:expectedAppCode,configCode:configCode,configName:configName,channelType:channelTypeRaw,endpointUrl:redactSensitive(endpointUrlRaw),channelConfig:redactSensitive(channelConfigRaw),description:description,connectTimeout:connectTimeout,readTimeout:readTimeout,endpointUrlRaw:endpointUrlRaw,channelConfigRaw:channelConfigRaw}}export async function requireExactNotificationConfig(appCode,id,operation){let item;try{item=await getNotificationChannelConfig(id,appCode)}catch{throw safeApiFailure(operation,"preflight",`Inspect with rabetbase notification config-list --appcode ${appCode} --type <CHANNEL_TYPE> --format compress; no mutation was submitted.`)}return normalizeExactNotificationConfig(item,id,appCode)}export function projectNotificationConfig(value){return{id:value.id??null,appCode:value.appCode,configCode:value.configCode??null,configName:value.configName,
|
|
8
|
+
channelType:value.channelType,endpointUrl:redactSensitive(value.endpointUrl),channelConfig:redactSensitive(value.channelConfig),description:value.description??null,connectTimeout:value.connectTimeout??null,readTimeout:value.readTimeout??null}}export function notificationSelector(record){return{appCode:record.appCode,id:record.id,configCode:record.configCode,configName:record.configName,channelType:record.channelType}}export function createMutationInput(appCode,document){return{appCode:appCode,configName:document.configName,channelType:document.channelType,...hasOwn(document,"endpointUrl")?{endpointUrl:document.endpointUrl}:{},...hasOwn(document,"channelConfig")?{channelConfig:serializeChannelConfig(document.channelConfig)}:{},...hasOwn(document,"description")?{description:document.description}:{},...hasOwn(document,"connectTimeout")?{connectTimeout:document.connectTimeout}:{},...hasOwn(document,"readTimeout")?{readTimeout:document.readTimeout}:{}}}
|
|
9
|
+
export function mergeUpdateInput(before,patch){return{id:before.id,appCode:before.appCode,configName:patch.configName??before.configName,channelType:patch.channelType??before.channelType,endpointUrl:hasOwn(patch,"endpointUrl")?patch.endpointUrl:before.endpointUrlRaw,channelConfig:hasOwn(patch,"channelConfig")?serializeChannelConfig(patch.channelConfig):before.channelConfigRaw,description:hasOwn(patch,"description")?patch.description:before.description,connectTimeout:hasOwn(patch,"connectTimeout")?patch.connectTimeout:before.connectTimeout,readTimeout:hasOwn(patch,"readTimeout")?patch.readTimeout:before.readTimeout}}export function plannedUpdateProjection(before,patch){return projectNotificationConfig({id:before.id,appCode:before.appCode,configCode:before.configCode,configName:patch.configName??before.configName,channelType:patch.channelType??before.channelType,endpointUrl:hasOwn(patch,"endpointUrl")?patch.endpointUrl:before.endpointUrlRaw,
|
|
10
|
+
channelConfig:hasOwn(patch,"channelConfig")?patch.channelConfig:before.channelConfigRaw,description:hasOwn(patch,"description")?patch.description:before.description,connectTimeout:hasOwn(patch,"connectTimeout")?patch.connectTimeout??DEFAULT_NOTIFICATION_CONNECT_TIMEOUT:before.connectTimeout,readTimeout:hasOwn(patch,"readTimeout")?patch.readTimeout??DEFAULT_NOTIFICATION_READ_TIMEOUT:before.readTimeout})}export function requestedSafeFieldsMatch(before,after,patch){const matches=[];const changed=[];const verifiedFields=[];for(const field of["configName","channelType","description"]){if(!hasOwn(patch,field))continue;verifiedFields.push(field);matches.push(after[field]===patch[field]);changed.push(before[field]!==patch[field]&&after[field]===patch[field])}for(const field of["connectTimeout","readTimeout"]){if(!hasOwn(patch,field))continue;const expected=patch[field]??(field==="connectTimeout"?DEFAULT_NOTIFICATION_CONNECT_TIMEOUT:DEFAULT_NOTIFICATION_READ_TIMEOUT);verifiedFields.push(field)
|
|
11
|
+
;matches.push(after[field]===expected);changed.push(before[field]!==expected&&after[field]===expected)}if(hasOwn(patch,"endpointUrl")&&patch.endpointUrl===null){verifiedFields.push("endpointUrl:null");matches.push(after.endpointUrlRaw===null||after.endpointUrlRaw==="");changed.push(before.endpointUrlRaw!==null&&before.endpointUrlRaw!==""&&(after.endpointUrlRaw===null||after.endpointUrlRaw===""))}return{allMatch:matches.every(Boolean),provesChange:changed.some(Boolean),verifiedFields:verifiedFields}}export function validateNotificationDeleteReadback(items,appCode,channelType){for(const[index,item]of items.entries()){if(!Number.isSafeInteger(item.id)||item.id<=0){throw notificationError("notification_config_response_invalid",`Notification config list item ${index+1} has an invalid id.`)}if(item.appCode!==appCode){throw notificationError("notification_config_response_invalid",`Notification config list item ${index+1} has an invalid appCode.`)}if(item.channelType!==channelType){
|
|
12
|
+
throw notificationError("notification_config_response_invalid",`Notification config list item ${index+1} has an invalid channelType.`)}}}export function safeApiFailure(operation,stage,hint){return notificationError(`notification_config_${operation}_${stage==="mutation"?"failed":`${stage}_unavailable`}`,`Notification config ${operation} ${stage} failed.`,hint)}export function notificationLookupCommand(appCode,channelType){return`rabetbase notification config-list --appcode ${appCode} --type ${channelType} --format compress`}function validateNotificationDocument(value,mode){for(const field of Object.keys(value)){if(FORBIDDEN_IDENTITY_FIELDS.has(field)){throw notificationError("notification_config_field_forbidden",`Notification JSON field "${field}" is controlled by the CLI or server and is forbidden.`)}if(!ALLOWED_INPUT_FIELDS.has(field)){throw notificationError("notification_config_field_unknown",`Unknown notification JSON field "${field}".`)}}
|
|
13
|
+
if(mode==="update"&&Object.keys(value).length===0){throw notificationError("notification_config_update_empty","Update JSON must contain at least one allowed field.")}const document={};if(hasOwn(value,"configName")){document.configName=validateRequiredString(value.configName,"configName",128)}else if(mode==="create"){throw notificationError("notification_config_field_required","Create JSON requires field "+'"configName".')}if(hasOwn(value,"channelType")){if(typeof value.channelType!=="string"){throw invalidFieldType("channelType","a supported string")}const channelType=value.channelType.trim();if(!NOTIFICATION_CHANNEL_TYPES.includes(channelType)){throw notificationError("notification_config_field_invalid",'Notification JSON field "channelType" is unsupported.',`Allowed values: ${NOTIFICATION_CHANNEL_TYPES.join(", ")}.`)}document.channelType=channelType}else if(mode==="create"){throw notificationError("notification_config_field_required","Create JSON requires field "+'"channelType".')}
|
|
14
|
+
for(const[field,maxLength]of[["endpointUrl",512],["description",256]]){if(!hasOwn(value,field))continue;const fieldValue=value[field];if(fieldValue!==null&&typeof fieldValue!=="string"){throw invalidFieldType(field,"a string or null")}if(typeof fieldValue==="string"&&fieldValue.length>maxLength){throw notificationError("notification_config_field_invalid",`Notification JSON field "${field}" cannot exceed ${maxLength} characters.`)}document[field]=fieldValue}if(hasOwn(value,"channelConfig")){const channelConfig=value.channelConfig;if(channelConfig===null&&mode==="create"){throw invalidFieldType("channelConfig","a JSON object")}if(channelConfig!==null&&!isJsonObject(channelConfig)){throw invalidFieldType("channelConfig",mode==="update"?"a JSON object or null":"a JSON object")}if(channelConfig!==null){validateChannelConfigFields(document.channelType,channelConfig)}document.channelConfig=channelConfig}for(const field of["connectTimeout","readTimeout"]){if(!hasOwn(value,field))continue
|
|
15
|
+
;const fieldValue=value[field];if(fieldValue!==null&&(!Number.isSafeInteger(fieldValue)||fieldValue<0)){throw notificationError("notification_config_field_invalid",`Notification JSON field "${field}" must be a non-negative safe integer or null.`)}document[field]=fieldValue}return document}function validateRequiredString(value,field,maxLength){if(typeof value!=="string")throw invalidFieldType(field,"a non-empty string");const normalized=value.trim();if(!normalized){throw notificationError("notification_config_field_invalid",`Notification JSON field "${field}" must be a non-empty string.`)}if(normalized.length>maxLength){throw notificationError("notification_config_field_invalid",`Notification JSON field "${field}" cannot exceed ${maxLength} characters.`)}return normalized}function validateChannelConfigFields(channelType,channelConfig){if(hasOwn(channelConfig,"messageTemplate")){throw forbiddenChannelConfigField("messageTemplate")}if(channelType==="EMAIL"){
|
|
16
|
+
for(const field of EMAIL_RECIPIENT_FIELDS){if(hasOwn(channelConfig,field))throw forbiddenChannelConfigField(field)}}}function forbiddenChannelConfigField(field){return notificationError("notification_config_channel_field_forbidden",`Notification JSON channelConfig field "${field}" is forbidden.`)}function invalidFieldType(field,expected){return notificationError("notification_config_field_invalid",`Notification JSON field "${field}" must be ${expected}.`)}function serializeChannelConfig(value){return value===null||value===undefined?null:JSON.stringify(value)}function redactSensitive(value){return value===null||value===undefined||value===""?null:"<redacted>"}function requireResponseString(value,field,index){if(typeof value!=="string"||value.trim()===""){throw CliErrors.apiError("Invalid notification config response.",`Item ${index+1} is missing required field "${field}".`)}return value.trim()}function requireExactString(value,field,id){if(typeof value!=="string"||value.trim()===""){
|
|
17
|
+
throw notificationError("notification_config_response_invalid",`Notification config ${id} is missing required field "${field}".`)}return value.trim()}function responseNullableString(value,field,id){if(value===undefined||value===null)return null;if(typeof value!=="string"){throw notificationError("notification_config_response_invalid",`Notification config ${id} has invalid field "${field}".`)}return value}function responseNullableTimeout(value,field,id){if(value===undefined||value===null)return null;if(!Number.isSafeInteger(value)||value<0){throw notificationError("notification_config_response_invalid",`Notification config ${id} has invalid field "${field}".`)}return value}function normalizeNullableString(value){return typeof value==="string"?value:null}function isJsonObject(value){return value!==null&&typeof value==="object"&&!Array.isArray(value)}function hasOwn(value,field){return Object.prototype.hasOwnProperty.call(value,field)}async function readStdin(){let data=""
|
|
18
|
+
;process.stdin.setEncoding("utf8");for await(const chunk of process.stdin)data+=chunk;return data}
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{requireDevelopmentUploadFile}from"../../commands/common/local-file.js";import{queryDevelopmentFileUrl,recognizeDevelopmentOcr,uploadDevelopmentFile}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";const SUPPORTED_SCENES=["invoice","general","form","idCard"];const SCENE_TO_LEGACY_TYPE={invoice:"Invoice",general:"General",form:"Table",idCard:"IdCard"};const SCENE_FLAG={name:"scene",type:"string",required:true,enum:[...SUPPORTED_SCENES],description:"OCR scene: invoice, general, form, or idCard"};const IMAGE_FILE_FLAG={name:"image-file",type:"string",description:"Local image or PDF file; uses upload -> query-url -> OCR"};const IMAGE_URL_FLAG={name:"image-url",type:"string",description:"Publicly accessible image or file URL"};function normalizeScene(scene){const normalized=scene.trim().toLowerCase();if(normalized==="idcard"){return"idCard"}if(normalized==="invoice"||normalized==="general"||normalized==="form"){return normalized}
|
|
2
|
+
throw CliErrors.validation(`Unsupported OCR scene: ${scene}. Supported scenes: ${SUPPORTED_SCENES.join(", ")}`)}function selectedInputs(ctx){const imageFile=ctx.str("image-file").trim();const imageUrl=ctx.str("image-url").trim();return{imageFile:imageFile,imageUrl:imageUrl,count:[imageFile,imageUrl].filter(Boolean).length}}function validateInputSelection(ctx){const inputs=selectedInputs(ctx);if(inputs.count!==1){throw CliErrors.validation("Choose exactly one OCR input: --image-file or --image-url.")}return inputs}function withScene(result,scene,sourceFile){return{...result,scene:scene,...sourceFile?{sourceFile:{fileName:sourceFile.fileName,filePath:sourceFile.filePath}}:{}}}const ocrRecognize={service:"ocr",command:"recognize",description:"Extract text and structured fields from voucher-style business documents; not for general image understanding",risk:"read",flags:[SCENE_FLAG,IMAGE_FILE_FLAG,IMAGE_URL_FLAG],async dryRun(ctx){const scene=normalizeScene(ctx.str("scene"))
|
|
3
|
+
;const type=SCENE_TO_LEGACY_TYPE[scene];const inputs=validateInputSelection(ctx);if(inputs.imageUrl){const params=new URLSearchParams({url:inputs.imageUrl,type:type,appCode:ctx.appCode});return{method:"GET",url:`/smartapi/ocr/recognize-text?${params.toString()}`,description:`Preview: recognize ${scene} OCR from URL`}}const file=requireDevelopmentUploadFile(inputs.imageFile,"image-file");return{method:"POST",url:"/smartapi/common/uploadFile",body:{steps:[{method:"POST",url:"/smartapi/common/uploadFile",body:{appCode:ctx.appCode,multipart:{file:file}}},{method:"POST",url:"/smartapi/common/queryFileUrl",body:{filePath:"<filePath returned by /smartapi/common/uploadFile>",downloadFlag:false}},{method:"GET",url:"/smartapi/ocr/recognize-text",query:{appCode:ctx.appCode,url:"<fileUrl returned by /smartapi/common/queryFileUrl>",type:type}}]},description:`Preview: upload local file, query temporary URL, then recognize ${scene} OCR`}},async execute(ctx){
|
|
4
|
+
const scene=normalizeScene(ctx.str("scene"));const type=SCENE_TO_LEGACY_TYPE[scene];const inputs=validateInputSelection(ctx);if(inputs.imageUrl){const data=await recognizeDevelopmentOcr(ctx.appCode,{url:inputs.imageUrl,type:type});return{ok:true,data:withScene(data,scene)}}const file=requireDevelopmentUploadFile(inputs.imageFile,"image-file");const uploaded=await uploadDevelopmentFile(ctx.appCode,file.path);if(!uploaded.filePath){throw CliErrors.apiError("File upload response missing filePath.")}const urlResult=await queryDevelopmentFileUrl(uploaded.filePath,{download:false});if(!urlResult.fileUrl){throw CliErrors.apiError("File URL response missing fileUrl.")}const data=await recognizeDevelopmentOcr(ctx.appCode,{url:urlResult.fileUrl,type:type});return{ok:true,data:withScene(data,scene,uploaded)}}};export const ocrDefinitions=[ocrRecognize];
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import{readFile}from"node:fs/promises";import{dirname,join,resolve}from"node:path";import{fileURLToPath}from"node:url";import{APPCODE_FLAG}from"../../commands/common/flags.js";import{readCustomPageDirectory}from"../../core/page/file-system.js";import{createCustomPage}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";import{buildCustomPageDevelopmentUrl,buildCustomPageEditUrl,validateCustomPageContent}from"./custom/shared.js";const CUSTOM_PAGE_PATTERNS=["BLANK","ONEPAGE","DASHBOARD"];const CUSTOM_PAGE_TEMPLATE_DIR=resolve(dirname(fileURLToPath(import.meta.url)),"../../../templates/custom-pages");export const pageCreate={service:"page",command:"create",description:"Create a JSX Custom Page from a released pattern or local directory",risk:"write",defaultOutputFormat:"compress",structuredErrors:true,rejectedFlags:[{name:"page-type",message:"page create does not accept --page-type.",
|
|
2
|
+
hint:"This command always creates a CUSTOM JSX page; use --page-pattern BLANK, ONEPAGE, DASHBOARD, or --page-dir."},{name:"page-content",message:"page create no longer accepts --page-content.",hint:"Write the complete page files to a local directory and use --page-dir <dir>."}],flags:[{name:"name",type:"string",description:"Optional Custom Page name (1-100 characters)"},{name:"parent-menu-id",type:"number",description:"Optional parent menu id when creating a menu entry"},{name:"page-pattern",type:"string",description:"Built-in Custom Page pattern (cannot be used with --page-dir)",enum:CUSTOM_PAGE_PATTERNS},{name:"page-dir",type:"string",description:"Directory containing all page files (cannot be used with --page-pattern)"},APPCODE_FLAG],async validate(ctx){await readValidatedPageSource(ctx)},async dryRun(ctx){const input=readInput(ctx,await readValidatedPageSource(ctx));return{method:"POST",url:"/smartapi/webcode/page/create",body:{appCode:input.appCode,pageName:input.pageName,
|
|
3
|
+
...input.parentMenuId!=null?{parentMenuId:input.parentMenuId}:{},createMenu:input.createMenu,codeContent:input.files},description:`Would create Custom Page ${JSON.stringify(input.pageName)} and its menu entry.`}},async execute(ctx){const input=readInput(ctx,await readValidatedPageSource(ctx));const created=await createCustomPage(input);if(!Number.isInteger(created.pageId)||created.pageId<=0){throw CliErrors.apiError("Custom Page creation did not return a valid pageId.")}const pageUrl=buildCustomPageDevelopmentUrl(input.appCode,created.menuPath);const editPageUrl=buildCustomPageEditUrl(input.appCode,created.pageId);return{ok:true,data:{operation:"page.create",pageType:"CUSTOM",pagePattern:readPagePattern(ctx),selector:{appCode:input.appCode,pageName:input.pageName},before:null,after:{pageId:created.pageId,pageName:created.pageName,appCode:created.appCode,version:created.version,menuId:created.menuId,menuPath:created.menuPath,files:created.files??Object.keys(input.files)},dryRun:false,
|
|
4
|
+
request:input,...pageUrl?{pageUrl:pageUrl}:{},...editPageUrl?{editPageUrl:editPageUrl}:{},warnings:pageUrl?[]:["Custom Page was created, but a link to its latest saved content could not be generated."]},message:`Created Custom Page ${created.pageId}.`}}};function readPagePattern(ctx){const pattern=ctx.str("page-pattern").trim();const pageDirectory=ctx.str("page-dir").trim();if(pattern&&pageDirectory){throw CliErrors.validation("--page-pattern and --page-dir cannot be used together.")}if(pageDirectory)return null;if(!pattern){throw CliErrors.validation("Provide --page-pattern BLANK, ONEPAGE, DASHBOARD, or --page-dir <dir>.")}if(!CUSTOM_PAGE_PATTERNS.includes(pattern)){throw CliErrors.validation("--page-pattern must be BLANK, ONEPAGE, or DASHBOARD.")}return pattern}async function readPageSource(ctx){const pageDirectory=ctx.str("page-dir").trim();const pattern=readPagePattern(ctx);if(pattern===null){const files=await readCustomPageDirectory(pageDirectory)
|
|
5
|
+
;if(Object.keys(files).length===0){throw CliErrors.validation("--page-dir must contain at least one page file.")}return files}let content;try{content=await readFile(join(CUSTOM_PAGE_TEMPLATE_DIR,`${pattern.toLowerCase()}.json`),"utf8")}catch{throw CliErrors.validation(`Custom Page pattern not found: ${pattern}.`)}let files;try{files=JSON.parse(content)}catch{throw CliErrors.validation(`Invalid Custom Page pattern: ${pattern}.`)}if(!files||typeof files!=="object"||Array.isArray(files)||Object.values(files).some(file=>typeof file!=="string")){throw CliErrors.validation(`Invalid Custom Page pattern: ${pattern}.`)}return files}async function readValidatedPageSource(ctx){const files=await readPageSource(ctx);await validateCustomPageContent(files);return files}function readInput(ctx,files){const pageName=ctx.str("name").trim()||`Custom_page_${Date.now()}`;if(pageName.length>100){throw CliErrors.validation("pageName cannot exceed 100 characters.")}
|
|
6
|
+
const parentMenuId=ctx.num("parent-menu-id",NaN);const hasParentMenuId=!Number.isNaN(parentMenuId);if(hasParentMenuId&&(!Number.isInteger(parentMenuId)||parentMenuId<=0)){throw CliErrors.validation("--parent-menu-id must be a positive integer.")}return{appCode:ctx.appCode,pageName:pageName,...hasParentMenuId?{parentMenuId:parentMenuId}:{},createMenu:true,files:files}}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{getCustomPageSource}from"../../../core/api-client.js";import{buildCustomPageEditUrl,buildCustomPageRuntimeUrl,readCustomPageId,CUSTOM_PAGE_APPCODE_FLAG_OPTIONAL,resolveCustomPageDevelopmentUrl}from"./shared.js";export const pageCustomDetail={service:"page",command:"custom-detail",description:"Show a Custom Page and all of its files",risk:"read",defaultOutputFormat:"compress",structuredErrors:true,requiresAppCode:false,flags:[{name:"id",type:"number",required:true,description:"Custom Page ID"},CUSTOM_PAGE_APPCODE_FLAG_OPTIONAL],async validate(ctx){readCustomPageId(ctx)},async execute(ctx){const pageId=readCustomPageId(ctx);const detail=await getCustomPageSource(pageId);const{bundle:_bundle,createTime:createTime,updateTime:updateTime,...page}=detail;const resolvedPageId=detail.id??pageId;const appCode=detail.appCode?.trim()||ctx.str("appcode").trim();const runtimePageUrl=buildCustomPageRuntimeUrl(appCode,detail.pageCode)
|
|
2
|
+
;const editPageUrl=buildCustomPageEditUrl(appCode,resolvedPageId);const pageUrl=await resolveCustomPageDevelopmentUrl(appCode,resolvedPageId,ctx.cookie);return{ok:true,data:{...page,...runtimePageUrl?{runtimePageUrl:runtimePageUrl}:{},...pageUrl?{pageUrl:pageUrl}:{},...editPageUrl?{editPageUrl:editPageUrl}:{},...createTime==null?{}:{createTime:formatTime(createTime)},...updateTime==null?{}:{updateTime:formatTime(updateTime)}},message:`Retrieved Custom Page ${pageId}.`}}};function formatTime(value){const date=new Date(value);if(Number.isNaN(date.getTime()))return String(value);const datePart=[date.getFullYear(),String(date.getMonth()+1).padStart(2,"0"),String(date.getDate()).padStart(2,"0")].join("-");const timePart=[String(date.getHours()).padStart(2,"0"),String(date.getMinutes()).padStart(2,"0"),String(date.getSeconds()).padStart(2,"0")].join(":");return`${datePart} ${timePart}`}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{APPCODE_FLAG_OPTIONAL}from"../../../commands/common/flags.js";import{fetchMenuSnapshot}from"../../../commands/menu/shared/facts.js";import{buildCustomPageDevelopmentUrl,buildCustomPageEditUrl,buildCustomPageRuntimeUrl}from"./shared.js";export const pageCustomList={service:"page",command:"custom-list",description:"List Custom Pages in the current app",risk:"read",defaultOutputFormat:"compress",structuredErrors:true,flags:[APPCODE_FLAG_OPTIONAL],async execute(ctx){const pages=(await fetchMenuSnapshot(ctx.appCode,ctx.cookie)).menus.flatMap(menu=>{if(menu.type!=="react"||menu.pageId==null)return[];const pageUrl=buildCustomPageDevelopmentUrl(ctx.appCode,menu.path);const runtimePageUrl=buildCustomPageRuntimeUrl(ctx.appCode,menu.path);const editPageUrl=buildCustomPageEditUrl(ctx.appCode,menu.pageId);return[{pageId:menu.pageId,label:menu.label,path:menu.path,...pageUrl?{pageUrl:pageUrl}:{},...runtimePageUrl?{runtimePageUrl:runtimePageUrl}:{},...editPageUrl?{editPageUrl:editPageUrl}:{}}]
|
|
2
|
+
});return{ok:true,data:{pages:pages},message:pages.length===0?"No Custom Pages found.":`Found ${pages.length} Custom Page(s).`}}};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{getCustomPageSource,publishCustomPage}from"../../../core/api-client.js";import{CliErrors}from"../../../errors.js";import{buildCustomPageEditUrl,buildCustomPageRuntimeUrl,readCustomPageId,resolveCustomPageDevelopmentUrl}from"./shared.js";export const pageCustomPublish={service:"page",command:"custom-publish",description:"Publish the latest saved content of a Custom Page",risk:"write",defaultOutputFormat:"compress",structuredErrors:true,requiresAppCode:false,flags:[{name:"id",type:"number",required:true,description:"Custom Page ID"},{name:"remark",type:"string",description:"Optional publish remark"}],async validate(ctx){readCustomPageId(ctx)},async dryRun(ctx){const input=readInput(ctx);return{method:"POST",url:"/smartapi/webcode/file/publish",body:{id:input.pageId,...input.remark?{remark:input.remark}:{}},description:`Would publish Custom Page ${input.pageId}.`}},async execute(ctx){const input=readInput(ctx);await getCustomPageSource(input.pageId)
|
|
2
|
+
;const publishedPageId=await publishCustomPage(input);if(!Number.isInteger(publishedPageId)||publishedPageId!==input.pageId){throw CliErrors.apiError("Custom Page publish did not return the expected page ID.")}const after=await getCustomPageSource(input.pageId);if(after.status!=="FORMAL"){throw CliErrors.apiError(`Custom Page publish did not reach published status: ${after.status??"unknown"}.`)}const appCode=after.appCode?.trim();const editPageUrl=buildCustomPageEditUrl(appCode,input.pageId);const pageUrl=await resolveCustomPageDevelopmentUrl(appCode,input.pageId,ctx.cookie);const data=buildMutationData(input,true,pageUrl,editPageUrl);if(appCode&&!pageUrl){data.warnings.push("Published successfully, but a link to the latest saved content could not be generated.")}const runtimePageUrl=buildCustomPageRuntimeUrl(after.appCode,after.pageCode);if(runtimePageUrl){data.runtimePageUrl=runtimePageUrl}else{
|
|
3
|
+
data.warnings.push("Published successfully, but a link to the published page could not be generated.")}return{ok:true,data:data,message:`Published Custom Page ${input.pageId}.`}}};function readInput(ctx){const pageId=readCustomPageId(ctx);const remark=ctx.str("remark").trim();return{pageId:pageId,...remark?{remark:remark}:{}}}function buildMutationData(input,published=false,pageUrl,editPageUrl){return{operation:"page.custom-publish",selector:{pageId:input.pageId},before:null,after:{pageId:input.pageId,status:"FORMAL"},dryRun:!published,request:input,...pageUrl?{pageUrl:pageUrl}:{},...editPageUrl?{editPageUrl:editPageUrl}:{},warnings:[]}}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{APPCODE_FLAG_OPTIONAL}from"../../../commands/common/flags.js";import{fetchMenuSnapshot}from"../../../commands/menu/shared/facts.js";import{getAppBaseUrl,getPublishedAppDomain}from"../../../constant/domain.js";import{CliErrors}from"../../../errors.js";import{validateCustomPageSourceFiles}from"./syntax.js";export const CUSTOM_PAGE_APPCODE_FLAG_OPTIONAL={...APPCODE_FLAG_OPTIONAL,description:"Optional app code resolved from page ID when omitted"};function trimOptional(value){return value?.trim()||undefined}export function buildCustomPageRuntimeUrl(appCode,pageCode){const normalizedAppCode=trimOptional(appCode);const normalizedPageCode=trimOptional(pageCode);if(!normalizedAppCode||!normalizedPageCode)return undefined;return`${getPublishedAppDomain(normalizedAppCode)}/${encodeURIComponent(normalizedPageCode)}`}export function buildCustomPageDevelopmentUrl(appCode,menuPath){const normalizedAppCode=trimOptional(appCode);const normalizedMenuPath=trimOptional(menuPath)
|
|
2
|
+
;if(!normalizedAppCode||!normalizedMenuPath)return undefined;return`${getAppBaseUrl(normalizedAppCode)}/pages/${encodeURIComponent(normalizedMenuPath)}`}export async function resolveCustomPageDevelopmentUrl(appCode,pageId,cookie){const normalizedAppCode=trimOptional(appCode);if(!normalizedAppCode)return undefined;try{const menu=(await fetchMenuSnapshot(normalizedAppCode,cookie)).menus.find(item=>item.type==="react"&&item.pageId===pageId);return buildCustomPageDevelopmentUrl(normalizedAppCode,menu?.path)}catch{return undefined}}export function buildCustomPageEditUrl(appCode,pageId){const normalizedAppCode=trimOptional(appCode);if(!normalizedAppCode)return;const normalizedPageId=trimOptional(String(pageId??""));if(!normalizedPageId)return;return`${getAppBaseUrl(normalizedAppCode)}/ide/${encodeURIComponent(normalizedPageId)}`}export async function validateCustomPageContent(pageContent){const issues=await validateCustomPageSourceFiles(pageContent);if(issues.length>0){
|
|
3
|
+
throw CliErrors.validation(`Invalid Custom Page content: ${issues.map(issue=>`${issue.file}: ${issue.message}`).join("; ")}`)}}export function readCustomPageId(ctx){const pageId=ctx.num("id");if(!Number.isInteger(pageId)||pageId<=0){throw CliErrors.validation("--id must be a positive integer.")}return pageId}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{format}from"prettier";const SOURCE_PARSERS={".js":"babel",".jsx":"babel",".ts":"typescript",".tsx":"typescript"};const CUSTOM_PAGE_EXTENSIONS=[".jsx",".tsx"];export async function validateCustomPageSourceFiles(pageContent){const sourceFiles=Object.entries(pageContent).filter(([filePath])=>getParser(filePath));if(!sourceFiles.some(([filePath])=>isReactSourceFile(filePath))){return[{file:"page files",message:"Missing React source file with extension .jsx or .tsx"}]}const results=await Promise.all(sourceFiles.map(async([file,content])=>{try{await format(content,{parser:getParser(file)});return undefined}catch(error){return{file:file,message:error instanceof Error?error.message:String(error)}}}));return results.filter(issue=>issue!==undefined)}function getParser(filePath){const lower=filePath.trim().toLowerCase();return Object.entries(SOURCE_PARSERS).find(([extension])=>lower.endsWith(extension))?.[1]}function isReactSourceFile(filePath){const lower=filePath.trim().toLowerCase()
|
|
2
|
+
;return CUSTOM_PAGE_EXTENSIONS.some(extension=>lower.endsWith(extension))}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{getCustomPageSource,updateCustomPageContent}from"../../../core/api-client.js";import{readCustomPageDirectory}from"../../../core/page/file-system.js";import{CliErrors}from"../../../errors.js";import{buildCustomPageEditUrl,resolveCustomPageDevelopmentUrl,readCustomPageId,CUSTOM_PAGE_APPCODE_FLAG_OPTIONAL,validateCustomPageContent}from"./shared.js";export const pageCustomUpdate={service:"page",command:"custom-update",description:"Save all files of a Custom Page",risk:"write",defaultOutputFormat:"compress",structuredErrors:true,requiresAppCode:false,rejectedFlags:[{name:"page-content",message:"page custom-update no longer accepts --page-content.",hint:"Write the complete page files to a local directory and use --page-dir <dir>."}],flags:[{name:"id",type:"number",required:true,description:"Custom Page ID"},{name:"page-dir",type:"string",required:true,description:"Directory containing all complete page files"},CUSTOM_PAGE_APPCODE_FLAG_OPTIONAL],async validate(ctx){
|
|
2
|
+
readCustomPageId(ctx);await readValidatedPageContent(ctx)},async dryRun(ctx){const input=await readInput(ctx);return{method:"POST",url:"/smartapi/webcode/page/update/content",body:{id:input.pageId,codeContent:input.pageContent},description:`Would save all files of Custom Page ${input.pageId}.`}},async execute(ctx){const input=await readInput(ctx);const updated=await updateCustomPageContent({pageId:input.pageId,pageContent:input.pageContent});if(!Number.isInteger(updated.newVersion)||updated.newVersion<=0){throw CliErrors.apiError("Custom Page update did not create a new version.")}const editPageUrl=buildCustomPageEditUrl(input.appCode,input.pageId);const pageUrl=await resolveCustomPageDevelopmentUrl(input.appCode,input.pageId,ctx.cookie);return{ok:true,data:{operation:"page.custom-update",selector:{appCode:input.appCode,pageId:input.pageId},before:null,after:{pageId:updated.pageId,version:updated.newVersion,pageContent:input.pageContent},dryRun:false,request:input,...pageUrl?{
|
|
3
|
+
pageUrl:pageUrl}:{},...editPageUrl?{editPageUrl:editPageUrl}:{},warnings:pageUrl?[]:["Custom Page was updated, but a link to its latest saved content could not be generated."]},message:`Updated Custom Page ${input.pageId}.`}}};async function readInput(ctx){const pageId=readCustomPageId(ctx);const appCode=ctx.str("appcode").trim()||(await getCustomPageSource(pageId)).appCode?.trim();if(!appCode){throw CliErrors.validation(`Cannot determine the appCode for Custom Page ${pageId}.`)}return{appCode:appCode,pageId:pageId,pageContent:await readValidatedPageContent(ctx)}}async function readValidatedPageContent(ctx){const pageContent=await readCustomPageDirectory(ctx.str("page-dir"));await validateCustomPageContent(pageContent);return pageContent}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{APPCODE_FLAG_OPTIONAL,DATASETCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{assessDataListPageState,getUndeletedRelatedPages,loadDatasetDetailForPage,loadDataListPageStatusForGenerate,serializeDryRunDescription,validateDatasetSelector}from"../../commands/page/shared.js";export const pageDataListStatus={service:"page",command:"data-list-status",description:"Query Data List Page facts for a dataset",risk:"read",defaultOutputFormat:"compress",flags:[APPCODE_FLAG_OPTIONAL,DATASETCODE_FLAG_OPTIONAL,{name:"alias",type:"string",description:"Dataset alias from api.ts (resolves to dataset code automatically)"}],async validate(ctx){validateDatasetSelector(ctx)},async dryRun(ctx){const dataset=await loadDatasetDetailForPage(ctx);return{method:"GET",url:`/smartapi/lovrabet/dataset/${dataset.code}/standard-page-status?appCode=${encodeURIComponent(ctx.appCode)}`,description:serializeDryRunDescription({dataset:{id:dataset.id,code:dataset.code,name:dataset.name},
|
|
2
|
+
action:"query-data-list-status"})}},async execute(ctx){const dataset=await loadDatasetDetailForPage(ctx);const dataListPageStatus=await loadDataListPageStatusForGenerate(ctx,dataset.code);const undeletedPages=getUndeletedRelatedPages(dataset);const assessment=assessDataListPageState(dataset.code,dataListPageStatus,{fallbackUndeletedPages:undeletedPages});return{ok:true,data:{datasetCode:dataset.code,precheckSource:dataListPageStatus?.source??"related-pages-fallback",status:assessment.status,manualResolutionRequired:assessment.manualResolutionRequired,nextAction:assessment.nextAction,dataListPageStatus:dataListPageStatus,relatedPages:{total:dataset.relatedPages.length,undeletedCount:undeletedPages.length}}}}};
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import{APPCODE_FLAG_OPTIONAL,DATASETCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{assessGenerateOperationState,assessDataListPageState,buildPageGenerateOperationStatusQueryCommand,buildDataListPageStatusQueryCommand,createPageGenerateClientOperationId,getUndeletedRelatedPages,loadDatasetDetailForPage,loadDataListPageStatusForGenerate,serializeDryRunDescription,validateDatasetSelector}from"../../commands/page/shared.js";import{startGenerateDataListPages}from"../../core/api-client.js";export const pageGenerateStart={service:"page",command:"generate-start",description:"Start async Data List Page generation from a dataset",risk:"write",defaultOutputFormat:"compress",rejectedFlags:[{name:"page-type",message:"page generate-start does not accept --page-type.",hint:"This command always generates a DATA_LIST page from a dataset."},{name:"page-pattern",message:"page generate-start does not accept --page-pattern.",hint:"DATA_LIST currently has one fixed pattern: CRUD_PAGE_SET."
|
|
2
|
+
}],flags:[APPCODE_FLAG_OPTIONAL,DATASETCODE_FLAG_OPTIONAL,{name:"alias",type:"string",description:"Dataset alias from api.ts (resolves to dataset code automatically)"},{name:"apply",type:"boolean",description:"Actually execute the generation. Without this flag, only a dry-run preview is shown."}],async validate(ctx){validateDatasetSelector(ctx)},async dryRun(ctx){const prepared=await prepare(ctx);return{method:"POST",url:`/smartapi/lovrabet/dataset/${prepared.dataset.code}/generate-standard-pages/start`,body:{appCode:ctx.appCode,clientOperationId:prepared.clientOperationId},description:serializeDryRunDescription({dataset:{id:prepared.dataset.id,code:prepared.dataset.code,name:prepared.dataset.name,fieldCount:prepared.dataset.fieldCount},precheckSource:prepared.dataListPageStatus?.source??"related-pages-fallback",action:"generate-start",clientOperationId:prepared.clientOperationId,plannedStatus:prepared.precheck.status,reason:prepared.precheck.message})}},async execute(ctx){
|
|
3
|
+
if(!ctx.bool("apply")){const preview=await pageGenerateStart.dryRun(ctx);return{ok:true,message:"Dry-run preview (pass --apply to execute the generation)",data:preview}}const prepared=await prepare(ctx);if(!prepared.precheck.allowGenerate){return{ok:false,message:prepared.precheck.message,data:{datasetCode:prepared.dataset.code,pageType:"DATA_LIST",pagePattern:"CRUD_PAGE_SET",clientOperationId:prepared.clientOperationId,precheckSource:prepared.dataListPageStatus?.source??"related-pages-fallback",status:prepared.precheck.status,manualResolutionRequired:prepared.precheck.manualResolutionRequired,nextAction:prepared.precheck.nextAction,query:{command:buildDataListPageStatusQueryCommand(prepared.dataset.code,ctx.appCode)},dataListPageStatus:prepared.dataListPageStatus}}}const startResult=await startGenerateDataListPages(ctx.appCode,prepared.dataset.code,{clientOperationId:prepared.clientOperationId})
|
|
4
|
+
;const terminalFacts=startResult.status==="SUCCESS"||startResult.status==="PARTIAL_SUCCESS"?await loadDataListPageStatusForGenerate(ctx,prepared.dataset.code):null;const assessment=assessGenerateOperationState(prepared.dataset.code,startResult.status,terminalFacts);return{ok:true,message:startResult.reused?"Reusing an existing generate task":"Submitted a generate task",data:{datasetCode:prepared.dataset.code,appCode:ctx.appCode,pageType:"DATA_LIST",pagePattern:"CRUD_PAGE_SET",taskId:startResult.taskId??null,operationId:startResult.operationId??null,clientOperationId:prepared.clientOperationId,jobStatus:startResult.status??null,progressRate:typeof startResult.progressRate==="number"?startResult.progressRate:null,currentStep:startResult.currentStep??null,reused:startResult.reused===true,status:assessment.status,manualResolutionRequired:assessment.manualResolutionRequired,nextAction:assessment.nextAction,query:{command:buildPageGenerateOperationStatusQueryCommand(prepared.dataset.code,{
|
|
5
|
+
appCode:ctx.appCode,taskId:startResult.taskId,operationId:startResult.operationId,clientOperationId:prepared.clientOperationId})},dataListPageStatus:terminalFacts}}}};async function prepare(ctx){const dataset=await loadDatasetDetailForPage(ctx);const dataListPageStatus=await loadDataListPageStatusForGenerate(ctx,dataset.code);const undeletedPages=getUndeletedRelatedPages(dataset);return{dataset:dataset,dataListPageStatus:dataListPageStatus,clientOperationId:createPageGenerateClientOperationId(),precheck:assessDataListPageState(dataset.code,dataListPageStatus,{fallbackUndeletedPages:undeletedPages})}}
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{APPCODE_FLAG_OPTIONAL,DATASETCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{assessGenerateOperationState,buildPageGenerateOperationStatusQueryCommand,loadDatasetDetailForPage,loadDataListPageStatusForGenerate,serializeDryRunDescription,validateDatasetSelector,validateGenerateOperationSelector}from"../../commands/page/shared.js";import{getGenerateDataListPagesStatus}from"../../core/api-client.js";export const pageGenerateStatus={service:"page",command:"generate-status",description:"Query Data List Page generate operation status",risk:"read",defaultOutputFormat:"compress",flags:[APPCODE_FLAG_OPTIONAL,DATASETCODE_FLAG_OPTIONAL,{name:"alias",type:"string",description:"Dataset alias from api.ts (resolves to dataset code automatically)"},{name:"task-id",type:"string",description:"Generic task id returned by page generate-start"},{name:"operation-id",type:"string",description:"Async operation id returned by page generate-start"},{name:"client-operation-id",
|
|
2
|
+
type:"string",description:"Client recovery/idempotency id when operationId is unavailable or lost"}],async validate(ctx){validateDatasetSelector(ctx);validateGenerateOperationSelector(ctx)},async dryRun(ctx){const dataset=await loadDatasetDetailForPage(ctx);const taskId=ctx.str("task-id");const operationId=ctx.str("operation-id");const clientOperationId=ctx.str("client-operation-id");const query=new URLSearchParams({appCode:ctx.appCode});if(taskId){query.set("taskId",taskId)}if(operationId){query.set("operationId",operationId)}if(clientOperationId){query.set("clientOperationId",clientOperationId)}return{method:"GET",url:`/smartapi/lovrabet/dataset/${dataset.code}/generate-standard-pages/status?${query.toString()}`,description:serializeDryRunDescription({dataset:{id:dataset.id,code:dataset.code,name:dataset.name},action:"query-generate-operation-status",taskId:taskId||undefined,operationId:operationId||undefined,clientOperationId:clientOperationId||undefined})}},async execute(ctx){
|
|
3
|
+
const dataset=await loadDatasetDetailForPage(ctx);const requestedTaskId=ctx.str("task-id");const requestedOperationId=ctx.str("operation-id");const requestedClientOperationId=ctx.str("client-operation-id");const job=await getGenerateDataListPagesStatus(ctx.appCode,dataset.code,{taskId:requestedTaskId||undefined,operationId:requestedOperationId||undefined,clientOperationId:requestedClientOperationId||undefined});const shouldLoadFacts=job.status==="SUCCESS"||job.status==="PARTIAL_SUCCESS";const dataListPageStatus=shouldLoadFacts?await loadDataListPageStatusForGenerate(ctx,dataset.code):null;const assessment=assessGenerateOperationState(dataset.code,job.status,dataListPageStatus);const resolvedTaskId=job.taskId??requestedTaskId??undefined;const resolvedOperationId=job.operationId??requestedOperationId??undefined;const resolvedClientOperationId=job.clientOperationId??requestedClientOperationId??undefined;return{ok:true,
|
|
4
|
+
message:assessment.status==="operation_failed"?job.errorMsg||assessment.message:assessment.message,data:{datasetCode:dataset.code,appCode:ctx.appCode,taskId:resolvedTaskId,operationId:resolvedOperationId,clientOperationId:resolvedClientOperationId,jobStatus:job.status??null,progressRate:typeof job.progressRate==="number"?job.progressRate:null,currentStep:job.currentStep??null,errorMsg:job.errorMsg??null,status:assessment.status,manualResolutionRequired:assessment.manualResolutionRequired,nextAction:assessment.nextAction,query:{command:buildPageGenerateOperationStatusQueryCommand(dataset.code,{appCode:ctx.appCode,taskId:resolvedTaskId,operationId:resolvedOperationId,clientOperationId:resolvedClientOperationId})},dataListPageStatus:dataListPageStatus,result:job.result??null}}}};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{pageGenerateStart}from"../../commands/page/generate-start.js";import{pageGenerateStatus}from"../../commands/page/generate-status.js";import{pageDataListStatus}from"../../commands/page/data-list-status.js";import{pageSync}from"../../commands/page/sync.js";import{pagePull}from"../../commands/page/pull.js";import{pagePush}from"../../commands/page/push.js";import{pageRelationAudit}from"../../commands/page/relation-audit.js";import{pageRestore}from"../../commands/page/restore.js";import{pageCreate}from"../../commands/page/create.js";import{pageCustomDetail}from"../../commands/page/custom/detail.js";import{pageCustomList}from"../../commands/page/custom/list.js";import{pageCustomPublish}from"../../commands/page/custom/publish.js";import{pageCustomUpdate}from"../../commands/page/custom/update.js"
|
|
2
|
+
;export const pageDefinitions=[pageGenerateStart,pageGenerateStatus,pageDataListStatus,pageRelationAudit,pageSync,pagePull,pagePush,pageRestore,pageCreate,pageCustomList,pageCustomDetail,pageCustomPublish,pageCustomUpdate];
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import{writeFile}from"node:fs/promises";import{APPCODE_FLAG_OPTIONAL,DATASETCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{getPageIdFlag,loadDatasetDetailForPage,loadPageDetailForPage,selectVersionTagGroup,serializeDryRunDescription,validatePageTargetSelector}from"../../commands/page/shared.js";import{computePageContentHash,computePageFileHash,serializePageSchemaForFile}from"../../core/page/hash.js";import{ensureParentDirectory,fileExists,loadPageProjectConfig,resolvePageFilePath}from"../../core/page/file-system.js";import{createEmptyPageLock,ensurePageLockScope,readPageLockFile,writePageLockFile}from"../../core/page/lock.js";import{CliErrors}from"../../errors.js";export const pagePull={service:"page",command:"pull",description:"Pull page schema to local files",risk:"read",defaultOutputFormat:"compress",flags:[APPCODE_FLAG_OPTIONAL,{name:"id",type:"number",description:"Page ID"},DATASETCODE_FLAG_OPTIONAL,{name:"alias",type:"string",
|
|
2
|
+
description:"Dataset alias from api.ts (resolves to dataset code automatically)"},{name:"version-tag",type:"string",description:"Page group version tag (batch mode only)"},{name:"force",type:"boolean",description:"Overwrite local files even when unsynced local changes exist"}],async validate(ctx){validatePageTargetSelector(ctx)},async dryRun(ctx){const plan=await buildPullPlan(ctx);return{method:"GET",url:plan.mode==="single"?`/smartapi/lovrabet/detail?pageId=${plan.items[0]?.detail.pageId??""}`:"/smartapi/lovrabet/detail (per selected page)",body:{appCode:ctx.appCode,mode:plan.mode,targetDatasetCode:plan.datasetCode??null,pages:plan.items.map(toPreviewItem)},description:serializeDryRunDescription({mode:plan.mode,datasetCode:plan.datasetCode??null,totalCandidates:plan.items.length,totalWouldPull:plan.items.filter(item=>item.status==="would_pull").length,totalConflicts:plan.items.filter(item=>item.status==="conflict").length})}},async execute(ctx){
|
|
3
|
+
const config=loadPageProjectConfig(ctx.appCode);const rawLock=await readPageLockFile(config.lockFilePath);const{lockData:lockData,appLock:appLock}=ensurePageLockScope(rawLock??createEmptyPageLock(),ctx.appCode);const plan=await buildPullPlan(ctx);const force=ctx.bool("force");if(plan.mode==="single"&&plan.items[0]?.status==="conflict"&&!force){throw CliErrors.validation(`Local page file has unsynced changes: ${plan.items[0].localPath}`,"Use --force to overwrite local changes.")}const pulledPages=[];const skippedPages=[];for(const item of plan.items){if(item.status==="conflict"&&!force){skippedPages.push({pageId:item.detail.pageId,type:item.detail.type,title:item.detail.name,localPath:item.localPath,reason:item.reason??"local unsynced changes"});continue}await ensureParentDirectory(item.localPath);const content=serializePageSchemaForFile(item.detail.code);await writeFile(item.localPath,content,"utf8");appLock.pages[String(item.detail.pageId)]=buildLockEntry(item.detail,content)
|
|
4
|
+
;pulledPages.push({pageId:item.detail.pageId,type:item.detail.type,title:item.detail.name,localPath:item.localPath})}appLock.lastSync=(new Date).toISOString();await writePageLockFile(config.lockFilePath,lockData);return{ok:true,message:`Pull complete: ${pulledPages.length} pulled, ${skippedPages.length} skipped`,data:{appCode:ctx.appCode,pulledPages:pulledPages,skippedPages:skippedPages,totalPulled:pulledPages.length,totalSkipped:skippedPages.length}}}};async function buildPullPlan(ctx){const config=loadPageProjectConfig(ctx.appCode);const rawLock=await readPageLockFile(config.lockFilePath);const{appLock:appLock}=ensurePageLockScope(rawLock??createEmptyPageLock(),ctx.appCode);const pageId=getPageIdFlag(ctx);if(pageId!==undefined){const detail=await loadPageDetailForPage(ctx,pageId);return{mode:"single",items:[await inspectPullTarget(config,appLock.pages[String(detail.pageId)],detail)]}}const dataset=await loadDatasetDetailForPage(ctx)
|
|
5
|
+
;const activePages=dataset.relatedPages.filter(page=>!page.deleted);if(activePages.length===0){throw CliErrors.validation(`Dataset "${dataset.code}" has no undeleted related pages.`)}const details=await Promise.all(activePages.map(page=>loadPageDetailForPage(ctx,page.id)));const selected=selectVersionTagGroup(details,detail=>detail.versionTag,ctx.str("version-tag"));return{mode:"batch",datasetCode:dataset.code,items:await Promise.all(selected.items.map(detail=>inspectPullTarget(config,appLock.pages[String(detail.pageId)],detail)))}}async function inspectPullTarget(config,lockEntry,detail){const localPath=resolvePageFilePath(config,detail.pageId,detail.type);const localExists=await fileExists(localPath);if(!localExists){const content=serializePageSchemaForFile(detail.code);return{detail:detail,localPath:localPath,localHash:computePageContentHash(content),status:"would_pull"}}const localHash=await computePageFileHash(localPath);if(!lockEntry||localHash!==lockEntry.hash){return{
|
|
6
|
+
detail:detail,localPath:localPath,localHash:localHash,status:"conflict",reason:"local unsynced changes"}}return{detail:detail,localPath:localPath,localHash:localHash,status:"would_pull"}}function buildLockEntry(detail,content){return{hash:computePageContentHash(content),pageId:detail.pageId,pageVersion:detail.pageVersion,type:detail.type,title:detail.name,datasetIds:detail.datasetIds,versionTag:detail.versionTag}}function toPreviewItem(item){return{pageId:item.detail.pageId,type:item.detail.type,title:item.detail.name,localPath:item.localPath,status:item.status,...item.reason?{reason:item.reason}:{}}}
|