kardalum 0.16.0 → 0.18.0
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 +76 -6
- package/dist/control/access/index.d.ts +3 -0
- package/dist/control/access/index.js +11 -0
- package/dist/control/access/roles.d.ts +6 -0
- package/dist/control/access/roles.js +119 -0
- package/dist/control/access/users.d.ts +4 -0
- package/dist/control/access/users.js +89 -0
- package/dist/control/args.d.ts +49 -0
- package/dist/control/args.js +76 -0
- package/dist/control/ask.d.ts +8 -0
- package/dist/control/ask.js +29 -0
- package/dist/control/assets/index.d.ts +2 -0
- package/dist/control/assets/index.js +222 -0
- package/dist/control/audit/index.d.ts +6 -0
- package/dist/control/audit/index.js +208 -0
- package/dist/control/client.d.ts +20 -0
- package/dist/control/client.js +53 -0
- package/dist/control/completion/emit.d.ts +4 -0
- package/dist/control/completion/emit.js +112 -0
- package/dist/control/completion/index.d.ts +2 -0
- package/dist/control/completion/index.js +19 -0
- package/dist/control/completion/tree.d.ts +17 -0
- package/dist/control/completion/tree.js +53 -0
- package/dist/control/config.d.ts +23 -0
- package/dist/control/config.js +120 -0
- package/dist/control/confirm.d.ts +30 -0
- package/dist/control/confirm.js +82 -0
- package/dist/control/content/destructive.d.ts +3 -0
- package/dist/control/content/destructive.js +153 -0
- package/dist/control/content/index.d.ts +2 -0
- package/dist/control/content/index.js +8 -0
- package/dist/control/content/permissions-shape.d.ts +7 -0
- package/dist/control/content/permissions-shape.js +32 -0
- package/dist/control/content/read.d.ts +6 -0
- package/dist/control/content/read.js +129 -0
- package/dist/control/content/write.d.ts +7 -0
- package/dist/control/content/write.js +223 -0
- package/dist/control/context.d.ts +74 -0
- package/dist/control/context.js +139 -0
- package/dist/control/dispatch.d.ts +4 -0
- package/dist/control/dispatch.js +160 -0
- package/dist/control/epipe.d.ts +5 -0
- package/dist/control/epipe.js +33 -0
- package/dist/control/errors.d.ts +76 -0
- package/dist/control/errors.js +252 -0
- package/dist/control/input.d.ts +30 -0
- package/dist/control/input.js +109 -0
- package/dist/control/media/files.d.ts +13 -0
- package/dist/control/media/files.js +150 -0
- package/dist/control/media/folders.d.ts +2 -0
- package/dist/control/media/folders.js +85 -0
- package/dist/control/media/index.d.ts +2 -0
- package/dist/control/media/index.js +8 -0
- package/dist/control/media/trash.d.ts +6 -0
- package/dist/control/media/trash.js +82 -0
- package/dist/control/mime.d.ts +2 -0
- package/dist/control/mime.js +30 -0
- package/dist/control/msys.d.ts +4 -0
- package/dist/control/msys.js +51 -0
- package/dist/control/nouns.d.ts +8 -0
- package/dist/control/nouns.js +22 -0
- package/dist/control/output.d.ts +18 -0
- package/dist/control/output.js +53 -0
- package/dist/control/paging.d.ts +55 -0
- package/dist/control/paging.js +75 -0
- package/dist/control/plans.d.ts +12 -0
- package/dist/control/plans.js +21 -0
- package/dist/control/plugins/index.d.ts +2 -0
- package/dist/control/plugins/index.js +20 -0
- package/dist/control/plugins/install.d.ts +2 -0
- package/dist/control/plugins/install.js +253 -0
- package/dist/control/plugins/lifecycle.d.ts +7 -0
- package/dist/control/plugins/lifecycle.js +329 -0
- package/dist/control/plugins/questions.d.ts +16 -0
- package/dist/control/plugins/questions.js +114 -0
- package/dist/control/plugins/read.d.ts +9 -0
- package/dist/control/plugins/read.js +105 -0
- package/dist/control/profile.d.ts +2 -0
- package/dist/control/profile.js +174 -0
- package/dist/control/prompt.d.ts +34 -0
- package/dist/control/prompt.js +228 -0
- package/dist/control/resolve.d.ts +20 -0
- package/dist/control/resolve.js +69 -0
- package/dist/control/settings/index.d.ts +2 -0
- package/dist/control/settings/index.js +4 -0
- package/dist/control/settings/settings.d.ts +3 -0
- package/dist/control/settings/settings.js +129 -0
- package/dist/control/settings/sites.d.ts +2 -0
- package/dist/control/settings/sites.js +135 -0
- package/dist/control/snapshots/index.d.ts +2 -0
- package/dist/control/snapshots/index.js +88 -0
- package/dist/control/structure/datatypes.d.ts +6 -0
- package/dist/control/structure/datatypes.js +102 -0
- package/dist/control/structure/index.d.ts +4 -0
- package/dist/control/structure/index.js +28 -0
- package/dist/control/structure/templates.d.ts +12 -0
- package/dist/control/structure/templates.js +338 -0
- package/dist/control/structure/types.d.ts +7 -0
- package/dist/control/structure/types.js +146 -0
- package/dist/control/timeout.d.ts +10 -0
- package/dist/control/timeout.js +42 -0
- package/dist/control/usage.d.ts +16 -0
- package/dist/control/usage.js +500 -0
- package/dist/control/verbs.d.ts +100 -0
- package/dist/control/verbs.js +19 -0
- package/dist/control/whoami.d.ts +2 -0
- package/dist/control/whoami.js +42 -0
- package/dist/dev/local-plugin.d.ts +147 -0
- package/dist/dev/local-plugin.js +422 -0
- package/dist/dev/rebuild-loop.d.ts +26 -0
- package/dist/dev/rebuild-loop.js +152 -0
- package/dist/dev/sandbox.d.ts +68 -21
- package/dist/dev/sandbox.js +299 -188
- package/dist/dev/server-resolution.d.ts +1 -1
- package/dist/dev/server-resolution.js +20 -20
- package/dist/index.d.ts +3 -1
- package/dist/index.js +40 -22
- package/dist/plugin/build-federation-bundle.d.ts +2 -2
- package/dist/plugin/build-federation-bundle.js +37 -12
- package/dist/plugin/build.d.ts +3 -3
- package/dist/plugin/build.js +17 -17
- package/dist/plugin/checks/audit.d.ts +4 -1
- package/dist/plugin/checks/audit.js +35 -29
- package/dist/plugin/checks/package-contract.d.ts +0 -23
- package/dist/plugin/checks/package-contract.js +8 -91
- package/dist/plugin/checks/sdk-shared-key.js +184 -5
- package/dist/plugin/checks/templates.d.ts +1 -37
- package/dist/plugin/checks/templates.js +22 -291
- package/dist/plugin/copy-package-contract.d.ts +16 -8
- package/dist/plugin/copy-package-contract.js +28 -15
- package/dist/plugin/copy-sample-content.d.ts +0 -14
- package/dist/plugin/copy-sample-content.js +1 -17
- package/dist/plugin/copy-templates.d.ts +10 -8
- package/dist/plugin/copy-templates.js +54 -65
- package/dist/plugin/delivery-results.d.ts +5 -0
- package/dist/plugin/delivery-results.js +13 -0
- package/dist/plugin/index.js +37 -17
- package/dist/plugin/load-manifest.d.ts +4 -3
- package/dist/plugin/load-manifest.js +34 -16
- package/dist/plugin/pack-starter.js +15 -27
- package/dist/plugin/pack.d.ts +21 -1
- package/dist/plugin/pack.js +64 -26
- package/dist/plugin/process-tree.d.ts +25 -0
- package/dist/plugin/process-tree.js +164 -0
- package/dist/plugin/publish.d.ts +6 -0
- package/dist/plugin/publish.js +8 -0
- package/dist/plugin/sandbox-package.d.ts +12 -0
- package/dist/plugin/sandbox-package.js +52 -0
- package/dist/plugin/usage.d.ts +1 -1
- package/dist/plugin/usage.js +7 -5
- package/dist/plugin/validate.d.ts +2 -2
- package/dist/plugin/validate.js +45 -79
- package/dist/plugin/write-manifest-json.d.ts +1 -1
- package/dist/plugin/write-manifest-json.js +20 -8
- package/node_modules/@kardalum/api-schemas/README.md +1 -1
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +90 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +43 -10
- package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.js +42 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +23 -1
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +60 -18
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +204 -0
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +134 -0
- package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.d.ts +36 -0
- package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.js +46 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +22 -6
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +2 -1
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +52 -10
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +33 -14
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +50 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +25 -5
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.js +28 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +42 -2
- package/node_modules/@kardalum/api-schemas/dist/home.schema.d.ts +130 -0
- package/node_modules/@kardalum/api-schemas/dist/home.schema.js +87 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +73 -31
- package/node_modules/@kardalum/api-schemas/dist/index.js +47 -17
- package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/issue-list.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/issue-list.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +216 -63
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +117 -5
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +93 -0
- package/node_modules/@kardalum/api-schemas/dist/news.schema.js +86 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +410 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +193 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +86 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +92 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +6 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +8 -6
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +8 -18
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +3 -19
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +13 -15
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +17 -7
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +18 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +97 -85
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +35 -68
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +60 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +116 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +9 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +22 -7
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +240 -6
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +164 -32
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +4 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +14 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +37 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.d.ts +64 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.js +134 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +19 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +33 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +83 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +152 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.js +15 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +35 -23
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.d.ts +83 -0
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +73 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +11 -2
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +21 -3
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +126 -0
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +70 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +6 -6
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +58 -25
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +194 -48
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +18 -6
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/strict-url.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/strict-url.js +31 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +115 -1
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +65 -10
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +37 -2
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +34 -8
- package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.js +29 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +16 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/uuid.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/uuid.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +88 -0
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +100 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +32 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/package.json +2 -2
- package/node_modules/@kardalum/plugin-package/README.md +5 -2
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +6 -21
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +13 -8
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +59 -16
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +4 -0
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +25 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +25 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +203 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +73 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +8 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +77 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.js +2052 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icons.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +51 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +8 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +7 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +119 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +14 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +21 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/locales.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +148 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.js +76 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.d.ts +22 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +137 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +90 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/support.d.ts +24 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/support.js +55 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +7 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +215 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +53 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.js +1 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +3 -2
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +4 -2
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +92 -3
- package/node_modules/@kardalum/plugin-package/dist/extract.js +251 -41
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +13 -4
- package/node_modules/@kardalum/plugin-package/dist/index.js +10 -3
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +56 -19
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +119 -25
- package/node_modules/@kardalum/plugin-package/dist/manifest-entry.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/manifest-entry.js +20 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +1 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +21 -3
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +37 -9
- package/node_modules/@kardalum/plugin-package/dist/shipped-files.d.ts +39 -0
- package/node_modules/@kardalum/plugin-package/dist/shipped-files.js +133 -0
- package/node_modules/@kardalum/plugin-package/dist/shipped-locales.d.ts +7 -0
- package/node_modules/@kardalum/plugin-package/dist/shipped-locales.js +27 -0
- package/node_modules/@kardalum/plugin-package/dist/vendor-token.d.ts +24 -0
- package/node_modules/@kardalum/plugin-package/dist/vendor-token.js +118 -0
- package/node_modules/@kardalum/plugin-package/package.json +4 -2
- package/node_modules/@kardalum/prisma-variants/README.md +1 -1
- package/package.json +10 -9
- package/dist/plugin/checks/bundle-size.d.ts +0 -3
- package/dist/plugin/checks/bundle-size.js +0 -21
- package/dist/plugin/checks/db-compat.d.ts +0 -3
- package/dist/plugin/checks/db-compat.js +0 -15
- package/dist/plugin/checks/icon-names.d.ts +0 -3
- package/dist/plugin/checks/icon-names.js +0 -143
- package/dist/plugin/checks/install-options.d.ts +0 -3
- package/dist/plugin/checks/install-options.js +0 -41
- package/dist/plugin/checks/locale-parity.d.ts +0 -2
- package/dist/plugin/checks/locale-parity.js +0 -76
- package/dist/plugin/checks/locales.d.ts +0 -2
- package/dist/plugin/checks/locales.js +0 -66
- package/dist/plugin/checks/shared-deps.d.ts +0 -3
- package/dist/plugin/checks/shared-deps.js +0 -31
- package/dist/plugin/checks/views.d.ts +0 -3
- package/dist/plugin/checks/views.js +0 -49
package/README.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# kardalum
|
|
2
2
|
|
|
3
3
|
The command line for [Kardalum](https://kardalum.com), the free CMS that
|
|
4
|
-
never loses your data.
|
|
5
|
-
|
|
6
|
-
validates, builds, packs and publishes the plugin.
|
|
4
|
+
never loses your data. For plugin authors, `kardalum dev` runs a local
|
|
5
|
+
Kardalum sandbox with your plugin loaded into it, and `kardalum plugin`
|
|
6
|
+
validates, builds, packs and publishes the plugin. For site operators, the
|
|
7
|
+
control commands (`kardalum profile`, `kardalum whoami`) manage a running
|
|
8
|
+
site through its management API.
|
|
7
9
|
|
|
8
10
|
## Install
|
|
9
11
|
|
|
@@ -18,7 +20,7 @@ npm install --save-dev kardalum
|
|
|
18
20
|
## Commands
|
|
19
21
|
|
|
20
22
|
```sh
|
|
21
|
-
npx kardalum dev start # a local CMS
|
|
23
|
+
npx kardalum dev start # a local CMS running this plugin; the first run offers its install screen
|
|
22
24
|
npx kardalum plugin validate # the checks the marketplace review runs
|
|
23
25
|
npx kardalum plugin build # build the plugin into dist/
|
|
24
26
|
npx kardalum plugin pack # build and zip the installable package
|
|
@@ -33,15 +35,83 @@ views. `--server-port` and `--plugin-port` move the ports (defaults `3100` and
|
|
|
33
35
|
`5273`), and `--server-version` pins the server.
|
|
34
36
|
|
|
35
37
|
`kardalum plugin bundle-server` bundles only a plugin's server half, which
|
|
36
|
-
the sandbox uses itself. `publish` sends to `https://
|
|
38
|
+
the sandbox uses itself. `publish` sends to `https://dev.kardalum.com`
|
|
37
39
|
unless `--registry` or `$KARDALUM_REGISTRY_URL` names another marketplace.
|
|
38
40
|
`kardalum --help`, `kardalum dev --help` and `kardalum plugin --help` list
|
|
39
41
|
every option.
|
|
40
42
|
|
|
43
|
+
## Control commands
|
|
44
|
+
|
|
45
|
+
`kardalum <noun> <verb>` manages a running site through its management API.
|
|
46
|
+
A profile names a site and holds the key to use with it:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npx kardalum profile add staging --url https://staging.example.com
|
|
50
|
+
printf '%s' "$KARDALUM_STAGING_KEY" | npx kardalum profile add staging --url https://staging.example.com --key-stdin
|
|
51
|
+
npx kardalum profile add production --url https://www.example.com --production
|
|
52
|
+
npx kardalum profile list
|
|
53
|
+
npx kardalum profile use staging # make it the default
|
|
54
|
+
npx kardalum profile show staging
|
|
55
|
+
npx kardalum profile remove staging # asks first; --yes skips the question
|
|
56
|
+
npx kardalum whoami # the key's name, expiry and actions
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The key is never a flag. `profile add` asks for it with hidden input, or reads
|
|
60
|
+
it from standard input with `--key-stdin`, and keeps it in
|
|
61
|
+
`~/.kardalum/credentials` (mode 0600 where the platform honours it); profiles
|
|
62
|
+
are kept in `~/.kardalum/config.json`. `KARDALUM_HOME` moves both. On a shared
|
|
63
|
+
Windows machine the folder's access rights are what protect the credentials
|
|
64
|
+
file, so check them. Mint the key in the admin under Settings, API keys; it
|
|
65
|
+
needs `managementApi.use` and the actions of the commands you will run. Key
|
|
66
|
+
management and user creation stay in the admin.
|
|
67
|
+
|
|
68
|
+
A profile marked `--production` takes `--yes` only together with
|
|
69
|
+
`--profile <name>`, so a default or `KARDALUM_PROFILE` never confirms a change
|
|
70
|
+
to production on its own. On a command that changes a site, `--dry-run` shows
|
|
71
|
+
what it would do and sends nothing; elsewhere it is a usage error.
|
|
72
|
+
|
|
73
|
+
In CI, set `KARDALUM_URL` and `KARDALUM_API_KEY` together: they form an unnamed
|
|
74
|
+
profile that wins over every file.
|
|
75
|
+
|
|
76
|
+
`kardalum content`, `kardalum media`, `kardalum types`, `kardalum datatypes`,
|
|
77
|
+
`kardalum templates`, `kardalum snapshots`, `kardalum plugins` (with its `marketplace` group),
|
|
78
|
+
`kardalum users`, `kardalum roles` and `kardalum settings` (with its `sites` group) are built
|
|
79
|
+
(run `kardalum <noun> --help` for their verbs; deleting a type or a template, uninstalling a
|
|
80
|
+
plugin, restoring a plugin's tables with `plugins restore-snapshot`, restoring a snapshot,
|
|
81
|
+
changing a user's role, deleting a user or a role, and every settings change ask first).
|
|
82
|
+
|
|
83
|
+
`kardalum plugins install` takes a package file (made by `kardalum plugin pack`)
|
|
84
|
+
or a marketplace plugin id. A listing's install questions are asked at a
|
|
85
|
+
terminal; a script writes them into an answers file first:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
kardalum plugins install com.kardalum.commerce --print-questions # reads the questions
|
|
89
|
+
kardalum plugins install com.kardalum.commerce --print-questions --json | jq .answers > answers.json
|
|
90
|
+
# edit answers.json (every option starts at its default)
|
|
91
|
+
kardalum plugins install com.kardalum.commerce --answers answers.json
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
An update asks only what the recorded answers leave open (it reads the install
|
|
95
|
+
record, so the key also needs `plugins.read`). A paid listing's
|
|
96
|
+
licence key is never a flag: pipe it in with `--license-key-stdin` or set
|
|
97
|
+
`KARDALUM_LICENSE_KEY`.
|
|
98
|
+
|
|
99
|
+
Exit codes:
|
|
100
|
+
|
|
101
|
+
| Code | Meaning |
|
|
102
|
+
| ---- | ------- |
|
|
103
|
+
| 0 | Success (also --help, --version and a dry run) |
|
|
104
|
+
| 1 | Failure: validation, a server error, a local file error, a refused confirmation |
|
|
105
|
+
| 2 | Usage: unknown noun, verb or flag, a missing argument, no profile selected |
|
|
106
|
+
| 3 | Not authenticated or not allowed (401, 403) |
|
|
107
|
+
| 4 | Not found (404) |
|
|
108
|
+
| 5 | Conflict, or confirmation needed (409, or no way to ask) |
|
|
109
|
+
| 6 | Server unreachable |
|
|
110
|
+
|
|
41
111
|
## Docs
|
|
42
112
|
|
|
43
113
|
The CLI reference and the plugin guide are at
|
|
44
|
-
[
|
|
114
|
+
[dev.kardalum.com/docs](https://dev.kardalum.com/docs/v1/reference/cli/).
|
|
45
115
|
|
|
46
116
|
## Support
|
|
47
117
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ROLES_USAGE, USERS_USAGE } from "../usage.js";
|
|
2
|
+
import * as roles from "./roles.js";
|
|
3
|
+
import * as users from "./users.js";
|
|
4
|
+
export const usersNoun = {
|
|
5
|
+
usage: USERS_USAGE,
|
|
6
|
+
verbs: { list: users.list, "set-role": users.setRole, delete: users.del },
|
|
7
|
+
};
|
|
8
|
+
export const rolesNoun = {
|
|
9
|
+
usage: ROLES_USAGE,
|
|
10
|
+
verbs: { list: roles.list, actions: roles.actions, create: roles.create, update: roles.update, delete: roles.del },
|
|
11
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { flag, stringOption } from "../args.js";
|
|
2
|
+
import { findRole } from "../ask.js";
|
|
3
|
+
import { CliError, EXIT, UsageError } from "../errors.js";
|
|
4
|
+
import { readJsonSource } from "../input.js";
|
|
5
|
+
import { cell, printTable, streamNdjson } from "../output.js";
|
|
6
|
+
import { PAGE_MAX, runList } from "../paging.js";
|
|
7
|
+
import { requestPlan } from "../plans.js";
|
|
8
|
+
// Roles (2026-10-20-s309-users-roles-and-settings-commands-design.md section 3). update is a full replace of
|
|
9
|
+
// the action set, as the server does it; the file or the comma list is the whole set.
|
|
10
|
+
const ACTION_OPTIONS = { actions: { type: "string" }, "actions-file": { type: "string" } };
|
|
11
|
+
async function roleId(text, verb) {
|
|
12
|
+
const { RoleIdSchema } = await import("@kardalum/api-schemas");
|
|
13
|
+
const checked = RoleIdSchema.safeParse(text);
|
|
14
|
+
if (!checked.success)
|
|
15
|
+
throw new UsageError(`${verb} needs a role id: a lowercase slug (see \`kardalum roles list\`).`);
|
|
16
|
+
return checked.data;
|
|
17
|
+
}
|
|
18
|
+
/** The action set from --actions or --actions-file (an array, or a role object with an actions array); undefined when neither is given. */
|
|
19
|
+
async function readActions(ctx, args) {
|
|
20
|
+
const inline = stringOption(args, "actions");
|
|
21
|
+
const file = stringOption(args, "actions-file");
|
|
22
|
+
if (inline !== undefined && file !== undefined)
|
|
23
|
+
throw new UsageError("give --actions or --actions-file, not both.");
|
|
24
|
+
if (inline !== undefined)
|
|
25
|
+
return inline.split(",").map((action) => action.trim()).filter((action) => action !== "");
|
|
26
|
+
if (file === undefined)
|
|
27
|
+
return undefined;
|
|
28
|
+
const parsed = await readJsonSource(ctx, file, "--actions-file -");
|
|
29
|
+
const list = Array.isArray(parsed) ? parsed : typeof parsed === "object" && parsed !== null ? parsed.actions : undefined;
|
|
30
|
+
if (!Array.isArray(list) || list.some((entry) => typeof entry !== "string")) {
|
|
31
|
+
throw new UsageError("--actions-file must hold a JSON array of action ids, or a role object with an actions array.", "`kardalum roles list --json` prints role objects.");
|
|
32
|
+
}
|
|
33
|
+
return list;
|
|
34
|
+
}
|
|
35
|
+
export const list = {
|
|
36
|
+
remote: true,
|
|
37
|
+
async run({ ctx, args, client }) {
|
|
38
|
+
if (args.positionals.length > 0)
|
|
39
|
+
throw new UsageError("list takes no arguments.");
|
|
40
|
+
const api = await client();
|
|
41
|
+
return runList(ctx, args, {
|
|
42
|
+
max: PAGE_MAX.roles,
|
|
43
|
+
fetch: (query) => api.manage.roles.list(query),
|
|
44
|
+
headers: ["id", "label", "actions", "users", "superuser"],
|
|
45
|
+
row: (role) => [role.id, role.label, role.superuser ? "all" : role.actions.length, role.userCount, role.superuser ? "yes" : ""],
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
export const actions = {
|
|
50
|
+
remote: true,
|
|
51
|
+
async run({ ctx, args, client }) {
|
|
52
|
+
if (args.positionals.length > 0)
|
|
53
|
+
throw new UsageError("actions takes no arguments.");
|
|
54
|
+
const { items } = await (await client()).manage.roles.listActions();
|
|
55
|
+
if (flag(args, "json")) {
|
|
56
|
+
await streamNdjson(ctx, items);
|
|
57
|
+
return EXIT.ok;
|
|
58
|
+
}
|
|
59
|
+
printTable(ctx, ["id", "label", "source", "active"], items.map((item) => [item.id, item.label, item.sourceLabel, item.active ? "yes" : "no"]));
|
|
60
|
+
return EXIT.ok;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
export const create = {
|
|
64
|
+
remote: true,
|
|
65
|
+
options: { label: { type: "string" }, ...ACTION_OPTIONS },
|
|
66
|
+
async run({ ctx, args, client }) {
|
|
67
|
+
if (args.positionals.length !== 1)
|
|
68
|
+
throw new UsageError("create takes exactly one argument: the new role's id.");
|
|
69
|
+
const id = await roleId(args.positionals[0], "create");
|
|
70
|
+
const label = stringOption(args, "label");
|
|
71
|
+
if (label === undefined || label.trim() === "")
|
|
72
|
+
throw new UsageError("create needs --label <text>.");
|
|
73
|
+
const given = (await readActions(ctx, args)) ?? [];
|
|
74
|
+
const created = await (await client()).manage.roles.create({ id, label, actions: given });
|
|
75
|
+
ctx.out(flag(args, "json") ? JSON.stringify(created) : `created role ${created.role.id} (${created.role.actions.length} actions)`);
|
|
76
|
+
return EXIT.ok;
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
export const update = {
|
|
80
|
+
remote: true,
|
|
81
|
+
options: { label: { type: "string" }, ...ACTION_OPTIONS },
|
|
82
|
+
async run({ ctx, args, client }) {
|
|
83
|
+
if (args.positionals.length !== 1)
|
|
84
|
+
throw new UsageError("update takes exactly one argument: a role id.");
|
|
85
|
+
const id = await roleId(args.positionals[0], "update");
|
|
86
|
+
const label = stringOption(args, "label");
|
|
87
|
+
const given = await readActions(ctx, args);
|
|
88
|
+
if (label === undefined && given === undefined)
|
|
89
|
+
throw new UsageError("update needs --label, --actions or --actions-file.");
|
|
90
|
+
const body = { ...(label !== undefined ? { label } : {}), ...(given !== undefined ? { actions: given } : {}) };
|
|
91
|
+
const updated = await (await client()).manage.roles.update(id, body);
|
|
92
|
+
ctx.out(flag(args, "json") ? JSON.stringify(updated) : `updated role ${updated.role.id}`);
|
|
93
|
+
return EXIT.ok;
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
export const del = {
|
|
97
|
+
remote: true,
|
|
98
|
+
destructive: true,
|
|
99
|
+
async plan({ args, client, profile }) {
|
|
100
|
+
if (args.positionals.length !== 1)
|
|
101
|
+
throw new UsageError("delete takes exactly one argument: a role id.");
|
|
102
|
+
const id = await roleId(args.positionals[0], "delete");
|
|
103
|
+
const role = await findRole(await client(), id);
|
|
104
|
+
// The server refuses both again; the CLI asks no question it knows will be refused.
|
|
105
|
+
const { SEEDED_ROLE_IDS } = await import("@kardalum/api-schemas");
|
|
106
|
+
if (id === SEEDED_ROLE_IDS.admin || id === SEEDED_ROLE_IDS.editor)
|
|
107
|
+
throw new CliError(`the seeded role ${id} cannot be deleted.`, EXIT.failure);
|
|
108
|
+
if (role.userCount > 0) {
|
|
109
|
+
throw new CliError(`role ${id} is held by ${role.userCount} user(s); reassign them first.`, EXIT.conflict, "see `kardalum users set-role`.");
|
|
110
|
+
}
|
|
111
|
+
return requestPlan("roles", profile, `Delete the role ${cell(role.label)} (${cell(role.id)}, ${role.actions.length} actions)? Page permissions that name it are removed too.`, { method: "DELETE", path: `/roles/${id}` });
|
|
112
|
+
},
|
|
113
|
+
async run({ ctx, args, client }) {
|
|
114
|
+
const id = await roleId(args.positionals[0], "delete");
|
|
115
|
+
const result = await (await client()).manage.roles.delete(id);
|
|
116
|
+
ctx.out(flag(args, "json") ? JSON.stringify(result) : `deleted role ${id}`);
|
|
117
|
+
return EXIT.ok;
|
|
118
|
+
},
|
|
119
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { flag } from "../args.js";
|
|
2
|
+
import { changeQuestion, findRole, findUser } from "../ask.js";
|
|
3
|
+
import { CliError, EXIT, UsageError } from "../errors.js";
|
|
4
|
+
import { cell } from "../output.js";
|
|
5
|
+
import { PAGE_MAX, runList } from "../paging.js";
|
|
6
|
+
import { requestPlan } from "../plans.js";
|
|
7
|
+
import { isId } from "../resolve.js";
|
|
8
|
+
// Users (2026-10-20-s309-users-roles-and-settings-commands-design.md section 3). There is no `create`: the
|
|
9
|
+
// route takes a session (S305 section 10). Both destructive verbs pre-read the user through the list, ask
|
|
10
|
+
// their own question and dry-run as a request echo; the server offers neither a plan nor a confirm field.
|
|
11
|
+
const ADMIN_NOTE = "Only an administrator's session may grant or revoke the admin role; a key is refused.";
|
|
12
|
+
function userId(text, verb) {
|
|
13
|
+
if (text === undefined || !isId(text))
|
|
14
|
+
throw new UsageError(`${verb} needs a user id (a uuid; see \`kardalum users list\`).`);
|
|
15
|
+
return text.toLowerCase();
|
|
16
|
+
}
|
|
17
|
+
export const list = {
|
|
18
|
+
remote: true,
|
|
19
|
+
async run({ ctx, args, client }) {
|
|
20
|
+
if (args.positionals.length > 0)
|
|
21
|
+
throw new UsageError("list takes no arguments.");
|
|
22
|
+
const api = await client();
|
|
23
|
+
return runList(ctx, args, {
|
|
24
|
+
max: PAGE_MAX.users,
|
|
25
|
+
fetch: (query) => api.manage.users.list(query),
|
|
26
|
+
headers: ["id", "email", "role", "system"],
|
|
27
|
+
row: (user) => [user.id, user.email, user.role, user.system ? "yes" : ""],
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
async function roleArg(text) {
|
|
32
|
+
const { RoleIdSchema } = await import("@kardalum/api-schemas");
|
|
33
|
+
const checked = RoleIdSchema.safeParse(text);
|
|
34
|
+
if (!checked.success)
|
|
35
|
+
throw new UsageError("set-role needs a role id: a lowercase slug (see `kardalum roles list`).");
|
|
36
|
+
return checked.data;
|
|
37
|
+
}
|
|
38
|
+
export const setRole = {
|
|
39
|
+
remote: true,
|
|
40
|
+
destructive: true,
|
|
41
|
+
async plan({ args, client, profile }) {
|
|
42
|
+
if (args.positionals.length !== 2)
|
|
43
|
+
throw new UsageError("set-role takes a user id and a role id.");
|
|
44
|
+
const id = userId(args.positionals[0], "set-role");
|
|
45
|
+
const role = await roleArg(args.positionals[1]);
|
|
46
|
+
const api = await client();
|
|
47
|
+
const user = await findUser(api, id);
|
|
48
|
+
if (user.system)
|
|
49
|
+
throw new CliError("the system account's role cannot be changed.", EXIT.failure);
|
|
50
|
+
// A role that does not exist is exit 4 before anything is asked (the server would answer 404).
|
|
51
|
+
await findRole(api, role);
|
|
52
|
+
const request = { method: "PATCH", path: `/users/${id}/role`, body: { role } };
|
|
53
|
+
if (user.role === role) {
|
|
54
|
+
return { ...requestPlan("users", profile, "", request), nothing: `${cell(user.email)} already has the role ${cell(role)}. Nothing to change.` };
|
|
55
|
+
}
|
|
56
|
+
const touchesAdmin = user.role === "admin" || role === "admin";
|
|
57
|
+
return requestPlan("users", profile, changeQuestion(`the role of ${cell(user.email)}`, cell(user.role), cell(role), touchesAdmin ? ADMIN_NOTE : undefined), request);
|
|
58
|
+
},
|
|
59
|
+
async run({ ctx, args, client }) {
|
|
60
|
+
const id = userId(args.positionals[0], "set-role");
|
|
61
|
+
const role = await roleArg(args.positionals[1]);
|
|
62
|
+
const result = await (await client()).manage.users.updateRole(id, { role });
|
|
63
|
+
ctx.out(flag(args, "json") ? JSON.stringify(result) : `set the role of ${cell(result.user.email)} to ${cell(result.user.role)}`);
|
|
64
|
+
return EXIT.ok;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
export const del = {
|
|
68
|
+
remote: true,
|
|
69
|
+
destructive: true,
|
|
70
|
+
async plan({ args, client, profile }) {
|
|
71
|
+
if (args.positionals.length !== 1)
|
|
72
|
+
throw new UsageError("delete takes exactly one argument: a user id.");
|
|
73
|
+
const id = userId(args.positionals[0], "delete");
|
|
74
|
+
const user = await findUser(await client(), id);
|
|
75
|
+
if (user.system)
|
|
76
|
+
throw new CliError("the system account cannot be deleted.", EXIT.failure);
|
|
77
|
+
// The CLI always calls with a key, and the server answers a key's delete of an administrator 403.
|
|
78
|
+
if (user.role === "admin") {
|
|
79
|
+
throw new CliError(`${cell(user.email)} is an administrator: only an administrator's session can delete an administrator, and a key is refused.`, EXIT.auth, "delete them in the admin, signed in as an administrator.");
|
|
80
|
+
}
|
|
81
|
+
return requestPlan("users", profile, `Delete the user ${cell(user.email)} (role ${cell(user.role)})? Their sessions end. API keys they made keep working as site credentials (revoke them in the admin under Settings, API keys if they should stop). Content they wrote keeps their id. Files they uploaded stay and move to the system account. This cannot be undone.`, { method: "DELETE", path: `/users/${id}` });
|
|
82
|
+
},
|
|
83
|
+
async run({ ctx, args, client }) {
|
|
84
|
+
const id = userId(args.positionals[0], "delete");
|
|
85
|
+
const result = await (await client()).manage.users.delete(id);
|
|
86
|
+
ctx.out(flag(args, "json") ? JSON.stringify(result) : `deleted user ${id}`);
|
|
87
|
+
return EXIT.ok;
|
|
88
|
+
},
|
|
89
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type ParseArgsConfig } from "node:util";
|
|
2
|
+
export type OptionTable = NonNullable<ParseArgsConfig["options"]>;
|
|
3
|
+
export declare const GLOBAL_OPTIONS: {
|
|
4
|
+
readonly profile: {
|
|
5
|
+
readonly type: "string";
|
|
6
|
+
};
|
|
7
|
+
readonly json: {
|
|
8
|
+
readonly type: "boolean";
|
|
9
|
+
};
|
|
10
|
+
readonly yes: {
|
|
11
|
+
readonly type: "boolean";
|
|
12
|
+
readonly short: "y";
|
|
13
|
+
};
|
|
14
|
+
readonly "dry-run": {
|
|
15
|
+
readonly type: "boolean";
|
|
16
|
+
};
|
|
17
|
+
readonly limit: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
};
|
|
20
|
+
readonly all: {
|
|
21
|
+
readonly type: "boolean";
|
|
22
|
+
};
|
|
23
|
+
readonly cursor: {
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
};
|
|
26
|
+
readonly timeout: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
};
|
|
29
|
+
readonly help: {
|
|
30
|
+
readonly type: "boolean";
|
|
31
|
+
readonly short: "h";
|
|
32
|
+
};
|
|
33
|
+
readonly version: {
|
|
34
|
+
readonly type: "boolean";
|
|
35
|
+
readonly short: "V";
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export interface ParsedArgs {
|
|
39
|
+
values: Record<string, string | boolean | (string | boolean)[] | undefined>;
|
|
40
|
+
positionals: string[];
|
|
41
|
+
}
|
|
42
|
+
/** Parses one command's arguments strictly; a problem is a UsageError, never a stack. */
|
|
43
|
+
export declare function parseCommand(argv: string[], extra?: OptionTable): ParsedArgs;
|
|
44
|
+
export declare function flag(args: ParsedArgs, name: string): boolean;
|
|
45
|
+
export declare function stringOption(args: ParsedArgs, name: string): string | undefined;
|
|
46
|
+
/** Every value of a repeatable string option (`--field a=1 --field b=2`), in order; [] when absent. */
|
|
47
|
+
export declare function stringList(args: ParsedArgs, name: string): string[];
|
|
48
|
+
/** `--limit`: a whole number from 1 up; the API's own maximum is the cap the server applies. */
|
|
49
|
+
export declare function limitOption(args: ParsedArgs): number | undefined;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
2
|
+
import { UsageError } from "./errors.js";
|
|
3
|
+
// The flags every control command accepts (2026-10-19-s305-what-the-cli-is-design.md section 4).
|
|
4
|
+
// There is deliberately no option that carries a key: a flag lands in shell history.
|
|
5
|
+
export const GLOBAL_OPTIONS = {
|
|
6
|
+
profile: { type: "string" },
|
|
7
|
+
json: { type: "boolean" },
|
|
8
|
+
yes: { type: "boolean", short: "y" },
|
|
9
|
+
"dry-run": { type: "boolean" },
|
|
10
|
+
limit: { type: "string" },
|
|
11
|
+
all: { type: "boolean" },
|
|
12
|
+
cursor: { type: "string" },
|
|
13
|
+
timeout: { type: "string" },
|
|
14
|
+
help: { type: "boolean", short: "h" },
|
|
15
|
+
version: { type: "boolean", short: "V" },
|
|
16
|
+
};
|
|
17
|
+
/** A parse error that never repeats a value: node's own message for an unknown `--name=value` quotes the whole token, and a value there may be a secret. */
|
|
18
|
+
function describeParseError(error, argv, known) {
|
|
19
|
+
const code = error?.code;
|
|
20
|
+
if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION") {
|
|
21
|
+
for (const token of argv) {
|
|
22
|
+
if (token === "--")
|
|
23
|
+
break;
|
|
24
|
+
if (!token.startsWith("-"))
|
|
25
|
+
continue;
|
|
26
|
+
const name = token.startsWith("--") ? token.slice(2).split("=")[0] ?? "" : "";
|
|
27
|
+
if (name !== "" && !Object.hasOwn(known, name))
|
|
28
|
+
return `unknown option '--${name}'.`;
|
|
29
|
+
if (!token.startsWith("--") && token.length > 1) {
|
|
30
|
+
const short = token.slice(1, 2);
|
|
31
|
+
if (!Object.values(known).some((option) => option.short === short))
|
|
32
|
+
return `unknown option '-${short}'.`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return "unknown option.";
|
|
36
|
+
}
|
|
37
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
38
|
+
// Other messages name an option and say what is wrong with it, and quote no value; the first
|
|
39
|
+
// line is the statement, the rest is node's advice about an option value starting with a dash.
|
|
40
|
+
return message.split("\n")[0] ?? message;
|
|
41
|
+
}
|
|
42
|
+
/** Parses one command's arguments strictly; a problem is a UsageError, never a stack. */
|
|
43
|
+
export function parseCommand(argv, extra = {}) {
|
|
44
|
+
const options = { ...GLOBAL_OPTIONS, ...extra };
|
|
45
|
+
try {
|
|
46
|
+
const { values, positionals } = parseArgs({ args: argv, allowPositionals: true, strict: true, options });
|
|
47
|
+
return { values: values, positionals };
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new UsageError(describeParseError(error, argv, options));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export function flag(args, name) {
|
|
54
|
+
return args.values[name] === true;
|
|
55
|
+
}
|
|
56
|
+
export function stringOption(args, name) {
|
|
57
|
+
const value = args.values[name];
|
|
58
|
+
return typeof value === "string" ? value : undefined;
|
|
59
|
+
}
|
|
60
|
+
/** Every value of a repeatable string option (`--field a=1 --field b=2`), in order; [] when absent. */
|
|
61
|
+
export function stringList(args, name) {
|
|
62
|
+
const value = args.values[name];
|
|
63
|
+
if (Array.isArray(value))
|
|
64
|
+
return value.filter((entry) => typeof entry === "string");
|
|
65
|
+
return typeof value === "string" ? [value] : [];
|
|
66
|
+
}
|
|
67
|
+
/** `--limit`: a whole number from 1 up; the API's own maximum is the cap the server applies. */
|
|
68
|
+
export function limitOption(args) {
|
|
69
|
+
const raw = stringOption(args, "limit");
|
|
70
|
+
if (raw === undefined)
|
|
71
|
+
return undefined;
|
|
72
|
+
const value = Number(raw);
|
|
73
|
+
if (!Number.isInteger(value) || value < 1)
|
|
74
|
+
throw new UsageError(`--limit must be a whole number of 1 or more, not '${raw.slice(0, 20)}'.`);
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Role, UserSummary } from "@kardalum/api-schemas";
|
|
2
|
+
import type { KardalumManageClient } from "@kardalum/client";
|
|
3
|
+
export declare function changeQuestion(subject: string, from: string, to: string, consequence?: string): string;
|
|
4
|
+
/** "a, b", or "(none)". */
|
|
5
|
+
export declare function listOf(values: readonly string[]): string;
|
|
6
|
+
/** One user by id. The walk stops at the match, so a large install does not read every page for one row. */
|
|
7
|
+
export declare function findUser(api: KardalumManageClient, id: string): Promise<UserSummary>;
|
|
8
|
+
export declare function findRole(api: KardalumManageClient, id: string): Promise<Role>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CliError, EXIT } from "./errors.js";
|
|
2
|
+
import { cell } from "./output.js";
|
|
3
|
+
import { PAGE_MAX } from "./paging.js";
|
|
4
|
+
// The old-to-new question of a destructive change (2026-10-20-s309-users-roles-and-settings-commands-design.md
|
|
5
|
+
// D7) and the two reads that feed it. Every part a caller passes is already a display string: wrap server
|
|
6
|
+
// text in cell() before it gets here.
|
|
7
|
+
export function changeQuestion(subject, from, to, consequence) {
|
|
8
|
+
return `Change ${subject} from ${from} to ${to}?${consequence === undefined ? "" : ` ${consequence}`}`;
|
|
9
|
+
}
|
|
10
|
+
/** "a, b", or "(none)". */
|
|
11
|
+
export function listOf(values) {
|
|
12
|
+
return values.length === 0 ? "(none)" : values.map(cell).join(", ");
|
|
13
|
+
}
|
|
14
|
+
/** One user by id. The walk stops at the match, so a large install does not read every page for one row. */
|
|
15
|
+
export async function findUser(api, id) {
|
|
16
|
+
const wanted = id.toLowerCase();
|
|
17
|
+
for await (const user of (await api.manage.users.list({ limit: PAGE_MAX.users })).all()) {
|
|
18
|
+
if (user.id === wanted)
|
|
19
|
+
return user;
|
|
20
|
+
}
|
|
21
|
+
throw new CliError(`no user has the id ${cell(id)}.`, EXIT.notFound, "see `kardalum users list`.");
|
|
22
|
+
}
|
|
23
|
+
export async function findRole(api, id) {
|
|
24
|
+
for await (const role of (await api.manage.roles.list({ limit: PAGE_MAX.roles })).all()) {
|
|
25
|
+
if (role.id === id)
|
|
26
|
+
return role;
|
|
27
|
+
}
|
|
28
|
+
throw new CliError(`no role has the id ${cell(id)}.`, EXIT.notFound, "see `kardalum roles list`.");
|
|
29
|
+
}
|