@lovrabet/rabetbase-cli 2.5.13 → 2.6.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -17
- package/lib/api/api-doc.js +3 -1
- package/lib/api/api-group.js +3 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +8 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +2 -1
- package/lib/api/model-registry-file.js +11 -1
- package/lib/api/model-registry-scaffold.js +2 -1
- package/lib/api/model-source.js +3 -1
- package/lib/auth/auth-server-ui.js +2 -1
- package/lib/auth/auth-server.js +5 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +3 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +5 -1
- package/lib/commands/api/generate.js +4 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +2 -1
- package/lib/commands/api/pull.js +10 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/detail.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +5 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +4 -1
- package/lib/commands/app-config/delete.js +2 -1
- package/lib/commands/app-config/get.js +2 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +2 -1
- package/lib/commands/app-config/set.js +3 -1
- package/lib/commands/app-config/shared.d.ts +9 -2
- package/lib/commands/app-config/shared.js +6 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +11 -1
- package/lib/commands/bff/delete.js +6 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +4 -1
- package/lib/commands/bff/pull.js +22 -1
- package/lib/commands/bff/push.js +16 -1
- package/lib/commands/bff/status.js +3 -1
- package/lib/commands/cli-skill/index.js +2 -1
- package/lib/commands/cli-update.js +7 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +4 -1
- package/lib/commands/common/app-selector.js +4 -1
- package/lib/commands/common/async-task.js +2 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +3 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +2 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +5 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +4 -1
- package/lib/commands/config/shared.js +2 -1
- package/lib/commands/dataset/batch-design.js +9 -1
- package/lib/commands/dataset/business-group-update.js +10 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +3 -1
- package/lib/commands/dataset/cross-relation-create.js +2 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +2 -1
- package/lib/commands/dataset/cross-relation-shared.js +10 -1
- package/lib/commands/dataset/cross-relation-update.js +2 -1
- package/lib/commands/dataset/delete.js +6 -1
- package/lib/commands/dataset/design-context.js +1 -1
- package/lib/commands/dataset/design-start.js +1 -1
- package/lib/commands/dataset/design-status.js +1 -1
- package/lib/commands/dataset/design-sync-retry.js +1 -1
- package/lib/commands/dataset/design-sync-status.js +1 -1
- package/lib/commands/dataset/design-validate.js +1 -1
- package/lib/commands/dataset/detail.js +5 -1
- package/lib/commands/dataset/extend-update.js +7 -1
- package/lib/commands/dataset/field-restore.js +7 -1
- package/lib/commands/dataset/field-update.js +7 -1
- package/lib/commands/dataset/generate.js +19 -1
- package/lib/commands/dataset/index.js +3 -1
- package/lib/commands/dataset/list.js +2 -1
- package/lib/commands/dataset/operations.js +2 -1
- package/lib/commands/dataset/relation-audit.js +7 -1
- package/lib/commands/dataset/relation-create.js +3 -1
- package/lib/commands/dataset/relation-delete.js +3 -1
- package/lib/commands/dataset/relation-shared.js +21 -1
- package/lib/commands/dataset/relation-update.js +4 -1
- package/lib/commands/dataset/relations.js +7 -1
- package/lib/commands/dataset/rename.js +4 -1
- package/lib/commands/dataset/restore.js +7 -1
- package/lib/commands/dataset/user-deleted-field-list.js +3 -1
- package/lib/commands/db/analysis-batching.js +3 -1
- package/lib/commands/db/analyze-batch-plan.js +2 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +3 -1
- package/lib/commands/db/analyze-status.js +6 -1
- package/lib/commands/db/create.js +4 -1
- package/lib/commands/db/cross-db-analysis-shared.js +3 -1
- package/lib/commands/db/cross-db-analyze-latest.js +1 -1
- package/lib/commands/db/cross-db-analyze-start.js +2 -1
- package/lib/commands/db/cross-db-analyze-status.js +1 -1
- package/lib/commands/db/delete.js +3 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +2 -1
- package/lib/commands/db/diff.js +3 -1
- package/lib/commands/db/index.js +2 -1
- package/lib/commands/db/list.js +2 -1
- package/lib/commands/db/shared.js +3 -1
- package/lib/commands/db/table-diff-shared.js +2 -1
- package/lib/commands/db/tables.js +2 -1
- package/lib/commands/db/test.js +2 -1
- package/lib/commands/db/update.js +4 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +3 -1
- package/lib/commands/deployment/sync-jobs.js +2 -1
- package/lib/commands/deployment/sync-status.js +2 -1
- package/lib/commands/doctor.js +12 -1
- package/lib/commands/file/index.js +3 -1
- package/lib/commands/flow/create.js +2 -1
- package/lib/commands/flow/detail.js +3 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +2 -1
- package/lib/commands/flow/page-list.js +2 -1
- package/lib/commands/flow/publish.js +2 -1
- package/lib/commands/flow/runtime-resources-shared.js +3 -1
- package/lib/commands/flow/runtime-role-list.js +2 -1
- package/lib/commands/flow/runtime-role-user-list.js +2 -1
- package/lib/commands/flow/runtime-user-search.js +2 -1
- package/lib/commands/flow/shared.js +6 -1
- package/lib/commands/flow/update.js +4 -1
- package/lib/commands/flow/validate.js +2 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +2 -1
- package/lib/commands/instant-api-policy/publish.js +5 -1
- package/lib/commands/instant-api-policy/pull.js +2 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +5 -1
- package/lib/commands/instant-api-policy/shared.js +5 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/context.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +2 -1
- package/lib/commands/issue/report.js +5 -1
- package/lib/commands/kb/create.js +5 -1
- package/lib/commands/kb/delete.js +5 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/import-api.d.ts +3 -0
- package/lib/commands/kb/import-api.js +1 -0
- package/lib/commands/kb/import-resume.d.ts +2 -0
- package/lib/commands/kb/import-resume.js +2 -0
- package/lib/commands/kb/import-shared.d.ts +69 -0
- package/lib/commands/kb/import-shared.js +9 -0
- package/lib/commands/kb/import-status.d.ts +2 -0
- package/lib/commands/kb/import-status.js +1 -0
- package/lib/commands/kb/import.d.ts +2 -0
- package/lib/commands/kb/import.js +3 -0
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +3 -1
- package/lib/commands/kb/shared.js +9 -1
- package/lib/commands/kb/update.js +7 -1
- package/lib/commands/logs/index.js +2 -1
- package/lib/commands/menu/asset-update.js +8 -1
- package/lib/commands/menu/delete.js +15 -1
- package/lib/commands/menu/external-link-create.js +16 -1
- package/lib/commands/menu/external-link-update.js +10 -1
- package/lib/commands/menu/group-create.js +8 -1
- package/lib/commands/menu/group-update.js +6 -1
- package/lib/commands/menu/index.js +2 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +6 -1
- package/lib/commands/menu/regroup-start.js +11 -1
- package/lib/commands/menu/rename.js +9 -1
- package/lib/commands/menu/shared/compare-table.js +2 -1
- package/lib/commands/menu/shared/delete-plan.js +13 -1
- package/lib/commands/menu/shared/facts.js +5 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +4 -1
- package/lib/commands/menu/shared/local-pages.js +5 -1
- package/lib/commands/menu/shared/logic.js +3 -1
- package/lib/commands/menu/shared/mutations.js +9 -1
- package/lib/commands/menu/shared/path.js +1 -1
- package/lib/commands/menu/shared/service.js +4 -1
- package/lib/commands/menu/shared/subapp-assets.js +4 -1
- package/lib/commands/menu/shared/sync-core.js +7 -1
- package/lib/commands/menu/shared/types.js +1 -1
- package/lib/commands/menu/shared/update-core.js +8 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.js +1 -1
- package/lib/commands/menu/subapp-assets-update.js +7 -1
- package/lib/commands/menu/sync.js +7 -1
- package/lib/commands/menu/visibility-update.js +13 -1
- package/lib/commands/metric/contract.d.ts +8 -0
- package/lib/commands/metric/contract.js +5 -0
- package/lib/commands/metric/definition.d.ts +43 -0
- package/lib/commands/metric/definition.js +4 -0
- package/lib/commands/metric/delete.d.ts +2 -0
- package/lib/commands/metric/delete.js +3 -0
- package/lib/commands/metric/detail.d.ts +2 -0
- package/lib/commands/metric/detail.js +1 -0
- package/lib/commands/metric/example.d.ts +2 -0
- package/lib/commands/metric/example.js +1 -0
- package/lib/commands/metric/index.d.ts +2 -0
- package/lib/commands/metric/index.js +1 -0
- package/lib/commands/metric/list.d.ts +2 -0
- package/lib/commands/metric/list.js +2 -0
- package/lib/commands/metric/publication-diff.d.ts +8 -0
- package/lib/commands/metric/publication-diff.js +1 -0
- package/lib/commands/metric/publish.d.ts +2 -0
- package/lib/commands/metric/publish.js +4 -0
- package/lib/commands/metric/schema.d.ts +2 -0
- package/lib/commands/metric/schema.js +1 -0
- package/lib/commands/metric/shared.d.ts +14 -0
- package/lib/commands/metric/shared.js +2 -0
- package/lib/commands/metric/validate.d.ts +2 -0
- package/lib/commands/metric/validate.js +1 -0
- package/lib/commands/notification/config-create.js +4 -1
- package/lib/commands/notification/config-delete.js +4 -1
- package/lib/commands/notification/config-list.js +2 -1
- package/lib/commands/notification/config-update.js +4 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +18 -1
- package/lib/commands/ocr/index.js +4 -1
- package/lib/commands/page/create.js +6 -1
- package/lib/commands/page/custom/detail.js +2 -1
- package/lib/commands/page/custom/list.js +2 -1
- package/lib/commands/page/custom/publish.js +3 -1
- package/lib/commands/page/custom/shared.js +3 -1
- package/lib/commands/page/custom/syntax.js +2 -1
- package/lib/commands/page/custom/update.js +3 -1
- package/lib/commands/page/data-list-status.js +2 -1
- package/lib/commands/page/generate-start.js +5 -1
- package/lib/commands/page/generate-status.js +4 -1
- package/lib/commands/page/index.js +2 -1
- package/lib/commands/page/pull.js +6 -1
- package/lib/commands/page/push.js +11 -1
- package/lib/commands/page/relation-audit.js +15 -1
- package/lib/commands/page/restore.js +5 -1
- package/lib/commands/page/shared.js +16 -1
- package/lib/commands/page/sync.js +2 -1
- package/lib/commands/project/api-architecture-upgrade.js +11 -1
- package/lib/commands/project/create/enhanced-guided-create.js +2 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +13 -1
- package/lib/commands/project/create/materialize-project-template.js +12 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +5 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +2 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +4 -1
- package/lib/commands/project/upgrade.js +7 -1
- package/lib/commands/registry.js +10 -1
- package/lib/commands/role/delete.js +2 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +2 -1
- package/lib/commands/role/shared.js +8 -1
- package/lib/commands/role/update.js +3 -1
- package/lib/commands/role/user-add.js +2 -1
- package/lib/commands/role/user-remove.js +2 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +7 -1
- package/lib/commands/rule/shared.js +4 -1
- package/lib/commands/run/index.js +5 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +7 -1
- package/lib/commands/sql/delete.js +4 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +2 -1
- package/lib/commands/sql/pull.js +10 -1
- package/lib/commands/sql/push.js +9 -1
- package/lib/commands/sql/shared.js +5 -1
- package/lib/commands/sql/status.js +3 -1
- package/lib/commands/sql/validate.js +5 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +2 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +2 -1
- package/lib/commands/tenant/shared.js +2 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +2 -1
- package/lib/commands/user-account/feishu-bind.js +2 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +7 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +8 -1
- package/lib/config/project-domain-routing.js +3 -1
- package/lib/config/region-config.js +2 -1
- package/lib/config/schema.js +7 -1
- package/lib/constant/cdn.js +2 -1
- package/lib/constant/cli.js +8 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +4 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +7 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +7 -1
- package/lib/context.js +9 -1
- package/lib/core/alias-resolver.js +5 -1
- package/lib/core/api-client.d.ts +14 -7
- package/lib/core/api-client.js +69 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +6 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +9 -1
- package/lib/core/bff/lock.js +2 -1
- package/lib/core/bff/types.js +1 -1
- package/lib/core/bff/utils.js +3 -1
- package/lib/core/cross-db-analysis.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +2 -1
- package/lib/core/flow-config.js +49 -1
- package/lib/core/instant-api-policy/config.js +7 -1
- package/lib/core/instant-api-policy/endpoints.js +1 -1
- package/lib/core/kb-management-client.d.ts +11 -0
- package/lib/core/kb-management-client.js +4 -1
- package/lib/core/kb-search-client.js +3 -1
- package/lib/core/page/file-system.js +2 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +2 -1
- package/lib/core/page/lr-smart-jsx.js +4 -1
- package/lib/core/page/types.js +1 -1
- package/lib/core/sql-index-auditor.js +14 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +3 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +2 -1
- package/lib/core/sql-sync/types.js +1 -1
- package/lib/core/sql-sync/utils.js +2 -1
- package/lib/core/sql-validator.js +15 -1
- package/lib/errors.js +3 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +2 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +2 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +2 -1
- package/lib/framework/runner.js +9 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +2 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +3 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/runtime/confirmation.js +2 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +4 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +2 -1
- package/lib/runtime/types.js +1 -1
- package/lib/services/dataset-design/checkpoint.js +2 -1
- package/lib/services/dataset-design/commands.js +14 -1
- package/lib/services/dataset-design/contract.js +8 -1
- package/lib/skills/builtin-skill.js +8 -1
- package/lib/skills/install-updated-skill.d.ts +8 -0
- package/lib/skills/install-updated-skill.js +3 -0
- package/lib/skills/local-skills-installer.d.ts +2 -0
- package/lib/skills/local-skills-installer.js +1 -0
- package/lib/skills/main.js +2 -1
- package/lib/skills/npx-skills-add.d.ts +6 -6
- package/lib/skills/npx-skills-add.js +5 -1
- package/lib/skills/skill-presence.d.ts +1 -30
- package/lib/skills/skill-presence.js +2 -1
- package/lib/telemetry/cli-command-trace.js +2 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/types/index.js +1 -1
- package/lib/utils/ai_config.js +3 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +5 -1
- package/lib/utils/cli-version-check.js +4 -1
- package/lib/utils/cli-version-policy.js +3 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +3 -1
- package/lib/utils/http-client.js +2 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +3 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +5 -1
- package/lib/utils/update-notice.js +3 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +10 -7
- package/skills/rabetbase/SKILL.md +11 -7
- package/skills/rabetbase/guides/backend-function.md +3 -1
- package/skills/rabetbase/guides/data-api-guidelines.md +1 -1
- package/skills/rabetbase/guides/frontend-development.md +1 -0
- package/skills/rabetbase/guides/metric-development.md +185 -0
- package/skills/rabetbase/references/rabetbase-app-config.md +4 -3
- package/skills/rabetbase/references/rabetbase-cli-skill-install.md +5 -5
- package/skills/rabetbase/references/rabetbase-dataset-design.md +1 -1
- package/skills/rabetbase/references/rabetbase-kb.md +16 -0
- package/skills/rabetbase/references/rabetbase-metric.md +119 -0
- package/skills/rabetbase/references/rabetbase-update.md +7 -5
- package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
- package/skills/rabetbase-dataset-generation/references/workflow.md +1 -1
- package/skills/rabetbase-metrics-generation/SKILL.md +22 -0
- package/skills/rabetbase-metrics-generation/references/verification.md +19 -0
- package/skills/rabetbase-metrics-generation/references/workflow.md +41 -0
- package/skills/rabetbase-metrics-generation/templates/statistics-delivery.md +11 -0
- package/skills/rabetbase-page-generation/SKILL.md +1 -1
- package/skills/rabetbase-page-generation/references/generation.md +1 -1
- package/skills/rabetbase.manifest.json +5 -3
- package/templates/metrics/definition.json +78 -0
- package/templates/metrics/metric-definition.schema.json +136 -0
- package/lib/postinstall.d.ts +0 -3
- package/lib/postinstall.js +0 -1
- package/scripts/postinstall.mjs +0 -24
- package/templates/README.md +0 -130
|
@@ -1 +1,12 @@
|
|
|
1
|
-
const a220_0x10f59f=a220_0x15d4;(function(_0x382e00,_0x38af75){const _0x108172=a220_0x15d4,_0x27e25e=_0x382e00();while(!![]){try{const _0xe79c79=parseInt(_0x108172(0x22f))/0x1+parseInt(_0x108172(0x1ff))/0x2+-parseInt(_0x108172(0x239))/0x3*(parseInt(_0x108172(0x209))/0x4)+parseInt(_0x108172(0x23f))/0x5+parseInt(_0x108172(0x22d))/0x6+-parseInt(_0x108172(0x256))/0x7*(-parseInt(_0x108172(0x251))/0x8)+-parseInt(_0x108172(0x20e))/0x9*(parseInt(_0x108172(0x24c))/0xa);if(_0xe79c79===_0x38af75)break;else _0x27e25e['push'](_0x27e25e['shift']());}catch(_0x47b1ad){_0x27e25e['push'](_0x27e25e['shift']());}}}(a220_0x31f9,0xd72ac));import{createHash}from'node:crypto';import a220_0x2203c5 from'node:fs/promises';import a220_0x4ea124 from'node:path';import a220_0x19f8eb from'semver';import{getProjectTemplateRelativeUrl}from'../../../constant/cdn.js';import{extractProjectTemplateArchive}from'../../../commands/project/create/project-template-archive.js';import{fetchProjectTemplateCdnConfig,isBetaCliVersion,resolveProjectTemplateDescriptor}from'../../../utils/cli-version-policy.js';function a220_0x31f9(){const _0xaf0051=['Use\x20a\x20different\x20project\x20name.','digest','assetBaseUrl','code','abort','startsWith','.idea','relative','signal','lstat','Local\x20template\x20source\x20and\x20project\x20output\x20must\x20not\x20overlap.','Choose\x20a\x20different\x20project\x20name\x20or\x20remove\x20the\x20directory\x20first.','CDN\x20config\x20contains\x20an\x20invalid\x20descriptor\x20for\x20\x22','readdir','origin','byteLength','protocol','dev','hex','Local\x20template\x20source\x20is\x20not\x20a\x20directory:\x20','ino','push','Pass\x20a\x20directory\x20containing\x20the\x20template\x20source\x20package.json.','toLowerCase','1500014mKKAsL','.DS_Store','CDN\x20project\x20template\x20relative\x20URL\x20must\x20match\x20its\x20release\x20channel\x20or\x20version.','releaseLock','message','utf8','validation','isFinite','access','.git','346708gyujtg','test','readFile','realpath','Rabetbase\x20CDN\x20config\x20is\x20unavailable.','18TDdmZy','parse','sub-app-react-demo','CDN\x20config\x20does\x20not\x20define\x20template\x20\x22','https:','rename','CDN\x20project\x20template\x20exceeds\x20its\x20declared\x20download\x20size.','Check\x20your\x20network\x20and\x20retry.\x20Details:\x20','Project\x20directory\x20already\x20exists:\x20','sha256:','string','CDN\x20project\x20template\x20size\x20mismatch:\x20expected\x20','copyFile','release','sep','includes','Unable\x20to\x20claim\x20the\x20project\x20directory.','update','object','resolving','sha256','number','Check\x20the\x20source\x20directory\x20and\x20retry.','from','pathname','Choose\x20an\x20output\x20directory\x20outside\x20the\x20template\x20source.','resolve','EEXIST','version','valid','isSymbolicLink','2512788xPwGnS','body','800617dJbLLZ','package.json','Project\x20template\x20package.json\x20is\x20invalid.','posix','Local\x20project\x20template\x20must\x20not\x20contain\x20symlinks:\x20','headers','name','isDirectory','size','length','3AJDvXo','url','trim','mkdir',',\x20received\x20','dist','1892905GTaMqK','join','isFile','basename','cancel','isSafeInteger','CDN\x20project\x20template\x20checksum\x20verification\x20failed.','copying','read','local','.rabetbase-create-','dirname','mode','8264410AhMEKp','concat','Local\x20template\x20source\x20does\x20not\x20exist:\x20','project','.lovrabet.json','545760btAPTM','.env','isAbsolute','.codegraph','Invalid\x20local\x20template\x20source:\x20','28pumWFp','get','node_modules','ENOENT','arrayBuffer','.rabetbase.json','.lovrabet.log','extracting','mkdtemp'];a220_0x31f9=function(){return _0xaf0051;};return a220_0x31f9();}import{getCliVersion}from'../../../utils/version.js';import{CliErrors}from'../../../errors.js';const TEMPLATE_ID=a220_0x10f59f(0x210),ARCHIVE_TIMEOUT_MS=0x3a98,MAX_ARCHIVE_SIZE=0x14*0x400*0x400;function nonEmptyString(_0x4155a4){const _0x39ec40=a220_0x10f59f;return typeof _0x4155a4===_0x39ec40(0x218)&&_0x4155a4[_0x39ec40(0x23b)]()?_0x4155a4['trim']():null;}function parseDescriptor(_0xb959fa){const _0xdc1cd7=a220_0x10f59f;if(!_0xb959fa||typeof _0xb959fa!==_0xdc1cd7(0x220))throw new Error(_0xdc1cd7(0x211)+TEMPLATE_ID+'\x22.');const _0x237a41=_0xb959fa,_0x4c756c=nonEmptyString(_0x237a41[_0xdc1cd7(0x22a)]),_0x190247=nonEmptyString(_0x237a41[_0xdc1cd7(0x235)]),_0x276c5b=_0x237a41[_0xdc1cd7(0x23a)]===undefined?undefined:nonEmptyString(_0x237a41[_0xdc1cd7(0x23a)])||undefined,_0x445a7f=nonEmptyString(_0x237a41[_0xdc1cd7(0x222)])?.[_0xdc1cd7(0x1fe)](),_0x39d330=_0x237a41[_0xdc1cd7(0x237)];if(!_0x4c756c||!a220_0x19f8eb[_0xdc1cd7(0x22b)](_0x4c756c)||!_0x190247||_0x190247!==a220_0x4ea124[_0xdc1cd7(0x232)][_0xdc1cd7(0x242)](_0x190247)||_0x190247['includes']('\x5c')||_0x237a41['url']!==undefined&&!_0x276c5b||!_0x445a7f||!/^sha256:[a-f0-9]{64}$/[_0xdc1cd7(0x20a)](_0x445a7f)||typeof _0x39d330!==_0xdc1cd7(0x223)||!Number[_0xdc1cd7(0x244)](_0x39d330)||_0x39d330<=0x0||_0x39d330>MAX_ARCHIVE_SIZE)throw new Error(_0xdc1cd7(0x1f3)+TEMPLATE_ID+'\x22.');return{'version':_0x4c756c,'name':_0x190247,'url':_0x276c5b,'sha256':_0x445a7f,'size':_0x39d330};}function a220_0x15d4(_0xfa859f,_0x362799){_0xfa859f=_0xfa859f-0x1e5;const _0x31f90f=a220_0x31f9();let _0x15d4e5=_0x31f90f[_0xfa859f];return _0x15d4e5;}async function fetchWithTimeout(_0x2bf888,_0x2274c8,_0x4a1198,_0x51ece8){const _0x15bed8=a220_0x10f59f,_0x4b35bc=new AbortController(),_0x1c0a7e=setTimeout(()=>_0x4b35bc[_0x15bed8(0x1eb)](),_0x2274c8);try{const _0x5f390f=await fetch(_0x2bf888,{'headers':{'Accept':_0x4a1198},'redirect':'error','signal':_0x4b35bc[_0x15bed8(0x1ef)]});return await _0x51ece8(_0x5f390f);}finally{clearTimeout(_0x1c0a7e);}}async function fetchTemplateDescriptor(){const _0x55a554=a220_0x10f59f,_0x29e178=getCliVersion(),_0x26c27c=isBetaCliVersion(_0x29e178)?'beta':_0x55a554(0x21b),_0x539755=await fetchProjectTemplateCdnConfig();if(!_0x539755)throw new Error(_0x55a554(0x20d));const _0x38ac91=parseDescriptor(resolveProjectTemplateDescriptor(_0x539755['config'],_0x29e178));return{'descriptor':_0x38ac91,'channel':_0x26c27c,'assetBaseUrl':_0x539755[_0x55a554(0x1e9)],'legacyAssetBaseUrl':_0x539755['legacyAssetBaseUrl']};}function resolveArchiveUrl(_0x28ed43,_0x4ef22e,_0x410a05,_0x4ae1e9){const _0x4e67e8=a220_0x10f59f,_0x540400=new URL(_0x410a05+'/'),_0x18b319=[getProjectTemplateRelativeUrl(_0x4ef22e),getProjectTemplateRelativeUrl(_0x4ef22e,_0x28ed43[_0x4e67e8(0x22a)])];if(_0x28ed43[_0x4e67e8(0x23a)]&&!_0x18b319[_0x4e67e8(0x21d)](_0x28ed43['url']))throw new Error(_0x4e67e8(0x201));const _0x124daf=new URL(_0x4ae1e9+'/'),_0x873483=_0x28ed43['url']?new URL(_0x28ed43[_0x4e67e8(0x23a)],_0x540400[_0x4e67e8(0x1f5)]):new URL(_0x28ed43[_0x4e67e8(0x235)],_0x124daf),_0x254d3f=_0x28ed43['url']?_0x540400[_0x4e67e8(0x1f5)]:_0x124daf['origin'];if(_0x873483[_0x4e67e8(0x1f7)]!==_0x4e67e8(0x212)||_0x873483['origin']!==_0x254d3f||a220_0x4ea124[_0x4e67e8(0x232)][_0x4e67e8(0x242)](decodeURIComponent(_0x873483[_0x4e67e8(0x226)]))!==_0x28ed43[_0x4e67e8(0x235)]||!_0x28ed43[_0x4e67e8(0x23a)]&&!_0x873483[_0x4e67e8(0x226)][_0x4e67e8(0x1ec)](_0x124daf['pathname']))throw new Error('CDN\x20project\x20template\x20URL\x20must\x20use\x20the\x20trusted\x20HTTPS\x20origin.');return _0x873483['href'];}async function readResponseBytes(_0x2ceb1e,_0x582604){const _0x1655db=a220_0x10f59f;if(!_0x2ceb1e[_0x1655db(0x22e)]){const _0x42db0a=Buffer[_0x1655db(0x225)](await _0x2ceb1e[_0x1655db(0x25a)]());if(_0x42db0a[_0x1655db(0x238)]>_0x582604)throw new Error(_0x1655db(0x214));return _0x42db0a;}const _0x1f2641=_0x2ceb1e[_0x1655db(0x22e)]['getReader'](),_0x4f084c=[];let _0x33be14=0x0;try{while(!![]){const {done:_0x5e8d70,value:_0x169363}=await _0x1f2641[_0x1655db(0x247)]();if(_0x5e8d70)break;_0x33be14+=_0x169363[_0x1655db(0x1f6)];if(_0x33be14>_0x582604){await _0x1f2641[_0x1655db(0x243)]();throw new Error('CDN\x20project\x20template\x20exceeds\x20its\x20declared\x20download\x20size.');}_0x4f084c[_0x1655db(0x1fc)](Buffer['from'](_0x169363));}}finally{_0x1f2641[_0x1655db(0x202)]();}return Buffer[_0x1655db(0x24d)](_0x4f084c,_0x33be14);}async function downloadArchive(_0x53d157,_0x46d381,_0x31f186,_0x5c49b6,_0x10f15a,_0x233400){const _0x26dfa9=a220_0x10f59f,_0x42150f=await fetchWithTimeout(resolveArchiveUrl(_0x53d157,_0x46d381,_0x31f186,_0x5c49b6),ARCHIVE_TIMEOUT_MS,'application/zip',async _0x3d8aad=>{const _0xa9f10=a220_0x15d4;if(!_0x3d8aad['ok'])throw new Error('CDN\x20project\x20template\x20request\x20failed\x20with\x20HTTP\x20'+_0x3d8aad['status']+'.');const _0x4f3db6=Number(_0x3d8aad[_0xa9f10(0x234)][_0xa9f10(0x257)]('content-length'));if(Number[_0xa9f10(0x206)](_0x4f3db6)&&_0x4f3db6>MAX_ARCHIVE_SIZE)throw new Error('CDN\x20project\x20template\x20exceeds\x20the\x2020\x20MB\x20download\x20limit.');return readResponseBytes(_0x3d8aad,_0x53d157[_0xa9f10(0x237)]);});if(_0x42150f[_0x26dfa9(0x238)]!==_0x53d157[_0x26dfa9(0x237)])throw new Error(_0x26dfa9(0x219)+_0x53d157[_0x26dfa9(0x237)]+_0x26dfa9(0x23d)+_0x42150f['length']+'.');_0x233400?.('verifying');const _0x5b04bc=_0x26dfa9(0x217)+createHash(_0x26dfa9(0x222))[_0x26dfa9(0x21f)](_0x42150f)[_0x26dfa9(0x1e8)](_0x26dfa9(0x1f9));if(_0x5b04bc!==_0x53d157[_0x26dfa9(0x222)])throw new Error(_0x26dfa9(0x245));await a220_0x2203c5['writeFile'](_0x10f15a,_0x42150f,{'flag':'wx'});}async function assertTemplateRoot(_0x517c64){const _0x311ee9=a220_0x10f59f,_0x5b0e9d=a220_0x4ea124[_0x311ee9(0x240)](_0x517c64,_0x311ee9(0x230)),_0x726011=JSON[_0x311ee9(0x20f)](await a220_0x2203c5[_0x311ee9(0x20b)](_0x5b0e9d,_0x311ee9(0x204)));if(!_0x726011||typeof _0x726011!==_0x311ee9(0x220))throw new Error(_0x311ee9(0x231));}const LOCAL_FORBIDDEN_NAMES=new Set([a220_0x10f59f(0x200),a220_0x10f59f(0x254),a220_0x10f59f(0x208),a220_0x10f59f(0x1ed),a220_0x10f59f(0x250),a220_0x10f59f(0x25c),'.rabetbase',a220_0x10f59f(0x25b),a220_0x10f59f(0x23e),a220_0x10f59f(0x258)]);function isForbiddenTemplateEntry(_0x571175){const _0x3310ca=a220_0x10f59f;if(LOCAL_FORBIDDEN_NAMES['has'](_0x571175))return!![];return _0x571175===_0x3310ca(0x252)||_0x571175[_0x3310ca(0x1ec)]('.env.')&&_0x571175!=='.env.example';}function containsPath(_0x2534ac,_0x48bcba){const _0xae25c9=a220_0x10f59f,_0x231eab=a220_0x4ea124[_0xae25c9(0x1ee)](_0x2534ac,_0x48bcba);return _0x231eab===''||!_0x231eab[_0xae25c9(0x1ec)]('..'+a220_0x4ea124[_0xae25c9(0x21c)])&&_0x231eab!=='..'&&!a220_0x4ea124[_0xae25c9(0x253)](_0x231eab);}async function copyLocalTemplateDirectory(_0x3ab59c,_0xa59c77){const _0x2f1647=a220_0x10f59f;await a220_0x2203c5[_0x2f1647(0x23c)](_0xa59c77,{'recursive':!![]});for(const _0x41ea15 of await a220_0x2203c5['readdir'](_0x3ab59c,{'withFileTypes':!![]})){const _0x572f9b=a220_0x4ea124[_0x2f1647(0x240)](_0x3ab59c,_0x41ea15[_0x2f1647(0x235)]),_0x11927a=a220_0x4ea124[_0x2f1647(0x240)](_0xa59c77,_0x41ea15['name']);if(isForbiddenTemplateEntry(_0x41ea15[_0x2f1647(0x235)]))throw new Error('Local\x20project\x20template\x20contains\x20a\x20local-only\x20entry:\x20'+_0x572f9b);const _0x13515e=await a220_0x2203c5[_0x2f1647(0x1f0)](_0x572f9b);if(_0x13515e[_0x2f1647(0x22c)]())throw new Error(_0x2f1647(0x233)+_0x572f9b);if(_0x13515e[_0x2f1647(0x236)]()){await copyLocalTemplateDirectory(_0x572f9b,_0x11927a);continue;}if(!_0x13515e[_0x2f1647(0x241)]())continue;await a220_0x2203c5[_0x2f1647(0x21a)](_0x572f9b,_0x11927a),await a220_0x2203c5['chmod'](_0x11927a,_0x13515e[_0x2f1647(0x24b)]&0x1ff);}}async function readTemplateVersion(_0x4aee76){const _0x48a8e7=a220_0x10f59f,_0x4b6f4d=JSON[_0x48a8e7(0x20f)](await a220_0x2203c5[_0x48a8e7(0x20b)](a220_0x4ea124['join'](_0x4aee76,_0x48a8e7(0x230)),_0x48a8e7(0x204)));return nonEmptyString(_0x4b6f4d[_0x48a8e7(0x22a)])||_0x48a8e7(0x248);}async function readDirectoryIdentity(_0x17f241){const _0x3a6dfe=a220_0x10f59f;try{const _0x1912b5=await a220_0x2203c5[_0x3a6dfe(0x1f0)](_0x17f241);if(!_0x1912b5['isDirectory']())return null;return{'dev':_0x1912b5[_0x3a6dfe(0x1f8)],'ino':_0x1912b5[_0x3a6dfe(0x1fb)]};}catch{return null;}}async function commitStagedProject(_0x4c3a68,_0x5b385f){const _0x183c5e=a220_0x10f59f;await a220_0x2203c5[_0x183c5e(0x23c)](_0x5b385f);const _0x5bfee9=await readDirectoryIdentity(_0x5b385f);if(!_0x5bfee9)throw new Error(_0x183c5e(0x21e));try{for(const _0x9b32e0 of await a220_0x2203c5[_0x183c5e(0x1f4)](_0x4c3a68)){await a220_0x2203c5[_0x183c5e(0x213)](a220_0x4ea124[_0x183c5e(0x240)](_0x4c3a68,_0x9b32e0),a220_0x4ea124[_0x183c5e(0x240)](_0x5b385f,_0x9b32e0));}}catch(_0x183c86){const _0x4a0dc8=await readDirectoryIdentity(_0x5b385f);_0x4a0dc8?.[_0x183c5e(0x1f8)]===_0x5bfee9['dev']&&_0x4a0dc8[_0x183c5e(0x1fb)]===_0x5bfee9[_0x183c5e(0x1fb)]&&await a220_0x2203c5['rm'](_0x5b385f,{'recursive':!![],'force':!![]});throw _0x183c86;}}export async function materializeProjectTemplate(_0x1ca3d8,_0x578214){const _0x20207f=a220_0x10f59f,_0x461bdf=a220_0x4ea124[_0x20207f(0x228)](_0x1ca3d8),_0xccc7e9=a220_0x4ea124[_0x20207f(0x24a)](_0x461bdf);try{await a220_0x2203c5[_0x20207f(0x1f0)](_0x461bdf);throw new Error(_0x20207f(0x216)+_0x461bdf);}catch(_0x2016c0){if(_0x2016c0['code']!==_0x20207f(0x259))throw _0x2016c0;}const _0x3dd3ec=await a220_0x2203c5['mkdtemp'](a220_0x4ea124[_0x20207f(0x240)](_0xccc7e9,_0x20207f(0x249))),_0x35c814=a220_0x4ea124[_0x20207f(0x240)](_0x3dd3ec,'project'),_0x4893be=a220_0x4ea124[_0x20207f(0x240)](_0x3dd3ec,'template.zip');try{try{_0x578214?.(_0x20207f(0x221));const {descriptor:_0x112cf8,channel:_0x4c6154,assetBaseUrl:_0xff41e5,legacyAssetBaseUrl:_0x1e2895}=await fetchTemplateDescriptor();return _0x578214?.('downloading'),await downloadArchive(_0x112cf8,_0x4c6154,_0xff41e5,_0x1e2895,_0x4893be,_0x578214),_0x578214?.(_0x20207f(0x1e5)),await extractProjectTemplateArchive(_0x4893be,_0x35c814),await assertTemplateRoot(_0x35c814),await commitStagedProject(_0x35c814,_0x461bdf),{'source':'cdn','version':_0x112cf8[_0x20207f(0x22a)]};}catch(_0x92bccc){if(_0x92bccc[_0x20207f(0x1ea)]===_0x20207f(0x229))throw CliErrors['validation'](_0x20207f(0x216)+_0x461bdf,_0x20207f(0x1e7));const _0x5839c7=_0x92bccc instanceof Error?_0x92bccc[_0x20207f(0x203)]:String(_0x92bccc);throw CliErrors['validation']('Unable\x20to\x20download\x20a\x20valid\x20project\x20template\x20from\x20CDN.',_0x20207f(0x215)+_0x5839c7);}}finally{await a220_0x2203c5['rm'](_0x3dd3ec,{'recursive':!![],'force':!![]});}}export async function materializeLocalProjectTemplate(_0x417526,_0x212db7,_0x127d6f){const _0x59f181=a220_0x10f59f;let _0x2aa173;try{_0x2aa173=await a220_0x2203c5[_0x59f181(0x20c)](a220_0x4ea124[_0x59f181(0x228)](_0x417526));}catch{throw CliErrors['validation'](_0x59f181(0x24e)+a220_0x4ea124[_0x59f181(0x228)](_0x417526),_0x59f181(0x1fd));}const _0x3b5db7=await a220_0x2203c5['lstat'](_0x2aa173);if(!_0x3b5db7[_0x59f181(0x236)]())throw CliErrors['validation'](_0x59f181(0x1fa)+_0x2aa173);const _0x64e9b3=a220_0x4ea124[_0x59f181(0x228)](_0x212db7),_0x58f384=await a220_0x2203c5['realpath'](a220_0x4ea124['dirname'](_0x64e9b3)),_0x3ccb06=a220_0x4ea124[_0x59f181(0x240)](_0x58f384,a220_0x4ea124[_0x59f181(0x242)](_0x64e9b3));if(containsPath(_0x2aa173,_0x3ccb06)||containsPath(_0x3ccb06,_0x2aa173))throw CliErrors[_0x59f181(0x205)](_0x59f181(0x1f1),_0x59f181(0x227));try{await a220_0x2203c5[_0x59f181(0x1f0)](_0x3ccb06);throw CliErrors['validation'](_0x59f181(0x216)+_0x3ccb06,_0x59f181(0x1f2));}catch(_0x47d62e){if(_0x47d62e[_0x59f181(0x1ea)]!==_0x59f181(0x259))throw _0x47d62e;}const _0x5cbd81=a220_0x4ea124[_0x59f181(0x24a)](_0x3ccb06);await a220_0x2203c5[_0x59f181(0x207)](_0x5cbd81);const _0x3d5711=await a220_0x2203c5[_0x59f181(0x1e6)](a220_0x4ea124[_0x59f181(0x240)](_0x5cbd81,_0x59f181(0x249))),_0xefefa9=a220_0x4ea124[_0x59f181(0x240)](_0x3d5711,_0x59f181(0x24f));try{_0x127d6f?.(_0x59f181(0x246)),await copyLocalTemplateDirectory(_0x2aa173,_0xefefa9),await assertTemplateRoot(_0xefefa9);const _0x3609bd=await readTemplateVersion(_0xefefa9);return await commitStagedProject(_0xefefa9,_0x3ccb06),{'source':_0x59f181(0x248),'version':_0x3609bd};}catch(_0x22dd78){const _0x31bc1e=_0x22dd78 instanceof Error?_0x22dd78['message']:String(_0x22dd78);throw CliErrors['validation'](_0x59f181(0x255)+_0x31bc1e,_0x59f181(0x224));}finally{await a220_0x2203c5['rm'](_0x3d5711,{'recursive':!![],'force':!![]});}}
|
|
1
|
+
import{createHash}from"node:crypto";import fs from"node:fs/promises";import path from"node:path";import semver from"semver";import{getProjectTemplateRelativeUrl}from"../../../constant/cdn.js";import{extractProjectTemplateArchive}from"../../../commands/project/create/project-template-archive.js";import{fetchProjectTemplateCdnConfig,isBetaCliVersion,resolveProjectTemplateDescriptor}from"../../../utils/cli-version-policy.js";import{getCliVersion}from"../../../utils/version.js";import{CliErrors}from"../../../errors.js";const TEMPLATE_ID="sub-app-react-demo";const ARCHIVE_TIMEOUT_MS=15e3;const MAX_ARCHIVE_SIZE=20*1024*1024;function nonEmptyString(value){return typeof value==="string"&&value.trim()?value.trim():null}function parseDescriptor(raw){if(!raw||typeof raw!=="object"){throw new Error(`CDN config does not define template "${TEMPLATE_ID}".`)}const source=raw;const version=nonEmptyString(source.version);const name=nonEmptyString(source.name)
|
|
2
|
+
;const url=source.url===undefined?undefined:nonEmptyString(source.url)||undefined;const sha256=nonEmptyString(source.sha256)?.toLowerCase();const size=source.size;if(!version||!semver.valid(version)||!name||name!==path.posix.basename(name)||name.includes("\\")||source.url!==undefined&&!url||!sha256||!/^sha256:[a-f0-9]{64}$/.test(sha256)||typeof size!=="number"||!Number.isSafeInteger(size)||size<=0||size>MAX_ARCHIVE_SIZE){throw new Error(`CDN config contains an invalid descriptor for "${TEMPLATE_ID}".`)}return{version:version,name:name,url:url,sha256:sha256,size:size}}async function fetchWithTimeout(url,timeoutMs,accept,consume){const controller=new AbortController;const timeoutId=setTimeout(()=>controller.abort(),timeoutMs);try{const response=await fetch(url,{headers:{Accept:accept},redirect:"error",signal:controller.signal});return await consume(response)}finally{clearTimeout(timeoutId)}}async function fetchTemplateDescriptor(){const cliVersion=getCliVersion()
|
|
3
|
+
;const channel=isBetaCliVersion(cliVersion)?"beta":"release";const resolution=await fetchProjectTemplateCdnConfig();if(!resolution)throw new Error("Rabetbase CDN config is unavailable.");const descriptor=parseDescriptor(resolveProjectTemplateDescriptor(resolution.config,cliVersion));return{descriptor:descriptor,channel:channel,assetBaseUrl:resolution.assetBaseUrl,legacyAssetBaseUrl:resolution.legacyAssetBaseUrl}}function resolveArchiveUrl(descriptor,channel,baseUrl,legacyBaseUrl){const assetBaseUrl=new URL(`${baseUrl}/`);const expectedRelativeUrls=[getProjectTemplateRelativeUrl(channel),getProjectTemplateRelativeUrl(channel,descriptor.version)];if(descriptor.url&&!expectedRelativeUrls.includes(descriptor.url)){throw new Error(`CDN project template relative URL must match its release channel or version.`)}const legacyAssetBase=new URL(`${legacyBaseUrl}/`);const url=descriptor.url?new URL(descriptor.url,assetBaseUrl.origin):new URL(descriptor.name,legacyAssetBase)
|
|
4
|
+
;const trustedOrigin=descriptor.url?assetBaseUrl.origin:legacyAssetBase.origin;if(url.protocol!=="https:"||url.origin!==trustedOrigin||path.posix.basename(decodeURIComponent(url.pathname))!==descriptor.name||!descriptor.url&&!url.pathname.startsWith(legacyAssetBase.pathname)){throw new Error("CDN project template URL must use the trusted HTTPS origin.")}return url.href}async function readResponseBytes(response,maximumSize){if(!response.body){const bytes=Buffer.from(await response.arrayBuffer());if(bytes.length>maximumSize){throw new Error("CDN project template exceeds its declared download size.")}return bytes}const reader=response.body.getReader();const chunks=[];let receivedSize=0;try{while(true){const{done:done,value:value}=await reader.read();if(done)break;receivedSize+=value.byteLength;if(receivedSize>maximumSize){await reader.cancel();throw new Error("CDN project template exceeds its declared download size.")}chunks.push(Buffer.from(value))}}finally{reader.releaseLock()}
|
|
5
|
+
return Buffer.concat(chunks,receivedSize)}async function downloadArchive(descriptor,channel,assetBaseUrl,legacyAssetBaseUrl,targetPath,onProgress){const bytes=await fetchWithTimeout(resolveArchiveUrl(descriptor,channel,assetBaseUrl,legacyAssetBaseUrl),ARCHIVE_TIMEOUT_MS,"application/zip",async response=>{if(!response.ok){throw new Error(`CDN project template request failed with HTTP ${response.status}.`)}const contentLength=Number(response.headers.get("content-length"));if(Number.isFinite(contentLength)&&contentLength>MAX_ARCHIVE_SIZE){throw new Error("CDN project template exceeds the 20 MB download limit.")}return readResponseBytes(response,descriptor.size)});if(bytes.length!==descriptor.size){throw new Error(`CDN project template size mismatch: expected ${descriptor.size}, received ${bytes.length}.`)}onProgress?.("verifying");const actualHash=`sha256:${createHash("sha256").update(bytes).digest("hex")}`;if(actualHash!==descriptor.sha256){
|
|
6
|
+
throw new Error("CDN project template checksum verification failed.")}await fs.writeFile(targetPath,bytes,{flag:"wx"})}async function assertTemplateRoot(templateDir){const packageJsonPath=path.join(templateDir,"package.json");const packageJson=JSON.parse(await fs.readFile(packageJsonPath,"utf8"));if(!packageJson||typeof packageJson!=="object"){throw new Error("Project template package.json is invalid.")}}const LOCAL_FORBIDDEN_NAMES=new Set([".DS_Store",".codegraph",".git",".idea",".lovrabet.json",".lovrabet.log",".rabetbase",".rabetbase.json","dist","node_modules"]);function isForbiddenTemplateEntry(name){if(LOCAL_FORBIDDEN_NAMES.has(name))return true;return name===".env"||name.startsWith(".env.")&&name!==".env.example"}function containsPath(parent,child){const relativePath=path.relative(parent,child);return relativePath===""||!relativePath.startsWith(`..${path.sep}`)&&relativePath!==".."&&!path.isAbsolute(relativePath)}async function copyLocalTemplateDirectory(sourceDir,targetDir){
|
|
7
|
+
await fs.mkdir(targetDir,{recursive:true});for(const entry of await fs.readdir(sourceDir,{withFileTypes:true})){const sourcePath=path.join(sourceDir,entry.name);const targetPath=path.join(targetDir,entry.name);if(isForbiddenTemplateEntry(entry.name)){throw new Error(`Local project template contains a local-only entry: ${sourcePath}`)}const stats=await fs.lstat(sourcePath);if(stats.isSymbolicLink()){throw new Error(`Local project template must not contain symlinks: ${sourcePath}`)}if(stats.isDirectory()){await copyLocalTemplateDirectory(sourcePath,targetPath);continue}if(!stats.isFile())continue;await fs.copyFile(sourcePath,targetPath);await fs.chmod(targetPath,stats.mode&511)}}async function readTemplateVersion(templateDir){const packageJson=JSON.parse(await fs.readFile(path.join(templateDir,"package.json"),"utf8"));return nonEmptyString(packageJson.version)||"local"}async function readDirectoryIdentity(directory){try{const stats=await fs.lstat(directory)
|
|
8
|
+
;if(!stats.isDirectory())return null;return{dev:stats.dev,ino:stats.ino}}catch{return null}}async function commitStagedProject(stagingDir,projectDir){await fs.mkdir(projectDir);const identity=await readDirectoryIdentity(projectDir);if(!identity)throw new Error("Unable to claim the project directory.");try{for(const entry of await fs.readdir(stagingDir)){await fs.rename(path.join(stagingDir,entry),path.join(projectDir,entry))}}catch(error){const currentIdentity=await readDirectoryIdentity(projectDir);if(currentIdentity?.dev===identity.dev&¤tIdentity.ino===identity.ino){await fs.rm(projectDir,{recursive:true,force:true})}throw error}}export async function materializeProjectTemplate(projectDir,onProgress){const resolvedProjectDir=path.resolve(projectDir);const parentDir=path.dirname(resolvedProjectDir);try{await fs.lstat(resolvedProjectDir);throw new Error(`Project directory already exists: ${resolvedProjectDir}`)}catch(error){if(error.code!=="ENOENT")throw error}
|
|
9
|
+
const workDir=await fs.mkdtemp(path.join(parentDir,".rabetbase-create-"));const stagingDir=path.join(workDir,"project");const archivePath=path.join(workDir,"template.zip");try{try{onProgress?.("resolving");const{descriptor:descriptor,channel:channel,assetBaseUrl:assetBaseUrl,legacyAssetBaseUrl:legacyAssetBaseUrl}=await fetchTemplateDescriptor();onProgress?.("downloading");await downloadArchive(descriptor,channel,assetBaseUrl,legacyAssetBaseUrl,archivePath,onProgress);onProgress?.("extracting");await extractProjectTemplateArchive(archivePath,stagingDir);await assertTemplateRoot(stagingDir);await commitStagedProject(stagingDir,resolvedProjectDir);return{source:"cdn",version:descriptor.version}}catch(error){if(error.code==="EEXIST"){throw CliErrors.validation(`Project directory already exists: ${resolvedProjectDir}`,"Use a different project name.")}const reason=error instanceof Error?error.message:String(error)
|
|
10
|
+
;throw CliErrors.validation("Unable to download a valid project template from CDN.",`Check your network and retry. Details: ${reason}`)}}finally{await fs.rm(workDir,{recursive:true,force:true})}}export async function materializeLocalProjectTemplate(sourceDir,projectDir,onProgress){let resolvedSourceDir;try{resolvedSourceDir=await fs.realpath(path.resolve(sourceDir))}catch{throw CliErrors.validation(`Local template source does not exist: ${path.resolve(sourceDir)}`,"Pass a directory containing the template source package.json.")}const sourceStats=await fs.lstat(resolvedSourceDir);if(!sourceStats.isDirectory()){throw CliErrors.validation(`Local template source is not a directory: ${resolvedSourceDir}`)}const requestedProjectDir=path.resolve(projectDir);const resolvedProjectParent=await fs.realpath(path.dirname(requestedProjectDir));const resolvedProjectDir=path.join(resolvedProjectParent,path.basename(requestedProjectDir))
|
|
11
|
+
;if(containsPath(resolvedSourceDir,resolvedProjectDir)||containsPath(resolvedProjectDir,resolvedSourceDir)){throw CliErrors.validation("Local template source and project output must not overlap.","Choose an output directory outside the template source.")}try{await fs.lstat(resolvedProjectDir);throw CliErrors.validation(`Project directory already exists: ${resolvedProjectDir}`,"Choose a different project name or remove the directory first.")}catch(error){if(error.code!=="ENOENT")throw error}const parentDir=path.dirname(resolvedProjectDir);await fs.access(parentDir);const workDir=await fs.mkdtemp(path.join(parentDir,".rabetbase-create-"));const stagingDir=path.join(workDir,"project");try{onProgress?.("copying");await copyLocalTemplateDirectory(resolvedSourceDir,stagingDir);await assertTemplateRoot(stagingDir);const version=await readTemplateVersion(stagingDir);await commitStagedProject(stagingDir,resolvedProjectDir);return{source:"local",version:version}}catch(error){
|
|
12
|
+
const reason=error instanceof Error?error.message:String(error);throw CliErrors.validation(`Invalid local template source: ${reason}`,"Check the source directory and retry.")}finally{await fs.rm(workDir,{recursive:true,force:true})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../../errors.js";const PROJECT_NAME_PATTERN=/^[A-Za-z0-9][A-Za-z0-9_-]*$/;const WINDOWS_RESERVED_NAME=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i;const MAX_PROJECT_NAME_LENGTH=100;export function getProjectNameValidationError(value){const projectName=value.trim();if(!projectName)return"Project name cannot be empty";if(projectName.length>MAX_PROJECT_NAME_LENGTH){return`Project name cannot exceed ${MAX_PROJECT_NAME_LENGTH} characters`}if(!PROJECT_NAME_PATTERN.test(projectName)){return"Must start with a letter/number and only contain letters, numbers, - and _"}if(WINDOWS_RESERVED_NAME.test(projectName)){return`Project name "${projectName}" is reserved on Windows`}return null}export function validateProjectName(value){const projectName=value.trim();const error=getProjectNameValidationError(projectName);if(error){throw CliErrors.validation(error,"Use a portable directory name without path separators.")}return projectName}
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import{createWriteStream}from"node:fs";import fs from"node:fs/promises";import path from"node:path";import{pipeline}from"node:stream/promises";import yauzl from"yauzl";const MAX_ENTRY_COUNT=2e3;const MAX_UNCOMPRESSED_SIZE=50*1024*1024;const WINDOWS_RESERVED_NAME=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/i;const WINDOWS_INVALID_CHAR=/[<>:"|?*\x00-\x1f]/;function openZip(zipPath){return new Promise((resolve,reject)=>{yauzl.open(zipPath,{lazyEntries:true,decodeStrings:true,strictFileNames:true,validateEntrySizes:true},(error,zipFile)=>{if(error||!zipFile){reject(error||new Error("Unable to open project template archive."));return}resolve(zipFile)})})}function openEntryStream(zipFile,entry){return new Promise((resolve,reject)=>{zipFile.openReadStream(entry,(error,stream)=>{if(error||!stream){reject(error||new Error(`Unable to read ZIP entry: ${entry.fileName}`));return}resolve(stream)})})}function validateEntryPath(fileName){const normalized=fileName.replace(/\\/g,"/")
|
|
2
|
+
;const directory=normalized.endsWith("/");const relativePath=directory?normalized.slice(0,-1):normalized;if(!relativePath||normalized.startsWith("/")||/^[A-Za-z]:\//.test(normalized)){throw new Error(`Unsafe absolute ZIP entry path: ${fileName}`)}const segments=relativePath.split("/");for(const segment of segments){if(!segment||segment==="."||segment===".."||segment.endsWith(".")||segment.endsWith(" ")||WINDOWS_INVALID_CHAR.test(segment)||WINDOWS_RESERVED_NAME.test(segment)){throw new Error(`Unsafe or non-portable ZIP entry path: ${fileName}`)}}return{relativePath:segments.join(path.sep),directory:directory}}function isSymbolicLink(entry){const unixMode=entry.externalFileAttributes>>>16&65535;return(unixMode&61440)===40960}export async function extractProjectTemplateArchive(zipPath,destinationDir){const zipFile=await openZip(zipPath);const destinationRoot=path.resolve(destinationDir);const seenPaths=new Set;const pathCasing=new Map;let entryCount=0;let totalUncompressedSize=0
|
|
3
|
+
;await fs.mkdir(destinationRoot,{recursive:true});await new Promise((resolve,reject)=>{let settled=false;const fail=error=>{if(settled)return;settled=true;zipFile.close();reject(error instanceof Error?error:new Error(String(error)))};zipFile.once("error",fail);zipFile.once("end",()=>{if(settled)return;settled=true;resolve()});zipFile.on("entry",entry=>{void(async()=>{entryCount+=1;totalUncompressedSize+=entry.uncompressedSize;if(entryCount>MAX_ENTRY_COUNT){throw new Error(`Project template ZIP exceeds ${MAX_ENTRY_COUNT} entries.`)}if(totalUncompressedSize>MAX_UNCOMPRESSED_SIZE){throw new Error("Project template ZIP expands beyond the 50 MB safety limit.")}if(entry.isEncrypted()){throw new Error(`Encrypted ZIP entries are not supported: ${entry.fileName}`)}if(isSymbolicLink(entry)){throw new Error(`Symbolic links are not allowed in project templates: ${entry.fileName}`)}const{relativePath:relativePath,directory:directory}=validateEntryPath(entry.fileName)
|
|
4
|
+
;const portableSegments=relativePath.split(path.sep);for(let index=1;index<=portableSegments.length;index+=1){const candidate=portableSegments.slice(0,index).join(path.sep);const candidateKey=candidate.toLocaleLowerCase("en-US");const existingCasing=pathCasing.get(candidateKey);if(existingCasing&&existingCasing!==candidate){throw new Error(`Case-conflicting ZIP entry path: ${entry.fileName}`)}pathCasing.set(candidateKey,candidate)}const collisionKey=relativePath.toLocaleLowerCase("en-US");if(seenPaths.has(collisionKey)){throw new Error(`Duplicate or case-conflicting ZIP entry: ${entry.fileName}`)}seenPaths.add(collisionKey);const outputPath=path.resolve(destinationRoot,relativePath);if(outputPath!==destinationRoot&&!outputPath.startsWith(`${destinationRoot}${path.sep}`)){throw new Error(`ZIP entry escapes the destination directory: ${entry.fileName}`)}if(directory){await fs.mkdir(outputPath,{recursive:true})}else{await fs.mkdir(path.dirname(outputPath),{recursive:true})
|
|
5
|
+
;const input=await openEntryStream(zipFile,entry);await pipeline(input,createWriteStream(outputPath,{flags:"wx",mode:420}))}zipFile.readEntry()})().catch(fail)});zipFile.readEntry()})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import path from"node:path";import{fileURLToPath}from"node:url";const __dirname=path.dirname(fileURLToPath(import.meta.url));export function getRabetbaseCliPackageRoot(){return path.resolve(__dirname,"../../../../")}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import path from"node:path";import{formatElapsed}from"../../../commands/project/create/format-elapsed.js";import{logger}from"../../../utils/logger.js";import{materializeLocalProjectTemplate,materializeProjectTemplate}from"../../../commands/project/create/materialize-project-template.js";export async function copyProjectTemplate(projectCode,onProgress,templateSource){const start=Date.now();const projectDir=path.resolve(process.cwd(),projectCode);try{logger.info("copy","Starting project template creation",{projectCode:projectCode});const result=templateSource?await materializeLocalProjectTemplate(templateSource,projectDir,onProgress):await materializeProjectTemplate(projectDir,onProgress);const duration=Date.now()-start;logger.success("copy","Project template created",duration,{projectCode:projectCode,templateSource:result.source,templateVersion:result.version})}catch(error){const duration=Date.now()-start;logger.error("copy","Failed to copy project template",{projectCode:projectCode,
|
|
2
|
+
error:error instanceof Error?error.message:String(error),duration:duration});throw error}return formatElapsed(start)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import path from"node:path";import{execa}from"execa";import{formatElapsed}from"../../../commands/project/create/format-elapsed.js";import{logger}from"../../../utils/logger.js";import{resolveNpmBin}from"../../../utils/platform.js";export async function formatProjectCode(projectCode){const start=Date.now();const projectDir=path.resolve(process.cwd(),projectCode);try{logger.info("format","Starting code format",{projectCode:projectCode});await execa(resolveNpmBin("npx"),["prettier","--write","."],{cwd:projectDir});const duration=Date.now()-start;logger.success("format","Code format completed",duration,{projectCode:projectCode})}catch(error){const duration=Date.now()-start;logger.error("format","Code format failed",{projectCode:projectCode,error:error instanceof Error?error.message:String(error),duration:duration});throw error}return formatElapsed(start)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import path from"node:path";import{execa}from"execa";import{formatElapsed}from"../../../commands/project/create/format-elapsed.js";import{logger}from"../../../utils/logger.js";import{resolveNpmBin}from"../../../utils/platform.js";export async function installDependencies(projectCode){const start=Date.now();const projectDir=path.resolve(process.cwd(),projectCode);try{logger.info("install","Starting dependency install",{projectCode:projectCode});await execa(resolveNpmBin("npm"),["install"],{cwd:projectDir});const duration=Date.now()-start;logger.success("install","Dependency install completed",duration,{projectCode:projectCode})}catch(error){const duration=Date.now()-start;logger.error("install","Dependency install failed",{projectCode:projectCode,error:error instanceof Error?error.message:String(error),duration:duration});throw error}return formatElapsed(start)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";import{CLI_BIN_NAME}from"../../constant/cli.js";import{findProjectRootDirectory,resolveConfigPath}from"../../context/config-loader.js";import{writeProjectDomainRoutingManifest}from"../../config/project-domain-routing.js";export const projectDomainRoutingSyncDefinition={service:"project",command:"domain-routing-sync",description:"Synchronize the current project's public Domain routing",risk:"read",requiresAuth:false,requiresAppCode:false,hasFormat:true,flags:[],async execute(){const projectRoot=findProjectRootDirectory();if(!resolveConfigPath(projectRoot)){throw CliErrors.validation("No Rabetbase project configuration was found.",`Run ${CLI_BIN_NAME} workspace init --appcode <code> in the project directory first.`)}const result=writeProjectDomainRoutingManifest(projectRoot);return{ok:true,message:`Domain routing synchronized: ${result.path}`,data:result}}};
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";import{CLI_BIN_NAME}from"../../constant/cli.js";import{analyseProjectUpgrade,upgradeApp}from"../../commands/project/upgrade.js";import{projectDomainRoutingSyncDefinition}from"../../commands/project/domain-routing-sync.js";const createFlags=[{name:"name",type:"string",description:"Project name"},{name:"env",type:"string",description:"Target environment"},{name:"appcode",type:"string",description:"App code to bind (skips interactive selection)"},{name:"current-dir",type:"boolean",description:"Initialize the current empty directory instead of creating a child directory",default:false},{name:"template-source",type:"string",description:"Prepared local project template directory"}];const upgradeFlags=[{name:"yes",type:"boolean",description:"Skip confirmation prompt",default:false}];export const projectDefinitions=[{service:"project",command:"create",description:"Create a new project",risk:"write",requiresAuth:true,requiresAppCode:false,hasFormat:false,
|
|
2
|
+
args:[{name:"project-name",description:"Project code/name (optional, prompts if omitted)",required:false}],flags:createFlags,async execute(ctx){const{createApp:createApp}=await(import("../../commands/project/create/main.js"));const projectCode=ctx.str("name").trim()||ctx.args[0]?.trim();const env=ctx.str("env")||undefined;const appCode=ctx.str("appcode")||undefined;const templateSource=ctx.str("template-source").trim()||undefined;const currentDir=ctx.bool("current-dir");if(currentDir&&projectCode){throw CliErrors.validation("--current-dir cannot be combined with a project name.",`Run ${CLI_BIN_NAME} project create --current-dir [--appcode <code>] from the empty target directory.`)}if(ctx.nonInteractive){if(!projectCode&&!currentDir){throw CliErrors.validation("Non-interactive mode requires a project name.",`Usage: ${CLI_BIN_NAME} project create <project-name> [--appcode <code>] or ${CLI_BIN_NAME} project create --current-dir [--appcode <code>]`)}await createApp({
|
|
3
|
+
projectCode:projectCode,appCode:appCode,env:env,cookie:ctx.cookie,currentDir:currentDir,nonInteractive:true,templateSource:templateSource})}else{await createApp({projectCode:projectCode,appCode:appCode,env:env,cookie:ctx.cookie,currentDir:currentDir,templateSource:templateSource})}return{ok:true}}},projectDomainRoutingSyncDefinition,{service:"project",command:"upgrade",description:"Upgrade project dependencies and application source structure",risk:"write",requiresAuth:false,requiresAppCode:false,hasFormat:false,flags:upgradeFlags,async dryRun(){const analysis=analyseProjectUpgrade(process.cwd());return{method:"PATCH",url:process.cwd(),body:analysis,description:"Would upgrade project dependencies and application source structure without overwriting project-owned entrypoints"}},async execute(ctx){const result=await upgradeApp(ctx.nonInteractive,{yes:ctx.bool("yes")});return{ok:result.completed||result.cancelled===true,
|
|
4
|
+
message:result.cancelled?"Upgrade cancelled.":result.completed?"Project upgrade completed.":"Project upgrade completed with follow-up work.",data:result}}}];
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
(function(_0x1af83d,_0x271f7c){const _0x562c1c=a229_0x1200,_0x2ebb90=_0x1af83d();while(!![]){try{const _0x2c7067=parseInt(_0x562c1c(0x14d))/0x1+-parseInt(_0x562c1c(0x142))/0x2*(-parseInt(_0x562c1c(0x14a))/0x3)+parseInt(_0x562c1c(0x15b))/0x4+parseInt(_0x562c1c(0x159))/0x5+parseInt(_0x562c1c(0x15f))/0x6*(-parseInt(_0x562c1c(0x16e))/0x7)+-parseInt(_0x562c1c(0x16a))/0x8+parseInt(_0x562c1c(0x18a))/0x9;if(_0x2c7067===_0x271f7c)break;else _0x2ebb90['push'](_0x2ebb90['shift']());}catch(_0x44aa1b){_0x2ebb90['push'](_0x2ebb90['shift']());}}}(a229_0x2617,0x5ee99));import a229_0x23cf4a from'chalk';import a229_0x570ebe from'ora';import{existsSync,readFileSync,writeFileSync}from'node:fs';import{resolve}from'node:path';import{askConfirm}from'../../commands/menu/shared/inquirer.js';function a229_0x1200(_0x5b9e7b,_0xc958bd){_0x5b9e7b=_0x5b9e7b-0x13e;const _0x2617f7=a229_0x2617();let _0x120005=_0x2617f7[_0x5b9e7b];return _0x120005;}import{analyzeProjectApiArchitecture,upgradeProjectApiArchitecture}from'../../commands/project/api-architecture-upgrade.js';import{NEW_CONFIG_NAME}from'../../context.js';function readProjectConfig(_0x1d2755){const _0x2c582a=a229_0x1200;try{const _0x6123ac=JSON[_0x2c582a(0x143)](readFileSync(_0x1d2755,_0x2c582a(0x170)));return _0x6123ac&&typeof _0x6123ac===_0x2c582a(0x191)?_0x6123ac:{};}catch{return{};}}export function analyseProjectUpgrade(_0x583fa2){const _0x5a277b=a229_0x1200;let _0x523b39=null;const _0x25a7bf=resolve(_0x583fa2,_0x5a277b(0x186));if(existsSync(_0x25a7bf))try{const _0xeb1c02=JSON[_0x5a277b(0x143)](readFileSync(_0x25a7bf,_0x5a277b(0x170)));for(const _0x23c7dd of[_0x5a277b(0x18f),_0x5a277b(0x145)]){const _0x1e9671=_0xeb1c02?.[_0x23c7dd]?.[_0x5a277b(0x14b)];if(typeof _0x1e9671===_0x5a277b(0x173)){_0x1e9671!=='latest'&&(_0x523b39={'pkgPath':_0x25a7bf,'currentVersion':_0x1e9671,'field':_0x23c7dd});break;}}}catch{}const _0x17e5f=resolve(_0x583fa2,NEW_CONFIG_NAME),_0x281986=existsSync(_0x17e5f)?readProjectConfig(_0x17e5f):{},_0x2428fb=analyzeProjectApiArchitecture(_0x583fa2,_0x281986);return{'sdkUpgrade':_0x523b39,'apiArchitecture':_0x2428fb};}function printReport(_0x12bec1){const _0x42456f=a229_0x1200;console['log'](''),console[_0x42456f(0x168)](a229_0x23cf4a[_0x42456f(0x192)]('===\x20Upgrade\x20Analysis\x20===')),console[_0x42456f(0x168)](''),console[_0x42456f(0x168)](a229_0x23cf4a[_0x42456f(0x140)](_0x42456f(0x152))+('\x20\x20'+(_0x12bec1['apiArchitecture'][_0x42456f(0x16c)]?a229_0x23cf4a[_0x42456f(0x163)](_0x42456f(0x166)):a229_0x23cf4a[_0x42456f(0x162)](_0x42456f(0x148)))));for(const _0x2c69ae of _0x12bec1[_0x42456f(0x180)][_0x42456f(0x190)]){console['log']('\x20\x20'+_0x2c69ae['apiDir']+'\x20('+_0x2c69ae['profiles'][_0x42456f(0x16b)](',\x20')+')');for(const _0x3b6275 of _0x2c69ae[_0x42456f(0x16d)]){console[_0x42456f(0x168)](_0x42456f(0x17d)+_0x3b6275['action'][_0x42456f(0x150)](0x11)+'\x20'+_0x3b6275[_0x42456f(0x17b)]),_0x3b6275[_0x42456f(0x151)]&&console[_0x42456f(0x168)](_0x42456f(0x164)+_0x3b6275[_0x42456f(0x151)]);}}_0x12bec1['apiArchitecture'][_0x42456f(0x15c)][_0x42456f(0x174)]>0x0&&console[_0x42456f(0x168)]('\x20\x20Historical\x20ungrouped\x20multi-app\x20directories\x20keep\x20their\x20prefixed\x20API\x20files.');console[_0x42456f(0x168)]('');if(_0x12bec1['sdkUpgrade']){const {currentVersion:_0x198e4b,field:_0xe2b95f,pkgPath:_0x288698}=_0x12bec1[_0x42456f(0x16f)];console[_0x42456f(0x168)](a229_0x23cf4a['cyan'](_0x42456f(0x185))+('\x20\x20'+a229_0x23cf4a[_0x42456f(0x163)](_0x288698))),console[_0x42456f(0x168)](_0x42456f(0x176)+_0xe2b95f+':\x20'+a229_0x23cf4a[_0x42456f(0x163)](_0x198e4b)+_0x42456f(0x172)+a229_0x23cf4a[_0x42456f(0x162)]('latest')),console['log'](_0x42456f(0x165));}else console[_0x42456f(0x168)](a229_0x23cf4a[_0x42456f(0x140)](_0x42456f(0x185))+'\x20\x20'+a229_0x23cf4a[_0x42456f(0x18e)](_0x42456f(0x181)));console[_0x42456f(0x168)]('');}function execUpgradeSdk(_0x6d84e6){const _0x433809=a229_0x1200;if(!_0x6d84e6['sdkUpgrade'])return{'step':0x1,'label':_0x433809(0x183),'ok':!![],'detail':_0x433809(0x175)};const {pkgPath:_0x4de5c4,currentVersion:_0xabc21b,field:_0x409cda}=_0x6d84e6['sdkUpgrade'];try{const _0xa3b0f3=readFileSync(_0x4de5c4,'utf8'),_0x26068e=JSON[_0x433809(0x143)](_0xa3b0f3);return _0x26068e[_0x409cda][_0x433809(0x14b)]=_0x433809(0x15d),writeFileSync(_0x4de5c4,JSON[_0x433809(0x18b)](_0x26068e,null,0x2)+'\x0a',_0x433809(0x170)),{'step':0x1,'label':_0x433809(0x183),'ok':!![],'detail':_0x409cda+'[\x22@lovrabet/sdk\x22]:\x20'+_0xabc21b+_0x433809(0x156)};}catch(_0x113f75){return{'step':0x1,'label':'Upgrade\x20@lovrabet/sdk','ok':![],'detail':_0x113f75 instanceof Error?_0x113f75[_0x433809(0x157)]:String(_0x113f75)};}}function printSummary(_0x573b3a){const _0x5b8f9c=a229_0x1200;console[_0x5b8f9c(0x168)](''),console[_0x5b8f9c(0x168)](a229_0x23cf4a[_0x5b8f9c(0x192)]('===\x20Upgrade\x20Summary\x20===')),console[_0x5b8f9c(0x168)]('');for(const _0x4230f0 of _0x573b3a){const _0x41b478=_0x4230f0['ok']?a229_0x23cf4a[_0x5b8f9c(0x162)]('OK'):a229_0x23cf4a['red'](_0x5b8f9c(0x13f));console[_0x5b8f9c(0x168)]('\x20\x20'+_0x41b478+_0x5b8f9c(0x161)+_0x4230f0[_0x5b8f9c(0x147)]+':\x20'+_0x4230f0[_0x5b8f9c(0x14e)]);if(_0x4230f0[_0x5b8f9c(0x149)])console['log'](_0x5b8f9c(0x155)+a229_0x23cf4a['gray'](_0x4230f0[_0x5b8f9c(0x149)]));}console[_0x5b8f9c(0x168)]('');}export async function upgradeApp(_0x2d7223,_0x1783bb){const _0x22ef6f=a229_0x1200,_0x3143ef=process[_0x22ef6f(0x189)](),_0xb74e71=analyseProjectUpgrade(_0x3143ef);if(!_0xb74e71['sdkUpgrade']&&!_0xb74e71[_0x22ef6f(0x180)][_0x22ef6f(0x16c)])return console['log'](a229_0x23cf4a[_0x22ef6f(0x162)](_0x22ef6f(0x141))),{'analysis':_0xb74e71,'steps':[],'completed':!![]};printReport(_0xb74e71);const _0x38b092=!!(_0x1783bb[_0x22ef6f(0x158)]||_0x1783bb['Y']||_0x2d7223);if(!_0x38b092)try{const _0x4576a0=await askConfirm(_0x22ef6f(0x17f));if(!_0x4576a0)return console[_0x22ef6f(0x168)](a229_0x23cf4a[_0x22ef6f(0x18e)](_0x22ef6f(0x17e))),{'analysis':_0xb74e71,'steps':[],'completed':![],'cancelled':!![]};}catch(_0x372713){if(_0x372713?.[_0x22ef6f(0x157)]===_0x22ef6f(0x144))return console[_0x22ef6f(0x168)](a229_0x23cf4a['gray'](_0x22ef6f(0x17e))),{'analysis':_0xb74e71,'steps':[],'completed':![],'cancelled':!![]};throw _0x372713;}const _0x4c43bf=[],_0x1d4c44=a229_0x570ebe({'text':_0x22ef6f(0x177),'color':_0x22ef6f(0x140)})[_0x22ef6f(0x187)](),_0x172405=execUpgradeSdk(_0xb74e71);_0x4c43bf[_0x22ef6f(0x17c)](_0x172405),_0x1d4c44[_0x172405['ok']?_0x22ef6f(0x18c):_0x22ef6f(0x15a)](_0x22ef6f(0x178)+(_0x172405[_0x22ef6f(0x149)]??(_0x172405['ok']?_0x22ef6f(0x146):_0x22ef6f(0x15e))));const _0x53914f=a229_0x570ebe({'text':_0x22ef6f(0x17a),'color':_0x22ef6f(0x140)})[_0x22ef6f(0x187)]();let _0x1e192a;try{_0x1e192a=await upgradeProjectApiArchitecture(_0x3143ef);const _0x460903=_0x1e192a[_0x22ef6f(0x171)]?'candidate\x20entrypoints\x20written;\x20manual\x20merge\x20required':_0x22ef6f(0x154);_0x53914f['succeed']('Step\x202/2:\x20Application\x20source\x20—\x20'+_0x460903),_0x4c43bf[_0x22ef6f(0x17c)]({'step':0x2,'label':_0x22ef6f(0x167),'ok':!![],'detail':_0x460903});}catch(_0x1645ef){const _0x47f218=_0x1645ef instanceof Error?_0x1645ef[_0x22ef6f(0x157)]:String(_0x1645ef);_0x53914f[_0x22ef6f(0x15a)](_0x22ef6f(0x169)+_0x47f218),_0x4c43bf[_0x22ef6f(0x17c)]({'step':0x2,'label':_0x22ef6f(0x167),'ok':![],'detail':_0x47f218});}printSummary(_0x4c43bf);const _0x52a0ae=_0x4c43bf[_0x22ef6f(0x188)](_0x49a9e1=>!_0x49a9e1['ok']);if(_0x52a0ae)console[_0x22ef6f(0x168)](a229_0x23cf4a[_0x22ef6f(0x163)](_0x22ef6f(0x14f)));else _0x1e192a?.[_0x22ef6f(0x171)]?console[_0x22ef6f(0x168)](a229_0x23cf4a[_0x22ef6f(0x163)](_0x22ef6f(0x184))):console['log'](a229_0x23cf4a[_0x22ef6f(0x162)](_0x22ef6f(0x18d)));return _0x172405['ok']&&_0xb74e71[_0x22ef6f(0x16f)]&&(console[_0x22ef6f(0x168)](''),console[_0x22ef6f(0x168)](a229_0x23cf4a['bold'][_0x22ef6f(0x140)](_0x22ef6f(0x13e))),console['log'](a229_0x23cf4a[_0x22ef6f(0x140)](_0x22ef6f(0x14c))),console[_0x22ef6f(0x168)](''),console[_0x22ef6f(0x168)](a229_0x23cf4a['white'](_0x22ef6f(0x160))),console[_0x22ef6f(0x168)](a229_0x23cf4a[_0x22ef6f(0x179)](_0x22ef6f(0x182))),console[_0x22ef6f(0x168)](a229_0x23cf4a[_0x22ef6f(0x179)](_0x22ef6f(0x153))),console['log']('')),{'analysis':_0xb74e71,'steps':_0x4c43bf,'apiArchitecture':_0x1e192a,'completed':!_0x52a0ae&&!_0x1e192a?.['manualMergeRequired']};}function a229_0x2617(){const _0x1580b1=['Step\x202/2:\x20Application\x20source\x20—\x20','5377352daHSBH','join','needed','files','1393QAnIAt','sdkUpgrade','utf8','manualMergeRequired','\x20→\x20','string','length','skipped\x20(not\x20found\x20or\x20already\x20at\x20latest)','\x20\x20Current\x20version\x20in\x20','Step\x201/2:\x20Upgrading\x20@lovrabet/sdk\x20in\x20package.json...','Step\x201/2:\x20@lovrabet/sdk\x20—\x20','white','Step\x202/2:\x20Upgrading\x20application\x20source\x20structure...','path','push','\x20\x20\x20\x20','Upgrade\x20cancelled.','Proceed\x20with\x20upgrade?','apiArchitecture','not\x20found\x20or\x20already\x20at\x20latest','\x20\x20#\x20or','Upgrade\x20@lovrabet/sdk','Upgrade\x20candidates\x20were\x20written,\x20but\x20project-owned\x20source\x20files\x20still\x20require\x20manual\x20merging.','@lovrabet/sdk:','package.json','start','some','cwd','1356552EkZRNV','stringify','succeed','Upgrade\x20completed\x20successfully!','gray','dependencies','groups','object','bold','@lovrabet/sdk\x20has\x20been\x20updated\x20to\x20latest\x20in\x20package.json.','FAIL','cyan','Your\x20project\x20is\x20already\x20up-to-date.','114MNphht','parse','CANCEL','devDependencies','done','step','up-to-date','detail','8727lZGzCC','@lovrabet/sdk','Please\x20re-install\x20dependencies\x20to\x20apply\x20the\x20change:','334761oDnuuP','label','Some\x20steps\x20failed.\x20Check\x20the\x20summary\x20above\x20for\x20details.','padEnd','candidatePath','Application\x20source:','\x20\x20bun\x20install','source\x20structure\x20is\x20current','\x20\x20\x20\x20\x20\x20\x20','\x20→\x20latest','message','yes','3570025uFThpb','fail','930896YixRLH','skippedLegacyDirectories','latest','failed','16194ZdJIrG','\x20\x20npm\x20install','\x20\x20Step\x20','green','yellow','\x20\x20\x20\x20\x20\x20candidate:\x20','\x20\x20Action:\x20update\x20package.json\x20(you\x20will\x20need\x20to\x20re-run\x20install)','upgrade\x20needed','Upgrade\x20application\x20source','log'];a229_0x2617=function(){return _0x1580b1;};return a229_0x2617();}
|
|
1
|
+
import chalk from"chalk";import ora from"ora";import{existsSync,readFileSync,writeFileSync}from"node:fs";import{resolve}from"node:path";import{askConfirm}from"../../commands/menu/shared/inquirer.js";import{analyzeProjectApiArchitecture,upgradeProjectApiArchitecture}from"../../commands/project/api-architecture-upgrade.js";import{NEW_CONFIG_NAME}from"../../context.js";function readProjectConfig(filePath){try{const parsed=JSON.parse(readFileSync(filePath,"utf8"));return parsed&&typeof parsed==="object"?parsed:{}}catch{return{}}}export function analyseProjectUpgrade(cwd){let sdkUpgrade=null;const pkgPath=resolve(cwd,"package.json");if(existsSync(pkgPath)){try{const pkg=JSON.parse(readFileSync(pkgPath,"utf8"));for(const field of["dependencies","devDependencies"]){const version=pkg?.[field]?.["@lovrabet/sdk"];if(typeof version==="string"){if(version!=="latest"){sdkUpgrade={pkgPath:pkgPath,currentVersion:version,field:field}}break}}}catch{}}const configPath=resolve(cwd,NEW_CONFIG_NAME)
|
|
2
|
+
;const projectConfig=existsSync(configPath)?readProjectConfig(configPath):{};const apiArchitecture=analyzeProjectApiArchitecture(cwd,projectConfig);return{sdkUpgrade:sdkUpgrade,apiArchitecture:apiArchitecture}}function printReport(analysis){console.log("");console.log(chalk.bold("=== Upgrade Analysis ==="));console.log("");console.log(chalk.cyan("Application source:")+` ${analysis.apiArchitecture.needed?chalk.yellow("upgrade needed"):chalk.green("up-to-date")}`);for(const group of analysis.apiArchitecture.groups){console.log(` ${group.apiDir} (${group.profiles.join(", ")})`);for(const file of group.files){console.log(` ${file.action.padEnd(17)} ${file.path}`);if(file.candidatePath){console.log(` candidate: ${file.candidatePath}`)}}}if(analysis.apiArchitecture.skippedLegacyDirectories.length>0){console.log(" Historical ungrouped multi-app directories keep their prefixed API files.")}console.log("");if(analysis.sdkUpgrade){
|
|
3
|
+
const{currentVersion:currentVersion,field:field,pkgPath:pkgPath}=analysis.sdkUpgrade;console.log(chalk.cyan("@lovrabet/sdk:")+` ${chalk.yellow(pkgPath)}`);console.log(` Current version in ${field}: ${chalk.yellow(currentVersion)} → ${chalk.green("latest")}`);console.log(" Action: update package.json (you will need to re-run install)")}else{console.log(chalk.cyan("@lovrabet/sdk:")+" "+chalk.gray("not found or already at latest"))}console.log("")}function execUpgradeSdk(analysis){if(!analysis.sdkUpgrade){return{step:1,label:"Upgrade @lovrabet/sdk",ok:true,detail:"skipped (not found or already at latest)"}}const{pkgPath:pkgPath,currentVersion:currentVersion,field:field}=analysis.sdkUpgrade;try{const raw=readFileSync(pkgPath,"utf8");const pkg=JSON.parse(raw);pkg[field]["@lovrabet/sdk"]="latest";writeFileSync(pkgPath,JSON.stringify(pkg,null,2)+"\n","utf8");return{step:1,label:"Upgrade @lovrabet/sdk",ok:true,detail:`${field}["@lovrabet/sdk"]: ${currentVersion} → latest`}}catch(error){
|
|
4
|
+
return{step:1,label:"Upgrade @lovrabet/sdk",ok:false,detail:error instanceof Error?error.message:String(error)}}}function printSummary(results){console.log("");console.log(chalk.bold("=== Upgrade Summary ==="));console.log("");for(const result of results){const icon=result.ok?chalk.green("OK"):chalk.red("FAIL");console.log(` ${icon} Step ${result.step}: ${result.label}`);if(result.detail)console.log(` ${chalk.gray(result.detail)}`)}console.log("")}export async function upgradeApp(nonInteractive,flags){const cwd=process.cwd();const analysis=analyseProjectUpgrade(cwd);if(!analysis.sdkUpgrade&&!analysis.apiArchitecture.needed){console.log(chalk.green("Your project is already up-to-date."));return{analysis:analysis,steps:[],completed:true}}printReport(analysis);const skipConfirm=!!(flags.yes||flags.Y||nonInteractive);if(!skipConfirm){try{const confirmed=await askConfirm("Proceed with upgrade?");if(!confirmed){console.log(chalk.gray("Upgrade cancelled."));return{analysis:analysis,
|
|
5
|
+
steps:[],completed:false,cancelled:true}}}catch(error){if(error?.message==="CANCEL"){console.log(chalk.gray("Upgrade cancelled."));return{analysis:analysis,steps:[],completed:false,cancelled:true}}throw error}}const results=[];const sdkSpinner=ora({text:"Step 1/2: Upgrading @lovrabet/sdk in package.json...",color:"cyan"}).start();const sdkResult=execUpgradeSdk(analysis);results.push(sdkResult);sdkSpinner[sdkResult.ok?"succeed":"fail"](`Step 1/2: @lovrabet/sdk — ${sdkResult.detail??(sdkResult.ok?"done":"failed")}`);const sourceSpinner=ora({text:"Step 2/2: Upgrading application source structure...",color:"cyan"}).start();let apiArchitecture;try{apiArchitecture=await upgradeProjectApiArchitecture(cwd);const detail=apiArchitecture.manualMergeRequired?"candidate entrypoints written; manual merge required":"source structure is current";sourceSpinner.succeed(`Step 2/2: Application source — ${detail}`);results.push({step:2,label:"Upgrade application source",ok:true,detail:detail})
|
|
6
|
+
}catch(error){const detail=error instanceof Error?error.message:String(error);sourceSpinner.fail(`Step 2/2: Application source — ${detail}`);results.push({step:2,label:"Upgrade application source",ok:false,detail:detail})}printSummary(results);const hasFailure=results.some(result=>!result.ok);if(hasFailure){console.log(chalk.yellow("Some steps failed. Check the summary above for details."))}else if(apiArchitecture?.manualMergeRequired){console.log(chalk.yellow("Upgrade candidates were written, but project-owned source files still require manual merging."))}else{console.log(chalk.green("Upgrade completed successfully!"))}if(sdkResult.ok&&analysis.sdkUpgrade){console.log("");console.log(chalk.bold.cyan("@lovrabet/sdk has been updated to latest in package.json."));console.log(chalk.cyan("Please re-install dependencies to apply the change:"));console.log("");console.log(chalk.white(" npm install"));console.log(chalk.white(" # or"));console.log(chalk.white(" bun install"))
|
|
7
|
+
;console.log("")}return{analysis:analysis,steps:results,apiArchitecture:apiArchitecture,completed:!hasFailure&&!apiArchitecture?.manualMergeRequired}}
|
package/lib/commands/registry.js
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
const a230_0xf89c42=a230_0x2361;(function(_0x4edd3f,_0x120ca1){const _0x3598de=a230_0x2361,_0x586cbd=_0x4edd3f();while(!![]){try{const _0xacbf0d=parseInt(_0x3598de(0xe7))/0x1*(-parseInt(_0x3598de(0xe0))/0x2)+parseInt(_0x3598de(0xd9))/0x3*(parseInt(_0x3598de(0xe1))/0x4)+parseInt(_0x3598de(0x139))/0x5+-parseInt(_0x3598de(0x138))/0x6*(parseInt(_0x3598de(0xdf))/0x7)+-parseInt(_0x3598de(0x117))/0x8*(-parseInt(_0x3598de(0xd7))/0x9)+-parseInt(_0x3598de(0xdb))/0xa+-parseInt(_0x3598de(0xc9))/0xb;if(_0xacbf0d===_0x120ca1)break;else _0x586cbd['push'](_0x586cbd['shift']());}catch(_0x1ee91b){_0x586cbd['push'](_0x586cbd['shift']());}}}(a230_0xc703,0x78a2b));import{apiDefinitions}from'../commands/api/index.js';import{bffDefinitions}from'../commands/bff/index.js';import{sqlDefinitions}from'../commands/sql/index.js';import{datasetDefinitions}from'../commands/dataset/index.js';import{pageDefinitions}from'../commands/page/index.js';import{dbDefinitions}from'../commands/db/index.js';import{deploymentDefinitions}from'../commands/deployment/index.js';import{codegenDefinitions}from'../commands/codegen/index.js';import{menuDefinitions}from'../commands/menu/index.js';import{taskDefinitions}from'../commands/task/index.js';import{tenantDefinitions}from'../commands/tenant/index.js';import{roleDefinitions}from'../commands/role/index.js';import{appDefinitions}from'../commands/app/index.js';import{appConfigDefinitions}from'../commands/app-config/index.js';import{kbDefinitions}from'../commands/kb/index.js';import{ruleDefinitions}from'../commands/rule/index.js';import{notificationDefinitions}from'../commands/notification/index.js';import{instantApiPolicyDefinitions}from'../commands/instant-api-policy/index.js';import{workspaceDefinitions}from'../commands/workspace/index.js';import{configDefinitions}from'../commands/config/index.js';import{doctorDefinition}from'../commands/doctor.js';import{updateDefinition}from'../commands/cli-update.js';import{schemaDefinition}from'../commands/schema.js';import{issueDefinitions}from'../commands/issue/index.js';function a230_0x2361(_0x42ad1e,_0xd7cde6){_0x42ad1e=_0x42ad1e-0xc8;const _0xc703f1=a230_0xc703();let _0x23612a=_0xc703f1[_0x42ad1e];return _0x23612a;}import{fileDefinitions}from'../commands/file/index.js';import{ocrDefinitions}from'../commands/ocr/index.js';import{cliSkillDefinitions}from'../commands/cli-skill/index.js';import{userAccountDefinitions}from'../commands/user-account/index.js';import{flowDefinitions}from'../commands/flow/index.js';import{authDefinitions}from'../commands/auth/index.js';import{logsDefinitions}from'../commands/logs/index.js';import{projectDefinitions}from'../commands/project/index.js';import{runDefinition}from'../commands/run/index.js';export const serviceRegistry=[];const serviceByName=new Map();export const definitions=new Map();export const serviceGroups=new Map();function registerDefinitions(_0x32aa63){const _0x4fdd9b=a230_0x2361;for(const _0x4da679 of _0x32aa63){definitions[_0x4fdd9b(0xfc)](_0x4da679[_0x4fdd9b(0xfb)]+':'+_0x4da679[_0x4fdd9b(0xee)],_0x4da679);let _0x43519b=serviceGroups[_0x4fdd9b(0xf0)](_0x4da679[_0x4fdd9b(0xfb)]);!_0x43519b&&(_0x43519b=[],serviceGroups[_0x4fdd9b(0xfc)](_0x4da679['service'],_0x43519b)),_0x43519b[_0x4fdd9b(0xd4)](_0x4da679);}}function registerDeclarativeService(_0x5d04af,_0x5883c2,_0x34215c){const _0x40f11f=a230_0x2361;registerDefinitions(_0x5883c2);_0x34215c?.[_0x40f11f(0xea)]&®isterDefinitions([_0x34215c['wildcardDef']]);const _0x527cf3=_0x405ea=>_0x405ea===_0x40f11f(0x12f)?'':_0x405ea==='write'?_0x40f11f(0x137):_0x40f11f(0x13b),_0x401b45={'service':_0x5883c2[0x0]['service'],'label':_0x5d04af,'commands':_0x5883c2[_0x40f11f(0x116)](_0x124467=>!_0x124467[_0x40f11f(0x111)])['map'](_0x309d6e=>({'command':_0x309d6e[_0x40f11f(0xee)],'description':_0x309d6e['description'],'tag':_0x527cf3(_0x309d6e[_0x40f11f(0xff)])})),'declarative':!![],'defaultCommand':_0x34215c?.[_0x40f11f(0x126)]??(_0x34215c?.[_0x40f11f(0xda)]?_0x5883c2[0x0][_0x40f11f(0xee)]:undefined),'wildcardDef':_0x34215c?.['wildcardDef'],'isSingleCommand':_0x34215c?.[_0x40f11f(0xda)]};serviceRegistry['push'](_0x401b45),serviceByName[_0x40f11f(0xfc)](_0x401b45[_0x40f11f(0xfb)],_0x401b45);}registerDeclarativeService(a230_0xf89c42(0xf7),projectDefinitions),registerDeclarativeService(a230_0xf89c42(0xd8),workspaceDefinitions),registerDeclarativeService(a230_0xf89c42(0x100),appDefinitions),registerDeclarativeService(a230_0xf89c42(0xe5),authDefinitions,{'defaultCommand':a230_0xf89c42(0x108)}),registerDeclarativeService('Tenant\x20Members',tenantDefinitions),registerDeclarativeService(a230_0xf89c42(0x130),userAccountDefinitions),registerDeclarativeService(a230_0xf89c42(0x103),datasetDefinitions),registerDeclarativeService(a230_0xf89c42(0x135),pageDefinitions),registerDeclarativeService(a230_0xf89c42(0xd6),apiDefinitions),registerDeclarativeService('Backend\x20Function\x20Scripts',bffDefinitions),registerDeclarativeService(a230_0xf89c42(0x12b),instantApiPolicyDefinitions),registerDeclarativeService(a230_0xf89c42(0xf8),notificationDefinitions),registerDeclarativeService(a230_0xf89c42(0x110),sqlDefinitions),registerDeclarativeService(a230_0xf89c42(0x12e),dbDefinitions),registerDeclarativeService(a230_0xf89c42(0xf4),deploymentDefinitions),registerDeclarativeService(a230_0xf89c42(0xd1),menuDefinitions),registerDeclarativeService('Async\x20Tasks',taskDefinitions),registerDeclarativeService('Roles',roleDefinitions),registerDeclarativeService(a230_0xf89c42(0xcf),appConfigDefinitions),registerDeclarativeService(a230_0xf89c42(0xdc),kbDefinitions),registerDeclarativeService(a230_0xf89c42(0x123),ruleDefinitions),registerDeclarativeService(a230_0xf89c42(0x13d),issueDefinitions),registerDeclarativeService('File',fileDefinitions),registerDeclarativeService(a230_0xf89c42(0x120),ocrDefinitions),registerDeclarativeService('Code\x20Generation',codegenDefinitions),registerDeclarativeService(a230_0xf89c42(0x136),configDefinitions),registerDeclarativeService(a230_0xf89c42(0xf5),[doctorDefinition],{'isSingleCommand':!![]}),registerDeclarativeService(a230_0xf89c42(0xcb),[schemaDefinition],{'isSingleCommand':!![]}),registerDeclarativeService(a230_0xf89c42(0x11a),[updateDefinition],{'isSingleCommand':!![]}),registerDeclarativeService(a230_0xf89c42(0x129),cliSkillDefinitions,{'defaultCommand':a230_0xf89c42(0x11e)}),registerDeclarativeService('Approval\x20Flows',flowDefinitions),registerDeclarativeService(a230_0xf89c42(0x125),logsDefinitions,{'defaultCommand':a230_0xf89c42(0x13c)}),registerDeclarativeService(a230_0xf89c42(0xe9),[runDefinition],{'wildcardDef':runDefinition});{const last=serviceRegistry[serviceRegistry[a230_0xf89c42(0xce)]-0x1];last[a230_0xf89c42(0x112)]=[{'command':'<script>','description':a230_0xf89c42(0x109),'tag':a230_0xf89c42(0x124)+runDefinition[a230_0xf89c42(0xff)]+']'}];}function a230_0xc703(){const _0x1ae17d=['This\x20lifecycle\x20operation\x20is\x20no\x20longer\x20exposed\x20by\x20Rabetbase\x20CLI;\x20no\x20replacement\x20command\x20is\x20available.','Authentication','rabetbase\x20kb\x20delete','4426EbTHUK','rabetbase\x20dataset\x20design-start\x20--file\x20<manifest.json>','Run\x20Scripts','wildcardDef','permit:page-set','lovrabet\x20data\x20getOne\x20--code\x20<datasetCode>\x20--params\x20\x27{\x22id\x22:123}\x27','rabetbase\x20run\x20preview','command','Resource\x20saves\x20are\x20synchronized\x20automatically\x20by\x20the\x20server;\x20no\x20manual\x20CLI\x20replacement\x20is\x20required.','get','rabetbase\x20menu\x20subapp-assets-update\x20--appcode\x20<host-appcode>\x20--app-name\x20<name>\x20--resources\x20\x27<json>\x27','knowledge-base:update','permit:role-menus','Deployment','Diagnostics','app:assets-status','Project','Notification\x20Configuration','sql:save','app:remove','service','set','sql:new','page:react-update','risk','App\x20Management','No\x20executable\x20CLI\x20replacement\x20is\x20available\x20under\x20the\x20current\x20server\x20authentication\x20contract.','rabetbase\x20page\x20custom-update','Dataset\x20&\x20Operations','rabetbase\x20page\x20custom-publish','project:init','rabetbase\x20sql\x20create\x20--name\x20<name>\x20--db-id\x20<id>\x20--mode\x20sql|mybatisXml','rabetbase\x20kb\x20list','login','Run\x20any\x20package.json\x20script','page:react-publish','bff:new','rabetbase\x20run\x20build','`\x20has\x20been\x20removed.','rabetbase\x20menu\x20asset-update','from','SQL\x20Queries','hidden','commands','flow:disable','rabetbase\x20run\x20start','flow:enable','filter','13432zlEhiH','rabetbase\x20workspace\x20init\x20--appcode\x20<code>','permit:role-apis-set','Self\x20Update','knowledge-base:detail','logout','values','install','page:react-detail','OCR','rabetbase\x20cli-skill\x20install','rabetbase\x20project\x20create\x20<project-name>','Agent\x20Context\x20Rules','\x20\x20[','Logs','defaultCommand','knowledge-base:create','permit:page-get','CLI\x20Built-in\x20Skill','rabetbase\x20page\x20custom-detail','Instant\x20API\x20Policy','app:remote','rabetbase\x20page\x20create\x20--page-pattern\x20BLANK','Database\x20Connections','read','User\x20Accounts','deployment:sync','app:assets-update','lovrabet\x20data\x20filter\x20--code\x20<datasetCode>\x20--params\x20\x27<json>\x27','rabetbase\x20workspace\x20remove\x20<name>','Data\x20List\x20Pages\x20&\x20Custom\x20Pages','Configuration','\x20\x20[write]','6kqahfX','923035bvCJuv','has','\x20\x20[high-risk-write]','show','Platform\x20Issue','rabetbase\x20dataset\x20design-status\x20--operation-id\x20<id>','app:add','rabetbase\x20workspace\x20use\x20--app\x20<name>','1183963cUTwKK','rabetbase\x20kb\x20update','Schema','skill:','build','length','Runtime\x20App\x20Config\x20Management','Use\x20`','Menu','data:getOne','rabetbase\x20bff\x20create','push','skills:install','API\x20Development','747PbpfHu','Workspace','89685NQKDHF','isSingleCommand','2945040mCdyBi','Company\x20Knowledge\x20Base','page:react-create','rabetbase\x20kb\x20create','792351ovmkDm','82JyFmry','116noeAMo','role:create','page:standard-page-status'];a230_0xc703=function(){return _0x1ae17d;};return a230_0xc703();}const REMOVED_COMMAND_REPLACEMENTS=new Map([['dataset:generate-start',a230_0xf89c42(0xe8)],['dataset:generate-status',a230_0xf89c42(0x13e)],[a230_0xf89c42(0xf9),a230_0xf89c42(0x106)],[a230_0xf89c42(0x10b),a230_0xf89c42(0xd3)],[a230_0xf89c42(0xfd),'rabetbase\x20sql\x20create'],['menu:update',a230_0xf89c42(0x10e)],[a230_0xf89c42(0x105),a230_0xf89c42(0x118)],[a230_0xf89c42(0xcc),a230_0xf89c42(0x121)],['skill:install',a230_0xf89c42(0x121)],['skills:',a230_0xf89c42(0x121)],[a230_0xf89c42(0xd5),a230_0xf89c42(0x121)],[a230_0xf89c42(0xf6),'rabetbase\x20menu\x20subapp-assets-status\x20--appcode\x20<host-appcode>\x20--app-name\x20<name>'],[a230_0xf89c42(0x132),a230_0xf89c42(0xf1)],[a230_0xf89c42(0x12c),'rabetbase\x20app\x20list\x20--remote'],['app:use',a230_0xf89c42(0xc8)],[a230_0xf89c42(0x13f),'rabetbase\x20workspace\x20add\x20<name>\x20--appcode\x20<code>'],[a230_0xf89c42(0xfa),a230_0xf89c42(0x134)],['knowledge-base:list',a230_0xf89c42(0x107)],[a230_0xf89c42(0x11b),'rabetbase\x20kb\x20detail'],[a230_0xf89c42(0x127),a230_0xf89c42(0xde)],[a230_0xf89c42(0xf2),a230_0xf89c42(0xca)],['knowledge-base:delete',a230_0xf89c42(0xe6)],[a230_0xf89c42(0xe2),'rabetbase\x20role\x20list'],['data:filter',a230_0xf89c42(0x133)],[a230_0xf89c42(0xd2),a230_0xf89c42(0xec)],[a230_0xf89c42(0xe3),'rabetbase\x20page\x20data-list-status'],[a230_0xf89c42(0xdd),a230_0xf89c42(0x12d)],['page:custom-create','rabetbase\x20page\x20create\x20--page-pattern\x20BLANK'],['page:react-list','rabetbase\x20page\x20custom-list'],[a230_0xf89c42(0x11f),a230_0xf89c42(0x12a)],[a230_0xf89c42(0xfe),a230_0xf89c42(0x102)],[a230_0xf89c42(0x10a),a230_0xf89c42(0x104)]]),REMOVED_COMMAND_HINTS=new Map([[a230_0xf89c42(0x115),a230_0xf89c42(0xe4)],[a230_0xf89c42(0x113),a230_0xf89c42(0xe4)],[a230_0xf89c42(0x131),a230_0xf89c42(0xef)],[a230_0xf89c42(0x128),a230_0xf89c42(0x101)],[a230_0xf89c42(0xeb),a230_0xf89c42(0x101)],[a230_0xf89c42(0xf3),'No\x20executable\x20CLI\x20replacement\x20is\x20available\x20under\x20the\x20current\x20server\x20authentication\x20contract.'],['permit:role-menus-set',a230_0xf89c42(0x101)],[a230_0xf89c42(0x119),a230_0xf89c42(0x101)]]),REMOVED_FLAT_COMMAND_REPLACEMENTS=new Map([['create',a230_0xf89c42(0x122)],['start',a230_0xf89c42(0x114)],[a230_0xf89c42(0xcd),a230_0xf89c42(0x10c)],['preview',a230_0xf89c42(0xed)],[a230_0xf89c42(0x11c),'rabetbase\x20auth\x20logout']]);export function resolveRemovedCommand(_0x185bb8,_0x1da3cc){const _0x4b8353=a230_0xf89c42;if(!_0x185bb8)return undefined;const _0x1abbdf=REMOVED_COMMAND_REPLACEMENTS[_0x4b8353(0xf0)](_0x185bb8+':'+(_0x1da3cc??'')),_0x3b1bc6=REMOVED_FLAT_COMMAND_REPLACEMENTS['get'](_0x185bb8),_0x32b3f9=_0x1abbdf??_0x3b1bc6,_0x4be687=REMOVED_COMMAND_HINTS[_0x4b8353(0xf0)](_0x185bb8+':'+(_0x1da3cc??''));if(!_0x32b3f9&&!_0x4be687)return undefined;const _0x453e68=_0x3b1bc6?_0x185bb8:_0x1da3cc?_0x185bb8+'\x20'+_0x1da3cc:_0x185bb8;return{'command':_0x453e68,'message':'`rabetbase\x20'+_0x453e68+_0x4b8353(0x10d),'hint':_0x4be687??_0x4b8353(0xd0)+_0x32b3f9+'`\x20instead.'};}export function findDefinition(_0x247427,_0x1c53f7){const _0x1288fd=a230_0xf89c42;return definitions[_0x1288fd(0xf0)](_0x247427+':'+_0x1c53f7);}export function isKnownService(_0x74dec0){const _0x3ba158=a230_0xf89c42;return serviceByName[_0x3ba158(0x13a)](_0x74dec0);}export function isDeclarativeService(_0x3ec4eb){const _0x3284b4=a230_0xf89c42;return serviceGroups[_0x3284b4(0x13a)](_0x3ec4eb)||serviceByName[_0x3284b4(0xf0)](_0x3ec4eb)?.[_0x3284b4(0xea)]!==undefined;}export function getServiceEntry(_0x501b3d){const _0x132c3d=a230_0xf89c42;return serviceByName[_0x132c3d(0xf0)](_0x501b3d);}export function getLegacyHandler(_0x198ad6,_0x17b623){return undefined;}export function getAllDefinitions(){const _0x94e48=a230_0xf89c42;return Array[_0x94e48(0x10f)](definitions[_0x94e48(0x11d)]());}
|
|
1
|
+
import{apiDefinitions}from"../commands/api/index.js";import{bffDefinitions}from"../commands/bff/index.js";import{metricDefinitions}from"../commands/metric/index.js";import{sqlDefinitions}from"../commands/sql/index.js";import{datasetDefinitions}from"../commands/dataset/index.js";import{pageDefinitions}from"../commands/page/index.js";import{dbDefinitions}from"../commands/db/index.js";import{deploymentDefinitions}from"../commands/deployment/index.js";import{codegenDefinitions}from"../commands/codegen/index.js";import{menuDefinitions}from"../commands/menu/index.js";import{taskDefinitions}from"../commands/task/index.js";import{tenantDefinitions}from"../commands/tenant/index.js";import{roleDefinitions}from"../commands/role/index.js";import{appDefinitions}from"../commands/app/index.js";import{appConfigDefinitions}from"../commands/app-config/index.js";import{kbDefinitions}from"../commands/kb/index.js";import{ruleDefinitions}from"../commands/rule/index.js"
|
|
2
|
+
;import{notificationDefinitions}from"../commands/notification/index.js";import{instantApiPolicyDefinitions}from"../commands/instant-api-policy/index.js";import{workspaceDefinitions}from"../commands/workspace/index.js";import{configDefinitions}from"../commands/config/index.js";import{doctorDefinition}from"../commands/doctor.js";import{updateDefinition}from"../commands/cli-update.js";import{schemaDefinition}from"../commands/schema.js";import{issueDefinitions}from"../commands/issue/index.js";import{fileDefinitions}from"../commands/file/index.js";import{ocrDefinitions}from"../commands/ocr/index.js";import{cliSkillDefinitions}from"../commands/cli-skill/index.js";import{userAccountDefinitions}from"../commands/user-account/index.js";import{flowDefinitions}from"../commands/flow/index.js";import{authDefinitions}from"../commands/auth/index.js";import{logsDefinitions}from"../commands/logs/index.js";import{projectDefinitions}from"../commands/project/index.js"
|
|
3
|
+
;import{runDefinition}from"../commands/run/index.js";export const serviceRegistry=[];const serviceByName=new Map;export const definitions=new Map;export const serviceGroups=new Map;function registerDefinitions(defs){for(const def of defs){definitions.set(`${def.service}:${def.command}`,def);let group=serviceGroups.get(def.service);if(!group){group=[];serviceGroups.set(def.service,group)}group.push(def)}}function registerDeclarativeService(label,defs,opts){registerDefinitions(defs);if(opts?.wildcardDef){registerDefinitions([opts.wildcardDef])}const riskTag=r=>r==="read"?"":r==="write"?" [write]":" [high-risk-write]";const entry={service:defs[0].service,label:label,commands:defs.filter(d=>!d.hidden).map(d=>({command:d.command,description:d.description,tag:riskTag(d.risk)})),declarative:true,defaultCommand:opts?.defaultCommand??(opts?.isSingleCommand?defs[0].command:undefined),wildcardDef:opts?.wildcardDef,isSingleCommand:opts?.isSingleCommand};serviceRegistry.push(entry)
|
|
4
|
+
;serviceByName.set(entry.service,entry)}registerDeclarativeService("Project",projectDefinitions);registerDeclarativeService("Workspace",workspaceDefinitions);registerDeclarativeService("App Management",appDefinitions);registerDeclarativeService("Authentication",authDefinitions,{defaultCommand:"login"});registerDeclarativeService("Tenant Members",tenantDefinitions);registerDeclarativeService("User Accounts",userAccountDefinitions);registerDeclarativeService("Dataset & Operations",datasetDefinitions);registerDeclarativeService("Data List Pages & Custom Pages",pageDefinitions);registerDeclarativeService("API Development",apiDefinitions);registerDeclarativeService("Backend Function Scripts",bffDefinitions);registerDeclarativeService("Instant API Policy",instantApiPolicyDefinitions);registerDeclarativeService("Notification Configuration",notificationDefinitions);registerDeclarativeService("SQL Queries",sqlDefinitions);registerDeclarativeService("Application Metrics",metricDefinitions)
|
|
5
|
+
;registerDeclarativeService("Database Connections",dbDefinitions);registerDeclarativeService("Deployment",deploymentDefinitions);registerDeclarativeService("Menu",menuDefinitions);registerDeclarativeService("Async Tasks",taskDefinitions);registerDeclarativeService("Roles",roleDefinitions);registerDeclarativeService("Runtime App Config Management",appConfigDefinitions);registerDeclarativeService("Company Knowledge Base",kbDefinitions);registerDeclarativeService("Agent Context Rules",ruleDefinitions);registerDeclarativeService("Platform Issue",issueDefinitions);registerDeclarativeService("File",fileDefinitions);registerDeclarativeService("OCR",ocrDefinitions);registerDeclarativeService("Code Generation",codegenDefinitions);registerDeclarativeService("Configuration",configDefinitions);registerDeclarativeService("Diagnostics",[doctorDefinition],{isSingleCommand:true});registerDeclarativeService("Schema",[schemaDefinition],{isSingleCommand:true})
|
|
6
|
+
;registerDeclarativeService("Self Update",[updateDefinition],{isSingleCommand:true});registerDeclarativeService("CLI Built-in Skill",cliSkillDefinitions,{defaultCommand:"install"});registerDeclarativeService("Approval Flows",flowDefinitions);registerDeclarativeService("Logs",logsDefinitions,{defaultCommand:"show"});registerDeclarativeService("Run Scripts",[runDefinition],{wildcardDef:runDefinition});{const last=serviceRegistry[serviceRegistry.length-1];last.commands=[{command:"<script>",description:"Run any package.json script",tag:` [${runDefinition.risk}]`}]}
|
|
7
|
+
const REMOVED_COMMAND_REPLACEMENTS=new Map([["dataset:generate-start","rabetbase dataset design-start --file <manifest.json>"],["dataset:generate-status","rabetbase dataset design-status --operation-id <id>"],["sql:save","rabetbase sql create --name <name> --db-id <id> --mode sql|mybatisXml"],["bff:new","rabetbase bff create"],["sql:new","rabetbase sql create"],["menu:update","rabetbase menu asset-update"],["project:init","rabetbase workspace init --appcode <code>"],["skill:","rabetbase cli-skill install"],["skill:install","rabetbase cli-skill install"],["skills:","rabetbase cli-skill install"],["skills:install","rabetbase cli-skill install"],["app:assets-status","rabetbase menu subapp-assets-status --appcode <host-appcode> --app-name <name>"],["app:assets-update","rabetbase menu subapp-assets-update --appcode <host-appcode> --app-name <name> --resources '<json>'"],["app:remote","rabetbase app list --remote"],["app:use","rabetbase workspace use --app <name>"],["app:add","rabetbase workspace add <name> --appcode <code>"],["app:remove","rabetbase workspace remove <name>"],["knowledge-base:list","rabetbase kb list"],["knowledge-base:detail","rabetbase kb detail"],["knowledge-base:create","rabetbase kb create"],["knowledge-base:update","rabetbase kb update"],["knowledge-base:delete","rabetbase kb delete"],["role:create","rabetbase role list"],["data:filter","lovrabet data filter --code <datasetCode> --params '<json>'"],["data:getOne","lovrabet data getOne --code <datasetCode> --params '{\"id\":123}'"],["page:standard-page-status","rabetbase page data-list-status"],["page:react-create","rabetbase page create --page-pattern BLANK"],["page:custom-create","rabetbase page create --page-pattern BLANK"],["page:react-list","rabetbase page custom-list"],["page:react-detail","rabetbase page custom-detail"],["page:react-update","rabetbase page custom-update"],["page:react-publish","rabetbase page custom-publish"]])
|
|
8
|
+
;const REMOVED_COMMAND_HINTS=new Map([["flow:enable","This lifecycle operation is no longer exposed by Rabetbase CLI; no replacement command is available."],["flow:disable","This lifecycle operation is no longer exposed by Rabetbase CLI; no replacement command is available."],["deployment:sync","Resource saves are synchronized automatically by the server; no manual CLI replacement is required."],["permit:page-get","No executable CLI replacement is available under the current server authentication contract."],["permit:page-set","No executable CLI replacement is available under the current server authentication contract."],["permit:role-menus","No executable CLI replacement is available under the current server authentication contract."],["permit:role-menus-set","No executable CLI replacement is available under the current server authentication contract."],["permit:role-apis-set","No executable CLI replacement is available under the current server authentication contract."]])
|
|
9
|
+
;const REMOVED_FLAT_COMMAND_REPLACEMENTS=new Map([["create","rabetbase project create <project-name>"],["start","rabetbase run start"],["build","rabetbase run build"],["preview","rabetbase run preview"],["logout","rabetbase auth logout"]]);export function resolveRemovedCommand(service,command){if(!service)return undefined;const exactReplacement=REMOVED_COMMAND_REPLACEMENTS.get(`${service}:${command??""}`);const flatReplacement=REMOVED_FLAT_COMMAND_REPLACEMENTS.get(service);const replacement=exactReplacement??flatReplacement;const exactHint=REMOVED_COMMAND_HINTS.get(`${service}:${command??""}`);if(!replacement&&!exactHint)return undefined;const commandLabel=flatReplacement?service:command?`${service} ${command}`:service;return{command:commandLabel,message:`\`rabetbase ${commandLabel}\` has been removed.`,hint:exactHint??`Use \`${replacement}\` instead.`}}export function findDefinition(service,command){return definitions.get(`${service}:${command}`)}export function isKnownService(name){
|
|
10
|
+
return serviceByName.has(name)}export function isDeclarativeService(name){return serviceGroups.has(name)||serviceByName.get(name)?.wildcardDef!==undefined}export function getServiceEntry(name){return serviceByName.get(name)}export function getLegacyHandler(_service,_command){return undefined}export function getAllDefinitions(){return Array.from(definitions.values())}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{deleteAppRole}from"../../core/api-client.js";import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{asDryRunResult}from"../../commands/common/dry-run.js";import{assertCustomRole,getRoleById,projectRole,ROLE_ID_FLAG}from"../../commands/role/shared.js";const DELETE_PATH="/smartapi/permit/role/delete";export const roleDelete={service:"role",command:"delete",description:"Delete a CUSTOM role (built-in roles rejected); requires --yes",risk:"high-risk-write",flags:[ROLE_ID_FLAG,APPCODE_FLAG_OPTIONAL],async dryRun(ctx){const id=ctx.num("id");const before=await getRoleById(ctx.appCode,id);assertCustomRole(before,"delete");return asDryRunResult({scope:"dev",operation:"delete",selector:{appCode:ctx.appCode,roleId:id,roleName:before.roleName},before:projectRole(before),after:null,dryRun:true,backend:{method:"POST",path:DELETE_PATH},warnings:before.userCount>0?[`Role still has ${before.userCount} member(s); they will lose this group.`]:[]},{method:"POST",url:DELETE_PATH})
|
|
2
|
+
},async execute(ctx){const id=ctx.num("id");const before=await getRoleById(ctx.appCode,id);assertCustomRole(before,"delete");await deleteAppRole(id);return{ok:true,data:{scope:"dev",operation:"delete",selector:{appCode:ctx.appCode,roleId:id,roleName:before.roleName},before:projectRole(before),after:null,dryRun:false,backend:{method:"POST",path:DELETE_PATH},warnings:[]},message:`Deleted role ${before.roleName} (id=${id})`}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{getRoleById,projectRole,ROLE_ID_FLAG}from"../../commands/role/shared.js";export const roleDetail={service:"role",command:"detail",description:"Show a single role's detail",risk:"read",flags:[ROLE_ID_FLAG,APPCODE_FLAG_OPTIONAL],async execute(ctx){const id=ctx.num("id");const role=await getRoleById(ctx.appCode,id);return{ok:true,data:{scope:"dev",role:projectRole(role)},message:`Role ${role.roleName} (${role.roleType})`}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{roleList}from"../../commands/role/list.js";import{roleDetail}from"../../commands/role/detail.js";import{roleUpdate}from"../../commands/role/update.js";import{roleDelete}from"../../commands/role/delete.js";import{roleUserResolve}from"../../commands/role/user-resolve.js";import{roleUserAdd}from"../../commands/role/user-add.js";import{roleUserRemove}from"../../commands/role/user-remove.js";export const roleDefinitions=[roleList,roleDetail,roleUpdate,roleDelete,roleUserResolve,roleUserAdd,roleUserRemove];
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{listAppRoles}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{projectRole}from"../../commands/role/shared.js";const ROLE_TYPES=["ADMIN","DEV","OWNER","CUSTOM"];export const roleList={service:"role",command:"list",description:"List user groups (roles) for the current app",risk:"read",flags:[APPCODE_FLAG_OPTIONAL,{name:"type",type:"string",required:false,description:"Filter by role type",enum:ROLE_TYPES},{name:"page",type:"number",description:"Page index (1-based)",default:1},{name:"pagesize",type:"number",description:"Page size (1-100)",default:100}],async validate(ctx){const type=ctx.str("type").trim();if(type&&!ROLE_TYPES.includes(type.toUpperCase())){throw CliErrors.validation(`Invalid --type "${type}".`,`Use one of: ${ROLE_TYPES.join(", ")}.`)}const page=ctx.num("page",1);const pageSize=ctx.num("pagesize",100);if(page<1){
|
|
2
|
+
throw CliErrors.validation("--page must be greater than or equal to 1.")}if(pageSize<1||pageSize>100){throw CliErrors.validation("--pagesize must be between 1 and 100.")}},async execute(ctx){const page=ctx.num("page",1)||1;const pageSize=ctx.num("pagesize",100)||100;const type=ctx.str("type").trim().toUpperCase();const{items:items,paging:paging}=await listAppRoles(ctx.appCode,{currentPage:page,pageSize:pageSize});const filtered=type?items.filter(r=>r.roleType===type):items;const roles=filtered.map(projectRole);return{ok:true,data:{scope:"dev",roles:roles,paging:paging},message:`Found ${roles.length} role(s)`}}};
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
const a235_0x18cccf=a235_0x55ea;function a235_0x2714(){const _0x15c2c2=['username','totalCount','Optional\x20role\x20remark/description','Role\x20id\x20','Role\x20id\x20(from\x20`role\x20list`)','Removed\x20','userId','roleType','authRequired','\x20duplicate\x20memberships\x20for\x20user\x20',';\x20no\x20change.','nickname','validation','expect-user-count','Cannot\x20','Missing\x20user\x20reference.','Role\x20id\x20or\x20exact\x20role\x20name','join','includes','Pass\x20--role\x20<id|name>.','16028FzSYDS','Nickname\x20or\x20username\x20to\x20resolve\x20to\x20a\x20userId','name','userCount','Role\x20name','User\x20','appCode','DEV','245kbPClG','\x20not\x20found\x20in\x20app\x20','length','\x22\x20not\x20found\x20in\x20app\x20','/smartapi/permit/user-role/create','Pass\x20--user\x20<id|name>.','Disambiguate\x20with\x20--role\x20<id>.','121286ANUZFx','ADMIN','map','Check\x20the\x20nickname/username.\x20','push','Run\x20`role\x20list`\x20to\x20see\x20available\x20roles,\x20or\x20pass\x20--role\x20<id>.','str','toLowerCase','number','14367240wPvPDv','Run\x20`role\x20list`\x20to\x20see\x20available\x20roles.','User\x20id,\x20username,\x20or\x20nickname\x20to\x20resolve\x20to\x20a\x20userId','user-add','remark','CUSTOM','filter','/smartapi/permit/user-role/delete','dev','tenant','\x22\x20is\x20ambiguous\x20(ids:\x20','36glThuY','Missing\x20role\x20reference.','Re-run\x20`role\x20detail`\x20/\x20`role\x20list`\x20and\x20retry\x20with\x20the\x20current\x20count.','trim','test','\x20is\x20already\x20a\x20member\x20of\x20role\x20','OWNER','user','3088848hzBjjI','Anti-drift\x20guard:\x20fail\x20if\x20the\x20role\x27s\x20current\x20member\x20count\x20differs','\x22:\x20','\x20is\x20not\x20a\x20member\x20of\x20role\x20','\x20members\x20of\x20the\x20OWNER\x20role.','flag','Role\x20name\x20\x22','Anti-drift\x20check\x20failed:\x20expected\x20','No\x20tenant\x20member\x20matches\x20\x22','string','roleName','194356DHrufv','Only\x20CUSTOM\x20roles\x20can\x20be\x20modified\x20or\x20deleted.','2248112kpApVv','role','Multiple\x20tenant\x20members\x20match\x20\x22','permitCount','tenant_code','3480750HYBluX','flagMissing'];a235_0x2714=function(){return _0x15c2c2;};return a235_0x2714();}(function(_0x33114b,_0x4841f6){const _0x2d9823=a235_0x55ea,_0x4fd3fc=_0x33114b();while(!![]){try{const _0x209383=-parseInt(_0x2d9823(0xc2))/0x1+parseInt(_0x2d9823(0xee))/0x2*(parseInt(_0x2d9823(0x102))/0x3)+-parseInt(_0x2d9823(0xdf))/0x4*(-parseInt(_0x2d9823(0xe7))/0x5)+parseInt(_0x2d9823(0xb7))/0x6+parseInt(_0x2d9823(0xc9))/0x7+parseInt(_0x2d9823(0xc4))/0x8+-parseInt(_0x2d9823(0xf7))/0x9;if(_0x209383===_0x4841f6)break;else _0x4fd3fc['push'](_0x4fd3fc['shift']());}catch(_0x165619){_0x4fd3fc['push'](_0x4fd3fc['shift']());}}}(a235_0x2714,0x681af));import{getTenantMembers,listDevUserRoleRelations,listAppRoles}from'../../core/api-client.js';import{getSessionUserInfo}from'../../auth/get-session-user.js';import{CliErrors}from'../../errors.js';export const ROLE_ID_FLAG={'name':'id','type':a235_0x18cccf(0xf6),'required':!![],'description':a235_0x18cccf(0xcf)};export const ROLE_REF_FLAG={'name':a235_0x18cccf(0xc5),'type':a235_0x18cccf(0xc0),'required':!![],'description':a235_0x18cccf(0xdb)};export const USER_REF_FLAG={'name':a235_0x18cccf(0xb6),'type':a235_0x18cccf(0xc0),'required':!![],'description':a235_0x18cccf(0xf9)};export const NAME_FLAG={'name':a235_0x18cccf(0xe1),'type':a235_0x18cccf(0xc0),'required':!![],'description':a235_0x18cccf(0xe3)};export const USER_NAME_FLAG={'name':'name','type':a235_0x18cccf(0xc0),'required':!![],'description':a235_0x18cccf(0xe0)};export const REMARK_FLAG={'name':'remark','type':a235_0x18cccf(0xc0),'required':![],'description':a235_0x18cccf(0xcd)};export const EXPECT_USER_COUNT_FLAG={'name':a235_0x18cccf(0xd8),'type':'number','required':![],'description':a235_0x18cccf(0xb8)};export const BUILTIN_ROLE_TYPES=[a235_0x18cccf(0xef),a235_0x18cccf(0xe6),a235_0x18cccf(0xb5)];export function isBuiltinRole(_0xc0e65e){const _0xb535a1=a235_0x18cccf;return BUILTIN_ROLE_TYPES[_0xb535a1(0xdd)](_0xc0e65e);}export function assertCustomRole(_0x439acb,_0x367c1d){const _0x327d3b=a235_0x18cccf;if(_0x439acb[_0x327d3b(0xd2)]!==_0x327d3b(0xfc))throw CliErrors[_0x327d3b(0xd7)](_0x327d3b(0xd9)+_0x367c1d+'\x20built-in\x20role\x20'+_0x439acb[_0x327d3b(0xc1)]+'\x20('+_0x439acb['roleType']+').',_0x327d3b(0xc3));}export function projectRole(_0x5a6bf4){const _0xbfc086=a235_0x18cccf;return{'id':_0x5a6bf4['id'],'roleName':_0x5a6bf4[_0xbfc086(0xc1)],'roleType':_0x5a6bf4[_0xbfc086(0xd2)],'remark':_0x5a6bf4[_0xbfc086(0xfb)],'userCount':_0x5a6bf4[_0xbfc086(0xe2)],'permitCount':_0x5a6bf4[_0xbfc086(0xc7)],'builtin':isBuiltinRole(_0x5a6bf4[_0xbfc086(0xd2)])};}export async function resolveRoleRef(_0x4902a6,_0x50c9f3){const _0x22addf=a235_0x18cccf,_0x381eb5=_0x50c9f3[_0x22addf(0x105)]();if(!_0x381eb5)throw CliErrors['validation'](_0x22addf(0x103),'Pass\x20--role\x20<id|name>.');if(/^\d+$/[_0x22addf(0x106)](_0x381eb5))return getRoleById(_0x4902a6,Number(_0x381eb5));const _0x37e053=await listAllAppRoles(_0x4902a6),_0x47e2cb=_0x37e053['filter'](_0x32b4d4=>_0x32b4d4['roleName']===_0x381eb5);if(_0x47e2cb[_0x22addf(0xe9)]===0x0)throw CliErrors[_0x22addf(0xd7)](_0x22addf(0xbd)+_0x381eb5+_0x22addf(0xea)+_0x4902a6+'.',_0x22addf(0xf3));if(_0x47e2cb['length']>0x1){const _0x4740fd=_0x47e2cb[_0x22addf(0xf0)](_0x43bd2b=>_0x43bd2b['id'])[_0x22addf(0xdc)](',\x20');throw CliErrors[_0x22addf(0xd7)](_0x22addf(0xbd)+_0x381eb5+_0x22addf(0x101)+_0x4740fd+').',_0x22addf(0xed));}return _0x47e2cb[0x0];}export async function getRoleById(_0x134042,_0x31b939){const _0x2c4c71=a235_0x18cccf,_0x5cf222=await listAllAppRoles(_0x134042),_0x353813=_0x5cf222[_0x2c4c71(0xfd)](_0x23d773=>_0x23d773['id']===_0x31b939&&(!_0x23d773[_0x2c4c71(0xe5)]||_0x23d773[_0x2c4c71(0xe5)]===_0x134042));if(_0x353813[_0x2c4c71(0xe9)]!==0x1)throw CliErrors[_0x2c4c71(0xd7)](_0x2c4c71(0xce)+_0x31b939+_0x2c4c71(0xe8)+_0x134042+'.',_0x2c4c71(0xf8));return _0x353813[0x0];}async function listAllAppRoles(_0x302988){const _0x1b7c34=a235_0x18cccf,_0x5ae4cd=0x64,_0x4da93e=[];for(let _0x49f67e=0x1;;_0x49f67e+=0x1){const {items:_0x545112,paging:_0x5ecbc3}=await listAppRoles(_0x302988,{'currentPage':_0x49f67e,'pageSize':_0x5ae4cd});_0x4da93e[_0x1b7c34(0xf2)](..._0x545112);if(_0x545112[_0x1b7c34(0xe9)]<_0x5ae4cd||_0x5ecbc3&&_0x4da93e[_0x1b7c34(0xe9)]>=_0x5ecbc3[_0x1b7c34(0xcc)])return _0x4da93e;}}export async function resolveTenantCode(){const _0x32f656=a235_0x18cccf,_0x1b3a9b=await getSessionUserInfo(),_0x3a2631=_0x1b3a9b?.[_0x32f656(0xb6)]?.[_0x32f656(0x100)]?.[_0x32f656(0xc8)];if(!_0x3a2631)throw CliErrors[_0x32f656(0xd3)]('Cannot\x20resolve\x20current\x20tenant.\x20Run\x20`rabetbase\x20auth\x20login`\x20first.');return _0x3a2631;}function matchMember(_0x21618e,_0x30c9a6){const _0x519d98=a235_0x18cccf,_0x16ea86=_0x30c9a6['trim']()['toLowerCase']();return(_0x21618e['nickname']??'')[_0x519d98(0xf5)]()===_0x16ea86||(_0x21618e[_0x519d98(0xcb)]??'')[_0x519d98(0xf5)]()===_0x16ea86;}export async function resolveUserRef(_0x288b6b,_0x41b655='Pass\x20--user\x20<id>.'){const _0x4665a0=a235_0x18cccf,_0x44b2fa=_0x288b6b[_0x4665a0(0x105)]();if(!_0x44b2fa)throw CliErrors[_0x4665a0(0xd7)](_0x4665a0(0xda),'Pass\x20--user\x20<id|name>.');const _0x15803b=await resolveTenantCode(),_0x7f3297=await getTenantMembers(_0x15803b);if(/^\d+$/['test'](_0x44b2fa)){const _0x482872=Number(_0x44b2fa),_0x52d766=_0x7f3297['find'](_0x4ded4a=>_0x4ded4a['userId']===_0x482872);return{'userId':_0x482872,'username':_0x52d766?.[_0x4665a0(0xcb)]??String(_0x482872),'nickname':_0x52d766?.['nickname'],'matchedBy':'id'};}const _0x4d64eb=_0x7f3297[_0x4665a0(0xfd)](_0xb4e5a8=>matchMember(_0xb4e5a8,_0x44b2fa));if(_0x4d64eb[_0x4665a0(0xe9)]===0x0)throw CliErrors[_0x4665a0(0xd7)](_0x4665a0(0xbf)+_0x44b2fa+'\x22.',_0x4665a0(0xf1)+_0x41b655);if(_0x4d64eb[_0x4665a0(0xe9)]>0x1){const _0x663e89=_0x4d64eb[_0x4665a0(0xf0)](_0x1ddb8f=>(_0x1ddb8f[_0x4665a0(0xd6)]??_0x1ddb8f[_0x4665a0(0xcb)]??'?')+'('+_0x1ddb8f[_0x4665a0(0xd1)]+')')['join'](',\x20');throw CliErrors['validation'](_0x4665a0(0xc6)+_0x44b2fa+_0x4665a0(0xb9)+_0x663e89+'.',_0x41b655);}const _0xdaad72=_0x4d64eb[0x0];return{'userId':_0xdaad72[_0x4665a0(0xd1)],'username':_0xdaad72['username']??String(_0xdaad72['userId']),'nickname':_0xdaad72['nickname'],'matchedBy':_0x4665a0(0xe1)};}export const CREATE_USER_ROLE_PATH=a235_0x18cccf(0xeb);export const DELETE_USER_ROLE_PATH=a235_0x18cccf(0xfe);export function computeRoleUserMutation(_0x54fdf8){const _0x2e1081=a235_0x18cccf,{operation:_0x4ea097,appCode:_0x5df8d0,role:_0x443367,relations:_0x430dd5,user:_0xc9d420}=_0x54fdf8,_0x289617=[...new Set(_0x430dd5[_0x2e1081(0xf0)](_0x36a321=>_0x36a321[_0x2e1081(0xd1)]))],_0x4d056d=[];if(_0x54fdf8['expectUserCount']!==undefined&&_0x54fdf8['expectUserCount']!==_0x289617['length'])throw CliErrors[_0x2e1081(0xd7)](_0x2e1081(0xbe)+_0x54fdf8['expectUserCount']+'\x20member(s)\x20but\x20role\x20has\x20'+_0x289617['length']+'.',_0x2e1081(0x104));const _0x23633b=_0x289617[_0x2e1081(0xdd)](_0xc9d420['userId']),_0x5430e6=_0x430dd5['filter'](_0x2ab7d3=>_0x2ab7d3[_0x2e1081(0xd1)]===_0xc9d420['userId'])[_0x2e1081(0xf0)](_0x17fb8e=>_0x17fb8e['id']),_0x2cd77b=_0x4ea097===_0x2e1081(0xfa)?!_0x23633b:_0x23633b;let _0x58af32=_0x289617;_0x4ea097==='user-add'?_0x23633b?_0x4d056d['push']('User\x20'+_0xc9d420[_0x2e1081(0xd1)]+_0x2e1081(0xb4)+_0x443367[_0x2e1081(0xc1)]+_0x2e1081(0xd5)):_0x58af32=[..._0x289617,_0xc9d420['userId']]:!_0x23633b?_0x4d056d[_0x2e1081(0xf2)](_0x2e1081(0xe4)+_0xc9d420['userId']+_0x2e1081(0xba)+_0x443367['roleName']+_0x2e1081(0xd5)):(_0x58af32=_0x289617['filter'](_0x31a4c3=>_0x31a4c3!==_0xc9d420[_0x2e1081(0xd1)]),_0x5430e6['length']>0x1&&_0x4d056d[_0x2e1081(0xf2)](_0x2e1081(0xd0)+_0x5430e6[_0x2e1081(0xe9)]+_0x2e1081(0xd4)+_0xc9d420['userId']+'.'));const _0x3259dd={'scope':_0x2e1081(0xff),'operation':_0x4ea097,'selector':{'appCode':_0x5df8d0,'roleId':_0x443367['id'],'roleName':_0x443367['roleName'],'userId':_0xc9d420['userId']},'before':{'userIds':_0x289617},'after':{'userIds':_0x58af32},'dryRun':_0x54fdf8['dryRun'],'backend':{'method':'POST','path':_0x4ea097===_0x2e1081(0xfa)?CREATE_USER_ROLE_PATH:DELETE_USER_ROLE_PATH},'warnings':_0x4d056d};return{'mutation':_0x3259dd,'changed':_0x2cd77b,'matchingRelationIds':_0x5430e6};}export async function loadDevRoleRelations(_0x32a331,_0x430072){const _0x3f80eb=a235_0x18cccf,_0x2990b5=0x64,_0x3ffde7=[];for(let _0x4001c6=0x1;;_0x4001c6+=0x1){const {items:_0x5d15cf,paging:_0x3ceda8}=await listDevUserRoleRelations(_0x32a331,{'roleId':_0x430072,'currentPage':_0x4001c6,'pageSize':_0x2990b5});_0x3ffde7[_0x3f80eb(0xf2)](..._0x5d15cf);if(_0x5d15cf[_0x3f80eb(0xe9)]<_0x2990b5||_0x3ceda8&&_0x3ffde7[_0x3f80eb(0xe9)]>=_0x3ceda8[_0x3f80eb(0xcc)])return _0x3ffde7;}}function a235_0x55ea(_0x1702c7,_0x4ccec1){_0x1702c7=_0x1702c7-0xb4;const _0x271493=a235_0x2714();let _0x55ea65=_0x271493[_0x1702c7];return _0x55ea65;}export function readRoleRef(_0x5e252){const _0x296031=a235_0x18cccf,_0x18f419=_0x5e252['str']('role')[_0x296031(0x105)]();if(!_0x18f419)throw CliErrors[_0x296031(0xca)]('role',_0x296031(0xde));return _0x18f419;}export async function prepareUserMutation(_0x178054,_0x30de4d,_0x1276f6){const _0x35fed2=a235_0x18cccf,_0x20468f=readRoleRef(_0x178054),_0x54449c=_0x178054[_0x35fed2(0xf4)](_0x35fed2(0xb6))['trim']();if(!_0x54449c)throw CliErrors['flagMissing'](_0x35fed2(0xb6),_0x35fed2(0xec));const _0x49c19e=_0x178054[_0x35fed2(0xbc)](_0x35fed2(0xd8)),_0x4dc37b=_0x49c19e===undefined||_0x49c19e===null?undefined:Number(_0x49c19e),_0x44fcf7=await resolveRoleRef(_0x178054['appCode'],_0x20468f);if(_0x44fcf7[_0x35fed2(0xd2)]===_0x35fed2(0xb5))throw CliErrors[_0x35fed2(0xd7)](_0x35fed2(0xd9)+_0x30de4d+_0x35fed2(0xbb),'Use\x20the\x20platform\x20ownership-transfer\x20workflow\x20to\x20change\x20the\x20application\x20owner.');const _0x14c100=await resolveUserRef(_0x54449c),_0x2702a1=await loadDevRoleRelations(_0x178054['appCode'],_0x44fcf7['id']);return{...computeRoleUserMutation({'operation':_0x30de4d,'appCode':_0x178054[_0x35fed2(0xe5)],'role':_0x44fcf7,'relations':_0x2702a1,'user':{'userId':_0x14c100['userId'],'username':_0x14c100[_0x35fed2(0xcb)],'nickname':_0x14c100[_0x35fed2(0xd6)]},'dryRun':_0x1276f6,..._0x4dc37b!==undefined?{'expectUserCount':_0x4dc37b}:{}}),'role':_0x44fcf7,'user':_0x14c100};}
|
|
1
|
+
import{getTenantMembers,listDevUserRoleRelations,listAppRoles}from"../../core/api-client.js";import{getSessionUserInfo}from"../../auth/get-session-user.js";import{CliErrors}from"../../errors.js";export const ROLE_ID_FLAG={name:"id",type:"number",required:true,description:"Role id (from `role list`)"};export const ROLE_REF_FLAG={name:"role",type:"string",required:true,description:"Role id or exact role name"};export const USER_REF_FLAG={name:"user",type:"string",required:true,description:"User id, username, or nickname to resolve to a userId"};export const NAME_FLAG={name:"name",type:"string",required:true,description:"Role name"};export const USER_NAME_FLAG={name:"name",type:"string",required:true,description:"Nickname or username to resolve to a userId"};export const REMARK_FLAG={name:"remark",type:"string",required:false,description:"Optional role remark/description"};export const EXPECT_USER_COUNT_FLAG={name:"expect-user-count",type:"number",required:false,
|
|
2
|
+
description:"Anti-drift guard: fail if the role's current member count differs"};export const BUILTIN_ROLE_TYPES=["ADMIN","DEV","OWNER"];export function isBuiltinRole(roleType){return BUILTIN_ROLE_TYPES.includes(roleType)}export function assertCustomRole(role,action){if(role.roleType!=="CUSTOM"){throw CliErrors.validation(`Cannot ${action} built-in role ${role.roleName} (${role.roleType}).`,"Only CUSTOM roles can be modified or deleted.")}}export function projectRole(role){return{id:role.id,roleName:role.roleName,roleType:role.roleType,remark:role.remark,userCount:role.userCount,permitCount:role.permitCount,builtin:isBuiltinRole(role.roleType)}}export async function resolveRoleRef(appCode,ref){const trimmed=ref.trim();if(!trimmed){throw CliErrors.validation("Missing role reference.","Pass --role <id|name>.")}if(/^\d+$/.test(trimmed)){return getRoleById(appCode,Number(trimmed))}const items=await listAllAppRoles(appCode);const matches=items.filter(r=>r.roleName===trimmed)
|
|
3
|
+
;if(matches.length===0){throw CliErrors.validation(`Role name "${trimmed}" not found in app ${appCode}.`,"Run `role list` to see available roles, or pass --role <id>.")}if(matches.length>1){const ids=matches.map(r=>r.id).join(", ");throw CliErrors.validation(`Role name "${trimmed}" is ambiguous (ids: ${ids}).`,"Disambiguate with --role <id>.")}return matches[0]}export async function getRoleById(appCode,id){const items=await listAllAppRoles(appCode);const matches=items.filter(role=>role.id===id&&(!role.appCode||role.appCode===appCode));if(matches.length!==1){throw CliErrors.validation(`Role id ${id} not found in app ${appCode}.`,"Run `role list` to see available roles.")}return matches[0]}async function listAllAppRoles(appCode){const pageSize=100;const all=[];for(let currentPage=1;;currentPage+=1){const{items:items,paging:paging}=await listAppRoles(appCode,{currentPage:currentPage,pageSize:pageSize});all.push(...items);if(items.length<pageSize||paging&&all.length>=paging.totalCount){
|
|
4
|
+
return all}}}export async function resolveTenantCode(){const session=await getSessionUserInfo();const code=session?.user?.tenant?.tenant_code;if(!code){throw CliErrors.authRequired("Cannot resolve current tenant. Run `rabetbase auth login` first.")}return code}function matchMember(member,name){const n=name.trim().toLowerCase();return(member.nickname??"").toLowerCase()===n||(member.username??"").toLowerCase()===n}export async function resolveUserRef(ref,idSelectionHint="Pass --user <id>."){const trimmed=ref.trim();if(!trimmed){throw CliErrors.validation("Missing user reference.","Pass --user <id|name>.")}const tenantCode=await resolveTenantCode();const members=await getTenantMembers(tenantCode);if(/^\d+$/.test(trimmed)){const userId=Number(trimmed);const hit=members.find(m=>m.userId===userId);return{userId:userId,username:hit?.username??String(userId),nickname:hit?.nickname,matchedBy:"id"}}const matches=members.filter(m=>matchMember(m,trimmed));if(matches.length===0){
|
|
5
|
+
throw CliErrors.validation(`No tenant member matches "${trimmed}".`,`Check the nickname/username. ${idSelectionHint}`)}if(matches.length>1){const hint=matches.map(m=>`${m.nickname??m.username??"?"}(${m.userId})`).join(", ");throw CliErrors.validation(`Multiple tenant members match "${trimmed}": ${hint}.`,idSelectionHint)}const m=matches[0];return{userId:m.userId,username:m.username??String(m.userId),nickname:m.nickname,matchedBy:"name"}}export const CREATE_USER_ROLE_PATH="/smartapi/permit/user-role/create";export const DELETE_USER_ROLE_PATH="/smartapi/permit/user-role/delete";export function computeRoleUserMutation(params){const{operation:operation,appCode:appCode,role:role,relations:relations,user:user}=params;const before=[...new Set(relations.map(relation=>relation.userId))];const warnings=[];if(params.expectUserCount!==undefined&¶ms.expectUserCount!==before.length){
|
|
6
|
+
throw CliErrors.validation(`Anti-drift check failed: expected ${params.expectUserCount} member(s) but role has ${before.length}.`,"Re-run `role detail` / `role list` and retry with the current count.")}const has=before.includes(user.userId);const matchingRelationIds=relations.filter(relation=>relation.userId===user.userId).map(relation=>relation.id);const changed=operation==="user-add"?!has:has;let after=before;if(operation==="user-add"){if(has){warnings.push(`User ${user.userId} is already a member of role ${role.roleName}; no change.`)}else{after=[...before,user.userId]}}else{if(!has){warnings.push(`User ${user.userId} is not a member of role ${role.roleName}; no change.`)}else{after=before.filter(userId=>userId!==user.userId);if(matchingRelationIds.length>1){warnings.push(`Removed ${matchingRelationIds.length} duplicate memberships for user ${user.userId}.`)}}}const mutation={scope:"dev",operation:operation,selector:{appCode:appCode,roleId:role.id,roleName:role.roleName,
|
|
7
|
+
userId:user.userId},before:{userIds:before},after:{userIds:after},dryRun:params.dryRun,backend:{method:"POST",path:operation==="user-add"?CREATE_USER_ROLE_PATH:DELETE_USER_ROLE_PATH},warnings:warnings};return{mutation:mutation,changed:changed,matchingRelationIds:matchingRelationIds}}export async function loadDevRoleRelations(appCode,roleId){const pageSize=100;const all=[];for(let currentPage=1;;currentPage+=1){const{items:items,paging:paging}=await listDevUserRoleRelations(appCode,{roleId:roleId,currentPage:currentPage,pageSize:pageSize});all.push(...items);if(items.length<pageSize||paging&&all.length>=paging.totalCount){return all}}}export function readRoleRef(ctx){const ref=ctx.str("role").trim();if(!ref){throw CliErrors.flagMissing("role","Pass --role <id|name>.")}return ref}export async function prepareUserMutation(ctx,operation,dryRun){const roleRef=readRoleRef(ctx);const userRef=ctx.str("user").trim();if(!userRef){throw CliErrors.flagMissing("user","Pass --user <id|name>.")}
|
|
8
|
+
const expectRaw=ctx.flag("expect-user-count");const expectUserCount=expectRaw===undefined||expectRaw===null?undefined:Number(expectRaw);const role=await resolveRoleRef(ctx.appCode,roleRef);if(role.roleType==="OWNER"){throw CliErrors.validation(`Cannot ${operation} members of the OWNER role.`,"Use the platform ownership-transfer workflow to change the application owner.")}const user=await resolveUserRef(userRef);const relations=await loadDevRoleRelations(ctx.appCode,role.id);return{...computeRoleUserMutation({operation:operation,appCode:ctx.appCode,role:role,relations:relations,user:{userId:user.userId,username:user.username,nickname:user.nickname},dryRun:dryRun,...expectUserCount!==undefined?{expectUserCount:expectUserCount}:{}}),role:role,user:user}}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{updateAppRole}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{asDryRunResult}from"../../commands/common/dry-run.js";import{assertCustomRole,getRoleById,projectRole,REMARK_FLAG,ROLE_ID_FLAG}from"../../commands/role/shared.js";const UPDATE_PATH="/smartapi/permit/role/update";function readPatch(ctx){const nameRaw=ctx.flag("name");const remarkRaw=ctx.flag("remark");const patch={};if(nameRaw!==undefined&&nameRaw!==null){const name=String(nameRaw).trim();if(!name)throw CliErrors.validation("--name cannot be empty.");if(name.length>64){throw CliErrors.validation("Role name cannot exceed 64 characters.")}patch.roleName=name}if(remarkRaw!==undefined&&remarkRaw!==null){patch.remark=String(remarkRaw)}if(patch.roleName===undefined&&patch.remark===undefined){throw CliErrors.validation("Nothing to update.","Pass at least one of --name / --remark.")}return patch}export const roleUpdate={
|
|
2
|
+
service:"role",command:"update",description:"Update a CUSTOM role's name/remark (built-in roles rejected)",risk:"write",flags:[ROLE_ID_FLAG,{...REMARK_FLAG},{name:"name",type:"string",required:false,description:"New role name"},APPCODE_FLAG_OPTIONAL],async validate(ctx){readPatch(ctx)},async dryRun(ctx){const id=ctx.num("id");const patch=readPatch(ctx);const before=await getRoleById(ctx.appCode,id);assertCustomRole(before,"update");return asDryRunResult({scope:"dev",operation:"update",selector:{appCode:ctx.appCode,roleId:id,roleName:before.roleName},before:projectRole(before),after:projectRole({...before,...patch.roleName!==undefined?{roleName:patch.roleName}:{},...patch.remark!==undefined?{remark:patch.remark}:{}}),dryRun:true,backend:{method:"POST",path:UPDATE_PATH},warnings:[]},{method:"POST",url:UPDATE_PATH})},async execute(ctx){const id=ctx.num("id");const patch=readPatch(ctx);const before=await getRoleById(ctx.appCode,id);assertCustomRole(before,"update");await updateAppRole({
|
|
3
|
+
id:id,appCode:ctx.appCode,...patch.roleName!==undefined?{roleName:patch.roleName}:{},...patch.remark!==undefined?{remark:patch.remark}:{}});const after=await getRoleById(ctx.appCode,id);return{ok:true,data:{scope:"dev",operation:"update",selector:{appCode:ctx.appCode,roleId:id,roleName:after.roleName},before:projectRole(before),after:projectRole(after),dryRun:false,backend:{method:"POST",path:UPDATE_PATH},warnings:[]},message:`Updated role ${after.roleName} (id=${id})`}}};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{createDevUserRole}from"../../core/api-client.js";import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{asDryRunResult}from"../../commands/common/dry-run.js";import{EXPECT_USER_COUNT_FLAG,CREATE_USER_ROLE_PATH,prepareUserMutation,ROLE_REF_FLAG,USER_REF_FLAG}from"../../commands/role/shared.js";export const roleUserAdd={service:"role",command:"user-add",description:"Add a user to a role (OWNER rejected); requires --yes",risk:"high-risk-write",flags:[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async dryRun(ctx){const{mutation:mutation}=await prepareUserMutation(ctx,"user-add",true);return asDryRunResult(mutation,{method:"POST",url:CREATE_USER_ROLE_PATH})},async execute(ctx){const{mutation:mutation,changed:changed,role:role,user:user}=await prepareUserMutation(ctx,"user-add",false);if(changed){await createDevUserRole({appCode:ctx.appCode,userId:user.userId,username:user.username,roleType:role.roleType,roleId:mutation.selector.roleId})}
|
|
2
|
+
return{ok:true,data:mutation,message:changed?`Added user ${mutation.selector.userId} to role ${mutation.selector.roleName}`:`No change: user ${mutation.selector.userId} already in role ${mutation.selector.roleName}`}}};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{deleteDevUserRole}from"../../core/api-client.js";import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{asDryRunResult}from"../../commands/common/dry-run.js";import{EXPECT_USER_COUNT_FLAG,DELETE_USER_ROLE_PATH,prepareUserMutation,ROLE_REF_FLAG,USER_REF_FLAG}from"../../commands/role/shared.js";export const roleUserRemove={service:"role",command:"user-remove",description:"Remove a user from a role (OWNER rejected); requires --yes",risk:"high-risk-write",flags:[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async dryRun(ctx){const{mutation:mutation}=await prepareUserMutation(ctx,"user-remove",true);return asDryRunResult(mutation,{method:"POST",url:DELETE_USER_ROLE_PATH})},async execute(ctx){const{matchingRelationIds:matchingRelationIds,mutation:mutation,changed:changed}=await prepareUserMutation(ctx,"user-remove",false);if(changed){for(const relationId of matchingRelationIds){await deleteDevUserRole(relationId)}}return{ok:true,
|
|
2
|
+
data:mutation,message:changed?`Removed user ${mutation.selector.userId} from role ${mutation.selector.roleName}`:`No change: user ${mutation.selector.userId} not in role ${mutation.selector.roleName}`}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{resolveUserRef,USER_NAME_FLAG}from"../../commands/role/shared.js";export const roleUserResolve={service:"role",command:"user-resolve",description:"Resolve a nickname/username to a userId (tenant member directory)",risk:"read",flags:[USER_NAME_FLAG,APPCODE_FLAG_OPTIONAL],async validate(ctx){if(!ctx.str("name").trim()){throw CliErrors.flagMissing("name","Pass --name <nickname|username>.")}},async execute(ctx){const name=ctx.str("name").trim();const user=await resolveUserRef(name,"Select a listed userId, then pass it to `role user-add` or `role user-remove` with --user <id>.");return{ok:true,data:{user:{userId:user.userId,username:user.username,nickname:user.nickname,matchedBy:user.matchedBy}},message:`Resolved "${name}" → userId ${user.userId}`}}};
|