@lovrabet/rabetbase-cli 2.5.13 → 2.6.0-beta.2
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
- package/templates/README.md +0 -130
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import chalk from"chalk";import{buildCompareRows,doCreateMenus,fetchMenuData}from"../../commands/menu/shared/logic.js";import{renderCompareTable,renderSyncSummary}from"../../commands/menu/shared/compare-table.js";import{selectPages,askJsUrl,askCssUrl,askConfirm,startSpinner,stopSpinner,isInteractive,requireInteractive}from"../../commands/menu/shared/inquirer.js";import{CliErrors}from"../../errors.js";import{writeCliSideChannelLine}from"../../utils/write-cli-side-channel.js";import{parseMenuSyncParams,resolvePage,runMenuSyncCore}from"../../commands/menu/shared/sync-core.js";import{getLocalPages}from"../../commands/menu/shared/local-pages.js";import{isInProject}from"../../context.js";import{assertSharedResourcesConfigured}from"../../commands/menu/shared/subapp-assets.js";export const menuSync={service:"menu",command:"sync",description:"Register local pages as platform menus",risk:"write",flags:[{name:"params",type:"string",
|
|
2
|
+
description:"Prefer appName for shared subapp resources and parentId for planned groups. "+'JSON: {"appName":"store-app","parentId":42,"visible":false}; jsUrl and cssUrl remain available for individual menu resources.'},{name:"paths",type:"string",description:"Exact comma-separated local page paths to sync"},{name:"yes",type:"boolean",description:"Confirm non-interactive sync; without --paths, create all missing local pages"}],async dryRun(ctx){ensureRunnableContext(ctx.rawFlags,ctx.selectedAppName);const preview=await runMenuSyncCore(ctx.appCode,ctx.cookie,parsePaths(ctx.str("paths")),ctx.str("params"),{dryRun:true});return{method:"POST",url:"/smartapi/menu/create",body:preview,description:preview.skipped?"No local microfrontend menus would be created.":`Would create ${preview.targetPages.length} local microfrontend menu(s).`}},async execute(ctx){ensureRunnableContext(ctx.rawFlags,ctx.selectedAppName);const yes=ctx.flag("yes");const paramsStr=ctx.str("params")
|
|
3
|
+
;const selectedPaths=parsePaths(ctx.str("paths"));const params=parseMenuSyncParams(paramsStr);if(yes){const result=await runMenuSyncCore(ctx.appCode,ctx.cookie,selectedPaths,paramsStr);if(result.skipped){const localPages=getLocalPages();if(localPages.length===0){writeCliSideChannelLine("! No local pages found in src/pages")}else{writeCliSideChannelLine("✓ All local pages are already on platform")}}else{writeCliSideChannelLine(`✓ Menu sync completed: ${result.created} menu(s) created`)}return{ok:true,data:result,message:result.skipped?"Menu sync skipped":`Menu sync completed: ${result.created} created.`}}if(selectedPaths.length>0){throw CliErrors.validation("menu sync --paths requires --yes for execution.","Preview with --dry-run, then reuse the same --paths and --params with --yes.")}if(!isInteractive()&¶msStr){throw CliErrors.validation("Non-interactive menu sync requires --yes.","Preview with --dry-run, then reuse the same --paths and --params with --yes.")}requireInteractive()
|
|
4
|
+
;writeCliSideChannelLine("Tip: For frontend subapps, prefer Agent-planned menu groups and shared resources. This manual sync workflow remains available as a fallback.");const spinner=startSpinner("Fetching online menu list...");let localPages;let onlinePaths;let onlineMenuList;try{const data=await fetchMenuData(ctx.appCode,ctx.cookie);localPages=data.localPages;onlinePaths=data.onlinePaths;onlineMenuList=data.onlineMenuList;stopSpinner(spinner,"Online menu list fetched",true)}catch(err){stopSpinner(spinner,"Failed to fetch online menu list",false);throw CliErrors.validation(err instanceof Error?err.message:"Failed to fetch online menu list")}if(localPages.length===0){writeCliSideChannelLine(chalk.yellow(" ! No local pages found, please create pages first"));return{ok:true}}const compareRows=buildCompareRows(localPages,onlinePaths);writeCliSideChannelLine(renderCompareTable(compareRows));writeCliSideChannelLine("");const selectedPages=await selectPages(localPages,onlinePaths)
|
|
5
|
+
;writeCliSideChannelLine("");writeCliSideChannelLine(chalk.cyan(` ✓ Selected: ${selectedPages.length} page(s)`));const hasFullUrls=params.jsUrl&¶ms.cssUrl;if(!hasFullUrls){writeCliSideChannelLine(renderSyncSummary(selectedPages,onlinePaths.size>0));const confirmed=await askConfirm(" Continue with creation?");if(!confirmed){writeCliSideChannelLine(chalk.gray(" Cancelled."));return{ok:true}}}let jsUrl=params.jsUrl;let cssUrl=params.cssUrl;if(!jsUrl&&!params.appName){jsUrl=await askJsUrl()}if(!cssUrl&&!params.appName){cssUrl=await askCssUrl()}const confirmed=await askConfirm(params.appName?` Create ${selectedPages.length} menu(s) bound to ${params.appName}?`:` Create ${selectedPages.length} menu(s) with JS: ${jsUrl} and CSS: ${cssUrl}?`);if(!confirmed){writeCliSideChannelLine(chalk.gray(" Cancelled."));return{ok:true}}const resources=[jsUrl,cssUrl].filter(url=>Boolean(url));if(params.appName&&resources.length===0){
|
|
6
|
+
await assertSharedResourcesConfigured(ctx.appCode,ctx.cookie,params.appName)}const execSpinner=startSpinner(`Creating ${selectedPages.length} menu(s)...`);try{const preparedPages=selectedPages.map(page=>resolvePage(page,params,onlineMenuList));const result=await doCreateMenus(ctx.appCode,ctx.cookie,preparedPages,resources,params.appName?{appName:params.appName}:undefined);stopSpinner(execSpinner,`Created ${result.created} menu(s)`,true);return{ok:true,data:result,message:`Menu sync completed: ${result.created} created, ${result.failed} failed.`}}catch(err){stopSpinner(execSpinner,"Menu creation failed",false);throw CliErrors.validation(err instanceof Error?err.message:"Menu creation failed")}}};function ensureRunnableContext(rawFlags,selectedAppName){const explicitAppcode=rawFlags.appcode?String(rawFlags.appcode).trim():"";if(!isInProject()&&!selectedAppName&&!explicitAppcode){
|
|
7
|
+
throw CliErrors.validation("menu sync requires a project context or explicit --appcode. "+"Run inside a directory with .rabetbase.json, or pass --appcode <code>.")}}function parsePaths(value){return[...new Set(value.split(",").map(path=>path.trim()).filter(Boolean))]}
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
const a191_0x50d41e=a191_0x51f7;(function(_0x5c5d99,_0x22c090){const _0x272917=a191_0x51f7,_0xa466d0=_0x5c5d99();while(!![]){try{const _0x14035c=parseInt(_0x272917(0x149))/0x1*(parseInt(_0x272917(0xf0))/0x2)+parseInt(_0x272917(0xfa))/0x3+-parseInt(_0x272917(0xf9))/0x4+-parseInt(_0x272917(0x148))/0x5*(parseInt(_0x272917(0x142))/0x6)+parseInt(_0x272917(0x108))/0x7+parseInt(_0x272917(0xe8))/0x8+-parseInt(_0x272917(0x125))/0x9;if(_0x14035c===_0x22c090)break;else _0xa466d0['push'](_0xa466d0['shift']());}catch(_0xa0cca4){_0xa466d0['push'](_0xa466d0['shift']());}}}(a191_0x4d97,0xd156d));import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{fetchMenuSnapshot}from'../../commands/menu/shared/facts.js';import{asVerificationError,assertVerified,describeMenuErrorCause,fetchMutationSnapshot,hasFlag,isMenuResponseLoss,mapMenuApiError,menuDryRunResult,menuError,menuFailure,mutationResult,recheckMutationSnapshot}from'../../commands/menu/shared/mutations.js';import{updateMenuEntity}from'../../commands/menu/shared/service.js';import{CliErrors}from'../../errors.js';const BACKEND=[{'method':a191_0x50d41e(0x130),'path':a191_0x50d41e(0xde)}];export const menuVisibilityUpdate={'service':a191_0x50d41e(0x13e),'command':'visibility-update','description':a191_0x50d41e(0xed),'risk':'write','structuredErrors':!![],'flags':[{'name':a191_0x50d41e(0x124),'type':a191_0x50d41e(0x128),'description':'Exact\x20comma-separated\x20menu\x20IDs\x20to\x20update'},{'name':a191_0x50d41e(0xe6),'type':a191_0x50d41e(0x128),'description':'Exact\x20comma-separated\x20menu\x20paths\x20to\x20update'},{'name':a191_0x50d41e(0x14e),'type':'boolean','required':!![],'description':a191_0x50d41e(0xec)},{'name':a191_0x50d41e(0x117),'type':'boolean','description':a191_0x50d41e(0xdf)},{'name':a191_0x50d41e(0x107),'type':a191_0x50d41e(0x147),'description':'Abort\x20unless\x20the\x20exact\x20number\x20of\x20selected\x20menus\x20matches'},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x2f68c2){parseInput(_0x2f68c2);},async 'dryRun'(_0x5d0f44){const _0x4f2787=a191_0x50d41e,_0x2d8dbe=await buildPlan(_0x5d0f44,!![]),_0x5cc0c6=_0x2d8dbe[_0x4f2787(0xfe)]['plannedActions']?.[_0x4f2787(0x10d)]??0x0,_0x36f576=_0x2d8dbe[_0x4f2787(0xfe)][_0x4f2787(0xeb)][_0x4f2787(0x10d)]-_0x5cc0c6;return menuDryRunResult(_0x2d8dbe[_0x4f2787(0xfe)],{'method':_0x4f2787(0x130),'url':'/smartapi/menu/update','body':{'updates':_0x2d8dbe[_0x4f2787(0xfe)][_0x4f2787(0x12a)]?.[_0x4f2787(0x137)](_0x3c3ab9=>_0x3c3ab9[_0x4f2787(0x139)])??[]},'description':'Would\x20update\x20visibility\x20for\x20'+_0x5cc0c6+_0x4f2787(0x10e)+_0x36f576+_0x4f2787(0x136)});},async 'execute'(_0x10b8a1){const _0x414362=a191_0x50d41e,_0x4ed990=await buildPlan(_0x10b8a1,![]);await recheckMutationSnapshot(_0x10b8a1,_0x4ed990[_0x414362(0xfe)],_0x414362(0x11d));const _0x1c2192=[],_0x394a46=[],_0x4603fa=[];for(const _0x273de4 of _0x4ed990['plan'][_0x414362(0xeb)]){if(_0x273de4[_0x414362(0x115)]['visible']===_0x4ed990['plan'][_0x414362(0xdc)]){_0x1c2192['push']({'id':_0x273de4['id'],'updated':![],'skipped':!![]});continue;}try{await updateMenuEntity(_0x10b8a1[_0x414362(0xf5)],_0x10b8a1[_0x414362(0x11e)],{'id':_0x273de4['id'],'visible':_0x4ed990[_0x414362(0xfe)][_0x414362(0xdc)]}),_0x1c2192[_0x414362(0xf6)]({'id':_0x273de4['id'],'updated':!![],'skipped':![]});}catch(_0x1b6ed1){const _0x2fd3ac=mapMenuApiError(_0x1b6ed1,_0x414362(0x110),_0x273de4['id']);if(isMenuResponseLoss(_0x1b6ed1)&&_0x2fd3ac[_0x414362(0x116)]!==_0x414362(0x13b)){_0x4603fa[_0x414362(0xf6)](_0x273de4['id']);continue;}_0x394a46[_0x414362(0xf6)]({'id':_0x273de4['id'],'stage':'update','code':_0x2fd3ac['code'],'message':_0x2fd3ac[_0x414362(0xe9)]});}}let _0x7b4f17;try{_0x7b4f17=await fetchMenuSnapshot(_0x10b8a1[_0x414362(0xf5)],_0x10b8a1['cookie']);}catch(_0x216770){const _0x1fe786=describeMenuErrorCause(_0x216770,'verify\x20menu\x20visibility\x20update'),_0x43e3ad=_0x4603fa[_0x414362(0x137)](_0x3754c3=>({'id':_0x3754c3,'stage':'update-recovery','code':_0x414362(0x126),'message':_0x414362(0xf1)+_0x3754c3+_0x414362(0x12d),'requestedStateConfirmed':![],'recovered':![]})),_0x420826={'stage':'verification','code':_0x414362(0x126),'message':_0x414362(0x10f),'targetIds':_0x4ed990[_0x414362(0xfe)][_0x414362(0xeb)][_0x414362(0x137)](_0x37de22=>_0x37de22['id']),'requestedStateConfirmed':![],..._0x1fe786};throw menuFailure(asVerificationError(_0x216770,'Visibility\x20update\x20requests\x20completed\x20but\x20readback\x20could\x20not\x20confirm\x20the\x20requested\x20state'),_0x4ed990[_0x414362(0xfe)],{'stage':'verification','succeeded':_0x1c2192,'failedRecords':[..._0x394a46,..._0x43e3ad,_0x420826],'warnings':[_0x414362(0xe5)],'verification':{'status':_0x414362(0x102),'recoveredCount':0x0,'lookupCommand':_0x414362(0x14b)}});}const _0x3c1fd9=[];for(const _0x3d0b67 of _0x1c2192){const _0x557d44=Number(_0x3d0b67['id']),_0x23014f=_0x4ed990['beforeById'][_0x414362(0x127)](_0x557d44),_0x27d0a5=_0x7b4f17[_0x414362(0xf2)]['get'](_0x557d44);try{verifyVisibilityUpdate(_0x23014f,_0x27d0a5,_0x4ed990[_0x414362(0xfe)][_0x414362(0xdc)]);}catch(_0x4fb580){const _0x48c5db=asVerificationError(_0x4fb580,'Menu\x20'+_0x557d44+_0x414362(0x12e));_0x3c1fd9[_0x414362(0xf6)]({'id':_0x557d44,'stage':'verification','code':_0x48c5db[_0x414362(0x116)],'message':_0x48c5db[_0x414362(0xe9)],'requestedStateConfirmed':![]});}}for(const _0x325836 of _0x4603fa){const _0x52d1ef=_0x4ed990[_0x414362(0xda)][_0x414362(0x127)](_0x325836),_0x22f209=_0x7b4f17['byId'][_0x414362(0x127)](_0x325836);try{verifyVisibilityUpdate(_0x52d1ef,_0x22f209,_0x4ed990[_0x414362(0xfe)][_0x414362(0xdc)]),_0x1c2192[_0x414362(0xf6)]({'id':_0x325836,'updated':!![],'skipped':![],'recovered':!![]});}catch(_0x557014){const _0x536cfc=asVerificationError(_0x557014,_0x414362(0x132)+_0x325836+'\x20visibility\x20could\x20not\x20be\x20verified\x20safely');_0x3c1fd9[_0x414362(0xf6)]({'id':_0x325836,'stage':_0x414362(0x105),'code':_0x536cfc[_0x414362(0x116)],'message':_0x536cfc['message'],'requestedStateConfirmed':![],'recovered':![]});}}if(_0x3c1fd9[_0x414362(0x10d)]>0x0){const _0x34b053=_0x3c1fd9[_0x414362(0x137)](_0x41ae70=>Number(_0x41ae70['id'])),_0x261425=_0x1c2192[_0x414362(0x119)](_0x12d9d4=>_0x12d9d4['recovered']===!![])[_0x414362(0x10d)],_0x1b02ca=menuError(_0x414362(0x126),_0x414362(0x133)+_0x34b053[_0x414362(0xdb)](',\x20')+'.',_0x414362(0xd9));throw menuFailure(_0x1b02ca,_0x4ed990[_0x414362(0xfe)],{'stage':_0x414362(0x11f),'succeeded':_0x1c2192,'failedRecords':[..._0x394a46,..._0x3c1fd9],'warnings':[_0x414362(0x143)],'verification':{'status':_0x414362(0x102),..._0x34b053['length']===0x1?{'targetId':_0x34b053[0x0]}:{'targetIds':_0x34b053},'recoveredCount':_0x261425,'lookupCommand':_0x414362(0x14b)}});}const _0x1733e5=_0x1c2192[_0x414362(0x119)](_0x3d9633=>_0x3d9633['updated']===!![])[_0x414362(0x10d)],_0x3d6045=_0x1c2192[_0x414362(0x10d)]-_0x1733e5,_0x265c06={..._0x4ed990[_0x414362(0xfe)],'succeeded':_0x1c2192,'failed':_0x394a46,'warnings':_0x394a46[_0x414362(0x10d)]>0x0?[..._0x4ed990[_0x414362(0xfe)][_0x414362(0x135)],_0x414362(0xf8)]:_0x4ed990['plan'][_0x414362(0x135)],'verification':{'checkedBy':'menu\x20list','snapshotHash':_0x7b4f17['hash'],'matchesRequestedState':_0x394a46[_0x414362(0x10d)]===0x0,'recoveredCount':_0x4603fa[_0x414362(0x10d)]}};return{'ok':_0x394a46[_0x414362(0x10d)]===0x0,'data':_0x265c06,'message':_0x394a46[_0x414362(0x10d)]===0x0?_0x414362(0x104)+_0x1733e5+_0x414362(0x118)+_0x3d6045+_0x414362(0x136):_0x414362(0xe0)+_0x1733e5+_0x414362(0x114)+_0x3d6045+_0x414362(0x113)+_0x394a46[_0x414362(0x10d)]+_0x414362(0x122)};}};function parseInput(_0x131f82){const _0x5e2141=a191_0x50d41e,_0x5edbaf=parseMenuIds(_0x131f82[_0x5e2141(0xfc)](_0x5e2141(0x124))),_0x343b75=parseCsv(_0x131f82[_0x5e2141(0xfc)](_0x5e2141(0xe6)));if(_0x5edbaf[_0x5e2141(0x10d)]===0x0&&_0x343b75[_0x5e2141(0x10d)]===0x0)throw CliErrors[_0x5e2141(0xdd)]('menu\x20visibility-update\x20requires\x20--menu-ids\x20or\x20--paths.');const _0x535848=parseBooleanFlag(_0x131f82,_0x5e2141(0x14e),!![]),_0x155577=parseBooleanFlag(_0x131f82,_0x5e2141(0x117),![]);let _0x415f35;if(hasFlag(_0x131f82,'expected-count')){_0x415f35=_0x131f82[_0x5e2141(0x123)](_0x5e2141(0x107));if(!Number[_0x5e2141(0xf7)](_0x415f35)||_0x415f35<0x0)throw CliErrors[_0x5e2141(0xdd)](_0x5e2141(0x109));}return{'menuIds':_0x5edbaf,'paths':_0x343b75,'visible':_0x535848,'expectVisible':_0x155577,'expectedCount':_0x415f35};}async function buildPlan(_0x3186a7,_0x465542){const _0xd2b5f7=a191_0x50d41e,_0x230433=parseInput(_0x3186a7),_0x435cab=await fetchMutationSnapshot(_0x3186a7,_0xd2b5f7(0x11d)),_0x249110=selectTargets(_0x435cab['menus'],_0x230433[_0xd2b5f7(0x112)],_0x230433[_0xd2b5f7(0xe6)]);if(_0x230433[_0xd2b5f7(0x138)]!==undefined&&_0x249110[_0xd2b5f7(0x10d)]!==_0x230433[_0xd2b5f7(0x138)])throw menuError(_0xd2b5f7(0x13c),_0xd2b5f7(0x100)+_0x249110[_0xd2b5f7(0x10d)]+'\x20menu(s),\x20expected\x20'+_0x230433[_0xd2b5f7(0x138)]+'.',_0xd2b5f7(0x13a));if(_0x230433[_0xd2b5f7(0xe2)]!==undefined){const _0x43dd29=_0x249110[_0xd2b5f7(0x119)](_0x3dd3bb=>_0x3dd3bb[_0xd2b5f7(0x14e)]!==_0x230433['expectVisible']);if(_0x43dd29[_0xd2b5f7(0x10d)]>0x0)throw menuError(_0xd2b5f7(0x10a),'Selected\x20menu\x20visibility\x20changed\x20for\x20id(s):\x20'+_0x43dd29[_0xd2b5f7(0x137)](_0x20c535=>_0x20c535['id'])[_0xd2b5f7(0xdb)](',\x20')+'.',_0xd2b5f7(0x14d));}const _0x202f3b=_0x249110[_0xd2b5f7(0x137)](_0x466fc7=>({'id':_0x466fc7['id'],'label':_0x466fc7[_0xd2b5f7(0x14c)],'path':_0x466fc7[_0xd2b5f7(0x141)],'before':{'visible':_0x466fc7[_0xd2b5f7(0x14e)]},'after':{'visible':_0x230433[_0xd2b5f7(0x14e)]}})),_0x580a6d=_0x202f3b[_0xd2b5f7(0x119)](_0x2c5683=>_0x2c5683[_0xd2b5f7(0x115)]['visible']!==_0x230433['visible'])[_0xd2b5f7(0x137)](_0x3d213a=>({'stage':_0xd2b5f7(0xff),'method':'POST','path':_0xd2b5f7(0xde),'body':{'appCode':_0x3186a7[_0xd2b5f7(0xf5)],'id':_0x3d213a['id'],'visible':_0x230433[_0xd2b5f7(0x14e)]}})),_0x1b6f1b=mutationResult({'operation':'visibility-update','selector':{'menuIds':_0x230433[_0xd2b5f7(0x112)],'paths':_0x230433['paths']},'before':{'menus':_0x249110[_0xd2b5f7(0x137)](_0xa69865=>({'id':_0xa69865['id'],'path':_0xa69865[_0xd2b5f7(0x141)],'visible':_0xa69865['visible']}))},'after':{'menus':_0x249110['map'](_0x2dbddc=>({'id':_0x2dbddc['id'],'path':_0x2dbddc[_0xd2b5f7(0x141)],'visible':_0x230433[_0xd2b5f7(0x14e)]}))},'dryRun':_0x465542,'backend':[...BACKEND],'plannedActions':_0x580a6d,'snapshotHash':_0x435cab[_0xd2b5f7(0x12f)],'warnings':_0x580a6d['length']===0x0?['Every\x20selected\x20menu\x20already\x20has\x20the\x20requested\x20visibility;\x20no\x20write\x20is\x20needed.']:[]});return{'plan':{..._0x1b6f1b,'requestedVisible':_0x230433[_0xd2b5f7(0x14e)],'targets':_0x202f3b},'beforeById':new Map(_0x249110[_0xd2b5f7(0x137)](_0x5afdc4=>[_0x5afdc4['id'],_0x5afdc4]))};}function selectTargets(_0x5b7c9e,_0x35e10f,_0xb67d85){const _0x396b05=a191_0x50d41e,_0xa43086=new Map(_0x5b7c9e[_0x396b05(0x137)](_0x4ab788=>[_0x4ab788['id'],_0x4ab788])),_0x144bd8=new Map(),_0x59c684=_0x35e10f[_0x396b05(0x119)](_0x2b8141=>!_0xa43086[_0x396b05(0x146)](_0x2b8141));if(_0x59c684[_0x396b05(0x10d)]>0x0)throw menuError('menu_selector_not_found','Menu\x20id\x20selector(s)\x20not\x20found:\x20'+_0x59c684[_0x396b05(0xdb)](',\x20')+'.','Run\x20`rabetbase\x20menu\x20list\x20--format\x20compress`\x20and\x20use\x20exact\x20current\x20ids.');for(const _0x2310dd of _0x35e10f){_0x144bd8[_0x396b05(0x103)](_0x2310dd,_0xa43086['get'](_0x2310dd));}for(const _0x19fcd4 of _0xb67d85){const _0x36205a=_0x5b7c9e[_0x396b05(0x119)](_0x3f7ae7=>_0x3f7ae7['path']===_0x19fcd4);if(_0x36205a[_0x396b05(0x10d)]===0x0)throw menuError(_0x396b05(0x144),_0x396b05(0xee)+JSON[_0x396b05(0xe3)](_0x19fcd4)+'.',_0x396b05(0xfd));if(_0x36205a[_0x396b05(0x10d)]>0x1)throw menuError(_0x396b05(0xe1),_0x396b05(0x14f)+JSON[_0x396b05(0xe3)](_0x19fcd4)+'.',_0x396b05(0xd8)+_0x36205a[_0x396b05(0x137)](_0x32c029=>_0x32c029['id'])[_0x396b05(0xdb)](',\x20')+'.');const _0x784462=_0x36205a[0x0];_0x144bd8[_0x396b05(0x103)](_0x784462['id'],_0x784462);}return[..._0x144bd8[_0x396b05(0x101)]()];}function a191_0x4d97(){const _0x5e1cb7=['failed','set','Updated\x20visibility\x20for\x20','update-recovery','modelType','expected-count','3024777vmYkGS','--expected-count\x20must\x20be\x20a\x20non-negative\x20integer.','menu_state_drift','flagMissing','childrenIds','length','\x20menu(s);\x20skip\x20','Final\x20menu\x20visibility\x20readback\x20failed.','update\x20visibility\x20for','\x20changed\x20unexpectedly.','menuIds','\x20skipped,\x20','\x20updated,\x20','before','code','expect-visible','\x20menu(s);\x20skipped\x20','filter','--menu-ids\x20must\x20contain\x20positive\x20safe\x20integers.','datasetId','datasetCode','update\x20menu\x20visibility','cookie','verification','\x20was\x20not\x20found\x20during\x20visibility\x20verification.','pageType','\x20failed.','num','menu-ids','4974309CaHSDo','menu_verification_failed','get','string','type','plannedActions','childrenCount','\x20must\x20be\x20true\x20or\x20false.','\x20and\x20final\x20state\x20could\x20not\x20be\x20read.','\x20visibility\x20update\x20could\x20not\x20be\x20verified','hash','POST','false','Response\x20was\x20lost\x20and\x20menu\x20','Menu\x20visibility\x20update\x20could\x20not\x20be\x20verified\x20for\x20id(s):\x20','url','warnings','\x20unchanged\x20menu(s).','map','expectedCount','body','Run\x20the\x20command\x20with\x20--dry-run\x20again\x20and\x20update\x20--expected-count.','menu_permission_denied','menu_expected_count_mismatch','split','menu','resources','some','path','12CLHgVU','One\x20or\x20more\x20updates\x20may\x20have\x20changed\x20fields\x20outside\x20visibility;\x20inspect\x20current\x20menu\x20facts\x20before\x20retrying.','menu_selector_not_found','depth','has','number','1508530vAMZaF','107ZtERwS','rawFlags','rabetbase\x20menu\x20list\x20--format\x20compress','label','Run\x20the\x20command\x20with\x20--dry-run\x20again\x20and\x20update\x20--expect-visible.','visible','Menu\x20path\x20selector\x20matched\x20multiple\x20menus:\x20','parentId','Use\x20--menu-ids\x20with\x20one\x20or\x20more\x20of:\x20','Inspect\x20current\x20menu\x20facts\x20before\x20retrying\x20any\x20target.','beforeById','join','requestedVisible','validation','/smartapi/menu/update','Abort\x20unless\x20every\x20selected\x20menu\x20has\x20this\x20visibility','Menu\x20visibility\x20update\x20completed:\x20','menu_selector_ambiguous','expectVisible','stringify','sort','The\x20update\x20may\x20have\x20taken\x20effect;\x20inspect\x20the\x20latest\x20menu\x20facts\x20before\x20retrying.','paths','isArray','8208616XkkgUf','message','Menu\x20','targets','Requested\x20menu\x20visibility','Set\x20exact\x20menus\x20visible\x20or\x20hidden\x20without\x20changing\x20their\x20routes\x20or\x20resources','Menu\x20path\x20selector\x20not\x20found:\x20','trim','14714mRVDRs','Response\x20was\x20lost\x20for\x20menu\x20','byId','pageId','resourcesValid','appCode','push','isSafeInteger','Failed\x20update\x20requests\x20were\x20not\x20retried;\x20inspect\x20current\x20menu\x20facts\x20before\x20retrying.','6352432yWIHqJ','4068861RqzydS','true','str','Run\x20`rabetbase\x20menu\x20list\x20--format\x20compress`\x20and\x20use\x20an\x20exact\x20current\x20path.','plan','update-menu-visibility','Selected\x20','values'];a191_0x4d97=function(){return _0x5e1cb7;};return a191_0x4d97();}function parseMenuIds(_0x238271){const _0x25396d=a191_0x50d41e,_0x12317d=parseCsv(_0x238271),_0x46c8a4=_0x12317d[_0x25396d(0x137)](Number);if(_0x46c8a4[_0x25396d(0x140)](_0x5c0a5b=>!Number[_0x25396d(0xf7)](_0x5c0a5b)||_0x5c0a5b<=0x0))throw CliErrors[_0x25396d(0xdd)](_0x25396d(0x11a));return[...new Set(_0x46c8a4)];}function parseCsv(_0x3bdc65){const _0x58d8a2=a191_0x50d41e;return[...new Set(_0x3bdc65[_0x58d8a2(0x13d)](',')[_0x58d8a2(0x137)](_0x51f7ad=>_0x51f7ad[_0x58d8a2(0xef)]())[_0x58d8a2(0x119)](Boolean))];}function a191_0x51f7(_0x4c9e24,_0x67de63){_0x4c9e24=_0x4c9e24-0xd7;const _0x4d979a=a191_0x4d97();let _0x51f702=_0x4d979a[_0x4c9e24];return _0x51f702;}function parseBooleanFlag(_0x501e9a,_0xdb7137,_0x31a29b){const _0x433df5=a191_0x50d41e;if(!hasFlag(_0x501e9a,_0xdb7137)){if(_0x31a29b)throw CliErrors[_0x433df5(0x10b)](_0xdb7137);return undefined;}const _0xd91c88=_0x501e9a[_0x433df5(0x14a)][_0xdb7137];if(_0xd91c88===!![]||_0xd91c88===![])return _0xd91c88;if(_0xd91c88===_0x433df5(0xfb))return!![];if(_0xd91c88===_0x433df5(0x131))return![];throw CliErrors[_0x433df5(0xdd)]('--'+_0xdb7137+_0x433df5(0x12c));}function verifyVisibilityUpdate(_0x3ca4a7,_0x559bca,_0x4a7b6d){const _0x35a424=a191_0x50d41e;assertVerified(!!_0x559bca,_0x35a424(0xea)+_0x3ca4a7['id']+_0x35a424(0x120)),assertVerified(_0x559bca[_0x35a424(0x14e)]===_0x4a7b6d,'Menu\x20'+_0x3ca4a7['id']+'\x20visible\x20did\x20not\x20match\x20the\x20requested\x20state.');const _0x2a4f84=[['id',_0x559bca['id'],_0x3ca4a7['id']],['parentId',_0x559bca[_0x35a424(0xd7)],_0x3ca4a7[_0x35a424(0xd7)]],['depth',_0x559bca[_0x35a424(0x145)],_0x3ca4a7[_0x35a424(0x145)]],['label',_0x559bca[_0x35a424(0x14c)],_0x3ca4a7[_0x35a424(0x14c)]],[_0x35a424(0x141),_0x559bca[_0x35a424(0x141)],_0x3ca4a7[_0x35a424(0x141)]],[_0x35a424(0x134),_0x559bca[_0x35a424(0x134)],_0x3ca4a7[_0x35a424(0x134)]],[_0x35a424(0x129),_0x559bca[_0x35a424(0x129)],_0x3ca4a7['type']],[_0x35a424(0xe4),_0x559bca[_0x35a424(0xe4)],_0x3ca4a7[_0x35a424(0xe4)]],[_0x35a424(0x13f),_0x559bca[_0x35a424(0x13f)],_0x3ca4a7[_0x35a424(0x13f)]],['resourcesValid',_0x559bca[_0x35a424(0xf4)],_0x3ca4a7[_0x35a424(0xf4)]],[_0x35a424(0x10c),_0x559bca[_0x35a424(0x10c)],_0x3ca4a7[_0x35a424(0x10c)]],[_0x35a424(0x12b),_0x559bca[_0x35a424(0x12b)],_0x3ca4a7[_0x35a424(0x12b)]],['pageId',_0x559bca['pageId'],_0x3ca4a7[_0x35a424(0xf3)]],[_0x35a424(0x121),_0x559bca[_0x35a424(0x121)],_0x3ca4a7['pageType']],[_0x35a424(0x106),_0x559bca[_0x35a424(0x106)],_0x3ca4a7[_0x35a424(0x106)]],[_0x35a424(0x11b),_0x559bca['datasetId'],_0x3ca4a7[_0x35a424(0x11b)]],[_0x35a424(0x11c),_0x559bca['datasetCode'],_0x3ca4a7['datasetCode']]];for(const [_0x2d32e9,_0x39484b,_0x428217]of _0x2a4f84){assertVerified(sameValue(_0x39484b,_0x428217),'Menu\x20'+_0x3ca4a7['id']+'\x20'+_0x2d32e9+_0x35a424(0x111));}}function sameValue(_0x3d4530,_0xb900e5){const _0x449719=a191_0x50d41e;if(Array[_0x449719(0xe7)](_0x3d4530)||Array[_0x449719(0xe7)](_0xb900e5))return JSON[_0x449719(0xe3)](_0x3d4530)===JSON[_0x449719(0xe3)](_0xb900e5);return _0x3d4530===_0xb900e5;}
|
|
1
|
+
import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{fetchMenuSnapshot}from"../../commands/menu/shared/facts.js";import{asVerificationError,assertVerified,describeMenuErrorCause,fetchMutationSnapshot,hasFlag,isMenuResponseLoss,mapMenuApiError,menuDryRunResult,menuError,menuFailure,mutationResult,recheckMutationSnapshot}from"../../commands/menu/shared/mutations.js";import{updateMenuEntity}from"../../commands/menu/shared/service.js";import{CliErrors}from"../../errors.js";const BACKEND=[{method:"POST",path:"/smartapi/menu/update"}];export const menuVisibilityUpdate={service:"menu",command:"visibility-update",description:"Set exact menus visible or hidden without changing their routes or resources",risk:"write",structuredErrors:true,flags:[{name:"menu-ids",type:"string",description:"Exact comma-separated menu IDs to update"},{name:"paths",type:"string",description:"Exact comma-separated menu paths to update"},{name:"visible",type:"boolean",required:true,
|
|
2
|
+
description:"Requested menu visibility"},{name:"expect-visible",type:"boolean",description:"Abort unless every selected menu has this visibility"},{name:"expected-count",type:"number",description:"Abort unless the exact number of selected menus matches"},APPCODE_FLAG_OPTIONAL],async validate(ctx){parseInput(ctx)},async dryRun(ctx){const prepared=await buildPlan(ctx,true);const updateCount=prepared.plan.plannedActions?.length??0;const skippedCount=prepared.plan.targets.length-updateCount;return menuDryRunResult(prepared.plan,{method:"POST",url:"/smartapi/menu/update",body:{updates:prepared.plan.plannedActions?.map(action=>action.body)??[]},description:`Would update visibility for ${updateCount} menu(s); skip ${skippedCount} unchanged menu(s).`})},async execute(ctx){const prepared=await buildPlan(ctx,false);await recheckMutationSnapshot(ctx,prepared.plan,"update menu visibility");const succeeded=[];const failed=[];const responseLostIds=[];for(const target of prepared.plan.targets){
|
|
3
|
+
if(target.before.visible===prepared.plan.requestedVisible){succeeded.push({id:target.id,updated:false,skipped:true});continue}try{await updateMenuEntity(ctx.appCode,ctx.cookie,{id:target.id,visible:prepared.plan.requestedVisible});succeeded.push({id:target.id,updated:true,skipped:false})}catch(error){const mapped=mapMenuApiError(error,"update visibility for",target.id);if(isMenuResponseLoss(error)&&mapped.code!=="menu_permission_denied"){responseLostIds.push(target.id);continue}failed.push({id:target.id,stage:"update",code:mapped.code,message:mapped.message})}}let verifiedSnapshot;try{verifiedSnapshot=await fetchMenuSnapshot(ctx.appCode,ctx.cookie)}catch(error){const cause=describeMenuErrorCause(error,"verify menu visibility update");const recoveryFailures=responseLostIds.map(id=>({id:id,stage:"update-recovery",code:"menu_verification_failed",message:`Response was lost for menu ${id} and final state could not be read.`,requestedStateConfirmed:false,recovered:false}))
|
|
4
|
+
;const verificationFailure={stage:"verification",code:"menu_verification_failed",message:"Final menu visibility readback failed.",targetIds:prepared.plan.targets.map(target=>target.id),requestedStateConfirmed:false,...cause};throw menuFailure(asVerificationError(error,"Visibility update requests completed but readback could not confirm the requested state"),prepared.plan,{stage:"verification",succeeded:succeeded,failedRecords:[...failed,...recoveryFailures,verificationFailure],warnings:["The update may have taken effect; inspect the latest menu facts before retrying."],verification:{status:"failed",recoveredCount:0,lookupCommand:"rabetbase menu list --format compress"}})}const verificationFailures=[];for(const outcome of succeeded){const id=Number(outcome.id);const before=prepared.beforeById.get(id);const verified=verifiedSnapshot.byId.get(id);try{verifyVisibilityUpdate(before,verified,prepared.plan.requestedVisible)}catch(error){
|
|
5
|
+
const verificationError=asVerificationError(error,`Menu ${id} visibility update could not be verified`);verificationFailures.push({id:id,stage:"verification",code:verificationError.code,message:verificationError.message,requestedStateConfirmed:false})}}for(const id of responseLostIds){const before=prepared.beforeById.get(id);const verified=verifiedSnapshot.byId.get(id);try{verifyVisibilityUpdate(before,verified,prepared.plan.requestedVisible);succeeded.push({id:id,updated:true,skipped:false,recovered:true})}catch(error){const verificationError=asVerificationError(error,`Response was lost and menu ${id} visibility could not be verified safely`);verificationFailures.push({id:id,stage:"update-recovery",code:verificationError.code,message:verificationError.message,requestedStateConfirmed:false,recovered:false})}}if(verificationFailures.length>0){const targetIds=verificationFailures.map(item=>Number(item.id));const recoveredCount=succeeded.filter(item=>item.recovered===true).length
|
|
6
|
+
;const verificationError=menuError("menu_verification_failed",`Menu visibility update could not be verified for id(s): ${targetIds.join(", ")}.`,"Inspect current menu facts before retrying any target.");throw menuFailure(verificationError,prepared.plan,{stage:"verification",succeeded:succeeded,failedRecords:[...failed,...verificationFailures],warnings:["One or more updates may have changed fields outside visibility; inspect current menu facts before retrying."],verification:{status:"failed",...targetIds.length===1?{targetId:targetIds[0]}:{targetIds:targetIds},recoveredCount:recoveredCount,lookupCommand:"rabetbase menu list --format compress"}})}const updatedCount=succeeded.filter(item=>item.updated===true).length;const skippedCount=succeeded.length-updatedCount;const data={...prepared.plan,succeeded:succeeded,failed:failed,warnings:failed.length>0?[...prepared.plan.warnings,"Failed update requests were not retried; inspect current menu facts before retrying."]:prepared.plan.warnings,
|
|
7
|
+
verification:{checkedBy:"menu list",snapshotHash:verifiedSnapshot.hash,matchesRequestedState:failed.length===0,recoveredCount:responseLostIds.length}};return{ok:failed.length===0,data:data,message:failed.length===0?`Updated visibility for ${updatedCount} menu(s); skipped ${skippedCount} unchanged menu(s).`:`Menu visibility update completed: ${updatedCount} updated, ${skippedCount} skipped, ${failed.length} failed.`}}};function parseInput(ctx){const menuIds=parseMenuIds(ctx.str("menu-ids"));const paths=parseCsv(ctx.str("paths"));if(menuIds.length===0&&paths.length===0){throw CliErrors.validation("menu visibility-update requires --menu-ids or --paths.")}const visible=parseBooleanFlag(ctx,"visible",true);const expectVisible=parseBooleanFlag(ctx,"expect-visible",false);let expectedCount;if(hasFlag(ctx,"expected-count")){expectedCount=ctx.num("expected-count");if(!Number.isSafeInteger(expectedCount)||expectedCount<0){
|
|
8
|
+
throw CliErrors.validation("--expected-count must be a non-negative integer.")}}return{menuIds:menuIds,paths:paths,visible:visible,expectVisible:expectVisible,expectedCount:expectedCount}}async function buildPlan(ctx,dryRun){const input=parseInput(ctx);const snapshot=await fetchMutationSnapshot(ctx,"update menu visibility");const targets=selectTargets(snapshot.menus,input.menuIds,input.paths);if(input.expectedCount!==undefined&&targets.length!==input.expectedCount){throw menuError("menu_expected_count_mismatch",`Selected ${targets.length} menu(s), expected ${input.expectedCount}.`,"Run the command with --dry-run again and update --expected-count.")}if(input.expectVisible!==undefined){const drifted=targets.filter(menu=>menu.visible!==input.expectVisible);if(drifted.length>0){throw menuError("menu_state_drift",`Selected menu visibility changed for id(s): ${drifted.map(menu=>menu.id).join(", ")}.`,"Run the command with --dry-run again and update --expect-visible.")}}
|
|
9
|
+
const diffs=targets.map(menu=>({id:menu.id,label:menu.label,path:menu.path,before:{visible:menu.visible},after:{visible:input.visible}}));const plannedActions=diffs.filter(diff=>diff.before.visible!==input.visible).map(diff=>({stage:"update-menu-visibility",method:"POST",path:"/smartapi/menu/update",body:{appCode:ctx.appCode,id:diff.id,visible:input.visible}}));const base=mutationResult({operation:"visibility-update",selector:{menuIds:input.menuIds,paths:input.paths},before:{menus:targets.map(menu=>({id:menu.id,path:menu.path,visible:menu.visible}))},after:{menus:targets.map(menu=>({id:menu.id,path:menu.path,visible:input.visible}))},dryRun:dryRun,backend:[...BACKEND],plannedActions:plannedActions,snapshotHash:snapshot.hash,warnings:plannedActions.length===0?["Every selected menu already has the requested visibility; no write is needed."]:[]});return{plan:{...base,requestedVisible:input.visible,targets:diffs},beforeById:new Map(targets.map(menu=>[menu.id,menu]))}}
|
|
10
|
+
function selectTargets(menus,menuIds,paths){const byId=new Map(menus.map(menu=>[menu.id,menu]));const selected=new Map;const missingIds=menuIds.filter(id=>!byId.has(id));if(missingIds.length>0){throw menuError("menu_selector_not_found",`Menu id selector(s) not found: ${missingIds.join(", ")}.`,"Run `rabetbase menu list --format compress` and use exact current ids.")}for(const id of menuIds){selected.set(id,byId.get(id))}for(const path of paths){const matches=menus.filter(menu=>menu.path===path);if(matches.length===0){throw menuError("menu_selector_not_found",`Menu path selector not found: ${JSON.stringify(path)}.`,"Run `rabetbase menu list --format compress` and use an exact current path.")}if(matches.length>1){throw menuError("menu_selector_ambiguous",`Menu path selector matched multiple menus: ${JSON.stringify(path)}.`,`Use --menu-ids with one or more of: ${matches.map(menu=>menu.id).join(", ")}.`)}const match=matches[0];selected.set(match.id,match)}return[...selected.values()]}
|
|
11
|
+
function parseMenuIds(value){const values=parseCsv(value);const ids=values.map(Number);if(ids.some(id=>!Number.isSafeInteger(id)||id<=0)){throw CliErrors.validation("--menu-ids must contain positive safe integers.")}return[...new Set(ids)]}function parseCsv(value){return[...new Set(value.split(",").map(item=>item.trim()).filter(Boolean))]}function parseBooleanFlag(ctx,name,required){if(!hasFlag(ctx,name)){if(required)throw CliErrors.flagMissing(name);return undefined}const raw=ctx.rawFlags[name];if(raw===true||raw===false)return raw;if(raw==="true")return true;if(raw==="false")return false;throw CliErrors.validation(`--${name} must be true or false.`)}function verifyVisibilityUpdate(before,after,requestedVisible){assertVerified(!!after,`Menu ${before.id} was not found during visibility verification.`);assertVerified(after.visible===requestedVisible,`Menu ${before.id} visible did not match the requested state.`)
|
|
12
|
+
;const comparisons=[["id",after.id,before.id],["parentId",after.parentId,before.parentId],["depth",after.depth,before.depth],["label",after.label,before.label],["path",after.path,before.path],["url",after.url,before.url],["type",after.type,before.type],["sort",after.sort,before.sort],["resources",after.resources,before.resources],["resourcesValid",after.resourcesValid,before.resourcesValid],["childrenIds",after.childrenIds,before.childrenIds],["childrenCount",after.childrenCount,before.childrenCount],["pageId",after.pageId,before.pageId],["pageType",after.pageType,before.pageType],["modelType",after.modelType,before.modelType],["datasetId",after.datasetId,before.datasetId],["datasetCode",after.datasetCode,before.datasetCode]];for(const[field,actual,expected]of comparisons){assertVerified(sameValue(actual,expected),`Menu ${before.id} ${field} changed unexpectedly.`)}}function sameValue(actual,expected){if(Array.isArray(actual)||Array.isArray(expected)){
|
|
13
|
+
return JSON.stringify(actual)===JSON.stringify(expected)}return actual===expected}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ValidateFunction } from 'ajv';
|
|
2
|
+
export declare function readMetricJson(file: string): Promise<unknown>;
|
|
3
|
+
export declare function parseMetricJson(text: string): unknown;
|
|
4
|
+
export declare function compileMetricContract(value: unknown): {
|
|
5
|
+
input: import("ajv/dist/core.js").AnyValidateFunction<unknown>;
|
|
6
|
+
output: import("ajv/dist/core.js").AnyValidateFunction<unknown>;
|
|
7
|
+
};
|
|
8
|
+
export declare function assertMetricInput(validate: ValidateFunction, value: unknown): asserts value is Record<string, unknown>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{readFile}from"node:fs/promises";import{Ajv2020}from"ajv/dist/2020.js";import addFormats from"ajv-formats";import{CliError,CliErrors}from"../../errors.js";function object(value){return value!==null&&typeof value==="object"&&!Array.isArray(value)}export async function readMetricJson(file){try{return parseMetricJson(await readFile(file,"utf8"))}catch(error){if(error instanceof CliError)throw error;throw CliErrors.validation(`Cannot read a valid metric JSON document: ${file}`)}}function assertMetricNumbers(value,failure=CliErrors.validation){if(typeof value==="number"&&(!Number.isFinite(value)||Number.isInteger(value)&&!Number.isSafeInteger(value))){throw failure("Metric JSON numbers must be finite and integers must be within the safe integer range.","Represent larger integers as decimal strings in the schema, examples and endpoint payloads.")}if(value!==null&&typeof value==="object"){for(const child of Object.values(value))assertMetricNumbers(child,failure)}}
|
|
2
|
+
export function parseMetricJson(text){try{const parsed=JSON.parse(text);assertMetricNumbers(parsed);const stack=[];for(const[token]of text.matchAll(/"(?:\\[\s\S]|[^"\\])*"|[{}\[\],]/g)){const frame=stack[stack.length-1];if(token==="{")stack.push({keys:new Set,keyExpected:true});else if(token==="[")stack.push(null);else if(token==="}"||token==="]")stack.pop();else if(token===","){if(frame)frame.keyExpected=true}else if(frame?.keyExpected){const key=JSON.parse(token);if(frame.keys.has(key))throw CliErrors.validation("Metric JSON must not contain duplicate object keys.");frame.keys.add(key);frame.keyExpected=false}}return parsed}catch(error){if(error instanceof CliError)throw error;throw CliErrors.validation("Cannot parse a valid metric JSON document.")}}export function compileMetricContract(value){assertMetricNumbers(value)
|
|
3
|
+
;if(!object(value)||!Object.hasOwn(value,"inputSchema")||!Object.hasOwn(value,"outputSchema")||Object.keys(value).some(key=>!["inputSchema","outputSchema","examples"].includes(key))){throw CliErrors.validation("Metric contract requires inputSchema and outputSchema, with optional examples only.")}const compile=(schema,label)=>{if(!object(schema))throw CliErrors.validation(`${label} must be a JSON Schema object.`);try{const ajv=new Ajv2020({strict:true,allErrors:false,coerceTypes:false,useDefaults:false,removeAdditional:false});addFormats.default(ajv);const validate=ajv.compile(schema);if("$async"in validate&&validate.$async)throw new Error("Asynchronous schemas are not supported.");return validate}catch(error){throw CliErrors.validation(`Invalid metric ${label}: ${error instanceof Error?error.message:"schema compilation failed"}`,"Use synchronous JSON Schema 2020-12 with local fragment references; remote schemas are not loaded.")}}
|
|
4
|
+
;if(!object(value.inputSchema)||value.inputSchema.type!=="object"){throw CliErrors.validation("Metric inputSchema must declare type: object.")}const input=compile(value.inputSchema,"inputSchema");const output=compile(value.outputSchema,"outputSchema");if(value.examples!==undefined){if(!Array.isArray(value.examples))throw CliErrors.validation("Metric contract examples must be an array.");for(const[index,example]of value.examples.entries()){if(!object(example)||!Object.hasOwn(example,"input")||!Object.hasOwn(example,"output")||Object.keys(example).some(key=>!["input","output"].includes(key))){throw CliErrors.validation(`Metric example ${index} requires input and output only.`)}assertMetricInput(input,example.input);if(!output(example.output))throw CliErrors.validation(`Metric example ${index} output: ${validationMessage(output)}`)}}return{input:input,output:output}}function validationMessage(validate){const error=validate.errors?.[0]
|
|
5
|
+
;return error?`${error.instancePath||"/"} ${error.message}`:"does not match its schema"}export function assertMetricInput(validate,value){if(!object(value))throw CliErrors.validation("Metric input must be a JSON object.");assertMetricNumbers(value);if(!validate(value))throw CliErrors.validation(`Metric input: ${validationMessage(validate)}`)}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface MetricEntry {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
displayName?: string;
|
|
5
|
+
categoryPath?: string[];
|
|
6
|
+
unit: string;
|
|
7
|
+
contract: unknown;
|
|
8
|
+
target: {
|
|
9
|
+
appCode: string;
|
|
10
|
+
} & ({
|
|
11
|
+
kind: 'sql';
|
|
12
|
+
sqlCode: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'bff';
|
|
15
|
+
functionName: string;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export declare function validateMetricEntry(entry: unknown, path?: string): MetricEntry;
|
|
19
|
+
/** The canonical metric name is the app-config key; never add or strip a prefix. */
|
|
20
|
+
export declare function validateMetricName(name: string): string;
|
|
21
|
+
export declare function validateMetricDefinition(value: unknown, appCode?: string, name?: string): {
|
|
22
|
+
metric: MetricEntry;
|
|
23
|
+
contract: {
|
|
24
|
+
input: import("ajv/dist/core.js").AnyValidateFunction<unknown>;
|
|
25
|
+
output: import("ajv/dist/core.js").AnyValidateFunction<unknown>;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/** Authoring must also satisfy app-config publication constraints. */
|
|
29
|
+
export declare function validateMetricPublication(value: unknown, appCode?: string): {
|
|
30
|
+
metric: MetricEntry;
|
|
31
|
+
contract: {
|
|
32
|
+
input: import("ajv/dist/core.js").AnyValidateFunction<unknown>;
|
|
33
|
+
output: import("ajv/dist/core.js").AnyValidateFunction<unknown>;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/** Assemble only the split storage format; metadata cannot be overridden by value. */
|
|
37
|
+
export declare function readStoredMetric(record: {
|
|
38
|
+
appCode: string;
|
|
39
|
+
key: string;
|
|
40
|
+
tags?: string | null;
|
|
41
|
+
description?: string | null;
|
|
42
|
+
value?: string | null;
|
|
43
|
+
}, appCode: string, name?: string): MetricEntry;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{CliErrors}from"../../errors.js";import{SQLCODE_FLAG}from"../../commands/common/flags.js";import{compileMetricContract,parseMetricJson}from"./contract.js";function invalid(path,message){throw CliErrors.validation(`${path}: ${message}`,"Read rabetbase metric schema and correct the definition.")}function object(value,keys,path,optional=[]){if(!value||typeof value!=="object"||Array.isArray(value))invalid(path,"Expected an object.");const record=value;for(const key of keys){if(!Object.hasOwn(record,key))invalid(`${path}.${key}`,"Required field is missing.")}for(const key of Object.keys(record)){if(!keys.includes(key)&&!optional.includes(key))invalid(`${path}.${key}`,"Unknown field.")}return record}function text(value,path){if(typeof value!=="string"||!value.trim()||value!==value.trim()){invalid(path,"Expected a non-empty string without leading or trailing whitespace.")}return value}export function validateMetricEntry(entry,path="metric"){
|
|
2
|
+
const metric=object(entry,["name","description","unit","target","contract"],path,["displayName","categoryPath"]);if(Object.hasOwn(metric,"displayName"))text(metric.displayName,`${path}.displayName`);if(Object.hasOwn(metric,"categoryPath")){const categories=metric.categoryPath;if(!Array.isArray(categories)||categories.length<1||categories.length>2){invalid(`${path}.categoryPath`,"Expected a category path with one or two levels.")}for(const[index,category]of categories.entries())text(category,`${path}.categoryPath[${index}]`)}validateMetricName(text(metric.name,`${path}.name`));for(const field of["description","unit"])text(metric[field],`${path}.${field}`);const targetValue=metric.target;if(!targetValue||typeof targetValue!=="object"||Array.isArray(targetValue))invalid(`${path}.target`,"Expected an object.");const kind=targetValue.kind;if(kind!=="sql"&&kind!=="bff")invalid(`${path}.target.kind`,"Expected sql or bff.");const selector=kind==="sql"?"sqlCode":"functionName"
|
|
3
|
+
;const target=object(targetValue,["kind","appCode",selector],`${path}.target`);const appCode=text(target.appCode,`${path}.target.appCode`);const code=text(target[selector],`${path}.target.${selector}`);if(kind==="sql"&&!SQLCODE_FLAG.pattern.regex.test(code)){invalid(`${path}.target.sqlCode`,"Expected a SQL code in xxxxxxxx-xxxxxxxx hexadecimal format.")}return metric}export function validateMetricName(name){if(!/^metrics\.[a-z][a-z0-9_-]*$/.test(name)||name!==name.trim()||name.length>256){throw CliErrors.validation("Metric name must be a metrics.<identifier> key of at most 256 characters.")}return name}export function validateMetricDefinition(value,appCode,name){const metric=validateMetricEntry(value);if(appCode!==undefined&&metric.target.appCode!==appCode||name!==undefined&&metric.name!==name){throw CliErrors.validation("Metric identity does not match the selected app and name.")}const contract=compileMetricContract(metric.contract);return{metric:metric,contract:contract}}
|
|
4
|
+
export function validateMetricPublication(value,appCode){const validated=validateMetricDefinition(value,appCode);if(validated.metric.description.length>256){throw CliErrors.validation("Metric description must not exceed 256 characters.")}return validated}export function readStoredMetric(record,appCode,name){if(!record||typeof record!=="object"||Array.isArray(record)||record.appCode!==appCode||record.tags!=="METRIC"||typeof record.value!=="string"||typeof record.key!=="string"){throw CliErrors.apiError("Invalid metric app-config record.")}const storedName=record.key;const value=parseMetricJson(record.value);if(!value||typeof value!=="object"||Array.isArray(value)||["name","description","tags"].some(field=>Object.hasOwn(value,field))){throw CliErrors.apiError("Metric value must contain only the metric payload, without app-config metadata.")}return validateMetricDefinition({...value,name:storedName,description:record.description},appCode,name).metric}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{deleteAppConfig,getAppConfigByKey}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";import{metricWriteFailure}from"./shared.js";import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{requireAppConfigId}from"../../commands/app-config/shared.js";import{validateMetricName}from"./definition.js";async function prepare(ctx){const key=ctx.str("name");validateMetricName(key);const before=await getAppConfigByKey(ctx.appCode,key);if(!before)throw CliErrors.validation(`Metric not found: ${key}`,`appCode: ${ctx.appCode}`);if(before.appCode!==ctx.appCode||before.key!==key||before.tags!=="METRIC"){throw CliErrors.validation("The metric key is occupied by a different app-config record.")}return{before:before,id:requireAppConfigId(before)}}function resultData(before,id,dryRun){return{operation:"delete",selector:{appCode:before.appCode,key:before.key,id:id},before:{appCode:before.appCode,key:before.key,id:id,description:before.description,tags:before.tags},
|
|
2
|
+
after:null,dryRun:dryRun,backend:"app-config",warnings:["Only the metric definition is deleted. Referenced SQL/BFF and local files are retained.","Deletion takes effect immediately. Concurrent changes have no version-conflict protection."]}}export const metricDelete={service:"metric",command:"delete",risk:"high-risk-write",strictFlags:true,description:"Delete one application metric definition and verify its absence",flags:[APPCODE_FLAG_OPTIONAL,{name:"name",type:"string",required:true,description:"Exact full metric name (e.g. metrics.paid_order_count)"}],async dryRun(ctx){const{before:before,id:id}=await prepare(ctx);return{method:"POST",url:"/smartapi/app-config/delete",data:resultData(before,id,true)}},async execute(ctx){const{before:before,id:id}=await prepare(ctx);let after;try{await deleteAppConfig({appCode:ctx.appCode,id:id});after=await getAppConfigByKey(ctx.appCode,before.key)}catch(error){
|
|
3
|
+
const hint=`Inspect ${before.key} in app ${ctx.appCode} before deleting again; a missing response does not prove the deletion failed.`;throw metricWriteFailure(error,"Metric deletion could not be verified.",hint)}if(after!==null){throw CliErrors.apiError("Metric delete readback still contains a record.","Inspect the current app-config record before deleting again; it may have changed or been recreated.")}return{ok:true,data:resultData(before,id,false),message:`Deleted metric ${before.key}`}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getMetricDetail}from"../../core/api-client.js";import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{validateMetricName,validateMetricDefinition}from"./definition.js";export const metricDetail={service:"metric",command:"detail",risk:"read",strictFlags:true,description:"Read and validate the current editable application metric definition",flags:[APPCODE_FLAG_OPTIONAL,{name:"name",type:"string",required:true,description:"Exact full metric name (e.g. metrics.paid_order_count); use name, not displayName"}],async execute(ctx){const name=ctx.str("name");const record=await getMetricDetail(ctx.appCode,validateMetricName(name));const definition=record&&typeof record==="object"&&"metricDefinition"in record?record.metricDefinition:undefined;return{ok:true,data:validateMetricDefinition(definition,ctx.appCode,name).metric}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readMetricAsset,metricCommand}from"./shared.js";export const metricExample={...metricCommand,command:"example",description:"Read a self-contained fictional metric definition",flags:[],async execute(){return{ok:true,data:await readMetricAsset("example")}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{metricSchema}from"./schema.js";import{metricExample}from"./example.js";import{metricValidate}from"./validate.js";import{metricPublish}from"./publish.js";import{metricList}from"./list.js";import{metricDetail}from"./detail.js";import{metricDelete}from"./delete.js";export const metricDefinitions=[metricSchema,metricExample,metricValidate,metricList,metricDetail,metricPublish,metricDelete];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{listAppConfigs}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{readStoredMetric}from"./definition.js";export const metricList={service:"metric",command:"list",risk:"read",strictFlags:true,description:"List application metric summaries, optionally filtering keys or descriptions by keyword",flags:[APPCODE_FLAG_OPTIONAL,{name:"key",type:"string",description:"Case-insensitive literal substring of the config key or description"}],async execute(ctx){const key=ctx.str("key").trim();const records=await listAppConfigs(ctx.appCode,{tags:"METRIC",...key?{keyword:key}:{}});const names=new Set;const summaries=records.map(record=>{const{name:name,description:description,displayName:displayName,categoryPath:categoryPath,unit:unit}=readStoredMetric(record,ctx.appCode);if(names.has(name))throw CliErrors.apiError("Duplicate metric identity in app-config.");names.add(name);return{name:name,
|
|
2
|
+
description:description,...displayName===undefined?{}:{displayName:displayName},...categoryPath===undefined?{}:{categoryPath:categoryPath},unit:unit}});const metrics=summaries.sort((a,b)=>a.name<b.name?-1:a.name>b.name?1:0);return{ok:true,data:{appCode:ctx.appCode,count:metrics.length,metrics:metrics}}}};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface MetricPublicationChange {
|
|
2
|
+
path: string;
|
|
3
|
+
operation: 'add' | 'remove' | 'replace';
|
|
4
|
+
before?: unknown;
|
|
5
|
+
after?: unknown;
|
|
6
|
+
}
|
|
7
|
+
/** Structural changes only: arrays are atomic, and no compatibility is inferred. */
|
|
8
|
+
export declare function diffMetricPublication(before: Record<string, unknown> | null, after: Record<string, unknown>): MetricPublicationChange[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isDeepStrictEqual}from"node:util";const object=value=>value!==null&&typeof value==="object"&&!Array.isArray(value);const escapePointer=key=>key.replace(/~/g,"~0").replace(/\//g,"~1");export function diffMetricPublication(before,after){const changes=[];const visit=(left,right,path)=>{for(const key of new Set([...Object.keys(left),...Object.keys(right)])){const next=`${path}/${escapePointer(key)}`;if(!Object.hasOwn(left,key))changes.push({path:next,operation:"add",after:right[key]});else if(!Object.hasOwn(right,key))changes.push({path:next,operation:"remove",before:left[key]});else if(object(left[key])&&object(right[key]))visit(left[key],right[key],next);else if(!isDeepStrictEqual(left[key],right[key])){changes.push({path:next,operation:"replace",before:left[key],after:right[key]})}}};visit(before??{},after,"");return changes.sort((a,b)=>a.path<b.path?-1:a.path>b.path?1:0)}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{resolve}from"node:path";import{createAppConfig,getAppConfigByKey,updateAppConfig}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";import{metricWriteFailure}from"./shared.js";import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{requireAppConfigId}from"../../commands/app-config/shared.js";import{readMetricJson}from"./contract.js";import{readStoredMetric,validateMetricPublication}from"./definition.js";import{diffMetricPublication}from"./publication-diff.js";const TAG="METRIC";async function prepare(ctx){const{metric:metric}=validateMetricPublication(await readMetricJson(resolve(ctx.str("file"))),ctx.appCode);const key=metric.name;const before=await getAppConfigByKey(ctx.appCode,key);if(before&&(before.appCode!==ctx.appCode||before.key!==key||before.tags!==TAG)){throw CliErrors.validation("The metric key is occupied by a different app-config record.")}if(before)requireAppConfigId(before);let previous=null;if(before){try{previous={
|
|
2
|
+
...readStoredMetric(before,ctx.appCode,key)}}catch{throw CliErrors.validation("The current metric definition cannot be reviewed.","Inspect the current metric with app-config get before publishing; no changes were written.")}}const changes=diffMetricPublication(previous,{...metric});const{name:name,description:description,...payload}=metric;return{before:before,changes:changes,input:{appCode:ctx.appCode,key:key,description:description,tags:TAG,value:JSON.stringify(payload)}}}function metadata(item){return item?{appCode:item.appCode,key:item.key,description:item.description,tags:item.tags}:null}function resultData(before,after,changes,dryRun){const warnings=["Updates take effect immediately. Concurrent publishing has no version-conflict protection."];if(before&&changes.some(change=>/^\/(target|contract)(\/|$)/.test(change.path))){warnings.push("Target or contract changed. Revalidate consumers before relying on the new definition.")}return{operation:before?"update":"create",selector:{
|
|
3
|
+
appCode:after.appCode,key:after.key},before:metadata(before),after:metadata(after),dryRun:dryRun,backend:"app-config",changes:changes,warnings:warnings}}export const metricPublish={service:"metric",command:"publish",risk:"write",strictFlags:true,description:"Validate and publish one application metric through app-config",flags:[APPCODE_FLAG_OPTIONAL,{name:"file",type:"string",required:true,description:"Self-contained metric definition JSON file"}],async dryRun(ctx){const{before:before,input:input,changes:changes}=await prepare(ctx);return{method:"POST",url:`/smartapi/app-config/${before?"update":"create"}`,data:resultData(before,input,changes,true)}},async execute(ctx){const{before:before,input:input,changes:changes}=await prepare(ctx);let after;try{if(before)await updateAppConfig({...input,id:requireAppConfigId(before)});else await createAppConfig(input);after=await getAppConfigByKey(ctx.appCode,input.key)}catch(error){
|
|
4
|
+
const hint=`Inspect ${input.key} in app ${ctx.appCode} before publishing again; a missing response does not prove the write failed.`;throw metricWriteFailure(error,"Metric publication could not be verified.",hint)}if(!after||after.appCode!==input.appCode||after.key!==input.key||after.tags!==TAG||after.description!==input.description||after.value!==input.value){throw CliErrors.apiError("Metric publish readback did not match the submitted definition.","The write may have succeeded. Inspect the app-config record before publishing again.")}return{ok:true,data:resultData(before,after,changes,false),message:`Published metric ${input.key}`}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readMetricAsset,metricCommand}from"./shared.js";export const metricSchema={...metricCommand,command:"schema",description:"Read the bundled metric definition or contract JSON Schema",flags:[{name:"kind",type:"string",enum:["definition","contract"],description:"Schema kind (default: definition)"}],async execute(ctx){return{ok:true,data:await readMetricAsset(ctx.str("kind")==="contract"?"contract":"definition")}}};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CliError } from '../../errors.js';
|
|
2
|
+
export declare const metricCommand: {
|
|
3
|
+
readonly service: "metric";
|
|
4
|
+
readonly risk: "read";
|
|
5
|
+
readonly requiresAuth: false;
|
|
6
|
+
readonly requiresAppCode: false;
|
|
7
|
+
readonly hasFormat: true;
|
|
8
|
+
readonly strictFlags: true;
|
|
9
|
+
readonly structuredErrors: true;
|
|
10
|
+
};
|
|
11
|
+
/** Read the bundled authoring assets without authentication or network access. */
|
|
12
|
+
export declare function readMetricAsset(kind: 'definition' | 'contract' | 'example'): Promise<any>;
|
|
13
|
+
/** Keep diagnostics while replacing generic retry advice with write-state inspection. */
|
|
14
|
+
export declare function metricWriteFailure(error: unknown, message: string, hint: string): CliError;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{readFile}from"node:fs/promises";import{CliError,CliErrors}from"../../errors.js";import{getPlatformErrorCode}from"../../core/api-client.js";export const metricCommand={service:"metric",risk:"read",requiresAuth:false,requiresAppCode:false,hasFormat:true,strictFlags:true,structuredErrors:true};export async function readMetricAsset(kind){const file=kind==="example"?"definition.json":"metric-definition.schema.json";const asset=JSON.parse(await readFile(new URL(`../../../templates/metrics/${file}`,import.meta.url),"utf8"));return kind==="contract"?{$schema:asset.$schema,...asset.properties.contract}:asset}export function metricWriteFailure(error,message,hint){if(!(error instanceof CliError))return CliErrors.apiError(message,hint);const remoteCode=getPlatformErrorCode(error);const descriptors=Object.getOwnPropertyDescriptors(error);return Object.defineProperties(new CliError(error.code,error.exitCode,error.message),{...descriptors,hint:{...descriptors.hint,
|
|
2
|
+
value:[remoteCode?`API error code: ${remoteCode}.`:undefined,hint].filter(Boolean).join(" ")}})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve}from"node:path";import{metricCommand}from"./shared.js";import{readMetricJson}from"./contract.js";import{validateMetricPublication}from"./definition.js";export const metricValidate={...metricCommand,command:"validate",description:"Validate a metric definition, contracts and examples without executing queries",flags:[{name:"file",type:"string",required:true,description:"Self-contained metric definition JSON file"}],async execute(ctx){const file=ctx.str("file");validateMetricPublication(await readMetricJson(resolve(file)));return{ok:true,data:{valid:true,verification:"definition-and-contract"}}}};
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{asDryRunResult}from"../../commands/common/dry-run.js";import{createNotificationChannelConfig,getNotificationChannelConfig,isPlatformTransportFailure}from"../../core/api-client.js";import{assertSingleNotificationSource,createMutationInput,DEFAULT_NOTIFICATION_CONNECT_TIMEOUT,DEFAULT_NOTIFICATION_READ_TIMEOUT,normalizeExactNotificationConfig,notificationError,notificationLookupCommand,NOTIFICATION_APP_FLAG,NOTIFICATION_INPUT_FLAGS,projectNotificationConfig,readNotificationDocument,safeApiFailure}from"../../commands/notification/shared.js";const CREATE_PATH="/notification/channel-config/create";async function prepareCreate(ctx){const document=await readNotificationDocument(ctx,"create");const input=createMutationInput(ctx.appCode,document);return{document:document,input:input,planned:projectNotificationConfig({appCode:ctx.appCode,configName:document.configName,channelType:document.channelType,endpointUrl:document.endpointUrl,channelConfig:document.channelConfig,
|
|
2
|
+
description:document.description,connectTimeout:document.connectTimeout??DEFAULT_NOTIFICATION_CONNECT_TIMEOUT,readTimeout:document.readTimeout??DEFAULT_NOTIFICATION_READ_TIMEOUT})}}export const notificationConfigCreate={service:"notification",command:"config-create",description:"Create an app-level notification config from a secure JSON source",risk:"write",requiresAppCode:true,structuredErrors:true,flags:[...NOTIFICATION_INPUT_FLAGS,NOTIFICATION_APP_FLAG],async validate(ctx){assertSingleNotificationSource(ctx)},async dryRun(ctx){const prepared=await prepareCreate(ctx);const lookupCommand=notificationLookupCommand(ctx.appCode,prepared.document.channelType);return asDryRunResult({operation:"create",selector:{appCode:ctx.appCode,configName:prepared.document.configName,channelType:prepared.document.channelType},before:null,after:prepared.planned,dryRun:true,backend:{method:"POST",path:CREATE_PATH},warnings:[],verification:{status:"planned",lookupCommand:lookupCommand}},{method:"POST",
|
|
3
|
+
url:CREATE_PATH})},async execute(ctx){const prepared=await prepareCreate(ctx);const lookupCommand=notificationLookupCommand(ctx.appCode,prepared.document.channelType);let id;try{id=await createNotificationChannelConfig(prepared.input)}catch(error){if(isPlatformTransportFailure(error)){throw notificationError("notification_config_create_outcome_unknown","Notification config create outcome is unknown because no server ID was received.",`Inspect with ${lookupCommand}; do not resubmit.`)}throw safeApiFailure("create","mutation",`Inspect with ${lookupCommand}; no automatic retry was attempted.`)}if(!Number.isSafeInteger(id)||id<=0){throw notificationError("notification_config_create_outcome_unknown","Notification config create returned no usable server ID.",`Inspect with ${lookupCommand}; do not resubmit.`)}let after;try{const item=await getNotificationChannelConfig(id,ctx.appCode);after=normalizeExactNotificationConfig(item,id,ctx.appCode)}catch{
|
|
4
|
+
throw safeApiFailure("create","verification",`Inspect with ${lookupCommand}; do not resubmit automatically.`)}return{ok:true,data:{operation:"create",selector:{appCode:after.appCode,id:after.id,configCode:after.configCode,configName:after.configName,channelType:after.channelType},before:null,after:projectNotificationConfig(after),dryRun:false,backend:{method:"POST",path:CREATE_PATH},warnings:[],verification:{status:"verified",lookupCommand:lookupCommand}},message:`Created notification config ${after.id}`}}};
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{asDryRunResult}from"../../commands/common/dry-run.js";import{deleteNotificationChannelConfig,isPlatformTransportFailure,listNotificationChannelConfigs}from"../../core/api-client.js";import{notificationError,notificationLookupCommand,notificationSelector,NOTIFICATION_APP_FLAG,NOTIFICATION_ID_FLAG,projectNotificationConfig,readNotificationId,requireNotificationExplicitYes,requireExactNotificationConfig,safeApiFailure,validateNotificationDeleteReadback}from"../../commands/notification/shared.js";const DELETE_PATH="/notification/channel-config/delete";const REFERENCE_WARNING="Deleting this app-level config may make dataset-level channels that reference it unavailable; dataset references were not verified by the CLI.";async function prepareDelete(ctx){const id=readNotificationId(ctx);const before=await requireExactNotificationConfig(ctx.appCode,id,"delete");return{id:id,before:before}}export const notificationConfigDelete={service:"notification",command:"config-delete",
|
|
2
|
+
description:"Delete an app-level notification config after exact preflight",risk:"high-risk-write",requiresAppCode:true,structuredErrors:true,flags:[NOTIFICATION_ID_FLAG,NOTIFICATION_APP_FLAG],async validate(ctx){readNotificationId(ctx);requireNotificationExplicitYes(ctx)},async dryRun(ctx){const prepared=await prepareDelete(ctx);const lookupCommand=notificationLookupCommand(ctx.appCode,prepared.before.channelType);return asDryRunResult({operation:"delete",selector:notificationSelector(prepared.before),before:projectNotificationConfig(prepared.before),after:null,dryRun:true,backend:{method:"POST",path:DELETE_PATH},warnings:[REFERENCE_WARNING],verification:{status:"planned",lookupCommand:lookupCommand}},{method:"POST",url:DELETE_PATH})},async execute(ctx){requireNotificationExplicitYes(ctx);const prepared=await prepareDelete(ctx);const lookupCommand=notificationLookupCommand(ctx.appCode,prepared.before.channelType);let recoveredAfterUnknownResponse=false;try{
|
|
3
|
+
await deleteNotificationChannelConfig(prepared.id,ctx.appCode)}catch(error){if(!isPlatformTransportFailure(error)){throw safeApiFailure("delete","mutation",`Inspect with ${lookupCommand}; no automatic retry was attempted.`)}recoveredAfterUnknownResponse=true}let items;try{items=await listNotificationChannelConfigs(ctx.appCode,prepared.before.channelType);validateNotificationDeleteReadback(items,ctx.appCode,prepared.before.channelType)}catch{throw notificationError(recoveredAfterUnknownResponse?"notification_config_delete_outcome_unknown":"notification_config_delete_verification_unavailable",`Notification config ${prepared.id} delete could not be verified.`,`Inspect with ${lookupCommand}; do not resubmit automatically.`)}if(items.some(item=>item.id===prepared.id)){
|
|
4
|
+
throw notificationError(recoveredAfterUnknownResponse?"notification_config_delete_outcome_unknown":"notification_config_delete_verification_failed",`Notification config ${prepared.id} remains present after delete.`,`Inspect with ${lookupCommand}; do not resubmit automatically.`)}const warnings=[REFERENCE_WARNING];if(recoveredAfterUnknownResponse){warnings.unshift("Delete response was unavailable; list readback proved ID absence without resubmitting.")}return{ok:true,data:{operation:"delete",selector:notificationSelector(prepared.before),before:projectNotificationConfig(prepared.before),after:null,dryRun:false,backend:{method:"POST",path:DELETE_PATH},warnings:warnings,verification:{status:"verified",absenceConfirmed:true,recoveredAfterUnknownResponse:recoveredAfterUnknownResponse,lookupCommand:lookupCommand}},message:`Deleted notification config ${prepared.id}`}}};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{listNotificationChannelConfigs}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";import{NOTIFICATION_CHANNEL_TYPES,projectNotificationListConfig,readNotificationChannelType}from"../../commands/notification/shared.js";export const notificationConfigList={service:"notification",command:"config-list",description:"List app-level notification configs and their configCode values",risk:"read",flags:[APPCODE_FLAG_OPTIONAL,{name:"type",type:"string",description:"Notification channel type",enum:NOTIFICATION_CHANNEL_TYPES},{name:"all",type:"boolean",default:false,description:"List configs for every supported notification channel type"}],async validate(ctx){if(ctx.bool("all")&&ctx.str("type").trim()){throw CliErrors.validation("--all and --type are mutually exclusive.","Use --all, or query one explicit --type.")}if(ctx.bool("all"))return;readNotificationChannelType(ctx)},async execute(ctx){
|
|
2
|
+
if(ctx.bool("all")){const results=await Promise.all(NOTIFICATION_CHANNEL_TYPES.map(channelType=>listNotificationChannelConfigs(ctx.appCode,channelType)));const configs=results.flat().map(projectNotificationListConfig);return{ok:true,data:{appCode:ctx.appCode,channelTypes:NOTIFICATION_CHANNEL_TYPES,count:configs.length,configs:configs},message:`Found ${configs.length} notification config(s) across all channel types`}}const channelType=readNotificationChannelType(ctx);const items=await listNotificationChannelConfigs(ctx.appCode,channelType);const configs=items.map(projectNotificationListConfig);return{ok:true,data:{appCode:ctx.appCode,channelType:channelType,count:configs.length,configs:configs},message:`Found ${configs.length} ${channelType} notification config(s)`}}};
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{asDryRunResult}from"../../commands/common/dry-run.js";import{getNotificationChannelConfig,isPlatformTransportFailure,updateNotificationChannelConfig}from"../../core/api-client.js";import{assertSingleNotificationSource,mergeUpdateInput,normalizeExactNotificationConfig,notificationError,notificationLookupCommand,notificationSelector,NOTIFICATION_APP_FLAG,NOTIFICATION_ID_FLAG,NOTIFICATION_INPUT_FLAGS,plannedUpdateProjection,projectNotificationConfig,readNotificationDocument,readNotificationId,requestedSafeFieldsMatch,requireNotificationExplicitYes,requireExactNotificationConfig,safeApiFailure}from"../../commands/notification/shared.js";const UPDATE_PATH="/notification/channel-config/update";async function prepareUpdate(ctx){const id=readNotificationId(ctx);const patch=await readNotificationDocument(ctx,"update");const before=await requireExactNotificationConfig(ctx.appCode,id,"update");return{id:id,patch:patch,before:before,payload:mergeUpdateInput(before,patch),
|
|
2
|
+
planned:plannedUpdateProjection(before,patch)}}export const notificationConfigUpdate={service:"notification",command:"config-update",description:"Update an app-level notification config from a secure JSON patch",risk:"high-risk-write",requiresAppCode:true,structuredErrors:true,flags:[NOTIFICATION_ID_FLAG,...NOTIFICATION_INPUT_FLAGS,NOTIFICATION_APP_FLAG],async validate(ctx){readNotificationId(ctx);assertSingleNotificationSource(ctx);requireNotificationExplicitYes(ctx)},async dryRun(ctx){const prepared=await prepareUpdate(ctx);const lookupCommand=notificationLookupCommand(ctx.appCode,prepared.before.channelType);return asDryRunResult({operation:"update",selector:notificationSelector(prepared.before),before:projectNotificationConfig(prepared.before),after:prepared.planned,dryRun:true,backend:{method:"POST",path:UPDATE_PATH},warnings:[],verification:{status:"planned",lookupCommand:lookupCommand}},{method:"POST",url:UPDATE_PATH})},async execute(ctx){requireNotificationExplicitYes(ctx)
|
|
3
|
+
;const prepared=await prepareUpdate(ctx);const lookupCommand=notificationLookupCommand(ctx.appCode,prepared.before.channelType);let recoveredAfterUnknownResponse=false;try{await updateNotificationChannelConfig(prepared.payload)}catch(error){if(!isPlatformTransportFailure(error)){throw safeApiFailure("update","mutation",`Inspect ID ${prepared.id} with ${lookupCommand}; no automatic retry was attempted.`)}recoveredAfterUnknownResponse=true}let after;try{const item=await getNotificationChannelConfig(prepared.id,ctx.appCode);after=normalizeExactNotificationConfig(item,prepared.id,ctx.appCode)}catch{throw notificationError(recoveredAfterUnknownResponse?"notification_config_update_outcome_unknown":"notification_config_update_verification_unavailable",`Notification config ${prepared.id} update could not be verified by exact ID.`,`Inspect with --id ${prepared.id} via ${lookupCommand}; do not resubmit automatically.`)}const proof=requestedSafeFieldsMatch(prepared.before,after,prepared.patch)
|
|
4
|
+
;if(!proof.allMatch||recoveredAfterUnknownResponse&&!proof.provesChange){throw notificationError(recoveredAfterUnknownResponse?"notification_config_update_outcome_unknown":"notification_config_update_verification_failed",`Notification config ${prepared.id} readback does not prove the requested update.`,`Inspect with --id ${prepared.id} via ${lookupCommand}; do not resubmit automatically.`)}const warnings=recoveredAfterUnknownResponse?["Update response was unavailable; exact-ID readback proved changed safe fields without resubmitting."]:[];return{ok:true,data:{operation:"update",selector:notificationSelector(after),before:projectNotificationConfig(prepared.before),after:projectNotificationConfig(after),dryRun:false,backend:{method:"POST",path:UPDATE_PATH},warnings:warnings,verification:{status:"verified",recoveredAfterUnknownResponse:recoveredAfterUnknownResponse,verifiedFields:proof.verifiedFields,lookupCommand:lookupCommand}},message:`Updated notification config ${after.id}`}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{notificationConfigList}from"../../commands/notification/config-list.js";import{notificationConfigCreate}from"../../commands/notification/config-create.js";import{notificationConfigUpdate}from"../../commands/notification/config-update.js";import{notificationConfigDelete}from"../../commands/notification/config-delete.js";export const notificationDefinitions=[notificationConfigList,notificationConfigCreate,notificationConfigUpdate,notificationConfigDelete];
|