@lovrabet/rabetbase-cli 2.5.13-beta.1 → 2.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -17
- package/lib/api/api-doc.js +3 -1
- package/lib/api/api-group.js +3 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +8 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +2 -1
- package/lib/api/model-registry-file.js +11 -1
- package/lib/api/model-registry-scaffold.js +2 -1
- package/lib/api/model-source.js +3 -1
- package/lib/auth/auth-server-ui.js +2 -1
- package/lib/auth/auth-server.js +5 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +3 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +5 -1
- package/lib/commands/api/generate.js +4 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +2 -1
- package/lib/commands/api/pull.js +10 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/detail.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +5 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +4 -1
- package/lib/commands/app-config/delete.js +2 -1
- package/lib/commands/app-config/get.js +2 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +2 -1
- package/lib/commands/app-config/set.js +3 -1
- package/lib/commands/app-config/shared.d.ts +9 -2
- package/lib/commands/app-config/shared.js +6 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +11 -1
- package/lib/commands/bff/delete.js +6 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +4 -1
- package/lib/commands/bff/pull.js +22 -1
- package/lib/commands/bff/push.js +16 -1
- package/lib/commands/bff/status.js +3 -1
- package/lib/commands/cli-skill/index.js +2 -1
- package/lib/commands/cli-update.js +7 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +4 -1
- package/lib/commands/common/app-selector.js +4 -1
- package/lib/commands/common/async-task.js +2 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +3 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +2 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +5 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +4 -1
- package/lib/commands/config/shared.js +2 -1
- package/lib/commands/dataset/batch-design.js +9 -1
- package/lib/commands/dataset/business-group-update.js +10 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +3 -1
- package/lib/commands/dataset/cross-relation-create.js +2 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +2 -1
- package/lib/commands/dataset/cross-relation-shared.js +10 -1
- package/lib/commands/dataset/cross-relation-update.js +2 -1
- package/lib/commands/dataset/delete.js +6 -1
- package/lib/commands/dataset/design-context.js +1 -1
- package/lib/commands/dataset/design-start.js +1 -1
- package/lib/commands/dataset/design-status.js +1 -1
- package/lib/commands/dataset/design-sync-retry.js +1 -1
- package/lib/commands/dataset/design-sync-status.js +1 -1
- package/lib/commands/dataset/design-validate.js +1 -1
- package/lib/commands/dataset/detail.js +5 -1
- package/lib/commands/dataset/extend-update.js +7 -1
- package/lib/commands/dataset/field-restore.js +7 -1
- package/lib/commands/dataset/field-update.js +7 -1
- package/lib/commands/dataset/generate.js +19 -1
- package/lib/commands/dataset/index.js +3 -1
- package/lib/commands/dataset/list.js +2 -1
- package/lib/commands/dataset/operations.js +2 -1
- package/lib/commands/dataset/relation-audit.js +7 -1
- package/lib/commands/dataset/relation-create.js +3 -1
- package/lib/commands/dataset/relation-delete.js +3 -1
- package/lib/commands/dataset/relation-shared.js +21 -1
- package/lib/commands/dataset/relation-update.js +4 -1
- package/lib/commands/dataset/relations.js +7 -1
- package/lib/commands/dataset/rename.js +4 -1
- package/lib/commands/dataset/restore.js +7 -1
- package/lib/commands/dataset/user-deleted-field-list.js +3 -1
- package/lib/commands/db/analysis-batching.js +3 -1
- package/lib/commands/db/analyze-batch-plan.js +2 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +3 -1
- package/lib/commands/db/analyze-status.js +6 -1
- package/lib/commands/db/create.js +4 -1
- package/lib/commands/db/cross-db-analysis-shared.js +3 -1
- package/lib/commands/db/cross-db-analyze-latest.js +1 -1
- package/lib/commands/db/cross-db-analyze-start.js +2 -1
- package/lib/commands/db/cross-db-analyze-status.js +1 -1
- package/lib/commands/db/delete.js +3 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +2 -1
- package/lib/commands/db/diff.js +3 -1
- package/lib/commands/db/index.js +2 -1
- package/lib/commands/db/list.js +2 -1
- package/lib/commands/db/shared.js +3 -1
- package/lib/commands/db/table-diff-shared.js +2 -1
- package/lib/commands/db/tables.js +2 -1
- package/lib/commands/db/test.js +2 -1
- package/lib/commands/db/update.js +4 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +3 -1
- package/lib/commands/deployment/sync-jobs.js +2 -1
- package/lib/commands/deployment/sync-status.js +2 -1
- package/lib/commands/doctor.js +12 -1
- package/lib/commands/file/index.js +3 -1
- package/lib/commands/flow/create.js +2 -1
- package/lib/commands/flow/detail.js +3 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +2 -1
- package/lib/commands/flow/page-list.js +2 -1
- package/lib/commands/flow/publish.js +2 -1
- package/lib/commands/flow/runtime-resources-shared.js +3 -1
- package/lib/commands/flow/runtime-role-list.js +2 -1
- package/lib/commands/flow/runtime-role-user-list.js +2 -1
- package/lib/commands/flow/runtime-user-search.js +2 -1
- package/lib/commands/flow/shared.js +6 -1
- package/lib/commands/flow/update.js +4 -1
- package/lib/commands/flow/validate.js +2 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +2 -1
- package/lib/commands/instant-api-policy/publish.js +5 -1
- package/lib/commands/instant-api-policy/pull.js +2 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +5 -1
- package/lib/commands/instant-api-policy/shared.js +5 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/context.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +2 -1
- package/lib/commands/issue/report.js +5 -1
- package/lib/commands/kb/create.js +5 -1
- package/lib/commands/kb/delete.js +5 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/import-api.d.ts +3 -0
- package/lib/commands/kb/import-api.js +1 -0
- package/lib/commands/kb/import-resume.d.ts +2 -0
- package/lib/commands/kb/import-resume.js +2 -0
- package/lib/commands/kb/import-shared.d.ts +69 -0
- package/lib/commands/kb/import-shared.js +9 -0
- package/lib/commands/kb/import-status.d.ts +2 -0
- package/lib/commands/kb/import-status.js +1 -0
- package/lib/commands/kb/import.d.ts +2 -0
- package/lib/commands/kb/import.js +3 -0
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +3 -1
- package/lib/commands/kb/shared.js +9 -1
- package/lib/commands/kb/update.js +7 -1
- package/lib/commands/logs/index.js +2 -1
- package/lib/commands/menu/asset-update.js +8 -1
- package/lib/commands/menu/delete.js +15 -1
- package/lib/commands/menu/external-link-create.js +16 -1
- package/lib/commands/menu/external-link-update.js +10 -1
- package/lib/commands/menu/group-create.js +8 -1
- package/lib/commands/menu/group-update.js +6 -1
- package/lib/commands/menu/index.js +2 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +6 -1
- package/lib/commands/menu/regroup-start.js +11 -1
- package/lib/commands/menu/rename.js +9 -1
- package/lib/commands/menu/shared/compare-table.js +2 -1
- package/lib/commands/menu/shared/delete-plan.js +13 -1
- package/lib/commands/menu/shared/facts.js +5 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +4 -1
- package/lib/commands/menu/shared/local-pages.js +5 -1
- package/lib/commands/menu/shared/logic.js +3 -1
- package/lib/commands/menu/shared/mutations.js +9 -1
- package/lib/commands/menu/shared/path.js +1 -1
- package/lib/commands/menu/shared/service.js +4 -1
- package/lib/commands/menu/shared/subapp-assets.js +4 -1
- package/lib/commands/menu/shared/sync-core.js +7 -1
- package/lib/commands/menu/shared/types.js +1 -1
- package/lib/commands/menu/shared/update-core.js +8 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.js +1 -1
- package/lib/commands/menu/subapp-assets-update.js +7 -1
- package/lib/commands/menu/sync.js +7 -1
- package/lib/commands/menu/visibility-update.js +13 -1
- package/lib/commands/metric/contract.d.ts +8 -0
- package/lib/commands/metric/contract.js +5 -0
- package/lib/commands/metric/definition.d.ts +43 -0
- package/lib/commands/metric/definition.js +4 -0
- package/lib/commands/metric/delete.d.ts +2 -0
- package/lib/commands/metric/delete.js +3 -0
- package/lib/commands/metric/detail.d.ts +2 -0
- package/lib/commands/metric/detail.js +1 -0
- package/lib/commands/metric/example.d.ts +2 -0
- package/lib/commands/metric/example.js +1 -0
- package/lib/commands/metric/index.d.ts +2 -0
- package/lib/commands/metric/index.js +1 -0
- package/lib/commands/metric/list.d.ts +2 -0
- package/lib/commands/metric/list.js +2 -0
- package/lib/commands/metric/publication-diff.d.ts +8 -0
- package/lib/commands/metric/publication-diff.js +1 -0
- package/lib/commands/metric/publish.d.ts +2 -0
- package/lib/commands/metric/publish.js +4 -0
- package/lib/commands/metric/schema.d.ts +2 -0
- package/lib/commands/metric/schema.js +1 -0
- package/lib/commands/metric/shared.d.ts +14 -0
- package/lib/commands/metric/shared.js +2 -0
- package/lib/commands/metric/validate.d.ts +2 -0
- package/lib/commands/metric/validate.js +1 -0
- package/lib/commands/notification/config-create.js +4 -1
- package/lib/commands/notification/config-delete.js +4 -1
- package/lib/commands/notification/config-list.js +2 -1
- package/lib/commands/notification/config-update.js +4 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +18 -1
- package/lib/commands/ocr/index.js +4 -1
- package/lib/commands/page/create.js +6 -1
- package/lib/commands/page/custom/detail.js +2 -1
- package/lib/commands/page/custom/list.js +2 -1
- package/lib/commands/page/custom/publish.js +3 -1
- package/lib/commands/page/custom/shared.js +3 -1
- package/lib/commands/page/custom/syntax.js +2 -1
- package/lib/commands/page/custom/update.js +3 -1
- package/lib/commands/page/data-list-status.js +2 -1
- package/lib/commands/page/generate-start.js +5 -1
- package/lib/commands/page/generate-status.js +4 -1
- package/lib/commands/page/index.js +2 -1
- package/lib/commands/page/pull.js +6 -1
- package/lib/commands/page/push.js +11 -1
- package/lib/commands/page/relation-audit.js +15 -1
- package/lib/commands/page/restore.js +5 -1
- package/lib/commands/page/shared.js +16 -1
- package/lib/commands/page/sync.js +2 -1
- package/lib/commands/project/api-architecture-upgrade.js +11 -1
- package/lib/commands/project/create/enhanced-guided-create.js +2 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +13 -1
- package/lib/commands/project/create/materialize-project-template.js +12 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +5 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +2 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +4 -1
- package/lib/commands/project/upgrade.js +7 -1
- package/lib/commands/registry.js +10 -1
- package/lib/commands/role/delete.js +2 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +2 -1
- package/lib/commands/role/shared.js +8 -1
- package/lib/commands/role/update.js +3 -1
- package/lib/commands/role/user-add.js +2 -1
- package/lib/commands/role/user-remove.js +2 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +7 -1
- package/lib/commands/rule/shared.js +4 -1
- package/lib/commands/run/index.js +5 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +7 -1
- package/lib/commands/sql/delete.js +4 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +2 -1
- package/lib/commands/sql/pull.js +10 -1
- package/lib/commands/sql/push.js +9 -1
- package/lib/commands/sql/shared.js +5 -1
- package/lib/commands/sql/status.js +3 -1
- package/lib/commands/sql/validate.js +5 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +2 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +2 -1
- package/lib/commands/tenant/shared.js +2 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +2 -1
- package/lib/commands/user-account/feishu-bind.js +2 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +7 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +8 -1
- package/lib/config/project-domain-routing.js +3 -1
- package/lib/config/region-config.js +2 -1
- package/lib/config/schema.js +7 -1
- package/lib/constant/cdn.js +2 -1
- package/lib/constant/cli.js +8 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +4 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +7 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +7 -1
- package/lib/context.js +9 -1
- package/lib/core/alias-resolver.js +5 -1
- package/lib/core/api-client.d.ts +14 -7
- package/lib/core/api-client.js +69 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +6 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +9 -1
- package/lib/core/bff/lock.js +2 -1
- package/lib/core/bff/types.js +1 -1
- package/lib/core/bff/utils.js +3 -1
- package/lib/core/cross-db-analysis.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +2 -1
- package/lib/core/flow-config.js +49 -1
- package/lib/core/instant-api-policy/config.js +7 -1
- package/lib/core/instant-api-policy/endpoints.js +1 -1
- package/lib/core/kb-management-client.d.ts +11 -0
- package/lib/core/kb-management-client.js +4 -1
- package/lib/core/kb-search-client.js +3 -1
- package/lib/core/page/file-system.js +2 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +2 -1
- package/lib/core/page/lr-smart-jsx.js +4 -1
- package/lib/core/page/types.js +1 -1
- package/lib/core/sql-index-auditor.js +14 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +3 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +2 -1
- package/lib/core/sql-sync/types.js +1 -1
- package/lib/core/sql-sync/utils.js +2 -1
- package/lib/core/sql-validator.js +15 -1
- package/lib/errors.js +3 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +2 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +2 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +2 -1
- package/lib/framework/runner.js +9 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +2 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +3 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/runtime/confirmation.js +2 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +4 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +2 -1
- package/lib/runtime/types.js +1 -1
- package/lib/services/dataset-design/checkpoint.js +2 -1
- package/lib/services/dataset-design/commands.js +14 -1
- package/lib/services/dataset-design/contract.js +8 -1
- package/lib/skills/builtin-skill.js +8 -1
- package/lib/skills/install-updated-skill.d.ts +8 -0
- package/lib/skills/install-updated-skill.js +3 -0
- package/lib/skills/local-skills-installer.d.ts +2 -0
- package/lib/skills/local-skills-installer.js +1 -0
- package/lib/skills/main.js +2 -1
- package/lib/skills/npx-skills-add.d.ts +6 -6
- package/lib/skills/npx-skills-add.js +5 -1
- package/lib/skills/skill-presence.d.ts +1 -30
- package/lib/skills/skill-presence.js +2 -1
- package/lib/telemetry/cli-command-trace.js +2 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/types/index.js +1 -1
- package/lib/utils/ai_config.js +3 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +5 -1
- package/lib/utils/cli-version-check.js +4 -1
- package/lib/utils/cli-version-policy.js +3 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +3 -1
- package/lib/utils/http-client.js +2 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +3 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +5 -1
- package/lib/utils/update-notice.js +3 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +10 -7
- package/skills/rabetbase/SKILL.md +11 -7
- package/skills/rabetbase/guides/backend-function.md +3 -1
- package/skills/rabetbase/guides/data-api-guidelines.md +1 -1
- package/skills/rabetbase/guides/frontend-development.md +1 -0
- package/skills/rabetbase/guides/metric-development.md +185 -0
- package/skills/rabetbase/references/rabetbase-app-config.md +4 -3
- package/skills/rabetbase/references/rabetbase-cli-skill-install.md +5 -5
- package/skills/rabetbase/references/rabetbase-dataset-design.md +1 -1
- package/skills/rabetbase/references/rabetbase-kb.md +16 -0
- package/skills/rabetbase/references/rabetbase-metric.md +119 -0
- package/skills/rabetbase/references/rabetbase-update.md +7 -5
- package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
- package/skills/rabetbase-dataset-generation/references/workflow.md +1 -1
- package/skills/rabetbase-metrics-generation/SKILL.md +22 -0
- package/skills/rabetbase-metrics-generation/references/verification.md +19 -0
- package/skills/rabetbase-metrics-generation/references/workflow.md +41 -0
- package/skills/rabetbase-metrics-generation/templates/statistics-delivery.md +11 -0
- package/skills/rabetbase-page-generation/SKILL.md +1 -1
- package/skills/rabetbase-page-generation/references/generation.md +1 -1
- package/skills/rabetbase.manifest.json +5 -3
- package/templates/metrics/definition.json +78 -0
- package/templates/metrics/metric-definition.schema.json +136 -0
- package/lib/postinstall.d.ts +0 -3
- package/lib/postinstall.js +0 -1
- package/scripts/postinstall.mjs +0 -24
|
@@ -1 +1 @@
|
|
|
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
|
-
function a65_0x1085(_0x23de39,_0x3d157f){_0x23de39=_0x23de39-0x199;const _0x37bce2=a65_0x37bc();let _0x108529=_0x37bce2[_0x23de39];return _0x108529;}const a65_0x1245c1=a65_0x1085;(function(_0x32333d,_0x16a01e){const _0x4d3d55=a65_0x1085,_0xa9e9dd=_0x32333d();while(!![]){try{const _0x53eafd=parseInt(_0x4d3d55(0x1a9))/0x1+-parseInt(_0x4d3d55(0x1b8))/0x2+-parseInt(_0x4d3d55(0x1fd))/0x3+-parseInt(_0x4d3d55(0x1e4))/0x4+-parseInt(_0x4d3d55(0x1fa))/0x5*(parseInt(_0x4d3d55(0x1ca))/0x6)+-parseInt(_0x4d3d55(0x1dc))/0x7+-parseInt(_0x4d3d55(0x1a1))/0x8*(-parseInt(_0x4d3d55(0x1e5))/0x9);if(_0x53eafd===_0x16a01e)break;else _0xa9e9dd['push'](_0xa9e9dd['shift']());}catch(_0x32de6b){_0xa9e9dd['push'](_0xa9e9dd['shift']());}}}(a65_0x37bc,0x6da3d));import{CliErrors}from'../../errors.js';const LOCAL_KEY=/^[a-z][a-z0-9_]{0,63}$/,SUPPORTED_CARDINALITIES=new Set([a65_0x1245c1(0x1d2),a65_0x1245c1(0x19c)]),SUPPORTED_FIELD_TYPES=new Set([a65_0x1245c1(0x1b2),a65_0x1245c1(0x1aa),'DATETIME','BOOLEAN',a65_0x1245c1(0x201),a65_0x1245c1(0x1c3),a65_0x1245c1(0x1cc),a65_0x1245c1(0x1de),a65_0x1245c1(0x1a7),'UPLOAD']);export function isDatasetBatchDesign(_0x37ec32){const _0x388b8d=a65_0x1245c1;return isObject(_0x37ec32)&&_0x37ec32['kind']===_0x388b8d(0x1f8);}export function validateDatasetBatchDesign(_0x2fe9e2){const _0x29de51=a65_0x1245c1;(!isObject(_0x2fe9e2)||_0x2fe9e2[_0x29de51(0x1ac)]!=='dataset-batch')&&fail(_0x29de51(0x203));_0x2fe9e2[_0x29de51(0x1b7)]!==0x1&&fail(_0x29de51(0x19f));const _0x4713ca=objectArray(_0x2fe9e2[_0x29de51(0x1be)],_0x29de51(0x1be),0x1,0x14),_0x49c105=objectArray(_0x2fe9e2[_0x29de51(0x1b9)],'relations',0x0,0xc8),_0x42ac5f=objectArray(_0x2fe9e2[_0x29de51(0x1bd)],_0x29de51(0x1bd),0x0,0xc8),_0x279ceb=new Set(),_0x1834ea=new Map();for(const [_0x36d238,_0x16ec4d]of _0x4713ca[_0x29de51(0x1e6)]()){const _0x5aa5f3=requiredString(_0x16ec4d[_0x29de51(0x1f1)],_0x29de51(0x1fc)+_0x36d238+_0x29de51(0x1e7));!LOCAL_KEY[_0x29de51(0x1d5)](_0x5aa5f3)&&fail(_0x29de51(0x1fc)+_0x36d238+_0x29de51(0x1f3)+LOCAL_KEY['source']+'.');_0x279ceb[_0x29de51(0x1d6)](_0x5aa5f3)&&fail(_0x29de51(0x1ee));_0x279ceb[_0x29de51(0x19d)](_0x5aa5f3);!isObject(_0x16ec4d['design'])&&fail(_0x29de51(0x1fc)+_0x36d238+_0x29de51(0x1d8));rejectServerDatasetIdentity(_0x16ec4d[_0x29de51(0x1c7)],'datasets['+_0x36d238+'].design');if(!isObject(_0x16ec4d[_0x29de51(0x1c7)][_0x29de51(0x1fb)]))fail(_0x29de51(0x1fc)+_0x36d238+_0x29de51(0x1f6));rejectServerDatasetIdentity(_0x16ec4d[_0x29de51(0x1c7)][_0x29de51(0x1fb)],_0x29de51(0x1fc)+_0x36d238+_0x29de51(0x1a2)),requiredString(_0x16ec4d[_0x29de51(0x1c7)]['dataset'][_0x29de51(0x1dd)],_0x29de51(0x1fc)+_0x36d238+_0x29de51(0x1b1));_0x29de51(0x1b9)in _0x16ec4d['design']&&(!Array[_0x29de51(0x1ab)](_0x16ec4d[_0x29de51(0x1c7)][_0x29de51(0x1b9)])||_0x16ec4d[_0x29de51(0x1c7)][_0x29de51(0x1b9)][_0x29de51(0x19b)]!==0x0)&&fail(_0x29de51(0x1fc)+_0x36d238+'].design.relations\x20must\x20be\x20an\x20empty\x20array;\x20use\x20top-level\x20relations.');const _0x6bfbf3=objectArray(_0x16ec4d[_0x29de51(0x1c7)][_0x29de51(0x200)],_0x29de51(0x1fc)+_0x36d238+_0x29de51(0x1e1),0x1,0xc8),_0x506870=new Map();for(const [_0x467f3a,_0x5369ca]of _0x6bfbf3[_0x29de51(0x1e6)]()){const _0x59a053=fieldName(_0x5369ca);if(!_0x59a053)fail('datasets['+_0x36d238+_0x29de51(0x1ad)+_0x467f3a+_0x29de51(0x1b0));const _0x5ad4b1=_0x59a053[_0x29de51(0x1f0)]();if(_0x506870[_0x29de51(0x1d6)](_0x5ad4b1))fail('Dataset\x20'+_0x5aa5f3+'\x20field\x20names\x20must\x20be\x20unique\x20ignoring\x20case.');const _0x4fb22d=stringValue(_0x5369ca[_0x29de51(0x1a4)]??_0x5369ca[_0x29de51(0x1d0)])['toUpperCase']();if(!SUPPORTED_FIELD_TYPES[_0x29de51(0x1d6)](_0x4fb22d))fail(_0x29de51(0x1fc)+_0x36d238+_0x29de51(0x1ad)+_0x467f3a+_0x29de51(0x19a));_0x506870['set'](_0x5ad4b1,_0x4fb22d),[_0x5369ca[_0x29de51(0x1c5)],_0x5369ca[_0x29de51(0x1fe)],_0x5369ca[_0x29de51(0x1e9)]][_0x29de51(0x1e2)](_0x252f7f=>stringValue(_0x252f7f))&&fail(_0x29de51(0x1fc)+_0x36d238+_0x29de51(0x1ad)+_0x467f3a+']\x20must\x20not\x20contain\x20embedded\x20relation\x20references.');}_0x1834ea[_0x29de51(0x1c6)](_0x5aa5f3,_0x506870);}const _0x57cef1=new Set(),_0x3bc961=new Set();for(const [_0x59317f,_0x4d84c6]of _0x49c105[_0x29de51(0x1e6)]()){const _0x30cd0d=validateRelation(_0x4d84c6,_0x59317f,_0x279ceb,_0x1834ea);if(_0x57cef1[_0x29de51(0x1d6)](_0x30cd0d))fail(_0x29de51(0x1f7));_0x57cef1[_0x29de51(0x19d)](_0x30cd0d);const _0xdc7374=_0x30cd0d[_0x29de51(0x1bf)]('\x00',0x2)['join']('\x00');if(_0x3bc961[_0x29de51(0x1d6)](_0xdc7374))fail(_0x29de51(0x1ce));_0x3bc961[_0x29de51(0x19d)](_0xdc7374);}for(const [_0x344d18,_0x77e4bb]of _0x42ac5f[_0x29de51(0x1e6)]()){requiredString(_0x77e4bb['reason'],'unresolvedRelations['+_0x344d18+_0x29de51(0x205)),validateConfidence(_0x77e4bb[_0x29de51(0x1cb)],_0x29de51(0x1bb)+_0x344d18+'].confidence');}return _0x2fe9e2;}function a65_0x37bc(){const _0x22beec=['toLowerCase','localKey','modelCode','].localKey\x20must\x20match\x20','.reason','fieldCode','].design.dataset\x20must\x20be\x20an\x20object.','Dataset\x20batch\x20relations\x20must\x20be\x20unique.','dataset-batch','string','2580iskAxw','dataset','datasets[','266181zOQiDc','refTableField','expectedLocalKeys','fields','SELECT','datasetCode','Batch\x20--design-file\x20must\x20have\x20kind\x20\x22dataset-batch\x22.','createdDatasets[].localKey','].reason','\x20objects.','].type\x20is\x20not\x20supported.','length','ONE_TO_ONE','add','\x20non-empty\x20strings.','Dataset\x20batch\x20schemaVersion\x20must\x20be\x201.','map','32lwEAkc','].design.dataset','\x20references\x20an\x20unknown\x20dataset\x20localKey.','type','name','.toDatasetKey','ADDRESS','\x20connects\x20incompatible\x20field\x20types.','519645LdTOyL','NUMBER','isArray','kind','].design.fields[','get','metrics',']\x20must\x20have\x20a\x20non-empty\x20name\x20or\x20code.','].design.dataset.datasetName','TEXT','relations[','.confidence','\x20references\x20an\x20unknown\x20field.','\x20must\x20be\x20between\x200\x20and\x201.','schemaVersion','1575730wXrzvn','relations','object','unresolvedRelations[','validation','unresolvedRelations','datasets','split','expectedRelations','createdRelations','toDatasetCode','MULTI_SELECT','.relationType\x20must\x20be\x20\x22lookup\x22.','refTable','set','design','every','.fromDatasetKey','3462NInvmh','confidence','DATE_RANGE','\x20must\x20contain\x20','Each\x20source\x20field\x20may\x20target\x20at\x20most\x20one\x20relation.','.toField','fieldType','keys','MANY_TO_ONE','.cardinality\x20is\x20not\x20supported.','join','test','has','lookup','].design\x20must\x20be\x20an\x20object.','size','reason','code','870660NmQMFO','datasetName','USER','toDatasetKey','fromField','].design.fields','some','\x20is\x20required.','671152OKIgFO','3140847cgmZxC','entries','].localKey','relationType','refTableLabelField','number','cardinality','createdDatasets','toField','Dataset\x20batch\x20localKey\x20values\x20must\x20be\x20unique.','fromDatasetKey'];a65_0x37bc=function(){return _0x22beec;};return a65_0x37bc();}export function reconcileBatchResult(_0x4e5b06){const _0x2a6263=a65_0x1245c1;if(!isObject(_0x4e5b06))return null;try{const _0x1ae0d0=stringArray(_0x4e5b06['expectedLocalKeys'],_0x2a6263(0x1ff),0x1,0x14),_0x1fb884=new Set(_0x1ae0d0);if(_0x1fb884[_0x2a6263(0x1d9)]!==_0x1ae0d0[_0x2a6263(0x19b)]||_0x1ae0d0[_0x2a6263(0x1e2)](_0x3378c1=>!LOCAL_KEY[_0x2a6263(0x1d5)](_0x3378c1)))return null;const _0x2d21b4=objectArray(_0x4e5b06['createdDatasets'],_0x2a6263(0x1ec),0x1,0x14),_0x9c901e=new Map(),_0x55caab=new Set();for(const _0x11d4ed of _0x2d21b4){const _0x1d3942=requiredString(_0x11d4ed[_0x2a6263(0x1f1)],_0x2a6263(0x204)),_0x53ee07=requiredString(_0x11d4ed[_0x2a6263(0x1db)]??_0x11d4ed[_0x2a6263(0x202)],'createdDatasets[].code');if(_0x9c901e[_0x2a6263(0x1d6)](_0x1d3942)||_0x55caab[_0x2a6263(0x1d6)](_0x53ee07))return null;_0x9c901e[_0x2a6263(0x1c6)](_0x1d3942,_0x53ee07),_0x55caab[_0x2a6263(0x19d)](_0x53ee07);}if(!sameSet(_0x1fb884,new Set(_0x9c901e[_0x2a6263(0x1d1)]())))return null;const _0x5f0249=objectArray(_0x4e5b06[_0x2a6263(0x1c0)],_0x2a6263(0x1c0),0x0,0xc8),_0x4e9219=objectArray(_0x4e5b06[_0x2a6263(0x1c1)],_0x2a6263(0x1c1),0x0,0xc8),_0x442d8b=relationTupleSet(_0x5f0249,![],_0x9c901e),_0x1a8712=relationTupleSet(_0x4e9219,!![],_0x9c901e);if(!_0x442d8b||!_0x1a8712||!sameSet(_0x442d8b,_0x1a8712))return null;const _0x117d14=objectArray(_0x4e5b06[_0x2a6263(0x1bd)],_0x2a6263(0x1bd),0x0,0xc8);return{'expectedLocalKeys':_0x1ae0d0,'expectedRelations':_0x5f0249,'createdDatasets':_0x2d21b4,'createdRelations':_0x4e9219,'unresolvedRelations':_0x117d14,...isObject(_0x4e5b06[_0x2a6263(0x1af)])?{'metrics':_0x4e5b06[_0x2a6263(0x1af)]}:{}};}catch{return null;}}function validateRelation(_0x444632,_0x2e40d5,_0x259ad0,_0x45efef){const _0x458588=a65_0x1245c1,_0x12d7a=_0x458588(0x1b3)+_0x2e40d5+']',_0x13218c=requiredString(_0x444632[_0x458588(0x1ef)],_0x12d7a+_0x458588(0x1c9)),_0x25742f=requiredString(_0x444632[_0x458588(0x1df)],_0x12d7a+_0x458588(0x1a6)),_0x83fd40=requiredString(_0x444632[_0x458588(0x1e0)],_0x12d7a+'.fromField')[_0x458588(0x1f0)](),_0x3391d4=requiredString(_0x444632[_0x458588(0x1ed)],_0x12d7a+_0x458588(0x1cf))[_0x458588(0x1f0)]();if(!_0x259ad0[_0x458588(0x1d6)](_0x13218c)||!_0x259ad0['has'](_0x25742f))fail(_0x12d7a+_0x458588(0x1a3));const _0x14ce35=_0x45efef['get'](_0x13218c)?.[_0x458588(0x1ae)](_0x83fd40),_0xf5737b=_0x45efef[_0x458588(0x1ae)](_0x25742f)?.['get'](_0x3391d4);if(_0x14ce35===undefined||_0xf5737b===undefined)fail(_0x12d7a+_0x458588(0x1b5));if(_0x14ce35&&_0xf5737b&&_0x14ce35!==_0xf5737b)fail(_0x12d7a+_0x458588(0x1a8));const _0x211e0f=stringValue(_0x444632[_0x458588(0x1e8)])||_0x458588(0x1d7);if(_0x211e0f!==_0x458588(0x1d7))fail(_0x12d7a+_0x458588(0x1c4));const _0x1603f4=stringValue(_0x444632['cardinality'])||_0x458588(0x1d2);if(!SUPPORTED_CARDINALITIES['has'](_0x1603f4))fail(_0x12d7a+_0x458588(0x1d3));return requiredString(_0x444632[_0x458588(0x1da)],_0x12d7a+_0x458588(0x1f4)),validateConfidence(_0x444632[_0x458588(0x1cb)],_0x12d7a+_0x458588(0x1b4)),tuple(_0x13218c,_0x83fd40,_0x25742f,_0x3391d4,_0x458588(0x1d7),_0x1603f4);}function relationTupleSet(_0x3ec8d2,_0x45c9d8,_0x2e5d65){const _0x459690=a65_0x1245c1,_0x22cf77=new Set();for(const _0x2c8af8 of _0x3ec8d2){const _0x2de418=stringValue(_0x2c8af8[_0x459690(0x1ef)]),_0x25d062=stringValue(_0x2c8af8[_0x459690(0x1df)]),_0x206611=stringValue(_0x2c8af8['fromField'])[_0x459690(0x1f0)](),_0x5a4d80=stringValue(_0x2c8af8[_0x459690(0x1ed)])[_0x459690(0x1f0)](),_0xb87c64=stringValue(_0x2c8af8[_0x459690(0x1e8)]),_0xc54aa7=stringValue(_0x2c8af8[_0x459690(0x1eb)]);if(!_0x2de418||!_0x25d062||!_0x206611||!_0x5a4d80||_0xb87c64!==_0x459690(0x1d7)||!SUPPORTED_CARDINALITIES[_0x459690(0x1d6)](_0xc54aa7))return null;if(!_0x2e5d65[_0x459690(0x1d6)](_0x2de418)||!_0x2e5d65[_0x459690(0x1d6)](_0x25d062))return null;if(_0x45c9d8&&(stringValue(_0x2c8af8['fromDatasetCode'])!==_0x2e5d65[_0x459690(0x1ae)](_0x2de418)||stringValue(_0x2c8af8[_0x459690(0x1c2)])!==_0x2e5d65['get'](_0x25d062)))return null;const _0x2ba9ec=tuple(_0x2de418,_0x206611,_0x25d062,_0x5a4d80,_0xb87c64,_0xc54aa7);if(_0x22cf77['has'](_0x2ba9ec))return null;_0x22cf77[_0x459690(0x19d)](_0x2ba9ec);}return _0x22cf77;}function rejectServerDatasetIdentity(_0x44fdae,_0x4197d2){const _0x34a7cf=a65_0x1245c1;for(const _0x140dcb of['id','datasetId','modelId',_0x34a7cf(0x1db),_0x34a7cf(0x202),_0x34a7cf(0x1f2)]){if(_0x44fdae[_0x140dcb]!==undefined&&_0x44fdae[_0x140dcb]!==null&&_0x44fdae[_0x140dcb]!=='')fail(_0x4197d2+'.'+_0x140dcb+'\x20must\x20not\x20be\x20supplied\x20by\x20the\x20client.');}}function objectArray(_0x5f58bd,_0x1d00c2,_0x5b6b69,_0x325b11){const _0x1627c7=a65_0x1245c1;return(!Array[_0x1627c7(0x1ab)](_0x5f58bd)||_0x5f58bd[_0x1627c7(0x19b)]<_0x5b6b69||_0x5f58bd[_0x1627c7(0x19b)]>_0x325b11||_0x5f58bd[_0x1627c7(0x1e2)](_0x6fa87e=>!isObject(_0x6fa87e)))&&fail(_0x1d00c2+_0x1627c7(0x1cd)+_0x5b6b69+'..'+_0x325b11+_0x1627c7(0x199)),_0x5f58bd;}function stringArray(_0x5cd9a9,_0x19a6e0,_0x35fe1b,_0x14f496){const _0x95ef1e=a65_0x1245c1;return(!Array[_0x95ef1e(0x1ab)](_0x5cd9a9)||_0x5cd9a9['length']<_0x35fe1b||_0x5cd9a9['length']>_0x14f496||_0x5cd9a9[_0x95ef1e(0x1e2)](_0x5ac804=>typeof _0x5ac804!=='string'||!_0x5ac804['trim']()))&&fail(_0x19a6e0+_0x95ef1e(0x1cd)+_0x35fe1b+'..'+_0x14f496+_0x95ef1e(0x19e)),_0x5cd9a9;}function requiredString(_0x18de26,_0x5c6553){const _0x1386bc=a65_0x1245c1,_0x59d025=stringValue(_0x18de26);if(!_0x59d025)fail(_0x5c6553+_0x1386bc(0x1e3));return _0x59d025;}function stringValue(_0x387de2){const _0x1019bd=a65_0x1245c1;return typeof _0x387de2===_0x1019bd(0x1f9)?_0x387de2['trim']():'';}function fieldName(_0x8dcbf2){const _0x5907aa=a65_0x1245c1;return stringValue(_0x8dcbf2['code']??_0x8dcbf2[_0x5907aa(0x1f5)]??_0x8dcbf2[_0x5907aa(0x1a5)]??_0x8dcbf2['fieldName']);}function validateConfidence(_0x9f54be,_0x39993d){const _0x3d33f7=a65_0x1245c1;_0x9f54be!==undefined&&_0x9f54be!==null&&(typeof _0x9f54be!==_0x3d33f7(0x1ea)||!Number['isFinite'](_0x9f54be)||_0x9f54be<0x0||_0x9f54be>0x1)&&fail(_0x39993d+_0x3d33f7(0x1b6));}function tuple(..._0xcadf37){const _0x284a7f=a65_0x1245c1;return _0xcadf37[_0x284a7f(0x1a0)]((_0x190d1a,_0xe53ebb)=>_0xe53ebb===0x1||_0xe53ebb===0x3?_0x190d1a[_0x284a7f(0x1f0)]():_0x190d1a)[_0x284a7f(0x1d4)]('\x00');}function sameSet(_0x1b2220,_0x54fafa){const _0x36f244=a65_0x1245c1;return _0x1b2220['size']===_0x54fafa[_0x36f244(0x1d9)]&&[..._0x1b2220][_0x36f244(0x1c8)](_0x276bea=>_0x54fafa[_0x36f244(0x1d6)](_0x276bea));}function isObject(_0x160686){const _0x1e2312=a65_0x1245c1;return typeof _0x160686===_0x1e2312(0x1ba)&&_0x160686!==null&&!Array['isArray'](_0x160686);}function fail(_0x238cc9){const _0x4da65a=a65_0x1245c1;throw CliErrors[_0x4da65a(0x1bc)](_0x238cc9);}
|
|
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_0x4ce35d=a66_0x4189;(function(_0x335915,_0x20f3ae){const _0x1c95a2=a66_0x4189,_0x188305=_0x335915();while(!![]){try{const _0x26c340=-parseInt(_0x1c95a2(0x15b))/0x1*(parseInt(_0x1c95a2(0x15e))/0x2)+-parseInt(_0x1c95a2(0x13c))/0x3*(parseInt(_0x1c95a2(0x13e))/0x4)+parseInt(_0x1c95a2(0x165))/0x5*(parseInt(_0x1c95a2(0x144))/0x6)+-parseInt(_0x1c95a2(0x15f))/0x7*(-parseInt(_0x1c95a2(0x154))/0x8)+parseInt(_0x1c95a2(0x140))/0x9*(-parseInt(_0x1c95a2(0x12f))/0xa)+parseInt(_0x1c95a2(0x148))/0xb*(parseInt(_0x1c95a2(0x172))/0xc)+parseInt(_0x1c95a2(0x153))/0xd;if(_0x26c340===_0x20f3ae)break;else _0x188305['push'](_0x188305['shift']());}catch(_0x535c42){_0x188305['push'](_0x188305['shift']());}}}(a66_0x1442,0x46b1a));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_0x4ce35d(0x13d),METADATA_BACKEND_PATH='/smartapi/question/er-config/business-group/edit',UNGROUPED_BUSINESS_GROUP=a66_0x4ce35d(0x13a);export async function buildDatasetBusinessGroupUpdateResult({appCode:_0x376d44,input:_0x45d6a0,dryRun:_0x42ef7e}){const _0x5d4e88=a66_0x4ce35d;validateInput(_0x45d6a0);const _0x42d6f3=normalizeBusinessGroupArgument(_0x45d6a0[_0x5d4e88(0x15d)]),_0x5742b4=await getDatasetDetail(_0x45d6a0[_0x5d4e88(0x129)]),_0x35281a=resolveBusinessGroupDataset(_0x5742b4,_0x45d6a0[_0x5d4e88(0x129)]);assertBusinessGroupUpdateSupported(_0x35281a,_0x42d6f3);const _0x2f6bed=loadCurrentBusinessGroup(_0x5742b4,_0x35281a);assertExpectedBusinessGroup(_0x2f6bed,_0x45d6a0[_0x5d4e88(0x134)]);const _0x5ce94a=buildBackendPlan(_0x376d44,_0x35281a,_0x42d6f3),_0x6a375d=_0x2f6bed!==_0x42d6f3;let _0x160dad;if(_0x6a375d&&!_0x42ef7e){_0x5ce94a[_0x5d4e88(0x137)]===_0x5d4e88(0x155)?await updateDbTableBusinessGroup(_0x5ce94a[_0x5d4e88(0x128)]):await updateErBusinessGroup(_0x5ce94a[_0x5d4e88(0x128)]);const _0x11d65b=await getDatasetDetail(_0x35281a['code']),_0xbc330=resolveBusinessGroupDataset(_0x11d65b,_0x35281a[_0x5d4e88(0x129)]),_0x35f452=loadCurrentBusinessGroup(_0x11d65b,_0xbc330);if(_0x35f452!==_0x42d6f3)throw CliErrors['apiError']('Business\x20scenario\x20group\x20update\x20did\x20not\x20match\x20dataset\x20detail\x20readback.',_0x5d4e88(0x16f)+JSON['stringify'](displayBusinessGroup(_0x42d6f3))+_0x5d4e88(0x13f)+JSON['stringify'](displayBusinessGroup(_0x35f452))+'.');_0x160dad={'verified':!![],'status':_0x5d4e88(0x139),'afterReadback':{'businessGroup':displayBusinessGroup(_0x35f452)}};}else!_0x6a375d&&(_0x160dad={'verified':!![],'status':_0x5d4e88(0x16b),'afterReadback':{'businessGroup':displayBusinessGroup(_0x2f6bed)}});const _0x1e5248={'operation':'update','appCode':_0x376d44,'selector':{'code':_0x35281a[_0x5d4e88(0x129)]},'dataset':{'id':_0x35281a['id'],'code':_0x35281a[_0x5d4e88(0x129)],'name':_0x35281a['name'],'sourceType':_0x35281a[_0x5d4e88(0x12c)]},'before':{'businessGroup':displayBusinessGroup(_0x2f6bed)},'after':{'businessGroup':displayBusinessGroup(_0x42d6f3)},'changed':_0x6a375d,'dryRun':_0x42ef7e,'submitted':_0x6a375d&&!_0x42ef7e,'backend':{'method':_0x5ce94a['method'],'path':_0x5ce94a[_0x5d4e88(0x127)],'payload':_0x5ce94a[_0x5d4e88(0x128)]},..._0x160dad?{'verification':_0x160dad}:{},'warnings':[]};return{'ok':!![],'data':_0x1e5248,'message':_0x6a375d?_0x42ef7e?_0x5d4e88(0x171)+_0x35281a[_0x5d4e88(0x129)]:_0x5d4e88(0x15a)+_0x35281a[_0x5d4e88(0x129)]:_0x5d4e88(0x136)+_0x35281a['code']};}export const datasetBusinessGroupUpdate={'service':a66_0x4ce35d(0x132),'command':a66_0x4ce35d(0x14a),'description':a66_0x4ce35d(0x135),'risk':a66_0x4ce35d(0x170),'flags':[CODE_FLAG,{'name':a66_0x4ce35d(0x157),'type':a66_0x4ce35d(0x126),'required':!![],'description':a66_0x4ce35d(0x14b)},{'name':'expect-business-group','type':'string','required':![],'description':a66_0x4ce35d(0x145)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x484492){validateInput(readBusinessGroupUpdateInput(_0x484492));},async 'dryRun'(_0x104c5e){const _0x405dd4=a66_0x4ce35d,_0x50892d=await buildDatasetBusinessGroupUpdateResult({'appCode':_0x104c5e['appCode'],'input':readBusinessGroupUpdateInput(_0x104c5e),'dryRun':!![]});return{'method':_0x50892d['data'][_0x405dd4(0x12b)][_0x405dd4(0x156)],'url':_0x50892d['data'][_0x405dd4(0x12b)][_0x405dd4(0x127)],'body':_0x50892d[_0x405dd4(0x13b)][_0x405dd4(0x12b)][_0x405dd4(0x128)],'description':_0x50892d[_0x405dd4(0x167)],..._0x50892d[_0x405dd4(0x13b)]};},async 'execute'(_0x4cfc17){const _0x221d1d=a66_0x4ce35d;return buildDatasetBusinessGroupUpdateResult({'appCode':_0x4cfc17[_0x221d1d(0x166)],'input':readBusinessGroupUpdateInput(_0x4cfc17),'dryRun':![]});}};function readBusinessGroupUpdateInput(_0x257af0){const _0x5cfb8a=a66_0x4ce35d,_0x205219=_0x257af0[_0x5cfb8a(0x163)](_0x5cfb8a(0x16d));return{'code':trim(_0x257af0[_0x5cfb8a(0x163)](_0x5cfb8a(0x129))),'businessGroup':_0x257af0['str']('business-group'),'expectBusinessGroup':_0x205219===undefined||_0x205219===''?undefined:_0x205219};}function validateInput(_0x4fc49b){const _0x1bf82b=a66_0x4ce35d;if(!trim(_0x4fc49b['code']))throw CliErrors[_0x1bf82b(0x16e)]('--code\x20is\x20required');if(_0x4fc49b[_0x1bf82b(0x15d)]===undefined)throw CliErrors[_0x1bf82b(0x16e)](_0x1bf82b(0x149));if(!trim(_0x4fc49b[_0x1bf82b(0x15d)]))throw CliErrors[_0x1bf82b(0x16e)](_0x1bf82b(0x14d));}function assertBusinessGroupUpdateSupported(_0x36fc9e,_0x1b86c8){const _0x3d24d3=a66_0x4ce35d;if(_0x36fc9e[_0x3d24d3(0x12c)]===_0x3d24d3(0x162)&&!_0x1b86c8)throw CliErrors[_0x3d24d3(0x16e)](_0x3d24d3(0x152));}function a66_0x4189(_0x3849fe,_0x32a1f0){_0x3849fe=_0x3849fe-0x125;const _0x144241=a66_0x1442();let _0x41892d=_0x144241[_0x3849fe];return _0x41892d;}function resolveBusinessGroupDataset(_0x31b463,_0xb014d1){const _0x208d81=a66_0x4ce35d,_0x2d0dcc=asPlainObject(_0x31b463[_0x208d81(0x132)]),_0x451904=asPlainObject(_0x31b463[_0x208d81(0x133)]),_0x157bff=resolveSourceType(_0x31b463,_0x2d0dcc,_0x451904),_0x2d1db3=firstString(_0x31b463['modelCode'],_0x31b463[_0x208d81(0x129)],_0x2d0dcc[_0x208d81(0x143)],_0xb014d1)||_0xb014d1;return{'id':firstNumber(_0x31b463[_0x208d81(0x138)],_0x31b463['id'],_0x2d0dcc['datasetId'])??firstString(_0x31b463['modelId'],_0x31b463['id'],_0x2d0dcc[_0x208d81(0x173)])??null,'code':_0x2d1db3,'name':firstString(_0x31b463[_0x208d81(0x14f)],_0x2d0dcc['datasetName'],_0x2d0dcc['name'])||null,'sourceType':_0x157bff,'dbTableSelector':_0x157bff===_0x208d81(0x162)?{'dbLinkId':firstNumber(_0x451904[_0x208d81(0x169)]),'tableName':firstString(_0x451904[_0x208d81(0x161)])||null}:null};}function resolveSourceType(_0x2c316e,_0x488fd1,_0x2021b1){const _0x44b154=a66_0x4ce35d,_0x53ca0c=firstString(_0x2c316e[_0x44b154(0x146)],_0x2c316e[_0x44b154(0x12c)],_0x488fd1['source'],_0x488fd1['sourceType'])?.[_0x44b154(0x160)]()[_0x44b154(0x142)]();if(_0x53ca0c===_0x44b154(0x162)||_0x53ca0c===_0x44b154(0x151))return _0x53ca0c;if(Object[_0x44b154(0x12a)](_0x2021b1)[_0x44b154(0x147)]>0x0)return _0x44b154(0x162);throw CliErrors[_0x44b154(0x16e)](_0x44b154(0x158));}function a66_0x1442(){const _0x40ba61=['string','path','payload','code','keys','backend','sourceType','extend','dbLinkId','20QQjnNG','isArray','call','dataset','dbtableConfig','expectBusinessGroup','Update\x20business\x20scenario\x20group','No\x20changes\x20for\x20business\x20scenario\x20group\x20on\x20dataset\x20','kind','modelId','matched','ungrouped','data','1728897uiXyNm','/smartapi/dblink/updateTableBusinessGroup','4NXzGUI',',\x20actual\x20','490977YcazSc','stringify','toUpperCase','datasetCode','171372yPbWtn','Expected\x20current\x20business\x20scenario\x20group;\x20use\x20ungrouped\x20to\x20expect\x20no\x20group;\x20mismatch\x20aborts\x20without\x20writing','source','length','6611DivdaE','--business-group\x20is\x20required','business-group-update','Business\x20scenario\x20group\x20(not\x20technical):\x20use\x20<scenario>,\x20<domain>---<scenario>\x20when\x20needed;\x20METADATA\x20accepts\x20ungrouped\x20to\x20clear\x20it','dbTableSelector','--business-group\x20must\x20not\x20be\x20blank','prototype','name','isFinite','METADATA','Clearing\x20business\x20scenario\x20groups\x20is\x20not\x20supported\x20for\x20DB_TABLE\x20datasets.','3376087ScNWxK','95200rKnUXv','db-table','method','business-group','Dataset\x20sourceType\x20is\x20required\x20and\x20must\x20be\x20DB_TABLE\x20or\x20METADATA.','POST','Updated\x20business\x20scenario\x20group\x20for\x20dataset\x20','1IcQfqJ','value','businessGroup','940926OTvUyn','273ExJeOH','trim','tableName','DB_TABLE','str','found','45iGreRw','appCode','message','Run\x20dataset\x20detail\x20and\x20complete\x20database\x20analysis\x20before\x20updating\x20the\x20business\x20group.','dbId','metadata','unchanged','object','expect-business-group','validation','Expected\x20','write','Dry-run:\x20business\x20scenario\x20group\x20would\x20change\x20for\x20dataset\x20','9276gOaPOF','datasetId','Expectation\x20mismatch\x20at\x20businessGroup','hasOwnProperty'];a66_0x1442=function(){return _0x40ba61;};return a66_0x1442();}function loadCurrentBusinessGroup(_0x568aa7,_0x8ce6d6){const _0x625b20=a66_0x4ce35d,_0x47faf5=readBusinessGroupFromDatasetDetail(_0x568aa7,_0x8ce6d6[_0x625b20(0x12c)]);if(_0x47faf5[_0x625b20(0x164)])return normalizeBusinessGroup(_0x47faf5[_0x625b20(0x15c)]);return'';}function readBusinessGroupFromDatasetDetail(_0x4b06ed,_0x502609){const _0x32aa1b=a66_0x4ce35d,_0x14bd2f=asPlainObject(_0x4b06ed[_0x32aa1b(0x132)]),_0x585829=firstPresent(_0x4b06ed['businessGroup']);if(_0x585829['found'])return _0x585829;const _0x5f3a29=firstPresent(_0x14bd2f[_0x32aa1b(0x15d)]);if(_0x5f3a29['found'])return _0x5f3a29;if(_0x502609==='DB_TABLE')return{'found':![]};const _0xf7f6ab=readBusinessGroupFromExtend(_0x4b06ed['extend']);if(_0xf7f6ab['found'])return _0xf7f6ab;return readBusinessGroupFromExtend(_0x14bd2f[_0x32aa1b(0x12d)]);}function readBusinessGroupFromExtend(_0x10673a){const _0x3dc9ae=a66_0x4ce35d;if(_0x10673a===undefined||_0x10673a===null||_0x10673a==='')return{'found':![]};if(typeof _0x10673a===_0x3dc9ae(0x126))try{const _0x5552fd=JSON['parse'](_0x10673a);return readBusinessGroupFromExtend(_0x5552fd);}catch{return{'found':![]};}const _0x5a02b5=asPlainObject(_0x10673a);if(Object[_0x3dc9ae(0x14e)][_0x3dc9ae(0x125)][_0x3dc9ae(0x131)](_0x5a02b5,_0x3dc9ae(0x15d)))return{'found':!![],'value':_0x5a02b5[_0x3dc9ae(0x15d)]};return{'found':![]};}function firstPresent(..._0x226c9d){for(const _0x58c391 of _0x226c9d){if(_0x58c391!==undefined&&_0x58c391!==null)return{'found':!![],'value':_0x58c391};}return{'found':![]};}function assertExpectedBusinessGroup(_0xf44ab4,_0x3e075c){const _0x817d02=a66_0x4ce35d;if(_0x3e075c===undefined)return;const _0x2760d0=normalizeBusinessGroupArgument(_0x3e075c);if(_0xf44ab4!==_0x2760d0)throw CliErrors[_0x817d02(0x16e)](_0x817d02(0x174),_0x817d02(0x16f)+JSON[_0x817d02(0x141)](_0x2760d0)+',\x20actual\x20'+JSON[_0x817d02(0x141)](_0xf44ab4));}function buildBackendPlan(_0x435407,_0x34f332,_0x43882d){const _0x45a817=a66_0x4ce35d;if(_0x34f332['sourceType']===_0x45a817(0x162)){if(!_0x34f332['dbTableSelector']||_0x34f332[_0x45a817(0x14c)][_0x45a817(0x12e)]===null||!_0x34f332['dbTableSelector'][_0x45a817(0x161)])throw CliErrors[_0x45a817(0x16e)]('DB_TABLE\x20dataset\x20requires\x20dbtableConfig.dbId\x20and\x20tableName.',_0x45a817(0x168));return{'kind':'db-table','method':'POST','path':DB_TABLE_BACKEND_PATH,'payload':{'dbLinkId':_0x34f332[_0x45a817(0x14c)][_0x45a817(0x12e)],'tableName':_0x34f332[_0x45a817(0x14c)][_0x45a817(0x161)],'businessGroup':_0x43882d}};}return{'kind':_0x45a817(0x16a),'method':_0x45a817(0x159),'path':METADATA_BACKEND_PATH,'payload':{'appCode':_0x435407,'datasetCode':_0x34f332[_0x45a817(0x129)],'businessGroup':_0x43882d}};}function normalizeBusinessGroup(_0x5a5491){if(_0x5a5491===undefined||_0x5a5491===null)return'';return String(_0x5a5491)['trim']();}function normalizeBusinessGroupArgument(_0x27710b){const _0x2864f3=normalizeBusinessGroup(_0x27710b);return _0x2864f3===UNGROUPED_BUSINESS_GROUP?'':_0x2864f3;}function displayBusinessGroup(_0x256c7d){return _0x256c7d||UNGROUPED_BUSINESS_GROUP;}function asPlainObject(_0x37f58c){const _0x26551b=a66_0x4ce35d;if(!_0x37f58c||typeof _0x37f58c!==_0x26551b(0x16c)||Array[_0x26551b(0x130)](_0x37f58c))return{};return _0x37f58c;}function firstString(..._0x3cf6ce){const _0x2f11cf=a66_0x4ce35d;for(const _0x3405a1 of _0x3cf6ce){if(typeof _0x3405a1==='string'&&_0x3405a1[_0x2f11cf(0x160)]())return _0x3405a1[_0x2f11cf(0x160)]();if(typeof _0x3405a1==='number'&&Number[_0x2f11cf(0x150)](_0x3405a1))return String(_0x3405a1);}return undefined;}function firstNumber(..._0x4dc0d9){const _0xc56664=a66_0x4ce35d;for(const _0x21617a of _0x4dc0d9){if(typeof _0x21617a==='number'&&Number['isFinite'](_0x21617a))return _0x21617a;if(typeof _0x21617a===_0xc56664(0x126)&&_0x21617a[_0xc56664(0x160)]()&&Number['isFinite'](Number(_0x21617a)))return Number(_0x21617a);}return null;}function trim(_0x40a114){const _0x43146e=a66_0x4ce35d;return String(_0x40a114||'')[_0x43146e(0x160)]();}
|
|
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_0x318449=a72_0x24e8;(function(_0x35f1e4,_0x17a211){const _0x41cddf=a72_0x24e8,_0x2f0c7a=_0x35f1e4();while(!![]){try{const _0x5917d2=-parseInt(_0x41cddf(0x15a))/0x1+-parseInt(_0x41cddf(0x162))/0x2*(parseInt(_0x41cddf(0x148))/0x3)+parseInt(_0x41cddf(0x16a))/0x4*(-parseInt(_0x41cddf(0x160))/0x5)+-parseInt(_0x41cddf(0x15b))/0x6+-parseInt(_0x41cddf(0x16f))/0x7*(-parseInt(_0x41cddf(0x15f))/0x8)+-parseInt(_0x41cddf(0x193))/0x9*(-parseInt(_0x41cddf(0x169))/0xa)+parseInt(_0x41cddf(0x14e))/0xb;if(_0x5917d2===_0x17a211)break;else _0x2f0c7a['push'](_0x2f0c7a['shift']());}catch(_0x487812){_0x2f0c7a['push'](_0x2f0c7a['shift']());}}}(a72_0x2e2a,0x256cf));function a72_0x2e2a(){const _0x3ce2e5=['body','defineProperty','\x20must\x20be\x20a\x20DB_TABLE\x20dataset.','fromDblinkId','to-column','DB_TABLE','Would\x20','fromField','datasetCode','Invalid\x20--cardinality.','data','to-datasetcode','from-dblink-id','sourceType','multiple\x20cross-database\x20relations\x20matched','message','extend','storageProfile','dblinkId','relationType','relationId','\x20write\x20was\x20not\x20verified.','Provide\x20--from-datasetcode\x20or\x20--from-dblink-id.','parse','fromTableName','Dataset\x20','cardinality','from','Cross-database\x20relations\x20require\x20different\x20source\x20and\x20target\x20database\x20connections.','POST','Cross-database\x20relation\x20not\x20found\x20for\x20this\x20source\x20dataset\x20and\x20field.','45aBLYQn','toTableName','toDblinkId','\x20has\x20invalid\x20storage\x20configuration.','create','toDatasetCode','\x20a\x20cross-database\x20relation\x20for\x20','str','expectedCardinality','1362RETyIn','table','Cross-database\x20relation\x20already\x20exists\x20for\x20these\x20source\x20and\x20target\x20endpoints.','tableName','Run\x20dataset\x20cross-relation-list\x20to\x20inspect\x20the\x20candidates.\x20This\x20command\x20accepts\x20only\x20a\x20source\x20dataset\x20and\x20field.','--from-dblink-id\x20does\x20not\x20match\x20the\x20source\x20dataset\x20connection.','7373861dERNju','The\x20write\x20was\x20accepted,\x20but\x20current\x20state\x20could\x20not\x20be\x20confirmed.\x20Run\x20dataset\x20cross-relation-list\x20before\x20attempting\x20another\x20write.','dbtableConfig','\x20verified.','toField','toDatasetName','dbId','appCode','catch','dbtable','isSafeInteger','trim','305750bowQsP','1576614HnclsR','some','Multiple\x20cross-database\x20relations\x20match\x20this\x20source\x20field;\x20update/delete\x20cannot\x20select\x20one\x20target.','before','33432Cucqdn','309775hvwope','from-column','662IUZBbv','query','refTableLabelName','Cross-database\x20relation\x20','from-datasetcode','filter','validation','82950Werzuu','8nvtCgF','map','delete','toLowerCase','unconfirmed','476wHcPMr','fromDatasetName','apiError','fromDatasetCode','includes'];a72_0x2e2a=function(){return _0x3ce2e5;};return a72_0x2e2a();}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(_0x319237,_0x117919){const _0x236f06=a72_0x24e8,_0x54960a=_0x319237[_0x236f06(0x19a)](_0x117919)[_0x236f06(0x159)]();if(!_0x54960a)throw CliErrors['flagMissing'](_0x117919);return _0x54960a;}function explicitDblink(_0x4d1c93){const _0x45fbc4=a72_0x24e8,_0x2d345d=_0x4d1c93['flag'](_0x45fbc4(0x180));if(_0x2d345d===undefined||_0x2d345d===null)return undefined;const _0x57e0d4=Number(_0x2d345d);if(!Number[_0x45fbc4(0x158)](_0x57e0d4)||_0x57e0d4<=0x0)throw CliErrors['validation']('--from-dblink-id\x20must\x20be\x20a\x20positive\x20safe\x20integer.');return _0x57e0d4;}export function validateCrossRelation(_0x515552,_0x1b498e){const _0x42798e=a72_0x24e8,_0x541139=explicitDblink(_0x515552);if(_0x1b498e==='list'){if(!_0x515552[_0x42798e(0x19a)](_0x42798e(0x166))[_0x42798e(0x159)]()&&_0x541139===undefined)throw CliErrors[_0x42798e(0x168)](_0x42798e(0x18a));return;}required(_0x515552,'from-datasetcode'),required(_0x515552,_0x42798e(0x161));if(_0x1b498e!==_0x42798e(0x16c)){required(_0x515552,_0x42798e(0x17f)),required(_0x515552,_0x42798e(0x178));const _0x4fbced=_0x515552['str']('cardinality')[_0x42798e(0x159)]();if(_0x4fbced&&!CROSS_RELATION_CARDINALITY_FLAG['enum']['includes'](_0x4fbced))throw CliErrors['validation'](_0x42798e(0x17d));}}async function resolveEndpoint(_0x459b4c){const _0x269244=a72_0x24e8,_0x27c58e=await getDatasetDetail(_0x459b4c),_0x47aeab=_0x27c58e?.['dataset']??{};if((_0x27c58e?.['source']??_0x47aeab[_0x269244(0x181)])!==_0x269244(0x179))throw CliErrors[_0x269244(0x168)](_0x269244(0x18d)+_0x459b4c+_0x269244(0x176));const _0x50f949=_0x27c58e[_0x269244(0x150)]??_0x27c58e[_0x269244(0x157)]??{};let _0x47e8d2=_0x27c58e[_0x269244(0x184)]??_0x47aeab[_0x269244(0x184)]??{};if(typeof _0x47e8d2==='string')try{_0x47e8d2=_0x47e8d2['trim']()?JSON[_0x269244(0x18b)](_0x47e8d2):{};}catch{throw CliErrors[_0x269244(0x168)](_0x269244(0x18d)+_0x459b4c+_0x269244(0x196));}const _0xc81e79=Number(_0x47e8d2?.[_0x269244(0x185)]?.[_0x269244(0x154)]??_0x27c58e[_0x269244(0x185)]?.[_0x269244(0x154)]??_0x47aeab[_0x269244(0x185)]?.[_0x269244(0x154)]??_0x50f949[_0x269244(0x154)]??_0x47aeab[_0x269244(0x154)]??_0x27c58e['dbId']),_0x1df2dd=String(_0x27c58e[_0x269244(0x14b)]??_0x47aeab['tableName']??_0x50f949[_0x269244(0x14b)]??'')[_0x269244(0x159)]();if(!Number[_0x269244(0x158)](_0xc81e79)||_0xc81e79<=0x0||!_0x1df2dd)throw CliErrors[_0x269244(0x168)](_0x269244(0x18d)+_0x459b4c+'\x20is\x20missing\x20its\x20database\x20connection\x20or\x20physical\x20table\x20name.');return{'datasetCode':_0x459b4c,'dblinkId':_0xc81e79,'table':_0x1df2dd};}export async function resolveCrossRelationQuery(_0x18d644){const _0x545a8a=a72_0x24e8,_0xc764f4=_0x18d644[_0x545a8a(0x19a)]('from-datasetcode')['trim'](),_0x1156b9=explicitDblink(_0x18d644),_0x3714a6=_0xc764f4?await resolveEndpoint(_0xc764f4):undefined;if(_0x3714a6&&_0x1156b9!==undefined&&_0x3714a6[_0x545a8a(0x186)]!==_0x1156b9)throw CliErrors[_0x545a8a(0x168)]('--from-dblink-id\x20does\x20not\x20match\x20the\x20source\x20dataset\x20connection.');const _0x34842a=_0x3714a6?.[_0x545a8a(0x186)]??_0x1156b9;if(_0x34842a===undefined)throw CliErrors['validation']('Provide\x20--from-datasetcode\x20or\x20--from-dblink-id.');return{'appCode':_0x18d644['appCode'],'fromDblinkId':_0x34842a,..._0xc764f4?{'fromDatasetCode':_0xc764f4}:{},..._0x18d644['str']('from-column')[_0x545a8a(0x159)]()?{'fromField':_0x18d644[_0x545a8a(0x19a)](_0x545a8a(0x161))[_0x545a8a(0x159)]()}:{}};}export function projectCrossRelation(_0x59e9df){const _0x283908=a72_0x24e8;return{'relationId':_0x59e9df['relationId'],'from':{'source':_0x283908(0x179),'datasetCode':_0x59e9df[_0x283908(0x172)],'datasetName':_0x59e9df[_0x283908(0x170)],'dblinkId':_0x59e9df[_0x283908(0x177)],'table':_0x59e9df['fromTableName'],'field':_0x59e9df['fromField']},'to':{'source':'DB_TABLE','datasetCode':_0x59e9df[_0x283908(0x198)],'datasetName':_0x59e9df[_0x283908(0x153)],'dblinkId':_0x59e9df[_0x283908(0x195)],'table':_0x59e9df[_0x283908(0x194)],'field':_0x59e9df['toField'],'labelField':_0x59e9df[_0x283908(0x164)]},'relation':{'cardinality':_0x59e9df['cardinality'],'relationType':_0x59e9df[_0x283908(0x187)]}};}function ambiguity(_0x46b37b){const _0x2e3e51=a72_0x24e8,_0x49892a=CliErrors[_0x2e3e51(0x168)](_0x2e3e51(0x15d),_0x2e3e51(0x14c));return Object[_0x2e3e51(0x175)](_0x49892a,_0x2e3e51(0x17e),{'value':{'candidates':_0x46b37b['map'](projectCrossRelation)}}),_0x49892a;}const sameName=(_0x2609ae,_0x2c559e)=>_0x2609ae[a72_0x318449(0x16d)]()===_0x2c559e[a72_0x318449(0x16d)]();function matchesEndpoint(_0x5869a7,_0x3a42c6,_0x24f18b,_0x5a0ed6,_0x4986e3){const _0x21b958=a72_0x318449;return _0x5869a7[_0x21b958(0x177)]===_0x3a42c6[_0x21b958(0x186)]&&sameName(_0x5869a7[_0x21b958(0x18c)],_0x3a42c6[_0x21b958(0x149)])&&sameName(_0x5869a7[_0x21b958(0x17b)],_0x24f18b)&&_0x5869a7[_0x21b958(0x195)]===_0x5a0ed6[_0x21b958(0x186)]&&sameName(_0x5869a7['toTableName'],_0x5a0ed6[_0x21b958(0x149)])&&sameName(_0x5869a7[_0x21b958(0x152)],_0x4986e3);}export async function prepareCrossRelation(_0xe541c3,_0x4d3f18){const _0x13952d=a72_0x318449,_0x2071e7=await resolveEndpoint(required(_0xe541c3,_0x13952d(0x166))),_0x4bcd75=explicitDblink(_0xe541c3);if(_0x4bcd75!==undefined&&_0x2071e7['dblinkId']!==_0x4bcd75)throw CliErrors[_0x13952d(0x168)](_0x13952d(0x14d));const _0xfbff94={'appCode':_0xe541c3[_0x13952d(0x155)],'fromDatasetCode':_0x2071e7[_0x13952d(0x17c)],'fromField':required(_0xe541c3,_0x13952d(0x161)),..._0x4bcd75!==undefined?{'fromDblinkId':_0x4bcd75}:{}},_0x23e818={'appCode':_0xe541c3[_0x13952d(0x155)],'fromDblinkId':_0x2071e7[_0x13952d(0x186)],'fromDatasetCode':_0x2071e7[_0x13952d(0x17c)],'fromField':_0xfbff94[_0x13952d(0x17b)]},_0x4fdd84=await queryCrossDbRelations(_0x23e818);let _0x9cef95=null;if(_0x4d3f18!==_0x13952d(0x197)){if(_0x4fdd84['length']>0x1)throw ambiguity(_0x4fdd84);_0x9cef95=_0x4fdd84[0x0]??null;if(!_0x9cef95)throw CliErrors[_0x13952d(0x168)](_0x13952d(0x192));}if(_0x4d3f18===_0x13952d(0x16c))return{'operation':_0x4d3f18,'from':_0x2071e7,'query':_0x23e818,'body':_0xfbff94,'before':_0x9cef95};const _0x20cd31=await resolveEndpoint(required(_0xe541c3,_0x13952d(0x17f)));if(_0x2071e7[_0x13952d(0x186)]===_0x20cd31[_0x13952d(0x186)])throw CliErrors[_0x13952d(0x168)](_0x13952d(0x190));const _0x456673=_0xe541c3['str']('to-label-column')[_0x13952d(0x159)](),_0x659046=_0xe541c3[_0x13952d(0x19a)](_0x13952d(0x18e))[_0x13952d(0x159)](),_0x5ad663={..._0xfbff94,'toDatasetCode':_0x20cd31[_0x13952d(0x17c)],'toField':required(_0xe541c3,'to-column'),..._0x456673?{'refTableLabelName':_0x456673}:{},..._0x659046?{'cardinality':_0x659046}:{}};if(_0x4fdd84['some'](_0x56f96e=>_0x56f96e[_0x13952d(0x188)]!==_0x9cef95?.[_0x13952d(0x188)]&&matchesEndpoint(_0x56f96e,_0x2071e7,_0x5ad663[_0x13952d(0x17b)],_0x20cd31,_0x5ad663['toField'])))throw CliErrors[_0x13952d(0x168)](_0x13952d(0x14a));return{'operation':_0x4d3f18,'from':_0x2071e7,'to':_0x20cd31,'query':_0x23e818,'body':_0x5ad663,'before':_0x9cef95,'expectedLabel':_0x456673||_0x9cef95?.[_0x13952d(0x164)]||_0x5ad663['toField'],'expectedCardinality':_0x659046||_0x9cef95?.[_0x13952d(0x18e)]||null};}function mutationData(_0x401e4b,_0x49608a,_0x14e394){const _0x120b0f=a72_0x318449,{operation:_0x2b80a3,body:_0x59f852,before:_0x2804e9}=_0x401e4b;return{'operation':_0x2b80a3,'selector':{'appCode':_0x59f852[_0x120b0f(0x155)],'from':{'datasetCode':_0x59f852['fromDatasetCode'],'field':_0x59f852[_0x120b0f(0x17b)],'dblinkId':_0x401e4b[_0x120b0f(0x18f)]['dblinkId']}},'before':_0x2804e9?projectCrossRelation(_0x2804e9):null,'after':_0x14e394,'dryRun':_0x49608a,'backend':{'method':_0x120b0f(0x191),'path':CROSS_DB_RELATION_PATHS[_0x2b80a3]},'warnings':_0x2b80a3==='update'&&!_0x59f852[_0x120b0f(0x164)]?[{'code':'label_inherited','message':'The\x20target\x20display\x20field\x20is\x20inherited.\x20When\x20changing\x20the\x20target\x20dataset,\x20provide\x20--to-label-column\x20explicitly.'}]:[]};}function a72_0x24e8(_0xcae479,_0xd3412c){_0xcae479=_0xcae479-0x148;const _0x2e2a38=a72_0x2e2a();let _0x24e858=_0x2e2a38[_0xcae479];return _0x24e858;}export async function previewCrossRelation(_0x4f2a93,_0x1c7ab1){const _0x53e749=a72_0x318449,_0x2364d8=await prepareCrossRelation(_0x4f2a93,_0x1c7ab1),_0x5a5f7b=_0x2364d8[_0x53e749(0x174)],_0x49c239=_0x1c7ab1===_0x53e749(0x16c)?null:{..._0x2364d8[_0x53e749(0x15e)]?{'relationId':_0x2364d8['before']['relationId']}:{},'from':{'datasetCode':_0x2364d8[_0x53e749(0x18f)][_0x53e749(0x17c)],'dblinkId':_0x2364d8['from'][_0x53e749(0x186)],'table':_0x2364d8['from'][_0x53e749(0x149)],'field':_0x5a5f7b[_0x53e749(0x17b)]},'to':{'datasetCode':_0x2364d8['to']['datasetCode'],'dblinkId':_0x2364d8['to'][_0x53e749(0x186)],'table':_0x2364d8['to'][_0x53e749(0x149)],'field':_0x5a5f7b['toField'],'labelField':_0x2364d8['expectedLabel']},'relation':{'cardinality':_0x2364d8['expectedCardinality'],'relationType':0x2}};return{...mutationData(_0x2364d8,!![],null),'after':_0x49c239,'method':_0x53e749(0x191),'url':CROSS_DB_RELATION_PATHS[_0x1c7ab1],'body':_0x2364d8[_0x53e749(0x174)],'description':_0x53e749(0x17a)+_0x1c7ab1+_0x53e749(0x199)+_0x5a5f7b[_0x53e749(0x172)]+'.'+_0x5a5f7b['fromField']};}export async function executeCrossRelation(_0x45d807,_0x1614d8,_0x450e0f){const _0x1c27e6=a72_0x318449,_0x4564ed=await prepareCrossRelation(_0x45d807,_0x1614d8);try{await _0x450e0f(_0x4564ed['body']);}catch(_0x171981){if(_0x171981 instanceof CliError&&_0x171981[_0x1c27e6(0x183)][_0x1c27e6(0x173)](_0x1c27e6(0x182))){const _0x3cf2e5=await queryCrossDbRelations(_0x4564ed[_0x1c27e6(0x163)])[_0x1c27e6(0x156)](()=>[]);throw ambiguity(_0x3cf2e5);}throw _0x171981;}let _0x45904b=[],_0xcd8a66,_0xb053cf=![];try{_0x45904b=await queryCrossDbRelations(_0x4564ed[_0x1c27e6(0x163)]);if(_0x1614d8===_0x1c27e6(0x16c))_0xb053cf=!_0x45904b[_0x1c27e6(0x15c)](_0x360296=>_0x360296[_0x1c27e6(0x188)]===_0x4564ed['before'][_0x1c27e6(0x188)]);else{const _0x5a7422=_0x4564ed[_0x1c27e6(0x174)],_0x9cfa79=_0x45904b[_0x1c27e6(0x167)](_0x3d9303=>matchesEndpoint(_0x3d9303,_0x4564ed['from'],_0x5a7422[_0x1c27e6(0x17b)],_0x4564ed['to'],_0x5a7422['toField'])&&(_0x1614d8===_0x1c27e6(0x197)||_0x3d9303[_0x1c27e6(0x188)]===_0x4564ed[_0x1c27e6(0x15e)][_0x1c27e6(0x188)]));_0xcd8a66=_0x9cfa79['length']===0x1?_0x9cfa79[0x0]:undefined,_0xb053cf=!!_0xcd8a66&&_0xcd8a66['refTableLabelName']===_0x4564ed['expectedLabel']&&_0xcd8a66[_0x1c27e6(0x18e)]===_0x4564ed[_0x1c27e6(0x19b)]&&_0xcd8a66[_0x1c27e6(0x187)]===0x2;}}catch{}const _0x23667e={...mutationData(_0x4564ed,![],_0xcd8a66?projectCrossRelation(_0xcd8a66):null),'verification':{'status':_0xb053cf?'matched':_0x1c27e6(0x16e),'verified':_0xb053cf}};if(!_0xb053cf){const _0x2ba203=CliErrors[_0x1c27e6(0x171)](_0x1c27e6(0x165)+_0x1614d8+_0x1c27e6(0x189),_0x1c27e6(0x14f));Object[_0x1c27e6(0x175)](_0x2ba203,_0x1c27e6(0x17e),{'value':{..._0x23667e,'candidates':_0x45904b[_0x1c27e6(0x16b)](projectCrossRelation)}});throw _0x2ba203;}return{'ok':!![],'data':_0x23667e,'message':_0x1c27e6(0x165)+_0x1614d8+_0x1c27e6(0x151)};}
|
|
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");
|