@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
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ACTION_SEGMENT_MAX } from "./action.schema.js";
|
|
3
|
+
import { HOSTILE_CHARS_MESSAGE, hasHostileChars } from "./plugin-docs-text.js";
|
|
4
|
+
import { MANIFEST_ID_SEGMENT_MAX, PLUGIN_ID_MAX, PLUGIN_ID_REGEX } from "./plugin-id-rules.js";
|
|
5
|
+
import { FILE_NAME_MAX } from "./plugin-template-payload.js";
|
|
6
|
+
// S311 fix wave (I-A): the rules over a manifest's identity and listing fields,
|
|
7
|
+
// defined once. The SDK's manifest schema (`kardalum plugin validate` and every
|
|
8
|
+
// install) and the marketplace door's shape rule both build these fields from
|
|
9
|
+
// here, and the upload checks the listing fields by them before it writes a
|
|
10
|
+
// listing row, so a manifest `validate` accepts is never refused at the door
|
|
11
|
+
// for its id, version, name, description, author, licence or CMS range. Before
|
|
12
|
+
// this the caps and the semver rule lived in the door alone.
|
|
13
|
+
export { PLUGIN_ID_MAX };
|
|
14
|
+
/** The longest version a manifest may declare (S311 second code fix): short
|
|
15
|
+
* enough that every name a version becomes part of fits in FILE_NAME_MAX
|
|
16
|
+
* beside the longest id. The longest of them is the starter download's
|
|
17
|
+
* "<id>-<version>-starter.zip": 255 - 128 (PLUGIN_ID_MAX) - 1 ("-") - 12
|
|
18
|
+
* ("-starter.zip") = 114, room for ordinary build metadata such as
|
|
19
|
+
* "1.0.0+21AF26D3----117B344092BD". The others are shorter: "<id>-<version>.zip.sig" and
|
|
20
|
+
* "<id>-<version>.zip" (pack's archive and the downloads), and on disk the
|
|
21
|
+
* marketplace's "<version>-starter.zip", "<version>.tar.gz.sig" and
|
|
22
|
+
* "<version>.tar.gz" and the server's "<id>/<version>" folder. */
|
|
23
|
+
export const PLUGIN_VERSION_MAX = FILE_NAME_MAX - PLUGIN_ID_MAX - "-".length - "-starter.zip".length;
|
|
24
|
+
/** The longest plugin name a listing shows. */
|
|
25
|
+
export const PLUGIN_NAME_MAX = 120;
|
|
26
|
+
/** The longest description a listing shows. */
|
|
27
|
+
export const PLUGIN_DESCRIPTION_MAX = 2000;
|
|
28
|
+
/** The longest author a listing shows. */
|
|
29
|
+
export const PLUGIN_AUTHOR_MAX = 200;
|
|
30
|
+
/** The longest licence text. */
|
|
31
|
+
export const PLUGIN_LICENSE_MAX = 100;
|
|
32
|
+
/** The longest CMS version range. */
|
|
33
|
+
export const PLUGIN_CMS_VERSION_MAX = 100;
|
|
34
|
+
export const PLUGIN_ID_MESSAGE = "must be a reverse-domain id like com.vendor.plugin: every segment is lowercase, starts with a letter, and uses only a-z, 0-9 and hyphens";
|
|
35
|
+
export const PLUGIN_ID_SEGMENTS_MESSAGE = `a plugin id has at most ${MANIFEST_ID_SEGMENT_MAX} segments: every action is the plugin id plus an object ` +
|
|
36
|
+
`and a verb, and an action has at most ${ACTION_SEGMENT_MAX} segments, so a longer id could not declare any action`;
|
|
37
|
+
export const PLUGIN_VERSION_MESSAGE = `must be a semver version such as 1.0.0 or 1.0.0-beta.1, at most ${PLUGIN_VERSION_MAX} characters`;
|
|
38
|
+
const IDENTIFIER = /^[0-9A-Za-z-]+$/;
|
|
39
|
+
const NUMERIC = /^[0-9]+$/;
|
|
40
|
+
/** A core part: digits, no leading zero, within the largest safe integer, so
|
|
41
|
+
* every reader of the version (semver, the install's ordering) reads one number. */
|
|
42
|
+
function isCorePart(part) {
|
|
43
|
+
if (!NUMERIC.test(part) || (part.length > 1 && part.startsWith("0")))
|
|
44
|
+
return false;
|
|
45
|
+
return Number(part) <= Number.MAX_SAFE_INTEGER;
|
|
46
|
+
}
|
|
47
|
+
/** A prerelease identifier: letters, digits and hyphens, and a number with no leading zero. */
|
|
48
|
+
function isPrereleasePart(part) {
|
|
49
|
+
if (!IDENTIFIER.test(part))
|
|
50
|
+
return false;
|
|
51
|
+
return !(NUMERIC.test(part) && part.length > 1 && part.startsWith("0"));
|
|
52
|
+
}
|
|
53
|
+
/** A build identifier: letters, digits and hyphens (leading zeros allowed). */
|
|
54
|
+
function isBuildPart(part) {
|
|
55
|
+
return IDENTIFIER.test(part);
|
|
56
|
+
}
|
|
57
|
+
/** Whether `value` is a SemVer 2.0.0 version (MAJOR.MINOR.PATCH, an optional
|
|
58
|
+
* `-prerelease` and `+build`, no `v` prefix, no spaces) of at most
|
|
59
|
+
* PLUGIN_VERSION_MAX characters. The length is checked first, then the text
|
|
60
|
+
* is split at its first `+` and its first `-` and each part read on its own,
|
|
61
|
+
* so the work is linear in a length that is already bounded. */
|
|
62
|
+
export function isPluginVersion(value) {
|
|
63
|
+
if (value.length === 0 || value.length > PLUGIN_VERSION_MAX)
|
|
64
|
+
return false;
|
|
65
|
+
const plus = value.indexOf("+");
|
|
66
|
+
const main = plus === -1 ? value : value.slice(0, plus);
|
|
67
|
+
if (plus !== -1 && !value.slice(plus + 1).split(".").every(isBuildPart))
|
|
68
|
+
return false;
|
|
69
|
+
const dash = main.indexOf("-");
|
|
70
|
+
const core = dash === -1 ? main : main.slice(0, dash);
|
|
71
|
+
if (dash !== -1 && !main.slice(dash + 1).split(".").every(isPrereleasePart))
|
|
72
|
+
return false;
|
|
73
|
+
const parts = core.split(".");
|
|
74
|
+
return parts.length === 3 && parts.every(isCorePart);
|
|
75
|
+
}
|
|
76
|
+
/** A manifest's own id: at most PLUGIN_ID_MAX characters, the reverse-domain
|
|
77
|
+
* rule, and at most MANIFEST_ID_SEGMENT_MAX segments. Also the rule for the
|
|
78
|
+
* ids of other plugins a manifest names (bundled plugins, dependencies),
|
|
79
|
+
* since each of those is some plugin's own id. */
|
|
80
|
+
export const PluginManifestIdSchema = z
|
|
81
|
+
.string()
|
|
82
|
+
.max(PLUGIN_ID_MAX, { message: `is at most ${PLUGIN_ID_MAX} characters` })
|
|
83
|
+
.regex(PLUGIN_ID_REGEX, PLUGIN_ID_MESSAGE)
|
|
84
|
+
.refine((id) => id.split(".").length <= MANIFEST_ID_SEGMENT_MAX, { message: PLUGIN_ID_SEGMENTS_MESSAGE });
|
|
85
|
+
export const PluginVersionSchema = z.string().refine(isPluginVersion, { message: PLUGIN_VERSION_MESSAGE });
|
|
86
|
+
/** Text a listing shows as written: not empty, at most `max` characters, and
|
|
87
|
+
* no control, zero-width or direction-override character (Trojan Source). */
|
|
88
|
+
function listingText(max) {
|
|
89
|
+
return z
|
|
90
|
+
.string()
|
|
91
|
+
.min(1, { message: "must not be empty" })
|
|
92
|
+
.max(max, { message: `is at most ${max} characters` })
|
|
93
|
+
.refine((value) => !hasHostileChars(value), { message: HOSTILE_CHARS_MESSAGE });
|
|
94
|
+
}
|
|
95
|
+
function boundedText(max) {
|
|
96
|
+
return z.string().min(1, { message: "must not be empty" }).max(max, { message: `is at most ${max} characters` });
|
|
97
|
+
}
|
|
98
|
+
export const PluginNameSchema = listingText(PLUGIN_NAME_MAX);
|
|
99
|
+
export const PluginDescriptionSchema = listingText(PLUGIN_DESCRIPTION_MAX);
|
|
100
|
+
export const PluginAuthorSchema = listingText(PLUGIN_AUTHOR_MAX);
|
|
101
|
+
export const PluginLicenseSchema = boundedText(PLUGIN_LICENSE_MAX);
|
|
102
|
+
export const PluginCmsVersionSchema = boundedText(PLUGIN_CMS_VERSION_MAX);
|
|
103
|
+
/** The identity and listing fields of a manifest, as one shape: the SDK's
|
|
104
|
+
* manifest schema and the door's shape rule each spread it into theirs. */
|
|
105
|
+
export const pluginManifestFields = {
|
|
106
|
+
id: PluginManifestIdSchema,
|
|
107
|
+
version: PluginVersionSchema,
|
|
108
|
+
name: PluginNameSchema,
|
|
109
|
+
description: PluginDescriptionSchema,
|
|
110
|
+
author: PluginAuthorSchema,
|
|
111
|
+
license: PluginLicenseSchema,
|
|
112
|
+
cmsVersion: PluginCmsVersionSchema,
|
|
113
|
+
};
|
|
114
|
+
const LISTING_FIELDS = [
|
|
115
|
+
["name", PluginNameSchema],
|
|
116
|
+
["description", PluginDescriptionSchema],
|
|
117
|
+
["author", PluginAuthorSchema],
|
|
118
|
+
];
|
|
119
|
+
/** The fields a listing row is written from, by the rules above, for the
|
|
120
|
+
* upload, which writes the row before validation reads the package: each
|
|
121
|
+
* field it refuses, with the rule's message. An absent author is left out
|
|
122
|
+
* (the listing names the publisher instead). */
|
|
123
|
+
export function checkPluginListingFields(fields) {
|
|
124
|
+
const issues = [];
|
|
125
|
+
for (const [key, schema] of LISTING_FIELDS) {
|
|
126
|
+
const value = fields[key];
|
|
127
|
+
if (key === "author" && value === undefined)
|
|
128
|
+
continue;
|
|
129
|
+
const parsed = schema.safeParse(value);
|
|
130
|
+
if (!parsed.success)
|
|
131
|
+
issues.push({ path: [key], message: parsed.error.issues[0]?.message ?? "is invalid" });
|
|
132
|
+
}
|
|
133
|
+
return issues;
|
|
134
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const PLUGIN_READ_ONLY_CODE: "plugin_read_only";
|
|
3
|
+
export declare const PluginReadOnlyNoticeSchema: z.ZodObject<{
|
|
4
|
+
code: z.ZodLiteral<"plugin_read_only">;
|
|
5
|
+
pluginId: z.ZodString;
|
|
6
|
+
pluginName: z.ZodString;
|
|
7
|
+
canRenew: z.ZodBoolean;
|
|
8
|
+
message: z.ZodString;
|
|
9
|
+
renewUrl: z.ZodOptional<z.ZodString>;
|
|
10
|
+
lapsedAt: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type PluginReadOnlyNotice = z.infer<typeof PluginReadOnlyNoticeSchema>;
|
|
13
|
+
export declare function isPluginReadOnlyNotice(value: unknown): value is PluginReadOnlyNotice;
|
|
14
|
+
export declare const ReadOnlyFieldSchema: z.ZodObject<{
|
|
15
|
+
fieldAlias: z.ZodString;
|
|
16
|
+
pluginId: z.ZodString;
|
|
17
|
+
message: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type ReadOnlyField = z.infer<typeof ReadOnlyFieldSchema>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// S318 (spec D7): what a refused write of a lapsed plugin answers, and what the
|
|
3
|
+
// plugin list, the entitlement route and the data type list carry for one.
|
|
4
|
+
// `message` is English for API readers; the admin words the notice in its own
|
|
5
|
+
// language from the other fields (plan P3). `canRenew` says whether the caller
|
|
6
|
+
// holds plugins.update (spec D2), which the server always knows; `renewUrl` and
|
|
7
|
+
// `lapsedAt` are only present when it does, and even then only when the
|
|
8
|
+
// marketplace is configured and the verdict carried the term's end.
|
|
9
|
+
export const PLUGIN_READ_ONLY_CODE = "plugin_read_only";
|
|
10
|
+
export const PluginReadOnlyNoticeSchema = z.object({
|
|
11
|
+
code: z.literal(PLUGIN_READ_ONLY_CODE),
|
|
12
|
+
pluginId: z.string(),
|
|
13
|
+
pluginName: z.string(),
|
|
14
|
+
/** Whether the caller may renew (holds plugins.update): the admin words the notice on this. */
|
|
15
|
+
canRenew: z.boolean(),
|
|
16
|
+
message: z.string(),
|
|
17
|
+
renewUrl: z.string().optional(),
|
|
18
|
+
/** The lapsed term's end (ISO). */
|
|
19
|
+
lapsedAt: z.string().optional(),
|
|
20
|
+
});
|
|
21
|
+
export function isPluginReadOnlyNotice(value) {
|
|
22
|
+
return PluginReadOnlyNoticeSchema.safeParse(value).success;
|
|
23
|
+
}
|
|
24
|
+
// S318 (spec 3b): a field a save tried to change while its data type's plugin
|
|
25
|
+
// is read-only. Its stored value was kept. `fieldAlias` is the field's id.
|
|
26
|
+
// `message` is worded for the caller the way the notice is (spec D2): the
|
|
27
|
+
// content and public API write routes reword it for a caller holding
|
|
28
|
+
// plugins.update.
|
|
29
|
+
export const ReadOnlyFieldSchema = z.object({
|
|
30
|
+
fieldAlias: z.string(),
|
|
31
|
+
pluginId: z.string(),
|
|
32
|
+
message: z.string(),
|
|
33
|
+
});
|
|
@@ -8,6 +8,7 @@ export declare const PluginSchema: z.ZodObject<{
|
|
|
8
8
|
storageType: z.ZodString;
|
|
9
9
|
enabled: z.ZodBoolean;
|
|
10
10
|
remoteUrl: z.ZodNullable<z.ZodString>;
|
|
11
|
+
locales: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
11
12
|
}, z.core.$strip>;
|
|
12
13
|
export type Plugin = z.infer<typeof PluginSchema>;
|
|
13
14
|
export declare const PluginListQuerySchema: z.ZodObject<{
|
|
@@ -25,6 +26,7 @@ export declare const PluginListResponseSchema: z.ZodObject<{
|
|
|
25
26
|
storageType: z.ZodString;
|
|
26
27
|
enabled: z.ZodBoolean;
|
|
27
28
|
remoteUrl: z.ZodNullable<z.ZodString>;
|
|
29
|
+
locales: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
28
30
|
}, z.core.$strip>>;
|
|
29
31
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
30
32
|
}, z.core.$strip>;
|
|
@@ -12,6 +12,10 @@ export const PluginSchema = z.object({
|
|
|
12
12
|
storageType: z.string(),
|
|
13
13
|
enabled: z.boolean(),
|
|
14
14
|
remoteUrl: z.string().nullable(),
|
|
15
|
+
// S314c2 (D9): the language codes of the locale files (locales/<code>.json) the plugin's
|
|
16
|
+
// package ships, read at install, update and attach; null when the row records none. The
|
|
17
|
+
// admin asks only for these files.
|
|
18
|
+
locales: z.array(z.string()).max(100).nullable(),
|
|
15
19
|
});
|
|
16
20
|
// Cursor-paginated per the non-negotiable list-endpoint rule, mirroring
|
|
17
21
|
// DataTypeListResponseSchema's exact shape (data-type-api.schema.ts).
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The longest path an entry of a package archive may have: Windows' MAX_PATH.
|
|
3
|
+
* A longer path cannot be written on a Windows host, wherever the package
|
|
4
|
+
* installs, since the install's own folder only adds to it. The entry gate
|
|
5
|
+
* in @kardalum/plugin-package (ENTRY_NAME_MAX) reads it from here (S311). */
|
|
6
|
+
export declare const PACKAGE_PATH_MAX = 260;
|
|
7
|
+
/** The longest file or folder name, one segment of a path, that NTFS, APFS and
|
|
8
|
+
* ext4 take. */
|
|
9
|
+
export declare const FILE_NAME_MAX = 255;
|
|
10
|
+
export declare const TEMPLATE_ALIAS_MAX = 120;
|
|
11
|
+
/** A template file lands at templates/<file>, so it may take PACKAGE_PATH_MAX
|
|
12
|
+
* less that folder (S311 third code fix): a longer one is named here, by the
|
|
13
|
+
* declarations check, not later by the archive's name rule. */
|
|
14
|
+
export declare const TEMPLATE_FILE_MAX: number;
|
|
15
|
+
/** A registered asset lands at public/<path>: PACKAGE_PATH_MAX less that folder. */
|
|
16
|
+
export declare const ASSET_PATH_MAX: number;
|
|
17
|
+
/** Templates and public/ together: the budget the install pipeline copes with. */
|
|
18
|
+
export declare const MAX_TEMPLATE_PAYLOAD_ENTRIES = 1800;
|
|
19
|
+
/** First path segments the request pipeline owns (compared case-insensitively):
|
|
20
|
+
* the server's reserved root slugs, the one list (S311 fix wave), so a root
|
|
21
|
+
* the server adds, such as the edit-on-page route's, is refused here too. */
|
|
22
|
+
export declare const RESERVED_ASSET_ROOTS: readonly ["kardalum", "api", "docs", "plugin-assets", "media", "kardalum-edit"];
|
|
23
|
+
/** A registered asset is read as UTF-8 text and kept with version history; a
|
|
24
|
+
* binary would be mangled. Binaries ship as unregistered public/ files. */
|
|
25
|
+
export declare const REGISTERED_ASSET_TEXT_EXTENSIONS: readonly ["css", "js", "mjs", "json", "svg", "txt", "md"];
|
|
26
|
+
/** S314c3 (fix wave): the extensions a site reads as text under public/ (the
|
|
27
|
+
* asset editor's files), each held to the asset limit wherever it lands: the
|
|
28
|
+
* upload route, the install pre-check and the build check, from this one list
|
|
29
|
+
* so the three cannot drift. Wider than the registered list: an undeclared
|
|
30
|
+
* file may be any of these. */
|
|
31
|
+
export declare const ASSET_TEXT_EXTENSIONS: readonly ["css", "js", "mjs", "cjs", "json", "svg", "txt", "md", "html", "htm", "xml", "map", "webmanifest"];
|
|
32
|
+
/** Whether a public/ path is a text file by its extension (ASSET_TEXT_EXTENSIONS);
|
|
33
|
+
* a name with no extension, or a dotfile with none of its own, is not. */
|
|
34
|
+
export declare function isAssetTextPath(path: string): boolean;
|
|
35
|
+
export declare function hasRegisteredAssetTextExtension(value: string): boolean;
|
|
36
|
+
export declare const PluginTemplateAliasSchema: z.ZodString;
|
|
37
|
+
export declare const PluginTemplateFileSchema: z.ZodString;
|
|
38
|
+
export declare const PluginAssetPathSchema: z.ZodString;
|
|
39
|
+
export declare const PluginTemplateEntrySchema: z.ZodObject<{
|
|
40
|
+
file: z.ZodString;
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
alias: z.ZodString;
|
|
43
|
+
kind: z.ZodEnum<{
|
|
44
|
+
page: "page";
|
|
45
|
+
layout: "layout";
|
|
46
|
+
partial: "partial";
|
|
47
|
+
}>;
|
|
48
|
+
documentType: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strict>;
|
|
50
|
+
export type PluginTemplateEntry = z.infer<typeof PluginTemplateEntrySchema>;
|
|
51
|
+
/** The two fields an install re-reads, whatever else the contributions hold. */
|
|
52
|
+
export declare const PluginTemplatePayloadSchema: z.ZodObject<{
|
|
53
|
+
templates: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
54
|
+
file: z.ZodString;
|
|
55
|
+
name: z.ZodString;
|
|
56
|
+
alias: z.ZodString;
|
|
57
|
+
kind: z.ZodEnum<{
|
|
58
|
+
page: "page";
|
|
59
|
+
layout: "layout";
|
|
60
|
+
partial: "partial";
|
|
61
|
+
}>;
|
|
62
|
+
documentType: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, z.core.$strict>>>;
|
|
64
|
+
assets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
65
|
+
}, z.core.$loose>;
|
|
66
|
+
export interface DeclarationIssue {
|
|
67
|
+
path: (string | number)[];
|
|
68
|
+
message: string;
|
|
69
|
+
}
|
|
70
|
+
/** The cross-entry rules: aliases unique per kind, unique files and asset paths, and a page
|
|
71
|
+
* template's documentType resolving against this manifest's own documentTypes. */
|
|
72
|
+
export declare function checkTemplateAndAssetDeclarations(value: {
|
|
73
|
+
templates?: ReadonlyArray<{
|
|
74
|
+
file: string;
|
|
75
|
+
alias: string;
|
|
76
|
+
kind: string;
|
|
77
|
+
documentType?: string;
|
|
78
|
+
}>;
|
|
79
|
+
assets?: ReadonlyArray<string>;
|
|
80
|
+
documentTypes?: ReadonlyArray<{
|
|
81
|
+
name: string;
|
|
82
|
+
}>;
|
|
83
|
+
}): DeclarationIssue[];
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { TEMPLATE_KINDS } from "./plugin-vocabulary.js";
|
|
3
|
+
import { RESERVED_ROOT_SLUGS, isReservedRootSlug } from "./reserved-slugs.js";
|
|
4
|
+
// S311 (S292): the rules for the two manifest fields an install lands as render
|
|
5
|
+
// templates and registered assets, defined once. The SDK's manifest schema
|
|
6
|
+
// (kardalum plugin validate), the delivery registry (validate and the
|
|
7
|
+
// marketplace door) and the server's install (install-template-payload.ts) all
|
|
8
|
+
// import from here; before S311 each held its own copy, three of them
|
|
9
|
+
// "byte-for-byte mirrors" kept in lockstep by a comment. Narrower than the
|
|
10
|
+
// server's general AssetPathSchema on purpose: a declared asset is a text file
|
|
11
|
+
// the admin edits, and may not repeat the public/ root.
|
|
12
|
+
/** The longest path an entry of a package archive may have: Windows' MAX_PATH.
|
|
13
|
+
* A longer path cannot be written on a Windows host, wherever the package
|
|
14
|
+
* installs, since the install's own folder only adds to it. The entry gate
|
|
15
|
+
* in @kardalum/plugin-package (ENTRY_NAME_MAX) reads it from here (S311). */
|
|
16
|
+
export const PACKAGE_PATH_MAX = 260;
|
|
17
|
+
/** The longest file or folder name, one segment of a path, that NTFS, APFS and
|
|
18
|
+
* ext4 take. */
|
|
19
|
+
export const FILE_NAME_MAX = 255;
|
|
20
|
+
export const TEMPLATE_ALIAS_MAX = 120;
|
|
21
|
+
/** A template file lands at templates/<file>, so it may take PACKAGE_PATH_MAX
|
|
22
|
+
* less that folder (S311 third code fix): a longer one is named here, by the
|
|
23
|
+
* declarations check, not later by the archive's name rule. */
|
|
24
|
+
export const TEMPLATE_FILE_MAX = PACKAGE_PATH_MAX - "templates/".length;
|
|
25
|
+
/** A registered asset lands at public/<path>: PACKAGE_PATH_MAX less that folder. */
|
|
26
|
+
export const ASSET_PATH_MAX = PACKAGE_PATH_MAX - "public/".length;
|
|
27
|
+
/** Templates and public/ together: the budget the install pipeline copes with. */
|
|
28
|
+
export const MAX_TEMPLATE_PAYLOAD_ENTRIES = 1800;
|
|
29
|
+
/** First path segments the request pipeline owns (compared case-insensitively):
|
|
30
|
+
* the server's reserved root slugs, the one list (S311 fix wave), so a root
|
|
31
|
+
* the server adds, such as the edit-on-page route's, is refused here too. */
|
|
32
|
+
export const RESERVED_ASSET_ROOTS = RESERVED_ROOT_SLUGS;
|
|
33
|
+
/** A registered asset is read as UTF-8 text and kept with version history; a
|
|
34
|
+
* binary would be mangled. Binaries ship as unregistered public/ files. */
|
|
35
|
+
export const REGISTERED_ASSET_TEXT_EXTENSIONS = ["css", "js", "mjs", "json", "svg", "txt", "md"];
|
|
36
|
+
/** S314c3 (fix wave): the extensions a site reads as text under public/ (the
|
|
37
|
+
* asset editor's files), each held to the asset limit wherever it lands: the
|
|
38
|
+
* upload route, the install pre-check and the build check, from this one list
|
|
39
|
+
* so the three cannot drift. Wider than the registered list: an undeclared
|
|
40
|
+
* file may be any of these. */
|
|
41
|
+
export const ASSET_TEXT_EXTENSIONS = ["css", "js", "mjs", "cjs", "json", "svg", "txt", "md", "html", "htm", "xml", "map", "webmanifest"];
|
|
42
|
+
const TEMPLATE_ALIAS_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
43
|
+
// Starts alphanumeric, then alphanumeric, dot, dash, underscore: this alone
|
|
44
|
+
// rejects "." and ".." segments, so no separate traversal check is needed.
|
|
45
|
+
const PATH_SEGMENT_REGEX = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
46
|
+
const isRelativeSlashPath = (value) => value.length > 0 && !value.startsWith("/") && !value.includes("\\");
|
|
47
|
+
const hasValidSegments = (value) => value.split("/").every((segment) => PATH_SEGMENT_REGEX.test(segment));
|
|
48
|
+
/** Whether a public/ path is a text file by its extension (ASSET_TEXT_EXTENSIONS);
|
|
49
|
+
* a name with no extension, or a dotfile with none of its own, is not. */
|
|
50
|
+
export function isAssetTextPath(path) {
|
|
51
|
+
const base = path.split("/").pop() ?? path;
|
|
52
|
+
const dot = base.lastIndexOf(".");
|
|
53
|
+
if (dot <= 0)
|
|
54
|
+
return false;
|
|
55
|
+
return ASSET_TEXT_EXTENSIONS.includes(base.slice(dot + 1).toLowerCase());
|
|
56
|
+
}
|
|
57
|
+
export function hasRegisteredAssetTextExtension(value) {
|
|
58
|
+
const base = value.split("/").pop() ?? value;
|
|
59
|
+
const dot = base.lastIndexOf(".");
|
|
60
|
+
if (dot <= 0)
|
|
61
|
+
return false;
|
|
62
|
+
const extension = base.slice(dot + 1).toLowerCase();
|
|
63
|
+
return REGISTERED_ASSET_TEXT_EXTENSIONS.includes(extension);
|
|
64
|
+
}
|
|
65
|
+
export const PluginTemplateAliasSchema = z
|
|
66
|
+
.string()
|
|
67
|
+
.min(1)
|
|
68
|
+
.max(TEMPLATE_ALIAS_MAX)
|
|
69
|
+
.regex(TEMPLATE_ALIAS_REGEX, "must be lowercase kebab-case, e.g. product-page");
|
|
70
|
+
export const PluginTemplateFileSchema = z
|
|
71
|
+
.string()
|
|
72
|
+
.min(1)
|
|
73
|
+
.max(TEMPLATE_FILE_MAX)
|
|
74
|
+
.refine(isRelativeSlashPath, { message: 'must be a relative path using forward slashes (no leading "/", no "\\\\")' })
|
|
75
|
+
.refine((value) => value.toLowerCase().endsWith(".liquid"), { message: "must end with .liquid" })
|
|
76
|
+
.refine(hasValidSegments, { message: 'path segments must match [a-z0-9][a-z0-9._-]*: no "." or ".." segments' });
|
|
77
|
+
export const PluginAssetPathSchema = z
|
|
78
|
+
.string()
|
|
79
|
+
.min(1)
|
|
80
|
+
.max(ASSET_PATH_MAX)
|
|
81
|
+
.refine(isRelativeSlashPath, { message: 'must be a relative path using forward slashes (no leading "/", no "\\\\")' })
|
|
82
|
+
.refine(hasValidSegments, { message: 'path segments must match [a-z0-9][a-z0-9._-]*: no "." or ".." segments' })
|
|
83
|
+
.refine((value) => !isReservedRootSlug(value.split("/")[0] ?? ""), {
|
|
84
|
+
message: `must not be rooted at a reserved path (${[...RESERVED_ASSET_ROOTS].sort().join(", ")})`,
|
|
85
|
+
})
|
|
86
|
+
.refine((value) => (value.split("/")[0]?.toLowerCase() ?? "") !== "public", {
|
|
87
|
+
message: 'declare asset paths relative to public/: drop the "public/" prefix',
|
|
88
|
+
})
|
|
89
|
+
.refine(hasRegisteredAssetTextExtension, {
|
|
90
|
+
message: "registered assets are text files editable in the admin: ship binary files as unregistered public/ files instead",
|
|
91
|
+
});
|
|
92
|
+
export const PluginTemplateEntrySchema = z
|
|
93
|
+
.object({
|
|
94
|
+
file: PluginTemplateFileSchema,
|
|
95
|
+
name: z.string().min(1),
|
|
96
|
+
alias: PluginTemplateAliasSchema,
|
|
97
|
+
kind: z.enum(TEMPLATE_KINDS),
|
|
98
|
+
documentType: z.string().min(1).optional(),
|
|
99
|
+
})
|
|
100
|
+
.strict();
|
|
101
|
+
/** The two fields an install re-reads, whatever else the contributions hold. */
|
|
102
|
+
export const PluginTemplatePayloadSchema = z
|
|
103
|
+
.object({
|
|
104
|
+
templates: z.array(PluginTemplateEntrySchema).optional(),
|
|
105
|
+
assets: z.array(PluginAssetPathSchema).optional(),
|
|
106
|
+
})
|
|
107
|
+
.passthrough();
|
|
108
|
+
/** The cross-entry rules: aliases unique per kind, unique files and asset paths, and a page
|
|
109
|
+
* template's documentType resolving against this manifest's own documentTypes. */
|
|
110
|
+
export function checkTemplateAndAssetDeclarations(value) {
|
|
111
|
+
const issues = [];
|
|
112
|
+
const documentTypeNames = new Set((value.documentTypes ?? []).map((documentType) => documentType.name));
|
|
113
|
+
const seenAliases = new Set();
|
|
114
|
+
const seenFiles = new Set();
|
|
115
|
+
(value.templates ?? []).forEach((template, index) => {
|
|
116
|
+
// S314o2 (D2): an alias is unique per kind, as on the server, so a page and a partial may share one.
|
|
117
|
+
const aliasKey = `${template.kind}:${template.alias}`;
|
|
118
|
+
if (seenAliases.has(aliasKey)) {
|
|
119
|
+
issues.push({
|
|
120
|
+
path: ["templates", index, "alias"],
|
|
121
|
+
message: `Duplicate template alias "${template.alias}" among the ${template.kind} templates: aliases must be unique per kind within a manifest`,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
seenAliases.add(aliasKey);
|
|
125
|
+
if (seenFiles.has(template.file)) {
|
|
126
|
+
issues.push({ path: ["templates", index, "file"], message: `Duplicate template file "${template.file}": files must be unique within a manifest` });
|
|
127
|
+
}
|
|
128
|
+
seenFiles.add(template.file);
|
|
129
|
+
if (template.kind === "page") {
|
|
130
|
+
if (template.documentType !== undefined && !documentTypeNames.has(template.documentType)) {
|
|
131
|
+
issues.push({
|
|
132
|
+
path: ["templates", index, "documentType"],
|
|
133
|
+
message: `documentType "${template.documentType}" does not match any name in this manifest's documentTypes contribution`,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else if (template.documentType !== undefined) {
|
|
138
|
+
issues.push({
|
|
139
|
+
path: ["templates", index, "documentType"],
|
|
140
|
+
message: `documentType is only allowed on "page" kind templates, not "${template.kind}"`,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
const seenAssets = new Set();
|
|
145
|
+
(value.assets ?? []).forEach((asset, index) => {
|
|
146
|
+
if (seenAssets.has(asset)) {
|
|
147
|
+
issues.push({ path: ["assets", index], message: `Duplicate asset path "${asset}": asset paths must be unique within a manifest` });
|
|
148
|
+
}
|
|
149
|
+
seenAssets.add(asset);
|
|
150
|
+
});
|
|
151
|
+
return issues;
|
|
152
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The listing labels. A label files and filters a listing; it gates nothing. */
|
|
2
|
+
export declare const PLUGIN_TYPES: readonly ["datatype", "section", "template", "theme", "integration", "utility", "bundle"];
|
|
3
|
+
/** Every dialect the SDK's manifest schema accepts, for a plugin that runs on a developer's own machine. */
|
|
4
|
+
export declare const DATABASE_DIALECTS: readonly ["postgresql", "mysql", "sqlite", "mssql", "mongodb"];
|
|
5
|
+
/** The dialects a listed plugin may claim: Tier 1, the ones the conformance suite covers. */
|
|
6
|
+
export declare const TIER1_DIALECTS: readonly ["postgresql", "mysql", "sqlite"];
|
|
7
|
+
export declare const STORAGE_TYPES: readonly ["simple", "structured"];
|
|
8
|
+
/** Which credential reaches an apiRoute handler. */
|
|
9
|
+
export declare const API_ROUTE_ACCESS_TIERS: readonly ["admin", "apiKey", "public"];
|
|
10
|
+
export declare const TEMPLATE_KINDS: readonly ["page", "layout", "partial"];
|
|
11
|
+
export type PluginTypeValue = (typeof PLUGIN_TYPES)[number];
|
|
12
|
+
export type DatabaseDialectValue = (typeof DATABASE_DIALECTS)[number];
|
|
13
|
+
export type Tier1Dialect = (typeof TIER1_DIALECTS)[number];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// S311: the closed lists a plugin manifest is written in, defined once. The
|
|
2
|
+
// marketplace may import api-schemas and may not import the SDK's runtime (the
|
|
3
|
+
// deployed Next app must not pull TipTap or CodeMirror), so the lists live here
|
|
4
|
+
// and the SDK re-exports them. Each constant has a `Same<>` check against its
|
|
5
|
+
// contract type in packages/plugin-sdk/src/manifest-schema.ts.
|
|
6
|
+
/** The listing labels. A label files and filters a listing; it gates nothing. */
|
|
7
|
+
export const PLUGIN_TYPES = ["datatype", "section", "template", "theme", "integration", "utility", "bundle"];
|
|
8
|
+
/** Every dialect the SDK's manifest schema accepts, for a plugin that runs on a developer's own machine. */
|
|
9
|
+
export const DATABASE_DIALECTS = ["postgresql", "mysql", "sqlite", "mssql", "mongodb"];
|
|
10
|
+
/** The dialects a listed plugin may claim: Tier 1, the ones the conformance suite covers. */
|
|
11
|
+
export const TIER1_DIALECTS = ["postgresql", "mysql", "sqlite"];
|
|
12
|
+
export const STORAGE_TYPES = ["simple", "structured"];
|
|
13
|
+
/** Which credential reaches an apiRoute handler. */
|
|
14
|
+
export const API_ROUTE_ACCESS_TIERS = ["admin", "apiKey", "public"];
|
|
15
|
+
export const TEMPLATE_KINDS = ["page", "layout", "partial"];
|
|
@@ -239,6 +239,11 @@ export declare const PublicTemplateListResponseSchema: z.ZodObject<{
|
|
|
239
239
|
}, z.core.$strip>;
|
|
240
240
|
export type PublicTemplateListResponse = z.infer<typeof PublicTemplateListResponseSchema>;
|
|
241
241
|
export declare const PublicContentWriteResponseSchema: z.ZodObject<{
|
|
242
|
+
readOnlyFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
243
|
+
fieldAlias: z.ZodString;
|
|
244
|
+
pluginId: z.ZodString;
|
|
245
|
+
message: z.ZodString;
|
|
246
|
+
}, z.core.$strip>>>;
|
|
242
247
|
id: z.ZodString;
|
|
243
248
|
documentTypeId: z.ZodString;
|
|
244
249
|
parentId: z.ZodNullable<z.ZodString>;
|