@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 @@
|
|
|
1
|
-
|
|
1
|
+
export function validateAppcode(code){const trimmed=code.trim();if(!trimmed)return{valid:false,message:"App Code cannot be empty"};if(trimmed.length>100)return{valid:false,message:"App Code cannot exceed 100 characters"};if(!/^[A-Za-z0-9_-]+$/.test(trimmed))return{valid:false,message:"Only letters, numbers, - and _ are allowed"};return{valid:true}}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";import{CLI_BIN_NAME,isTopLevelConfigKey,readScopedConfig,resolveWriteScope,writeScopedConfig}from"../../commands/config/shared.js";const LEGACY_DELETABLE_KEYS=new Set(["inherit"]);const EXTRA_DELETABLE_KEYS=new Set(["defaultApp","routing"]);async function execute(ctx){const key=ctx.args[0]?.trim();if(!key){throw CliErrors.validation("Missing key argument.",`Usage: ${CLI_BIN_NAME} config delete <key> [--global]`)}if(key==="riskLevel"){throw CliErrors.validation('"riskLevel" cannot be changed via the CLI.')}if(!isTopLevelConfigKey(key)&&!EXTRA_DELETABLE_KEYS.has(key)&&!LEGACY_DELETABLE_KEYS.has(key)){throw CliErrors.validation(`Top-level key "${key}" is not deletable.`,"Use workspace commands to modify apps and their default selection.")}const scope=resolveWriteScope({global:ctx.bool("global")});const config=readScopedConfig(scope);const changed=Object.prototype.hasOwnProperty.call(config,key);if(changed){delete config[key]
|
|
2
|
+
;writeScopedConfig(config,scope)}const scopeLabel=scope==="global"?"Global":"Project";return{ok:true,message:changed?`✓ ${scopeLabel} ${key} deleted`:`✓ ${scopeLabel} ${key} already absent`,data:{key:key,scope:scope,changed:changed}}}export const configDeleteDefinition={service:"config",command:"delete",description:"Delete a config value from one scope",risk:"write",requiresAuth:false,requiresAppCode:false,args:[{name:"key",description:"Top-level config key; legacy inherit is accepted for migration",required:true}],flags:[{name:"global",type:"boolean",description:"Delete from global config (~/.rabetbase.json)",default:false}],execute:execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";import{readConfig}from"../../utils/config.js";import{CLI_BIN_NAME}from"../../constant/cli.js";import{getConfigCommandKeyDescription}from"../../commands/config/shared.js";async function execute(ctx){const key=ctx.str("key");if(!key){throw CliErrors.validation("Missing key.",`Usage: ${CLI_BIN_NAME} config get --key <key>`)}const config=readConfig();const actualKey=key==="app"?"appcode":key;const val=config[actualKey];if(val===undefined){throw CliErrors.validation(`Key not found: ${key}`)}return{ok:true,data:typeof val==="object"?val:{[actualKey]:val},message:typeof val==="object"?undefined:String(val)}}export const configGetDefinition={service:"config",command:"get",description:"Get a config value by key",risk:"read",requiresAuth:false,requiresAppCode:false,flags:[{name:"key",type:"string",description:getConfigCommandKeyDescription(),required:true}],execute:execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{configListDefinition}from"../../commands/config/list.js";import{configGetDefinition}from"../../commands/config/get.js";import{configSetDefinition}from"../../commands/config/set.js";import{configDeleteDefinition}from"../../commands/config/delete.js";import{configInitDefinition}from"../../commands/config/init.js";export const configDefinitions=[configInitDefinition,configListDefinition,configGetDefinition,configSetDefinition,configDeleteDefinition];
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import{select}from"@inquirer/prompts";import{CliErrors}from"../../errors.js";import{readScopedConfig,writeScopedConfig}from"../../commands/config/shared.js";import{DOMAIN_CONFIG_FIELDS,LEGACY_DOMAIN_CONFIG_FIELDS,resolveDomainConfigInput}from"../../config/domain-config.js";import{ENTERPRISE_ROUTING_KIND,ENTERPRISE_ROUTING_PROTOCOL}from"../../generated/routing-contract.js";import{DEFAULT_LOVRABET_REGION,ENABLED_LOVRABET_REGION_VALUES,isEnabledLovrabetRegion}from"../../constant/region.js";import{getOfficialRoutingProfile}from"../../constant/routing-profile.js";import{GLOBAL_SCOPE_FLAG}from"../../commands/common/flags.js";export const configInitFlags=[GLOBAL_SCOPE_FLAG,{name:"region",type:"string",description:`Official Lovrabet region: ${ENABLED_LOVRABET_REGION_VALUES.join(", ")}`,enum:[...ENABLED_LOVRABET_REGION_VALUES]},{name:"domain-config",type:"string",description:"Independent-deployment Domain JSON file"},{name:"user-domain",type:"string",description:"Custom User HTTPS origin"},{
|
|
2
|
+
name:"api-domain",type:"string",description:"Custom platform API HTTPS origin"},{name:"runtime-domain",type:"string",description:"Custom Runtime HTTPS origin"},{name:"skill-domain",type:"string",description:"Custom SkillHub HTTPS origin"},{name:"kb-domain",type:"string",description:"Custom knowledge-base HTTPS origin"},{name:"kb-service-domain",type:"string",description:"Custom KB Service HTTPS origin"},{name:"app-domain",type:"string",description:"Custom Lovrabet workspace HTTPS origin"},{name:"local-domain",type:"string",description:"Custom local callback HTTPS origin"},{name:"certificate-domain",type:"string",description:"Custom certificate service HTTPS origin"}];async function resolveRegion(ctx){const explicit=ctx.str("region");if(explicit){if(!isEnabledLovrabetRegion(explicit)){throw CliErrors.validation(`Region "${explicit}" is not currently available.`,`Available regions: ${ENABLED_LOVRABET_REGION_VALUES.join(", ")}`)}return explicit}
|
|
3
|
+
if(ctx.nonInteractive)return DEFAULT_LOVRABET_REGION;try{return await select({message:"Select Lovrabet region",default:DEFAULT_LOVRABET_REGION,choices:ENABLED_LOVRABET_REGION_VALUES.map(region=>({name:`${getOfficialRoutingProfile(region).label} (${region})`,value:region}))})}catch(err){if(err?.name==="ExitPromptError"){throw CliErrors.cancelled()}throw err}}export async function executeConfigInit(ctx){const routingInput=resolveDomainConfigInput(ctx);const domains=routingInput.domains;const hasDomains=Object.keys(domains).length>0;if(hasDomains&&ctx.str("region")){throw CliErrors.validation("Choose either an official region or independent-deployment Domains, not both.")}if(!!domains.localDomain!==!!domains.certificateDomain){throw CliErrors.validation("Independent deployment requires --local-domain and --certificate-domain together.")}const scope=ctx.bool("global")?"global":"project";const config=readScopedConfig(scope);for(const field of DOMAIN_CONFIG_FIELDS)delete config[field]
|
|
4
|
+
;for(const field of LEGACY_DOMAIN_CONFIG_FIELDS)delete config[field];delete config.routing;let region=null;if(hasDomains){delete config.region;if(routingInput.mode==="enterprise-v1"){config.routing={protocol:ENTERPRISE_ROUTING_PROTOCOL,kind:ENTERPRISE_ROUTING_KIND,domains:routingInput.manifestDomains,cdn:routingInput.cdn}}else{Object.assign(config,domains)}}else{region=await resolveRegion(ctx);if(region===DEFAULT_LOVRABET_REGION)delete config.region;else config.region=region}writeScopedConfig(config,scope);return{ok:true,message:hasDomains?`Rabetbase connection configured for independent deployment. Domains: ${Object.keys(routingInput.mode==="enterprise-v1"?routingInput.manifestDomains:domains).join(", ")}.`:`Rabetbase connection configured for region: ${region}.`,data:{mode:hasDomains?"independent":"official",protocol:routingInput.mode==="enterprise-v1"?ENTERPRISE_ROUTING_PROTOCOL:undefined,region:region,domains:domains,
|
|
5
|
+
cdn:routingInput.mode==="enterprise-v1"?routingInput.cdn:undefined}}}export const configInitDefinition={service:"config",command:"init",description:"Initialize the Lovrabet region or independent-deployment Domains",risk:"write",confirmationDescription:"Updates the selected Rabetbase region or independent-deployment Domain configuration. Cookie, output format, and app bindings stay unchanged.",requiresAuth:false,requiresAppCode:false,hasFormat:false,flags:configInitFlags,execute:executeConfigInit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{readScopedConfig}from"../../commands/config/shared.js";import{readConfig}from"../../utils/config.js";async function execute(ctx){const config=ctx.bool("global")?readScopedConfig("global"):readConfig();return{ok:true,data:config}}export const configListDefinition={service:"config",command:"list",description:"List all config values",risk:"read",requiresAuth:false,requiresAppCode:false,flags:[{name:"global",type:"boolean",description:"Show global config only (~/.rabetbase.json)",default:false}],execute:execute};
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";import{buildCanonicalProjectConfig}from"../../config/schema.js";import{CLI_BIN_NAME,CONFIG_ENUM_VALUES,getConfigCommandKeyDescription,getTopLevelConfigKeySummary,isTopLevelConfigKey,normalizeLocale,resolveWriteScope,readScopedConfig,writeScopedConfig}from"../../commands/config/shared.js";import{normalizeEnv,isProduction,isDaily}from"../../constant/env.js";import{DOMAIN_CONFIG_FIELDS,normalizeDomainOrigin}from"../../config/domain-config.js";async function execute(ctx){const key=ctx.str("key");const value=ctx.str("value");if(!key){throw CliErrors.validation("Missing key.",`Usage: ${CLI_BIN_NAME} config set --key <key> --value <value>`)}if(value===undefined||value===""){throw CliErrors.validation("Missing value.",`Usage: ${CLI_BIN_NAME} config set --key <key> --value <value>`)}let actualKey=key;let actualValue=value;if(value.length>500){throw CliErrors.validation("Config value is invalid or too long.")}if(key==="riskLevel"){
|
|
2
|
+
throw CliErrors.validation(`"riskLevel" cannot be changed via the CLI.`)}if(!isTopLevelConfigKey(key)){throw CliErrors.validation(`Top-level key "${key}" is not settable.`,`Settable top-level keys: ${getTopLevelConfigKeySummary()}`)}if(CONFIG_ENUM_VALUES[key]&&!CONFIG_ENUM_VALUES[key].includes(value)){throw CliErrors.validation(`Invalid value for "${key}". Allowed: ${CONFIG_ENUM_VALUES[key].join(", ")}`)}if(key==="locale"&&!normalizeLocale(value)){throw CliErrors.validation("Invalid locale value.","Supported: zh, en, zh-CN, en-US")}if(DOMAIN_CONFIG_FIELDS.includes(key)){actualValue=normalizeDomainOrigin(key,value)}const flags={global:ctx.bool("global")};const scope=resolveWriteScope(flags);const config=readScopedConfig(scope);if(key==="app"){actualKey="appcode";delete config.app}if(key==="locale"){actualValue=normalizeLocale(value)}if(key==="env"){actualValue=normalizeEnv(value);if(!isProduction(actualValue)&&!isDaily(actualValue)){
|
|
3
|
+
throw CliErrors.validation("Invalid value for env. Allowed: production, daily.",'Legacy alias "online" is accepted and stored as production.')}}if(key==="appcode"){const existingApps=config.apps&&typeof config.apps==="object"?Object.keys(config.apps):[];if(existingApps.length>0){throw CliErrors.validation('Cannot set top-level "appcode" when multi-app config already exists.',`Use \`${CLI_BIN_NAME} workspace add <name> --appcode ${actualValue}\`, \`${CLI_BIN_NAME} workspace use --app <name>\`, or pass \`--appcode\` on the command.`)}const nextConfig=buildCanonicalProjectConfig({...config},{appCodes:[actualValue],env:typeof config.env==="string"?config.env:undefined});writeScopedConfig(nextConfig,scope);const scopeLabel=scope==="global"?"Global":"Project";return{ok:true,message:`✓ ${scopeLabel} appcode set to: ${actualValue} (stored as a single app profile)`}}config[actualKey]=actualValue;writeScopedConfig(config,scope);const scopeLabel=scope==="global"?"Global":"Project";return{ok:true,
|
|
4
|
+
message:`✓ ${scopeLabel} ${actualKey} set to: ${actualValue}`}}export const configSetDefinition={service:"config",command:"set",description:"Set a config value",risk:"write",requiresAuth:false,requiresAppCode:false,flags:[{name:"key",type:"string",description:getConfigCommandKeyDescription(),required:true},{name:"value",type:"string",description:"Config value",required:true},{name:"global",type:"boolean",description:"Write to global config (~/.rabetbase.json)",default:false}],execute:execute};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{CLI_BIN_NAME}from"../../constant/cli.js";import{isInProject,resolveWriteConfigPath,readConfigFile,writeConfigFile}from"../../context.js";import{CliErrors}from"../../errors.js";import{CONFIG_ENUM_VALUES,TOP_LEVEL_CONFIG_KEYS,getConfigCommandKeyDescription,getTopLevelConfigKeyList,getTopLevelConfigKeySummary,isTopLevelConfigKey,normalizeLocale}from"../../config/schema.js";export{CLI_BIN_NAME};export{normalizeLocale};export{CONFIG_ENUM_VALUES,TOP_LEVEL_CONFIG_KEYS,getConfigCommandKeyDescription,getTopLevelConfigKeyList,getTopLevelConfigKeySummary,isTopLevelConfigKey};export function resolveWriteScope(flags){if(flags.global)return"global";if(!isInProject()){throw CliErrors.validation("Not inside a project (no .rabetbase.json found).",`Add --global to write to ~/.rabetbase.json, or run \`${CLI_BIN_NAME} workspace init --appcode <code>\` first.`)}return"project"}export function readScopedConfig(scope){return readConfigFile(resolveWriteConfigPath(scope))}
|
|
2
|
+
export function writeScopedConfig(config,scope){writeConfigFile(resolveWriteConfigPath(scope),config)}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
const a65_0x559050=a65_0x544f;(function(_0x20b9ca,_0xe65264){const _0x5ccbee=a65_0x544f,_0x26dc21=_0x20b9ca();while(!![]){try{const _0x8a643=-parseInt(_0x5ccbee(0x96))/0x1*(-parseInt(_0x5ccbee(0x9f))/0x2)+-parseInt(_0x5ccbee(0x91))/0x3+parseInt(_0x5ccbee(0xc1))/0x4*(-parseInt(_0x5ccbee(0xaf))/0x5)+-parseInt(_0x5ccbee(0xac))/0x6*(parseInt(_0x5ccbee(0xd3))/0x7)+-parseInt(_0x5ccbee(0x8a))/0x8+-parseInt(_0x5ccbee(0x80))/0x9+parseInt(_0x5ccbee(0x9d))/0xa;if(_0x8a643===_0xe65264)break;else _0x26dc21['push'](_0x26dc21['shift']());}catch(_0x180a63){_0x26dc21['push'](_0x26dc21['shift']());}}}(a65_0x1667,0x6c735));import{CliErrors}from'../../errors.js';const LOCAL_KEY=/^[a-z][a-z0-9_]{0,63}$/,SUPPORTED_CARDINALITIES=new Set([a65_0x559050(0xc6),a65_0x559050(0xba)]),SUPPORTED_FIELD_TYPES=new Set([a65_0x559050(0x89),a65_0x559050(0x6e),'DATETIME',a65_0x559050(0xbc),a65_0x559050(0xbb),a65_0x559050(0xb1),a65_0x559050(0xcb),a65_0x559050(0x7e),'ADDRESS',a65_0x559050(0x88)]);export function isDatasetBatchDesign(_0x2e7c7c){const _0x1964e0=a65_0x559050;return isObject(_0x2e7c7c)&&_0x2e7c7c[_0x1964e0(0xcf)]==='dataset-batch';}export function validateDatasetBatchDesign(_0x1d3679){const _0x3ddd21=a65_0x559050;(!isObject(_0x1d3679)||_0x1d3679[_0x3ddd21(0xcf)]!==_0x3ddd21(0xd6))&&fail(_0x3ddd21(0x74));_0x1d3679[_0x3ddd21(0x81)]!==0x1&&fail(_0x3ddd21(0x7c));const _0x304577=objectArray(_0x1d3679[_0x3ddd21(0x9e)],_0x3ddd21(0x9e),0x1,0x14),_0x4f2c6d=objectArray(_0x1d3679['relations'],_0x3ddd21(0x84),0x0,0xc8),_0x30f3a9=objectArray(_0x1d3679['unresolvedRelations'],'unresolvedRelations',0x0,0xc8),_0x527818=new Set(),_0x2667f8=new Map();for(const [_0x29b955,_0x59c40d]of _0x304577['entries']()){const _0x59995e=requiredString(_0x59c40d[_0x3ddd21(0xad)],_0x3ddd21(0xb8)+_0x29b955+_0x3ddd21(0x6d));!LOCAL_KEY[_0x3ddd21(0xb5)](_0x59995e)&&fail(_0x3ddd21(0xb8)+_0x29b955+_0x3ddd21(0x93)+LOCAL_KEY['source']+'.');_0x527818['has'](_0x59995e)&&fail(_0x3ddd21(0x86));_0x527818['add'](_0x59995e);!isObject(_0x59c40d[_0x3ddd21(0x72)])&&fail(_0x3ddd21(0xb8)+_0x29b955+_0x3ddd21(0xc9));rejectServerDatasetIdentity(_0x59c40d[_0x3ddd21(0x72)],'datasets['+_0x29b955+_0x3ddd21(0xcd));if(!isObject(_0x59c40d[_0x3ddd21(0x72)]['dataset']))fail(_0x3ddd21(0xb8)+_0x29b955+_0x3ddd21(0x97));rejectServerDatasetIdentity(_0x59c40d['design']['dataset'],_0x3ddd21(0xb8)+_0x29b955+'].design.dataset'),requiredString(_0x59c40d['design'][_0x3ddd21(0xd5)][_0x3ddd21(0x82)],_0x3ddd21(0xb8)+_0x29b955+_0x3ddd21(0xbf));'relations'in _0x59c40d[_0x3ddd21(0x72)]&&(!Array[_0x3ddd21(0xa6)](_0x59c40d[_0x3ddd21(0x72)]['relations'])||_0x59c40d[_0x3ddd21(0x72)][_0x3ddd21(0x84)][_0x3ddd21(0xc7)]!==0x0)&&fail(_0x3ddd21(0xb8)+_0x29b955+_0x3ddd21(0x8d));const _0x3b98e0=objectArray(_0x59c40d[_0x3ddd21(0x72)]['fields'],_0x3ddd21(0xb8)+_0x29b955+'].design.fields',0x1,0xc8),_0x22d3c9=new Map();for(const [_0x1c7291,_0x254a00]of _0x3b98e0['entries']()){const _0x24cf4d=fieldName(_0x254a00);if(!_0x24cf4d)fail(_0x3ddd21(0xb8)+_0x29b955+'].design.fields['+_0x1c7291+_0x3ddd21(0x99));const _0x4f5940=_0x24cf4d['toLowerCase']();if(_0x22d3c9[_0x3ddd21(0xb0)](_0x4f5940))fail(_0x3ddd21(0xa5)+_0x59995e+_0x3ddd21(0xc8));const _0x5c23aa=stringValue(_0x254a00[_0x3ddd21(0x85)]??_0x254a00[_0x3ddd21(0xce)])[_0x3ddd21(0xa0)]();if(!SUPPORTED_FIELD_TYPES[_0x3ddd21(0xb0)](_0x5c23aa))fail(_0x3ddd21(0xb8)+_0x29b955+_0x3ddd21(0x7d)+_0x1c7291+'].type\x20is\x20not\x20supported.');_0x22d3c9[_0x3ddd21(0xa8)](_0x4f5940,_0x5c23aa),[_0x254a00[_0x3ddd21(0xa4)],_0x254a00[_0x3ddd21(0x95)],_0x254a00[_0x3ddd21(0xd4)]]['some'](_0x58ac84=>stringValue(_0x58ac84))&&fail(_0x3ddd21(0xb8)+_0x29b955+_0x3ddd21(0x7d)+_0x1c7291+_0x3ddd21(0x70));}_0x2667f8[_0x3ddd21(0xa8)](_0x59995e,_0x22d3c9);}const _0xac7147=new Set(),_0xee5dcf=new Set();for(const [_0x3be205,_0x5062fa]of _0x4f2c6d[_0x3ddd21(0x76)]()){const _0x11d57f=validateRelation(_0x5062fa,_0x3be205,_0x527818,_0x2667f8);if(_0xac7147[_0x3ddd21(0xb0)](_0x11d57f))fail('Dataset\x20batch\x20relations\x20must\x20be\x20unique.');_0xac7147['add'](_0x11d57f);const _0x16776a=_0x11d57f[_0x3ddd21(0xa3)]('\x00',0x2)['join']('\x00');if(_0xee5dcf[_0x3ddd21(0xb0)](_0x16776a))fail(_0x3ddd21(0x8b));_0xee5dcf['add'](_0x16776a);}for(const [_0x4b14d4,_0x366354]of _0x30f3a9[_0x3ddd21(0x76)]()){requiredString(_0x366354[_0x3ddd21(0xa9)],'unresolvedRelations['+_0x4b14d4+_0x3ddd21(0x92)),validateConfidence(_0x366354[_0x3ddd21(0x73)],_0x3ddd21(0xae)+_0x4b14d4+_0x3ddd21(0x98));}return _0x1d3679;}function a65_0x544f(_0x411c35,_0x2e2c14){_0x411c35=_0x411c35-0x6c;const _0x1667db=a65_0x1667();let _0x544f1f=_0x1667db[_0x411c35];return _0x544f1f;}export function reconcileBatchResult(_0x2df936){const _0x4df768=a65_0x559050;if(!isObject(_0x2df936))return null;try{const _0x2855cb=stringArray(_0x2df936['expectedLocalKeys'],'expectedLocalKeys',0x1,0x14),_0x521d37=new Set(_0x2855cb);if(_0x521d37[_0x4df768(0xb7)]!==_0x2855cb['length']||_0x2855cb[_0x4df768(0xb2)](_0x454738=>!LOCAL_KEY[_0x4df768(0xb5)](_0x454738)))return null;const _0x502476=objectArray(_0x2df936[_0x4df768(0xc3)],_0x4df768(0xc3),0x1,0x14),_0x45fd43=new Map(),_0x2dc546=new Set();for(const _0x1a32ed of _0x502476){const _0x16c2c2=requiredString(_0x1a32ed[_0x4df768(0xad)],'createdDatasets[].localKey'),_0x36f9d1=requiredString(_0x1a32ed['code']??_0x1a32ed['datasetCode'],_0x4df768(0x8f));if(_0x45fd43[_0x4df768(0xb0)](_0x16c2c2)||_0x2dc546[_0x4df768(0xb0)](_0x36f9d1))return null;_0x45fd43[_0x4df768(0xa8)](_0x16c2c2,_0x36f9d1),_0x2dc546[_0x4df768(0x9a)](_0x36f9d1);}if(!sameSet(_0x521d37,new Set(_0x45fd43[_0x4df768(0xa2)]())))return null;const _0x436562=objectArray(_0x2df936[_0x4df768(0x78)],_0x4df768(0x78),0x0,0xc8),_0x159ca5=objectArray(_0x2df936[_0x4df768(0x6f)],_0x4df768(0x6f),0x0,0xc8),_0x2e2061=relationTupleSet(_0x436562,![],_0x45fd43),_0x4415e5=relationTupleSet(_0x159ca5,!![],_0x45fd43);if(!_0x2e2061||!_0x4415e5||!sameSet(_0x2e2061,_0x4415e5))return null;const _0x143aa0=objectArray(_0x2df936[_0x4df768(0xd7)],_0x4df768(0xd7),0x0,0xc8);return{'expectedLocalKeys':_0x2855cb,'expectedRelations':_0x436562,'createdDatasets':_0x502476,'createdRelations':_0x159ca5,'unresolvedRelations':_0x143aa0,...isObject(_0x2df936[_0x4df768(0x83)])?{'metrics':_0x2df936[_0x4df768(0x83)]}:{}};}catch{return null;}}function a65_0x1667(){const _0x4472f5=['set','reason','\x20connects\x20incompatible\x20field\x20types.','map','6lkNLrP','localKey','unresolvedRelations[','4144975MDufxz','has','MULTI_SELECT','some','fromField','\x20must\x20not\x20be\x20supplied\x20by\x20the\x20client.','test','get','size','datasets[','every','ONE_TO_ONE','SELECT','BOOLEAN','relationType','\x20non-empty\x20strings.','].design.dataset.datasetName','trim','4UkpVZa','toField','createdDatasets','modelId','isFinite','MANY_TO_ONE','length','\x20field\x20names\x20must\x20be\x20unique\x20ignoring\x20case.','].design\x20must\x20be\x20an\x20object.','validation','DATE_RANGE','.confidence','].design','fieldType','kind','string','\x20must\x20be\x20between\x200\x20and\x201.','.fromDatasetKey','1015833tNuEME','refTableLabelField','dataset','dataset-batch','unresolvedRelations','\x20references\x20an\x20unknown\x20field.','datasetId','].localKey','NUMBER','createdRelations',']\x20must\x20not\x20contain\x20embedded\x20relation\x20references.','toDatasetKey','design','confidence','Batch\x20--design-file\x20must\x20have\x20kind\x20\x22dataset-batch\x22.','\x20objects.','entries','.fromField','expectedRelations','cardinality','toDatasetCode','fromDatasetCode','Dataset\x20batch\x20schemaVersion\x20must\x20be\x201.','].design.fields[','USER','number','1029312ojngIW','schemaVersion','datasetName','metrics','relations','type','Dataset\x20batch\x20localKey\x20values\x20must\x20be\x20unique.','.reason','UPLOAD','TEXT','3419032UlRnek','Each\x20source\x20field\x20may\x20target\x20at\x20most\x20one\x20relation.','toLowerCase','].design.relations\x20must\x20be\x20an\x20empty\x20array;\x20use\x20top-level\x20relations.','object','createdDatasets[].code','\x20must\x20contain\x20','308274FTQPgp','].reason','].localKey\x20must\x20match\x20','.relationType\x20must\x20be\x20\x22lookup\x22.','refTableField','421SyqUTE','].design.dataset\x20must\x20be\x20an\x20object.','].confidence',']\x20must\x20have\x20a\x20non-empty\x20name\x20or\x20code.','add','lookup','join','17214010LUoJQI','datasets','1622KGhNUV','toUpperCase','fromDatasetKey','keys','split','refTable','Dataset\x20','isArray','code'];a65_0x1667=function(){return _0x4472f5;};return a65_0x1667();}function validateRelation(_0x5d70ed,_0x2491ff,_0x26ae5a,_0x138f56){const _0x1a4745=a65_0x559050,_0x1909b5='relations['+_0x2491ff+']',_0x32b263=requiredString(_0x5d70ed['fromDatasetKey'],_0x1909b5+_0x1a4745(0xd2)),_0x7d1e2=requiredString(_0x5d70ed[_0x1a4745(0x71)],_0x1909b5+'.toDatasetKey'),_0x3b55b3=requiredString(_0x5d70ed[_0x1a4745(0xb3)],_0x1909b5+_0x1a4745(0x77))['toLowerCase'](),_0x21f13e=requiredString(_0x5d70ed[_0x1a4745(0xc2)],_0x1909b5+'.toField')[_0x1a4745(0x8c)]();if(!_0x26ae5a[_0x1a4745(0xb0)](_0x32b263)||!_0x26ae5a[_0x1a4745(0xb0)](_0x7d1e2))fail(_0x1909b5+'\x20references\x20an\x20unknown\x20dataset\x20localKey.');const _0x544f8f=_0x138f56[_0x1a4745(0xb6)](_0x32b263)?.['get'](_0x3b55b3),_0x2bd015=_0x138f56[_0x1a4745(0xb6)](_0x7d1e2)?.['get'](_0x21f13e);if(_0x544f8f===undefined||_0x2bd015===undefined)fail(_0x1909b5+_0x1a4745(0xd8));if(_0x544f8f&&_0x2bd015&&_0x544f8f!==_0x2bd015)fail(_0x1909b5+_0x1a4745(0xaa));const _0x2d460d=stringValue(_0x5d70ed[_0x1a4745(0xbd)])||_0x1a4745(0x9b);if(_0x2d460d!==_0x1a4745(0x9b))fail(_0x1909b5+_0x1a4745(0x94));const _0x3d681b=stringValue(_0x5d70ed[_0x1a4745(0x79)])||_0x1a4745(0xc6);if(!SUPPORTED_CARDINALITIES[_0x1a4745(0xb0)](_0x3d681b))fail(_0x1909b5+'.cardinality\x20is\x20not\x20supported.');return requiredString(_0x5d70ed[_0x1a4745(0xa9)],_0x1909b5+_0x1a4745(0x87)),validateConfidence(_0x5d70ed[_0x1a4745(0x73)],_0x1909b5+_0x1a4745(0xcc)),tuple(_0x32b263,_0x3b55b3,_0x7d1e2,_0x21f13e,_0x1a4745(0x9b),_0x3d681b);}function relationTupleSet(_0x55d11a,_0x5e0f81,_0x102dfa){const _0x3c515e=a65_0x559050,_0x2e1b5f=new Set();for(const _0x4b422a of _0x55d11a){const _0x4b8c41=stringValue(_0x4b422a[_0x3c515e(0xa1)]),_0xc7239e=stringValue(_0x4b422a['toDatasetKey']),_0x576fb0=stringValue(_0x4b422a[_0x3c515e(0xb3)])['toLowerCase'](),_0x4bb274=stringValue(_0x4b422a[_0x3c515e(0xc2)])[_0x3c515e(0x8c)](),_0x195801=stringValue(_0x4b422a[_0x3c515e(0xbd)]),_0x270af=stringValue(_0x4b422a[_0x3c515e(0x79)]);if(!_0x4b8c41||!_0xc7239e||!_0x576fb0||!_0x4bb274||_0x195801!=='lookup'||!SUPPORTED_CARDINALITIES[_0x3c515e(0xb0)](_0x270af))return null;if(!_0x102dfa[_0x3c515e(0xb0)](_0x4b8c41)||!_0x102dfa[_0x3c515e(0xb0)](_0xc7239e))return null;if(_0x5e0f81&&(stringValue(_0x4b422a[_0x3c515e(0x7b)])!==_0x102dfa['get'](_0x4b8c41)||stringValue(_0x4b422a[_0x3c515e(0x7a)])!==_0x102dfa['get'](_0xc7239e)))return null;const _0x3edff0=tuple(_0x4b8c41,_0x576fb0,_0xc7239e,_0x4bb274,_0x195801,_0x270af);if(_0x2e1b5f[_0x3c515e(0xb0)](_0x3edff0))return null;_0x2e1b5f[_0x3c515e(0x9a)](_0x3edff0);}return _0x2e1b5f;}function rejectServerDatasetIdentity(_0x5eed25,_0x4b937b){const _0x6adde5=a65_0x559050;for(const _0x4f53de of['id',_0x6adde5(0x6c),_0x6adde5(0xc4),_0x6adde5(0xa7),'datasetCode','modelCode']){if(_0x5eed25[_0x4f53de]!==undefined&&_0x5eed25[_0x4f53de]!==null&&_0x5eed25[_0x4f53de]!=='')fail(_0x4b937b+'.'+_0x4f53de+_0x6adde5(0xb4));}}function objectArray(_0x1e6f2c,_0x1171f9,_0x285695,_0x434960){const _0x463e6d=a65_0x559050;return(!Array[_0x463e6d(0xa6)](_0x1e6f2c)||_0x1e6f2c[_0x463e6d(0xc7)]<_0x285695||_0x1e6f2c['length']>_0x434960||_0x1e6f2c[_0x463e6d(0xb2)](_0x3cd283=>!isObject(_0x3cd283)))&&fail(_0x1171f9+_0x463e6d(0x90)+_0x285695+'..'+_0x434960+_0x463e6d(0x75)),_0x1e6f2c;}function stringArray(_0x2c5bfe,_0x24826f,_0x743f5,_0x3f8d2e){const _0x2e34d7=a65_0x559050;return(!Array['isArray'](_0x2c5bfe)||_0x2c5bfe['length']<_0x743f5||_0x2c5bfe['length']>_0x3f8d2e||_0x2c5bfe[_0x2e34d7(0xb2)](_0x47abd6=>typeof _0x47abd6!==_0x2e34d7(0xd0)||!_0x47abd6[_0x2e34d7(0xc0)]()))&&fail(_0x24826f+'\x20must\x20contain\x20'+_0x743f5+'..'+_0x3f8d2e+_0x2e34d7(0xbe)),_0x2c5bfe;}function requiredString(_0x2a706b,_0x426a49){const _0x557196=stringValue(_0x2a706b);if(!_0x557196)fail(_0x426a49+'\x20is\x20required.');return _0x557196;}function stringValue(_0x148f92){const _0x2aa088=a65_0x559050;return typeof _0x148f92===_0x2aa088(0xd0)?_0x148f92[_0x2aa088(0xc0)]():'';}function fieldName(_0x3971e1){const _0x3ed973=a65_0x559050;return stringValue(_0x3971e1[_0x3ed973(0xa7)]??_0x3971e1['fieldCode']??_0x3971e1['name']??_0x3971e1['fieldName']);}function validateConfidence(_0x243529,_0x4fadef){const _0x3b0891=a65_0x559050;_0x243529!==undefined&&_0x243529!==null&&(typeof _0x243529!==_0x3b0891(0x7f)||!Number[_0x3b0891(0xc5)](_0x243529)||_0x243529<0x0||_0x243529>0x1)&&fail(_0x4fadef+_0x3b0891(0xd1));}function tuple(..._0x1e2be1){const _0x175fcd=a65_0x559050;return _0x1e2be1[_0x175fcd(0xab)]((_0x1cf8b1,_0x59db35)=>_0x59db35===0x1||_0x59db35===0x3?_0x1cf8b1[_0x175fcd(0x8c)]():_0x1cf8b1)[_0x175fcd(0x9c)]('\x00');}function sameSet(_0x5ca061,_0x242658){const _0x19590c=a65_0x559050;return _0x5ca061['size']===_0x242658['size']&&[..._0x5ca061][_0x19590c(0xb9)](_0x19870a=>_0x242658['has'](_0x19870a));}function isObject(_0x28546d){const _0x3fdb3f=a65_0x559050;return typeof _0x28546d===_0x3fdb3f(0x8e)&&_0x28546d!==null&&!Array['isArray'](_0x28546d);}function fail(_0x1b48ae){const _0x1444ba=a65_0x559050;throw CliErrors[_0x1444ba(0xca)](_0x1b48ae);}
|
|
1
|
+
import{CliErrors}from"../../errors.js";const LOCAL_KEY=/^[a-z][a-z0-9_]{0,63}$/;const SUPPORTED_CARDINALITIES=new Set(["MANY_TO_ONE","ONE_TO_ONE"]);const SUPPORTED_FIELD_TYPES=new Set(["TEXT","NUMBER","DATETIME","BOOLEAN","SELECT","MULTI_SELECT","DATE_RANGE","USER","ADDRESS","UPLOAD"]);export function isDatasetBatchDesign(value){return isObject(value)&&value.kind==="dataset-batch"}export function validateDatasetBatchDesign(value){if(!isObject(value)||value.kind!=="dataset-batch"){fail('Batch --design-file must have kind "dataset-batch".')}if(value.schemaVersion!==1){fail("Dataset batch schemaVersion must be 1.")}const datasets=objectArray(value.datasets,"datasets",1,20);const relations=objectArray(value.relations,"relations",0,200);const unresolved=objectArray(value.unresolvedRelations,"unresolvedRelations",0,200);const datasetKeys=new Set;const fieldsByDataset=new Map;for(const[index,item]of datasets.entries()){const localKey=requiredString(item.localKey,`datasets[${index}].localKey`)
|
|
2
|
+
;if(!LOCAL_KEY.test(localKey)){fail(`datasets[${index}].localKey must match ${LOCAL_KEY.source}.`)}if(datasetKeys.has(localKey)){fail("Dataset batch localKey values must be unique.")}datasetKeys.add(localKey);if(!isObject(item.design)){fail(`datasets[${index}].design must be an object.`)}rejectServerDatasetIdentity(item.design,`datasets[${index}].design`);if(!isObject(item.design.dataset))fail(`datasets[${index}].design.dataset must be an object.`);rejectServerDatasetIdentity(item.design.dataset,`datasets[${index}].design.dataset`);requiredString(item.design.dataset.datasetName,`datasets[${index}].design.dataset.datasetName`);if("relations"in item.design&&(!Array.isArray(item.design.relations)||item.design.relations.length!==0)){fail(`datasets[${index}].design.relations must be an empty array; use top-level relations.`)}const fields=objectArray(item.design.fields,`datasets[${index}].design.fields`,1,200);const fieldTypes=new Map;for(const[fieldIndex,field]of fields.entries()){
|
|
3
|
+
const name=fieldName(field);if(!name)fail(`datasets[${index}].design.fields[${fieldIndex}] must have a non-empty name or code.`);const normalized=name.toLowerCase();if(fieldTypes.has(normalized))fail(`Dataset ${localKey} field names must be unique ignoring case.`);const type=stringValue(field.type??field.fieldType).toUpperCase();if(!SUPPORTED_FIELD_TYPES.has(type))fail(`datasets[${index}].design.fields[${fieldIndex}].type is not supported.`);fieldTypes.set(normalized,type);if([field.refTable,field.refTableField,field.refTableLabelField].some(entry=>stringValue(entry))){fail(`datasets[${index}].design.fields[${fieldIndex}] must not contain embedded relation references.`)}}fieldsByDataset.set(localKey,fieldTypes)}const relationTuples=new Set;const sources=new Set;for(const[index,relation]of relations.entries()){const tuple=validateRelation(relation,index,datasetKeys,fieldsByDataset);if(relationTuples.has(tuple))fail("Dataset batch relations must be unique.");relationTuples.add(tuple)
|
|
4
|
+
;const source=tuple.split("\0",2).join("\0");if(sources.has(source))fail("Each source field may target at most one relation.");sources.add(source)}for(const[index,relation]of unresolved.entries()){requiredString(relation.reason,`unresolvedRelations[${index}].reason`);validateConfidence(relation.confidence,`unresolvedRelations[${index}].confidence`)}return value}export function reconcileBatchResult(value){if(!isObject(value))return null;try{const expectedLocalKeys=stringArray(value.expectedLocalKeys,"expectedLocalKeys",1,20);const expectedSet=new Set(expectedLocalKeys);if(expectedSet.size!==expectedLocalKeys.length||expectedLocalKeys.some(key=>!LOCAL_KEY.test(key)))return null;const createdDatasets=objectArray(value.createdDatasets,"createdDatasets",1,20);const codes=new Map;const uniqueCodes=new Set;for(const dataset of createdDatasets){const localKey=requiredString(dataset.localKey,"createdDatasets[].localKey")
|
|
5
|
+
;const code=requiredString(dataset.code??dataset.datasetCode,"createdDatasets[].code");if(codes.has(localKey)||uniqueCodes.has(code))return null;codes.set(localKey,code);uniqueCodes.add(code)}if(!sameSet(expectedSet,new Set(codes.keys())))return null;const expectedRelations=objectArray(value.expectedRelations,"expectedRelations",0,200);const createdRelations=objectArray(value.createdRelations,"createdRelations",0,200);const expectedTuples=relationTupleSet(expectedRelations,false,codes);const createdTuples=relationTupleSet(createdRelations,true,codes);if(!expectedTuples||!createdTuples||!sameSet(expectedTuples,createdTuples))return null;const unresolvedRelations=objectArray(value.unresolvedRelations,"unresolvedRelations",0,200);return{expectedLocalKeys:expectedLocalKeys,expectedRelations:expectedRelations,createdDatasets:createdDatasets,createdRelations:createdRelations,unresolvedRelations:unresolvedRelations,...isObject(value.metrics)?{metrics:value.metrics}:{}}}catch{return null}}
|
|
6
|
+
function validateRelation(relation,index,datasetKeys,fieldsByDataset){const prefix=`relations[${index}]`;const fromKey=requiredString(relation.fromDatasetKey,`${prefix}.fromDatasetKey`);const toKey=requiredString(relation.toDatasetKey,`${prefix}.toDatasetKey`);const fromField=requiredString(relation.fromField,`${prefix}.fromField`).toLowerCase();const toField=requiredString(relation.toField,`${prefix}.toField`).toLowerCase();if(!datasetKeys.has(fromKey)||!datasetKeys.has(toKey))fail(`${prefix} references an unknown dataset localKey.`);const fromType=fieldsByDataset.get(fromKey)?.get(fromField);const toType=fieldsByDataset.get(toKey)?.get(toField);if(fromType===undefined||toType===undefined)fail(`${prefix} references an unknown field.`);if(fromType&&toType&&fromType!==toType)fail(`${prefix} connects incompatible field types.`);const relationType=stringValue(relation.relationType)||"lookup";if(relationType!=="lookup")fail(`${prefix}.relationType must be "lookup".`)
|
|
7
|
+
;const cardinality=stringValue(relation.cardinality)||"MANY_TO_ONE";if(!SUPPORTED_CARDINALITIES.has(cardinality))fail(`${prefix}.cardinality is not supported.`);requiredString(relation.reason,`${prefix}.reason`);validateConfidence(relation.confidence,`${prefix}.confidence`);return tuple(fromKey,fromField,toKey,toField,"lookup",cardinality)}function relationTupleSet(relations,requireCodes,codes){const result=new Set;for(const relation of relations){const fromKey=stringValue(relation.fromDatasetKey);const toKey=stringValue(relation.toDatasetKey);const fromField=stringValue(relation.fromField).toLowerCase();const toField=stringValue(relation.toField).toLowerCase();const relationType=stringValue(relation.relationType);const cardinality=stringValue(relation.cardinality);if(!fromKey||!toKey||!fromField||!toField||relationType!=="lookup"||!SUPPORTED_CARDINALITIES.has(cardinality))return null;if(!codes.has(fromKey)||!codes.has(toKey))return null
|
|
8
|
+
;if(requireCodes&&(stringValue(relation.fromDatasetCode)!==codes.get(fromKey)||stringValue(relation.toDatasetCode)!==codes.get(toKey)))return null;const key=tuple(fromKey,fromField,toKey,toField,relationType,cardinality);if(result.has(key))return null;result.add(key)}return result}function rejectServerDatasetIdentity(value,path){for(const key of["id","datasetId","modelId","code","datasetCode","modelCode"]){if(value[key]!==undefined&&value[key]!==null&&value[key]!=="")fail(`${path}.${key} must not be supplied by the client.`)}}function objectArray(value,path,min,max){if(!Array.isArray(value)||value.length<min||value.length>max||value.some(item=>!isObject(item))){fail(`${path} must contain ${min}..${max} objects.`)}return value}function stringArray(value,path,min,max){if(!Array.isArray(value)||value.length<min||value.length>max||value.some(item=>typeof item!=="string"||!item.trim())){fail(`${path} must contain ${min}..${max} non-empty strings.`)}return value}
|
|
9
|
+
function requiredString(value,path){const result=stringValue(value);if(!result)fail(`${path} is required.`);return result}function stringValue(value){return typeof value==="string"?value.trim():""}function fieldName(field){return stringValue(field.code??field.fieldCode??field.name??field.fieldName)}function validateConfidence(value,path){if(value!==undefined&&value!==null&&(typeof value!=="number"||!Number.isFinite(value)||value<0||value>1)){fail(`${path} must be between 0 and 1.`)}}function tuple(...parts){return parts.map((part,index)=>index===1||index===3?part.toLowerCase():part).join("\0")}function sameSet(left,right){return left.size===right.size&&[...left].every(item=>right.has(item))}function isObject(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)}function fail(message){throw CliErrors.validation(message)}
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
const a66_0x3deab3=a66_0x1282;(function(_0x3f3e70,_0x10f5a0){const _0x4205e3=a66_0x1282,_0x34e9d3=_0x3f3e70();while(!![]){try{const _0x31571c=parseInt(_0x4205e3(0x131))/0x1*(parseInt(_0x4205e3(0xf5))/0x2)+-parseInt(_0x4205e3(0xe9))/0x3*(-parseInt(_0x4205e3(0x100))/0x4)+parseInt(_0x4205e3(0xed))/0x5*(-parseInt(_0x4205e3(0xfc))/0x6)+parseInt(_0x4205e3(0x128))/0x7*(-parseInt(_0x4205e3(0x120))/0x8)+parseInt(_0x4205e3(0x101))/0x9*(-parseInt(_0x4205e3(0x111))/0xa)+parseInt(_0x4205e3(0x112))/0xb*(-parseInt(_0x4205e3(0x119))/0xc)+parseInt(_0x4205e3(0x109))/0xd*(parseInt(_0x4205e3(0x105))/0xe);if(_0x31571c===_0x10f5a0)break;else _0x34e9d3['push'](_0x34e9d3['shift']());}catch(_0x465635){_0x34e9d3['push'](_0x34e9d3['shift']());}}}(a66_0x59b8,0x3a0b8));import{APPCODE_FLAG_OPTIONAL,CODE_FLAG}from'../../commands/common/flags.js';import{getDatasetDetail,updateDbTableBusinessGroup,updateErBusinessGroup}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';const DB_TABLE_BACKEND_PATH=a66_0x3deab3(0x138),METADATA_BACKEND_PATH=a66_0x3deab3(0xf9),UNGROUPED_BUSINESS_GROUP=a66_0x3deab3(0x130);export async function buildDatasetBusinessGroupUpdateResult({appCode:_0x5e5eb1,input:_0x34b7ae,dryRun:_0xdb9805}){const _0x3bb0a5=a66_0x3deab3;validateInput(_0x34b7ae);const _0xc004cc=normalizeBusinessGroupArgument(_0x34b7ae[_0x3bb0a5(0x135)]),_0xb6259f=await getDatasetDetail(_0x34b7ae[_0x3bb0a5(0x129)]),_0x462df0=resolveBusinessGroupDataset(_0xb6259f,_0x34b7ae[_0x3bb0a5(0x129)]);assertBusinessGroupUpdateSupported(_0x462df0,_0xc004cc);const _0x478714=loadCurrentBusinessGroup(_0xb6259f,_0x462df0);assertExpectedBusinessGroup(_0x478714,_0x34b7ae[_0x3bb0a5(0x137)]);const _0x1192fa=buildBackendPlan(_0x5e5eb1,_0x462df0,_0xc004cc),_0x2878b5=_0x478714!==_0xc004cc;let _0x30b3fe;if(_0x2878b5&&!_0xdb9805){_0x1192fa[_0x3bb0a5(0x12c)]===_0x3bb0a5(0x13b)?await updateDbTableBusinessGroup(_0x1192fa[_0x3bb0a5(0x133)]):await updateErBusinessGroup(_0x1192fa[_0x3bb0a5(0x133)]);const _0x58b78b=await getDatasetDetail(_0x462df0[_0x3bb0a5(0x129)]),_0x363a99=resolveBusinessGroupDataset(_0x58b78b,_0x462df0[_0x3bb0a5(0x129)]),_0x35aa36=loadCurrentBusinessGroup(_0x58b78b,_0x363a99);if(_0x35aa36!==_0xc004cc)throw CliErrors[_0x3bb0a5(0x139)]('Business\x20scenario\x20group\x20update\x20did\x20not\x20match\x20dataset\x20detail\x20readback.',_0x3bb0a5(0x12b)+JSON['stringify'](displayBusinessGroup(_0xc004cc))+_0x3bb0a5(0x113)+JSON[_0x3bb0a5(0x114)](displayBusinessGroup(_0x35aa36))+'.');_0x30b3fe={'verified':!![],'status':_0x3bb0a5(0x122),'afterReadback':{'businessGroup':displayBusinessGroup(_0x35aa36)}};}else!_0x2878b5&&(_0x30b3fe={'verified':!![],'status':_0x3bb0a5(0xfd),'afterReadback':{'businessGroup':displayBusinessGroup(_0x478714)}});const _0x1cf52e={'operation':_0x3bb0a5(0xef),'appCode':_0x5e5eb1,'selector':{'code':_0x462df0[_0x3bb0a5(0x129)]},'dataset':{'id':_0x462df0['id'],'code':_0x462df0[_0x3bb0a5(0x129)],'name':_0x462df0[_0x3bb0a5(0x126)],'sourceType':_0x462df0[_0x3bb0a5(0x10d)]},'before':{'businessGroup':displayBusinessGroup(_0x478714)},'after':{'businessGroup':displayBusinessGroup(_0xc004cc)},'changed':_0x2878b5,'dryRun':_0xdb9805,'submitted':_0x2878b5&&!_0xdb9805,'backend':{'method':_0x1192fa[_0x3bb0a5(0xf0)],'path':_0x1192fa[_0x3bb0a5(0xec)],'payload':_0x1192fa[_0x3bb0a5(0x133)]},..._0x30b3fe?{'verification':_0x30b3fe}:{},'warnings':[]};return{'ok':!![],'data':_0x1cf52e,'message':_0x2878b5?_0xdb9805?_0x3bb0a5(0xf1)+_0x462df0[_0x3bb0a5(0x129)]:_0x3bb0a5(0x132)+_0x462df0[_0x3bb0a5(0x129)]:_0x3bb0a5(0x134)+_0x462df0[_0x3bb0a5(0x129)]};}export const datasetBusinessGroupUpdate={'service':'dataset','command':'business-group-update','description':a66_0x3deab3(0xf4),'risk':a66_0x3deab3(0x12d),'flags':[CODE_FLAG,{'name':a66_0x3deab3(0x10e),'type':'string','required':!![],'description':'Business\x20scenario\x20group\x20(not\x20technical):\x20use\x20<scenario>,\x20<domain>---<scenario>\x20when\x20needed;\x20METADATA\x20accepts\x20ungrouped\x20to\x20clear\x20it'},{'name':a66_0x3deab3(0x11c),'type':'string','required':![],'description':a66_0x3deab3(0x10c)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x356916){validateInput(readBusinessGroupUpdateInput(_0x356916));},async 'dryRun'(_0x37bef6){const _0x4221b0=a66_0x3deab3,_0x4903ed=await buildDatasetBusinessGroupUpdateResult({'appCode':_0x37bef6['appCode'],'input':readBusinessGroupUpdateInput(_0x37bef6),'dryRun':!![]});return{'method':_0x4903ed[_0x4221b0(0x12f)][_0x4221b0(0xff)][_0x4221b0(0xf0)],'url':_0x4903ed[_0x4221b0(0x12f)][_0x4221b0(0xff)][_0x4221b0(0xec)],'body':_0x4903ed[_0x4221b0(0x12f)]['backend'][_0x4221b0(0x133)],'description':_0x4903ed[_0x4221b0(0xfe)],..._0x4903ed[_0x4221b0(0x12f)]};},async 'execute'(_0x561013){const _0x107135=a66_0x3deab3;return buildDatasetBusinessGroupUpdateResult({'appCode':_0x561013[_0x107135(0x121)],'input':readBusinessGroupUpdateInput(_0x561013),'dryRun':![]});}};function readBusinessGroupUpdateInput(_0x3a7255){const _0x3b8b8c=a66_0x3deab3,_0x219ed6=_0x3a7255[_0x3b8b8c(0x102)](_0x3b8b8c(0x11c));return{'code':trim(_0x3a7255[_0x3b8b8c(0x102)](_0x3b8b8c(0x129))),'businessGroup':_0x3a7255[_0x3b8b8c(0x102)](_0x3b8b8c(0x10e)),'expectBusinessGroup':_0x219ed6===undefined||_0x219ed6===''?undefined:_0x219ed6};}function validateInput(_0x44d5d6){const _0x24d770=a66_0x3deab3;if(!trim(_0x44d5d6[_0x24d770(0x129)]))throw CliErrors[_0x24d770(0x12a)](_0x24d770(0x118));if(_0x44d5d6[_0x24d770(0x135)]===undefined)throw CliErrors['validation'](_0x24d770(0x107));if(!trim(_0x44d5d6[_0x24d770(0x135)]))throw CliErrors[_0x24d770(0x12a)](_0x24d770(0x104));}function assertBusinessGroupUpdateSupported(_0x285cbb,_0x15514c){const _0x3481c1=a66_0x3deab3;if(_0x285cbb[_0x3481c1(0x10d)]===_0x3481c1(0x117)&&!_0x15514c)throw CliErrors[_0x3481c1(0x12a)](_0x3481c1(0x11e));}function resolveBusinessGroupDataset(_0x245f8c,_0x8f2a75){const _0x4f79c4=a66_0x3deab3,_0x168102=asPlainObject(_0x245f8c[_0x4f79c4(0xf7)]),_0x20eb00=asPlainObject(_0x245f8c[_0x4f79c4(0xea)]),_0x255934=resolveSourceType(_0x245f8c,_0x168102,_0x20eb00),_0x5e072d=firstString(_0x245f8c[_0x4f79c4(0x103)],_0x245f8c[_0x4f79c4(0x129)],_0x168102[_0x4f79c4(0x11d)],_0x8f2a75)||_0x8f2a75;return{'id':firstNumber(_0x245f8c['modelId'],_0x245f8c['id'],_0x168102['datasetId'])??firstString(_0x245f8c[_0x4f79c4(0xf6)],_0x245f8c['id'],_0x168102[_0x4f79c4(0xf3)])??null,'code':_0x5e072d,'name':firstString(_0x245f8c[_0x4f79c4(0x126)],_0x168102[_0x4f79c4(0x125)],_0x168102['name'])||null,'sourceType':_0x255934,'dbTableSelector':_0x255934===_0x4f79c4(0x117)?{'dbLinkId':firstNumber(_0x20eb00[_0x4f79c4(0x11b)]),'tableName':firstString(_0x20eb00['tableName'])||null}:null};}function resolveSourceType(_0x40c809,_0x34d0c3,_0x5c496b){const _0x3716ff=a66_0x3deab3,_0x56e1ab=firstString(_0x40c809[_0x3716ff(0x123)],_0x40c809[_0x3716ff(0x10d)],_0x34d0c3[_0x3716ff(0x123)],_0x34d0c3[_0x3716ff(0x10d)])?.[_0x3716ff(0x124)]()[_0x3716ff(0x13c)]();if(_0x56e1ab===_0x3716ff(0x117)||_0x56e1ab==='METADATA')return _0x56e1ab;if(Object[_0x3716ff(0x136)](_0x5c496b)[_0x3716ff(0x110)]>0x0)return'DB_TABLE';throw CliErrors[_0x3716ff(0x12a)](_0x3716ff(0xeb));}function a66_0x59b8(){const _0x5a41d9=[',\x20actual\x20','stringify','dbLinkId','metadata','DB_TABLE','--code\x20is\x20required','1291452CyZrjc','isFinite','dbId','expect-business-group','datasetCode','Clearing\x20business\x20scenario\x20groups\x20is\x20not\x20supported\x20for\x20DB_TABLE\x20datasets.','hasOwnProperty','432AwnrYO','appCode','matched','source','trim','datasetName','name','tableName','51569uRqORI','code','validation','Expected\x20','kind','write','Run\x20dataset\x20detail\x20and\x20complete\x20database\x20analysis\x20before\x20updating\x20the\x20business\x20group.','data','ungrouped','121798MCmMtw','Updated\x20business\x20scenario\x20group\x20for\x20dataset\x20','payload','No\x20changes\x20for\x20business\x20scenario\x20group\x20on\x20dataset\x20','businessGroup','keys','expectBusinessGroup','/smartapi/dblink/updateTableBusinessGroup','apiError','string','db-table','toUpperCase','object','3RBCDyJ','dbtableConfig','Dataset\x20sourceType\x20is\x20required\x20and\x20must\x20be\x20DB_TABLE\x20or\x20METADATA.','path','5990leqzVn','dbTableSelector','update','method','Dry-run:\x20business\x20scenario\x20group\x20would\x20change\x20for\x20dataset\x20','Expectation\x20mismatch\x20at\x20businessGroup','datasetId','Update\x20business\x20scenario\x20group','6cvejJt','modelId','dataset','value','/smartapi/question/er-config/business-group/edit','isArray','found','798VGxLDH','unchanged','message','backend','62968SyOrwg','280179guzJiO','str','modelCode','--business-group\x20must\x20not\x20be\x20blank','56RHdNqG','call','--business-group\x20is\x20required','POST','3009799ZocFFQ','number','parse','Expected\x20current\x20business\x20scenario\x20group;\x20use\x20ungrouped\x20to\x20expect\x20no\x20group;\x20mismatch\x20aborts\x20without\x20writing','sourceType','business-group','extend','length','130RSXujx','11Dqezyb'];a66_0x59b8=function(){return _0x5a41d9;};return a66_0x59b8();}function loadCurrentBusinessGroup(_0x189fb2,_0x43dfe0){const _0xc1c63b=a66_0x3deab3,_0x168744=readBusinessGroupFromDatasetDetail(_0x189fb2,_0x43dfe0['sourceType']);if(_0x168744[_0xc1c63b(0xfb)])return normalizeBusinessGroup(_0x168744[_0xc1c63b(0xf8)]);return'';}function a66_0x1282(_0x374c8d,_0x24f2a3){_0x374c8d=_0x374c8d-0xe9;const _0x59b872=a66_0x59b8();let _0x128258=_0x59b872[_0x374c8d];return _0x128258;}function readBusinessGroupFromDatasetDetail(_0x27b526,_0x4d9356){const _0x1b9321=a66_0x3deab3,_0x35122e=asPlainObject(_0x27b526[_0x1b9321(0xf7)]),_0x594402=firstPresent(_0x27b526['businessGroup']);if(_0x594402['found'])return _0x594402;const _0x48a83b=firstPresent(_0x35122e[_0x1b9321(0x135)]);if(_0x48a83b[_0x1b9321(0xfb)])return _0x48a83b;if(_0x4d9356==='DB_TABLE')return{'found':![]};const _0x2cbdae=readBusinessGroupFromExtend(_0x27b526[_0x1b9321(0x10f)]);if(_0x2cbdae[_0x1b9321(0xfb)])return _0x2cbdae;return readBusinessGroupFromExtend(_0x35122e[_0x1b9321(0x10f)]);}function readBusinessGroupFromExtend(_0x44f6cc){const _0x10ea7e=a66_0x3deab3;if(_0x44f6cc===undefined||_0x44f6cc===null||_0x44f6cc==='')return{'found':![]};if(typeof _0x44f6cc===_0x10ea7e(0x13a))try{const _0x4e09e9=JSON[_0x10ea7e(0x10b)](_0x44f6cc);return readBusinessGroupFromExtend(_0x4e09e9);}catch{return{'found':![]};}const _0xdc40f5=asPlainObject(_0x44f6cc);if(Object['prototype'][_0x10ea7e(0x11f)][_0x10ea7e(0x106)](_0xdc40f5,_0x10ea7e(0x135)))return{'found':!![],'value':_0xdc40f5[_0x10ea7e(0x135)]};return{'found':![]};}function firstPresent(..._0x3241e3){for(const _0x10370d of _0x3241e3){if(_0x10370d!==undefined&&_0x10370d!==null)return{'found':!![],'value':_0x10370d};}return{'found':![]};}function assertExpectedBusinessGroup(_0x7fbbe2,_0x34c56c){const _0x2be7dc=a66_0x3deab3;if(_0x34c56c===undefined)return;const _0x14fbc7=normalizeBusinessGroupArgument(_0x34c56c);if(_0x7fbbe2!==_0x14fbc7)throw CliErrors[_0x2be7dc(0x12a)](_0x2be7dc(0xf2),_0x2be7dc(0x12b)+JSON[_0x2be7dc(0x114)](_0x14fbc7)+_0x2be7dc(0x113)+JSON[_0x2be7dc(0x114)](_0x7fbbe2));}function buildBackendPlan(_0x33c2b6,_0xf38b0d,_0xcbaa03){const _0x33ad9e=a66_0x3deab3;if(_0xf38b0d[_0x33ad9e(0x10d)]==='DB_TABLE'){if(!_0xf38b0d['dbTableSelector']||_0xf38b0d[_0x33ad9e(0xee)]['dbLinkId']===null||!_0xf38b0d[_0x33ad9e(0xee)][_0x33ad9e(0x127)])throw CliErrors[_0x33ad9e(0x12a)]('DB_TABLE\x20dataset\x20requires\x20dbtableConfig.dbId\x20and\x20tableName.',_0x33ad9e(0x12e));return{'kind':'db-table','method':_0x33ad9e(0x108),'path':DB_TABLE_BACKEND_PATH,'payload':{'dbLinkId':_0xf38b0d[_0x33ad9e(0xee)][_0x33ad9e(0x115)],'tableName':_0xf38b0d['dbTableSelector'][_0x33ad9e(0x127)],'businessGroup':_0xcbaa03}};}return{'kind':_0x33ad9e(0x116),'method':'POST','path':METADATA_BACKEND_PATH,'payload':{'appCode':_0x33c2b6,'datasetCode':_0xf38b0d['code'],'businessGroup':_0xcbaa03}};}function normalizeBusinessGroup(_0x1c1f50){if(_0x1c1f50===undefined||_0x1c1f50===null)return'';return String(_0x1c1f50)['trim']();}function normalizeBusinessGroupArgument(_0x31dc47){const _0x4f1fac=normalizeBusinessGroup(_0x31dc47);return _0x4f1fac===UNGROUPED_BUSINESS_GROUP?'':_0x4f1fac;}function displayBusinessGroup(_0xecb910){return _0xecb910||UNGROUPED_BUSINESS_GROUP;}function asPlainObject(_0x30e47f){const _0x1c7b66=a66_0x3deab3;if(!_0x30e47f||typeof _0x30e47f!==_0x1c7b66(0x13d)||Array[_0x1c7b66(0xfa)](_0x30e47f))return{};return _0x30e47f;}function firstString(..._0x10d391){const _0x116735=a66_0x3deab3;for(const _0xc5ae32 of _0x10d391){if(typeof _0xc5ae32===_0x116735(0x13a)&&_0xc5ae32[_0x116735(0x124)]())return _0xc5ae32['trim']();if(typeof _0xc5ae32===_0x116735(0x10a)&&Number[_0x116735(0x11a)](_0xc5ae32))return String(_0xc5ae32);}return undefined;}function firstNumber(..._0x22e591){const _0x132701=a66_0x3deab3;for(const _0x4bacea of _0x22e591){if(typeof _0x4bacea==='number'&&Number['isFinite'](_0x4bacea))return _0x4bacea;if(typeof _0x4bacea===_0x132701(0x13a)&&_0x4bacea[_0x132701(0x124)]()&&Number[_0x132701(0x11a)](Number(_0x4bacea)))return Number(_0x4bacea);}return null;}function trim(_0x46ba96){const _0x41b6d8=a66_0x3deab3;return String(_0x46ba96||'')[_0x41b6d8(0x124)]();}
|
|
1
|
+
import{APPCODE_FLAG_OPTIONAL,CODE_FLAG}from"../../commands/common/flags.js";import{getDatasetDetail,updateDbTableBusinessGroup,updateErBusinessGroup}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";const DB_TABLE_BACKEND_PATH="/smartapi/dblink/updateTableBusinessGroup";const METADATA_BACKEND_PATH="/smartapi/question/er-config/business-group/edit";const UNGROUPED_BUSINESS_GROUP="ungrouped";export async function buildDatasetBusinessGroupUpdateResult({appCode:appCode,input:input,dryRun:dryRun}){validateInput(input);const requestedBusinessGroup=normalizeBusinessGroupArgument(input.businessGroup);const drivenData=await getDatasetDetail(input.code);const dataset=resolveBusinessGroupDataset(drivenData,input.code);assertBusinessGroupUpdateSupported(dataset,requestedBusinessGroup);const beforeBusinessGroup=loadCurrentBusinessGroup(drivenData,dataset);assertExpectedBusinessGroup(beforeBusinessGroup,input.expectBusinessGroup)
|
|
2
|
+
;const backend=buildBackendPlan(appCode,dataset,requestedBusinessGroup);const changed=beforeBusinessGroup!==requestedBusinessGroup;let verification;if(changed&&!dryRun){if(backend.kind==="db-table"){await updateDbTableBusinessGroup(backend.payload)}else{await updateErBusinessGroup(backend.payload)}const readbackDrivenData=await getDatasetDetail(dataset.code);const readbackDataset=resolveBusinessGroupDataset(readbackDrivenData,dataset.code);const afterReadback=loadCurrentBusinessGroup(readbackDrivenData,readbackDataset);if(afterReadback!==requestedBusinessGroup){throw CliErrors.apiError("Business scenario group update did not match dataset detail readback.",`Expected ${JSON.stringify(displayBusinessGroup(requestedBusinessGroup))}, actual ${JSON.stringify(displayBusinessGroup(afterReadback))}.`)}verification={verified:true,status:"matched",afterReadback:{businessGroup:displayBusinessGroup(afterReadback)}}}else if(!changed){verification={verified:true,status:"unchanged",afterReadback:{
|
|
3
|
+
businessGroup:displayBusinessGroup(beforeBusinessGroup)}}}const data={operation:"update",appCode:appCode,selector:{code:dataset.code},dataset:{id:dataset.id,code:dataset.code,name:dataset.name,sourceType:dataset.sourceType},before:{businessGroup:displayBusinessGroup(beforeBusinessGroup)},after:{businessGroup:displayBusinessGroup(requestedBusinessGroup)},changed:changed,dryRun:dryRun,submitted:changed&&!dryRun,backend:{method:backend.method,path:backend.path,payload:backend.payload},...verification?{verification:verification}:{},warnings:[]};return{ok:true,data:data,message:changed?dryRun?`Dry-run: business scenario group would change for dataset ${dataset.code}`:`Updated business scenario group for dataset ${dataset.code}`:`No changes for business scenario group on dataset ${dataset.code}`}}export const datasetBusinessGroupUpdate={service:"dataset",command:"business-group-update",description:"Update business scenario group",risk:"write",flags:[CODE_FLAG,{name:"business-group",
|
|
4
|
+
type:"string",required:true,description:"Business scenario group (not technical): use <scenario>, <domain>---<scenario> when needed; METADATA accepts ungrouped to clear it"},{name:"expect-business-group",type:"string",required:false,description:"Expected current business scenario group; use ungrouped to expect no group; mismatch aborts without writing"},APPCODE_FLAG_OPTIONAL],async validate(ctx){validateInput(readBusinessGroupUpdateInput(ctx))},async dryRun(ctx){const preview=await buildDatasetBusinessGroupUpdateResult({appCode:ctx.appCode,input:readBusinessGroupUpdateInput(ctx),dryRun:true});return{method:preview.data.backend.method,url:preview.data.backend.path,body:preview.data.backend.payload,description:preview.message,...preview.data}},async execute(ctx){return buildDatasetBusinessGroupUpdateResult({appCode:ctx.appCode,input:readBusinessGroupUpdateInput(ctx),dryRun:false})}};function readBusinessGroupUpdateInput(ctx){const expectBusinessGroup=ctx.str("expect-business-group")
|
|
5
|
+
;return{code:trim(ctx.str("code")),businessGroup:ctx.str("business-group"),expectBusinessGroup:expectBusinessGroup===undefined||expectBusinessGroup===""?undefined:expectBusinessGroup}}function validateInput(input){if(!trim(input.code)){throw CliErrors.validation("--code is required")}if(input.businessGroup===undefined){throw CliErrors.validation("--business-group is required")}if(!trim(input.businessGroup)){throw CliErrors.validation("--business-group must not be blank")}}function assertBusinessGroupUpdateSupported(dataset,requestedBusinessGroup){if(dataset.sourceType==="DB_TABLE"&&!requestedBusinessGroup){throw CliErrors.validation("Clearing business scenario groups is not supported for DB_TABLE datasets.")}}function resolveBusinessGroupDataset(drivenData,fallbackCode){const dataset=asPlainObject(drivenData.dataset);const dbtable=asPlainObject(drivenData.dbtableConfig);const sourceType=resolveSourceType(drivenData,dataset,dbtable)
|
|
6
|
+
;const code=firstString(drivenData.modelCode,drivenData.code,dataset.datasetCode,fallbackCode)||fallbackCode;return{id:firstNumber(drivenData.modelId,drivenData.id,dataset.datasetId)??firstString(drivenData.modelId,drivenData.id,dataset.datasetId)??null,code:code,name:firstString(drivenData.name,dataset.datasetName,dataset.name)||null,sourceType:sourceType,dbTableSelector:sourceType==="DB_TABLE"?{dbLinkId:firstNumber(dbtable.dbId),tableName:firstString(dbtable.tableName)||null}:null}}function resolveSourceType(drivenData,dataset,dbtable){const source=firstString(drivenData.source,drivenData.sourceType,dataset.source,dataset.sourceType)?.trim().toUpperCase();if(source==="DB_TABLE"||source==="METADATA"){return source}if(Object.keys(dbtable).length>0){return"DB_TABLE"}throw CliErrors.validation("Dataset sourceType is required and must be DB_TABLE or METADATA.")}function loadCurrentBusinessGroup(drivenData,dataset){
|
|
7
|
+
const businessGroup=readBusinessGroupFromDatasetDetail(drivenData,dataset.sourceType);if(businessGroup.found){return normalizeBusinessGroup(businessGroup.value)}return""}function readBusinessGroupFromDatasetDetail(drivenData,sourceType){const dataset=asPlainObject(drivenData.dataset);const topLevel=firstPresent(drivenData.businessGroup);if(topLevel.found){return topLevel}const direct=firstPresent(dataset.businessGroup);if(direct.found){return direct}if(sourceType==="DB_TABLE"){return{found:false}}const extendValue=readBusinessGroupFromExtend(drivenData.extend);if(extendValue.found){return extendValue}return readBusinessGroupFromExtend(dataset.extend)}function readBusinessGroupFromExtend(extend){if(extend===undefined||extend===null||extend===""){return{found:false}}if(typeof extend==="string"){try{const parsed=JSON.parse(extend);return readBusinessGroupFromExtend(parsed)}catch{return{found:false}}}const extendObject=asPlainObject(extend)
|
|
8
|
+
;if(Object.prototype.hasOwnProperty.call(extendObject,"businessGroup")){return{found:true,value:extendObject.businessGroup}}return{found:false}}function firstPresent(...values){for(const value of values){if(value!==undefined&&value!==null){return{found:true,value:value}}}return{found:false}}function assertExpectedBusinessGroup(actual,expected){if(expected===undefined)return;const normalizedExpected=normalizeBusinessGroupArgument(expected);if(actual!==normalizedExpected){throw CliErrors.validation("Expectation mismatch at businessGroup",`Expected ${JSON.stringify(normalizedExpected)}, actual ${JSON.stringify(actual)}`)}}function buildBackendPlan(appCode,dataset,businessGroup){if(dataset.sourceType==="DB_TABLE"){if(!dataset.dbTableSelector||dataset.dbTableSelector.dbLinkId===null||!dataset.dbTableSelector.tableName){
|
|
9
|
+
throw CliErrors.validation("DB_TABLE dataset requires dbtableConfig.dbId and tableName.","Run dataset detail and complete database analysis before updating the business group.")}return{kind:"db-table",method:"POST",path:DB_TABLE_BACKEND_PATH,payload:{dbLinkId:dataset.dbTableSelector.dbLinkId,tableName:dataset.dbTableSelector.tableName,businessGroup:businessGroup}}}return{kind:"metadata",method:"POST",path:METADATA_BACKEND_PATH,payload:{appCode:appCode,datasetCode:dataset.code,businessGroup:businessGroup}}}function normalizeBusinessGroup(value){if(value===undefined||value===null)return"";return String(value).trim()}function normalizeBusinessGroupArgument(value){const normalized=normalizeBusinessGroup(value);return normalized===UNGROUPED_BUSINESS_GROUP?"":normalized}function displayBusinessGroup(value){return value||UNGROUPED_BUSINESS_GROUP}function asPlainObject(value){if(!value||typeof value!=="object"||Array.isArray(value))return{};return value}function firstString(...values){
|
|
10
|
+
for(const value of values){if(typeof value==="string"&&value.trim())return value.trim();if(typeof value==="number"&&Number.isFinite(value)){return String(value)}}return undefined}function firstNumber(...values){for(const value of values){if(typeof value==="number"&&Number.isFinite(value))return value;if(typeof value==="string"&&value.trim()&&Number.isFinite(Number(value))){return Number(value)}}return null}function trim(value){return String(value||"").trim()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{getErBusinessGroupSummary}from"../../core/api-client.js";export const datasetBusinessGroups={service:"dataset",command:"business-groups",description:"List DB_TABLE dataset business groups for a database connection; does not include METADATA",risk:"read",flags:[{name:"dbid",type:"number",required:true,description:"Database connection ID (dblink id from db list)"},APPCODE_FLAG_OPTIONAL],async execute(ctx){const dblinkId=ctx.num("dbid");const summary=await getErBusinessGroupSummary(ctx.appCode,dblinkId);const groups=summary.groups.map(group=>({...group,businessGroup:group.businessGroup.trim()||"ungrouped"}));return{ok:true,data:{...summary,groups:groups,scope:"DB_TABLE"},message:`Found ${groups.length} business group(s) for database connection ${dblinkId}`}}};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";export const RUNTIME_DATA_ACCESS_COMMANDS={cli:"lovrabet",filter:"lovrabet data filter --code <datasetCode> --params '<json>' --format compress",getOne:"lovrabet data getOne --code <datasetCode> --params '{\"id\":123}' --format compress"};export const RUNTIME_DATA_ACCESS_SUMMARY="Use lovrabet data filter/getOne for real runtime records.";function valueToString(value){return value==null?"":String(value).trim()}function getDatasetCode(dataset){return valueToString(dataset.code??dataset.modelCode??dataset.dataset?.datasetCode)}function getDatasetName(dataset){return valueToString(dataset.name??dataset.dataset?.datasetName)||"unknown"}function getDatasetSource(dataset){return valueToString(dataset.source??dataset.dataset?.sourceType).toUpperCase()}function getDbtableConfig(dataset){const dbtable=dataset.dbtableConfig??dataset.dbtable;return dbtable&&typeof dbtable==="object"?dbtable:{}}export function isDbTableBackedDataset(dataset){
|
|
2
|
+
const source=getDatasetSource(dataset);if(source==="METADATA")return false;const dbtable=getDbtableConfig(dataset);const dbId=dbtable.dbId??dbtable.id;const tableName=valueToString(dbtable.tableName??dataset.tableName??dataset.dataset?.tableName);return dbId!==undefined&&dbId!==null&&tableName.length>0}export function filterDbTableBackedDatasets(datasets){return datasets.filter(dataset=>isDbTableBackedDataset(dataset))}export function buildDbTableBackedRequirementMessage(dataset,assetName="SQL schema validation"){const source=getDatasetSource(dataset)||"UNKNOWN";const name=getDatasetName(dataset);const code=getDatasetCode(dataset);const suffix=code?` (${code})`:""
|
|
3
|
+
;return[`The current dataset "${name}"${suffix} is ${source} and has no DB_TABLE data-source context for ${assetName}.`,"Reason: schema introspection and custom SQL require source=DB_TABLE, dbtableConfig.dbId, dbtableConfig.tableName, and a database connection context.","Upgrade or migrate this dataset to a DB_TABLE dataset, then continue with the new dataset code.",`To inspect real runtime rows, switch to lovrabet CLI: ${RUNTIME_DATA_ACCESS_COMMANDS.filter}; ${RUNTIME_DATA_ACCESS_COMMANDS.getOne}.`].join(" ")}export function assertDatasetIsDbTableBacked(dataset,assetName){if(!isDbTableBackedDataset(dataset)){throw CliErrors.validation(buildDbTableBackedRequirementMessage(dataset,assetName))}}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{createCrossDbRelation}from"../../core/api-client.js";import{CROSS_RELATION_FROM_DATASET_FLAG,CROSS_RELATION_FROM_COLUMN_FLAG,CROSS_RELATION_TO_DATASET_FLAG,CROSS_RELATION_TO_COLUMN_FLAG,CROSS_RELATION_LABEL_FLAG,CROSS_RELATION_CARDINALITY_FLAG,APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{executeCrossRelation,previewCrossRelation,validateCrossRelation}from"../../commands/dataset/cross-relation-shared.js";export const datasetCrossRelationCreate={service:"dataset",command:"cross-relation-create",description:"Create a logical relation between DB_TABLE datasets in different database connections",risk:"write",strictFlags:true,requiresCookieAuth:true,structuredErrors:true,flags:[CROSS_RELATION_FROM_DATASET_FLAG,CROSS_RELATION_FROM_COLUMN_FLAG,CROSS_RELATION_TO_DATASET_FLAG,CROSS_RELATION_TO_COLUMN_FLAG,CROSS_RELATION_LABEL_FLAG,CROSS_RELATION_CARDINALITY_FLAG,APPCODE_FLAG_OPTIONAL],validate:async ctx=>validateCrossRelation(ctx,"create"),
|
|
2
|
+
dryRun:ctx=>previewCrossRelation(ctx,"create"),execute:ctx=>executeCrossRelation(ctx,"create",createCrossDbRelation)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{deleteCrossDbRelation}from"../../core/api-client.js";import{CROSS_RELATION_FROM_DATASET_FLAG,CROSS_RELATION_FROM_COLUMN_FLAG,CROSS_RELATION_DBLINK_FLAG,APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{executeCrossRelation,previewCrossRelation,validateCrossRelation}from"../../commands/dataset/cross-relation-shared.js";export const datasetCrossRelationDelete={service:"dataset",command:"cross-relation-delete",description:"Delete the single cross-database relation matching a source dataset and field",risk:"high-risk-write",strictFlags:true,requiresCookieAuth:true,structuredErrors:true,flags:[CROSS_RELATION_FROM_DATASET_FLAG,CROSS_RELATION_FROM_COLUMN_FLAG,CROSS_RELATION_DBLINK_FLAG,APPCODE_FLAG_OPTIONAL],validate:async ctx=>validateCrossRelation(ctx,"delete"),dryRun:ctx=>previewCrossRelation(ctx,"delete"),execute:ctx=>executeCrossRelation(ctx,"delete",deleteCrossDbRelation)};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{queryCrossDbRelations}from"../../core/api-client.js";import{APPCODE_FLAG_OPTIONAL,CROSS_RELATION_DBLINK_FLAG,CROSS_RELATION_FROM_DATASET_FLAG,CROSS_RELATION_FROM_COLUMN_FLAG}from"../../commands/common/flags.js";import{projectCrossRelation,resolveCrossRelationQuery,validateCrossRelation}from"../../commands/dataset/cross-relation-shared.js";export const datasetCrossRelationList={service:"dataset",command:"cross-relation-list",description:"List outgoing cross-database relations by source dataset or database connection",risk:"read",strictFlags:true,requiresCookieAuth:true,structuredErrors:true,flags:[{...CROSS_RELATION_FROM_DATASET_FLAG,required:false},CROSS_RELATION_DBLINK_FLAG,{...CROSS_RELATION_FROM_COLUMN_FLAG,required:false},APPCODE_FLAG_OPTIONAL],validate:async ctx=>validateCrossRelation(ctx,"list"),async execute(ctx){const query=await resolveCrossRelationQuery(ctx);const rows=await queryCrossDbRelations(query);return{ok:true,data:{appCode:ctx.appCode,selector:query,
|
|
2
|
+
total:rows.length,relations:rows.map(projectCrossRelation)},message:`Cross-database relations: ${rows.length} relation(s)`}}};
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
const a72_0x5bffc1=a72_0x5595;(function(_0x19a38d,_0x31693f){const _0xc0890e=a72_0x5595,_0x2daef1=_0x19a38d();while(!![]){try{const _0x23f06a=-parseInt(_0xc0890e(0xb3))/0x1+-parseInt(_0xc0890e(0xb8))/0x2+parseInt(_0xc0890e(0xc2))/0x3*(parseInt(_0xc0890e(0xa5))/0x4)+-parseInt(_0xc0890e(0xc5))/0x5+parseInt(_0xc0890e(0xae))/0x6*(-parseInt(_0xc0890e(0x99))/0x7)+parseInt(_0xc0890e(0xd4))/0x8+parseInt(_0xc0890e(0xb7))/0x9;if(_0x23f06a===_0x31693f)break;else _0x2daef1['push'](_0x2daef1['shift']());}catch(_0x29d85f){_0x2daef1['push'](_0x2daef1['shift']());}}}(a72_0x1fbc,0x9617a));import{getDatasetDetail,queryCrossDbRelations}from'../../core/api-client.js';import{CROSS_DB_RELATION_PATHS}from'../../core/cross-db-relation.js';function a72_0x5595(_0x15c16b,_0x173dc4){_0x15c16b=_0x15c16b-0x96;const _0x1fbc61=a72_0x1fbc();let _0x5595cb=_0x1fbc61[_0x15c16b];return _0x5595cb;}import{CliError,CliErrors}from'../../errors.js';import{CROSS_RELATION_CARDINALITY_FLAG}from'../../commands/common/flags.js';function required(_0xc96da0,_0x4cfdb1){const _0x5009a4=a72_0x5595,_0x53088f=_0xc96da0[_0x5009a4(0xcd)](_0x4cfdb1)[_0x5009a4(0x96)]();if(!_0x53088f)throw CliErrors[_0x5009a4(0xc4)](_0x4cfdb1);return _0x53088f;}function explicitDblink(_0x19c656){const _0x33e346=a72_0x5595,_0xf9c506=_0x19c656[_0x33e346(0xb0)](_0x33e346(0x9b));if(_0xf9c506===undefined||_0xf9c506===null)return undefined;const _0x1038e0=Number(_0xf9c506);if(!Number[_0x33e346(0xb1)](_0x1038e0)||_0x1038e0<=0x0)throw CliErrors['validation'](_0x33e346(0xa7));return _0x1038e0;}export function validateCrossRelation(_0x38ce77,_0x2e8f14){const _0x42dd80=a72_0x5595,_0x478482=explicitDblink(_0x38ce77);if(_0x2e8f14==='list'){if(!_0x38ce77['str'](_0x42dd80(0xad))['trim']()&&_0x478482===undefined)throw CliErrors['validation'](_0x42dd80(0xbe));return;}required(_0x38ce77,'from-datasetcode'),required(_0x38ce77,'from-column');if(_0x2e8f14!==_0x42dd80(0xa3)){required(_0x38ce77,_0x42dd80(0xc1)),required(_0x38ce77,_0x42dd80(0x97));const _0x3c4d85=_0x38ce77[_0x42dd80(0xcd)]('cardinality')['trim']();if(_0x3c4d85&&!CROSS_RELATION_CARDINALITY_FLAG['enum'][_0x42dd80(0xbf)](_0x3c4d85))throw CliErrors[_0x42dd80(0xa2)](_0x42dd80(0xea));}}function a72_0x1fbc(){const _0x393749=['label_inherited','\x20write\x20was\x20not\x20verified.','validation','delete','datasetCode','4472828JQSNVi','update','--from-dblink-id\x20must\x20be\x20a\x20positive\x20safe\x20integer.','table','Would\x20','length','map','\x20verified.','from-datasetcode','5348298GHWjrP','string','flag','isSafeInteger','dataset','1068320IJmtrl','\x20must\x20be\x20a\x20DB_TABLE\x20dataset.','The\x20target\x20display\x20field\x20is\x20inherited.\x20When\x20changing\x20the\x20target\x20dataset,\x20provide\x20--to-label-column\x20explicitly.','relationType','9734409vDUZHK','1086rplvaF','toField','filter','data','Cross-database\x20relations\x20require\x20different\x20source\x20and\x20target\x20database\x20connections.','extend','Provide\x20--from-datasetcode\x20or\x20--from-dblink-id.','includes','toTableName','to-datasetcode','3sSfYWS','some','flagMissing','2784475mdktpc','\x20is\x20missing\x20its\x20database\x20connection\x20or\x20physical\x20table\x20name.','DB_TABLE','expectedLabel','\x20a\x20cross-database\x20relation\x20for\x20','query','unconfirmed','fromDblinkId','str','to-label-column','fromTableName','Run\x20dataset\x20cross-relation-list\x20to\x20inspect\x20the\x20candidates.\x20This\x20command\x20accepts\x20only\x20a\x20source\x20dataset\x20and\x20field.','matched','appCode','parse','7456888tJiqvL','toDatasetCode','dbId','create','Dataset\x20','dblinkId','expectedCardinality','from','toLowerCase','cardinality','refTableLabelName','tableName','fromField','from-column','dbtable','\x20has\x20invalid\x20storage\x20configuration.','catch','apiError','Multiple\x20cross-database\x20relations\x20match\x20this\x20source\x20field;\x20update/delete\x20cannot\x20select\x20one\x20target.','source','storageProfile','fromDatasetName','Invalid\x20--cardinality.','toDblinkId','POST','relationId','trim','to-column','Cross-database\x20relation\x20not\x20found\x20for\x20this\x20source\x20dataset\x20and\x20field.','7HmRzwJ','fromDatasetCode','from-dblink-id','before','sourceType','body','--from-dblink-id\x20does\x20not\x20match\x20the\x20source\x20dataset\x20connection.'];a72_0x1fbc=function(){return _0x393749;};return a72_0x1fbc();}async function resolveEndpoint(_0x2bee35){const _0x38b2b0=a72_0x5595,_0x11d511=await getDatasetDetail(_0x2bee35),_0x1f352d=_0x11d511?.[_0x38b2b0(0xb2)]??{};if((_0x11d511?.[_0x38b2b0(0xe7)]??_0x1f352d[_0x38b2b0(0x9d)])!==_0x38b2b0(0xc7))throw CliErrors[_0x38b2b0(0xa2)](_0x38b2b0(0xd8)+_0x2bee35+_0x38b2b0(0xb4));const _0x13af82=_0x11d511['dbtableConfig']??_0x11d511[_0x38b2b0(0xe2)]??{};let _0x289e66=_0x11d511['extend']??_0x1f352d[_0x38b2b0(0xbd)]??{};if(typeof _0x289e66===_0x38b2b0(0xaf))try{_0x289e66=_0x289e66[_0x38b2b0(0x96)]()?JSON[_0x38b2b0(0xd3)](_0x289e66):{};}catch{throw CliErrors[_0x38b2b0(0xa2)]('Dataset\x20'+_0x2bee35+_0x38b2b0(0xe3));}const _0x31f170=Number(_0x289e66?.['storageProfile']?.[_0x38b2b0(0xd6)]??_0x11d511['storageProfile']?.[_0x38b2b0(0xd6)]??_0x1f352d[_0x38b2b0(0xe8)]?.[_0x38b2b0(0xd6)]??_0x13af82[_0x38b2b0(0xd6)]??_0x1f352d[_0x38b2b0(0xd6)]??_0x11d511[_0x38b2b0(0xd6)]),_0xaaedfe=String(_0x11d511[_0x38b2b0(0xdf)]??_0x1f352d[_0x38b2b0(0xdf)]??_0x13af82[_0x38b2b0(0xdf)]??'')[_0x38b2b0(0x96)]();if(!Number[_0x38b2b0(0xb1)](_0x31f170)||_0x31f170<=0x0||!_0xaaedfe)throw CliErrors[_0x38b2b0(0xa2)](_0x38b2b0(0xd8)+_0x2bee35+_0x38b2b0(0xc6));return{'datasetCode':_0x2bee35,'dblinkId':_0x31f170,'table':_0xaaedfe};}export async function resolveCrossRelationQuery(_0x1125e8){const _0x24f0bb=a72_0x5595,_0x441642=_0x1125e8[_0x24f0bb(0xcd)](_0x24f0bb(0xad))['trim'](),_0x253ae1=explicitDblink(_0x1125e8),_0x83dcaa=_0x441642?await resolveEndpoint(_0x441642):undefined;if(_0x83dcaa&&_0x253ae1!==undefined&&_0x83dcaa[_0x24f0bb(0xd9)]!==_0x253ae1)throw CliErrors[_0x24f0bb(0xa2)](_0x24f0bb(0x9f));const _0x5b7f7e=_0x83dcaa?.[_0x24f0bb(0xd9)]??_0x253ae1;if(_0x5b7f7e===undefined)throw CliErrors['validation']('Provide\x20--from-datasetcode\x20or\x20--from-dblink-id.');return{'appCode':_0x1125e8['appCode'],'fromDblinkId':_0x5b7f7e,..._0x441642?{'fromDatasetCode':_0x441642}:{},..._0x1125e8[_0x24f0bb(0xcd)]('from-column')[_0x24f0bb(0x96)]()?{'fromField':_0x1125e8[_0x24f0bb(0xcd)](_0x24f0bb(0xe1))['trim']()}:{}};}export function projectCrossRelation(_0x1bf011){const _0x55651b=a72_0x5595;return{'relationId':_0x1bf011[_0x55651b(0xed)],'from':{'source':_0x55651b(0xc7),'datasetCode':_0x1bf011[_0x55651b(0x9a)],'datasetName':_0x1bf011[_0x55651b(0xe9)],'dblinkId':_0x1bf011[_0x55651b(0xcc)],'table':_0x1bf011['fromTableName'],'field':_0x1bf011[_0x55651b(0xe0)]},'to':{'source':'DB_TABLE','datasetCode':_0x1bf011[_0x55651b(0xd5)],'datasetName':_0x1bf011['toDatasetName'],'dblinkId':_0x1bf011[_0x55651b(0xeb)],'table':_0x1bf011[_0x55651b(0xc0)],'field':_0x1bf011[_0x55651b(0xb9)],'labelField':_0x1bf011[_0x55651b(0xde)]},'relation':{'cardinality':_0x1bf011[_0x55651b(0xdd)],'relationType':_0x1bf011[_0x55651b(0xb6)]}};}function ambiguity(_0x3e311b){const _0x5dc40e=a72_0x5595,_0x4e9344=CliErrors['validation'](_0x5dc40e(0xe6),_0x5dc40e(0xd0));return Object['defineProperty'](_0x4e9344,_0x5dc40e(0xbb),{'value':{'candidates':_0x3e311b[_0x5dc40e(0xab)](projectCrossRelation)}}),_0x4e9344;}const sameName=(_0x2b83ec,_0x157ed5)=>_0x2b83ec[a72_0x5bffc1(0xdc)]()===_0x157ed5[a72_0x5bffc1(0xdc)]();function matchesEndpoint(_0x298c3e,_0x26fc8c,_0x58f6a2,_0x510838,_0x261086){const _0x383386=a72_0x5bffc1;return _0x298c3e[_0x383386(0xcc)]===_0x26fc8c[_0x383386(0xd9)]&&sameName(_0x298c3e[_0x383386(0xcf)],_0x26fc8c[_0x383386(0xa8)])&&sameName(_0x298c3e[_0x383386(0xe0)],_0x58f6a2)&&_0x298c3e[_0x383386(0xeb)]===_0x510838['dblinkId']&&sameName(_0x298c3e['toTableName'],_0x510838['table'])&&sameName(_0x298c3e['toField'],_0x261086);}export async function prepareCrossRelation(_0x210eb1,_0x940c50){const _0x5e4208=a72_0x5bffc1,_0x42a19f=await resolveEndpoint(required(_0x210eb1,'from-datasetcode')),_0x4e1381=explicitDblink(_0x210eb1);if(_0x4e1381!==undefined&&_0x42a19f[_0x5e4208(0xd9)]!==_0x4e1381)throw CliErrors[_0x5e4208(0xa2)](_0x5e4208(0x9f));const _0x13793d={'appCode':_0x210eb1[_0x5e4208(0xd2)],'fromDatasetCode':_0x42a19f[_0x5e4208(0xa4)],'fromField':required(_0x210eb1,'from-column'),..._0x4e1381!==undefined?{'fromDblinkId':_0x4e1381}:{}},_0x13d889={'appCode':_0x210eb1['appCode'],'fromDblinkId':_0x42a19f['dblinkId'],'fromDatasetCode':_0x42a19f['datasetCode'],'fromField':_0x13793d[_0x5e4208(0xe0)]},_0x4429d5=await queryCrossDbRelations(_0x13d889);let _0x1b9c49=null;if(_0x940c50!==_0x5e4208(0xd7)){if(_0x4429d5[_0x5e4208(0xaa)]>0x1)throw ambiguity(_0x4429d5);_0x1b9c49=_0x4429d5[0x0]??null;if(!_0x1b9c49)throw CliErrors['validation'](_0x5e4208(0x98));}if(_0x940c50===_0x5e4208(0xa3))return{'operation':_0x940c50,'from':_0x42a19f,'query':_0x13d889,'body':_0x13793d,'before':_0x1b9c49};const _0x266a7d=await resolveEndpoint(required(_0x210eb1,_0x5e4208(0xc1)));if(_0x42a19f['dblinkId']===_0x266a7d[_0x5e4208(0xd9)])throw CliErrors[_0x5e4208(0xa2)](_0x5e4208(0xbc));const _0x60b7e3=_0x210eb1[_0x5e4208(0xcd)](_0x5e4208(0xce))[_0x5e4208(0x96)](),_0x313646=_0x210eb1[_0x5e4208(0xcd)](_0x5e4208(0xdd))[_0x5e4208(0x96)](),_0x354c74={..._0x13793d,'toDatasetCode':_0x266a7d[_0x5e4208(0xa4)],'toField':required(_0x210eb1,'to-column'),..._0x60b7e3?{'refTableLabelName':_0x60b7e3}:{},..._0x313646?{'cardinality':_0x313646}:{}};if(_0x4429d5[_0x5e4208(0xc3)](_0x55c8e6=>_0x55c8e6['relationId']!==_0x1b9c49?.[_0x5e4208(0xed)]&&matchesEndpoint(_0x55c8e6,_0x42a19f,_0x354c74[_0x5e4208(0xe0)],_0x266a7d,_0x354c74[_0x5e4208(0xb9)])))throw CliErrors[_0x5e4208(0xa2)]('Cross-database\x20relation\x20already\x20exists\x20for\x20these\x20source\x20and\x20target\x20endpoints.');return{'operation':_0x940c50,'from':_0x42a19f,'to':_0x266a7d,'query':_0x13d889,'body':_0x354c74,'before':_0x1b9c49,'expectedLabel':_0x60b7e3||_0x1b9c49?.[_0x5e4208(0xde)]||_0x354c74[_0x5e4208(0xb9)],'expectedCardinality':_0x313646||_0x1b9c49?.[_0x5e4208(0xdd)]||null};}function mutationData(_0x2df385,_0x4e0277,_0x22940f){const _0x251fb0=a72_0x5bffc1,{operation:_0x1f58f2,body:_0x3042aa,before:_0x4e8c59}=_0x2df385;return{'operation':_0x1f58f2,'selector':{'appCode':_0x3042aa[_0x251fb0(0xd2)],'from':{'datasetCode':_0x3042aa[_0x251fb0(0x9a)],'field':_0x3042aa[_0x251fb0(0xe0)],'dblinkId':_0x2df385[_0x251fb0(0xdb)][_0x251fb0(0xd9)]}},'before':_0x4e8c59?projectCrossRelation(_0x4e8c59):null,'after':_0x22940f,'dryRun':_0x4e0277,'backend':{'method':_0x251fb0(0xec),'path':CROSS_DB_RELATION_PATHS[_0x1f58f2]},'warnings':_0x1f58f2===_0x251fb0(0xa6)&&!_0x3042aa['refTableLabelName']?[{'code':_0x251fb0(0xa0),'message':_0x251fb0(0xb5)}]:[]};}export async function previewCrossRelation(_0x35573a,_0x44a1f8){const _0x5c1e00=a72_0x5bffc1,_0x5e43a2=await prepareCrossRelation(_0x35573a,_0x44a1f8),_0x7ee611=_0x5e43a2[_0x5c1e00(0x9e)],_0x38b67a=_0x44a1f8===_0x5c1e00(0xa3)?null:{..._0x5e43a2[_0x5c1e00(0x9c)]?{'relationId':_0x5e43a2[_0x5c1e00(0x9c)][_0x5c1e00(0xed)]}:{},'from':{'datasetCode':_0x5e43a2[_0x5c1e00(0xdb)][_0x5c1e00(0xa4)],'dblinkId':_0x5e43a2[_0x5c1e00(0xdb)]['dblinkId'],'table':_0x5e43a2[_0x5c1e00(0xdb)][_0x5c1e00(0xa8)],'field':_0x7ee611[_0x5c1e00(0xe0)]},'to':{'datasetCode':_0x5e43a2['to'][_0x5c1e00(0xa4)],'dblinkId':_0x5e43a2['to'][_0x5c1e00(0xd9)],'table':_0x5e43a2['to']['table'],'field':_0x7ee611['toField'],'labelField':_0x5e43a2[_0x5c1e00(0xc8)]},'relation':{'cardinality':_0x5e43a2[_0x5c1e00(0xda)],'relationType':0x2}};return{...mutationData(_0x5e43a2,!![],null),'after':_0x38b67a,'method':_0x5c1e00(0xec),'url':CROSS_DB_RELATION_PATHS[_0x44a1f8],'body':_0x5e43a2['body'],'description':_0x5c1e00(0xa9)+_0x44a1f8+_0x5c1e00(0xc9)+_0x7ee611['fromDatasetCode']+'.'+_0x7ee611['fromField']};}export async function executeCrossRelation(_0x64bd15,_0x10a4e2,_0x395903){const _0xf76088=a72_0x5bffc1,_0x22bdb5=await prepareCrossRelation(_0x64bd15,_0x10a4e2);try{await _0x395903(_0x22bdb5['body']);}catch(_0x4ec865){if(_0x4ec865 instanceof CliError&&_0x4ec865['message']['includes']('multiple\x20cross-database\x20relations\x20matched')){const _0x5aa51d=await queryCrossDbRelations(_0x22bdb5[_0xf76088(0xca)])[_0xf76088(0xe4)](()=>[]);throw ambiguity(_0x5aa51d);}throw _0x4ec865;}let _0x3d01fb=[],_0x5ed34c,_0x1f9e3d=![];try{_0x3d01fb=await queryCrossDbRelations(_0x22bdb5[_0xf76088(0xca)]);if(_0x10a4e2===_0xf76088(0xa3))_0x1f9e3d=!_0x3d01fb[_0xf76088(0xc3)](_0x50cd51=>_0x50cd51['relationId']===_0x22bdb5['before']['relationId']);else{const _0xb752ab=_0x22bdb5[_0xf76088(0x9e)],_0x24f46d=_0x3d01fb[_0xf76088(0xba)](_0xad24ab=>matchesEndpoint(_0xad24ab,_0x22bdb5[_0xf76088(0xdb)],_0xb752ab['fromField'],_0x22bdb5['to'],_0xb752ab['toField'])&&(_0x10a4e2===_0xf76088(0xd7)||_0xad24ab[_0xf76088(0xed)]===_0x22bdb5[_0xf76088(0x9c)][_0xf76088(0xed)]));_0x5ed34c=_0x24f46d[_0xf76088(0xaa)]===0x1?_0x24f46d[0x0]:undefined,_0x1f9e3d=!!_0x5ed34c&&_0x5ed34c['refTableLabelName']===_0x22bdb5[_0xf76088(0xc8)]&&_0x5ed34c[_0xf76088(0xdd)]===_0x22bdb5['expectedCardinality']&&_0x5ed34c['relationType']===0x2;}}catch{}const _0x37f1fc={...mutationData(_0x22bdb5,![],_0x5ed34c?projectCrossRelation(_0x5ed34c):null),'verification':{'status':_0x1f9e3d?_0xf76088(0xd1):_0xf76088(0xcb),'verified':_0x1f9e3d}};if(!_0x1f9e3d){const _0x545154=CliErrors[_0xf76088(0xe5)]('Cross-database\x20relation\x20'+_0x10a4e2+_0xf76088(0xa1),'The\x20write\x20was\x20accepted,\x20but\x20current\x20state\x20could\x20not\x20be\x20confirmed.\x20Run\x20dataset\x20cross-relation-list\x20before\x20attempting\x20another\x20write.');Object['defineProperty'](_0x545154,_0xf76088(0xbb),{'value':{..._0x37f1fc,'candidates':_0x3d01fb[_0xf76088(0xab)](projectCrossRelation)}});throw _0x545154;}return{'ok':!![],'data':_0x37f1fc,'message':'Cross-database\x20relation\x20'+_0x10a4e2+_0xf76088(0xac)};}
|
|
1
|
+
import{getDatasetDetail,queryCrossDbRelations}from"../../core/api-client.js";import{CROSS_DB_RELATION_PATHS}from"../../core/cross-db-relation.js";import{CliError,CliErrors}from"../../errors.js";import{CROSS_RELATION_CARDINALITY_FLAG}from"../../commands/common/flags.js";function required(ctx,flag){const value=ctx.str(flag).trim();if(!value)throw CliErrors.flagMissing(flag);return value}function explicitDblink(ctx){const raw=ctx.flag("from-dblink-id");if(raw===undefined||raw===null)return undefined;const id=Number(raw);if(!Number.isSafeInteger(id)||id<=0)throw CliErrors.validation("--from-dblink-id must be a positive safe integer.");return id}export function validateCrossRelation(ctx,operation){const id=explicitDblink(ctx);if(operation==="list"){if(!ctx.str("from-datasetcode").trim()&&id===undefined){throw CliErrors.validation("Provide --from-datasetcode or --from-dblink-id.")}return}required(ctx,"from-datasetcode");required(ctx,"from-column");if(operation!=="delete"){
|
|
2
|
+
required(ctx,"to-datasetcode");required(ctx,"to-column");const cardinality=ctx.str("cardinality").trim();if(cardinality&&!CROSS_RELATION_CARDINALITY_FLAG.enum.includes(cardinality)){throw CliErrors.validation("Invalid --cardinality.")}}}async function resolveEndpoint(datasetCode){const detail=await getDatasetDetail(datasetCode);const dataset=detail?.dataset??{};if((detail?.source??dataset.sourceType)!=="DB_TABLE"){throw CliErrors.validation(`Dataset ${datasetCode} must be a DB_TABLE dataset.`)}const dbtable=detail.dbtableConfig??detail.dbtable??{};let extend=detail.extend??dataset.extend??{};if(typeof extend==="string"){try{extend=extend.trim()?JSON.parse(extend):{}}catch{throw CliErrors.validation(`Dataset ${datasetCode} has invalid storage configuration.`)}}const dblinkId=Number(extend?.storageProfile?.dbId??detail.storageProfile?.dbId??dataset.storageProfile?.dbId??dbtable.dbId??dataset.dbId??detail.dbId)
|
|
3
|
+
;const table=String(detail.tableName??dataset.tableName??dbtable.tableName??"").trim();if(!Number.isSafeInteger(dblinkId)||dblinkId<=0||!table){throw CliErrors.validation(`Dataset ${datasetCode} is missing its database connection or physical table name.`)}return{datasetCode:datasetCode,dblinkId:dblinkId,table:table}}export async function resolveCrossRelationQuery(ctx){const code=ctx.str("from-datasetcode").trim();const requestedId=explicitDblink(ctx);const from=code?await resolveEndpoint(code):undefined;if(from&&requestedId!==undefined&&from.dblinkId!==requestedId){throw CliErrors.validation("--from-dblink-id does not match the source dataset connection.")}const id=from?.dblinkId??requestedId;if(id===undefined)throw CliErrors.validation("Provide --from-datasetcode or --from-dblink-id.");return{appCode:ctx.appCode,fromDblinkId:id,...code?{fromDatasetCode:code}:{},...ctx.str("from-column").trim()?{fromField:ctx.str("from-column").trim()}:{}}}export function projectCrossRelation(row){
|
|
4
|
+
return{relationId:row.relationId,from:{source:"DB_TABLE",datasetCode:row.fromDatasetCode,datasetName:row.fromDatasetName,dblinkId:row.fromDblinkId,table:row.fromTableName,field:row.fromField},to:{source:"DB_TABLE",datasetCode:row.toDatasetCode,datasetName:row.toDatasetName,dblinkId:row.toDblinkId,table:row.toTableName,field:row.toField,labelField:row.refTableLabelName},relation:{cardinality:row.cardinality,relationType:row.relationType}}}function ambiguity(candidates){const error=CliErrors.validation("Multiple cross-database relations match this source field; update/delete cannot select one target.","Run dataset cross-relation-list to inspect the candidates. This command accepts only a source dataset and field.");Object.defineProperty(error,"data",{value:{candidates:candidates.map(projectCrossRelation)}});return error}const sameName=(left,right)=>left.toLowerCase()===right.toLowerCase();function matchesEndpoint(row,from,fromField,to,toField){
|
|
5
|
+
return row.fromDblinkId===from.dblinkId&&sameName(row.fromTableName,from.table)&&sameName(row.fromField,fromField)&&row.toDblinkId===to.dblinkId&&sameName(row.toTableName,to.table)&&sameName(row.toField,toField)}export async function prepareCrossRelation(ctx,operation){const from=await resolveEndpoint(required(ctx,"from-datasetcode"));const requestedId=explicitDblink(ctx);if(requestedId!==undefined&&from.dblinkId!==requestedId){throw CliErrors.validation("--from-dblink-id does not match the source dataset connection.")}const source={appCode:ctx.appCode,fromDatasetCode:from.datasetCode,fromField:required(ctx,"from-column"),...requestedId!==undefined?{fromDblinkId:requestedId}:{}};const query={appCode:ctx.appCode,fromDblinkId:from.dblinkId,fromDatasetCode:from.datasetCode,fromField:source.fromField};const candidates=await queryCrossDbRelations(query);let before=null;if(operation!=="create"){if(candidates.length>1)throw ambiguity(candidates);before=candidates[0]??null
|
|
6
|
+
;if(!before)throw CliErrors.validation("Cross-database relation not found for this source dataset and field.")}if(operation==="delete")return{operation:operation,from:from,query:query,body:source,before:before};const to=await resolveEndpoint(required(ctx,"to-datasetcode"));if(from.dblinkId===to.dblinkId){throw CliErrors.validation("Cross-database relations require different source and target database connections.")}const label=ctx.str("to-label-column").trim();const cardinality=ctx.str("cardinality").trim();const body={...source,toDatasetCode:to.datasetCode,toField:required(ctx,"to-column"),...label?{refTableLabelName:label}:{},...cardinality?{cardinality:cardinality}:{}};if(candidates.some(row=>row.relationId!==before?.relationId&&matchesEndpoint(row,from,body.fromField,to,body.toField))){throw CliErrors.validation("Cross-database relation already exists for these source and target endpoints.")}return{operation:operation,from:from,to:to,query:query,body:body,before:before,
|
|
7
|
+
expectedLabel:label||before?.refTableLabelName||body.toField,expectedCardinality:cardinality||before?.cardinality||null}}function mutationData(prepared,dryRun,after){const{operation:operation,body:body,before:before}=prepared;return{operation:operation,selector:{appCode:body.appCode,from:{datasetCode:body.fromDatasetCode,field:body.fromField,dblinkId:prepared.from.dblinkId}},before:before?projectCrossRelation(before):null,after:after,dryRun:dryRun,backend:{method:"POST",path:CROSS_DB_RELATION_PATHS[operation]},warnings:operation==="update"&&!body.refTableLabelName?[{code:"label_inherited",message:"The target display field is inherited. When changing the target dataset, provide --to-label-column explicitly."}]:[]}}export async function previewCrossRelation(ctx,operation){const prepared=await prepareCrossRelation(ctx,operation);const body=prepared.body;const after=operation==="delete"?null:{...prepared.before?{relationId:prepared.before.relationId}:{},from:{
|
|
8
|
+
datasetCode:prepared.from.datasetCode,dblinkId:prepared.from.dblinkId,table:prepared.from.table,field:body.fromField},to:{datasetCode:prepared.to.datasetCode,dblinkId:prepared.to.dblinkId,table:prepared.to.table,field:body.toField,labelField:prepared.expectedLabel},relation:{cardinality:prepared.expectedCardinality,relationType:2}};return{...mutationData(prepared,true,null),after:after,method:"POST",url:CROSS_DB_RELATION_PATHS[operation],body:prepared.body,description:`Would ${operation} a cross-database relation for ${body.fromDatasetCode}.${body.fromField}`}}export async function executeCrossRelation(ctx,operation,write){const prepared=await prepareCrossRelation(ctx,operation);try{await write(prepared.body)}catch(error){if(error instanceof CliError&&error.message.includes("multiple cross-database relations matched")){const candidates=await queryCrossDbRelations(prepared.query).catch(()=>[]);throw ambiguity(candidates)}throw error}let rows=[];let after;let verified=false;try{
|
|
9
|
+
rows=await queryCrossDbRelations(prepared.query);if(operation==="delete"){verified=!rows.some(row=>row.relationId===prepared.before.relationId)}else{const body=prepared.body;const matches=rows.filter(row=>matchesEndpoint(row,prepared.from,body.fromField,prepared.to,body.toField)&&(operation==="create"||row.relationId===prepared.before.relationId));after=matches.length===1?matches[0]:undefined;verified=!!after&&after.refTableLabelName===prepared.expectedLabel&&after.cardinality===prepared.expectedCardinality&&after.relationType===2}}catch{}const data={...mutationData(prepared,false,after?projectCrossRelation(after):null),verification:{status:verified?"matched":"unconfirmed",verified:verified}};if(!verified){const error=CliErrors.apiError(`Cross-database relation ${operation} write was not verified.`,"The write was accepted, but current state could not be confirmed. Run dataset cross-relation-list before attempting another write.");Object.defineProperty(error,"data",{value:{...data,
|
|
10
|
+
candidates:rows.map(projectCrossRelation)}});throw error}return{ok:true,data:data,message:`Cross-database relation ${operation} verified.`}}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{updateCrossDbRelation}from"../../core/api-client.js";import{CROSS_RELATION_FROM_DATASET_FLAG,CROSS_RELATION_FROM_COLUMN_FLAG,CROSS_RELATION_TO_DATASET_FLAG,CROSS_RELATION_TO_COLUMN_FLAG,CROSS_RELATION_LABEL_FLAG,CROSS_RELATION_CARDINALITY_FLAG,CROSS_RELATION_DBLINK_FLAG,APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{executeCrossRelation,previewCrossRelation,validateCrossRelation}from"../../commands/dataset/cross-relation-shared.js";export const datasetCrossRelationUpdate={service:"dataset",command:"cross-relation-update",description:"Update the target or properties of the single cross-database relation matching a source dataset and field",risk:"write",strictFlags:true,requiresCookieAuth:true,structuredErrors:true,flags:[CROSS_RELATION_FROM_DATASET_FLAG,CROSS_RELATION_FROM_COLUMN_FLAG,CROSS_RELATION_TO_DATASET_FLAG,CROSS_RELATION_TO_COLUMN_FLAG,CROSS_RELATION_LABEL_FLAG,CROSS_RELATION_CARDINALITY_FLAG,CROSS_RELATION_DBLINK_FLAG,APPCODE_FLAG_OPTIONAL],
|
|
2
|
+
validate:async ctx=>validateCrossRelation(ctx,"update"),dryRun:ctx=>previewCrossRelation(ctx,"update"),execute:ctx=>executeCrossRelation(ctx,"update",updateCrossDbRelation)};
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import{deleteDataset,getDatasetDetail,listDatasets}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";import{APPCODE_FLAG_OPTIONAL,CODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";const DATASET_ID_FLAG={name:"id",type:"number",description:"Dataset id"};const DBID_FLAG={name:"dbid",type:"number",description:"Delete all datasets under this database connection id"};const CONFIRM_FLAG={name:"confirm",type:"boolean",description:"Required to execute dataset deletion"};const CASCADE_FLAG={name:"cascade",type:"boolean",description:"Also delete related pages and menus; requires explicit --confirm"};const EXPECTED_COUNT_FLAG={name:"expected-count",type:"number",description:"Abort unless the matched dataset count equals this value"};export const datasetDelete={service:"dataset",command:"delete",description:"Delete dataset metadata by id/code or all datasets under a db id",risk:"high-risk-write",
|
|
2
|
+
flags:[DATASET_ID_FLAG,CODE_FLAG_OPTIONAL,DBID_FLAG,CASCADE_FLAG,CONFIRM_FLAG,EXPECTED_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async validate(ctx){const id=ctx.num("id");const code=ctx.str("code");const dbId=ctx.num("dbid");const selectors=[id>0,Boolean(code),dbId>0].filter(Boolean);if(selectors.length===0){throw CliErrors.validation("One of --id, --code, or --dbid is required.")}if(selectors.length>1){throw CliErrors.validation("Use only one of --id, --code, or --dbid.")}},async dryRun(ctx){const targets=await resolveTargets(ctx);const cascade=ctx.bool("cascade");return{method:"POST",url:`/smartapi/dataset/delete?cascade=${cascade?"true":"false"}`,body:{count:targets.length,cascade:cascade,datasets:targets},
|
|
3
|
+
description:cascade?`Would delete ${targets.length} dataset(s) and their listed related pages/menus. Restore each Dataset first, then restore pages explicitly when needed.`:`Would safely delete ${targets.length} dataset(s) without cascading to pages. The server blocks a Dataset that still has related pages.`}},async execute(ctx){if(!ctx.bool("confirm")){throw CliErrors.validation("--confirm is required to delete datasets.","Run with --dry-run first, then add --confirm when the target list is correct.")}const targets=await resolveTargets(ctx);const cascade=ctx.bool("cascade");const deleted=[];const failed=[];for(const target of targets){try{await deleteDataset(target.id,cascade);deleted.push(target)}catch(error){failed.push({...target,error:error instanceof Error?error.message:String(error)})}}if(failed.length>0){const pageRestoreCommands=buildPageRestoreCommands(ctx.appCode,cascade?deleted:[]);return{ok:false,data:{requested:targets.length,cascade:cascade,deletedCount:deleted.length,
|
|
4
|
+
failedCount:failed.length,deleted:deleted,failed:failed,pageRestoreCommands:pageRestoreCommands},message:`Deleted ${deleted.length}/${targets.length} dataset(s); ${failed.length} failed`}}return{ok:true,data:{requested:targets.length,cascade:cascade,deletedCount:deleted.length,deleted:deleted,pageRestoreCommands:buildPageRestoreCommands(ctx.appCode,cascade?deleted:[])},message:`Deleted ${deleted.length} dataset(s)`}}};async function resolveTargets(ctx){const id=ctx.num("id");const code=ctx.str("code");const dbId=ctx.num("dbid");let datasets;if(code){datasets=await listDatasets(ctx.appCode,{code:code});datasets=datasets.filter(item=>item.code===code)}else{datasets=await listDatasets(ctx.appCode);if(id>0){datasets=datasets.filter(item=>item.id===id)}if(dbId>0){datasets=datasets.filter(item=>item.dbtableConfig?.dbId===dbId)}}const targets=[];for(const dataset of datasets){const detail=await getDatasetDetail(dataset.code)
|
|
5
|
+
;const relatedPages=Array.isArray(detail.relatedPageInfoList)?detail.relatedPageInfoList.filter(page=>page!=null&&typeof page==="object"&&page.deleted!==true):[];targets.push(normalizeTarget(dataset,relatedPages))}if(targets.length===0){const selector=code||(id>0?`id=${id}`:`dbid=${dbId}`);throw CliErrors.validation(`No undeleted dataset found for ${selector}.`)}const expectedCount=ctx.num("expected-count");if(expectedCount>0&&targets.length!==expectedCount){throw CliErrors.validation(`Matched ${targets.length} dataset(s), but --expected-count is ${expectedCount}.`)}return targets}function normalizeTarget(dataset,relatedPages){const db=dataset.dbtableConfig??{};const normalizedPages=relatedPages.map(page=>{if(page==null||typeof page!=="object")return null;const raw=page;const id=Number(raw.id);if(!Number.isInteger(id)||id<=0)return null;const name=raw.title??raw.name;return{id:id,...name?{name:String(name)}:{},...raw.type?{type:String(raw.type)}:{}}}).filter(page=>page!==null);return{
|
|
6
|
+
id:dataset.id,code:dataset.code,name:dataset.name,description:dataset.description,source:dataset.source,dbId:db.dbId,dbName:db.dbName,tableName:db.tableName,relatedPageCount:normalizedPages.length,relatedPages:normalizedPages}}function buildPageRestoreCommands(appCode,targets){const pageIds=new Set;for(const target of targets){for(const page of target.relatedPages)pageIds.add(page.id)}return[...pageIds].map(pageId=>`rabetbase page restore --id ${pageId} --appcode ${appCode}`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{designCommand}from"../../services/dataset-design/commands.js";export const datasetDesignContext=designCommand("context");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{designCommand}from"../../services/dataset-design/commands.js";export const datasetDesignStart=designCommand("start");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{designCommand}from"../../services/dataset-design/commands.js";export const datasetDesignStatus=designCommand("status");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{designCommand}from"../../services/dataset-design/commands.js";export const datasetDesignSyncRetry=designCommand("sync-retry");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{designCommand}from"../../services/dataset-design/commands.js";export const datasetDesignSyncStatus=designCommand("sync-status");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{designCommand}from"../../services/dataset-design/commands.js";export const datasetDesignValidate=designCommand("validate");
|