@kardalum/plugin-sdk 0.0.0-stage → 0.15.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/CHANGELOG.md +108 -0
- package/LICENSE +202 -0
- package/README.md +70 -2
- package/dist/admin-section-registry.d.ts +34 -0
- package/dist/admin-section-registry.js +49 -0
- package/dist/built-in-serializers.d.ts +3 -0
- package/dist/built-in-serializers.js +18 -0
- package/dist/built-in-settings-schemas.d.ts +14 -0
- package/dist/built-in-settings-schemas.js +225 -0
- package/dist/built-in-value-schemas.d.ts +4 -0
- package/dist/built-in-value-schemas.js +47 -0
- package/dist/built-ins.d.ts +1 -0
- package/dist/built-ins.js +257 -0
- package/dist/capabilities.d.ts +99 -0
- package/dist/capabilities.js +363 -0
- package/dist/data-type-plugin.d.ts +28 -0
- package/dist/data-type-plugin.js +1 -0
- package/dist/datatype-validation.d.ts +26 -0
- package/dist/datatype-validation.js +110 -0
- package/dist/datatypes-entry.d.ts +4 -0
- package/dist/datatypes-entry.js +18 -0
- package/dist/define-plugin.d.ts +25 -0
- package/dist/define-plugin.js +51 -0
- package/dist/entitlement-entry.d.ts +5 -0
- package/dist/entitlement-entry.js +24 -0
- package/dist/entitlement-gate.d.ts +36 -0
- package/dist/entitlement-gate.js +201 -0
- package/dist/entitlement-types.d.ts +39 -0
- package/dist/entitlement-types.js +1 -0
- package/dist/entitlement.d.ts +57 -0
- package/dist/entitlement.js +170 -0
- package/dist/host-entry.d.ts +1 -0
- package/dist/host-entry.js +11 -0
- package/dist/icon-name.d.ts +1 -0
- package/dist/icon-name.js +1 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +10 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +93 -0
- package/dist/license-verdict-keys.d.ts +18 -0
- package/dist/license-verdict-keys.js +22 -0
- package/dist/local-host.d.ts +3 -0
- package/dist/local-host.js +38 -0
- package/dist/manifest-entry.d.ts +8 -0
- package/dist/manifest-entry.js +13 -0
- package/dist/manifest-schema.d.ts +408 -0
- package/dist/manifest-schema.js +774 -0
- package/dist/manifest.d.ts +546 -0
- package/dist/manifest.js +86 -0
- package/dist/media/media-picker.d.ts +39 -0
- package/dist/media/media-picker.js +438 -0
- package/dist/media/upload-error.d.ts +12 -0
- package/dist/media/upload-error.js +30 -0
- package/dist/plugin-context.d.ts +75 -0
- package/dist/plugin-context.js +70 -0
- package/dist/plugin-screen-context.d.ts +40 -0
- package/dist/plugin-screen-context.js +16 -0
- package/dist/register-built-ins.d.ts +1 -0
- package/dist/register-built-ins.js +41 -0
- package/dist/registry.d.ts +4 -0
- package/dist/registry.js +17 -0
- package/dist/rendition-eligibility.d.ts +24 -0
- package/dist/rendition-eligibility.js +40 -0
- package/dist/richtext/block-panel.d.ts +27 -0
- package/dist/richtext/block-panel.js +232 -0
- package/dist/richtext/extensions.d.ts +19 -0
- package/dist/richtext/extensions.js +56 -0
- package/dist/richtext/insert-menu.d.ts +24 -0
- package/dist/richtext/insert-menu.js +142 -0
- package/dist/richtext/kardalum-block.d.ts +33 -0
- package/dist/richtext/kardalum-block.js +282 -0
- package/dist/richtext/style-listbox.d.ts +10 -0
- package/dist/richtext/style-listbox.js +69 -0
- package/dist/richtext/text-style-class.d.ts +18 -0
- package/dist/richtext/text-style-class.js +36 -0
- package/dist/simple-storage-value-provider.d.ts +9 -0
- package/dist/simple-storage-value-provider.js +96 -0
- package/dist/structured-storage-types.d.ts +61 -0
- package/dist/structured-storage-types.js +11 -0
- package/dist/tailwind.d.ts +1 -0
- package/dist/tailwind.js +5 -0
- package/dist/tokens/system-dark.css +75 -0
- package/dist/tokens/tokens.css +239 -0
- package/dist/tokens/tokens.json +212 -0
- package/dist/tokens.d.ts +1 -0
- package/dist/tokens.js +11 -0
- package/dist/ui-entry.d.ts +5 -0
- package/dist/ui-entry.js +42 -0
- package/dist/views/content-list-preview.d.ts +1 -0
- package/dist/views/content-list-preview.js +14 -0
- package/dist/views/content-list-settings-view.d.ts +1 -0
- package/dist/views/content-list-settings-view.js +97 -0
- package/dist/views/content-list-view.d.ts +19 -0
- package/dist/views/content-list-view.js +248 -0
- package/dist/views/crop-view.d.ts +55 -0
- package/dist/views/crop-view.js +161 -0
- package/dist/views/date-range-view.d.ts +6 -0
- package/dist/views/date-range-view.js +55 -0
- package/dist/views/file-upload-view.d.ts +43 -0
- package/dist/views/file-upload-view.js +104 -0
- package/dist/views/html-code-editor.d.ts +10 -0
- package/dist/views/html-code-editor.js +101 -0
- package/dist/views/html-view.d.ts +3 -0
- package/dist/views/html-view.js +53 -0
- package/dist/views/image-view.d.ts +3 -0
- package/dist/views/image-view.js +387 -0
- package/dist/views/rich-text-view.d.ts +2 -0
- package/dist/views/rich-text-view.js +429 -0
- package/node_modules/@kardalum/api-schemas/LICENSE +202 -0
- package/node_modules/@kardalum/api-schemas/README.md +56 -0
- package/node_modules/@kardalum/api-schemas/dist/action.schema.d.ts +30 -0
- package/node_modules/@kardalum/api-schemas/dist/action.schema.js +88 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +36 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +89 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +24 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +47 -0
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.d.ts +38 -0
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +537 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +353 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +158 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +139 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +125 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +256 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +23 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +151 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +82 -0
- package/node_modules/@kardalum/api-schemas/dist/content-version.schema.d.ts +18 -0
- package/node_modules/@kardalum/api-schemas/dist/content-version.schema.js +22 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.js +20 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +302 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +97 -0
- package/node_modules/@kardalum/api-schemas/dist/culture-direction.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/culture-direction.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +36 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +296 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +138 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +121 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +147 -0
- package/node_modules/@kardalum/api-schemas/dist/health.schema.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/health.schema.js +5 -0
- package/node_modules/@kardalum/api-schemas/dist/html-entities.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/html-entities.js +250 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +102 -0
- package/node_modules/@kardalum/api-schemas/dist/index.js +58 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +381 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +197 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +167 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +214 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +77 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +117 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +27 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.js +279 -0
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.d.ts +74 -0
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +157 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +80 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +156 -0
- package/node_modules/@kardalum/api-schemas/dist/nav.schema.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/nav.schema.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +846 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +356 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +169 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +80 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.d.ts +65 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +889 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +89 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +134 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +369 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +393 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +87 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +25 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +24 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +306 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +328 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +79 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +50 -0
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +90 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +69 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +108 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +93 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +243 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +296 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +43 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +25 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +30 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +112 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +74 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +39 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +89 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +68 -0
- package/node_modules/@kardalum/api-schemas/package.json +35 -0
- package/node_modules/@kardalum/design-tokens/LICENSE +202 -0
- package/node_modules/@kardalum/design-tokens/README.md +29 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +32 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +88 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.d.ts +1 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.js +18 -0
- package/node_modules/@kardalum/design-tokens/dist/index.d.ts +6 -0
- package/node_modules/@kardalum/design-tokens/dist/index.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/system-dark.css +75 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +33 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +54 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +12 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-css.js +42 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +43 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-types.js +1 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +13 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +120 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/index.d.ts +5 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/index.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +9 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/light.js +13 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +239 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +25 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +276 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +212 -0
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +91 -0
- package/node_modules/@kardalum/design-tokens/dist/types.js +5 -0
- package/node_modules/@kardalum/design-tokens/package.json +42 -0
- package/node_modules/@kardalum/plugin-package/LICENSE +202 -0
- package/node_modules/@kardalum/plugin-package/README.md +71 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +50 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +659 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +19 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.js +104 -0
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +37 -0
- package/node_modules/@kardalum/plugin-package/dist/extract.js +199 -0
- package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/hash.js +69 -0
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +11 -0
- package/node_modules/@kardalum/plugin-package/dist/index.js +7 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +185 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +236 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +50 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.js +115 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +17 -0
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +45 -0
- package/node_modules/@kardalum/plugin-package/dist/types.js +1 -0
- package/node_modules/@kardalum/plugin-package/package.json +49 -0
- package/node_modules/@kardalum/ui/LICENSE +202 -0
- package/node_modules/@kardalum/ui/README.md +35 -0
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +14 -0
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +38 -0
- package/node_modules/@kardalum/ui/dist/components/badge.d.ts +9 -0
- package/node_modules/@kardalum/ui/dist/components/badge.js +30 -0
- package/node_modules/@kardalum/ui/dist/components/button.d.ts +11 -0
- package/node_modules/@kardalum/ui/dist/components/button.js +37 -0
- package/node_modules/@kardalum/ui/dist/components/checkbox.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/dialog.js +48 -0
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +53 -0
- package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +30 -0
- package/node_modules/@kardalum/ui/dist/components/empty-state.js +9 -0
- package/node_modules/@kardalum/ui/dist/components/input.d.ts +4 -0
- package/node_modules/@kardalum/ui/dist/components/input.js +6 -0
- package/node_modules/@kardalum/ui/dist/components/panel.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/panel.js +6 -0
- package/node_modules/@kardalum/ui/dist/components/property-field.d.ts +19 -0
- package/node_modules/@kardalum/ui/dist/components/property-field.js +86 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.js +55 -0
- package/node_modules/@kardalum/ui/dist/components/skeleton.d.ts +3 -0
- package/node_modules/@kardalum/ui/dist/components/skeleton.js +9 -0
- package/node_modules/@kardalum/ui/dist/components/switch.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/switch.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +34 -0
- package/node_modules/@kardalum/ui/dist/components/tab-strip.js +72 -0
- package/node_modules/@kardalum/ui/dist/components/toast.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/components/toast.js +42 -0
- package/node_modules/@kardalum/ui/dist/components/toaster.d.ts +12 -0
- package/node_modules/@kardalum/ui/dist/components/toaster.js +11 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.js +62 -0
- package/node_modules/@kardalum/ui/dist/index.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/index.js +18 -0
- package/node_modules/@kardalum/ui/dist/lib/cn.d.ts +2 -0
- package/node_modules/@kardalum/ui/dist/lib/cn.js +5 -0
- package/node_modules/@kardalum/ui/package.json +63 -0
- package/package.json +146 -4
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ACTION_SEGMENT_MAX, ActionStringSchema, CultureSchema, MANIFEST_ID_SEGMENT_MAX, PLUGIN_ID_REGEX, SLOT_ID_MAX, SLOT_ID_REGEX, PluginDocsPageSchema, checkDocsDeclaration, CreateDocumentTypeRequestSchema, PluginActionDeclarationSchema, PluginRoleOfferSchema, checkActionDeclarations as checkActionDeclarationsRule, isPluginActionFor } from "@kardalum/api-schemas";
|
|
3
|
+
import { isActionGated } from "./capabilities.js";
|
|
4
|
+
// Runtime mirror of manifest.ts — the same contract, enforced for
|
|
5
|
+
// manifests that arrive as VALUES (Module Federation remotes, sideloaded
|
|
6
|
+
// plugins, the future `kardalum plugin validate` CLI) where the compiler
|
|
7
|
+
// can't help. Since S268 there is ONE manifest shape and ONE contributions
|
|
8
|
+
// object: the plugin's `type` gates nothing. Both objects stay .strict(),
|
|
9
|
+
// so an unknown key still fails with a clear path like
|
|
10
|
+
// `contributions.adminSection` (a typo, or a field a later version
|
|
11
|
+
// removed). Ungating which contributions are legal is not the same as
|
|
12
|
+
// accepting anything.
|
|
13
|
+
//
|
|
14
|
+
// Lives in the SDK, not @kardalum/api-schemas, deliberately: the manifest
|
|
15
|
+
// carries React components and functions (api-schemas must never know
|
|
16
|
+
// React), and third-party tooling needs this validator from the
|
|
17
|
+
// published package.
|
|
18
|
+
// Zod 4: z.function() is not a schema — validate callables with
|
|
19
|
+
// z.custom. The type parameter is the CONTRACT type from manifest.ts,
|
|
20
|
+
// which is what makes the compile-time sync assertion at the bottom of
|
|
21
|
+
// this file hold. React components may be functions OR objects
|
|
22
|
+
// (React.memo/forwardRef produce exotic objects).
|
|
23
|
+
const callable = (label) => z.custom((value) => typeof value === "function", { message: `${label} must be a function` });
|
|
24
|
+
const componentSchema = z.custom((value) => typeof value === "function" || (typeof value === "object" && value !== null), { message: "must be a React component" });
|
|
25
|
+
// A JSON Schema document is a plain object (DataTypePlugin.schema is the
|
|
26
|
+
// JSONSchema7 object interface, not the boolean shorthand).
|
|
27
|
+
const jsonSchemaSchema = z.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value), { message: "must be a JSON Schema object" });
|
|
28
|
+
// A plugin-declared request schema must be a REAL Zod schema instance
|
|
29
|
+
// (z.object(...), z.string(), etc. — every Zod schema extends the base
|
|
30
|
+
// ZodType class), not just an object that looks like one — plugin-api-
|
|
31
|
+
// routes.ts calls .safeParse() on it directly at request time.
|
|
32
|
+
const zodSchemaField = z.instanceof(z.ZodType);
|
|
33
|
+
// Reverse-domain id per the documented contract, e.g. "com.vendor.name".
|
|
34
|
+
// Shared by manifest ids, datatype ids and plugin references, so it carries
|
|
35
|
+
// only the CHARACTER rules: every segment is lowercase and starts with a
|
|
36
|
+
// letter. Every action a plugin declares is prefixed with the plugin's id,
|
|
37
|
+
// and an action segment must match /^[a-z][a-zA-Z0-9-]*$/, so a segment
|
|
38
|
+
// that starts with a digit or a hyphen, or is uppercase, would make an id
|
|
39
|
+
// that can never prefix a valid action. The segment COUNT is deliberately
|
|
40
|
+
// not capped here: a datatype id is the owning plugin's id plus the field
|
|
41
|
+
// name (com.kardalum.google-maps.location), so four segments is correct for it.
|
|
42
|
+
// The pattern itself lives in api-schemas (PLUGIN_ID_REGEX), which the nav
|
|
43
|
+
// setting reads too.
|
|
44
|
+
const pluginIdSchema = z
|
|
45
|
+
.string()
|
|
46
|
+
.regex(PLUGIN_ID_REGEX, "must be a reverse-domain id like com.vendor.plugin: every segment is lowercase, starts with a letter, and uses only a-z, 0-9 and hyphens");
|
|
47
|
+
// The most segments a plugin manifest's own id may have. An action is the
|
|
48
|
+
// plugin id plus at least an object and a verb, and an action has at most
|
|
49
|
+
// ACTION_SEGMENT_MAX segments, so an id of more than ACTION_SEGMENT_MAX - 2
|
|
50
|
+
// segments could not declare any action at all. MANIFEST_ID_SEGMENT_MAX
|
|
51
|
+
// (ACTION_SEGMENT_MAX - 2) is imported from api-schemas.
|
|
52
|
+
// A plugin manifest's own id: the shared id rules plus the segment cap
|
|
53
|
+
// above. Not used for datatype ids, which extend the plugin id with a field
|
|
54
|
+
// name and are legitimately longer.
|
|
55
|
+
const manifestIdSchema = pluginIdSchema.refine((id) => id.split(".").length <= MANIFEST_ID_SEGMENT_MAX, {
|
|
56
|
+
message: `a plugin id has at most ${MANIFEST_ID_SEGMENT_MAX} segments: every action is the plugin id plus an object ` +
|
|
57
|
+
`and a verb, and an action has at most ${ACTION_SEGMENT_MAX} segments, so a longer id could not declare any action`,
|
|
58
|
+
});
|
|
59
|
+
// S234a Task 6c: the catch-all is a singleton the whole upload path
|
|
60
|
+
// depends on (an upload of an extension nothing else claims lands on it,
|
|
61
|
+
// or 400s if there is none). A plugin's install path calls
|
|
62
|
+
// DocumentTypeService.createDocumentType directly, bypassing the sweep
|
|
63
|
+
// that the /api/document-types routes use to keep the flag a singleton,
|
|
64
|
+
// and uninstalling a plugin deletes every document type it contributed.
|
|
65
|
+
// A plugin allowed to hold the catch-all could therefore take it to zero
|
|
66
|
+
// on uninstall, so it is refused here, at the one schema every
|
|
67
|
+
// manifest-contributed document type passes through regardless of which
|
|
68
|
+
// plugin declares it (contributionsSchema references this, not the bare
|
|
69
|
+
// array).
|
|
70
|
+
// A plugin contributing a media type without the flag stays legal.
|
|
71
|
+
const manifestDocumentTypesSchema = z
|
|
72
|
+
.array(CreateDocumentTypeRequestSchema)
|
|
73
|
+
.optional()
|
|
74
|
+
.superRefine((documentTypes, ctx) => {
|
|
75
|
+
(documentTypes ?? []).forEach((documentType, index) => {
|
|
76
|
+
if (documentType.kind === "media" && documentType.catchAll === true) {
|
|
77
|
+
ctx.addIssue({
|
|
78
|
+
code: "custom",
|
|
79
|
+
message: "A plugin may contribute a media document type but may not claim the catch-all " +
|
|
80
|
+
'("catchAll: true"): uninstalling the plugin deletes its contributed types, and the ' +
|
|
81
|
+
"catch-all must survive that.",
|
|
82
|
+
path: [index, "catchAll"],
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
const dialectSchema = z.enum(["postgresql", "mysql", "sqlite", "mssql", "mongodb"]);
|
|
88
|
+
const databaseCompatibilitySchema = z
|
|
89
|
+
.object({
|
|
90
|
+
storageType: z.enum(["simple", "structured"]),
|
|
91
|
+
// A plugin supporting zero databases can never be installed anywhere.
|
|
92
|
+
supported: z.array(dialectSchema).min(1),
|
|
93
|
+
unsupportedReason: z.partialRecord(dialectSchema, z.string()).optional(),
|
|
94
|
+
})
|
|
95
|
+
.strict();
|
|
96
|
+
// An assertion is a key with a reason, never a boolean. Presence is the
|
|
97
|
+
// claim, so there is no `false` to write and no way to assert something
|
|
98
|
+
// and deny it in the same breath. Keyed by assertion name rather than
|
|
99
|
+
// held in an array of { kind, reason } for the same reason the booleans
|
|
100
|
+
// lost `needsStructuredData`: an array admits two entries for the same
|
|
101
|
+
// kind with contradicting reasons, and a manifest that can disagree with
|
|
102
|
+
// itself is the shape S267 is removing. Readers that want a list take
|
|
103
|
+
// Object.entries.
|
|
104
|
+
const assertionSchema = z
|
|
105
|
+
.object({
|
|
106
|
+
// Non-empty because an empty reason is the bare boolean again, and
|
|
107
|
+
// the install screen would render a blank line where the operator
|
|
108
|
+
// needs a sentence.
|
|
109
|
+
reason: z.string().min(1),
|
|
110
|
+
})
|
|
111
|
+
.strict();
|
|
112
|
+
// Held as a shape, not inlined into the schema, so ASSERTION_KINDS below
|
|
113
|
+
// can be derived from it rather than retyped beside it.
|
|
114
|
+
const assertionsShape = {
|
|
115
|
+
externalNetwork: assertionSchema.optional(),
|
|
116
|
+
filesystemAccess: assertionSchema.optional(),
|
|
117
|
+
};
|
|
118
|
+
// .strict() is what rejects an old manifest's `needsStructuredData`
|
|
119
|
+
// loudly instead of dropping it: the capability it stood for is derived
|
|
120
|
+
// from databaseCompatibility.storageType now, and a manifest still
|
|
121
|
+
// carrying the boolean was written against a contract that is gone.
|
|
122
|
+
export const AssertionsSchema = z.object(assertionsShape).strict();
|
|
123
|
+
/**
|
|
124
|
+
* Every assertion kind this contract defines, at runtime, derived from
|
|
125
|
+
* the shape above so it cannot drift from it.
|
|
126
|
+
*
|
|
127
|
+
* Exists for the same reason CONTRIBUTION_KEYS does: the marketplace
|
|
128
|
+
* carries a hand-maintained static mirror of AssertionsSchema (its
|
|
129
|
+
* Next.js runtime never imports plugin tooling), that mirror is
|
|
130
|
+
* `.strict()`, and a kind added here but not there turns into a publish
|
|
131
|
+
* refusal for an artifact that built fine. Exporting the kinds and the
|
|
132
|
+
* schema gives the mirror something to be pinned against.
|
|
133
|
+
*/
|
|
134
|
+
export const ASSERTION_KINDS = Object.keys(assertionsShape);
|
|
135
|
+
const pluginMigrationSchema = z
|
|
136
|
+
.object({
|
|
137
|
+
id: z.string().min(1),
|
|
138
|
+
name: z.string().min(1),
|
|
139
|
+
up: callable("up"),
|
|
140
|
+
down: callable("down"),
|
|
141
|
+
})
|
|
142
|
+
.strict();
|
|
143
|
+
const migrationHooksSchema = z
|
|
144
|
+
.object({
|
|
145
|
+
beforeMigration: callable("beforeMigration").optional(),
|
|
146
|
+
transformRow: callable("transformRow").optional(),
|
|
147
|
+
afterMigration: callable("afterMigration").optional(),
|
|
148
|
+
validateMigration: callable("validateMigration").optional(),
|
|
149
|
+
})
|
|
150
|
+
.strict();
|
|
151
|
+
const HOOK_EVENTS = [
|
|
152
|
+
"content:beforeSave",
|
|
153
|
+
"content:afterSave",
|
|
154
|
+
"content:beforePublish",
|
|
155
|
+
"content:afterPublish",
|
|
156
|
+
"content:afterTrash",
|
|
157
|
+
"content:afterRestore",
|
|
158
|
+
"content:beforeDelete",
|
|
159
|
+
"media:afterUpload",
|
|
160
|
+
"user:afterLogin",
|
|
161
|
+
"api:beforeResponse",
|
|
162
|
+
];
|
|
163
|
+
// z.partialRecord, not z.record: with enum keys, Zod 4's record is
|
|
164
|
+
// exhaustive (it would demand a handler for all ten events).
|
|
165
|
+
const hooksSchema = z.partialRecord(z.enum(HOOK_EVENTS), callable("hook handler"));
|
|
166
|
+
// The DataTypePlugin contract's structural shape — shared by manifests
|
|
167
|
+
// (dataTypes contributions arriving as data) and definePlugin (which
|
|
168
|
+
// fronts it with friendlier required-view messages).
|
|
169
|
+
export const DataTypePluginSchema = z
|
|
170
|
+
.object({
|
|
171
|
+
id: pluginIdSchema,
|
|
172
|
+
name: z.string().min(1),
|
|
173
|
+
icon: z.string().min(1),
|
|
174
|
+
version: z.string().min(1),
|
|
175
|
+
type: z.literal("datatype"),
|
|
176
|
+
schema: jsonSchemaSchema,
|
|
177
|
+
settingsSchema: jsonSchemaSchema,
|
|
178
|
+
defaultSettings: z.record(z.string(), z.unknown()),
|
|
179
|
+
views: z
|
|
180
|
+
.object({
|
|
181
|
+
input: componentSchema,
|
|
182
|
+
readOnly: componentSchema,
|
|
183
|
+
settings: componentSchema,
|
|
184
|
+
preview: componentSchema.optional(),
|
|
185
|
+
})
|
|
186
|
+
.strict(),
|
|
187
|
+
serialize: callable("serialize"),
|
|
188
|
+
deserialize: callable("deserialize"),
|
|
189
|
+
// Runtime-module members only: the manifest.json writer keeps a
|
|
190
|
+
// string-field allowlist, so these never serialize (S198 spec S8).
|
|
191
|
+
// They must still be ACCEPTED here — the object is .strict(), and a
|
|
192
|
+
// plugin author declaring its datatype's validate hook goes through
|
|
193
|
+
// this same schema via definePlugin.
|
|
194
|
+
validate: callable("validate").optional(),
|
|
195
|
+
isEmpty: callable("isEmpty").optional(),
|
|
196
|
+
})
|
|
197
|
+
.strict();
|
|
198
|
+
// --- the slots (S280, Theme B) ----------------------------------------------
|
|
199
|
+
// Three closed kinds, never a general registry (spec D1): a top-level
|
|
200
|
+
// section whose view is its landing page, a rail entry in that section's own
|
|
201
|
+
// rail, and a rail entry in a built-in section. Every slot declares its
|
|
202
|
+
// action (D4) and carries a translatable label (D5). `name` is gone from
|
|
203
|
+
// adminSections rather than kept beside `label`: nothing is released, and a
|
|
204
|
+
// leftover `name` is refused with a message that says what to write instead.
|
|
205
|
+
// A slot's id is a segment of its screen's URL (spec D3), so it is limited
|
|
206
|
+
// to characters that need no encoding and cannot be read as a path step:
|
|
207
|
+
// no "/", "%", space, unicode or upper case, and never "." or "..", which a
|
|
208
|
+
// router resolves as "this" or "the parent" segment. The same kebab-case
|
|
209
|
+
// rule template aliases use. The pattern and the cap live in api-schemas
|
|
210
|
+
// (SLOT_ID_REGEX, SLOT_ID_MAX), which the nav setting reads too.
|
|
211
|
+
const slotIdSchema = z
|
|
212
|
+
.string()
|
|
213
|
+
.regex(SLOT_ID_REGEX, 'slot ids are lowercase letters, digits and single hyphens (for example "orders" or "order-reports"), because the id is a segment of the screen\'s URL')
|
|
214
|
+
.max(SLOT_ID_MAX, `slot ids are at most ${SLOT_ID_MAX} characters, because the id is a segment of the screen's URL`);
|
|
215
|
+
// A language code to the text shown in that language; `en` is required
|
|
216
|
+
// because it is what every other language falls back to. No language may
|
|
217
|
+
// carry an empty string, which would render a blank tab. Every key is a
|
|
218
|
+
// language code under the same rule as the site's cultures setting
|
|
219
|
+
// (CultureSchema), so "" or "anything" is refused rather than carried as a
|
|
220
|
+
// language no locale can ever pick.
|
|
221
|
+
const slotLabelSchema = z
|
|
222
|
+
.object({ en: z.string().min(1) })
|
|
223
|
+
.catchall(z.string().min(1))
|
|
224
|
+
.superRefine((label, ctx) => {
|
|
225
|
+
for (const key of Object.keys(label)) {
|
|
226
|
+
if (!CultureSchema.safeParse(key).success) {
|
|
227
|
+
ctx.addIssue({
|
|
228
|
+
code: "custom",
|
|
229
|
+
message: `label keys are language codes such as "en", "de" or "pt-BR", not ${JSON.stringify(key)}`,
|
|
230
|
+
path: [key],
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
const railEntryInSectionSchema = z
|
|
236
|
+
.object({
|
|
237
|
+
id: slotIdSchema,
|
|
238
|
+
label: slotLabelSchema,
|
|
239
|
+
icon: z.string().min(1).optional(),
|
|
240
|
+
action: ActionStringSchema,
|
|
241
|
+
view: componentSchema,
|
|
242
|
+
})
|
|
243
|
+
.strict();
|
|
244
|
+
const adminSectionSchema = z
|
|
245
|
+
.object({
|
|
246
|
+
id: slotIdSchema,
|
|
247
|
+
label: slotLabelSchema,
|
|
248
|
+
icon: z.string().min(1),
|
|
249
|
+
action: ActionStringSchema,
|
|
250
|
+
view: componentSchema,
|
|
251
|
+
rail: z.array(railEntryInSectionSchema).optional(),
|
|
252
|
+
// `name` was the section's plain-text title before labels became
|
|
253
|
+
// translatable. Declared here only so a manifest still carrying it is
|
|
254
|
+
// told what to write instead, rather than reading "Unrecognized key"
|
|
255
|
+
// beside a missing label and having to infer the change.
|
|
256
|
+
name: z
|
|
257
|
+
.never({
|
|
258
|
+
error: (issue) => `"name" was replaced by "label", a map of language code to text with "en" required: write label: { en: ${typeof issue.input === "string" ? JSON.stringify(issue.input) : '"<your name>"'} }`,
|
|
259
|
+
})
|
|
260
|
+
.optional(),
|
|
261
|
+
})
|
|
262
|
+
.strict();
|
|
263
|
+
/**
|
|
264
|
+
* The built-in sections whose rail a plugin may add an entry to. Plugin
|
|
265
|
+
* management is not among them: it is the operator's screen for plugins,
|
|
266
|
+
* not a host for them. A plugin cannot take over any built-in section's
|
|
267
|
+
* landing page (spec D2), only add to its rail.
|
|
268
|
+
*/
|
|
269
|
+
export const BUILT_IN_RAIL_SECTIONS = ["content", "media", "settings", "users"];
|
|
270
|
+
const railEntrySchema = z
|
|
271
|
+
.object({
|
|
272
|
+
id: slotIdSchema,
|
|
273
|
+
section: z.enum(BUILT_IN_RAIL_SECTIONS),
|
|
274
|
+
label: slotLabelSchema,
|
|
275
|
+
icon: z.string().min(1).optional(),
|
|
276
|
+
action: ActionStringSchema,
|
|
277
|
+
view: componentSchema,
|
|
278
|
+
})
|
|
279
|
+
.strict();
|
|
280
|
+
const dashboardWidgetSchema = z
|
|
281
|
+
.object({
|
|
282
|
+
id: z.string().min(1),
|
|
283
|
+
name: z.string().min(1),
|
|
284
|
+
view: componentSchema,
|
|
285
|
+
action: ActionStringSchema,
|
|
286
|
+
})
|
|
287
|
+
.strict();
|
|
288
|
+
const apiRouteSchema = z
|
|
289
|
+
.object({
|
|
290
|
+
method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]),
|
|
291
|
+
path: z.string().min(1).refine((p) => p.startsWith("/"), { message: 'path must start with "/"' }),
|
|
292
|
+
access: z.enum(["admin", "apiKey", "public"]).optional(),
|
|
293
|
+
action: ActionStringSchema.optional(),
|
|
294
|
+
schema: z
|
|
295
|
+
.object({
|
|
296
|
+
body: zodSchemaField.optional(),
|
|
297
|
+
querystring: zodSchemaField.optional(),
|
|
298
|
+
params: zodSchemaField.optional(),
|
|
299
|
+
})
|
|
300
|
+
.strict()
|
|
301
|
+
.optional(),
|
|
302
|
+
handler: callable("handler"),
|
|
303
|
+
})
|
|
304
|
+
.strict();
|
|
305
|
+
const customFormatContributionSchema = z.object({
|
|
306
|
+
name: z.string().regex(/^[a-z0-9-]+$/),
|
|
307
|
+
build: callable("build"),
|
|
308
|
+
}).strict();
|
|
309
|
+
const serializerContributionSchema = z
|
|
310
|
+
.object({
|
|
311
|
+
extendContentResponse: callable("extendContentResponse").optional(),
|
|
312
|
+
customFormats: z.array(customFormatContributionSchema).optional(),
|
|
313
|
+
})
|
|
314
|
+
.strict()
|
|
315
|
+
.superRefine((value, ctx) => {
|
|
316
|
+
const names = (value.customFormats ?? []).map((format) => format.name);
|
|
317
|
+
if (new Set(names).size !== names.length) {
|
|
318
|
+
ctx.addIssue({ code: "custom", message: "customFormats names must be unique within a manifest" });
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
const scheduledTaskSchema = z
|
|
322
|
+
.object({
|
|
323
|
+
id: z.string().min(1),
|
|
324
|
+
name: z.string().min(1),
|
|
325
|
+
cron: z.string().min(1),
|
|
326
|
+
run: callable("run"),
|
|
327
|
+
})
|
|
328
|
+
.strict();
|
|
329
|
+
const mediaProcessorSchema = z
|
|
330
|
+
.object({
|
|
331
|
+
id: z.string().min(1),
|
|
332
|
+
name: z.string().min(1),
|
|
333
|
+
process: callable("process"),
|
|
334
|
+
})
|
|
335
|
+
.strict();
|
|
336
|
+
const settingsPageSchema = z
|
|
337
|
+
.object({
|
|
338
|
+
id: z.string().min(1),
|
|
339
|
+
name: z.string().min(1),
|
|
340
|
+
view: componentSchema,
|
|
341
|
+
action: ActionStringSchema,
|
|
342
|
+
})
|
|
343
|
+
.strict();
|
|
344
|
+
const contentTreeActionSchema = z
|
|
345
|
+
.object({
|
|
346
|
+
id: z.string().min(1),
|
|
347
|
+
label: z.string().min(1),
|
|
348
|
+
onSelect: callable("onSelect"),
|
|
349
|
+
action: ActionStringSchema,
|
|
350
|
+
})
|
|
351
|
+
.strict();
|
|
352
|
+
const editorToolbarSchema = z
|
|
353
|
+
.object({
|
|
354
|
+
id: z.string().min(1),
|
|
355
|
+
label: z.string().min(1),
|
|
356
|
+
icon: z.string().min(1),
|
|
357
|
+
onClick: callable("onClick"),
|
|
358
|
+
action: ActionStringSchema,
|
|
359
|
+
})
|
|
360
|
+
.strict();
|
|
361
|
+
const exposedServiceSchema = z
|
|
362
|
+
.object({ id: z.string().min(1), name: z.string().min(1), service: z.unknown() })
|
|
363
|
+
.strict();
|
|
364
|
+
const bundledTemplateSchema = z
|
|
365
|
+
.object({
|
|
366
|
+
name: z.string().min(1),
|
|
367
|
+
description: z.string().optional(),
|
|
368
|
+
repository: z.string().optional(),
|
|
369
|
+
})
|
|
370
|
+
.strict();
|
|
371
|
+
// Both the record KEY (kebab-cased into the CSS custom-property name by
|
|
372
|
+
// @kardalum/design-tokens's flatten()) and the VALUE (emitted verbatim after
|
|
373
|
+
// the colon) end up spliced into a shared, admin-wide `[data-theme] { ... }`
|
|
374
|
+
// block at runtime (see theme-css.ts's themeOverridesToCss). Braces,
|
|
375
|
+
// semicolons, and control characters are never legitimate in a single CSS
|
|
376
|
+
// identifier or value, and would otherwise let an installed theme plugin
|
|
377
|
+
// break out of its declaration and inject arbitrary rules. This is a belt
|
|
378
|
+
// to theme-css.ts's own runtime filter, enforced earlier at manifest
|
|
379
|
+
// validation time.
|
|
380
|
+
const safeCssTokenSchema = z
|
|
381
|
+
.string()
|
|
382
|
+
.max(200)
|
|
383
|
+
.regex(new RegExp('^[^{};\\u0000-\\u001f\\u007f]+$'), "must not contain CSS-escaping characters");
|
|
384
|
+
// themeTokens: minimal strict mirror of ThemeTokenOverrides — only
|
|
385
|
+
// color/radius keys exist (themes are cosmetic by construction);
|
|
386
|
+
// design-tokens has no Zod and shouldn't gain one, so token values are
|
|
387
|
+
// validated shallowly here.
|
|
388
|
+
const themeTokensSchema = z
|
|
389
|
+
.object({
|
|
390
|
+
color: z.record(safeCssTokenSchema, z.record(safeCssTokenSchema, safeCssTokenSchema)).optional(),
|
|
391
|
+
radius: z.record(safeCssTokenSchema, safeCssTokenSchema).optional(),
|
|
392
|
+
})
|
|
393
|
+
.strict();
|
|
394
|
+
// --- templates/assets contributions (S192 §8) -------------------------------
|
|
395
|
+
// Any plugin may declare templates and assets (S268). What still binds is
|
|
396
|
+
// the cross-check below: a `page` kind entry may only name a document type
|
|
397
|
+
// the same manifest declares.
|
|
398
|
+
// Local copies of the canonical alias/path rules and reserved roots, not
|
|
399
|
+
// imports. This is NOT a package boundary: plugin-sdk does depend on
|
|
400
|
+
// @kardalum/api-schemas (package.json lists it, and
|
|
401
|
+
// CreateDocumentTypeRequestSchema is value-imported above for
|
|
402
|
+
// contributionsSchema). The real one-way rule runs the other direction:
|
|
403
|
+
// api-schemas must never know about React, which the manifest carries,
|
|
404
|
+
// which is why the manifest schema lives here rather than there.
|
|
405
|
+
// These rules stay local because the manifest's versions are strictly
|
|
406
|
+
// narrower than the server's: assetPathSchema below also refuses a
|
|
407
|
+
// "public/" prefix and non-text extensions, neither of which
|
|
408
|
+
// api-schemas' AssetPathSchema does. They are still deliberate mirrors
|
|
409
|
+
// of api-schemas' AssetPathSchema / TemplateAliasSchema, so a change
|
|
410
|
+
// there wants a matching change here.
|
|
411
|
+
const TEMPLATE_ALIAS_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
412
|
+
// A path segment: starts alnum, then alnum/dot/dash/underscore. This alone
|
|
413
|
+
// rejects "." and ".." segments (both start with a dot, never alnum) —
|
|
414
|
+
// no separate traversal check needed.
|
|
415
|
+
const PATH_SEGMENT_REGEX = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
416
|
+
// Case-insensitive first-segment refusal — same reserved roots the
|
|
417
|
+
// request pipeline enforces for real routes (S192 §6 / since S184).
|
|
418
|
+
const RESERVED_ASSET_ROOTS = new Set(["kardalum", "api", "docs", "plugin-assets", "media"]);
|
|
419
|
+
// I3 (S196 final-fix wave): registered assets (contributions.assets) are
|
|
420
|
+
// the admin-editable css/js layer per the S192 spec — the install pipeline
|
|
421
|
+
// reads a declared asset's file as utf8 and registers it as TEXT content
|
|
422
|
+
// with version history, so a binary file declared here would be silently
|
|
423
|
+
// UTF-8-mangled on install. Ship binaries as unregistered public/ files
|
|
424
|
+
// instead (still copied byte-for-byte, just without a registry row). This
|
|
425
|
+
// allowlist is intentionally narrower than asset-fs.ts's isTextPath (which
|
|
426
|
+
// classifies the walked, unregistered tree and is more permissive) — it is
|
|
427
|
+
// mirrored byte-for-byte in kardalum plugin's checks/templates.ts and the
|
|
428
|
+
// marketplace's validation-checks.ts; keep all three in lockstep.
|
|
429
|
+
const REGISTERED_ASSET_TEXT_EXTENSIONS = new Set(["css", "js", "mjs", "json", "svg", "txt", "md"]);
|
|
430
|
+
function hasAllowedRegisteredAssetExtension(value) {
|
|
431
|
+
const base = value.split("/").pop() ?? value;
|
|
432
|
+
const dot = base.lastIndexOf(".");
|
|
433
|
+
if (dot <= 0)
|
|
434
|
+
return false; // no extension, or a dotfile with no extension of its own
|
|
435
|
+
return REGISTERED_ASSET_TEXT_EXTENSIONS.has(base.slice(dot + 1).toLowerCase());
|
|
436
|
+
}
|
|
437
|
+
function isRelativeSlashPath(value) {
|
|
438
|
+
return value.length > 0 && !value.startsWith("/") && !value.includes("\\");
|
|
439
|
+
}
|
|
440
|
+
function hasValidSegments(value) {
|
|
441
|
+
return value.split("/").every((segment) => PATH_SEGMENT_REGEX.test(segment));
|
|
442
|
+
}
|
|
443
|
+
const templateAliasSchema = z
|
|
444
|
+
.string()
|
|
445
|
+
.min(1)
|
|
446
|
+
.max(120)
|
|
447
|
+
.regex(TEMPLATE_ALIAS_REGEX, "must be lowercase kebab-case, e.g. product-page");
|
|
448
|
+
const templateFileSchema = z
|
|
449
|
+
.string()
|
|
450
|
+
.min(1)
|
|
451
|
+
.max(255)
|
|
452
|
+
.refine(isRelativeSlashPath, {
|
|
453
|
+
message: "must be a relative path using forward slashes (no leading \"/\", no \"\\\\\")",
|
|
454
|
+
})
|
|
455
|
+
.refine((value) => value.toLowerCase().endsWith(".liquid"), { message: "must end with .liquid" })
|
|
456
|
+
.refine(hasValidSegments, {
|
|
457
|
+
message: 'path segments must match [a-z0-9][a-z0-9._-]*: no "." or ".." segments',
|
|
458
|
+
});
|
|
459
|
+
const assetPathSchema = z
|
|
460
|
+
.string()
|
|
461
|
+
.min(1)
|
|
462
|
+
.max(400)
|
|
463
|
+
.refine(isRelativeSlashPath, {
|
|
464
|
+
message: "must be a relative path using forward slashes (no leading \"/\", no \"\\\\\")",
|
|
465
|
+
})
|
|
466
|
+
.refine(hasValidSegments, {
|
|
467
|
+
message: 'path segments must match [a-z0-9][a-z0-9._-]*: no "." or ".." segments',
|
|
468
|
+
})
|
|
469
|
+
.refine((value) => {
|
|
470
|
+
const firstSegment = value.split("/")[0]?.toLowerCase() ?? "";
|
|
471
|
+
return !RESERVED_ASSET_ROOTS.has(firstSegment);
|
|
472
|
+
}, { message: `must not be rooted at a reserved path (${[...RESERVED_ASSET_ROOTS].sort().join(", ")})` })
|
|
473
|
+
// contributions.assets entries flow verbatim into the server's
|
|
474
|
+
// AssetMirrorService.register at install time, whose AssetPathSchema is
|
|
475
|
+
// already public/-relative — a "public/"-prefixed entry here would
|
|
476
|
+
// resolve to public/public/…. Rejecting the prefix outright (rather than
|
|
477
|
+
// just documenting the bare convention) makes the ambiguity impossible
|
|
478
|
+
// for plugin authors to hit.
|
|
479
|
+
.refine((value) => (value.split("/")[0]?.toLowerCase() ?? "") !== "public", {
|
|
480
|
+
message: 'declare asset paths relative to public/: drop the "public/" prefix',
|
|
481
|
+
})
|
|
482
|
+
// I3: registered assets are text-only — see REGISTERED_ASSET_TEXT_EXTENSIONS above.
|
|
483
|
+
.refine(hasAllowedRegisteredAssetExtension, {
|
|
484
|
+
message: "registered assets are text files editable in the admin: ship binary files as unregistered public/ files instead",
|
|
485
|
+
});
|
|
486
|
+
const templateEntrySchema = z
|
|
487
|
+
.object({
|
|
488
|
+
file: templateFileSchema,
|
|
489
|
+
name: z.string().min(1),
|
|
490
|
+
alias: templateAliasSchema,
|
|
491
|
+
kind: z.enum(["page", "layout", "partial"]),
|
|
492
|
+
documentType: z.string().min(1).optional(),
|
|
493
|
+
})
|
|
494
|
+
.strict();
|
|
495
|
+
// The templates/assets cross-checks, run by contributionsSchema for every
|
|
496
|
+
// manifest (S268: one contributions object, so one place this fires).
|
|
497
|
+
// `documentTypes` is read structurally: a manifest that declares none can
|
|
498
|
+
// never resolve a `documentType` reference, which is the correct outcome
|
|
499
|
+
// rather than a special case.
|
|
500
|
+
function checkTemplateAndAssetContributions(value, ctx) {
|
|
501
|
+
const documentTypeNames = new Set((value.documentTypes ?? []).map((dt) => dt.name));
|
|
502
|
+
const seenAliases = new Set();
|
|
503
|
+
const seenFiles = new Set();
|
|
504
|
+
(value.templates ?? []).forEach((template, index) => {
|
|
505
|
+
if (seenAliases.has(template.alias)) {
|
|
506
|
+
ctx.addIssue({
|
|
507
|
+
code: "custom",
|
|
508
|
+
message: `Duplicate template alias "${template.alias}": aliases must be unique within a manifest`,
|
|
509
|
+
path: ["templates", index, "alias"],
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
seenAliases.add(template.alias);
|
|
513
|
+
if (seenFiles.has(template.file)) {
|
|
514
|
+
ctx.addIssue({
|
|
515
|
+
code: "custom",
|
|
516
|
+
message: `Duplicate template file "${template.file}": files must be unique within a manifest`,
|
|
517
|
+
path: ["templates", index, "file"],
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
seenFiles.add(template.file);
|
|
521
|
+
if (template.kind === "page") {
|
|
522
|
+
if (template.documentType !== undefined && !documentTypeNames.has(template.documentType)) {
|
|
523
|
+
ctx.addIssue({
|
|
524
|
+
code: "custom",
|
|
525
|
+
message: `documentType "${template.documentType}" does not match any name in this manifest's documentTypes contribution`,
|
|
526
|
+
path: ["templates", index, "documentType"],
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
else if (template.documentType !== undefined) {
|
|
531
|
+
ctx.addIssue({
|
|
532
|
+
code: "custom",
|
|
533
|
+
message: `documentType is only allowed on "page" kind templates, not "${template.kind}"`,
|
|
534
|
+
path: ["templates", index, "documentType"],
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
const seenAssets = new Set();
|
|
539
|
+
(value.assets ?? []).forEach((asset, index) => {
|
|
540
|
+
if (seenAssets.has(asset)) {
|
|
541
|
+
ctx.addIssue({
|
|
542
|
+
code: "custom",
|
|
543
|
+
message: `Duplicate asset path "${asset}": asset paths must be unique within a manifest`,
|
|
544
|
+
path: ["assets", index],
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
seenAssets.add(asset);
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
// Two apiRoutes entries sharing a (method, path) pair within one manifest
|
|
551
|
+
// would silently last-wins in plugin-api-routes.ts's dispatcher: a
|
|
552
|
+
// validation error, not a runtime surprise, same reasoning as
|
|
553
|
+
// document-type-api.schema.ts's duplicate-field-id check.
|
|
554
|
+
function checkApiRouteContributions(value, ctx) {
|
|
555
|
+
const seen = new Set();
|
|
556
|
+
(value.apiRoutes ?? []).forEach((route, index) => {
|
|
557
|
+
const key = `${route.method} ${route.path}`;
|
|
558
|
+
if (seen.has(key)) {
|
|
559
|
+
ctx.addIssue({
|
|
560
|
+
code: "custom",
|
|
561
|
+
message: `Duplicate apiRoute "${key}": method+path pairs must be unique within a manifest`,
|
|
562
|
+
path: ["apiRoutes", index],
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
seen.add(key);
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
// A slot's id is the last segment of its URL (spec D3), so it must be unique
|
|
569
|
+
// where its URL would collide: among this plugin's sections, within one
|
|
570
|
+
// section's rail, and among this plugin's built-in rail entries. Across those
|
|
571
|
+
// three lists the same id is fine, because the URLs differ
|
|
572
|
+
// (/plugins/<plugin>/<id>, /plugins/<plugin>/<section>/<id>,
|
|
573
|
+
// /<built-in>/plugins/<plugin>/<id>), and two plugins may share any id
|
|
574
|
+
// because every one of those URLs carries the plugin's id (D8).
|
|
575
|
+
function checkSlotContributions(value, ctx) {
|
|
576
|
+
const unique = (entries, path, what) => {
|
|
577
|
+
const seen = new Set();
|
|
578
|
+
entries.forEach((entry, index) => {
|
|
579
|
+
if (seen.has(entry.id)) {
|
|
580
|
+
ctx.addIssue({
|
|
581
|
+
code: "custom",
|
|
582
|
+
message: `Duplicate ${what} id "${entry.id}": ids must be unique ${what === "rail entry" ? "within one section's rail" : `within ${path[0]}`}, because the id is part of the slot's URL`,
|
|
583
|
+
path: [...path, index, "id"],
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
seen.add(entry.id);
|
|
587
|
+
});
|
|
588
|
+
};
|
|
589
|
+
const sections = value.adminSections ?? [];
|
|
590
|
+
unique(sections, ["adminSections"], "section");
|
|
591
|
+
sections.forEach((section, index) => unique(section.rail ?? [], ["adminSections", index, "rail"], "rail entry"));
|
|
592
|
+
unique(value.railEntries ?? [], ["railEntries"], "built-in rail entry");
|
|
593
|
+
}
|
|
594
|
+
// Every action a plugin declares must sit in that plugin's own namespace
|
|
595
|
+
// (its full reverse-domain id plus a dot), so one plugin cannot declare an
|
|
596
|
+
// action in another plugin's namespace or in core's. An admin-tier apiRoute
|
|
597
|
+
// must declare one; a public route needs no credential and so no action.
|
|
598
|
+
function checkActionContributions(value, ctx) {
|
|
599
|
+
const contributions = value.contributions;
|
|
600
|
+
// A section's own rail entries are gated too (S280). They are not a
|
|
601
|
+
// contribution key of their own, so they are walked here, beside the
|
|
602
|
+
// section that carries them, under the path an author can find.
|
|
603
|
+
(contributions.adminSections ?? []).forEach((section, index) => {
|
|
604
|
+
(section.rail ?? []).forEach((entry, railIndex) => {
|
|
605
|
+
if (entry.action !== undefined && !isPluginActionFor(entry.action, value.id)) {
|
|
606
|
+
ctx.addIssue({
|
|
607
|
+
code: "custom",
|
|
608
|
+
message: `action "${entry.action}" must be prefixed with this plugin's id "${value.id}."`,
|
|
609
|
+
path: ["contributions", "adminSections", index, "rail", railIndex, "action"],
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
// Derived from the classification on CONTRIBUTION_RULES, never a literal
|
|
615
|
+
// list, so a newly gated contribution kind cannot skip this check.
|
|
616
|
+
for (const key of CONTRIBUTION_KEYS.filter(isActionGated)) {
|
|
617
|
+
(contributions[key] ?? []).forEach((entry, index) => {
|
|
618
|
+
if (entry.action === undefined) {
|
|
619
|
+
if (key === "apiRoutes" && entry.access !== undefined && entry.access !== "admin")
|
|
620
|
+
return;
|
|
621
|
+
if (key === "apiRoutes") {
|
|
622
|
+
ctx.addIssue({
|
|
623
|
+
code: "custom",
|
|
624
|
+
message: 'an admin-tier apiRoute must declare an "action" (only a "public" or "apiKey" route may omit it)',
|
|
625
|
+
path: ["contributions", key, index, "action"],
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
if (!isPluginActionFor(entry.action, value.id)) {
|
|
631
|
+
ctx.addIssue({
|
|
632
|
+
code: "custom",
|
|
633
|
+
message: `action "${entry.action}" must be prefixed with this plugin's id "${value.id}."`,
|
|
634
|
+
path: ["contributions", key, index, "action"],
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
// S274b: the rule itself lives in api-schemas (spec D3) so the marketplace
|
|
641
|
+
// runs the same function at submission; this adapter only maps its issues
|
|
642
|
+
// onto the Zod context.
|
|
643
|
+
function checkActionDeclarations(value, ctx) {
|
|
644
|
+
for (const issue of checkActionDeclarationsRule(value)) {
|
|
645
|
+
ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
// --- contributions: one ungated surface (S268) ------------------------------
|
|
649
|
+
// Every key optional, and the plugin's `type` gates none of them. .strict()
|
|
650
|
+
// stays: a key this contract does not define is still an error, so a typo
|
|
651
|
+
// and a field removed by a later version both fail loudly instead of being
|
|
652
|
+
// silently dropped. The two cross-checks it runs are what still binds, and
|
|
653
|
+
// they now run for every manifest rather than for some of the old variants.
|
|
654
|
+
const contributionsShape = {
|
|
655
|
+
dataTypes: z.array(DataTypePluginSchema).optional(),
|
|
656
|
+
adminSections: z.array(adminSectionSchema).optional(),
|
|
657
|
+
railEntries: z.array(railEntrySchema).optional(),
|
|
658
|
+
dashboardWidgets: z.array(dashboardWidgetSchema).optional(),
|
|
659
|
+
apiRoutes: z.array(apiRouteSchema).optional(),
|
|
660
|
+
hooks: hooksSchema.optional(),
|
|
661
|
+
scheduledTasks: z.array(scheduledTaskSchema).optional(),
|
|
662
|
+
mediaProcessors: z.array(mediaProcessorSchema).optional(),
|
|
663
|
+
settingsPages: z.array(settingsPageSchema).optional(),
|
|
664
|
+
contentTreeActions: z.array(contentTreeActionSchema).optional(),
|
|
665
|
+
editorToolbar: z.array(editorToolbarSchema).optional(),
|
|
666
|
+
exposedServices: z.array(exposedServiceSchema).optional(),
|
|
667
|
+
serializers: serializerContributionSchema.optional(),
|
|
668
|
+
documentTypes: manifestDocumentTypesSchema,
|
|
669
|
+
themeTokens: themeTokensSchema.optional(),
|
|
670
|
+
templates: z.array(templateEntrySchema).optional(),
|
|
671
|
+
assets: z.array(assetPathSchema).optional(),
|
|
672
|
+
// manifestIdSchema, not the shared one: these are the ids of OTHER
|
|
673
|
+
// PLUGINS, each of which has a manifest and so is itself capped. A
|
|
674
|
+
// four-segment entry here could never resolve to an installable plugin,
|
|
675
|
+
// so catching it at publish beats discovering it at install.
|
|
676
|
+
bundledPlugins: z.array(manifestIdSchema).optional(),
|
|
677
|
+
bundledTemplate: bundledTemplateSchema.optional(),
|
|
678
|
+
};
|
|
679
|
+
const contributionsSchema = z
|
|
680
|
+
.object(contributionsShape)
|
|
681
|
+
.strict()
|
|
682
|
+
.superRefine(checkApiRouteContributions)
|
|
683
|
+
.superRefine(checkTemplateAndAssetContributions)
|
|
684
|
+
.superRefine(checkSlotContributions);
|
|
685
|
+
/**
|
|
686
|
+
* Every contribution key this contract defines, at runtime, derived from
|
|
687
|
+
* the schema above so it cannot drift from it.
|
|
688
|
+
*
|
|
689
|
+
* Exists for the conformance tests that partition these keys into
|
|
690
|
+
* view-bearing and not (S268 Task 3 review, F3). Splitting a list by hand
|
|
691
|
+
* has a third outcome besides "in the right half" and "in the wrong
|
|
692
|
+
* half": in neither half, and therefore never exercised, which is how a
|
|
693
|
+
* mirror of VIEW_BEARING_CONTRIBUTIONS can diverge and still be green.
|
|
694
|
+
* Counting against this set is what closes that.
|
|
695
|
+
*/
|
|
696
|
+
export const CONTRIBUTION_KEYS = Object.keys(contributionsShape);
|
|
697
|
+
// --- the manifest -----------------------------------------------------------
|
|
698
|
+
const baseFields = {
|
|
699
|
+
id: manifestIdSchema,
|
|
700
|
+
name: z.string().min(1),
|
|
701
|
+
// Non-empty for now; strict semver checking belongs to
|
|
702
|
+
// `kardalum plugin validate` (Month 7).
|
|
703
|
+
version: z.string().min(1),
|
|
704
|
+
description: z.string().min(1),
|
|
705
|
+
author: z.string().min(1),
|
|
706
|
+
license: z.string().min(1),
|
|
707
|
+
price: z.number().nonnegative().optional(),
|
|
708
|
+
// Optional by design: sideloaded/dev plugins are unsigned (Tier 2).
|
|
709
|
+
signature: z.string().optional(),
|
|
710
|
+
cmsVersion: z.string().min(1),
|
|
711
|
+
// Capped for the same reason as bundledPlugins above: a dependency names
|
|
712
|
+
// another plugin's manifest id.
|
|
713
|
+
pluginDependencies: z.array(manifestIdSchema).optional(),
|
|
714
|
+
databaseCompatibility: databaseCompatibilitySchema,
|
|
715
|
+
// Optional: a plugin that claims neither thing writes nothing, rather
|
|
716
|
+
// than three falses.
|
|
717
|
+
assertions: AssertionsSchema.optional(),
|
|
718
|
+
migrations: z.array(pluginMigrationSchema).optional(),
|
|
719
|
+
onInstall: callable("onInstall").optional(),
|
|
720
|
+
onUninstall: callable("onUninstall").optional(),
|
|
721
|
+
onActivate: callable("onActivate").optional(),
|
|
722
|
+
onDeactivate: callable("onDeactivate").optional(),
|
|
723
|
+
onUpdate: callable("onUpdate").optional(),
|
|
724
|
+
migrationHooks: migrationHooksSchema.optional(),
|
|
725
|
+
actions: z.array(PluginActionDeclarationSchema).optional(),
|
|
726
|
+
roles: z.array(PluginRoleOfferSchema).optional(),
|
|
727
|
+
docs: z.array(PluginDocsPageSchema).optional(),
|
|
728
|
+
};
|
|
729
|
+
const pluginTypeSchema = z.enum([
|
|
730
|
+
"datatype",
|
|
731
|
+
"section",
|
|
732
|
+
"template",
|
|
733
|
+
"theme",
|
|
734
|
+
"integration",
|
|
735
|
+
"utility",
|
|
736
|
+
"bundle",
|
|
737
|
+
]);
|
|
738
|
+
// One manifest, no union (S268). `type` is a marketplace listing label
|
|
739
|
+
// that parses as one of seven values and gates nothing; what a plugin may
|
|
740
|
+
// do is decided by the capability list derived from `contributions` and by
|
|
741
|
+
// marketplace review. .strict() here is the other half of the contract:
|
|
742
|
+
// an unknown top-level key is still rejected.
|
|
743
|
+
export const CMSPluginSchema = z
|
|
744
|
+
.object({ ...baseFields, type: pluginTypeSchema, contributions: contributionsSchema })
|
|
745
|
+
.strict()
|
|
746
|
+
.superRefine(checkActionContributions)
|
|
747
|
+
.superRefine(checkActionDeclarations)
|
|
748
|
+
.superRefine((value, ctx) => {
|
|
749
|
+
for (const issue of checkDocsDeclaration(value.docs ?? [])) {
|
|
750
|
+
ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
|
|
751
|
+
}
|
|
752
|
+
});
|
|
753
|
+
// Shared by validatePluginManifest and definePlugin — one formatting
|
|
754
|
+
// convention for every validation surface: `path: message`.
|
|
755
|
+
export function formatIssues(issues) {
|
|
756
|
+
return issues.map((issue) => {
|
|
757
|
+
const path = issue.path.join(".");
|
|
758
|
+
return path ? `${path}: ${issue.message}` : issue.message;
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Validate an untrusted value as a plugin manifest. The registry's
|
|
763
|
+
* install() (Session 62) and `kardalum plugin validate` (Month 7) both go
|
|
764
|
+
* through this: errors come back as readable `path: message` strings
|
|
765
|
+
* (e.g. `contributions.adminSection: Unrecognized key ...` for a key this
|
|
766
|
+
* contract does not define).
|
|
767
|
+
*/
|
|
768
|
+
export function validatePluginManifest(value) {
|
|
769
|
+
const result = CMSPluginSchema.safeParse(value);
|
|
770
|
+
if (result.success) {
|
|
771
|
+
return { ok: true, manifest: result.data };
|
|
772
|
+
}
|
|
773
|
+
return { ok: false, errors: formatIssues(result.error.issues) };
|
|
774
|
+
}
|