@kardalum/plugin-sdk 0.0.0-stage → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +108 -0
- package/LICENSE +202 -0
- package/README.md +70 -2
- package/dist/admin-section-registry.d.ts +34 -0
- package/dist/admin-section-registry.js +49 -0
- package/dist/built-in-serializers.d.ts +3 -0
- package/dist/built-in-serializers.js +18 -0
- package/dist/built-in-settings-schemas.d.ts +14 -0
- package/dist/built-in-settings-schemas.js +225 -0
- package/dist/built-in-value-schemas.d.ts +4 -0
- package/dist/built-in-value-schemas.js +47 -0
- package/dist/built-ins.d.ts +1 -0
- package/dist/built-ins.js +257 -0
- package/dist/capabilities.d.ts +99 -0
- package/dist/capabilities.js +363 -0
- package/dist/data-type-plugin.d.ts +28 -0
- package/dist/data-type-plugin.js +1 -0
- package/dist/datatype-validation.d.ts +26 -0
- package/dist/datatype-validation.js +110 -0
- package/dist/datatypes-entry.d.ts +4 -0
- package/dist/datatypes-entry.js +18 -0
- package/dist/define-plugin.d.ts +25 -0
- package/dist/define-plugin.js +51 -0
- package/dist/entitlement-entry.d.ts +5 -0
- package/dist/entitlement-entry.js +24 -0
- package/dist/entitlement-gate.d.ts +36 -0
- package/dist/entitlement-gate.js +201 -0
- package/dist/entitlement-types.d.ts +39 -0
- package/dist/entitlement-types.js +1 -0
- package/dist/entitlement.d.ts +57 -0
- package/dist/entitlement.js +170 -0
- package/dist/host-entry.d.ts +1 -0
- package/dist/host-entry.js +11 -0
- package/dist/icon-name.d.ts +1 -0
- package/dist/icon-name.js +1 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +10 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +93 -0
- package/dist/license-verdict-keys.d.ts +18 -0
- package/dist/license-verdict-keys.js +22 -0
- package/dist/local-host.d.ts +3 -0
- package/dist/local-host.js +38 -0
- package/dist/manifest-entry.d.ts +8 -0
- package/dist/manifest-entry.js +13 -0
- package/dist/manifest-schema.d.ts +408 -0
- package/dist/manifest-schema.js +774 -0
- package/dist/manifest.d.ts +546 -0
- package/dist/manifest.js +86 -0
- package/dist/media/media-picker.d.ts +39 -0
- package/dist/media/media-picker.js +438 -0
- package/dist/media/upload-error.d.ts +12 -0
- package/dist/media/upload-error.js +30 -0
- package/dist/plugin-context.d.ts +75 -0
- package/dist/plugin-context.js +70 -0
- package/dist/plugin-screen-context.d.ts +40 -0
- package/dist/plugin-screen-context.js +16 -0
- package/dist/register-built-ins.d.ts +1 -0
- package/dist/register-built-ins.js +41 -0
- package/dist/registry.d.ts +4 -0
- package/dist/registry.js +17 -0
- package/dist/rendition-eligibility.d.ts +24 -0
- package/dist/rendition-eligibility.js +40 -0
- package/dist/richtext/block-panel.d.ts +27 -0
- package/dist/richtext/block-panel.js +232 -0
- package/dist/richtext/extensions.d.ts +19 -0
- package/dist/richtext/extensions.js +56 -0
- package/dist/richtext/insert-menu.d.ts +24 -0
- package/dist/richtext/insert-menu.js +142 -0
- package/dist/richtext/kardalum-block.d.ts +33 -0
- package/dist/richtext/kardalum-block.js +282 -0
- package/dist/richtext/style-listbox.d.ts +10 -0
- package/dist/richtext/style-listbox.js +69 -0
- package/dist/richtext/text-style-class.d.ts +18 -0
- package/dist/richtext/text-style-class.js +36 -0
- package/dist/simple-storage-value-provider.d.ts +9 -0
- package/dist/simple-storage-value-provider.js +96 -0
- package/dist/structured-storage-types.d.ts +61 -0
- package/dist/structured-storage-types.js +11 -0
- package/dist/tailwind.d.ts +1 -0
- package/dist/tailwind.js +5 -0
- package/dist/tokens/system-dark.css +75 -0
- package/dist/tokens/tokens.css +239 -0
- package/dist/tokens/tokens.json +212 -0
- package/dist/tokens.d.ts +1 -0
- package/dist/tokens.js +11 -0
- package/dist/ui-entry.d.ts +5 -0
- package/dist/ui-entry.js +42 -0
- package/dist/views/content-list-preview.d.ts +1 -0
- package/dist/views/content-list-preview.js +14 -0
- package/dist/views/content-list-settings-view.d.ts +1 -0
- package/dist/views/content-list-settings-view.js +97 -0
- package/dist/views/content-list-view.d.ts +19 -0
- package/dist/views/content-list-view.js +248 -0
- package/dist/views/crop-view.d.ts +55 -0
- package/dist/views/crop-view.js +161 -0
- package/dist/views/date-range-view.d.ts +6 -0
- package/dist/views/date-range-view.js +55 -0
- package/dist/views/file-upload-view.d.ts +43 -0
- package/dist/views/file-upload-view.js +104 -0
- package/dist/views/html-code-editor.d.ts +10 -0
- package/dist/views/html-code-editor.js +101 -0
- package/dist/views/html-view.d.ts +3 -0
- package/dist/views/html-view.js +53 -0
- package/dist/views/image-view.d.ts +3 -0
- package/dist/views/image-view.js +387 -0
- package/dist/views/rich-text-view.d.ts +2 -0
- package/dist/views/rich-text-view.js +429 -0
- package/node_modules/@kardalum/api-schemas/LICENSE +202 -0
- package/node_modules/@kardalum/api-schemas/README.md +56 -0
- package/node_modules/@kardalum/api-schemas/dist/action.schema.d.ts +30 -0
- package/node_modules/@kardalum/api-schemas/dist/action.schema.js +88 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +36 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +89 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +24 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +47 -0
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.d.ts +38 -0
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +537 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +353 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +158 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +139 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +125 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +256 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +23 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +151 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +82 -0
- package/node_modules/@kardalum/api-schemas/dist/content-version.schema.d.ts +18 -0
- package/node_modules/@kardalum/api-schemas/dist/content-version.schema.js +22 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.js +20 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +302 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +97 -0
- package/node_modules/@kardalum/api-schemas/dist/culture-direction.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/culture-direction.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +36 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +296 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +138 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +121 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +147 -0
- package/node_modules/@kardalum/api-schemas/dist/health.schema.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/health.schema.js +5 -0
- package/node_modules/@kardalum/api-schemas/dist/html-entities.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/html-entities.js +250 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +102 -0
- package/node_modules/@kardalum/api-schemas/dist/index.js +58 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +381 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +197 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +167 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +214 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +77 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +117 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +27 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.js +279 -0
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.d.ts +74 -0
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +157 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +80 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +156 -0
- package/node_modules/@kardalum/api-schemas/dist/nav.schema.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/nav.schema.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +846 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +356 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +169 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +80 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.d.ts +65 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +889 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +89 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +134 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +369 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +393 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +87 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +25 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +24 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +306 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +328 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +79 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +50 -0
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +90 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +69 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +108 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +93 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +243 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +296 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +43 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +25 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +30 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +112 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +74 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +39 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +89 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +68 -0
- package/node_modules/@kardalum/api-schemas/package.json +35 -0
- package/node_modules/@kardalum/design-tokens/LICENSE +202 -0
- package/node_modules/@kardalum/design-tokens/README.md +29 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +32 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +88 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.d.ts +1 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.js +18 -0
- package/node_modules/@kardalum/design-tokens/dist/index.d.ts +6 -0
- package/node_modules/@kardalum/design-tokens/dist/index.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/system-dark.css +75 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +33 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +54 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +12 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-css.js +42 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +43 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-types.js +1 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +13 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +120 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/index.d.ts +5 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/index.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +9 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/light.js +13 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +239 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +25 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +276 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +212 -0
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +91 -0
- package/node_modules/@kardalum/design-tokens/dist/types.js +5 -0
- package/node_modules/@kardalum/design-tokens/package.json +42 -0
- package/node_modules/@kardalum/plugin-package/LICENSE +202 -0
- package/node_modules/@kardalum/plugin-package/README.md +71 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +50 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +659 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +19 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.js +104 -0
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +37 -0
- package/node_modules/@kardalum/plugin-package/dist/extract.js +199 -0
- package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/hash.js +69 -0
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +11 -0
- package/node_modules/@kardalum/plugin-package/dist/index.js +7 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +185 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +236 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +50 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.js +115 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +17 -0
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +45 -0
- package/node_modules/@kardalum/plugin-package/dist/types.js +1 -0
- package/node_modules/@kardalum/plugin-package/package.json +49 -0
- package/node_modules/@kardalum/ui/LICENSE +202 -0
- package/node_modules/@kardalum/ui/README.md +35 -0
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +14 -0
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +38 -0
- package/node_modules/@kardalum/ui/dist/components/badge.d.ts +9 -0
- package/node_modules/@kardalum/ui/dist/components/badge.js +30 -0
- package/node_modules/@kardalum/ui/dist/components/button.d.ts +11 -0
- package/node_modules/@kardalum/ui/dist/components/button.js +37 -0
- package/node_modules/@kardalum/ui/dist/components/checkbox.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/dialog.js +48 -0
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +53 -0
- package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +30 -0
- package/node_modules/@kardalum/ui/dist/components/empty-state.js +9 -0
- package/node_modules/@kardalum/ui/dist/components/input.d.ts +4 -0
- package/node_modules/@kardalum/ui/dist/components/input.js +6 -0
- package/node_modules/@kardalum/ui/dist/components/panel.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/panel.js +6 -0
- package/node_modules/@kardalum/ui/dist/components/property-field.d.ts +19 -0
- package/node_modules/@kardalum/ui/dist/components/property-field.js +86 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.js +55 -0
- package/node_modules/@kardalum/ui/dist/components/skeleton.d.ts +3 -0
- package/node_modules/@kardalum/ui/dist/components/skeleton.js +9 -0
- package/node_modules/@kardalum/ui/dist/components/switch.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/switch.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +34 -0
- package/node_modules/@kardalum/ui/dist/components/tab-strip.js +72 -0
- package/node_modules/@kardalum/ui/dist/components/toast.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/components/toast.js +42 -0
- package/node_modules/@kardalum/ui/dist/components/toaster.d.ts +12 -0
- package/node_modules/@kardalum/ui/dist/components/toaster.js +11 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.js +62 -0
- package/node_modules/@kardalum/ui/dist/index.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/index.js +18 -0
- package/node_modules/@kardalum/ui/dist/lib/cn.d.ts +2 -0
- package/node_modules/@kardalum/ui/dist/lib/cn.js +5 -0
- package/node_modules/@kardalum/ui/package.json +63 -0
- package/package.json +146 -4
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const CROP_EDITOR_ID = "com.kardalum.crop";
|
|
3
|
+
export const THUMBNAIL_EDITOR_ID = "com.kardalum.thumbnail";
|
|
4
|
+
// Seeded ids continue the b1e00000 block. 0001 to 0009 are taken by
|
|
5
|
+
// earlier sessions; 0010 and 0011 are skipped because document-type
|
|
6
|
+
// .schema.test.ts already uses them as fixtures, and a seed that looks
|
|
7
|
+
// like a test row is a trap for whoever debugs it next.
|
|
8
|
+
export const CROP_DATA_TYPE_ID = "b1e00000-0000-4000-8000-000000000012";
|
|
9
|
+
export const THUMBNAIL_DATA_TYPE_ID = "b1e00000-0000-4000-8000-000000000013";
|
|
10
|
+
// Fractions of the source, never pixels (spec section 5). A rectangle
|
|
11
|
+
// expressed in pixels cannot be reapplied to a different resolution, and
|
|
12
|
+
// reapplying it is the whole point: a new version offers the previous
|
|
13
|
+
// rectangle, and the source may be a different size.
|
|
14
|
+
export const CropRectSchema = z
|
|
15
|
+
.object({
|
|
16
|
+
x: z.number().min(0).lt(1),
|
|
17
|
+
y: z.number().min(0).lt(1),
|
|
18
|
+
w: z.number().gt(0).max(1),
|
|
19
|
+
h: z.number().gt(0).max(1),
|
|
20
|
+
})
|
|
21
|
+
.refine((r) => r.x + r.w <= 1 && r.y + r.h <= 1, {
|
|
22
|
+
message: "the rectangle must lie inside the source",
|
|
23
|
+
});
|
|
24
|
+
// A crop is a RATIO, not an output size (operator, 2026-09-20). The cut
|
|
25
|
+
// keeps the source region's own resolution, and maxWidth is the only
|
|
26
|
+
// ceiling. Leading zeros are refused so one shape has one spelling.
|
|
27
|
+
//
|
|
28
|
+
// `.strict()` is what lets the hand-kept mirror in @kardalum/plugin-sdk
|
|
29
|
+
// be generated with `io: "input"`: input mode is the only mode that keeps
|
|
30
|
+
// `maxWidth` out of `required` (a member with a default is always present
|
|
31
|
+
// AFTER a parse, never before one, and the mirror validates what a client
|
|
32
|
+
// SENDS), but on a non-strict object input mode also drops
|
|
33
|
+
// `additionalProperties: false`. Strict here means both hold at once, and
|
|
34
|
+
// it matches what the mirror has enforced since these types shipped.
|
|
35
|
+
export const CropSettingsSchema = z
|
|
36
|
+
.object({
|
|
37
|
+
ratio: z.string().regex(/^[1-9][0-9]*:[1-9][0-9]*$/, "a ratio looks like 3:4"),
|
|
38
|
+
maxWidth: z.number().int().positive().nullable().default(null),
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
41
|
+
// `.strict()` for the same reason as the crop above, even though this one
|
|
42
|
+
// has no member carrying a default: its mirror is generated in the same
|
|
43
|
+
// input mode, and without strict that mode would quietly emit a schema
|
|
44
|
+
// with no `additionalProperties: false`, loosening server validation.
|
|
45
|
+
export const ThumbnailSettingsSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
longestEdge: z.number().int().positive(),
|
|
48
|
+
})
|
|
49
|
+
.strict();
|
|
50
|
+
export const MediaRenditionSchema = z.object({
|
|
51
|
+
id: z.string().uuid(),
|
|
52
|
+
mediaVersionId: z.string().uuid(),
|
|
53
|
+
// The suffix its filename carries, "3x4" or "thumb". Unique within a
|
|
54
|
+
// version, which is what lets the public route resolve a rendition by
|
|
55
|
+
// filename alone.
|
|
56
|
+
name: z.string().min(1),
|
|
57
|
+
filename: z.string().min(1),
|
|
58
|
+
mimeType: z.string().min(1),
|
|
59
|
+
size: z.number().int().nonnegative(),
|
|
60
|
+
width: z.number().int().positive(),
|
|
61
|
+
height: z.number().int().positive(),
|
|
62
|
+
rect: CropRectSchema,
|
|
63
|
+
createdAt: z.string().datetime(),
|
|
64
|
+
});
|
|
65
|
+
// THE ONE PLACE the suffix rule lives. A crop's suffix comes from its
|
|
66
|
+
// ratio, which is why two crops on one media type may not share a ratio:
|
|
67
|
+
// they would write to one filename and overwrite each other. Two
|
|
68
|
+
// thumbnail fields collide the same way, since every thumbnail is named
|
|
69
|
+
// "thumb". Three doors refuse that state, and all three ask this function
|
|
70
|
+
// rather than re-deriving the rule (S234c Task 7):
|
|
71
|
+
// DocumentTypeService.createDocumentType (which is also the plugin
|
|
72
|
+
// manifest install path), PUT /api/document-types/:id, and
|
|
73
|
+
// PATCH /api/data-types/:id, which could otherwise edit one crop data
|
|
74
|
+
// type's ratio into another's without touching the media type at all.
|
|
75
|
+
export function renditionName(dataType) {
|
|
76
|
+
// A union rather than `editorId: string` with a cast. The argument is a
|
|
77
|
+
// DATA TYPE (an editor id and its settings), not a field definition: a
|
|
78
|
+
// field carries a datatypeId and has no editorId of its own. Narrowing
|
|
79
|
+
// on the id is what makes `settings` the right shape in each branch, so
|
|
80
|
+
// an editor this function does not know cannot reach `ratio` through a
|
|
81
|
+
// cast and throw from somewhere confusing.
|
|
82
|
+
if (dataType.editorId === THUMBNAIL_EDITOR_ID) {
|
|
83
|
+
return "thumb";
|
|
84
|
+
}
|
|
85
|
+
return dataType.settings.ratio.replace(":", "x");
|
|
86
|
+
}
|
|
87
|
+
/** Two numbers around an `x` and nothing else: exactly what
|
|
88
|
+
* `CropSettingsSchema`'s ratio allows above (no leading zeros, both sides
|
|
89
|
+
* at least 1) once `renditionName` has replaced the colon. It is written
|
|
90
|
+
* here, next to that schema, so the rule and its inverse are read
|
|
91
|
+
* together: a copy of this pattern in another package would drift the
|
|
92
|
+
* first time either spelling changed, and only someone reading both files
|
|
93
|
+
* would notice. */
|
|
94
|
+
const RATIO_NAME = /^([1-9][0-9]*)x([1-9][0-9]*)$/;
|
|
95
|
+
/**
|
|
96
|
+
* `renditionName` read backwards, `"3x4"` -> `"3:4"`, for every surface
|
|
97
|
+
* that shows a name to a PERSON.
|
|
98
|
+
*
|
|
99
|
+
* A crop's name is its ratio with the colon replaced, because a filename
|
|
100
|
+
* cannot carry a colon. That makes the name INVERTIBLE: the shape comes
|
|
101
|
+
* back out of it with no lookup, nothing to go stale and nothing to
|
|
102
|
+
* guess. Everything that talks to the server keeps sending the name.
|
|
103
|
+
*
|
|
104
|
+
* Everything else comes back unchanged, `"thumb"` included: a thumbnail's
|
|
105
|
+
* name encodes no ratio, and a name this rule does not recognise (a
|
|
106
|
+
* plugin's own, a hand-authored one) is a name nothing here is entitled
|
|
107
|
+
* to rewrite.
|
|
108
|
+
*
|
|
109
|
+
* WHAT IT DOES NOT RECOVER is the crop field's own caption, "Portrait".
|
|
110
|
+
* That caption lives on a field of a MEDIA document type, while an image
|
|
111
|
+
* field's settings store a name and only a name (ImageSettingsSchema
|
|
112
|
+
* below), so a surface holding just the name says the shape, which is
|
|
113
|
+
* true, rather than a caption it would have to invent.
|
|
114
|
+
*/
|
|
115
|
+
export function renditionShape(name) {
|
|
116
|
+
const match = RATIO_NAME.exec(name);
|
|
117
|
+
return match ? `${match[1]}:${match[2]}` : name;
|
|
118
|
+
}
|
|
119
|
+
// `espresso-bar.jpg` + `3x4` -> `espresso-bar_3x4.jpg`. The LAST dot wins,
|
|
120
|
+
// so `my.photo.v2.jpeg` keeps `.jpeg` rather than treating `.photo` as the
|
|
121
|
+
// extension. A name with no dot simply gains the suffix.
|
|
122
|
+
export function renditionFilename(sourceFilename, name) {
|
|
123
|
+
const dot = sourceFilename.lastIndexOf(".");
|
|
124
|
+
if (dot <= 0) {
|
|
125
|
+
return `${sourceFilename}_${name}`;
|
|
126
|
+
}
|
|
127
|
+
return `${sourceFilename.slice(0, dot)}_${name}${sourceFilename.slice(dot)}`;
|
|
128
|
+
}
|
|
129
|
+
// The com.kardalum.image editor's settings. `acceptedTypes` and
|
|
130
|
+
// `maxSizeBytes` have existed since Session 69, in the hand-kept JSON
|
|
131
|
+
// Schema mirror (IMAGE_SETTINGS_SCHEMA in @kardalum/plugin-sdk) alone;
|
|
132
|
+
// this is their first Zod statement, and it is now the source of truth
|
|
133
|
+
// the mirror is generated from.
|
|
134
|
+
//
|
|
135
|
+
// `rendition` (S234d) is what an image field asks its picture for: null
|
|
136
|
+
// means any picture will do, a value means the field wants that crop.
|
|
137
|
+
//
|
|
138
|
+
// THE VALUE IS A RENDITION NAME, the one `renditionName` above produces:
|
|
139
|
+
// "3x4", "thumb". Not a data type id, and not the ratio "3:4" the name
|
|
140
|
+
// came from. The field doing the asking sits on a PAGE document type; the
|
|
141
|
+
// crop it is asking about is a field on a MEDIA document type. Those are
|
|
142
|
+
// two different types with two different field lists, so a data type id
|
|
143
|
+
// would be meaningless on the far side of that boundary. The name is the
|
|
144
|
+
// one value both sides already agree on, it is what the rendition's
|
|
145
|
+
// filename carries, and `renditionName` is the only thing in the product
|
|
146
|
+
// that produces one.
|
|
147
|
+
//
|
|
148
|
+
// `.strict()` matches what the mirror has always done
|
|
149
|
+
// (`additionalProperties: false`): a misspelled setting is a setting that
|
|
150
|
+
// silently does nothing, which is worse than a refusal.
|
|
151
|
+
export const ImageSettingsSchema = z
|
|
152
|
+
.object({
|
|
153
|
+
acceptedTypes: z.array(z.string()).optional(),
|
|
154
|
+
maxSizeBytes: z.number().int().positive().optional(),
|
|
155
|
+
rendition: z.string().min(1).nullable().default(null),
|
|
156
|
+
})
|
|
157
|
+
.strict();
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const MediaVisibilitySchema: z.ZodEnum<{
|
|
3
|
+
public: "public";
|
|
4
|
+
private: "private";
|
|
5
|
+
}>;
|
|
6
|
+
export type MediaVisibility = z.infer<typeof MediaVisibilitySchema>;
|
|
7
|
+
export declare const MediaFileSchema: z.ZodObject<{
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
filename: z.ZodString;
|
|
10
|
+
mimeType: z.ZodString;
|
|
11
|
+
size: z.ZodNumber;
|
|
12
|
+
url: z.ZodString;
|
|
13
|
+
visibility: z.ZodEnum<{
|
|
14
|
+
public: "public";
|
|
15
|
+
private: "private";
|
|
16
|
+
}>;
|
|
17
|
+
folderId: z.ZodNullable<z.ZodString>;
|
|
18
|
+
uploadedBy: z.ZodString;
|
|
19
|
+
uploadedAt: z.ZodString;
|
|
20
|
+
documentTypeId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
21
|
+
data: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>, z.ZodTransform<Record<string, unknown>, Record<string, unknown> | null | undefined>>;
|
|
22
|
+
currentVersion: z.ZodDefault<z.ZodNumber>;
|
|
23
|
+
hasRendition: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
deletedAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export type MediaFile = z.infer<typeof MediaFileSchema>;
|
|
27
|
+
export declare const MediaVersionSchema: z.ZodObject<{
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
mediaFileId: z.ZodString;
|
|
30
|
+
version: z.ZodNumber;
|
|
31
|
+
filename: z.ZodString;
|
|
32
|
+
mimeType: z.ZodString;
|
|
33
|
+
size: z.ZodNumber;
|
|
34
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
35
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
36
|
+
createdAt: z.ZodString;
|
|
37
|
+
createdBy: z.ZodString;
|
|
38
|
+
createdByName: z.ZodNullable<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export type MediaVersion = z.infer<typeof MediaVersionSchema>;
|
|
41
|
+
/**
|
|
42
|
+
* CORE-KNOWN FIELD ALIAS: `private`, on a media document type.
|
|
43
|
+
*
|
|
44
|
+
* S234a, and the first member of a set the core will grow. A field alias is
|
|
45
|
+
* an ordinary field id, legal under FieldDefinitionSchema and authored like
|
|
46
|
+
* any other field, that the core recognises by name on a type of a given
|
|
47
|
+
* kind and gives a meaning beyond "a value in `data`". Here: a media type's
|
|
48
|
+
* `private` field binds to the item's `visibility` column. The column stays
|
|
49
|
+
* the one source of truth for whether an item is private; the field is how
|
|
50
|
+
* a person edits it.
|
|
51
|
+
*
|
|
52
|
+
* THE RULE, which is what makes an alias a rule rather than a special case:
|
|
53
|
+
* an alias is optional, and its absence has a defined default. A media type
|
|
54
|
+
* with no `private` field has public items. An alias can therefore never
|
|
55
|
+
* make a type invalid, and a type authored by someone who has never heard
|
|
56
|
+
* of aliases behaves exactly as its author expected.
|
|
57
|
+
*
|
|
58
|
+
* It is deliberately a name a person could also choose for a field of their
|
|
59
|
+
* own, and that is the point: they get the behavior, not a collision. The
|
|
60
|
+
* reserved-key approach this replaced (a leading underscore, as
|
|
61
|
+
* CONTENT_NAME_KEY still uses) bought collision-proofing at the price of an
|
|
62
|
+
* id no field definition can legally hold, which made any type carrying it
|
|
63
|
+
* unserializable through the document types API.
|
|
64
|
+
*
|
|
65
|
+
* Planned next, same mechanism: `navhide` on a content type, a page that is
|
|
66
|
+
* published but not returned among its parent's children, defaulting to
|
|
67
|
+
* "shown" when the type omits it.
|
|
68
|
+
*/
|
|
69
|
+
export declare const MEDIA_PRIVATE_ALIAS = "private";
|
|
70
|
+
export declare const IMAGE_MEDIA_TYPE_ID = "d1e00000-0000-4000-8000-000000000001";
|
|
71
|
+
export declare const FILE_MEDIA_TYPE_ID = "d1e00000-0000-4000-8000-000000000002";
|
|
72
|
+
export declare const IMAGE_FILE_DATA_TYPE_ID = "b1e00000-0000-4000-8000-000000000008";
|
|
73
|
+
export declare const ANY_FILE_DATA_TYPE_ID = "b1e00000-0000-4000-8000-000000000009";
|
|
74
|
+
export declare const MediaFolderSchema: z.ZodObject<{
|
|
75
|
+
id: z.ZodString;
|
|
76
|
+
name: z.ZodString;
|
|
77
|
+
parentId: z.ZodNullable<z.ZodString>;
|
|
78
|
+
createdAt: z.ZodString;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
export type MediaFolder = z.infer<typeof MediaFolderSchema>;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// 'public' | 'private' (S186c §2) — a flag, never a location. Default
|
|
3
|
+
// 'public' matches a CMS's normal case (images in posts) and existing
|
|
4
|
+
// rows' pre-S186c behavior (everything was effectively link-accessible).
|
|
5
|
+
export const MediaVisibilitySchema = z.enum(["public", "private"]);
|
|
6
|
+
export const MediaFileSchema = z.object({
|
|
7
|
+
id: z.string().uuid(),
|
|
8
|
+
filename: z.string().min(1),
|
|
9
|
+
mimeType: z.string().min(1),
|
|
10
|
+
size: z.number().int().nonnegative(),
|
|
11
|
+
// The stable app path (`/media/<id>/v<version>/<filename>`, S186c §3,
|
|
12
|
+
// versioned by S234b), not an absolute URL. Computed per response from
|
|
13
|
+
// the row (id, currentVersion, filename) and never signed, so it can
|
|
14
|
+
// never have a host/port/endpoint baked in that has gone stale. It
|
|
15
|
+
// names one set of bytes: a replace moves the item to a new version and
|
|
16
|
+
// this path moves with it, which is what lets the byte route cache each
|
|
17
|
+
// version forever.
|
|
18
|
+
url: z.string().min(1),
|
|
19
|
+
visibility: MediaVisibilitySchema,
|
|
20
|
+
// Virtual folder membership (S186e §1) — null = library root. A flag on
|
|
21
|
+
// the row only, same spirit as visibility: it never changes `url`
|
|
22
|
+
// above or anything in storage (folders are explicitly excluded from
|
|
23
|
+
// media URLs, spec §4 — the permanence guardrail). Moving a file is a
|
|
24
|
+
// metadata write, nothing else.
|
|
25
|
+
folderId: z.string().uuid().nullable(),
|
|
26
|
+
uploadedBy: z.string().uuid(),
|
|
27
|
+
uploadedAt: z.string().datetime(),
|
|
28
|
+
// S234a: the media document type this item is, and that type's field
|
|
29
|
+
// values. Null and empty for rows written before media had types, which
|
|
30
|
+
// the upgrade backfills. The reference is by id with no foreign key:
|
|
31
|
+
// document types are adapter-owned and may live in a different database
|
|
32
|
+
// (KARDALUM_CONTENT_DATABASE_URL), so nothing may join across it.
|
|
33
|
+
documentTypeId: z.string().uuid().nullable().default(null),
|
|
34
|
+
// `.nullish()` + a transform, not `.default({})`: `data` is a nullable
|
|
35
|
+
// Prisma column with no default (see schema.prisma's MediaFile comment
|
|
36
|
+
// for why), so a row can hand back a JS `null`, not just `undefined`.
|
|
37
|
+
// Zod's `.default()` only ever substitutes on `undefined` and lets a
|
|
38
|
+
// `null` straight through to the record check, where it fails. This
|
|
39
|
+
// normalizes both `null` and absence to `{}`, so the output type stays
|
|
40
|
+
// a plain `Record<string, unknown>` and no consumer has to think about
|
|
41
|
+
// a possible null.
|
|
42
|
+
data: z
|
|
43
|
+
.record(z.string(), z.unknown())
|
|
44
|
+
.nullish()
|
|
45
|
+
.transform((value) => value ?? {}),
|
|
46
|
+
// S234b: which version this item serves. Defaults to 1 so a row written
|
|
47
|
+
// before versions existed parses unchanged; the 0007 step backfills the
|
|
48
|
+
// column itself.
|
|
49
|
+
currentVersion: z.number().int().positive().default(1),
|
|
50
|
+
// S234d: whether this item's current version carries the rendition the
|
|
51
|
+
// list was asked about (`rendition` on MediaListQuerySchema). OPTIONAL,
|
|
52
|
+
// and absent is the honest answer when nothing was asked: a `false`
|
|
53
|
+
// there would read as "this picture has no such crop" when the truth is
|
|
54
|
+
// that no crop was named. Only the picker asks, and only so it can dim
|
|
55
|
+
// the pictures a field cannot use.
|
|
56
|
+
//
|
|
57
|
+
// Not stored, ever. It is an answer about one query, computed per
|
|
58
|
+
// response from the renditions of `currentVersion`, so it goes stale the
|
|
59
|
+
// moment either the query or the item changes.
|
|
60
|
+
hasRendition: z.boolean().optional(),
|
|
61
|
+
// S234e: when this item was moved to the Recycle Bin, null while it is
|
|
62
|
+
// live. Nullable with a default rather than optional, because every
|
|
63
|
+
// media row written before this session has no such column value and
|
|
64
|
+
// must parse as "not trashed" rather than as "unknown".
|
|
65
|
+
//
|
|
66
|
+
// A trashed item is not reachable through any ordinary read: the
|
|
67
|
+
// service's own reads all carry `deletedAt: null`. So this field is
|
|
68
|
+
// null on every item the library, the picker and the API ever return,
|
|
69
|
+
// and non-null only on the two reads that deliberately ask for a
|
|
70
|
+
// trashed one (the bin's listing, and the item screen's read of a file
|
|
71
|
+
// that was trashed while it was open).
|
|
72
|
+
deletedAt: z.string().datetime().nullable().default(null),
|
|
73
|
+
});
|
|
74
|
+
// S234b: one set of bytes. A media item has one of these per version, and
|
|
75
|
+
// `MediaFile.currentVersion` says which one it serves.
|
|
76
|
+
//
|
|
77
|
+
// `storageKey` is deliberately absent: where bytes live is the server's
|
|
78
|
+
// business, it differs per version (rows written before S234b keep their
|
|
79
|
+
// old unversioned key), and nothing outside the service has any use for it.
|
|
80
|
+
export const MediaVersionSchema = z.object({
|
|
81
|
+
id: z.string().uuid(),
|
|
82
|
+
mediaFileId: z.string().uuid(),
|
|
83
|
+
version: z.number().int().positive(),
|
|
84
|
+
filename: z.string().min(1),
|
|
85
|
+
mimeType: z.string().min(1),
|
|
86
|
+
size: z.number().int().nonnegative(),
|
|
87
|
+
// Pixel dimensions, when the client that sent the replacement measured
|
|
88
|
+
// them. Null for a PDF, null on every upload (nothing measures there),
|
|
89
|
+
// and null for every version written before anything measured them.
|
|
90
|
+
width: z.number().int().positive().nullable(),
|
|
91
|
+
height: z.number().int().positive().nullable(),
|
|
92
|
+
createdAt: z.string().datetime(),
|
|
93
|
+
createdBy: z.string().uuid(),
|
|
94
|
+
// The display name of the user `createdBy` names, so a history row can
|
|
95
|
+
// say who replaced a file instead of showing an editor a uuid.
|
|
96
|
+
//
|
|
97
|
+
// Nullable rather than optional, because the server always decides:
|
|
98
|
+
// null means there is no name to show, which covers both a user row that
|
|
99
|
+
// is gone and a user who never set one (`User.name` is itself nullable).
|
|
100
|
+
//
|
|
101
|
+
// NAME ONLY, deliberately. Never the email and never the role: those
|
|
102
|
+
// live on GET /api/users, which is admin only, and this list is not.
|
|
103
|
+
createdByName: z.string().nullable(),
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* CORE-KNOWN FIELD ALIAS: `private`, on a media document type.
|
|
107
|
+
*
|
|
108
|
+
* S234a, and the first member of a set the core will grow. A field alias is
|
|
109
|
+
* an ordinary field id, legal under FieldDefinitionSchema and authored like
|
|
110
|
+
* any other field, that the core recognises by name on a type of a given
|
|
111
|
+
* kind and gives a meaning beyond "a value in `data`". Here: a media type's
|
|
112
|
+
* `private` field binds to the item's `visibility` column. The column stays
|
|
113
|
+
* the one source of truth for whether an item is private; the field is how
|
|
114
|
+
* a person edits it.
|
|
115
|
+
*
|
|
116
|
+
* THE RULE, which is what makes an alias a rule rather than a special case:
|
|
117
|
+
* an alias is optional, and its absence has a defined default. A media type
|
|
118
|
+
* with no `private` field has public items. An alias can therefore never
|
|
119
|
+
* make a type invalid, and a type authored by someone who has never heard
|
|
120
|
+
* of aliases behaves exactly as its author expected.
|
|
121
|
+
*
|
|
122
|
+
* It is deliberately a name a person could also choose for a field of their
|
|
123
|
+
* own, and that is the point: they get the behavior, not a collision. The
|
|
124
|
+
* reserved-key approach this replaced (a leading underscore, as
|
|
125
|
+
* CONTENT_NAME_KEY still uses) bought collision-proofing at the price of an
|
|
126
|
+
* id no field definition can legally hold, which made any type carrying it
|
|
127
|
+
* unserializable through the document types API.
|
|
128
|
+
*
|
|
129
|
+
* Planned next, same mechanism: `navhide` on a content type, a page that is
|
|
130
|
+
* published but not returned among its parent's children, defaulting to
|
|
131
|
+
* "shown" when the type omits it.
|
|
132
|
+
*/
|
|
133
|
+
export const MEDIA_PRIVATE_ALIAS = "private";
|
|
134
|
+
// S234a: fixed uuids for the two built-in media document types and the two
|
|
135
|
+
// built-in file upload data type configs, seeded by a migration in the
|
|
136
|
+
// adapter-owned database. Named here, in the Prisma-owned schema package,
|
|
137
|
+
// so a migration in one database can reference a row seeded in the other
|
|
138
|
+
// without either side guessing at a string.
|
|
139
|
+
export const IMAGE_MEDIA_TYPE_ID = "d1e00000-0000-4000-8000-000000000001";
|
|
140
|
+
export const FILE_MEDIA_TYPE_ID = "d1e00000-0000-4000-8000-000000000002";
|
|
141
|
+
export const IMAGE_FILE_DATA_TYPE_ID = "b1e00000-0000-4000-8000-000000000008";
|
|
142
|
+
export const ANY_FILE_DATA_TYPE_ID = "b1e00000-0000-4000-8000-000000000009";
|
|
143
|
+
// Virtual media folders (S186e §1) — organization lives in the database
|
|
144
|
+
// only; folders are deliberately never part of `/media/<id>/v<version>/<filename>`
|
|
145
|
+
// URLs (spec §4). A tree via parentId: null = a top-level folder. Depth
|
|
146
|
+
// (capped at 5) and per-parent name uniqueness are service-layer
|
|
147
|
+
// concerns, not schema-level ones — see the MediaFolder Prisma model's
|
|
148
|
+
// comment (apps/server/prisma/schema.prisma) for why a DB/schema
|
|
149
|
+
// constraint can't actually deliver per-parent uniqueness across dialects
|
|
150
|
+
// at the root level.
|
|
151
|
+
export const MediaFolderSchema = z.object({
|
|
152
|
+
id: z.string().uuid(),
|
|
153
|
+
name: z.string().min(1),
|
|
154
|
+
parentId: z.string().uuid().nullable(),
|
|
155
|
+
createdAt: z.string().datetime(),
|
|
156
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The most ids the order may hold. */
|
|
3
|
+
export declare const NAV_ORDER_MAX = 100;
|
|
4
|
+
/**
|
|
5
|
+
* One section of the app bar: a built-in section's id, or
|
|
6
|
+
* `plugins/<pluginId>/<sectionId>` for a plugin's section (its URL without
|
|
7
|
+
* the leading slash). Nothing else gets through, so an id can never carry a
|
|
8
|
+
* scheme, a host, a query or a path step into the URL the admin makes of it.
|
|
9
|
+
*
|
|
10
|
+
* The length is asked again inside the refinement, so neither pattern ever
|
|
11
|
+
* runs over a string longer than NAV_ID_MAX, whatever else failed first.
|
|
12
|
+
*/
|
|
13
|
+
export declare const NavIdSchema: z.ZodString;
|
|
14
|
+
/**
|
|
15
|
+
* The `nav` settings row, and the body and answer of GET and PUT
|
|
16
|
+
* /api/settings/nav. An id that names no section the admin knows today is
|
|
17
|
+
* kept (its plugin may be inactive) and skipped when the bar is built. An
|
|
18
|
+
* empty order is the reset: every section in registration order.
|
|
19
|
+
*/
|
|
20
|
+
export declare const NavSettingsSchema: z.ZodObject<{
|
|
21
|
+
order: z.ZodArray<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type NavSettings = z.infer<typeof NavSettingsSchema>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { MANIFEST_ID_SEGMENT_MAX, PLUGIN_ID_REGEX, SLOT_ID_MAX, SLOT_ID_REGEX } from "./plugin-id-rules.js";
|
|
3
|
+
// S281 (spec D6): the operator's order of the admin's app bar, one settings
|
|
4
|
+
// row keyed "nav". The admin builds the bar from it: the listed sections
|
|
5
|
+
// first in this order, the rest after them in registration order, each one
|
|
6
|
+
// shown only to a subject holding its action. A plugin has no say in it.
|
|
7
|
+
/** The most ids the order may hold. */
|
|
8
|
+
export const NAV_ORDER_MAX = 100;
|
|
9
|
+
/** The longest one id may be. */
|
|
10
|
+
const NAV_ID_MAX = 200;
|
|
11
|
+
/** A built-in section's id, such as "content" or "document-types". */
|
|
12
|
+
const BUILT_IN_ID_REGEX = /^[a-z][a-z0-9-]*$/;
|
|
13
|
+
const PLUGIN_SECTION_PREFIX = "plugins/";
|
|
14
|
+
/**
|
|
15
|
+
* Whether `id` is `plugins/<pluginId>/<sectionId>`, the pluginId under the
|
|
16
|
+
* SDK's rule for a manifest id and the sectionId under its rule for a slot
|
|
17
|
+
* id. Split with string functions, so each pattern runs on one short piece.
|
|
18
|
+
*/
|
|
19
|
+
function isPluginSectionId(id) {
|
|
20
|
+
if (!id.startsWith(PLUGIN_SECTION_PREFIX))
|
|
21
|
+
return false;
|
|
22
|
+
const parts = id.slice(PLUGIN_SECTION_PREFIX.length).split("/");
|
|
23
|
+
if (parts.length !== 2)
|
|
24
|
+
return false;
|
|
25
|
+
const [pluginId, sectionId] = parts;
|
|
26
|
+
return (PLUGIN_ID_REGEX.test(pluginId) &&
|
|
27
|
+
pluginId.split(".").length <= MANIFEST_ID_SEGMENT_MAX &&
|
|
28
|
+
sectionId.length <= SLOT_ID_MAX &&
|
|
29
|
+
SLOT_ID_REGEX.test(sectionId));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* One section of the app bar: a built-in section's id, or
|
|
33
|
+
* `plugins/<pluginId>/<sectionId>` for a plugin's section (its URL without
|
|
34
|
+
* the leading slash). Nothing else gets through, so an id can never carry a
|
|
35
|
+
* scheme, a host, a query or a path step into the URL the admin makes of it.
|
|
36
|
+
*
|
|
37
|
+
* The length is asked again inside the refinement, so neither pattern ever
|
|
38
|
+
* runs over a string longer than NAV_ID_MAX, whatever else failed first.
|
|
39
|
+
*/
|
|
40
|
+
export const NavIdSchema = z
|
|
41
|
+
.string()
|
|
42
|
+
.min(1)
|
|
43
|
+
.max(NAV_ID_MAX)
|
|
44
|
+
.refine((id) => id.length <= NAV_ID_MAX && (BUILT_IN_ID_REGEX.test(id) || isPluginSectionId(id)), {
|
|
45
|
+
message: 'A section id is a built-in section such as "content", or "plugins/<plugin id>/<section id>".',
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* The `nav` settings row, and the body and answer of GET and PUT
|
|
49
|
+
* /api/settings/nav. An id that names no section the admin knows today is
|
|
50
|
+
* kept (its plugin may be inactive) and skipped when the bar is built. An
|
|
51
|
+
* empty order is the reset: every section in registration order.
|
|
52
|
+
*/
|
|
53
|
+
export const NavSettingsSchema = z
|
|
54
|
+
.object({ order: z.array(NavIdSchema).max(NAV_ORDER_MAX) })
|
|
55
|
+
.refine((v) => new Set(v.order).size === v.order.length, { message: "A section is listed twice", path: ["order"] });
|