@kardalum/plugin-sdk 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/CHANGELOG.md +105 -0
- package/README.md +4 -3
- package/dist/admin-section-registry.d.ts +14 -5
- package/dist/admin-section-registry.js +14 -4
- package/dist/assets/asset-picker.d.ts +11 -0
- package/dist/assets/asset-picker.js +109 -0
- package/dist/assets/asset-tree.d.ts +30 -0
- package/dist/assets/asset-tree.js +150 -0
- package/dist/built-in-editor-ids.d.ts +1 -0
- package/dist/built-in-editor-ids.js +20 -0
- package/dist/built-in-settings-schemas.d.ts +2 -0
- package/dist/built-in-settings-schemas.js +27 -0
- package/dist/built-in-value-schemas.js +3 -0
- package/dist/built-ins.js +10 -1
- package/dist/capabilities.js +5 -3
- package/dist/datatype-validation.js +18 -4
- package/dist/datatypes-entry.d.ts +1 -0
- package/dist/datatypes-entry.js +1 -0
- package/dist/entitlement-entry.d.ts +3 -2
- package/dist/entitlement-entry.js +13 -1
- package/dist/entitlement-gate.d.ts +18 -0
- package/dist/entitlement-gate.js +95 -21
- package/dist/entitlement-plan.d.ts +21 -0
- package/dist/entitlement-plan.js +26 -0
- package/dist/entitlement-types.d.ts +21 -4
- package/dist/entitlement.d.ts +29 -1
- package/dist/entitlement.js +39 -0
- package/dist/grid-arrow-step.d.ts +7 -0
- package/dist/grid-arrow-step.js +20 -0
- package/dist/host-entry.d.ts +1 -1
- package/dist/host-entry.js +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +13 -18
- package/dist/license-verdict-keys.d.ts +4 -3
- package/dist/license-verdict-keys.js +4 -7
- package/dist/manifest-entry.d.ts +6 -2
- package/dist/manifest-entry.js +5 -1
- package/dist/manifest-schema.d.ts +56 -63
- package/dist/manifest-schema.js +103 -249
- package/dist/manifest.d.ts +61 -73
- package/dist/manifest.js +13 -36
- package/dist/media/media-picker.js +32 -32
- package/dist/notify.d.ts +17 -0
- package/dist/notify.js +17 -0
- package/dist/plugin-screen-context.d.ts +11 -1
- package/dist/richtext/block-panel.js +19 -20
- package/dist/richtext/extensions.js +10 -1
- package/dist/richtext/insert-menu.js +1 -1
- package/dist/richtext/kardalum-block.js +17 -17
- package/dist/richtext/style-listbox.js +4 -4
- package/dist/richtext-html-entry.d.ts +35 -0
- package/dist/richtext-html-entry.js +73 -0
- package/dist/structured-storage-types.d.ts +11 -0
- package/dist/tailwind.js +10 -3
- package/dist/tokens/tailwind-theme.css +176 -0
- package/dist/tokens/tokens.css +2 -0
- package/dist/tokens/tokens.json +4 -2
- package/dist/type-equality.d.ts +2 -0
- package/dist/type-equality.js +1 -0
- package/dist/vendor-check.d.ts +39 -0
- package/dist/vendor-check.js +79 -0
- package/dist/vendor-entry.d.ts +3 -0
- package/dist/vendor-entry.js +9 -0
- package/dist/vendor-service.d.ts +20 -0
- package/dist/vendor-service.js +20 -0
- package/dist/views/asset-view.d.ts +6 -0
- package/dist/views/asset-view.js +55 -0
- package/dist/views/content-list-settings-view.js +1 -1
- package/dist/views/content-list-view.js +1 -1
- package/dist/views/html-code-editor.js +0 -1
- package/dist/views/html-view.js +1 -1
- package/dist/views/image-view.js +1 -1
- package/dist/views/rich-text-view.js +30 -30
- 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/design-tokens/README.md +1 -1
- package/node_modules/@kardalum/design-tokens/dist/build-theme-css.d.ts +16 -0
- package/node_modules/@kardalum/design-tokens/dist/build-theme-css.js +76 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.js +4 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +176 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +2 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +4 -2
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +2 -0
- package/node_modules/@kardalum/design-tokens/package.json +6 -3
- 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/ui/README.md +1 -1
- package/node_modules/@kardalum/ui/dist/components/button.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.js +5 -2
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +3 -3
- package/node_modules/@kardalum/ui/dist/components/input.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/popover-panel.d.ts +4 -0
- package/node_modules/@kardalum/ui/dist/components/popover-panel.js +13 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.js +5 -4
- package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/tab-strip.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/toast.js +1 -1
- package/node_modules/@kardalum/ui/dist/index.d.ts +1 -0
- package/node_modules/@kardalum/ui/dist/index.js +1 -0
- package/node_modules/@kardalum/ui/package.json +1 -1
- package/package.json +19 -6
package/dist/manifest-schema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { API_ROUTE_ACCESS_TIERS, API_ROUTE_METHODS, DATABASE_DIALECTS, PLUGIN_TYPES, STORAGE_TYPES, TEMPLATE_KINDS, TIER1_DIALECTS, API_ROUTE_RESPONSE_STATUSES_MAX, isApiRouteResponseStatus, ActionStringSchema, DocsLanguageSchema, PLUGIN_ID_MESSAGE, PLUGIN_ID_REGEX, PluginManifestIdSchema, SLOT_ID_MAX, pluginManifestFields, SLOT_ID_REGEX, PluginDocsPageSchema, PluginInstallDeclarationSchema, PluginVendorServiceSchema, apiRoutePathParams, checkApiRouteActions, checkApiRouteDeclarations, checkTemplateAndAssetDeclarations, PluginAssetPathSchema, PluginTemplateEntrySchema, checkDocsDeclaration, checkInstallDeclaration, CreateDocumentTypeRequestSchema, PluginActionDeclarationSchema, PluginRoleOfferSchema, PluginLabelSchema, SlotLabelSchema, checkActionDeclarations as checkActionDeclarationsRule, isPluginActionFor } from "@kardalum/api-schemas";
|
|
3
3
|
import { isActionGated } from "./capabilities.js";
|
|
4
|
-
// Runtime mirror of manifest.ts
|
|
4
|
+
// Runtime mirror of manifest.ts: the same contract, enforced for
|
|
5
5
|
// manifests that arrive as VALUES (Module Federation remotes, sideloaded
|
|
6
6
|
// plugins, the future `kardalum plugin validate` CLI) where the compiler
|
|
7
7
|
// can't help. Since S268 there is ONE manifest shape and ONE contributions
|
|
@@ -15,7 +15,7 @@ import { isActionGated } from "./capabilities.js";
|
|
|
15
15
|
// carries React components and functions (api-schemas must never know
|
|
16
16
|
// React), and third-party tooling needs this validator from the
|
|
17
17
|
// published package.
|
|
18
|
-
// Zod 4: z.function() is not a schema
|
|
18
|
+
// Zod 4: z.function() is not a schema: validate callables with
|
|
19
19
|
// z.custom. The type parameter is the CONTRACT type from manifest.ts,
|
|
20
20
|
// which is what makes the compile-time sync assertion at the bottom of
|
|
21
21
|
// this file hold. React components may be functions OR objects
|
|
@@ -42,21 +42,15 @@ const zodSchemaField = z.instanceof(z.ZodType);
|
|
|
42
42
|
// name (com.kardalum.google-maps.location), so four segments is correct for it.
|
|
43
43
|
// The pattern itself lives in api-schemas (PLUGIN_ID_REGEX), which the nav
|
|
44
44
|
// setting reads too.
|
|
45
|
-
const pluginIdSchema = z
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
// above. Not used for datatype ids, which extend the plugin id with a field
|
|
55
|
-
// name and are legitimately longer.
|
|
56
|
-
const manifestIdSchema = pluginIdSchema.refine((id) => id.split(".").length <= MANIFEST_ID_SEGMENT_MAX, {
|
|
57
|
-
message: `a plugin id has at most ${MANIFEST_ID_SEGMENT_MAX} segments: every action is the plugin id plus an object ` +
|
|
58
|
-
`and a verb, and an action has at most ${ACTION_SEGMENT_MAX} segments, so a longer id could not declare any action`,
|
|
59
|
-
});
|
|
45
|
+
const pluginIdSchema = z.string().regex(PLUGIN_ID_REGEX, PLUGIN_ID_MESSAGE);
|
|
46
|
+
// A plugin manifest's own id: the shared id rules, at most 128 characters, and
|
|
47
|
+
// at most MANIFEST_ID_SEGMENT_MAX segments (an action is the plugin id plus at
|
|
48
|
+
// least an object and a verb, and an action has at most ACTION_SEGMENT_MAX
|
|
49
|
+
// segments, so a longer id could not declare any action). The rule is
|
|
50
|
+
// api-schemas' PluginManifestIdSchema, the one the marketplace door reads a
|
|
51
|
+
// manifest.json by (S311 fix wave). Not used for datatype ids, which extend the
|
|
52
|
+
// plugin id with a field name and are legitimately longer.
|
|
53
|
+
const manifestIdSchema = PluginManifestIdSchema;
|
|
60
54
|
// S234a Task 6c: the catch-all is a singleton the whole upload path
|
|
61
55
|
// depends on (an upload of an extension nothing else claims lands on it,
|
|
62
56
|
// or 400s if there is none). A plugin's install path calls
|
|
@@ -88,14 +82,10 @@ const manifestDocumentTypesSchema = z
|
|
|
88
82
|
// S289: each enum the manual quotes is an exported constant the schema
|
|
89
83
|
// itself uses, so the manual's enum test checks against what is enforced,
|
|
90
84
|
// never a copy (manual-enum-examples.test.ts).
|
|
91
|
-
export
|
|
92
|
-
export const STORAGE_TYPES = ["simple", "structured"];
|
|
85
|
+
export { API_ROUTE_ACCESS_TIERS, DATABASE_DIALECTS, PLUGIN_TYPES, STORAGE_TYPES, TEMPLATE_KINDS, TIER1_DIALECTS };
|
|
93
86
|
// S295: api-schemas' list, the one the apiRoutes rule compares, re-exported so
|
|
94
87
|
// the enum below and the manual's enum test read that same constant.
|
|
95
88
|
export { API_ROUTE_METHODS };
|
|
96
|
-
export const API_ROUTE_ACCESS_TIERS = ["admin", "apiKey", "public"];
|
|
97
|
-
export const TEMPLATE_KINDS = ["page", "layout", "partial"];
|
|
98
|
-
export const PLUGIN_TYPES = ["datatype", "section", "template", "theme", "integration", "utility", "bundle"];
|
|
99
89
|
export const DATATYPE_ENTRY_TYPES = ["datatype"];
|
|
100
90
|
const dialectSchema = z.enum(DATABASE_DIALECTS);
|
|
101
91
|
const databaseCompatibilitySchema = z
|
|
@@ -173,16 +163,27 @@ export const HOOK_EVENTS = [
|
|
|
173
163
|
"user:afterLogin",
|
|
174
164
|
"api:beforeResponse",
|
|
175
165
|
];
|
|
166
|
+
// Each constant above that mirrors a contract type equals it, both ways.
|
|
176
167
|
const hookEventsMatch = true;
|
|
177
168
|
const pluginTypesMatch = true;
|
|
178
169
|
const dialectsMatch = true;
|
|
170
|
+
const storageTypesMatch = true;
|
|
171
|
+
const routeMethodsMatch = true;
|
|
172
|
+
const routeAccessMatch = true;
|
|
173
|
+
const templateKindsMatch = true;
|
|
174
|
+
const viewBearingKeysExist = true;
|
|
179
175
|
void hookEventsMatch;
|
|
180
176
|
void pluginTypesMatch;
|
|
181
177
|
void dialectsMatch;
|
|
178
|
+
void storageTypesMatch;
|
|
179
|
+
void routeMethodsMatch;
|
|
180
|
+
void routeAccessMatch;
|
|
181
|
+
void templateKindsMatch;
|
|
182
|
+
void viewBearingKeysExist;
|
|
182
183
|
// z.partialRecord, not z.record: with enum keys, Zod 4's record is
|
|
183
184
|
// exhaustive (it would demand a handler for all ten events).
|
|
184
185
|
const hooksSchema = z.partialRecord(z.enum(HOOK_EVENTS), callable("hook handler"));
|
|
185
|
-
// The DataTypePlugin contract's structural shape
|
|
186
|
+
// The DataTypePlugin contract's structural shape: shared by manifests
|
|
186
187
|
// (dataTypes contributions arriving as data) and definePlugin (which
|
|
187
188
|
// fronts it with friendlier required-view messages).
|
|
188
189
|
export const DataTypePluginSchema = z
|
|
@@ -207,7 +208,7 @@ export const DataTypePluginSchema = z
|
|
|
207
208
|
deserialize: callable("deserialize"),
|
|
208
209
|
// Runtime-module members only: the manifest.json writer keeps a
|
|
209
210
|
// string-field allowlist, so these never serialize (S198 spec S8).
|
|
210
|
-
// They must still be ACCEPTED here
|
|
211
|
+
// They must still be ACCEPTED here: the object is .strict(), and a
|
|
211
212
|
// plugin author declaring its datatype's validate hook goes through
|
|
212
213
|
// this same schema via definePlugin.
|
|
213
214
|
validate: callable("validate").optional(),
|
|
@@ -231,32 +232,16 @@ const slotIdSchema = z
|
|
|
231
232
|
.string()
|
|
232
233
|
.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')
|
|
233
234
|
.max(SLOT_ID_MAX, `slot ids are at most ${SLOT_ID_MAX} characters, because the id is a segment of the screen's URL`);
|
|
234
|
-
// A
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
//
|
|
240
|
-
// language no locale can ever pick.
|
|
241
|
-
const slotLabelTextSchema = z.string().refine((text) => text.trim() !== "", { message: "must not be empty" });
|
|
242
|
-
const slotLabelSchema = z
|
|
243
|
-
.object({ en: slotLabelTextSchema })
|
|
244
|
-
.catchall(slotLabelTextSchema)
|
|
245
|
-
.superRefine((label, ctx) => {
|
|
246
|
-
for (const key of Object.keys(label)) {
|
|
247
|
-
if (!CultureSchema.safeParse(key).success) {
|
|
248
|
-
ctx.addIssue({
|
|
249
|
-
code: "custom",
|
|
250
|
-
message: `label keys are language codes such as "en", "de" or "pt-BR", not ${JSON.stringify(key)}`,
|
|
251
|
-
path: [key],
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
});
|
|
235
|
+
// A slot's label is api-schemas' SlotLabelSchema (S311 moved it there): a
|
|
236
|
+
// language code to the text shown in that language, `en` required, no blank
|
|
237
|
+
// text, every key a language code under the site's culture rule. The display
|
|
238
|
+
// names of the other surfaces below take PluginLabelSchema, the same map or a
|
|
239
|
+
// plain string; a name other code compares (a data type's, a document type's,
|
|
240
|
+
// a template's) stays a plain string.
|
|
256
241
|
const railEntryInSectionSchema = z
|
|
257
242
|
.object({
|
|
258
243
|
id: slotIdSchema,
|
|
259
|
-
label:
|
|
244
|
+
label: SlotLabelSchema,
|
|
260
245
|
icon: z.string().min(1).optional(),
|
|
261
246
|
action: ActionStringSchema,
|
|
262
247
|
view: componentSchema,
|
|
@@ -265,7 +250,7 @@ const railEntryInSectionSchema = z
|
|
|
265
250
|
const adminSectionSchema = z
|
|
266
251
|
.object({
|
|
267
252
|
id: slotIdSchema,
|
|
268
|
-
label:
|
|
253
|
+
label: SlotLabelSchema,
|
|
269
254
|
icon: z.string().min(1),
|
|
270
255
|
action: ActionStringSchema,
|
|
271
256
|
view: componentSchema,
|
|
@@ -292,7 +277,7 @@ const railEntrySchema = z
|
|
|
292
277
|
.object({
|
|
293
278
|
id: slotIdSchema,
|
|
294
279
|
section: z.enum(BUILT_IN_RAIL_SECTIONS),
|
|
295
|
-
label:
|
|
280
|
+
label: SlotLabelSchema,
|
|
296
281
|
icon: z.string().min(1).optional(),
|
|
297
282
|
action: ActionStringSchema,
|
|
298
283
|
view: componentSchema,
|
|
@@ -301,7 +286,7 @@ const railEntrySchema = z
|
|
|
301
286
|
const dashboardWidgetSchema = z
|
|
302
287
|
.object({
|
|
303
288
|
id: z.string().min(1),
|
|
304
|
-
name:
|
|
289
|
+
name: PluginLabelSchema,
|
|
305
290
|
view: componentSchema,
|
|
306
291
|
action: ActionStringSchema,
|
|
307
292
|
})
|
|
@@ -363,7 +348,7 @@ const serializerContributionSchema = z
|
|
|
363
348
|
const scheduledTaskSchema = z
|
|
364
349
|
.object({
|
|
365
350
|
id: z.string().min(1),
|
|
366
|
-
name:
|
|
351
|
+
name: PluginLabelSchema,
|
|
367
352
|
cron: z.string().min(1),
|
|
368
353
|
run: callable("run"),
|
|
369
354
|
})
|
|
@@ -371,37 +356,12 @@ const scheduledTaskSchema = z
|
|
|
371
356
|
const mediaProcessorSchema = z
|
|
372
357
|
.object({
|
|
373
358
|
id: z.string().min(1),
|
|
374
|
-
name:
|
|
359
|
+
name: PluginLabelSchema,
|
|
375
360
|
process: callable("process"),
|
|
376
361
|
})
|
|
377
362
|
.strict();
|
|
378
|
-
const settingsPageSchema = z
|
|
379
|
-
.object({
|
|
380
|
-
id: z.string().min(1),
|
|
381
|
-
name: z.string().min(1),
|
|
382
|
-
view: componentSchema,
|
|
383
|
-
action: ActionStringSchema,
|
|
384
|
-
})
|
|
385
|
-
.strict();
|
|
386
|
-
const contentTreeActionSchema = z
|
|
387
|
-
.object({
|
|
388
|
-
id: z.string().min(1),
|
|
389
|
-
label: z.string().min(1),
|
|
390
|
-
onSelect: callable("onSelect"),
|
|
391
|
-
action: ActionStringSchema,
|
|
392
|
-
})
|
|
393
|
-
.strict();
|
|
394
|
-
const editorToolbarSchema = z
|
|
395
|
-
.object({
|
|
396
|
-
id: z.string().min(1),
|
|
397
|
-
label: z.string().min(1),
|
|
398
|
-
icon: z.string().min(1),
|
|
399
|
-
onClick: callable("onClick"),
|
|
400
|
-
action: ActionStringSchema,
|
|
401
|
-
})
|
|
402
|
-
.strict();
|
|
403
363
|
const exposedServiceSchema = z
|
|
404
|
-
.object({ id: z.string().min(1), name:
|
|
364
|
+
.object({ id: z.string().min(1), name: PluginLabelSchema, service: z.unknown() })
|
|
405
365
|
.strict();
|
|
406
366
|
const bundledTemplateSchema = z
|
|
407
367
|
.object({
|
|
@@ -423,7 +383,7 @@ const safeCssTokenSchema = z
|
|
|
423
383
|
.string()
|
|
424
384
|
.max(200)
|
|
425
385
|
.regex(new RegExp('^[^{};\\u0000-\\u001f\\u007f]+$'), "must not contain CSS-escaping characters");
|
|
426
|
-
// themeTokens: minimal strict mirror of ThemeTokenOverrides
|
|
386
|
+
// themeTokens: minimal strict mirror of ThemeTokenOverrides: only
|
|
427
387
|
// color/radius keys exist (themes are cosmetic by construction);
|
|
428
388
|
// design-tokens has no Zod and shouldn't gain one, so token values are
|
|
429
389
|
// validated shallowly here.
|
|
@@ -436,158 +396,18 @@ const themeTokensSchema = z
|
|
|
436
396
|
// --- templates/assets contributions (S192 §8) -------------------------------
|
|
437
397
|
// Any plugin may declare templates and assets (S268). What still binds is
|
|
438
398
|
// the cross-check below: a `page` kind entry may only name a document type
|
|
439
|
-
// the same manifest declares.
|
|
440
|
-
//
|
|
441
|
-
//
|
|
442
|
-
// @kardalum/api-schemas (package.json lists it, and
|
|
443
|
-
// CreateDocumentTypeRequestSchema is value-imported above for
|
|
444
|
-
// contributionsSchema). The real one-way rule runs the other direction:
|
|
445
|
-
// api-schemas must never know about React, which the manifest carries,
|
|
446
|
-
// which is why the manifest schema lives here rather than there.
|
|
447
|
-
// These rules stay local because the manifest's versions are strictly
|
|
448
|
-
// narrower than the server's: assetPathSchema below also refuses a
|
|
449
|
-
// "public/" prefix and non-text extensions, neither of which
|
|
450
|
-
// api-schemas' AssetPathSchema does. They are still deliberate mirrors
|
|
451
|
-
// of api-schemas' AssetPathSchema / TemplateAliasSchema, so a change
|
|
452
|
-
// there wants a matching change here.
|
|
453
|
-
const TEMPLATE_ALIAS_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
454
|
-
// A path segment: starts alnum, then alnum/dot/dash/underscore. This alone
|
|
455
|
-
// rejects "." and ".." segments (both start with a dot, never alnum) —
|
|
456
|
-
// no separate traversal check needed.
|
|
457
|
-
const PATH_SEGMENT_REGEX = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
458
|
-
// Case-insensitive first-segment refusal — same reserved roots the
|
|
459
|
-
// request pipeline enforces for real routes (S192 §6 / since S184).
|
|
460
|
-
const RESERVED_ASSET_ROOTS = new Set(["kardalum", "api", "docs", "plugin-assets", "media"]);
|
|
461
|
-
// I3 (S196 final-fix wave): registered assets (contributions.assets) are
|
|
462
|
-
// the admin-editable css/js layer per the S192 spec — the install pipeline
|
|
463
|
-
// reads a declared asset's file as utf8 and registers it as TEXT content
|
|
464
|
-
// with version history, so a binary file declared here would be silently
|
|
465
|
-
// UTF-8-mangled on install. Ship binaries as unregistered public/ files
|
|
466
|
-
// instead (still copied byte-for-byte, just without a registry row). This
|
|
467
|
-
// allowlist is intentionally narrower than asset-fs.ts's isTextPath (which
|
|
468
|
-
// classifies the walked, unregistered tree and is more permissive) — it is
|
|
469
|
-
// mirrored byte-for-byte in kardalum plugin's checks/templates.ts and the
|
|
470
|
-
// marketplace's validation-checks.ts; keep all three in lockstep.
|
|
471
|
-
const REGISTERED_ASSET_TEXT_EXTENSIONS = new Set(["css", "js", "mjs", "json", "svg", "txt", "md"]);
|
|
472
|
-
function hasAllowedRegisteredAssetExtension(value) {
|
|
473
|
-
const base = value.split("/").pop() ?? value;
|
|
474
|
-
const dot = base.lastIndexOf(".");
|
|
475
|
-
if (dot <= 0)
|
|
476
|
-
return false; // no extension, or a dotfile with no extension of its own
|
|
477
|
-
return REGISTERED_ASSET_TEXT_EXTENSIONS.has(base.slice(dot + 1).toLowerCase());
|
|
478
|
-
}
|
|
479
|
-
function isRelativeSlashPath(value) {
|
|
480
|
-
return value.length > 0 && !value.startsWith("/") && !value.includes("\\");
|
|
481
|
-
}
|
|
482
|
-
function hasValidSegments(value) {
|
|
483
|
-
return value.split("/").every((segment) => PATH_SEGMENT_REGEX.test(segment));
|
|
484
|
-
}
|
|
485
|
-
const templateAliasSchema = z
|
|
486
|
-
.string()
|
|
487
|
-
.min(1)
|
|
488
|
-
.max(120)
|
|
489
|
-
.regex(TEMPLATE_ALIAS_REGEX, "must be lowercase kebab-case, e.g. product-page");
|
|
490
|
-
const templateFileSchema = z
|
|
491
|
-
.string()
|
|
492
|
-
.min(1)
|
|
493
|
-
.max(255)
|
|
494
|
-
.refine(isRelativeSlashPath, {
|
|
495
|
-
message: "must be a relative path using forward slashes (no leading \"/\", no \"\\\\\")",
|
|
496
|
-
})
|
|
497
|
-
.refine((value) => value.toLowerCase().endsWith(".liquid"), { message: "must end with .liquid" })
|
|
498
|
-
.refine(hasValidSegments, {
|
|
499
|
-
message: 'path segments must match [a-z0-9][a-z0-9._-]*: no "." or ".." segments',
|
|
500
|
-
});
|
|
501
|
-
const assetPathSchema = z
|
|
502
|
-
.string()
|
|
503
|
-
.min(1)
|
|
504
|
-
.max(400)
|
|
505
|
-
.refine(isRelativeSlashPath, {
|
|
506
|
-
message: "must be a relative path using forward slashes (no leading \"/\", no \"\\\\\")",
|
|
507
|
-
})
|
|
508
|
-
.refine(hasValidSegments, {
|
|
509
|
-
message: 'path segments must match [a-z0-9][a-z0-9._-]*: no "." or ".." segments',
|
|
510
|
-
})
|
|
511
|
-
.refine((value) => {
|
|
512
|
-
const firstSegment = value.split("/")[0]?.toLowerCase() ?? "";
|
|
513
|
-
return !RESERVED_ASSET_ROOTS.has(firstSegment);
|
|
514
|
-
}, { message: `must not be rooted at a reserved path (${[...RESERVED_ASSET_ROOTS].sort().join(", ")})` })
|
|
515
|
-
// contributions.assets entries flow verbatim into the server's
|
|
516
|
-
// AssetMirrorService.register at install time, whose AssetPathSchema is
|
|
517
|
-
// already public/-relative — a "public/"-prefixed entry here would
|
|
518
|
-
// resolve to public/public/…. Rejecting the prefix outright (rather than
|
|
519
|
-
// just documenting the bare convention) makes the ambiguity impossible
|
|
520
|
-
// for plugin authors to hit.
|
|
521
|
-
.refine((value) => (value.split("/")[0]?.toLowerCase() ?? "") !== "public", {
|
|
522
|
-
message: 'declare asset paths relative to public/: drop the "public/" prefix',
|
|
523
|
-
})
|
|
524
|
-
// I3: registered assets are text-only — see REGISTERED_ASSET_TEXT_EXTENSIONS above.
|
|
525
|
-
.refine(hasAllowedRegisteredAssetExtension, {
|
|
526
|
-
message: "registered assets are text files editable in the admin: ship binary files as unregistered public/ files instead",
|
|
527
|
-
});
|
|
528
|
-
const templateEntrySchema = z
|
|
529
|
-
.object({
|
|
530
|
-
file: templateFileSchema,
|
|
531
|
-
name: z.string().min(1),
|
|
532
|
-
alias: templateAliasSchema,
|
|
533
|
-
kind: z.enum(TEMPLATE_KINDS),
|
|
534
|
-
documentType: z.string().min(1).optional(),
|
|
535
|
-
})
|
|
536
|
-
.strict();
|
|
399
|
+
// the same manifest declares. The entry and path rules and the cross-checks
|
|
400
|
+
// are api-schemas' (plugin-template-payload.ts, S311), the one copy the
|
|
401
|
+
// delivery registry and the server's install read too.
|
|
537
402
|
// The templates/assets cross-checks, run by contributionsSchema for every
|
|
538
403
|
// manifest (S268: one contributions object, so one place this fires).
|
|
539
404
|
// `documentTypes` is read structurally: a manifest that declares none can
|
|
540
405
|
// never resolve a `documentType` reference, which is the correct outcome
|
|
541
406
|
// rather than a special case.
|
|
542
407
|
function checkTemplateAndAssetContributions(value, ctx) {
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
(value.templates ?? []).forEach((template, index) => {
|
|
547
|
-
if (seenAliases.has(template.alias)) {
|
|
548
|
-
ctx.addIssue({
|
|
549
|
-
code: "custom",
|
|
550
|
-
message: `Duplicate template alias "${template.alias}": aliases must be unique within a manifest`,
|
|
551
|
-
path: ["templates", index, "alias"],
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
seenAliases.add(template.alias);
|
|
555
|
-
if (seenFiles.has(template.file)) {
|
|
556
|
-
ctx.addIssue({
|
|
557
|
-
code: "custom",
|
|
558
|
-
message: `Duplicate template file "${template.file}": files must be unique within a manifest`,
|
|
559
|
-
path: ["templates", index, "file"],
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
seenFiles.add(template.file);
|
|
563
|
-
if (template.kind === "page") {
|
|
564
|
-
if (template.documentType !== undefined && !documentTypeNames.has(template.documentType)) {
|
|
565
|
-
ctx.addIssue({
|
|
566
|
-
code: "custom",
|
|
567
|
-
message: `documentType "${template.documentType}" does not match any name in this manifest's documentTypes contribution`,
|
|
568
|
-
path: ["templates", index, "documentType"],
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
else if (template.documentType !== undefined) {
|
|
573
|
-
ctx.addIssue({
|
|
574
|
-
code: "custom",
|
|
575
|
-
message: `documentType is only allowed on "page" kind templates, not "${template.kind}"`,
|
|
576
|
-
path: ["templates", index, "documentType"],
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
});
|
|
580
|
-
const seenAssets = new Set();
|
|
581
|
-
(value.assets ?? []).forEach((asset, index) => {
|
|
582
|
-
if (seenAssets.has(asset)) {
|
|
583
|
-
ctx.addIssue({
|
|
584
|
-
code: "custom",
|
|
585
|
-
message: `Duplicate asset path "${asset}": asset paths must be unique within a manifest`,
|
|
586
|
-
path: ["assets", index],
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
seenAssets.add(asset);
|
|
590
|
-
});
|
|
408
|
+
for (const issue of checkTemplateAndAssetDeclarations(value)) {
|
|
409
|
+
ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
|
|
410
|
+
}
|
|
591
411
|
}
|
|
592
412
|
// A slot's id is the last segment of its URL (spec D3), so it must be unique
|
|
593
413
|
// where its URL would collide: among this plugin's sections, within one
|
|
@@ -595,25 +415,29 @@ function checkTemplateAndAssetContributions(value, ctx) {
|
|
|
595
415
|
// three lists the same id is fine, because the URLs differ
|
|
596
416
|
// (/plugins/<plugin>/<id>, /plugins/<plugin>/<section>/<id>,
|
|
597
417
|
// /<built-in>/plugins/<plugin>/<id>), and two plugins may share any id
|
|
598
|
-
// because every one of those URLs carries the plugin's id (D8).
|
|
418
|
+
// because every one of those URLs carries the plugin's id (D8). A dashboard
|
|
419
|
+
// widget has no URL, but the Home page keys its card by plugin id and widget
|
|
420
|
+
// id (S313b, W8), so its id is unique among this plugin's widgets too.
|
|
599
421
|
function checkSlotContributions(value, ctx) {
|
|
600
|
-
const unique = (entries, path, what) => {
|
|
422
|
+
const unique = (entries, path, what, because) => {
|
|
601
423
|
const seen = new Set();
|
|
602
424
|
entries.forEach((entry, index) => {
|
|
603
425
|
if (seen.has(entry.id)) {
|
|
604
426
|
ctx.addIssue({
|
|
605
427
|
code: "custom",
|
|
606
|
-
message: `Duplicate ${what} id "${entry.id}": ids must be unique ${what === "rail entry" ? "within one section's rail" : `within ${path[0]}`}, because
|
|
428
|
+
message: `Duplicate ${what} id "${entry.id}": ids must be unique ${what === "rail entry" ? "within one section's rail" : `within ${path[0]}`}, ${because}`,
|
|
607
429
|
path: [...path, index, "id"],
|
|
608
430
|
});
|
|
609
431
|
}
|
|
610
432
|
seen.add(entry.id);
|
|
611
433
|
});
|
|
612
434
|
};
|
|
435
|
+
const inUrl = "because the id is part of the slot's URL";
|
|
613
436
|
const sections = value.adminSections ?? [];
|
|
614
|
-
unique(sections, ["adminSections"], "section");
|
|
615
|
-
sections.forEach((section, index) => unique(section.rail ?? [], ["adminSections", index, "rail"], "rail entry"));
|
|
616
|
-
unique(value.railEntries ?? [], ["railEntries"], "built-in rail entry");
|
|
437
|
+
unique(sections, ["adminSections"], "section", inUrl);
|
|
438
|
+
sections.forEach((section, index) => unique(section.rail ?? [], ["adminSections", index, "rail"], "rail entry", inUrl));
|
|
439
|
+
unique(value.railEntries ?? [], ["railEntries"], "built-in rail entry", inUrl);
|
|
440
|
+
unique(value.dashboardWidgets ?? [], ["dashboardWidgets"], "dashboard widget", "because the Home page tells a plugin's widgets apart by their ids");
|
|
617
441
|
}
|
|
618
442
|
// Every action a plugin declares must sit in that plugin's own namespace (its
|
|
619
443
|
// full reverse-domain id plus a dot), so one plugin cannot declare an action in
|
|
@@ -679,21 +503,20 @@ const contributionsShape = {
|
|
|
679
503
|
hooks: hooksSchema.optional(),
|
|
680
504
|
scheduledTasks: z.array(scheduledTaskSchema).optional(),
|
|
681
505
|
mediaProcessors: z.array(mediaProcessorSchema).optional(),
|
|
682
|
-
settingsPages: z.array(settingsPageSchema).optional(),
|
|
683
|
-
contentTreeActions: z.array(contentTreeActionSchema).optional(),
|
|
684
|
-
editorToolbar: z.array(editorToolbarSchema).optional(),
|
|
685
506
|
exposedServices: z.array(exposedServiceSchema).optional(),
|
|
686
507
|
serializers: serializerContributionSchema.optional(),
|
|
687
508
|
documentTypes: manifestDocumentTypesSchema,
|
|
688
509
|
themeTokens: themeTokensSchema.optional(),
|
|
689
|
-
templates: z.array(
|
|
690
|
-
assets: z.array(
|
|
510
|
+
templates: z.array(PluginTemplateEntrySchema).optional(),
|
|
511
|
+
assets: z.array(PluginAssetPathSchema).optional(),
|
|
691
512
|
// manifestIdSchema, not the shared one: these are the ids of OTHER
|
|
692
513
|
// PLUGINS, each of which has a manifest and so is itself capped. A
|
|
693
514
|
// four-segment entry here could never resolve to an installable plugin,
|
|
694
515
|
// so catching it at publish beats discovering it at install.
|
|
695
516
|
bundledPlugins: z.array(manifestIdSchema).optional(),
|
|
696
517
|
bundledTemplate: bundledTemplateSchema.optional(),
|
|
518
|
+
// S314n3 (D1): `true` or absent; the capability is derived from it.
|
|
519
|
+
notifications: z.literal(true).optional(),
|
|
697
520
|
};
|
|
698
521
|
const contributionsSchema = z
|
|
699
522
|
.object(contributionsShape)
|
|
@@ -714,18 +537,17 @@ const contributionsSchema = z
|
|
|
714
537
|
export const CONTRIBUTION_KEYS = Object.keys(contributionsShape);
|
|
715
538
|
// --- the manifest -----------------------------------------------------------
|
|
716
539
|
const baseFields = {
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
//
|
|
720
|
-
//
|
|
721
|
-
|
|
722
|
-
description
|
|
723
|
-
|
|
724
|
-
|
|
540
|
+
// S311 fix wave (I-A): id, version, name, description, author, license and
|
|
541
|
+
// cmsVersion follow the rules api-schemas defines once
|
|
542
|
+
// (plugin-manifest-fields.ts), the ones the marketplace door reads a
|
|
543
|
+
// manifest.json by: the id at most 128 characters, the version a semver, the
|
|
544
|
+
// listing texts capped, and no control or direction-override character in
|
|
545
|
+
// the name, the description or the author. Before this they were only
|
|
546
|
+
// non-empty here, so `validate` passed a manifest the door then refused.
|
|
547
|
+
...pluginManifestFields,
|
|
725
548
|
price: z.number().nonnegative().optional(),
|
|
726
549
|
// Optional by design: sideloaded/dev plugins are unsigned (Tier 2).
|
|
727
550
|
signature: z.string().optional(),
|
|
728
|
-
cmsVersion: z.string().min(1),
|
|
729
551
|
// Capped for the same reason as bundledPlugins above: a dependency names
|
|
730
552
|
// another plugin's manifest id.
|
|
731
553
|
pluginDependencies: z.array(manifestIdSchema).optional(),
|
|
@@ -753,6 +575,10 @@ const baseFields = {
|
|
|
753
575
|
// defaults among the choices) runs below through checkInstallDeclaration,
|
|
754
576
|
// the function `kardalum plugin validate` and the marketplace door run.
|
|
755
577
|
install: PluginInstallDeclarationSchema.optional(),
|
|
578
|
+
// S320 (D6): the author's server, an origin and nothing else (strict). An
|
|
579
|
+
// http://localhost origin parses (a plugin in development); both publish
|
|
580
|
+
// gates refuse it (vendorServiceCheck in @kardalum/plugin-package).
|
|
581
|
+
vendorService: PluginVendorServiceSchema.optional(),
|
|
756
582
|
};
|
|
757
583
|
const pluginTypeSchema = z.enum(PLUGIN_TYPES);
|
|
758
584
|
// One manifest, no union (S268). `type` is a marketplace listing label
|
|
@@ -780,6 +606,34 @@ export const CMSPluginSchema = z
|
|
|
780
606
|
for (const issue of checkApiRouteActions(value)) {
|
|
781
607
|
ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
|
|
782
608
|
}
|
|
609
|
+
})
|
|
610
|
+
.superRefine((value, ctx) => {
|
|
611
|
+
// S311 (S295): schema.params must name exactly the path's :name parameters,
|
|
612
|
+
// or the route answers 400 on every call. SDK-side only: manifest.json
|
|
613
|
+
// carries no Zod.
|
|
614
|
+
(value.contributions.apiRoutes ?? []).forEach((route, index) => {
|
|
615
|
+
const params = route.schema?.params;
|
|
616
|
+
if (params === undefined)
|
|
617
|
+
return;
|
|
618
|
+
const named = apiRoutePathParams(route.path);
|
|
619
|
+
const declared = params instanceof z.ZodObject ? Object.keys(params.shape) : null;
|
|
620
|
+
const where = ["contributions", "apiRoutes", index, "schema", "params"];
|
|
621
|
+
if (declared === null) {
|
|
622
|
+
if (named.length > 0) {
|
|
623
|
+
ctx.addIssue({ code: "custom", path: where, message: "schema.params must be a z.object so its keys can be compared with the path's :name parameters" });
|
|
624
|
+
}
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
const missing = named.filter((name) => !declared.includes(name));
|
|
628
|
+
const extra = declared.filter((name) => !named.includes(name));
|
|
629
|
+
if (missing.length > 0 || extra.length > 0) {
|
|
630
|
+
ctx.addIssue({
|
|
631
|
+
code: "custom",
|
|
632
|
+
path: where,
|
|
633
|
+
message: `schema.params keys must equal the path's :name parameters (path names ${JSON.stringify(named)}, schema declares ${JSON.stringify(declared)})`,
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
});
|
|
783
637
|
})
|
|
784
638
|
.superRefine((value, ctx) => {
|
|
785
639
|
for (const issue of checkDocsDeclaration(value.docs ?? [])) {
|
|
@@ -799,7 +653,7 @@ export const CMSPluginSchema = z
|
|
|
799
653
|
ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
|
|
800
654
|
}
|
|
801
655
|
});
|
|
802
|
-
// Shared by validatePluginManifest and definePlugin
|
|
656
|
+
// Shared by validatePluginManifest and definePlugin: one formatting
|
|
803
657
|
// convention for every validation surface: `path: message`.
|
|
804
658
|
export function formatIssues(issues) {
|
|
805
659
|
return issues.map((issue) => {
|
|
@@ -811,8 +665,8 @@ export function formatIssues(issues) {
|
|
|
811
665
|
* Validate an untrusted value as a plugin manifest. The registry's
|
|
812
666
|
* install() (Session 62) and `kardalum plugin validate` (Month 7) both go
|
|
813
667
|
* through this: errors come back as readable `path: message` strings
|
|
814
|
-
* (e.g. `contributions
|
|
815
|
-
* contract does not define).
|
|
668
|
+
* (e.g. `contributions: Unrecognized key: "adminSection"` for a key this
|
|
669
|
+
* contract does not define, listed before any issue it causes).
|
|
816
670
|
*/
|
|
817
671
|
export function validatePluginManifest(value) {
|
|
818
672
|
const result = CMSPluginSchema.safeParse(value);
|