@kardalum/plugin-sdk 0.15.0 → 0.17.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 +49 -1
- package/README.md +10 -0
- package/dist/admin-section-registry.d.ts +14 -5
- package/dist/admin-section-registry.js +14 -4
- package/dist/built-in-value-schemas.js +1 -1
- package/dist/built-ins.js +2 -2
- package/dist/capabilities.d.ts +8 -78
- package/dist/capabilities.js +23 -322
- package/dist/host-entry.d.ts +1 -1
- package/dist/host-entry.js +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +13 -12
- package/dist/license-verdict-keys.d.ts +4 -3
- package/dist/license-verdict-keys.js +6 -5
- package/dist/manifest-entry.d.ts +3 -3
- package/dist/manifest-entry.js +2 -2
- package/dist/manifest-schema.d.ts +113 -56
- package/dist/manifest-schema.js +192 -295
- package/dist/manifest.d.ts +145 -112
- package/dist/manifest.js +13 -36
- package/dist/media/media-picker.js +21 -12
- package/dist/media/upload-error.d.ts +1 -1
- package/dist/media/upload-error.js +1 -1
- package/dist/plugin-context.d.ts +7 -0
- package/dist/plugin-context.js +7 -0
- package/dist/plugin-screen-context.d.ts +44 -3
- package/dist/plugin-screen-context.js +27 -2
- package/dist/read-all-pages.d.ts +23 -0
- package/dist/read-all-pages.js +30 -0
- package/dist/richtext/block-panel.js +6 -6
- package/dist/richtext/insert-menu.js +4 -4
- package/dist/richtext/style-listbox.js +4 -4
- package/dist/tokens/tokens.css +1 -0
- package/dist/tokens/tokens.json +2 -1
- package/dist/type-equality.d.ts +2 -0
- package/dist/type-equality.js +1 -0
- package/dist/views/content-list-view.js +2 -2
- package/dist/views/html-view.js +1 -1
- package/dist/views/image-view.js +24 -39
- package/dist/views/rich-text-view.js +3 -3
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +43 -25
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +60 -8
- 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 +33 -2
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +22 -1
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +50 -15
- 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/content-api.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +18 -13
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +11 -7
- 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.d.ts +1 -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 +143 -57
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +110 -60
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +67 -40
- package/node_modules/@kardalum/api-schemas/dist/index.js +35 -19
- 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/management-multipart.schema.d.ts +73 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +356 -16
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +93 -10
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +38 -30
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +2 -2
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +1 -1
- 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 +69 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +76 -9
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +84 -24
- 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 +69 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +597 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +503 -0
- 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 +82 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +228 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +33 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +28 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +11 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +17 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +58 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +198 -0
- 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-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 +74 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +132 -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 +8 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +23 -4
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +4 -4
- package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +97 -0
- 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 +36 -6
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +17 -5
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +52 -33
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +195 -56
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +19 -3
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
- 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 +105 -1
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +47 -7
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +30 -2
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +19 -5
- 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 +15 -3
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +19 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +22 -0
- package/node_modules/@kardalum/api-schemas/package.json +2 -2
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +3 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/README.md +4 -1
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +96 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +66 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +346 -0
- 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 +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +60 -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 +133 -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 +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +158 -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 +11 -2
- package/node_modules/@kardalum/plugin-package/dist/index.js +8 -2
- 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 +3 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +7 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +38 -1
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +84 -16
- 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/types.d.ts +4 -6
- package/node_modules/@kardalum/plugin-package/dist/types.js +15 -1
- package/node_modules/@kardalum/plugin-package/package.json +9 -2
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +2 -2
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +2 -2
- package/node_modules/@kardalum/ui/dist/components/property-field.js +4 -1
- package/node_modules/@kardalum/ui/package.json +1 -1
- package/package.json +6 -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, 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
|
|
@@ -25,10 +25,11 @@ const componentSchema = z.custom((value) => typeof value === "function" || (type
|
|
|
25
25
|
// A JSON Schema document is a plain object (DataTypePlugin.schema is the
|
|
26
26
|
// JSONSchema7 object interface, not the boolean shorthand).
|
|
27
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()
|
|
30
|
-
// ZodType class), not just an object that looks like one
|
|
31
|
-
//
|
|
28
|
+
// A plugin-declared request schema must be a REAL Zod v4 schema instance
|
|
29
|
+
// (z.object(...), z.string() and the rest: every Zod schema extends the base
|
|
30
|
+
// ZodType class), not just an object that looks like one. The server compiles
|
|
31
|
+
// it with its validator compiler (fastify-type-provider-zod), which runs it
|
|
32
|
+
// through Zod's core safeParse, and that needs a real v4 instance.
|
|
32
33
|
const zodSchemaField = z.instanceof(z.ZodType);
|
|
33
34
|
// Reverse-domain id per the documented contract, e.g. "com.vendor.name".
|
|
34
35
|
// Shared by manifest ids, datatype ids and plugin references, so it carries
|
|
@@ -41,26 +42,20 @@ const zodSchemaField = z.instanceof(z.ZodType);
|
|
|
41
42
|
// name (com.kardalum.google-maps.location), so four segments is correct for it.
|
|
42
43
|
// The pattern itself lives in api-schemas (PLUGIN_ID_REGEX), which the nav
|
|
43
44
|
// setting reads too.
|
|
44
|
-
const pluginIdSchema = z
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
|
|
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
|
-
});
|
|
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;
|
|
59
54
|
// S234a Task 6c: the catch-all is a singleton the whole upload path
|
|
60
55
|
// depends on (an upload of an extension nothing else claims lands on it,
|
|
61
56
|
// or 400s if there is none). A plugin's install path calls
|
|
62
57
|
// DocumentTypeService.createDocumentType directly, bypassing the sweep
|
|
63
|
-
// that the /api/document-types routes use to keep the flag a singleton,
|
|
58
|
+
// that the /api/manage/v1/document-types routes use to keep the flag a singleton,
|
|
64
59
|
// and uninstalling a plugin deletes every document type it contributed.
|
|
65
60
|
// A plugin allowed to hold the catch-all could therefore take it to zero
|
|
66
61
|
// on uninstall, so it is refused here, at the one schema every
|
|
@@ -84,10 +79,18 @@ const manifestDocumentTypesSchema = z
|
|
|
84
79
|
}
|
|
85
80
|
});
|
|
86
81
|
});
|
|
87
|
-
|
|
82
|
+
// S289: each enum the manual quotes is an exported constant the schema
|
|
83
|
+
// itself uses, so the manual's enum test checks against what is enforced,
|
|
84
|
+
// never a copy (manual-enum-examples.test.ts).
|
|
85
|
+
export { API_ROUTE_ACCESS_TIERS, DATABASE_DIALECTS, PLUGIN_TYPES, STORAGE_TYPES, TEMPLATE_KINDS, TIER1_DIALECTS };
|
|
86
|
+
// S295: api-schemas' list, the one the apiRoutes rule compares, re-exported so
|
|
87
|
+
// the enum below and the manual's enum test read that same constant.
|
|
88
|
+
export { API_ROUTE_METHODS };
|
|
89
|
+
export const DATATYPE_ENTRY_TYPES = ["datatype"];
|
|
90
|
+
const dialectSchema = z.enum(DATABASE_DIALECTS);
|
|
88
91
|
const databaseCompatibilitySchema = z
|
|
89
92
|
.object({
|
|
90
|
-
storageType: z.enum(
|
|
93
|
+
storageType: z.enum(STORAGE_TYPES),
|
|
91
94
|
// A plugin supporting zero databases can never be installed anywhere.
|
|
92
95
|
supported: z.array(dialectSchema).min(1),
|
|
93
96
|
unsupportedReason: z.partialRecord(dialectSchema, z.string()).optional(),
|
|
@@ -148,7 +151,7 @@ const migrationHooksSchema = z
|
|
|
148
151
|
validateMigration: callable("validateMigration").optional(),
|
|
149
152
|
})
|
|
150
153
|
.strict();
|
|
151
|
-
const HOOK_EVENTS = [
|
|
154
|
+
export const HOOK_EVENTS = [
|
|
152
155
|
"content:beforeSave",
|
|
153
156
|
"content:afterSave",
|
|
154
157
|
"content:beforePublish",
|
|
@@ -160,10 +163,27 @@ const HOOK_EVENTS = [
|
|
|
160
163
|
"user:afterLogin",
|
|
161
164
|
"api:beforeResponse",
|
|
162
165
|
];
|
|
166
|
+
// Each constant above that mirrors a contract type equals it, both ways.
|
|
167
|
+
const hookEventsMatch = true;
|
|
168
|
+
const pluginTypesMatch = true;
|
|
169
|
+
const dialectsMatch = true;
|
|
170
|
+
const storageTypesMatch = true;
|
|
171
|
+
const routeMethodsMatch = true;
|
|
172
|
+
const routeAccessMatch = true;
|
|
173
|
+
const templateKindsMatch = true;
|
|
174
|
+
const viewBearingKeysExist = true;
|
|
175
|
+
void hookEventsMatch;
|
|
176
|
+
void pluginTypesMatch;
|
|
177
|
+
void dialectsMatch;
|
|
178
|
+
void storageTypesMatch;
|
|
179
|
+
void routeMethodsMatch;
|
|
180
|
+
void routeAccessMatch;
|
|
181
|
+
void templateKindsMatch;
|
|
182
|
+
void viewBearingKeysExist;
|
|
163
183
|
// z.partialRecord, not z.record: with enum keys, Zod 4's record is
|
|
164
184
|
// exhaustive (it would demand a handler for all ten events).
|
|
165
185
|
const hooksSchema = z.partialRecord(z.enum(HOOK_EVENTS), callable("hook handler"));
|
|
166
|
-
// The DataTypePlugin contract's structural shape
|
|
186
|
+
// The DataTypePlugin contract's structural shape: shared by manifests
|
|
167
187
|
// (dataTypes contributions arriving as data) and definePlugin (which
|
|
168
188
|
// fronts it with friendlier required-view messages).
|
|
169
189
|
export const DataTypePluginSchema = z
|
|
@@ -172,7 +192,7 @@ export const DataTypePluginSchema = z
|
|
|
172
192
|
name: z.string().min(1),
|
|
173
193
|
icon: z.string().min(1),
|
|
174
194
|
version: z.string().min(1),
|
|
175
|
-
type: z.literal(
|
|
195
|
+
type: z.literal(DATATYPE_ENTRY_TYPES[0]),
|
|
176
196
|
schema: jsonSchemaSchema,
|
|
177
197
|
settingsSchema: jsonSchemaSchema,
|
|
178
198
|
defaultSettings: z.record(z.string(), z.unknown()),
|
|
@@ -188,7 +208,7 @@ export const DataTypePluginSchema = z
|
|
|
188
208
|
deserialize: callable("deserialize"),
|
|
189
209
|
// Runtime-module members only: the manifest.json writer keeps a
|
|
190
210
|
// string-field allowlist, so these never serialize (S198 spec S8).
|
|
191
|
-
// They must still be ACCEPTED here
|
|
211
|
+
// They must still be ACCEPTED here: the object is .strict(), and a
|
|
192
212
|
// plugin author declaring its datatype's validate hook goes through
|
|
193
213
|
// this same schema via definePlugin.
|
|
194
214
|
validate: callable("validate").optional(),
|
|
@@ -212,30 +232,16 @@ const slotIdSchema = z
|
|
|
212
232
|
.string()
|
|
213
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')
|
|
214
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`);
|
|
215
|
-
// A
|
|
216
|
-
//
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
//
|
|
220
|
-
//
|
|
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
|
+
// 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.
|
|
235
241
|
const railEntryInSectionSchema = z
|
|
236
242
|
.object({
|
|
237
243
|
id: slotIdSchema,
|
|
238
|
-
label:
|
|
244
|
+
label: SlotLabelSchema,
|
|
239
245
|
icon: z.string().min(1).optional(),
|
|
240
246
|
action: ActionStringSchema,
|
|
241
247
|
view: componentSchema,
|
|
@@ -244,7 +250,7 @@ const railEntryInSectionSchema = z
|
|
|
244
250
|
const adminSectionSchema = z
|
|
245
251
|
.object({
|
|
246
252
|
id: slotIdSchema,
|
|
247
|
-
label:
|
|
253
|
+
label: SlotLabelSchema,
|
|
248
254
|
icon: z.string().min(1),
|
|
249
255
|
action: ActionStringSchema,
|
|
250
256
|
view: componentSchema,
|
|
@@ -271,7 +277,7 @@ const railEntrySchema = z
|
|
|
271
277
|
.object({
|
|
272
278
|
id: slotIdSchema,
|
|
273
279
|
section: z.enum(BUILT_IN_RAIL_SECTIONS),
|
|
274
|
-
label:
|
|
280
|
+
label: SlotLabelSchema,
|
|
275
281
|
icon: z.string().min(1).optional(),
|
|
276
282
|
action: ActionStringSchema,
|
|
277
283
|
view: componentSchema,
|
|
@@ -280,22 +286,43 @@ const railEntrySchema = z
|
|
|
280
286
|
const dashboardWidgetSchema = z
|
|
281
287
|
.object({
|
|
282
288
|
id: z.string().min(1),
|
|
283
|
-
name:
|
|
289
|
+
name: PluginLabelSchema,
|
|
284
290
|
view: componentSchema,
|
|
285
291
|
action: ActionStringSchema,
|
|
286
292
|
})
|
|
287
293
|
.strict();
|
|
294
|
+
// S297: a route's declared success responses. The keys are decided by the rule
|
|
295
|
+
// the host's route table compiles with (isApiRouteResponseStatus), so the two
|
|
296
|
+
// cannot disagree; the values are real Zod schemas like the request parts.
|
|
297
|
+
const apiRouteResponseSchema = z.record(z.string(), zodSchemaField).superRefine((value, ctx) => {
|
|
298
|
+
const keys = Object.keys(value);
|
|
299
|
+
if (keys.length > API_ROUTE_RESPONSE_STATUSES_MAX) {
|
|
300
|
+
ctx.addIssue({
|
|
301
|
+
code: "custom",
|
|
302
|
+
message: `declares ${keys.length} responses; at most ${API_ROUTE_RESPONSE_STATUSES_MAX} are allowed`,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
for (const key of keys) {
|
|
306
|
+
if (!isApiRouteResponseStatus(key)) {
|
|
307
|
+
ctx.addIssue({ code: "custom", message: `"${key}" is not a success status: use a status code from "200" to "299"`, path: [key] });
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
});
|
|
288
311
|
const apiRouteSchema = z
|
|
289
312
|
.object({
|
|
290
|
-
method: z.enum(
|
|
291
|
-
|
|
292
|
-
|
|
313
|
+
method: z.enum(API_ROUTE_METHODS),
|
|
314
|
+
// S295: the path's syntax and its relation to the plugin's other routes are
|
|
315
|
+
// api-schemas' checkApiRouteDeclarations, run once on the whole manifest
|
|
316
|
+
// below, so a bad path is reported once and in the words the door uses.
|
|
317
|
+
path: z.string(),
|
|
318
|
+
access: z.enum(API_ROUTE_ACCESS_TIERS).optional(),
|
|
293
319
|
action: ActionStringSchema.optional(),
|
|
294
320
|
schema: z
|
|
295
321
|
.object({
|
|
296
322
|
body: zodSchemaField.optional(),
|
|
297
323
|
querystring: zodSchemaField.optional(),
|
|
298
324
|
params: zodSchemaField.optional(),
|
|
325
|
+
response: apiRouteResponseSchema.optional(),
|
|
299
326
|
})
|
|
300
327
|
.strict()
|
|
301
328
|
.optional(),
|
|
@@ -321,7 +348,7 @@ const serializerContributionSchema = z
|
|
|
321
348
|
const scheduledTaskSchema = z
|
|
322
349
|
.object({
|
|
323
350
|
id: z.string().min(1),
|
|
324
|
-
name:
|
|
351
|
+
name: PluginLabelSchema,
|
|
325
352
|
cron: z.string().min(1),
|
|
326
353
|
run: callable("run"),
|
|
327
354
|
})
|
|
@@ -329,37 +356,12 @@ const scheduledTaskSchema = z
|
|
|
329
356
|
const mediaProcessorSchema = z
|
|
330
357
|
.object({
|
|
331
358
|
id: z.string().min(1),
|
|
332
|
-
name:
|
|
359
|
+
name: PluginLabelSchema,
|
|
333
360
|
process: callable("process"),
|
|
334
361
|
})
|
|
335
362
|
.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
363
|
const exposedServiceSchema = z
|
|
362
|
-
.object({ id: z.string().min(1), name:
|
|
364
|
+
.object({ id: z.string().min(1), name: PluginLabelSchema, service: z.unknown() })
|
|
363
365
|
.strict();
|
|
364
366
|
const bundledTemplateSchema = z
|
|
365
367
|
.object({
|
|
@@ -381,7 +383,7 @@ const safeCssTokenSchema = z
|
|
|
381
383
|
.string()
|
|
382
384
|
.max(200)
|
|
383
385
|
.regex(new RegExp('^[^{};\\u0000-\\u001f\\u007f]+$'), "must not contain CSS-escaping characters");
|
|
384
|
-
// themeTokens: minimal strict mirror of ThemeTokenOverrides
|
|
386
|
+
// themeTokens: minimal strict mirror of ThemeTokenOverrides: only
|
|
385
387
|
// color/radius keys exist (themes are cosmetic by construction);
|
|
386
388
|
// design-tokens has no Zod and shouldn't gain one, so token values are
|
|
387
389
|
// validated shallowly here.
|
|
@@ -394,176 +396,18 @@ const themeTokensSchema = z
|
|
|
394
396
|
// --- templates/assets contributions (S192 §8) -------------------------------
|
|
395
397
|
// Any plugin may declare templates and assets (S268). What still binds is
|
|
396
398
|
// the cross-check below: a `page` kind entry may only name a document type
|
|
397
|
-
// the same manifest declares.
|
|
398
|
-
//
|
|
399
|
-
//
|
|
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();
|
|
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.
|
|
495
402
|
// The templates/assets cross-checks, run by contributionsSchema for every
|
|
496
403
|
// manifest (S268: one contributions object, so one place this fires).
|
|
497
404
|
// `documentTypes` is read structurally: a manifest that declares none can
|
|
498
405
|
// never resolve a `documentType` reference, which is the correct outcome
|
|
499
406
|
// rather than a special case.
|
|
500
407
|
function checkTemplateAndAssetContributions(value, ctx) {
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
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
|
-
});
|
|
408
|
+
for (const issue of checkTemplateAndAssetDeclarations(value)) {
|
|
409
|
+
ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
|
|
410
|
+
}
|
|
567
411
|
}
|
|
568
412
|
// A slot's id is the last segment of its URL (spec D3), so it must be unique
|
|
569
413
|
// where its URL would collide: among this plugin's sections, within one
|
|
@@ -571,30 +415,35 @@ function checkApiRouteContributions(value, ctx) {
|
|
|
571
415
|
// three lists the same id is fine, because the URLs differ
|
|
572
416
|
// (/plugins/<plugin>/<id>, /plugins/<plugin>/<section>/<id>,
|
|
573
417
|
// /<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).
|
|
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.
|
|
575
421
|
function checkSlotContributions(value, ctx) {
|
|
576
|
-
const unique = (entries, path, what) => {
|
|
422
|
+
const unique = (entries, path, what, because) => {
|
|
577
423
|
const seen = new Set();
|
|
578
424
|
entries.forEach((entry, index) => {
|
|
579
425
|
if (seen.has(entry.id)) {
|
|
580
426
|
ctx.addIssue({
|
|
581
427
|
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
|
|
428
|
+
message: `Duplicate ${what} id "${entry.id}": ids must be unique ${what === "rail entry" ? "within one section's rail" : `within ${path[0]}`}, ${because}`,
|
|
583
429
|
path: [...path, index, "id"],
|
|
584
430
|
});
|
|
585
431
|
}
|
|
586
432
|
seen.add(entry.id);
|
|
587
433
|
});
|
|
588
434
|
};
|
|
435
|
+
const inUrl = "because the id is part of the slot's URL";
|
|
589
436
|
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");
|
|
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");
|
|
593
441
|
}
|
|
594
|
-
// Every action a plugin declares must sit in that plugin's own namespace
|
|
595
|
-
//
|
|
596
|
-
//
|
|
597
|
-
//
|
|
442
|
+
// Every action a plugin declares must sit in that plugin's own namespace (its
|
|
443
|
+
// full reverse-domain id plus a dot), so one plugin cannot declare an action in
|
|
444
|
+
// another plugin's namespace or in core's. Whether an apiRoute must declare one
|
|
445
|
+
// at all is api-schemas' checkApiRouteActions, the one rule the marketplace
|
|
446
|
+
// door runs too.
|
|
598
447
|
function checkActionContributions(value, ctx) {
|
|
599
448
|
const contributions = value.contributions;
|
|
600
449
|
// A section's own rail entries are gated too (S280). They are not a
|
|
@@ -616,15 +465,9 @@ function checkActionContributions(value, ctx) {
|
|
|
616
465
|
for (const key of CONTRIBUTION_KEYS.filter(isActionGated)) {
|
|
617
466
|
(contributions[key] ?? []).forEach((entry, index) => {
|
|
618
467
|
if (entry.action === undefined) {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
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
|
-
}
|
|
468
|
+
// Whether an apiRoute may omit its action is checkApiRouteActions' to
|
|
469
|
+
// say (only a public route may), run once on the whole manifest below;
|
|
470
|
+
// every other gated kind requires its action through its own schema.
|
|
628
471
|
return;
|
|
629
472
|
}
|
|
630
473
|
if (!isPluginActionFor(entry.action, value.id)) {
|
|
@@ -660,15 +503,12 @@ const contributionsShape = {
|
|
|
660
503
|
hooks: hooksSchema.optional(),
|
|
661
504
|
scheduledTasks: z.array(scheduledTaskSchema).optional(),
|
|
662
505
|
mediaProcessors: z.array(mediaProcessorSchema).optional(),
|
|
663
|
-
settingsPages: z.array(settingsPageSchema).optional(),
|
|
664
|
-
contentTreeActions: z.array(contentTreeActionSchema).optional(),
|
|
665
|
-
editorToolbar: z.array(editorToolbarSchema).optional(),
|
|
666
506
|
exposedServices: z.array(exposedServiceSchema).optional(),
|
|
667
507
|
serializers: serializerContributionSchema.optional(),
|
|
668
508
|
documentTypes: manifestDocumentTypesSchema,
|
|
669
509
|
themeTokens: themeTokensSchema.optional(),
|
|
670
|
-
templates: z.array(
|
|
671
|
-
assets: z.array(
|
|
510
|
+
templates: z.array(PluginTemplateEntrySchema).optional(),
|
|
511
|
+
assets: z.array(PluginAssetPathSchema).optional(),
|
|
672
512
|
// manifestIdSchema, not the shared one: these are the ids of OTHER
|
|
673
513
|
// PLUGINS, each of which has a manifest and so is itself capped. A
|
|
674
514
|
// four-segment entry here could never resolve to an installable plugin,
|
|
@@ -679,7 +519,6 @@ const contributionsShape = {
|
|
|
679
519
|
const contributionsSchema = z
|
|
680
520
|
.object(contributionsShape)
|
|
681
521
|
.strict()
|
|
682
|
-
.superRefine(checkApiRouteContributions)
|
|
683
522
|
.superRefine(checkTemplateAndAssetContributions)
|
|
684
523
|
.superRefine(checkSlotContributions);
|
|
685
524
|
/**
|
|
@@ -696,18 +535,17 @@ const contributionsSchema = z
|
|
|
696
535
|
export const CONTRIBUTION_KEYS = Object.keys(contributionsShape);
|
|
697
536
|
// --- the manifest -----------------------------------------------------------
|
|
698
537
|
const baseFields = {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
//
|
|
702
|
-
//
|
|
703
|
-
|
|
704
|
-
description
|
|
705
|
-
|
|
706
|
-
|
|
538
|
+
// S311 fix wave (I-A): id, version, name, description, author, license and
|
|
539
|
+
// cmsVersion follow the rules api-schemas defines once
|
|
540
|
+
// (plugin-manifest-fields.ts), the ones the marketplace door reads a
|
|
541
|
+
// manifest.json by: the id at most 128 characters, the version a semver, the
|
|
542
|
+
// listing texts capped, and no control or direction-override character in
|
|
543
|
+
// the name, the description or the author. Before this they were only
|
|
544
|
+
// non-empty here, so `validate` passed a manifest the door then refused.
|
|
545
|
+
...pluginManifestFields,
|
|
707
546
|
price: z.number().nonnegative().optional(),
|
|
708
547
|
// Optional by design: sideloaded/dev plugins are unsigned (Tier 2).
|
|
709
548
|
signature: z.string().optional(),
|
|
710
|
-
cmsVersion: z.string().min(1),
|
|
711
549
|
// Capped for the same reason as bundledPlugins above: a dependency names
|
|
712
550
|
// another plugin's manifest id.
|
|
713
551
|
pluginDependencies: z.array(manifestIdSchema).optional(),
|
|
@@ -725,16 +563,18 @@ const baseFields = {
|
|
|
725
563
|
actions: z.array(PluginActionDeclarationSchema).optional(),
|
|
726
564
|
roles: z.array(PluginRoleOfferSchema).optional(),
|
|
727
565
|
docs: z.array(PluginDocsPageSchema).optional(),
|
|
566
|
+
// S291: the docs pages' language, a code under the same rule as a slot
|
|
567
|
+
// label's keys (CultureSchema), so "German" is refused rather than shown,
|
|
568
|
+
// and at most 35 characters: DocsLanguageSchema is the one rule the
|
|
569
|
+
// marketplace's check and its stored languages apply too.
|
|
570
|
+
docsLanguage: DocsLanguageSchema.optional(),
|
|
571
|
+
// S292: what the install asks. The shape is api-schemas'
|
|
572
|
+
// PluginInstallDeclarationSchema; the rule over it (caps, distinct ids,
|
|
573
|
+
// defaults among the choices) runs below through checkInstallDeclaration,
|
|
574
|
+
// the function `kardalum plugin validate` and the marketplace door run.
|
|
575
|
+
install: PluginInstallDeclarationSchema.optional(),
|
|
728
576
|
};
|
|
729
|
-
const pluginTypeSchema = z.enum(
|
|
730
|
-
"datatype",
|
|
731
|
-
"section",
|
|
732
|
-
"template",
|
|
733
|
-
"theme",
|
|
734
|
-
"integration",
|
|
735
|
-
"utility",
|
|
736
|
-
"bundle",
|
|
737
|
-
]);
|
|
577
|
+
const pluginTypeSchema = z.enum(PLUGIN_TYPES);
|
|
738
578
|
// One manifest, no union (S268). `type` is a marketplace listing label
|
|
739
579
|
// that parses as one of seven values and gates nothing; what a plugin may
|
|
740
580
|
// do is decided by the capability list derived from `contributions` and by
|
|
@@ -745,12 +585,69 @@ export const CMSPluginSchema = z
|
|
|
745
585
|
.strict()
|
|
746
586
|
.superRefine(checkActionContributions)
|
|
747
587
|
.superRefine(checkActionDeclarations)
|
|
588
|
+
// S295 (2026-10-14-s295-routes-fastify-knows-about-design.md 3.1): the rule
|
|
589
|
+
// `kardalum plugin validate` and the marketplace door run too, rooted at the
|
|
590
|
+
// manifest.
|
|
591
|
+
.superRefine((value, ctx) => {
|
|
592
|
+
for (const issue of checkApiRouteDeclarations(value)) {
|
|
593
|
+
ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
|
|
594
|
+
}
|
|
595
|
+
})
|
|
596
|
+
// S299 (2026-10-15-s299-tokens-that-carry-actions-design.md D15): an admin-tier
|
|
597
|
+
// or apiKey-tier apiRoute names its action; the marketplace door runs the same
|
|
598
|
+
// function on manifest.json.
|
|
599
|
+
.superRefine((value, ctx) => {
|
|
600
|
+
for (const issue of checkApiRouteActions(value)) {
|
|
601
|
+
ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
|
|
602
|
+
}
|
|
603
|
+
})
|
|
604
|
+
.superRefine((value, ctx) => {
|
|
605
|
+
// S311 (S295): schema.params must name exactly the path's :name parameters,
|
|
606
|
+
// or the route answers 400 on every call. SDK-side only: manifest.json
|
|
607
|
+
// carries no Zod.
|
|
608
|
+
(value.contributions.apiRoutes ?? []).forEach((route, index) => {
|
|
609
|
+
const params = route.schema?.params;
|
|
610
|
+
if (params === undefined)
|
|
611
|
+
return;
|
|
612
|
+
const named = apiRoutePathParams(route.path);
|
|
613
|
+
const declared = params instanceof z.ZodObject ? Object.keys(params.shape) : null;
|
|
614
|
+
const where = ["contributions", "apiRoutes", index, "schema", "params"];
|
|
615
|
+
if (declared === null) {
|
|
616
|
+
if (named.length > 0) {
|
|
617
|
+
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" });
|
|
618
|
+
}
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
const missing = named.filter((name) => !declared.includes(name));
|
|
622
|
+
const extra = declared.filter((name) => !named.includes(name));
|
|
623
|
+
if (missing.length > 0 || extra.length > 0) {
|
|
624
|
+
ctx.addIssue({
|
|
625
|
+
code: "custom",
|
|
626
|
+
path: where,
|
|
627
|
+
message: `schema.params keys must equal the path's :name parameters (path names ${JSON.stringify(named)}, schema declares ${JSON.stringify(declared)})`,
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
})
|
|
748
632
|
.superRefine((value, ctx) => {
|
|
749
633
|
for (const issue of checkDocsDeclaration(value.docs ?? [])) {
|
|
750
634
|
ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
|
|
751
635
|
}
|
|
636
|
+
})
|
|
637
|
+
.superRefine((value, ctx) => {
|
|
638
|
+
if (!value.install)
|
|
639
|
+
return;
|
|
640
|
+
// The rule reads only a declaration its schema parsed. A refinement still
|
|
641
|
+
// runs when a field failed a check (an id the id rule refused), and the
|
|
642
|
+
// rule would then report that id a second time, as "used more than once".
|
|
643
|
+
const install = PluginInstallDeclarationSchema.safeParse(value.install);
|
|
644
|
+
if (!install.success)
|
|
645
|
+
return;
|
|
646
|
+
for (const issue of checkInstallDeclaration(install.data)) {
|
|
647
|
+
ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
|
|
648
|
+
}
|
|
752
649
|
});
|
|
753
|
-
// Shared by validatePluginManifest and definePlugin
|
|
650
|
+
// Shared by validatePluginManifest and definePlugin: one formatting
|
|
754
651
|
// convention for every validation surface: `path: message`.
|
|
755
652
|
export function formatIssues(issues) {
|
|
756
653
|
return issues.map((issue) => {
|
|
@@ -762,8 +659,8 @@ export function formatIssues(issues) {
|
|
|
762
659
|
* Validate an untrusted value as a plugin manifest. The registry's
|
|
763
660
|
* install() (Session 62) and `kardalum plugin validate` (Month 7) both go
|
|
764
661
|
* through this: errors come back as readable `path: message` strings
|
|
765
|
-
* (e.g. `contributions
|
|
766
|
-
* contract does not define).
|
|
662
|
+
* (e.g. `contributions: Unrecognized key: "adminSection"` for a key this
|
|
663
|
+
* contract does not define, listed before any issue it causes).
|
|
767
664
|
*/
|
|
768
665
|
export function validatePluginManifest(value) {
|
|
769
666
|
const result = CMSPluginSchema.safeParse(value);
|