@lovrabet/rabetbase-cli 2.5.13-beta.1 → 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_0x3c2664=a197_0x2402;(function(_0xc63f7,_0x260cb1){const _0x23c71f=a197_0x2402,_0x48f7eb=_0xc63f7();while(!![]){try{const _0x1cfcc8=parseInt(_0x23c71f(0xce))/0x1*(parseInt(_0x23c71f(0x106))/0x2)+-parseInt(_0x23c71f(0x11a))/0x3+-parseInt(_0x23c71f(0x127))/0x4*(-parseInt(_0x23c71f(0xd6))/0x5)+parseInt(_0x23c71f(0x141))/0x6*(-parseInt(_0x23c71f(0xc9))/0x7)+parseInt(_0x23c71f(0xda))/0x8+parseInt(_0x23c71f(0xf9))/0x9+-parseInt(_0x23c71f(0x146))/0xa;if(_0x1cfcc8===_0x260cb1)break;else _0x48f7eb['push'](_0x48f7eb['shift']());}catch(_0x3e98bd){_0x48f7eb['push'](_0x48f7eb['shift']());}}}(a197_0x5429,0x46ad9));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_0x3c2664(0xdd),'FEISHU','DINGTALK',a197_0x3c2664(0xe0),a197_0x3c2664(0x11e)];export const DEFAULT_NOTIFICATION_CONNECT_TIMEOUT=0x1388;export const DEFAULT_NOTIFICATION_READ_TIMEOUT=0x2710;const ALLOWED_INPUT_FIELDS=new Set([a197_0x3c2664(0xf5),'channelType',a197_0x3c2664(0xc7),a197_0x3c2664(0x129),a197_0x3c2664(0xf4),a197_0x3c2664(0x10d),a197_0x3c2664(0xd7)]),FORBIDDEN_IDENTITY_FIELDS=new Set(['id',a197_0x3c2664(0xdc),a197_0x3c2664(0x147),a197_0x3c2664(0x142)]),EMAIL_RECIPIENT_FIELDS=new Set([a197_0x3c2664(0x116),a197_0x3c2664(0x148),a197_0x3c2664(0x104),'bccList',a197_0x3c2664(0x109),a197_0x3c2664(0x114),a197_0x3c2664(0xcb),'to','cc']);export const NOTIFICATION_INPUT_FLAGS=[{'name':a197_0x3c2664(0xcd),'type':a197_0x3c2664(0x13a),'required':![],'description':a197_0x3c2664(0x12e)},{'name':a197_0x3c2664(0x13d),'type':a197_0x3c2664(0x115),'required':![],'default':![],'description':a197_0x3c2664(0xf7)},{'name':a197_0x3c2664(0x10e),'type':a197_0x3c2664(0x13a),'required':![],'description':a197_0x3c2664(0x12c)}];export const NOTIFICATION_ID_FLAG={'name':'id','type':a197_0x3c2664(0x125),'required':!![],'description':a197_0x3c2664(0x108)};export const NOTIFICATION_APP_FLAG=APPCODE_FLAG_OPTIONAL;export function notificationError(_0x1bc036,_0x40f752,_0x60f46c){return new CliError(_0x1bc036,0x1,_0x40f752,_0x60f46c);}export function readNotificationId(_0x31c8bd){const _0xd75c9f=a197_0x3c2664,_0x3790b0=_0x31c8bd[_0xd75c9f(0xee)]('id');if(!Number['isSafeInteger'](_0x3790b0)||_0x3790b0<=0x0)throw notificationError(_0xd75c9f(0xcf),_0xd75c9f(0x131));return _0x3790b0;}export function requireNotificationExplicitYes(_0xb89736){const _0x378584=a197_0x3c2664;if(_0xb89736['bool'](_0x378584(0x10a))||_0xb89736['bool']('yes'))return;throw notificationError('notification_config_confirmation_required',_0x378584(0xf0),_0x378584(0x137));}export function readNotificationChannelType(_0x19844b,_0x42c263=a197_0x3c2664(0x136),_0x37d170=a197_0x3c2664(0xdd)){const _0x649c0b=a197_0x3c2664,_0x366c4c=_0x19844b[_0x649c0b(0xf6)](_0x42c263)[_0x649c0b(0x10b)]()||_0x37d170;if(!NOTIFICATION_CHANNEL_TYPES[_0x649c0b(0x128)](_0x366c4c))throw CliErrors[_0x649c0b(0xd5)]('Invalid\x20--'+_0x42c263+':\x20'+_0x366c4c,_0x649c0b(0x13c)+NOTIFICATION_CHANNEL_TYPES[_0x649c0b(0x132)](',\x20')+'.');return _0x366c4c;}export function assertSingleNotificationSource(_0x45cdde){const _0x5560f8=a197_0x3c2664,_0x352741=[],_0x359b85=_0x45cdde['str'](_0x5560f8(0xcd))['trim']();if(_0x359b85)_0x352741[_0x5560f8(0xed)]({'kind':'file','path':_0x359b85});if(_0x45cdde['bool'](_0x5560f8(0x13d)))_0x352741['push']({'kind':'stdin'});const _0x7dbf6b=_0x45cdde[_0x5560f8(0xf6)](_0x5560f8(0x10e))[_0x5560f8(0x10b)]();if(_0x7dbf6b)_0x352741[_0x5560f8(0xed)]({'kind':_0x5560f8(0x113),'name':_0x7dbf6b});if(_0x352741[_0x5560f8(0xe4)]===0x0)throw CliErrors[_0x5560f8(0xd5)](_0x5560f8(0x121),_0x5560f8(0xea));if(_0x352741[_0x5560f8(0xe4)]>0x1)throw CliErrors[_0x5560f8(0xd5)](_0x5560f8(0x118),_0x5560f8(0xea));return _0x352741[0x0];}export async function readNotificationDocument(_0x10b9d0,_0x596973){const _0x507bf0=a197_0x3c2664,_0x1dcf4d=assertSingleNotificationSource(_0x10b9d0),_0x540c89=_0x1dcf4d[_0x507bf0(0xe3)]==='file'?_0x507bf0(0x12b)+_0x1dcf4d['path']:_0x1dcf4d[_0x507bf0(0xe3)]===_0x507bf0(0x113)?_0x507bf0(0xf8)+_0x1dcf4d[_0x507bf0(0x111)]:'stdin';let _0x135cd6;try{if(_0x1dcf4d[_0x507bf0(0xe3)]===_0x507bf0(0xcd))_0x135cd6=await readFile(_0x1dcf4d[_0x507bf0(0xe1)],'utf8');else{if(_0x1dcf4d[_0x507bf0(0xe3)]===_0x507bf0(0x113)){if(!(_0x1dcf4d[_0x507bf0(0x111)]in process.env))throw notificationError(_0x507bf0(0x145),_0x507bf0(0x12a)+_0x1dcf4d['name']);_0x135cd6=process.env[_0x1dcf4d.name]??'';}else _0x135cd6=await readStdin();}}catch(_0x5aaf7d){if(_0x5aaf7d instanceof CliError)throw _0x5aaf7d;throw notificationError(_0x507bf0(0x145),'Unable\x20to\x20read\x20notification\x20JSON\x20from\x20'+_0x540c89+'.');}let _0x48f12b;try{_0x48f12b=JSON[_0x507bf0(0x144)](_0x135cd6);}catch{throw notificationError(_0x507bf0(0x11d),'Notification\x20JSON\x20from\x20'+_0x540c89+_0x507bf0(0x139),_0x507bf0(0xe6));}if(!isJsonObject(_0x48f12b))throw notificationError(_0x507bf0(0x11d),_0x507bf0(0x138)+_0x540c89+_0x507bf0(0xd3));return validateNotificationDocument(_0x48f12b,_0x596973);}export function projectNotificationListConfig(_0x14b5cf,_0x22c5dc){const _0x1f2f78=a197_0x3c2664;return{'id':typeof _0x14b5cf['id']===_0x1f2f78(0x125)?_0x14b5cf['id']:null,'configCode':requireResponseString(_0x14b5cf[_0x1f2f78(0x147)],_0x1f2f78(0x147),_0x22c5dc),'configName':requireResponseString(_0x14b5cf[_0x1f2f78(0xf5)],_0x1f2f78(0xf5),_0x22c5dc),'channelType':requireResponseString(_0x14b5cf['channelType'],'channelType',_0x22c5dc),'description':normalizeNullableString(_0x14b5cf['description']),'createTime':normalizeNullableString(_0x14b5cf[_0x1f2f78(0xe2)]),'updateTime':normalizeNullableString(_0x14b5cf['updateTime'])};}function a197_0x5429(){const _0x54dc03=['Use\x20exactly\x20one\x20of\x20--file\x20<path>,\x20--stdin,\x20or\x20--from-env\x20<NAME>.','keys','\x22\x20must\x20be\x20a\x20non-negative\x20safe\x20integer\x20or\x20null.','push','num','apiError','This\x20notification\x20config\x20mutation\x20requires\x20explicit\x20--yes.','\x20is\x20missing\x20required\x20field\x20\x22','notification_config_','notification_config_field_invalid','description','configName','str','Read\x20the\x20notification\x20JSON\x20document\x20from\x20stdin','environment\x20variable\x20','675675VmKxCi','\x20--type\x20','\x20has\x20invalid\x20field\x20\x22','\x20--type\x20<CHANNEL_TYPE>\x20--format\x20compress;\x20no\x20mutation\x20was\x20submitted.','endpointUrl:null','notification_config_field_unknown','Invalid\x20notification\x20config\x20response.','Notification\x20JSON\x20field\x20\x22','has','object','rabetbase\x20notification\x20config-list\x20--appcode\x20','ccList','\x22configName\x22.','2AeHvSP','\x20has\x20an\x20invalid\x20id.','Application-level\x20notification\x20config\x20ID','replyTo','dry-run','trim','\x22\x20cannot\x20exceed\x20','connectTimeout','from-env','Notification\x20config\x20detail\x20did\x20not\x20contain\x20the\x20requested\x20ID\x20','failed','name','_unavailable','env','subjectPrefix','boolean','emailTargets','\x20has\x20an\x20invalid\x20channelType.','Notification\x20JSON\x20source\x20is\x20ambiguous.','endpointUrlRaw','359091lpCSin','a\x20JSON\x20object\x20or\x20null','Notification\x20JSON\x20channelConfig\x20field\x20\x22','notification_config_json_invalid','WEBHOOK','call','notification_config_update_empty','Missing\x20notification\x20JSON\x20source.','\x20has\x20an\x20unsupported\x20channelType.','notification_config_response_invalid','Inspect\x20with\x20rabetbase\x20notification\x20config-list\x20--appcode\x20','number','stringify','340mWndPb','includes','channelConfig','Notification\x20JSON\x20environment\x20variable\x20is\x20not\x20set:\x20','file\x20','Read\x20the\x20notification\x20JSON\x20document\x20from\x20a\x20named\x20environment\x20variable','a\x20non-empty\x20string','Read\x20the\x20notification\x20JSON\x20document\x20from\x20a\x20UTF-8\x20file','\x22\x20must\x20be\x20','messageTemplate','--id\x20must\x20be\x20a\x20positive\x20safe\x20integer.','join','\x22\x20is\x20forbidden.','mutation','Notification\x20config\x20','type','Run\x20the\x20command\x20with\x20--dry-run\x20first,\x20then\x20add\x20--yes\x20after\x20reviewing\x20the\x20plan.','Notification\x20JSON\x20from\x20','\x20is\x20invalid.','string','\x22channelType\x22.','Allowed\x20values:\x20','stdin','\x20has\x20an\x20invalid\x20appCode.','\x20characters.','create','93306KqOrjF','channelCode','a\x20string\x20or\x20null','parse','notification_config_source_unavailable','4292600LGyzRL','configCode','recipients','endpointUrl','notification_config_channel_field_forbidden','63AePzod','update','fromName','channelType','file','357928dhDCJW','notification_config_id_invalid','some','\x20failed.','Update\x20JSON\x20must\x20contain\x20at\x20least\x20one\x20allowed\x20field.','\x20must\x20be\x20an\x20object.','\x22\x20must\x20be\x20a\x20non-empty\x20string.','validation','2475KNiLvj','readTimeout','Create\x20JSON\x20requires\x20field\x20','hasOwnProperty','4026680tBudJI','a\x20JSON\x20object','appCode','EMAIL','utf8','isSafeInteger','WECOM','path','createTime','kind','length','every','Provide\x20one\x20valid\x20JSON\x20object;\x20source\x20contents\x20are\x20not\x20included\x20in\x20errors.','channelConfigRaw','notification_config_field_forbidden','notification_config_field_required'];a197_0x5429=function(){return _0x54dc03;};return a197_0x5429();}export function normalizeExactNotificationConfig(_0x548263,_0x3d5e51,_0x562738){const _0x3f63a7=a197_0x3c2664;if(!Number[_0x3f63a7(0xdf)](_0x548263['id'])||_0x548263['id']!==_0x3d5e51)throw notificationError('notification_config_response_invalid',_0x3f63a7(0x10f)+_0x3d5e51+'.');if(_0x548263['appCode']!==_0x562738)throw notificationError(_0x3f63a7(0x123),_0x3f63a7(0x135)+_0x3d5e51+'\x20does\x20not\x20belong\x20to\x20the\x20resolved\x20app.');const _0x5330ee=requireExactString(_0x548263[_0x3f63a7(0xf5)],_0x3f63a7(0xf5),_0x3d5e51),_0x2c7023=requireExactString(_0x548263[_0x3f63a7(0x147)],_0x3f63a7(0x147),_0x3d5e51),_0x2deb57=requireExactString(_0x548263[_0x3f63a7(0xcc)],_0x3f63a7(0xcc),_0x3d5e51);if(!NOTIFICATION_CHANNEL_TYPES['includes'](_0x2deb57))throw notificationError(_0x3f63a7(0x123),_0x3f63a7(0x135)+_0x3d5e51+_0x3f63a7(0x122));const _0x52872a=responseNullableString(_0x548263[_0x3f63a7(0xc7)],_0x3f63a7(0xc7),_0x3d5e51),_0x4949a6=responseNullableString(_0x548263[_0x3f63a7(0x129)],_0x3f63a7(0x129),_0x3d5e51),_0x3b945b=responseNullableString(_0x548263['description'],_0x3f63a7(0xf4),_0x3d5e51),_0x4be527=responseNullableTimeout(_0x548263[_0x3f63a7(0x10d)],'connectTimeout',_0x3d5e51),_0xd0a4a7=responseNullableTimeout(_0x548263[_0x3f63a7(0xd7)],_0x3f63a7(0xd7),_0x3d5e51);return{'id':_0x3d5e51,'appCode':_0x562738,'configCode':_0x2c7023,'configName':_0x5330ee,'channelType':_0x2deb57,'endpointUrl':redactSensitive(_0x52872a),'channelConfig':redactSensitive(_0x4949a6),'description':_0x3b945b,'connectTimeout':_0x4be527,'readTimeout':_0xd0a4a7,'endpointUrlRaw':_0x52872a,'channelConfigRaw':_0x4949a6};}export async function requireExactNotificationConfig(_0x483dfb,_0x3b18c0,_0x3de9d8){const _0x2a877d=a197_0x3c2664;let _0x4c93f7;try{_0x4c93f7=await getNotificationChannelConfig(_0x3b18c0,_0x483dfb);}catch{throw safeApiFailure(_0x3de9d8,'preflight',_0x2a877d(0x124)+_0x483dfb+_0x2a877d(0xfc));}return normalizeExactNotificationConfig(_0x4c93f7,_0x3b18c0,_0x483dfb);}export function projectNotificationConfig(_0x192446){const _0x8d8b34=a197_0x3c2664;return{'id':_0x192446['id']??null,'appCode':_0x192446[_0x8d8b34(0xdc)],'configCode':_0x192446[_0x8d8b34(0x147)]??null,'configName':_0x192446[_0x8d8b34(0xf5)],'channelType':_0x192446[_0x8d8b34(0xcc)],'endpointUrl':redactSensitive(_0x192446['endpointUrl']),'channelConfig':redactSensitive(_0x192446[_0x8d8b34(0x129)]),'description':_0x192446[_0x8d8b34(0xf4)]??null,'connectTimeout':_0x192446['connectTimeout']??null,'readTimeout':_0x192446[_0x8d8b34(0xd7)]??null};}export function notificationSelector(_0x3b3473){const _0x3ea05a=a197_0x3c2664;return{'appCode':_0x3b3473[_0x3ea05a(0xdc)],'id':_0x3b3473['id'],'configCode':_0x3b3473[_0x3ea05a(0x147)],'configName':_0x3b3473[_0x3ea05a(0xf5)],'channelType':_0x3b3473['channelType']};}export function createMutationInput(_0x10fa9c,_0x43b446){const _0x3a341c=a197_0x3c2664;return{'appCode':_0x10fa9c,'configName':_0x43b446['configName'],'channelType':_0x43b446[_0x3a341c(0xcc)],...hasOwn(_0x43b446,_0x3a341c(0xc7))?{'endpointUrl':_0x43b446[_0x3a341c(0xc7)]}:{},...hasOwn(_0x43b446,'channelConfig')?{'channelConfig':serializeChannelConfig(_0x43b446[_0x3a341c(0x129)])}:{},...hasOwn(_0x43b446,_0x3a341c(0xf4))?{'description':_0x43b446[_0x3a341c(0xf4)]}:{},...hasOwn(_0x43b446,_0x3a341c(0x10d))?{'connectTimeout':_0x43b446['connectTimeout']}:{},...hasOwn(_0x43b446,_0x3a341c(0xd7))?{'readTimeout':_0x43b446[_0x3a341c(0xd7)]}:{}};}function a197_0x2402(_0x1b001b,_0x5eeddb){_0x1b001b=_0x1b001b-0xc7;const _0x54290d=a197_0x5429();let _0x240268=_0x54290d[_0x1b001b];return _0x240268;}export function mergeUpdateInput(_0x5963e4,_0x2badc2){const _0x275f14=a197_0x3c2664;return{'id':_0x5963e4['id'],'appCode':_0x5963e4['appCode'],'configName':_0x2badc2[_0x275f14(0xf5)]??_0x5963e4[_0x275f14(0xf5)],'channelType':_0x2badc2['channelType']??_0x5963e4[_0x275f14(0xcc)],'endpointUrl':hasOwn(_0x2badc2,'endpointUrl')?_0x2badc2[_0x275f14(0xc7)]:_0x5963e4[_0x275f14(0x119)],'channelConfig':hasOwn(_0x2badc2,_0x275f14(0x129))?serializeChannelConfig(_0x2badc2[_0x275f14(0x129)]):_0x5963e4[_0x275f14(0xe7)],'description':hasOwn(_0x2badc2,_0x275f14(0xf4))?_0x2badc2[_0x275f14(0xf4)]:_0x5963e4[_0x275f14(0xf4)],'connectTimeout':hasOwn(_0x2badc2,_0x275f14(0x10d))?_0x2badc2[_0x275f14(0x10d)]:_0x5963e4[_0x275f14(0x10d)],'readTimeout':hasOwn(_0x2badc2,_0x275f14(0xd7))?_0x2badc2['readTimeout']:_0x5963e4[_0x275f14(0xd7)]};}export function plannedUpdateProjection(_0xe8a1c5,_0x31cf5c){const _0x152e24=a197_0x3c2664;return projectNotificationConfig({'id':_0xe8a1c5['id'],'appCode':_0xe8a1c5['appCode'],'configCode':_0xe8a1c5[_0x152e24(0x147)],'configName':_0x31cf5c['configName']??_0xe8a1c5[_0x152e24(0xf5)],'channelType':_0x31cf5c['channelType']??_0xe8a1c5[_0x152e24(0xcc)],'endpointUrl':hasOwn(_0x31cf5c,_0x152e24(0xc7))?_0x31cf5c[_0x152e24(0xc7)]:_0xe8a1c5['endpointUrlRaw'],'channelConfig':hasOwn(_0x31cf5c,_0x152e24(0x129))?_0x31cf5c[_0x152e24(0x129)]:_0xe8a1c5['channelConfigRaw'],'description':hasOwn(_0x31cf5c,_0x152e24(0xf4))?_0x31cf5c[_0x152e24(0xf4)]:_0xe8a1c5[_0x152e24(0xf4)],'connectTimeout':hasOwn(_0x31cf5c,_0x152e24(0x10d))?_0x31cf5c[_0x152e24(0x10d)]??DEFAULT_NOTIFICATION_CONNECT_TIMEOUT:_0xe8a1c5[_0x152e24(0x10d)],'readTimeout':hasOwn(_0x31cf5c,_0x152e24(0xd7))?_0x31cf5c[_0x152e24(0xd7)]??DEFAULT_NOTIFICATION_READ_TIMEOUT:_0xe8a1c5[_0x152e24(0xd7)]});}export function requestedSafeFieldsMatch(_0x557e4c,_0x8f3e3a,_0x3cd223){const _0x2b3424=a197_0x3c2664,_0x10f6ab=[],_0x58d112=[],_0xcc77d5=[];for(const _0x5259eb of[_0x2b3424(0xf5),_0x2b3424(0xcc),_0x2b3424(0xf4)]){if(!hasOwn(_0x3cd223,_0x5259eb))continue;_0xcc77d5[_0x2b3424(0xed)](_0x5259eb),_0x10f6ab[_0x2b3424(0xed)](_0x8f3e3a[_0x5259eb]===_0x3cd223[_0x5259eb]),_0x58d112[_0x2b3424(0xed)](_0x557e4c[_0x5259eb]!==_0x3cd223[_0x5259eb]&&_0x8f3e3a[_0x5259eb]===_0x3cd223[_0x5259eb]);}for(const _0x5e6bd8 of['connectTimeout','readTimeout']){if(!hasOwn(_0x3cd223,_0x5e6bd8))continue;const _0x567833=_0x3cd223[_0x5e6bd8]??(_0x5e6bd8===_0x2b3424(0x10d)?DEFAULT_NOTIFICATION_CONNECT_TIMEOUT:DEFAULT_NOTIFICATION_READ_TIMEOUT);_0xcc77d5[_0x2b3424(0xed)](_0x5e6bd8),_0x10f6ab[_0x2b3424(0xed)](_0x8f3e3a[_0x5e6bd8]===_0x567833),_0x58d112[_0x2b3424(0xed)](_0x557e4c[_0x5e6bd8]!==_0x567833&&_0x8f3e3a[_0x5e6bd8]===_0x567833);}return hasOwn(_0x3cd223,_0x2b3424(0xc7))&&_0x3cd223['endpointUrl']===null&&(_0xcc77d5['push'](_0x2b3424(0xfd)),_0x10f6ab['push'](_0x8f3e3a['endpointUrlRaw']===null||_0x8f3e3a[_0x2b3424(0x119)]===''),_0x58d112[_0x2b3424(0xed)](_0x557e4c[_0x2b3424(0x119)]!==null&&_0x557e4c[_0x2b3424(0x119)]!==''&&(_0x8f3e3a['endpointUrlRaw']===null||_0x8f3e3a[_0x2b3424(0x119)]===''))),{'allMatch':_0x10f6ab[_0x2b3424(0xe5)](Boolean),'provesChange':_0x58d112[_0x2b3424(0xd0)](Boolean),'verifiedFields':_0xcc77d5};}export function validateNotificationDeleteReadback(_0xcb6224,_0x49376d,_0x4d2d32){const _0x4eec23=a197_0x3c2664;for(const [_0x513638,_0x540e8f]of _0xcb6224['entries']()){if(!Number['isSafeInteger'](_0x540e8f['id'])||_0x540e8f['id']<=0x0)throw notificationError(_0x4eec23(0x123),'Notification\x20config\x20list\x20item\x20'+(_0x513638+0x1)+_0x4eec23(0x107));if(_0x540e8f[_0x4eec23(0xdc)]!==_0x49376d)throw notificationError('notification_config_response_invalid','Notification\x20config\x20list\x20item\x20'+(_0x513638+0x1)+_0x4eec23(0x13e));if(_0x540e8f['channelType']!==_0x4d2d32)throw notificationError(_0x4eec23(0x123),'Notification\x20config\x20list\x20item\x20'+(_0x513638+0x1)+_0x4eec23(0x117));}}export function safeApiFailure(_0x1e661e,_0x2d4f3d,_0x34c2c2){const _0x4ae5e0=a197_0x3c2664;return notificationError(_0x4ae5e0(0xf2)+_0x1e661e+'_'+(_0x2d4f3d===_0x4ae5e0(0x134)?_0x4ae5e0(0x110):_0x2d4f3d+_0x4ae5e0(0x112)),'Notification\x20config\x20'+_0x1e661e+'\x20'+_0x2d4f3d+_0x4ae5e0(0xd1),_0x34c2c2);}export function notificationLookupCommand(_0x1bf70b,_0x3291c1){const _0x11f638=a197_0x3c2664;return _0x11f638(0x103)+_0x1bf70b+_0x11f638(0xfa)+_0x3291c1+'\x20--format\x20compress';}function validateNotificationDocument(_0x189d74,_0xe5904a){const _0x2edd19=a197_0x3c2664;for(const _0x30af0a of Object[_0x2edd19(0xeb)](_0x189d74)){if(FORBIDDEN_IDENTITY_FIELDS['has'](_0x30af0a))throw notificationError(_0x2edd19(0xe8),_0x2edd19(0x100)+_0x30af0a+'\x22\x20is\x20controlled\x20by\x20the\x20CLI\x20or\x20server\x20and\x20is\x20forbidden.');if(!ALLOWED_INPUT_FIELDS[_0x2edd19(0x101)](_0x30af0a))throw notificationError(_0x2edd19(0xfe),'Unknown\x20notification\x20JSON\x20field\x20\x22'+_0x30af0a+'\x22.');}if(_0xe5904a===_0x2edd19(0xca)&&Object[_0x2edd19(0xeb)](_0x189d74)[_0x2edd19(0xe4)]===0x0)throw notificationError(_0x2edd19(0x120),_0x2edd19(0xd2));const _0x492662={};if(hasOwn(_0x189d74,_0x2edd19(0xf5)))_0x492662['configName']=validateRequiredString(_0x189d74[_0x2edd19(0xf5)],_0x2edd19(0xf5),0x80);else{if(_0xe5904a===_0x2edd19(0x140))throw notificationError(_0x2edd19(0xe9),_0x2edd19(0xd8)+_0x2edd19(0x105));}if(hasOwn(_0x189d74,_0x2edd19(0xcc))){if(typeof _0x189d74[_0x2edd19(0xcc)]!==_0x2edd19(0x13a))throw invalidFieldType(_0x2edd19(0xcc),'a\x20supported\x20string');const _0x218f43=_0x189d74['channelType']['trim']();if(!NOTIFICATION_CHANNEL_TYPES[_0x2edd19(0x128)](_0x218f43))throw notificationError('notification_config_field_invalid','Notification\x20JSON\x20field\x20\x22channelType\x22\x20is\x20unsupported.',_0x2edd19(0x13c)+NOTIFICATION_CHANNEL_TYPES[_0x2edd19(0x132)](',\x20')+'.');_0x492662['channelType']=_0x218f43;}else{if(_0xe5904a==='create')throw notificationError(_0x2edd19(0xe9),_0x2edd19(0xd8)+_0x2edd19(0x13b));}for(const [_0xa39bee,_0x35d3f0]of[[_0x2edd19(0xc7),0x200],[_0x2edd19(0xf4),0x100]]){if(!hasOwn(_0x189d74,_0xa39bee))continue;const _0x2da828=_0x189d74[_0xa39bee];if(_0x2da828!==null&&typeof _0x2da828!==_0x2edd19(0x13a))throw invalidFieldType(_0xa39bee,_0x2edd19(0x143));if(typeof _0x2da828===_0x2edd19(0x13a)&&_0x2da828['length']>_0x35d3f0)throw notificationError(_0x2edd19(0xf3),_0x2edd19(0x100)+_0xa39bee+_0x2edd19(0x10c)+_0x35d3f0+_0x2edd19(0x13f));_0x492662[_0xa39bee]=_0x2da828;}if(hasOwn(_0x189d74,_0x2edd19(0x129))){const _0x4a0690=_0x189d74[_0x2edd19(0x129)];if(_0x4a0690===null&&_0xe5904a===_0x2edd19(0x140))throw invalidFieldType(_0x2edd19(0x129),_0x2edd19(0xdb));if(_0x4a0690!==null&&!isJsonObject(_0x4a0690))throw invalidFieldType(_0x2edd19(0x129),_0xe5904a===_0x2edd19(0xca)?_0x2edd19(0x11b):_0x2edd19(0xdb));_0x4a0690!==null&&validateChannelConfigFields(_0x492662['channelType'],_0x4a0690),_0x492662[_0x2edd19(0x129)]=_0x4a0690;}for(const _0xc8aebf of['connectTimeout',_0x2edd19(0xd7)]){if(!hasOwn(_0x189d74,_0xc8aebf))continue;const _0x32d22a=_0x189d74[_0xc8aebf];if(_0x32d22a!==null&&(!Number[_0x2edd19(0xdf)](_0x32d22a)||_0x32d22a<0x0))throw notificationError(_0x2edd19(0xf3),_0x2edd19(0x100)+_0xc8aebf+_0x2edd19(0xec));_0x492662[_0xc8aebf]=_0x32d22a;}return _0x492662;}function validateRequiredString(_0x51434c,_0x17fa32,_0x13cf73){const _0x381606=a197_0x3c2664;if(typeof _0x51434c!==_0x381606(0x13a))throw invalidFieldType(_0x17fa32,_0x381606(0x12d));const _0xe51ee5=_0x51434c['trim']();if(!_0xe51ee5)throw notificationError(_0x381606(0xf3),_0x381606(0x100)+_0x17fa32+_0x381606(0xd4));if(_0xe51ee5[_0x381606(0xe4)]>_0x13cf73)throw notificationError(_0x381606(0xf3),_0x381606(0x100)+_0x17fa32+_0x381606(0x10c)+_0x13cf73+_0x381606(0x13f));return _0xe51ee5;}function validateChannelConfigFields(_0x2397e1,_0x18fb84){const _0x477db5=a197_0x3c2664;if(hasOwn(_0x18fb84,_0x477db5(0x130)))throw forbiddenChannelConfigField('messageTemplate');if(_0x2397e1===_0x477db5(0xdd))for(const _0x2a3dac of EMAIL_RECIPIENT_FIELDS){if(hasOwn(_0x18fb84,_0x2a3dac))throw forbiddenChannelConfigField(_0x2a3dac);}}function forbiddenChannelConfigField(_0x589a07){const _0xd89c21=a197_0x3c2664;return notificationError(_0xd89c21(0xc8),_0xd89c21(0x11c)+_0x589a07+_0xd89c21(0x133));}function invalidFieldType(_0x4a5df5,_0x1ffb89){const _0x5c6357=a197_0x3c2664;return notificationError(_0x5c6357(0xf3),_0x5c6357(0x100)+_0x4a5df5+_0x5c6357(0x12f)+_0x1ffb89+'.');}function serializeChannelConfig(_0x3aa15b){const _0x29a963=a197_0x3c2664;return _0x3aa15b===null||_0x3aa15b===undefined?null:JSON[_0x29a963(0x126)](_0x3aa15b);}function redactSensitive(_0xe082b8){return _0xe082b8===null||_0xe082b8===undefined||_0xe082b8===''?null:'<redacted>';}function requireResponseString(_0x58eedf,_0x3a9d0f,_0x8cad46){const _0x2d4b87=a197_0x3c2664;if(typeof _0x58eedf!==_0x2d4b87(0x13a)||_0x58eedf[_0x2d4b87(0x10b)]()==='')throw CliErrors[_0x2d4b87(0xef)](_0x2d4b87(0xff),'Item\x20'+(_0x8cad46+0x1)+'\x20is\x20missing\x20required\x20field\x20\x22'+_0x3a9d0f+'\x22.');return _0x58eedf[_0x2d4b87(0x10b)]();}function requireExactString(_0xc9744a,_0x3405a1,_0x1729c8){const _0x43dfe8=a197_0x3c2664;if(typeof _0xc9744a!==_0x43dfe8(0x13a)||_0xc9744a[_0x43dfe8(0x10b)]()==='')throw notificationError(_0x43dfe8(0x123),_0x43dfe8(0x135)+_0x1729c8+_0x43dfe8(0xf1)+_0x3405a1+'\x22.');return _0xc9744a[_0x43dfe8(0x10b)]();}function responseNullableString(_0x520e29,_0x207464,_0x225162){const _0x2e9b81=a197_0x3c2664;if(_0x520e29===undefined||_0x520e29===null)return null;if(typeof _0x520e29!==_0x2e9b81(0x13a))throw notificationError(_0x2e9b81(0x123),_0x2e9b81(0x135)+_0x225162+_0x2e9b81(0xfb)+_0x207464+'\x22.');return _0x520e29;}function responseNullableTimeout(_0x2d191f,_0x52784a,_0x8f2d9){const _0x7baf26=a197_0x3c2664;if(_0x2d191f===undefined||_0x2d191f===null)return null;if(!Number[_0x7baf26(0xdf)](_0x2d191f)||_0x2d191f<0x0)throw notificationError(_0x7baf26(0x123),_0x7baf26(0x135)+_0x8f2d9+_0x7baf26(0xfb)+_0x52784a+'\x22.');return _0x2d191f;}function normalizeNullableString(_0x4aec96){const _0x45e4f8=a197_0x3c2664;return typeof _0x4aec96===_0x45e4f8(0x13a)?_0x4aec96:null;}function isJsonObject(_0x3a11e5){const _0x4ce05c=a197_0x3c2664;return _0x3a11e5!==null&&typeof _0x3a11e5===_0x4ce05c(0x102)&&!Array['isArray'](_0x3a11e5);}function hasOwn(_0x18fd1b,_0x5993a2){const _0x11e1c9=a197_0x3c2664;return Object['prototype'][_0x11e1c9(0xd9)][_0x11e1c9(0x11f)](_0x18fd1b,_0x5993a2);}async function readStdin(){const _0x4beda0=a197_0x3c2664;let _0x50d759='';process[_0x4beda0(0x13d)]['setEncoding'](_0x4beda0(0xde));for await(const _0x28b3df of process[_0x4beda0(0x13d)])_0x50d759+=_0x28b3df;return _0x50d759;}
|
|
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}:{}}}
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
const a211_0x5a381f=a211_0x1da1;(function(_0xa5c766,_0x33ce4b){const _0x46106c=a211_0x1da1,_0x24880d=_0xa5c766();while(!![]){try{const _0x594186=-parseInt(_0x46106c(0xdf))/0x1*(-parseInt(_0x46106c(0x10d))/0x2)+-parseInt(_0x46106c(0x124))/0x3+parseInt(_0x46106c(0xf9))/0x4+-parseInt(_0x46106c(0xfc))/0x5+-parseInt(_0x46106c(0x117))/0x6+parseInt(_0x46106c(0xf1))/0x7*(-parseInt(_0x46106c(0xe6))/0x8)+parseInt(_0x46106c(0x114))/0x9;if(_0x594186===_0x33ce4b)break;else _0x24880d['push'](_0x24880d['shift']());}catch(_0x33112b){_0x24880d['push'](_0x24880d['shift']());}}}(a211_0x2495,0xdbd1d));import{readFile,writeFile}from'node:fs/promises';import{APPCODE_FLAG_OPTIONAL,DATASETCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{getPageIdFlag,loadDatasetDetailForPage,loadPageDetailForPage,selectVersionTagGroup,serializeDryRunDescription,validatePageTargetSelector}from'../../commands/page/shared.js';import{transpileLrSmartJsx,updatePage}from'../../core/api-client.js';import{computePageContentHash,computeSerializedSchemaHash,serializePageSchemaForFile}from'../../core/page/hash.js';import{fileExists,loadPageProjectConfig,resolvePageFilePath}from'../../core/page/file-system.js';import{createEmptyPageLock,ensurePageLockScope,readPageLockFile,writePageLockFile}from'../../core/page/lock.js';import{prepareLrSmartJsxForPush}from'../../core/page/lr-smart-jsx.js';import{CliErrors}from'../../errors.js';export const pagePush={'service':'page','command':a211_0x5a381f(0x11a),'description':'Push\x20local\x20page\x20schema\x20back\x20to\x20remote','risk':a211_0x5a381f(0x109),'defaultOutputFormat':a211_0x5a381f(0xf8),'flags':[APPCODE_FLAG_OPTIONAL,{'name':'id','type':a211_0x5a381f(0xf5),'description':a211_0x5a381f(0x106)},DATASETCODE_FLAG_OPTIONAL,{'name':a211_0x5a381f(0x121),'type':'string','description':'Dataset\x20alias\x20from\x20api.ts\x20(resolves\x20to\x20dataset\x20code\x20automatically)'},{'name':a211_0x5a381f(0xf0),'type':a211_0x5a381f(0x100),'description':a211_0x5a381f(0x108)}],async 'validate'(_0x3b5c9b){validatePageTargetSelector(_0x3b5c9b);},async 'dryRun'(_0x3e54db){const _0x15dffe=a211_0x5a381f,_0x53122b=await buildPushPreview(_0x3e54db);return{'method':_0x15dffe(0x125),'url':'/smartapi/lovrabet/update-page','body':{'appCode':_0x3e54db[_0x15dffe(0xdc)],'mode':_0x53122b[_0x15dffe(0xe0)],'datasetCode':_0x53122b[_0x15dffe(0xd4)]??null,'pages':_0x53122b[_0x15dffe(0xfe)]},'description':serializeDryRunDescription({'mode':_0x53122b[_0x15dffe(0xe0)],'datasetCode':_0x53122b['datasetCode']??null,'totalWouldPush':_0x53122b[_0x15dffe(0xfe)][_0x15dffe(0x10a)](_0x1b055d=>_0x1b055d['status']===_0x15dffe(0xe8))[_0x15dffe(0x10b)],'totalUnchanged':_0x53122b[_0x15dffe(0xfe)][_0x15dffe(0x10a)](_0x1c14fd=>_0x1c14fd[_0x15dffe(0x107)]===_0x15dffe(0xd8))[_0x15dffe(0x10b)],'totalConflicts':_0x53122b[_0x15dffe(0xfe)]['filter'](_0x2a13ae=>_0x2a13ae[_0x15dffe(0x107)]===_0x15dffe(0xdb)||_0x2a13ae[_0x15dffe(0x107)]===_0x15dffe(0xda))[_0x15dffe(0x10b)]})};},async 'execute'(_0x58fdde){const _0x28b209=a211_0x5a381f,_0x10221f=loadPageProjectConfig(_0x58fdde[_0x28b209(0xdc)]),_0x457ecf=await readPageLockFile(_0x10221f[_0x28b209(0xf3)]),{lockData:_0x1a176,appLock:_0x2f723d}=ensurePageLockScope(_0x457ecf??createEmptyPageLock(),_0x58fdde[_0x28b209(0xdc)]),_0x36f5ac=getPageIdFlag(_0x58fdde);if(_0x36f5ac!==undefined){const _0x54336c=await prepareSinglePush(_0x58fdde,_0x10221f,_0x2f723d[_0x28b209(0xe2)][String(_0x36f5ac)],_0x36f5ac),_0x470218=await pushPreparedPage(_0x58fdde,_0x54336c);return _0x2f723d['pages'][String(_0x470218[_0x28b209(0x122)])]=_0x470218['nextLockEntry'],_0x2f723d['lastSync']=new Date()['toISOString'](),await writePageLockFile(_0x10221f[_0x28b209(0xf3)],_0x1a176),{'ok':!![],'message':_0x470218[_0x28b209(0xf6)]?_0x28b209(0xe7):_0x28b209(0x105),'data':{'appCode':_0x58fdde[_0x28b209(0xdc)],'pushedPages':[{'pageId':_0x470218['pageId'],'type':_0x470218[_0x28b209(0xec)],'title':_0x470218[_0x28b209(0xe1)],'normalized':_0x470218[_0x28b209(0xf6)]}],'skippedPages':[],'failedPages':[],'totalPushed':0x1,'totalSkipped':0x0,'totalFailed':0x0}};}const _0x151222=await buildBatchPushPlan(_0x58fdde,_0x2f723d['pages']),_0x4aa310=[],_0x3b6410=[],_0x3b8a89=[];for(const _0x3e07f6 of _0x151222[_0x28b209(0xef)]){try{const _0x597c48=await prepareSinglePush(_0x58fdde,_0x10221f,_0x2f723d['pages'][String(_0x3e07f6[_0x28b209(0x122)])],_0x3e07f6[_0x28b209(0x122)],_0x151222['datasetId']);if(!_0x597c48[_0x28b209(0x123)]&&_0x597c48[_0x28b209(0x119)]===_0x597c48[_0x28b209(0x110)][_0x28b209(0x11c)]){_0x3b6410['push']({'pageId':_0x3e07f6['pageId'],'type':_0x3e07f6[_0x28b209(0xec)],'title':_0x3e07f6[_0x28b209(0xe1)],'reason':'no\x20changes'});continue;}const _0x56b45c=await pushPreparedPage(_0x58fdde,_0x597c48);_0x2f723d[_0x28b209(0xe2)][String(_0x56b45c[_0x28b209(0x122)])]=_0x56b45c[_0x28b209(0x10e)],_0x4aa310[_0x28b209(0x11a)]({'pageId':_0x56b45c[_0x28b209(0x122)],'type':_0x56b45c[_0x28b209(0xec)],'title':_0x56b45c[_0x28b209(0xe1)],'normalized':_0x56b45c[_0x28b209(0xf6)]});}catch(_0x2a9122){_0x3b8a89[_0x28b209(0x11a)]({'pageId':_0x3e07f6[_0x28b209(0x122)],'type':_0x3e07f6[_0x28b209(0xec)],'title':_0x3e07f6[_0x28b209(0xe1)],'reason':_0x2a9122 instanceof Error?_0x2a9122['message']:String(_0x2a9122)});}}return _0x2f723d[_0x28b209(0xea)]=new Date()[_0x28b209(0xfd)](),await writePageLockFile(_0x10221f[_0x28b209(0xf3)],_0x1a176),{'ok':_0x3b8a89[_0x28b209(0x10b)]===0x0||_0x4aa310['length']>0x0||_0x3b6410['length']>0x0,'message':_0x3b8a89[_0x28b209(0x10b)]>0x0&&_0x4aa310[_0x28b209(0x10b)]>0x0?_0x28b209(0xdd):_0x4aa310['length']>0x0?_0x28b209(0x105):_0x3b6410[_0x28b209(0x10b)]>0x0&&_0x3b8a89['length']===0x0?_0x28b209(0xfb):_0x3b8a89[0x0]?.[_0x28b209(0x116)]||'Push\x20failed','data':{'appCode':_0x58fdde['appCode'],'pushedPages':_0x4aa310,'skippedPages':_0x3b6410,'failedPages':_0x3b8a89,'totalPushed':_0x4aa310['length'],'totalSkipped':_0x3b6410[_0x28b209(0x10b)],'totalFailed':_0x3b8a89['length']}};}};async function buildPushPreview(_0x236f70){const _0x516e91=a211_0x5a381f,_0x496196=loadPageProjectConfig(_0x236f70['appCode']),_0x3101f1=await readPageLockFile(_0x496196[_0x516e91(0xf3)]),{appLock:_0x5d3cd9}=ensurePageLockScope(_0x3101f1??createEmptyPageLock(),_0x236f70[_0x516e91(0xdc)]),_0x202a36=getPageIdFlag(_0x236f70);if(_0x202a36!==undefined)return{'mode':'single','items':[await inspectPushPage(_0x236f70,_0x496196,_0x5d3cd9['pages'][String(_0x202a36)],_0x202a36)]};const _0x2f2e3f=await buildBatchPushPlan(_0x236f70,_0x5d3cd9[_0x516e91(0xe2)]);return{'mode':_0x516e91(0x104),'datasetCode':_0x2f2e3f[_0x516e91(0xd4)],'items':await Promise['all'](_0x2f2e3f[_0x516e91(0xef)][_0x516e91(0x118)](_0x2728b3=>inspectPushPage(_0x236f70,_0x496196,_0x5d3cd9['pages'][String(_0x2728b3['pageId'])],_0x2728b3[_0x516e91(0x122)],_0x2f2e3f[_0x516e91(0x113)])))};}function a211_0x1da1(_0x293f8b,_0x573c40){_0x293f8b=_0x293f8b-0xd2;const _0x2495d6=a211_0x2495();let _0x1da151=_0x2495d6[_0x293f8b];return _0x1da151;}async function buildBatchPushPlan(_0x1ef625,_0x5b5cda){const _0x29e738=a211_0x5a381f,_0x5a3646=await loadDatasetDetailForPage(_0x1ef625),_0x16e905=_0x5a3646['id'],_0x6dedde=new Set(_0x5a3646['relatedPages'][_0x29e738(0x10a)](_0x1f127e=>!_0x1f127e[_0x29e738(0xff)])[_0x29e738(0x118)](_0x45b412=>_0x45b412['id'])),_0x21c7f3=Object[_0x29e738(0xd2)](_0x5b5cda)[_0x29e738(0x10a)](_0xc29db6=>_0xc29db6[_0x29e738(0xf4)][_0x29e738(0xe4)](_0x16e905)&&_0x6dedde['has'](_0xc29db6[_0x29e738(0x122)]));if(_0x21c7f3['length']===0x0)throw CliErrors[_0x29e738(0xf7)](_0x29e738(0xde)+_0x5a3646['code']+'\x22.',_0x29e738(0x11d)+CLI_BIN_NAME+'\x20page\x20pull\x20--datasetcode\x20'+_0x5a3646[_0x29e738(0x101)]+'`\x20first.');const _0xee46fc=selectVersionTagGroup(_0x21c7f3,_0x2ca36e=>_0x2ca36e['versionTag']??null,_0x1ef625[_0x29e738(0x102)]('version-tag')),_0x478b90=[];for(const _0x139fb1 of _0xee46fc[_0x29e738(0xfe)]){_0x478b90[_0x29e738(0x11a)]({'pageId':_0x139fb1[_0x29e738(0x122)],'type':_0x139fb1['type'],'title':_0x139fb1[_0x29e738(0xe1)]});}return{'datasetCode':_0x5a3646['code'],'datasetId':_0x16e905,'candidates':_0x478b90};}function a211_0x2495(){const _0x3e5e86=['5318OOakUg','nextLockEntry','`\x20first','lockEntry','pageVersion','versionTag','datasetId','25539165JDctPE','`\x20first.','reason','1412412vlNtcr','map','localHash','push','name','hash','Run\x20`','page-','remoteDetail','utf8','alias','pageId','preparedChanges','3729519RqnQwE','POST','normalizedNodes','Page\x20update\x20failed:\x20','Local\x20file\x20not\x20found:\x20','values','localContent','datasetCode','Remote\x20page\x20','Page\x20','message','unchanged','UNKNOWN','blocked','conflict','appCode','Some\x20pages\x20failed\x20to\x20push','No\x20local\x20pages\x20found\x20for\x20dataset\x20\x22','349CTHffN','mode','title','pages','Invalid\x20JSON\x20in\x20local\x20page\x20file:\x20','includes','local\x20JSON\x20is\x20invalid','11588408TwEokp','Push\x20succeeded;\x20server\x20normalized\x20the\x20schema','would_push','remote\x20schema\x20changed','lastSync','no\x20changes','type','\x20has\x20changed\x20since\x20last\x20pull.','parse','candidates','version-tag','7wmhaxv','\x20page\x20pull\x20--id\x20','lockFilePath','datasetIds','number','normalized','validation','compress','5728284CQKODs','No\x20lock\x20record\x20found\x20for\x20page\x20','No\x20changes\x20to\x20push','6851200obrHmb','toISOString','items','deleted','string','code','str','content','batch','Push\x20succeeded','Page\x20ID','status','Page\x20group\x20version\x20tag\x20(batch\x20mode\x20only)','write','filter','length','remote\x20pageVersion\x20changed'];a211_0x2495=function(){return _0x3e5e86;};return a211_0x2495();}async function inspectPushPage(_0x3242a9,_0x352cca,_0x398240,_0x9fedd9,_0x561710){const _0x24755f=a211_0x5a381f;if(!_0x398240)return{'pageId':_0x9fedd9,'type':'UNKNOWN','title':_0x24755f(0x11e)+_0x9fedd9,'localPath':resolvePageFilePath(_0x352cca,_0x9fedd9,_0x24755f(0xd9)),'status':_0x24755f(0xda),'reason':_0x24755f(0x11d)+CLI_BIN_NAME+_0x24755f(0xf2)+_0x9fedd9+_0x24755f(0x10f)};const _0x335859=resolvePageFilePath(_0x352cca,_0x9fedd9,_0x398240[_0x24755f(0xec)]);if(!await fileExists(_0x335859))return{'pageId':_0x9fedd9,'type':_0x398240['type'],'title':_0x398240['title'],'localPath':_0x335859,'status':'blocked','reason':_0x24755f(0x128)+_0x335859};const _0x5b1850=await readFile(_0x335859,_0x24755f(0x120));try{JSON[_0x24755f(0xee)](_0x5b1850);}catch{return{'pageId':_0x9fedd9,'type':_0x398240['type'],'title':_0x398240[_0x24755f(0xe1)],'localPath':_0x335859,'status':'blocked','reason':_0x24755f(0xe5)};}try{const _0x2cd0e1=await loadPageDetailForPage(_0x3242a9,_0x9fedd9);if(_0x561710!=null&&!_0x2cd0e1[_0x24755f(0xf4)]['includes'](_0x561710))return{'pageId':_0x9fedd9,'type':_0x398240[_0x24755f(0xec)],'title':_0x398240[_0x24755f(0xe1)],'localPath':_0x335859,'status':'conflict','reason':_0x24755f(0xd6)+_0x9fedd9+'\x20no\x20longer\x20belongs\x20to\x20the\x20target\x20dataset'};const _0x2ef9cc=_0x398240[_0x24755f(0x111)]!=null&&_0x2cd0e1[_0x24755f(0x111)]!=null;if(_0x2ef9cc&&_0x398240['pageVersion']!==_0x2cd0e1[_0x24755f(0x111)])return{'pageId':_0x9fedd9,'type':_0x398240[_0x24755f(0xec)],'title':_0x398240[_0x24755f(0xe1)],'localPath':_0x335859,'status':_0x24755f(0xdb),'reason':_0x24755f(0x10c)};if(!_0x2ef9cc&&computeSerializedSchemaHash(_0x2cd0e1[_0x24755f(0x101)])!==_0x398240[_0x24755f(0x11c)])return{'pageId':_0x9fedd9,'type':_0x398240['type'],'title':_0x398240[_0x24755f(0xe1)],'localPath':_0x335859,'status':'conflict','reason':_0x24755f(0xe9)};const _0x5437c5=await prepareLrSmartJsxForPush(_0x5b1850,_0x2cd0e1[_0x24755f(0x101)],transpileLrSmartJsx);if(_0x5437c5[_0x24755f(0x126)]===0x0&&computePageContentHash(_0x5437c5['content'])===_0x398240[_0x24755f(0x11c)])return{'pageId':_0x9fedd9,'type':_0x398240[_0x24755f(0xec)],'title':_0x398240['title'],'localPath':_0x335859,'status':_0x24755f(0xd8),'reason':_0x24755f(0xeb)};}catch(_0x265748){return{'pageId':_0x9fedd9,'type':_0x398240[_0x24755f(0xec)],'title':_0x398240[_0x24755f(0xe1)],'localPath':_0x335859,'status':'blocked','reason':_0x265748 instanceof Error?_0x265748[_0x24755f(0xd7)]:String(_0x265748)};}return{'pageId':_0x9fedd9,'type':_0x398240['type'],'title':_0x398240[_0x24755f(0xe1)],'localPath':_0x335859,'status':_0x24755f(0xe8)};}async function prepareSinglePush(_0x4729e1,_0x1c36f4,_0x342d32,_0x33c935,_0x3d9f2f){const _0x1c334a=a211_0x5a381f;if(!_0x342d32)throw CliErrors[_0x1c334a(0xf7)](_0x1c334a(0xfa)+_0x33c935+'.',_0x1c334a(0x11d)+CLI_BIN_NAME+_0x1c334a(0xf2)+_0x33c935+'`\x20first.');const _0x46b9ed=resolvePageFilePath(_0x1c36f4,_0x33c935,_0x342d32[_0x1c334a(0xec)]);if(!await fileExists(_0x46b9ed))throw CliErrors[_0x1c334a(0xf7)]('Local\x20file\x20not\x20found:\x20'+_0x46b9ed,_0x1c334a(0x11d)+CLI_BIN_NAME+'\x20page\x20pull\x20--id\x20'+_0x33c935+'`\x20first.');const _0x149643=await readFile(_0x46b9ed,_0x1c334a(0x120));try{JSON['parse'](_0x149643);}catch{throw CliErrors[_0x1c334a(0xf7)](_0x1c334a(0xe3)+_0x46b9ed);}const _0x141487=await loadPageDetailForPage(_0x4729e1,_0x33c935);if(_0x3d9f2f!=null&&!_0x141487[_0x1c334a(0xf4)][_0x1c334a(0xe4)](_0x3d9f2f))throw CliErrors['validation'](_0x1c334a(0xd6)+_0x33c935+'\x20no\x20longer\x20belongs\x20to\x20the\x20selected\x20dataset.');const _0x423d68=_0x342d32[_0x1c334a(0x111)]!=null&&_0x141487[_0x1c334a(0x111)]!=null;if(_0x423d68){if(_0x342d32[_0x1c334a(0x111)]!==_0x141487[_0x1c334a(0x111)])throw CliErrors[_0x1c334a(0xf7)](_0x1c334a(0xd5)+_0x33c935+_0x1c334a(0xed),_0x1c334a(0x11d)+CLI_BIN_NAME+'\x20page\x20pull\x20--id\x20'+_0x33c935+_0x1c334a(0x115));}else{const _0x1dec97=computeSerializedSchemaHash(_0x141487[_0x1c334a(0x101)]);if(_0x1dec97!==_0x342d32[_0x1c334a(0x11c)])throw CliErrors['validation'](_0x1c334a(0xd5)+_0x33c935+_0x1c334a(0xed),_0x1c334a(0x11d)+CLI_BIN_NAME+_0x1c334a(0xf2)+_0x33c935+'`\x20first.');}const _0x9afcfd=await prepareLrSmartJsxForPush(_0x149643,_0x141487[_0x1c334a(0x101)],transpileLrSmartJsx);return{'lockEntry':_0x342d32,'localPath':_0x46b9ed,'localContent':_0x9afcfd['content'],'localHash':computePageContentHash(_0x9afcfd[_0x1c334a(0x103)]),'preparedChanges':_0x9afcfd[_0x1c334a(0x126)]>0x0,'remoteDetail':_0x141487};}async function pushPreparedPage(_0x39815d,_0x104202){const _0x1b19da=a211_0x5a381f,_0x1e2918=await updatePage(_0x39815d[_0x1b19da(0xdc)],_0x104202[_0x1b19da(0x11f)][_0x1b19da(0x122)],_0x104202[_0x1b19da(0xd3)],_0x104202[_0x1b19da(0x11f)][_0x1b19da(0xf4)]);if(!_0x1e2918)throw CliErrors['apiError'](_0x1b19da(0x127)+_0x104202[_0x1b19da(0x11f)][_0x1b19da(0x122)]);const _0x59eca9=await loadPageDetailForPage(_0x39815d,_0x104202[_0x1b19da(0x11f)]['pageId']),_0x4ecce7=serializePageSchemaForFile(_0x59eca9[_0x1b19da(0x101)]);return await writeFile(_0x104202['localPath'],_0x4ecce7,_0x1b19da(0x120)),{'pageId':_0x59eca9[_0x1b19da(0x122)],'type':_0x59eca9[_0x1b19da(0xec)],'title':_0x59eca9[_0x1b19da(0x11b)],'normalized':_0x4ecce7!==serializePageSchemaForFile(_0x104202['localContent']),'nextLockEntry':{'hash':computePageContentHash(_0x4ecce7),'pageId':_0x59eca9[_0x1b19da(0x122)],'pageVersion':_0x59eca9[_0x1b19da(0x111)],'type':_0x59eca9[_0x1b19da(0xec)],'title':_0x59eca9[_0x1b19da(0x11b)],'datasetIds':_0x59eca9[_0x1b19da(0xf4)],'versionTag':_0x59eca9[_0x1b19da(0x112)]}};}
|
|
1
|
+
import{readFile,writeFile}from"node:fs/promises";import{APPCODE_FLAG_OPTIONAL,DATASETCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{CLI_BIN_NAME}from"../../constant/cli.js";import{getPageIdFlag,loadDatasetDetailForPage,loadPageDetailForPage,selectVersionTagGroup,serializeDryRunDescription,validatePageTargetSelector}from"../../commands/page/shared.js";import{transpileLrSmartJsx,updatePage}from"../../core/api-client.js";import{computePageContentHash,computeSerializedSchemaHash,serializePageSchemaForFile}from"../../core/page/hash.js";import{fileExists,loadPageProjectConfig,resolvePageFilePath}from"../../core/page/file-system.js";import{createEmptyPageLock,ensurePageLockScope,readPageLockFile,writePageLockFile}from"../../core/page/lock.js";import{prepareLrSmartJsxForPush}from"../../core/page/lr-smart-jsx.js";import{CliErrors}from"../../errors.js";export const pagePush={service:"page",command:"push",description:"Push local page schema back to remote",risk:"write",
|
|
2
|
+
defaultOutputFormat:"compress",flags:[APPCODE_FLAG_OPTIONAL,{name:"id",type:"number",description:"Page ID"},DATASETCODE_FLAG_OPTIONAL,{name:"alias",type:"string",description:"Dataset alias from api.ts (resolves to dataset code automatically)"},{name:"version-tag",type:"string",description:"Page group version tag (batch mode only)"}],async validate(ctx){validatePageTargetSelector(ctx)},async dryRun(ctx){const preview=await buildPushPreview(ctx);return{method:"POST",url:"/smartapi/lovrabet/update-page",body:{appCode:ctx.appCode,mode:preview.mode,datasetCode:preview.datasetCode??null,pages:preview.items},description:serializeDryRunDescription({mode:preview.mode,datasetCode:preview.datasetCode??null,totalWouldPush:preview.items.filter(item=>item.status==="would_push").length,totalUnchanged:preview.items.filter(item=>item.status==="unchanged").length,totalConflicts:preview.items.filter(item=>item.status==="conflict"||item.status==="blocked").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 pageId=getPageIdFlag(ctx);if(pageId!==undefined){const prepared=await prepareSinglePush(ctx,config,appLock.pages[String(pageId)],pageId);const result=await pushPreparedPage(ctx,prepared);appLock.pages[String(result.pageId)]=result.nextLockEntry;appLock.lastSync=(new Date).toISOString();await writePageLockFile(config.lockFilePath,lockData);return{ok:true,message:result.normalized?"Push succeeded; server normalized the schema":"Push succeeded",data:{appCode:ctx.appCode,pushedPages:[{pageId:result.pageId,type:result.type,title:result.title,normalized:result.normalized}],skippedPages:[],failedPages:[],totalPushed:1,totalSkipped:0,totalFailed:0}}}const batch=await buildBatchPushPlan(ctx,appLock.pages);const pushedPages=[];const skippedPages=[];const failedPages=[]
|
|
4
|
+
;for(const candidate of batch.candidates){try{const prepared=await prepareSinglePush(ctx,config,appLock.pages[String(candidate.pageId)],candidate.pageId,batch.datasetId);if(!prepared.preparedChanges&&prepared.localHash===prepared.lockEntry.hash){skippedPages.push({pageId:candidate.pageId,type:candidate.type,title:candidate.title,reason:"no changes"});continue}const result=await pushPreparedPage(ctx,prepared);appLock.pages[String(result.pageId)]=result.nextLockEntry;pushedPages.push({pageId:result.pageId,type:result.type,title:result.title,normalized:result.normalized})}catch(error){failedPages.push({pageId:candidate.pageId,type:candidate.type,title:candidate.title,reason:error instanceof Error?error.message:String(error)})}}appLock.lastSync=(new Date).toISOString();await writePageLockFile(config.lockFilePath,lockData);return{ok:failedPages.length===0||pushedPages.length>0||skippedPages.length>0,
|
|
5
|
+
message:failedPages.length>0&&pushedPages.length>0?"Some pages failed to push":pushedPages.length>0?"Push succeeded":skippedPages.length>0&&failedPages.length===0?"No changes to push":failedPages[0]?.reason||"Push failed",data:{appCode:ctx.appCode,pushedPages:pushedPages,skippedPages:skippedPages,failedPages:failedPages,totalPushed:pushedPages.length,totalSkipped:skippedPages.length,totalFailed:failedPages.length}}}};async function buildPushPreview(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){return{mode:"single",items:[await inspectPushPage(ctx,config,appLock.pages[String(pageId)],pageId)]}}const batch=await buildBatchPushPlan(ctx,appLock.pages);return{mode:"batch",datasetCode:batch.datasetCode,
|
|
6
|
+
items:await Promise.all(batch.candidates.map(candidate=>inspectPushPage(ctx,config,appLock.pages[String(candidate.pageId)],candidate.pageId,batch.datasetId)))}}async function buildBatchPushPlan(ctx,lockPages){const dataset=await loadDatasetDetailForPage(ctx);const datasetId=dataset.id;const activePageIds=new Set(dataset.relatedPages.filter(page=>!page.deleted).map(page=>page.id));const matchedEntries=Object.values(lockPages).filter(entry=>entry.datasetIds.includes(datasetId)&&activePageIds.has(entry.pageId));if(matchedEntries.length===0){throw CliErrors.validation(`No local pages found for dataset "${dataset.code}".`,`Run \`${CLI_BIN_NAME} page pull --datasetcode ${dataset.code}\` first.`)}const selected=selectVersionTagGroup(matchedEntries,entry=>entry.versionTag??null,ctx.str("version-tag"));const candidates=[];for(const entry of selected.items){candidates.push({pageId:entry.pageId,type:entry.type,title:entry.title})}return{datasetCode:dataset.code,datasetId:datasetId,
|
|
7
|
+
candidates:candidates}}async function inspectPushPage(ctx,config,lockEntry,pageId,targetDatasetId){if(!lockEntry){return{pageId:pageId,type:"UNKNOWN",title:`page-${pageId}`,localPath:resolvePageFilePath(config,pageId,"UNKNOWN"),status:"blocked",reason:`Run \`${CLI_BIN_NAME} page pull --id ${pageId}\` first`}}const localPath=resolvePageFilePath(config,pageId,lockEntry.type);if(!await fileExists(localPath)){return{pageId:pageId,type:lockEntry.type,title:lockEntry.title,localPath:localPath,status:"blocked",reason:`Local file not found: ${localPath}`}}const localContent=await readFile(localPath,"utf8");try{JSON.parse(localContent)}catch{return{pageId:pageId,type:lockEntry.type,title:lockEntry.title,localPath:localPath,status:"blocked",reason:"local JSON is invalid"}}try{const remoteDetail=await loadPageDetailForPage(ctx,pageId);if(targetDatasetId!=null&&!remoteDetail.datasetIds.includes(targetDatasetId)){return{pageId:pageId,type:lockEntry.type,title:lockEntry.title,localPath:localPath,
|
|
8
|
+
status:"conflict",reason:`Page ${pageId} no longer belongs to the target dataset`}}const hasVersion=lockEntry.pageVersion!=null&&remoteDetail.pageVersion!=null;if(hasVersion&&lockEntry.pageVersion!==remoteDetail.pageVersion){return{pageId:pageId,type:lockEntry.type,title:lockEntry.title,localPath:localPath,status:"conflict",reason:"remote pageVersion changed"}}if(!hasVersion&&computeSerializedSchemaHash(remoteDetail.code)!==lockEntry.hash){return{pageId:pageId,type:lockEntry.type,title:lockEntry.title,localPath:localPath,status:"conflict",reason:"remote schema changed"}}const preparedJsx=await prepareLrSmartJsxForPush(localContent,remoteDetail.code,transpileLrSmartJsx);if(preparedJsx.normalizedNodes===0&&computePageContentHash(preparedJsx.content)===lockEntry.hash){return{pageId:pageId,type:lockEntry.type,title:lockEntry.title,localPath:localPath,status:"unchanged",reason:"no changes"}}}catch(error){return{pageId:pageId,type:lockEntry.type,title:lockEntry.title,localPath:localPath,
|
|
9
|
+
status:"blocked",reason:error instanceof Error?error.message:String(error)}}return{pageId:pageId,type:lockEntry.type,title:lockEntry.title,localPath:localPath,status:"would_push"}}async function prepareSinglePush(ctx,config,lockEntry,pageId,targetDatasetId){if(!lockEntry){throw CliErrors.validation(`No lock record found for page ${pageId}.`,`Run \`${CLI_BIN_NAME} page pull --id ${pageId}\` first.`)}const localPath=resolvePageFilePath(config,pageId,lockEntry.type);if(!await fileExists(localPath)){throw CliErrors.validation(`Local file not found: ${localPath}`,`Run \`${CLI_BIN_NAME} page pull --id ${pageId}\` first.`)}const localContent=await readFile(localPath,"utf8");try{JSON.parse(localContent)}catch{throw CliErrors.validation(`Invalid JSON in local page file: ${localPath}`)}const remoteDetail=await loadPageDetailForPage(ctx,pageId);if(targetDatasetId!=null&&!remoteDetail.datasetIds.includes(targetDatasetId)){
|
|
10
|
+
throw CliErrors.validation(`Page ${pageId} no longer belongs to the selected dataset.`)}const hasVersion=lockEntry.pageVersion!=null&&remoteDetail.pageVersion!=null;if(hasVersion){if(lockEntry.pageVersion!==remoteDetail.pageVersion){throw CliErrors.validation(`Remote page ${pageId} has changed since last pull.`,`Run \`${CLI_BIN_NAME} page pull --id ${pageId}\` first.`)}}else{const remoteHash=computeSerializedSchemaHash(remoteDetail.code);if(remoteHash!==lockEntry.hash){throw CliErrors.validation(`Remote page ${pageId} has changed since last pull.`,`Run \`${CLI_BIN_NAME} page pull --id ${pageId}\` first.`)}}const preparedJsx=await prepareLrSmartJsxForPush(localContent,remoteDetail.code,transpileLrSmartJsx);return{lockEntry:lockEntry,localPath:localPath,localContent:preparedJsx.content,localHash:computePageContentHash(preparedJsx.content),preparedChanges:preparedJsx.normalizedNodes>0,remoteDetail:remoteDetail}}async function pushPreparedPage(ctx,prepared){
|
|
11
|
+
const didUpdate=await updatePage(ctx.appCode,prepared.remoteDetail.pageId,prepared.localContent,prepared.remoteDetail.datasetIds);if(!didUpdate){throw CliErrors.apiError(`Page update failed: ${prepared.remoteDetail.pageId}`)}const canonicalDetail=await loadPageDetailForPage(ctx,prepared.remoteDetail.pageId);const canonicalContent=serializePageSchemaForFile(canonicalDetail.code);await writeFile(prepared.localPath,canonicalContent,"utf8");return{pageId:canonicalDetail.pageId,type:canonicalDetail.type,title:canonicalDetail.name,normalized:canonicalContent!==serializePageSchemaForFile(prepared.localContent),nextLockEntry:{hash:computePageContentHash(canonicalContent),pageId:canonicalDetail.pageId,pageVersion:canonicalDetail.pageVersion,type:canonicalDetail.type,title:canonicalDetail.name,datasetIds:canonicalDetail.datasetIds,versionTag:canonicalDetail.versionTag}}}
|