@kardalum/plugin-sdk 0.18.0 → 0.20.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 +253 -0
- package/README.md +20 -1
- package/dist/admin-section-registry.d.ts +16 -1
- package/dist/admin-section-registry.js +23 -0
- package/dist/assets/asset-picker.js +3 -3
- package/dist/built-in-editor-ids.d.ts +1 -1
- package/dist/built-in-editor-ids.js +2 -20
- package/dist/built-in-serializers.js +1 -1
- package/dist/built-in-settings-schemas.d.ts +10 -0
- package/dist/built-in-settings-schemas.js +90 -4
- package/dist/built-in-value-schemas.js +35 -0
- package/dist/built-ins.js +48 -17
- package/dist/capabilities.d.ts +11 -1
- package/dist/capabilities.js +55 -3
- package/dist/cli.d.ts +66 -0
- package/dist/cli.js +22 -0
- package/dist/content-library.d.ts +85 -0
- package/dist/content-library.js +15 -0
- package/dist/content-picker/page-picker-sheet.d.ts +13 -0
- package/dist/content-picker/page-picker-sheet.js +105 -0
- package/dist/content-picker/page-tree.d.ts +25 -0
- package/dist/content-picker/page-tree.js +132 -0
- package/dist/data-type-plugin.d.ts +9 -3
- package/dist/datatype-validation.d.ts +6 -11
- package/dist/datatype-validation.js +141 -3
- package/dist/define-plugin.d.ts +4 -4
- package/dist/define-plugin.js +5 -5
- package/dist/entitlement-entry.d.ts +1 -1
- package/dist/entitlement-entry.js +1 -1
- package/dist/entitlement-gate.d.ts +14 -0
- package/dist/entitlement-gate.js +64 -7
- package/dist/entitlement-plan.d.ts +6 -0
- package/dist/entitlement-plan.js +10 -0
- package/dist/entitlement-types.d.ts +36 -12
- package/dist/entitlement.d.ts +31 -4
- package/dist/entitlement.js +58 -17
- package/dist/hook-entry.d.ts +5 -0
- package/dist/hook-entry.js +30 -0
- package/dist/host-entry.d.ts +1 -1
- package/dist/host-entry.js +1 -1
- package/dist/index.d.ts +38 -4
- package/dist/index.js +54 -3
- package/dist/mail.d.ts +30 -0
- package/dist/mail.js +1 -0
- package/dist/manifest-entry.d.ts +29 -4
- package/dist/manifest-entry.js +39 -2
- package/dist/manifest-schema.d.ts +443 -29
- package/dist/manifest-schema.js +292 -24
- package/dist/manifest.d.ts +450 -51
- package/dist/manifest.js +1 -1
- package/dist/media/media-picker.js +33 -20
- package/dist/media/upload-error.d.ts +5 -1
- package/dist/media/upload-error.js +14 -2
- package/dist/media-library.d.ts +32 -0
- package/dist/media-library.js +15 -0
- package/dist/nested-field-host.d.ts +76 -0
- package/dist/nested-field-host.js +90 -0
- package/dist/notify.d.ts +12 -4
- package/dist/notify.js +1 -1
- package/dist/outbound.d.ts +47 -0
- package/dist/outbound.js +1 -0
- package/dist/plugin-context.d.ts +5 -0
- package/dist/plugin-context.js +3 -3
- package/dist/plugin-screen-context.d.ts +112 -0
- package/dist/plugin-screen-context.js +26 -0
- package/dist/providers.d.ts +268 -0
- package/dist/providers.js +74 -0
- package/dist/read-all-pages.d.ts +5 -0
- package/dist/read-all-pages.js +3 -2
- package/dist/register-built-ins.js +6 -6
- package/dist/registry.js +1 -1
- package/dist/richtext/block-panel.js +12 -7
- package/dist/richtext/extensions.js +7 -7
- package/dist/richtext/insert-menu.js +12 -9
- package/dist/richtext/style-listbox.js +7 -5
- package/dist/richtext/text-style-class.js +1 -1
- package/dist/sdk-strings.d.ts +285 -0
- package/dist/sdk-strings.js +347 -0
- package/dist/sealing.d.ts +14 -0
- package/dist/sealing.js +1 -0
- package/dist/simple-storage-value-provider.js +27 -27
- package/dist/structured-storage-types.d.ts +309 -9
- package/dist/structured-storage-types.js +2 -2
- package/dist/text-entry.d.ts +1 -0
- package/dist/text-entry.js +6 -0
- package/dist/tokens/tailwind-theme.css +5 -0
- package/dist/tokens/tokens.css +15 -3
- package/dist/tokens/tokens.json +8 -3
- package/dist/ui-entry.js +3 -3
- package/dist/views/asset-view.js +6 -3
- package/dist/views/content-list-preview.js +3 -1
- package/dist/views/content-list-settings-view.js +11 -7
- package/dist/views/content-list-view.d.ts +5 -3
- package/dist/views/content-list-view.js +38 -34
- package/dist/views/content-picker-view.d.ts +3 -0
- package/dist/views/content-picker-view.js +143 -0
- package/dist/views/crop-view.d.ts +4 -6
- package/dist/views/crop-view.js +22 -13
- package/dist/views/date-range-view.js +9 -6
- package/dist/views/file-upload-view.d.ts +5 -7
- package/dist/views/file-upload-view.js +16 -7
- package/dist/views/group-view.d.ts +8 -0
- package/dist/views/group-view.js +123 -0
- package/dist/views/html-code-editor.js +2 -2
- package/dist/views/html-view.js +12 -11
- package/dist/views/image-view.js +40 -22
- package/dist/views/link-view.d.ts +3 -0
- package/dist/views/link-view.js +150 -0
- package/dist/views/options-list-view.d.ts +3 -0
- package/dist/views/options-list-view.js +104 -0
- package/dist/views/repeatable-list-view.d.ts +3 -0
- package/dist/views/repeatable-list-view.js +113 -0
- package/dist/views/rich-text-view.js +32 -16
- package/dist/views/suggest-key.d.ts +17 -0
- package/dist/views/suggest-key.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.d.ts +215 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.js +179 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-context.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-context.schema.js +10 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +5 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +7 -1
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +4 -2
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.d.ts +65 -0
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.js +126 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +116 -3
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +71 -18
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +57 -2
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +137 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-search.schema.d.ts +50 -0
- package/node_modules/@kardalum/api-schemas/dist/content-search.schema.js +42 -0
- package/node_modules/@kardalum/api-schemas/dist/content-summary.schema.d.ts +37 -0
- package/node_modules/@kardalum/api-schemas/dist/content-summary.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -3
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-unpublish.schema.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/content-unpublish.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +3 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.js +10 -0
- package/node_modules/@kardalum/api-schemas/dist/contract-cancel.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/contract-cancel.schema.js +86 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +10 -5
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +7 -4
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +25 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +9 -1
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/data-type-issue.d.ts +35 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-issue.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +267 -12
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +54 -8
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +24 -6
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +98 -13
- package/node_modules/@kardalum/api-schemas/dist/form-protection.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection.js +12 -0
- package/node_modules/@kardalum/api-schemas/dist/graphql-limits.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/graphql-limits.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/held-embed-words.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/held-embed-words.js +70 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +122 -43
- package/node_modules/@kardalum/api-schemas/dist/index.js +92 -27
- package/node_modules/@kardalum/api-schemas/dist/install-sign-in-switched-off.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/install-sign-in-switched-off.schema.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/legal-anchors.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/legal-anchors.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +63 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +54 -0
- package/node_modules/@kardalum/api-schemas/dist/listing-categories.schema.d.ts +46 -0
- package/node_modules/@kardalum/api-schemas/dist/listing-categories.schema.js +52 -0
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.d.ts +224 -0
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.js +404 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-leaks.schema.d.ts +145 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-leaks.schema.js +154 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +359 -8
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +85 -11
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-payouts.schema.d.ts +131 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-payouts.schema.js +272 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-profile.schema.d.ts +84 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-profile.schema.js +138 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-revocation.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-revocation.schema.js +49 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-sites.schema.d.ts +211 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-sites.schema.js +424 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.d.ts +78 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-tool-inputs.schema.d.ts +70 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-tool-inputs.schema.js +43 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +22 -10
- package/node_modules/@kardalum/api-schemas/dist/media-move.schema.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/media-move.schema.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +9 -5
- package/node_modules/@kardalum/api-schemas/dist/nested-fields.schema.d.ts +204 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-fields.schema.js +370 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.d.ts +53 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.js +284 -0
- package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +5 -5
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +1 -2
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +1 -2
- package/node_modules/@kardalum/api-schemas/dist/notification-kinds.d.ts +145 -0
- package/node_modules/@kardalum/api-schemas/dist/notification-kinds.js +177 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +258 -7
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +96 -5
- package/node_modules/@kardalum/api-schemas/dist/page-address.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/page-address.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/password-reset.schema.d.ts +34 -0
- package/node_modules/@kardalum/api-schemas/dist/password-reset.schema.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +28 -3
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +55 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-caller.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-caller.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-cli-commands.d.ts +76 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-cli-commands.js +316 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.d.ts +42 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.js +74 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-data-type-configs.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-data-type-configs.js +131 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +26 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +1 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +26 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +13 -5
- package/node_modules/@kardalum/api-schemas/dist/plugin-document-types.d.ts +228 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-document-types.js +41 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.d.ts +40 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.js +124 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-field-info.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-field-info.js +51 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-graphql-fields.d.ts +32 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-graphql-fields.js +102 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.d.ts +107 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.js +213 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-https-origin.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-https-origin.js +21 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +38 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +237 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +205 -6
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +29 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +32 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +120 -14
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +357 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +279 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +16 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +34 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-ai.d.ts +40 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-ai.js +139 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +22 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +31 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-media-access.d.ts +25 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-media-access.js +43 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.d.ts +107 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.js +150 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-package-build.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-package-build.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.d.ts +310 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.js +430 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +2 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-sealed-values.d.ts +45 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-sealed-values.js +99 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-secrets.d.ts +68 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-secrets.js +114 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-settings.d.ts +342 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-settings.js +400 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.d.ts +180 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.js +612 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +50 -7
- package/node_modules/@kardalum/api-schemas/dist/plugin-tasks.d.ts +45 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-tasks.js +197 -0
- package/node_modules/@kardalum/api-schemas/dist/plural-rules.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/plural-rules.js +41 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +100 -12
- package/node_modules/@kardalum/api-schemas/dist/refund-request.schema.d.ts +189 -0
- package/node_modules/@kardalum/api-schemas/dist/refund-request.schema.js +164 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +4 -4
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +7 -3
- package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.js +82 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-text.d.ts +66 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-text.js +497 -0
- package/node_modules/@kardalum/api-schemas/dist/sale-conditions.schema.d.ts +82 -0
- package/node_modules/@kardalum/api-schemas/dist/sale-conditions.schema.js +99 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +28 -0
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +91 -1
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.d.ts +289 -0
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +205 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +121 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +51 -10
- package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.d.ts +384 -0
- package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.js +616 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +3 -3
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/structured-duplicate-key.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-duplicate-key.js +26 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.d.ts +66 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.js +160 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/transaction-rolled-back.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/transaction-rolled-back.js +29 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-purge.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-purge.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +58 -1
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +35 -4
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +5 -1
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +4 -3
- package/node_modules/@kardalum/api-schemas/package.json +1 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +8 -2
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +5 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +3 -3
- package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +2 -2
- package/node_modules/@kardalum/design-tokens/dist/theme-css.js +2 -2
- package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +2 -2
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +3 -3
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +3 -3
- package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/themes/light.js +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +15 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +4 -4
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +17 -8
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +8 -3
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +2 -2
- package/node_modules/@kardalum/design-tokens/dist/types.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +21 -2
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +8 -2
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +17 -10
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +355 -22
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +2 -0
- package/node_modules/@kardalum/plugin-package/dist/cms-range.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/cms-range.js +353 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/ai-declarations.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/ai-declarations.js +26 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +3 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.js +34 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +2 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.js +27 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/graphql-fields.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/graphql-fields.js +22 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +47 -5
- package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.d.ts +27 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.js +95 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +9 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/plugin-settings.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/plugin-settings.js +68 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.js +298 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +27 -5
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +91 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.d.ts +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.js +140 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.js +36 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +21 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +10 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +2 -2
- package/node_modules/@kardalum/plugin-package/dist/envelope.js +2 -2
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +3 -3
- package/node_modules/@kardalum/plugin-package/dist/extract.js +9 -9
- package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/hash.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -2
- package/node_modules/@kardalum/plugin-package/dist/index.js +2 -1
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +75 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +123 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +2 -2
- package/node_modules/@kardalum/plugin-package/dist/package-contract.js +5 -5
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +8 -3
- package/node_modules/@kardalum/ui/dist/components/badge.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/button.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.js +49 -4
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +5 -1
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +18 -5
- package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +4 -4
- package/node_modules/@kardalum/ui/dist/components/input.js +6 -1
- package/node_modules/@kardalum/ui/dist/components/property-field.js +3 -3
- package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/sheet.js +12 -7
- package/node_modules/@kardalum/ui/dist/components/skeleton.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +3 -3
- package/node_modules/@kardalum/ui/dist/components/toast.js +4 -3
- package/node_modules/@kardalum/ui/dist/components/tooltip.d.ts +27 -0
- package/node_modules/@kardalum/ui/dist/components/tooltip.js +81 -0
- package/node_modules/@kardalum/ui/dist/components/truncated-text.d.ts +16 -0
- package/node_modules/@kardalum/ui/dist/components/truncated-text.js +95 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.js +2 -2
- package/node_modules/@kardalum/ui/dist/index.d.ts +3 -1
- package/node_modules/@kardalum/ui/dist/index.js +3 -1
- package/node_modules/@kardalum/ui/dist/lib/menu-host.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/lib/menu-host.js +17 -0
- package/node_modules/@kardalum/ui/package.json +8 -6
- package/package.json +18 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
// 'public' | 'private' (S186c §2)
|
|
2
|
+
// 'public' | 'private' (S186c §2): a flag, never a location. Default
|
|
3
3
|
// 'public' matches a CMS's normal case (images in posts) and existing
|
|
4
4
|
// rows' pre-S186c behavior (everything was effectively link-accessible).
|
|
5
5
|
export const MediaVisibilitySchema = z.enum(["public", "private"]);
|
|
@@ -17,10 +17,10 @@ export const MediaFileSchema = z.object({
|
|
|
17
17
|
// version forever.
|
|
18
18
|
url: z.string().min(1),
|
|
19
19
|
visibility: MediaVisibilitySchema,
|
|
20
|
-
// Virtual folder membership (S186e §1)
|
|
20
|
+
// Virtual folder membership (S186e §1): null = library root. A flag on
|
|
21
21
|
// the row only, same spirit as visibility: it never changes `url`
|
|
22
22
|
// above or anything in storage (folders are explicitly excluded from
|
|
23
|
-
// media URLs, spec §4
|
|
23
|
+
// media URLs, spec §4, the permanence guardrail). Moving a file is a
|
|
24
24
|
// metadata write, nothing else.
|
|
25
25
|
folderId: z.string().uuid().nullable(),
|
|
26
26
|
uploadedBy: z.string().uuid(),
|
|
@@ -70,6 +70,10 @@ export const MediaFileSchema = z.object({
|
|
|
70
70
|
// trashed one (the bin's listing, and the item screen's read of a file
|
|
71
71
|
// that was trashed while it was open).
|
|
72
72
|
deletedAt: z.string().datetime().nullable().default(null),
|
|
73
|
+
// M32 F4e (E1): whether the store this item's bytes live in gives a public address now. Set on
|
|
74
|
+
// the management item (the admin warns that making such an item private cannot withdraw the
|
|
75
|
+
// copy the store serves); absent everywhere else. Never the address itself.
|
|
76
|
+
storeAddress: z.boolean().optional(),
|
|
73
77
|
});
|
|
74
78
|
// S234b: one set of bytes. A media item has one of these per version, and
|
|
75
79
|
// `MediaFile.currentVersion` says which one it serves.
|
|
@@ -140,11 +144,11 @@ export const IMAGE_MEDIA_TYPE_ID = "d1e00000-0000-4000-8000-000000000001";
|
|
|
140
144
|
export const FILE_MEDIA_TYPE_ID = "d1e00000-0000-4000-8000-000000000002";
|
|
141
145
|
export const IMAGE_FILE_DATA_TYPE_ID = "b1e00000-0000-4000-8000-000000000008";
|
|
142
146
|
export const ANY_FILE_DATA_TYPE_ID = "b1e00000-0000-4000-8000-000000000009";
|
|
143
|
-
// Virtual media folders (S186e §1)
|
|
147
|
+
// Virtual media folders (S186e §1): organization lives in the database
|
|
144
148
|
// only; folders are deliberately never part of `/media/<id>/v<version>/<filename>`
|
|
145
149
|
// URLs (spec §4). A tree via parentId: null = a top-level folder. Depth
|
|
146
150
|
// (capped at 5) and per-parent name uniqueness are service-layer
|
|
147
|
-
// concerns, not schema-level ones
|
|
151
|
+
// concerns, not schema-level ones; see the MediaFolder Prisma model's
|
|
148
152
|
// comment (apps/server/prisma/schema.prisma) for why a DB/schema
|
|
149
153
|
// constraint can't actually deliver per-parent uniqueness across dialects
|
|
150
154
|
// at the root level.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type DataTypeConfig } from "./data-type-config.schema.js";
|
|
3
|
+
export declare const GROUP_EDITOR_ID = "com.kardalum.group";
|
|
4
|
+
export declare const REPEATABLE_LIST_EDITOR_ID = "com.kardalum.list";
|
|
5
|
+
export declare const GROUP_FIELDS_MAX = 20;
|
|
6
|
+
export declare const LIST_ITEMS_MAX = 100;
|
|
7
|
+
export declare const NESTING_DEPTH_MAX = 2;
|
|
8
|
+
export declare const NESTED_PICKED_PAGES_MAX = 200;
|
|
9
|
+
export declare const NESTED_ISSUES_MAX = 50;
|
|
10
|
+
export declare const SUB_FIELD_ALIAS_MAX = 64;
|
|
11
|
+
export declare const SUB_FIELD_NAME_MAX = 200;
|
|
12
|
+
export declare const NESTABLE_EDITOR_IDS: ReadonlySet<string>;
|
|
13
|
+
/** M32 I2 (A4): a list of Groups holding rich text would be a list of up to 100 editors, so a save
|
|
14
|
+
* is refused both ways (a list naming such a Group, a Group a list repeats gaining rich text), and
|
|
15
|
+
* the tree reads rich text below a list as unreadable. */
|
|
16
|
+
export declare const RICH_TEXT_IN_LIST_MESSAGE = "Rich text can sit in a group, but not in a group that a repeatable list repeats.";
|
|
17
|
+
/** M32 I5 (D9): every reason a Group or list save is refused for its nesting, as a code the admin
|
|
18
|
+
* words in its own language. The server's English sentence stays the 400's `message`. */
|
|
19
|
+
export declare const NESTING_PROBLEM_CODES: readonly ["sub_field_gone", "sub_field_not_nestable", "sub_field_plugin_not_nestable", "sub_field_switched_off", "item_gone", "item_not_nestable", "item_plugin_not_nestable", "item_switched_off", "rich_text_in_list", "holds_itself", "too_deep", "too_deep_through", "scan_incomplete"];
|
|
20
|
+
export type NestingProblemCode = (typeof NESTING_PROBLEM_CODES)[number];
|
|
21
|
+
/** M32 I5 (D9): one reason a Group or list cannot be saved, for the admin to word. The values are
|
|
22
|
+
* plain data (names as stored), shown as text. */
|
|
23
|
+
export declare const NestingProblemSchema: z.ZodObject<{
|
|
24
|
+
code: z.ZodEnum<{
|
|
25
|
+
sub_field_gone: "sub_field_gone";
|
|
26
|
+
sub_field_not_nestable: "sub_field_not_nestable";
|
|
27
|
+
sub_field_plugin_not_nestable: "sub_field_plugin_not_nestable";
|
|
28
|
+
sub_field_switched_off: "sub_field_switched_off";
|
|
29
|
+
item_gone: "item_gone";
|
|
30
|
+
item_not_nestable: "item_not_nestable";
|
|
31
|
+
item_plugin_not_nestable: "item_plugin_not_nestable";
|
|
32
|
+
item_switched_off: "item_switched_off";
|
|
33
|
+
rich_text_in_list: "rich_text_in_list";
|
|
34
|
+
holds_itself: "holds_itself";
|
|
35
|
+
too_deep: "too_deep";
|
|
36
|
+
too_deep_through: "too_deep_through";
|
|
37
|
+
scan_incomplete: "scan_incomplete";
|
|
38
|
+
}>;
|
|
39
|
+
field: z.ZodOptional<z.ZodString>;
|
|
40
|
+
type: z.ZodOptional<z.ZodString>;
|
|
41
|
+
plugin: z.ZodOptional<z.ZodString>;
|
|
42
|
+
through: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type NestingProblem = z.infer<typeof NestingProblemSchema>;
|
|
45
|
+
/** M32 I5 (D9): the reasons a Group or list's own settings are refused (GroupSettingsSchema,
|
|
46
|
+
* RepeatableListSettingsSchema), as codes the admin words. Not nesting refusals, so a sibling list. */
|
|
47
|
+
export declare const DATA_TYPE_SETTINGS_PROBLEM_CODES: readonly ["alias_invalid", "name_required", "alias_duplicate", "min_above_max", "limit_out_of_range", "sub_field_type_required"];
|
|
48
|
+
export type DataTypeSettingsProblemCode = (typeof DATA_TYPE_SETTINGS_PROBLEM_CODES)[number];
|
|
49
|
+
/** M32 I5 (D9): one reason a data type save is refused, a nesting code or a settings code. */
|
|
50
|
+
export declare const DataTypeSettingsProblemSchema: z.ZodObject<{
|
|
51
|
+
field: z.ZodOptional<z.ZodString>;
|
|
52
|
+
type: z.ZodOptional<z.ZodString>;
|
|
53
|
+
plugin: z.ZodOptional<z.ZodString>;
|
|
54
|
+
through: z.ZodOptional<z.ZodString>;
|
|
55
|
+
code: z.ZodEnum<{
|
|
56
|
+
sub_field_gone: "sub_field_gone";
|
|
57
|
+
sub_field_not_nestable: "sub_field_not_nestable";
|
|
58
|
+
sub_field_plugin_not_nestable: "sub_field_plugin_not_nestable";
|
|
59
|
+
sub_field_switched_off: "sub_field_switched_off";
|
|
60
|
+
item_gone: "item_gone";
|
|
61
|
+
item_not_nestable: "item_not_nestable";
|
|
62
|
+
item_plugin_not_nestable: "item_plugin_not_nestable";
|
|
63
|
+
item_switched_off: "item_switched_off";
|
|
64
|
+
rich_text_in_list: "rich_text_in_list";
|
|
65
|
+
holds_itself: "holds_itself";
|
|
66
|
+
too_deep: "too_deep";
|
|
67
|
+
too_deep_through: "too_deep_through";
|
|
68
|
+
scan_incomplete: "scan_incomplete";
|
|
69
|
+
alias_invalid: "alias_invalid";
|
|
70
|
+
name_required: "name_required";
|
|
71
|
+
alias_duplicate: "alias_duplicate";
|
|
72
|
+
min_above_max: "min_above_max";
|
|
73
|
+
limit_out_of_range: "limit_out_of_range";
|
|
74
|
+
sub_field_type_required: "sub_field_type_required";
|
|
75
|
+
}>;
|
|
76
|
+
alias: z.ZodOptional<z.ZodString>;
|
|
77
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
export type DataTypeSettingsProblem = z.infer<typeof DataTypeSettingsProblemSchema>;
|
|
80
|
+
/** M32 I5 (D9): the data type POST and PATCH 400: the English message, and the problems when the
|
|
81
|
+
* nesting checks or a Group or list's settings refused it (absent for every other 400, and for a
|
|
82
|
+
* settings refusal with a part no code names). */
|
|
83
|
+
export declare const DataTypeSettingsErrorSchema: z.ZodObject<{
|
|
84
|
+
message: z.ZodString;
|
|
85
|
+
problems: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
86
|
+
field: z.ZodOptional<z.ZodString>;
|
|
87
|
+
type: z.ZodOptional<z.ZodString>;
|
|
88
|
+
plugin: z.ZodOptional<z.ZodString>;
|
|
89
|
+
through: z.ZodOptional<z.ZodString>;
|
|
90
|
+
code: z.ZodEnum<{
|
|
91
|
+
sub_field_gone: "sub_field_gone";
|
|
92
|
+
sub_field_not_nestable: "sub_field_not_nestable";
|
|
93
|
+
sub_field_plugin_not_nestable: "sub_field_plugin_not_nestable";
|
|
94
|
+
sub_field_switched_off: "sub_field_switched_off";
|
|
95
|
+
item_gone: "item_gone";
|
|
96
|
+
item_not_nestable: "item_not_nestable";
|
|
97
|
+
item_plugin_not_nestable: "item_plugin_not_nestable";
|
|
98
|
+
item_switched_off: "item_switched_off";
|
|
99
|
+
rich_text_in_list: "rich_text_in_list";
|
|
100
|
+
holds_itself: "holds_itself";
|
|
101
|
+
too_deep: "too_deep";
|
|
102
|
+
too_deep_through: "too_deep_through";
|
|
103
|
+
scan_incomplete: "scan_incomplete";
|
|
104
|
+
alias_invalid: "alias_invalid";
|
|
105
|
+
name_required: "name_required";
|
|
106
|
+
alias_duplicate: "alias_duplicate";
|
|
107
|
+
min_above_max: "min_above_max";
|
|
108
|
+
limit_out_of_range: "limit_out_of_range";
|
|
109
|
+
sub_field_type_required: "sub_field_type_required";
|
|
110
|
+
}>;
|
|
111
|
+
alias: z.ZodOptional<z.ZodString>;
|
|
112
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
113
|
+
}, z.core.$strip>>>;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
export type DataTypeSettingsError = z.infer<typeof DataTypeSettingsErrorSchema>;
|
|
116
|
+
export declare function isCompositeEditor(editorId: string): boolean;
|
|
117
|
+
export declare const GroupSubFieldSchema: z.ZodObject<{
|
|
118
|
+
alias: z.ZodString;
|
|
119
|
+
name: z.ZodString;
|
|
120
|
+
dataTypeId: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
121
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
122
|
+
}, z.core.$strict>;
|
|
123
|
+
export type GroupSubField = z.output<typeof GroupSubFieldSchema>;
|
|
124
|
+
export declare const GroupSettingsSchema: z.ZodObject<{
|
|
125
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
126
|
+
alias: z.ZodString;
|
|
127
|
+
name: z.ZodString;
|
|
128
|
+
dataTypeId: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
129
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
130
|
+
}, z.core.$strict>>>;
|
|
131
|
+
}, z.core.$strict>;
|
|
132
|
+
export type GroupSettings = z.output<typeof GroupSettingsSchema>;
|
|
133
|
+
export declare const RepeatableListSettingsSchema: z.ZodObject<{
|
|
134
|
+
itemDataTypeId: z.ZodDefault<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
135
|
+
min: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
136
|
+
max: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
137
|
+
}, z.core.$strict>;
|
|
138
|
+
export type RepeatableListSettings = z.output<typeof RepeatableListSettingsSchema>;
|
|
139
|
+
export declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
|
|
140
|
+
export declare function readGroupSettings(raw: unknown): GroupSettings;
|
|
141
|
+
export declare function readRepeatableListSettings(raw: unknown): RepeatableListSettings;
|
|
142
|
+
export interface DataTypeTreeSubField {
|
|
143
|
+
alias: string;
|
|
144
|
+
name: string;
|
|
145
|
+
required: boolean;
|
|
146
|
+
/** null: the sub-type is missing, not nestable, or too deep. Its value is ignored. */
|
|
147
|
+
type: DataTypeTree | null;
|
|
148
|
+
/** M32 I5 (D12): `type` is null because no data type answers the id (deleted, or removed with
|
|
149
|
+
* its plugin). A sub-type that only cannot nest (its plugin switched off) is not missing. */
|
|
150
|
+
missing?: true;
|
|
151
|
+
}
|
|
152
|
+
export interface DataTypeTree {
|
|
153
|
+
dataTypeId: string;
|
|
154
|
+
editorId: string;
|
|
155
|
+
/** As stored; a consumer applies its editor's defaults to `{}` as at the top level. */
|
|
156
|
+
settings: Record<string, unknown>;
|
|
157
|
+
/** M32 I5 (D12): a top-level id no data type answers, read as an editor id as before. */
|
|
158
|
+
missing?: true;
|
|
159
|
+
group?: {
|
|
160
|
+
fields: DataTypeTreeSubField[];
|
|
161
|
+
};
|
|
162
|
+
/** `itemMissing` (M32 I5, D12): the list names no item type, or no data type answers it. */
|
|
163
|
+
list?: {
|
|
164
|
+
item: DataTypeTree | null;
|
|
165
|
+
min: number | null;
|
|
166
|
+
max: number;
|
|
167
|
+
itemMissing?: true;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
type ConfigLookup = (id: string) => DataTypeConfig | null | undefined;
|
|
171
|
+
/** M32 F4d (D15): which editors may sit inside a Group or list. The server adds the attached plugin
|
|
172
|
+
* data types declaring `nestable: true`; without it, the core set. An answer that throws is "no". */
|
|
173
|
+
export interface DataTypeTreeOptions {
|
|
174
|
+
isNestable?: (editorId: string) => boolean;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* A field's data type with its sub-types resolved. A top-level id with no config is a legacy
|
|
178
|
+
* field naming its editor directly (as every resolver treats it); a missing nested one is null.
|
|
179
|
+
*/
|
|
180
|
+
export declare function buildDataTypeTree(dataTypeId: string, lookup: ConfigLookup, options?: DataTypeTreeOptions): DataTypeTree | null;
|
|
181
|
+
/** Reads each distinct config once (sub-types level by level), then builds every tree. */
|
|
182
|
+
export declare function loadDataTypeTrees(ids: readonly string[], getConfig: (id: string) => Promise<DataTypeConfig | null>, cache?: Map<string, Promise<DataTypeConfig | null>>, options?: DataTypeTreeOptions): Promise<Map<string, DataTypeTree | null>>;
|
|
183
|
+
/** D5: 0 for a plain type, 1 + the deepest sub-type for a composite; "cycle" when it holds itself. */
|
|
184
|
+
export declare function compositeDepth(dataTypeId: string, lookup: ConfigLookup): number | "cycle";
|
|
185
|
+
/**
|
|
186
|
+
* D7: keeps only the current aliases of every group inside the value; any other shape is kept as is.
|
|
187
|
+
* M32 E (m11): `capLists` cuts each list at its maximum (at most LIST_ITEMS_MAX) for a read; a write
|
|
188
|
+
* leaves it whole so validation can still answer that the list has too many items.
|
|
189
|
+
*/
|
|
190
|
+
export declare function pruneNestedValue(tree: DataTypeTree | null, value: unknown, options?: {
|
|
191
|
+
capLists?: boolean;
|
|
192
|
+
}): unknown;
|
|
193
|
+
/** D10, D18: the item numbers and sub-field names a failure path names; the sub-type's own path is not spelled out. */
|
|
194
|
+
export declare function nestedPathParts(tree: DataTypeTree | null, path: string): Array<{
|
|
195
|
+
kind: "item";
|
|
196
|
+
n: number;
|
|
197
|
+
} | {
|
|
198
|
+
kind: "field";
|
|
199
|
+
alias: string;
|
|
200
|
+
name: string;
|
|
201
|
+
}>;
|
|
202
|
+
/** D9: the JSON Schema of a nested value, built from the tree; a leaf asks `leafSchema`. */
|
|
203
|
+
export declare function nestedValueSchema(tree: DataTypeTree, leafSchema: (editorId: string) => Record<string, unknown> | null): Record<string, unknown> | null;
|
|
204
|
+
export {};
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ApiErrorSchema } from "./api-error.schema.js";
|
|
3
|
+
import { ASSET_EDITOR_ID } from "./asset-field.schema.js";
|
|
4
|
+
import { RICHTEXT_EDITOR_ID } from "./data-type-config.schema.js";
|
|
5
|
+
import { CONTENT_PICKER_EDITOR_ID, LINK_EDITOR_ID, OPTIONS_EDITOR_ID } from "./structured-fields.schema.js";
|
|
6
|
+
import { UuidStringSchema } from "./uuid.schema.js";
|
|
7
|
+
// M32 D (D1 to D9): two data types that hold other data types. A Group's value is an object keyed
|
|
8
|
+
// by its sub-fields' aliases; a Repeatable list's value is an array of one item type. A field's
|
|
9
|
+
// "tree" is its data type with the sub-types resolved, at most NESTING_DEPTH_MAX composite levels
|
|
10
|
+
// deep. Every function here is total: it reads a stored value or settings bag that may predate a
|
|
11
|
+
// change of settings and never throws.
|
|
12
|
+
export const GROUP_EDITOR_ID = "com.kardalum.group";
|
|
13
|
+
export const REPEATABLE_LIST_EDITOR_ID = "com.kardalum.list";
|
|
14
|
+
export const GROUP_FIELDS_MAX = 20;
|
|
15
|
+
export const LIST_ITEMS_MAX = 100;
|
|
16
|
+
export const NESTING_DEPTH_MAX = 2;
|
|
17
|
+
export const NESTED_PICKED_PAGES_MAX = 200;
|
|
18
|
+
export const NESTED_ISSUES_MAX = 50;
|
|
19
|
+
export const SUB_FIELD_ALIAS_MAX = 64;
|
|
20
|
+
export const SUB_FIELD_NAME_MAX = 200;
|
|
21
|
+
// D3: what may sit inside a Group or list. The valueless editors do not nest; a plugin editor nests
|
|
22
|
+
// only when it declares `nestable: true` (M32 F4d, D15, `DataTypeTreeOptions`). Rich text nests in a
|
|
23
|
+
// Group, never below a Repeatable list (M32 I2, A4; RICH_TEXT_IN_LIST_MESSAGE).
|
|
24
|
+
export const NESTABLE_EDITOR_IDS = new Set([
|
|
25
|
+
"com.kardalum.text",
|
|
26
|
+
RICHTEXT_EDITOR_ID,
|
|
27
|
+
"com.kardalum.number",
|
|
28
|
+
"com.kardalum.boolean",
|
|
29
|
+
"com.kardalum.date",
|
|
30
|
+
"com.kardalum.image",
|
|
31
|
+
"com.kardalum.html",
|
|
32
|
+
"com.kardalum.daterange",
|
|
33
|
+
ASSET_EDITOR_ID,
|
|
34
|
+
CONTENT_PICKER_EDITOR_ID,
|
|
35
|
+
OPTIONS_EDITOR_ID,
|
|
36
|
+
LINK_EDITOR_ID,
|
|
37
|
+
GROUP_EDITOR_ID,
|
|
38
|
+
REPEATABLE_LIST_EDITOR_ID,
|
|
39
|
+
]);
|
|
40
|
+
/** M32 I2 (A4): a list of Groups holding rich text would be a list of up to 100 editors, so a save
|
|
41
|
+
* is refused both ways (a list naming such a Group, a Group a list repeats gaining rich text), and
|
|
42
|
+
* the tree reads rich text below a list as unreadable. */
|
|
43
|
+
export const RICH_TEXT_IN_LIST_MESSAGE = "Rich text can sit in a group, but not in a group that a repeatable list repeats.";
|
|
44
|
+
/** M32 I5 (D9): every reason a Group or list save is refused for its nesting, as a code the admin
|
|
45
|
+
* words in its own language. The server's English sentence stays the 400's `message`. */
|
|
46
|
+
export const NESTING_PROBLEM_CODES = [
|
|
47
|
+
"sub_field_gone",
|
|
48
|
+
"sub_field_not_nestable",
|
|
49
|
+
"sub_field_plugin_not_nestable",
|
|
50
|
+
"sub_field_switched_off",
|
|
51
|
+
"item_gone",
|
|
52
|
+
"item_not_nestable",
|
|
53
|
+
"item_plugin_not_nestable",
|
|
54
|
+
"item_switched_off",
|
|
55
|
+
"rich_text_in_list",
|
|
56
|
+
"holds_itself",
|
|
57
|
+
"too_deep",
|
|
58
|
+
"too_deep_through",
|
|
59
|
+
"scan_incomplete",
|
|
60
|
+
];
|
|
61
|
+
/** M32 I5 (D9): one reason a Group or list cannot be saved, for the admin to word. The values are
|
|
62
|
+
* plain data (names as stored), shown as text. */
|
|
63
|
+
export const NestingProblemSchema = z.object({
|
|
64
|
+
code: z.enum(NESTING_PROBLEM_CODES),
|
|
65
|
+
/** The sub-field's name (sub-field codes). */
|
|
66
|
+
field: z.string().optional(),
|
|
67
|
+
/** The data type's name (the not-nestable codes). */
|
|
68
|
+
type: z.string().optional(),
|
|
69
|
+
/** The switched-off plugin's name (the switched-off codes). */
|
|
70
|
+
plugin: z.string().optional(),
|
|
71
|
+
/** The outermost holder's name (too_deep_through). */
|
|
72
|
+
through: z.string().optional(),
|
|
73
|
+
});
|
|
74
|
+
/** M32 I5 (D9): the reasons a Group or list's own settings are refused (GroupSettingsSchema,
|
|
75
|
+
* RepeatableListSettingsSchema), as codes the admin words. Not nesting refusals, so a sibling list. */
|
|
76
|
+
export const DATA_TYPE_SETTINGS_PROBLEM_CODES = [
|
|
77
|
+
"alias_invalid",
|
|
78
|
+
"name_required",
|
|
79
|
+
"alias_duplicate",
|
|
80
|
+
"min_above_max",
|
|
81
|
+
"limit_out_of_range",
|
|
82
|
+
/** A sub-field with no data type chosen (an empty or missing `dataTypeId`). */
|
|
83
|
+
"sub_field_type_required",
|
|
84
|
+
];
|
|
85
|
+
/** M32 I5 (D9): one reason a data type save is refused, a nesting code or a settings code. */
|
|
86
|
+
export const DataTypeSettingsProblemSchema = NestingProblemSchema.extend({
|
|
87
|
+
code: z.enum([...NESTING_PROBLEM_CODES, ...DATA_TYPE_SETTINGS_PROBLEM_CODES]),
|
|
88
|
+
/** The shared alias (alias_duplicate). */
|
|
89
|
+
alias: z.string().optional(),
|
|
90
|
+
/** The highest value a limit may take (limit_out_of_range). */
|
|
91
|
+
count: z.number().int().optional(),
|
|
92
|
+
});
|
|
93
|
+
/** M32 I5 (D9): the data type POST and PATCH 400: the English message, and the problems when the
|
|
94
|
+
* nesting checks or a Group or list's settings refused it (absent for every other 400, and for a
|
|
95
|
+
* settings refusal with a part no code names). */
|
|
96
|
+
export const DataTypeSettingsErrorSchema = ApiErrorSchema.extend({ problems: z.array(DataTypeSettingsProblemSchema).optional() });
|
|
97
|
+
export function isCompositeEditor(editorId) {
|
|
98
|
+
return editorId === GROUP_EDITOR_ID || editorId === REPEATABLE_LIST_EDITOR_ID;
|
|
99
|
+
}
|
|
100
|
+
const lowerUuid = UuidStringSchema.transform((value) => value.toLowerCase());
|
|
101
|
+
/** M32 I5 fix wave: a sub-field left on "Choose a data type" reads this, not "Invalid UUID". */
|
|
102
|
+
const SUB_FIELD_TYPE_REQUIRED = "Every sub-field needs a data type.";
|
|
103
|
+
const subFieldTypeId = z
|
|
104
|
+
.string({ error: SUB_FIELD_TYPE_REQUIRED })
|
|
105
|
+
.uuid({ error: SUB_FIELD_TYPE_REQUIRED })
|
|
106
|
+
.transform((value) => value.toLowerCase());
|
|
107
|
+
// Anchored and linear; only ever reads a developer's alias of at most 64 characters.
|
|
108
|
+
const ALIAS = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
109
|
+
export const GroupSubFieldSchema = z
|
|
110
|
+
.object({
|
|
111
|
+
alias: z
|
|
112
|
+
.string()
|
|
113
|
+
.max(SUB_FIELD_ALIAS_MAX)
|
|
114
|
+
.regex(ALIAS, { message: "An alias starts with a letter and holds only letters, digits and _." }),
|
|
115
|
+
name: z.string().trim().min(1, { message: "Every sub-field needs a name." }).max(SUB_FIELD_NAME_MAX),
|
|
116
|
+
dataTypeId: subFieldTypeId,
|
|
117
|
+
required: z.boolean().default(false),
|
|
118
|
+
})
|
|
119
|
+
.strict();
|
|
120
|
+
export const GroupSettingsSchema = z
|
|
121
|
+
.object({
|
|
122
|
+
fields: z
|
|
123
|
+
.array(GroupSubFieldSchema)
|
|
124
|
+
.max(GROUP_FIELDS_MAX)
|
|
125
|
+
.default([])
|
|
126
|
+
.refine((fields) => new Set(fields.map((field) => field.alias)).size === fields.length, {
|
|
127
|
+
message: "Two sub-fields share an alias.",
|
|
128
|
+
}),
|
|
129
|
+
})
|
|
130
|
+
.strict();
|
|
131
|
+
export const RepeatableListSettingsSchema = z
|
|
132
|
+
.object({
|
|
133
|
+
itemDataTypeId: lowerUuid.nullable().default(null),
|
|
134
|
+
min: z.number().int().min(0).max(LIST_ITEMS_MAX).nullable().default(null),
|
|
135
|
+
max: z.number().int().min(1).max(LIST_ITEMS_MAX).nullable().default(null),
|
|
136
|
+
})
|
|
137
|
+
.strict()
|
|
138
|
+
.refine((settings) => settings.min === null || settings.max === null || settings.min <= settings.max, {
|
|
139
|
+
message: "The minimum is more than the maximum.",
|
|
140
|
+
});
|
|
141
|
+
export function isPlainRecord(value) {
|
|
142
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
143
|
+
}
|
|
144
|
+
export function readGroupSettings(raw) {
|
|
145
|
+
const bag = isPlainRecord(raw) ? raw : {};
|
|
146
|
+
const list = Array.isArray(bag.fields) ? bag.fields.slice(0, GROUP_FIELDS_MAX) : [];
|
|
147
|
+
const seen = new Set();
|
|
148
|
+
const fields = [];
|
|
149
|
+
for (const entry of list) {
|
|
150
|
+
const parsed = GroupSubFieldSchema.safeParse(entry);
|
|
151
|
+
if (!parsed.success || seen.has(parsed.data.alias))
|
|
152
|
+
continue;
|
|
153
|
+
seen.add(parsed.data.alias);
|
|
154
|
+
fields.push(parsed.data);
|
|
155
|
+
}
|
|
156
|
+
return { fields };
|
|
157
|
+
}
|
|
158
|
+
export function readRepeatableListSettings(raw) {
|
|
159
|
+
const parsed = RepeatableListSettingsSchema.safeParse(isPlainRecord(raw) ? raw : {});
|
|
160
|
+
if (parsed.success)
|
|
161
|
+
return parsed.data;
|
|
162
|
+
const bag = isPlainRecord(raw) ? raw : {};
|
|
163
|
+
const item = UuidStringSchema.safeParse(bag.itemDataTypeId);
|
|
164
|
+
return { itemDataTypeId: item.success ? item.data.toLowerCase() : null, min: null, max: null };
|
|
165
|
+
}
|
|
166
|
+
function nestableCheck(options) {
|
|
167
|
+
const given = options?.isNestable;
|
|
168
|
+
if (!given)
|
|
169
|
+
return (editorId) => NESTABLE_EDITOR_IDS.has(editorId);
|
|
170
|
+
return (editorId) => {
|
|
171
|
+
try {
|
|
172
|
+
return given(editorId) === true;
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function subTypeIds(config) {
|
|
180
|
+
if (config.editorId === GROUP_EDITOR_ID)
|
|
181
|
+
return readGroupSettings(config.settings).fields.map((field) => field.dataTypeId);
|
|
182
|
+
if (config.editorId === REPEATABLE_LIST_EDITOR_ID) {
|
|
183
|
+
const item = readRepeatableListSettings(config.settings).itemDataTypeId;
|
|
184
|
+
return item ? [item] : [];
|
|
185
|
+
}
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
function build(id, lookup, level, stack, nested, isNestable, underList = false) {
|
|
189
|
+
const config = lookup(id);
|
|
190
|
+
if (!config)
|
|
191
|
+
return nested ? null : { dataTypeId: id, editorId: id, settings: {}, missing: true };
|
|
192
|
+
if (nested && !isNestable(config.editorId))
|
|
193
|
+
return null;
|
|
194
|
+
// M32 I2 (A4): rich text below a list is never saved; a stale settings bag reads as unreadable.
|
|
195
|
+
if (underList && config.editorId === RICHTEXT_EDITOR_ID)
|
|
196
|
+
return null;
|
|
197
|
+
const base = { dataTypeId: config.id, editorId: config.editorId, settings: config.settings ?? {} };
|
|
198
|
+
if (!isCompositeEditor(config.editorId))
|
|
199
|
+
return base;
|
|
200
|
+
// A composite at this level would hold a third level, or holds itself: unreadable.
|
|
201
|
+
if (level >= NESTING_DEPTH_MAX || stack.has(config.id))
|
|
202
|
+
return null;
|
|
203
|
+
const inner = new Set(stack).add(config.id);
|
|
204
|
+
if (config.editorId === GROUP_EDITOR_ID) {
|
|
205
|
+
const fields = readGroupSettings(config.settings).fields.map((field) => ({
|
|
206
|
+
alias: field.alias,
|
|
207
|
+
name: field.name,
|
|
208
|
+
required: field.required,
|
|
209
|
+
type: build(field.dataTypeId, lookup, level + 1, inner, true, isNestable, underList),
|
|
210
|
+
...(lookup(field.dataTypeId) ? {} : { missing: true }),
|
|
211
|
+
}));
|
|
212
|
+
return { ...base, group: { fields } };
|
|
213
|
+
}
|
|
214
|
+
const settings = readRepeatableListSettings(config.settings);
|
|
215
|
+
const itemMissing = !settings.itemDataTypeId || !lookup(settings.itemDataTypeId);
|
|
216
|
+
return {
|
|
217
|
+
...base,
|
|
218
|
+
list: {
|
|
219
|
+
item: settings.itemDataTypeId ? build(settings.itemDataTypeId, lookup, level + 1, inner, true, isNestable, true) : null,
|
|
220
|
+
min: settings.min,
|
|
221
|
+
max: Math.min(settings.max ?? LIST_ITEMS_MAX, LIST_ITEMS_MAX),
|
|
222
|
+
...(itemMissing ? { itemMissing: true } : {}),
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* A field's data type with its sub-types resolved. A top-level id with no config is a legacy
|
|
228
|
+
* field naming its editor directly (as every resolver treats it); a missing nested one is null.
|
|
229
|
+
*/
|
|
230
|
+
export function buildDataTypeTree(dataTypeId, lookup, options) {
|
|
231
|
+
return build(dataTypeId, lookup, 0, new Set(), false, nestableCheck(options));
|
|
232
|
+
}
|
|
233
|
+
/** Reads each distinct config once (sub-types level by level), then builds every tree. */
|
|
234
|
+
export async function loadDataTypeTrees(ids, getConfig, cache = new Map(), options) {
|
|
235
|
+
const loaded = new Map();
|
|
236
|
+
let frontier = [...new Set(ids)];
|
|
237
|
+
for (let level = 0; level <= NESTING_DEPTH_MAX && frontier.length > 0; level++) {
|
|
238
|
+
const read = await Promise.all(frontier.map(async (key) => {
|
|
239
|
+
let pending = cache.get(key);
|
|
240
|
+
if (!pending) {
|
|
241
|
+
pending = getConfig(key);
|
|
242
|
+
cache.set(key, pending);
|
|
243
|
+
// A failed read is not kept, so the next caller sharing the cache asks again.
|
|
244
|
+
pending.catch(() => {
|
|
245
|
+
if (cache.get(key) === pending)
|
|
246
|
+
cache.delete(key);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return [key, await pending];
|
|
250
|
+
}));
|
|
251
|
+
const next = new Set();
|
|
252
|
+
for (const [key, config] of read) {
|
|
253
|
+
loaded.set(key, config);
|
|
254
|
+
if (config)
|
|
255
|
+
for (const sub of subTypeIds(config))
|
|
256
|
+
if (!loaded.has(sub))
|
|
257
|
+
next.add(sub);
|
|
258
|
+
}
|
|
259
|
+
frontier = [...next].filter((key) => !loaded.has(key));
|
|
260
|
+
}
|
|
261
|
+
const trees = new Map();
|
|
262
|
+
for (const key of new Set(ids))
|
|
263
|
+
trees.set(key, buildDataTypeTree(key, (sub) => loaded.get(sub), options));
|
|
264
|
+
return trees;
|
|
265
|
+
}
|
|
266
|
+
/** D5: 0 for a plain type, 1 + the deepest sub-type for a composite; "cycle" when it holds itself. */
|
|
267
|
+
export function compositeDepth(dataTypeId, lookup) {
|
|
268
|
+
const walk = (key, stack) => {
|
|
269
|
+
const config = lookup(key);
|
|
270
|
+
if (!config || !isCompositeEditor(config.editorId))
|
|
271
|
+
return 0;
|
|
272
|
+
if (stack.has(key))
|
|
273
|
+
return "cycle";
|
|
274
|
+
const inner = new Set(stack).add(key);
|
|
275
|
+
let deepest = 0;
|
|
276
|
+
for (const sub of subTypeIds(config)) {
|
|
277
|
+
const depth = walk(sub, inner);
|
|
278
|
+
if (depth === "cycle")
|
|
279
|
+
return "cycle";
|
|
280
|
+
// Past the nesting limit the answer is "too deep" whatever else is below.
|
|
281
|
+
if (depth + 1 > NESTING_DEPTH_MAX)
|
|
282
|
+
return NESTING_DEPTH_MAX + 1;
|
|
283
|
+
deepest = Math.max(deepest, depth);
|
|
284
|
+
}
|
|
285
|
+
return deepest + 1;
|
|
286
|
+
};
|
|
287
|
+
return walk(dataTypeId, new Set());
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* D7: keeps only the current aliases of every group inside the value; any other shape is kept as is.
|
|
291
|
+
* M32 E (m11): `capLists` cuts each list at its maximum (at most LIST_ITEMS_MAX) for a read; a write
|
|
292
|
+
* leaves it whole so validation can still answer that the list has too many items.
|
|
293
|
+
*/
|
|
294
|
+
export function pruneNestedValue(tree, value, options = {}) {
|
|
295
|
+
if (!tree)
|
|
296
|
+
return value;
|
|
297
|
+
if (tree.group) {
|
|
298
|
+
if (!isPlainRecord(value))
|
|
299
|
+
return value;
|
|
300
|
+
const out = {};
|
|
301
|
+
for (const field of tree.group.fields) {
|
|
302
|
+
if (Object.prototype.hasOwnProperty.call(value, field.alias))
|
|
303
|
+
out[field.alias] = pruneNestedValue(field.type, value[field.alias], options);
|
|
304
|
+
}
|
|
305
|
+
return out;
|
|
306
|
+
}
|
|
307
|
+
if (tree.list) {
|
|
308
|
+
if (!Array.isArray(value))
|
|
309
|
+
return value;
|
|
310
|
+
const items = options.capLists === true ? value.slice(0, tree.list.max) : value;
|
|
311
|
+
return items.map((item) => pruneNestedValue(tree.list.item, item, options));
|
|
312
|
+
}
|
|
313
|
+
return value;
|
|
314
|
+
}
|
|
315
|
+
function isDecimalDigits(text) {
|
|
316
|
+
if (text.length === 0 || text.length > 9)
|
|
317
|
+
return false;
|
|
318
|
+
for (let i = 0; i < text.length; i++) {
|
|
319
|
+
const code = text.charCodeAt(i);
|
|
320
|
+
if (code < 48 || code > 57)
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
/** D10, D18: the item numbers and sub-field names a failure path names; the sub-type's own path is not spelled out. */
|
|
326
|
+
export function nestedPathParts(tree, path) {
|
|
327
|
+
const parts = [];
|
|
328
|
+
let at = tree;
|
|
329
|
+
for (const segment of path.split("/")) {
|
|
330
|
+
if (!at)
|
|
331
|
+
break;
|
|
332
|
+
if (at.list) {
|
|
333
|
+
// Decimal digits only: Number() alone would also read "0x1", "1e0" or " 1".
|
|
334
|
+
if (!isDecimalDigits(segment))
|
|
335
|
+
break;
|
|
336
|
+
const n = Number(segment);
|
|
337
|
+
if (!Number.isSafeInteger(n) || n < 1)
|
|
338
|
+
break;
|
|
339
|
+
parts.push({ kind: "item", n });
|
|
340
|
+
at = at.list.item;
|
|
341
|
+
}
|
|
342
|
+
else if (at.group) {
|
|
343
|
+
const field = at.group.fields.find((candidate) => candidate.alias === segment);
|
|
344
|
+
if (!field)
|
|
345
|
+
break;
|
|
346
|
+
parts.push({ kind: "field", alias: field.alias, name: field.name });
|
|
347
|
+
at = field.type;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return parts;
|
|
354
|
+
}
|
|
355
|
+
/** D9: the JSON Schema of a nested value, built from the tree; a leaf asks `leafSchema`. */
|
|
356
|
+
export function nestedValueSchema(tree, leafSchema) {
|
|
357
|
+
if (tree.group) {
|
|
358
|
+
const properties = {};
|
|
359
|
+
for (const field of tree.group.fields) {
|
|
360
|
+
const inner = field.type ? nestedValueSchema(field.type, leafSchema) : null;
|
|
361
|
+
properties[field.alias] = { title: field.name, ...(inner ?? {}) };
|
|
362
|
+
}
|
|
363
|
+
return { anyOf: [{ type: "object", properties, additionalProperties: false }, { type: "null" }] };
|
|
364
|
+
}
|
|
365
|
+
if (tree.list) {
|
|
366
|
+
const items = tree.list.item ? nestedValueSchema(tree.list.item, leafSchema) : null;
|
|
367
|
+
return { anyOf: [{ type: "array", maxItems: tree.list.max, ...(items ? { items } : {}) }, { type: "null" }] };
|
|
368
|
+
}
|
|
369
|
+
return leafSchema(tree.editorId);
|
|
370
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { DataTypeValidatorIssue } from "./data-type-issue.js";
|
|
2
|
+
import { type DataTypeTree } from "./nested-fields.schema.js";
|
|
3
|
+
/** M33 K46: the core's issue type, which a plugin leaf's issue carries its plugin in. */
|
|
4
|
+
export type NestedIssue = DataTypeValidatorIssue;
|
|
5
|
+
export interface NestedValidatorEntry {
|
|
6
|
+
defaultSettings?: Record<string, unknown>;
|
|
7
|
+
validate?: (value: unknown, ctx: {
|
|
8
|
+
settings: Record<string, unknown>;
|
|
9
|
+
}) => NestedIssue[] | undefined;
|
|
10
|
+
isEmpty?: (value: unknown) => boolean;
|
|
11
|
+
}
|
|
12
|
+
type Lookup = (editorId: string) => NestedValidatorEntry | undefined;
|
|
13
|
+
export declare function isNestedEmpty(tree: DataTypeTree | null, value: unknown, lookup: Lookup): boolean;
|
|
14
|
+
export declare function validateNestedValue(tree: DataTypeTree, value: unknown, lookup: Lookup): NestedIssue[];
|
|
15
|
+
export interface PickedOccurrence {
|
|
16
|
+
id: string;
|
|
17
|
+
editorId: string;
|
|
18
|
+
settings: Record<string, unknown>;
|
|
19
|
+
path: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function pickedPagesInValue(tree: DataTypeTree, value: unknown): PickedOccurrence[];
|
|
22
|
+
/**
|
|
23
|
+
* M32 I2 (A5): the value with every picked page `drop` names taken out. A Content Picker loses
|
|
24
|
+
* the id (a single pick becomes null), a Link to a dropped page becomes null. Groups and lists
|
|
25
|
+
* are walked as `pickedPagesInValue` walks them; the input is never mutated, and a branch with
|
|
26
|
+
* nothing to drop is returned as it was.
|
|
27
|
+
*
|
|
28
|
+
* M32 I5 (D12): with `dropUntyped` (a copy made by a person), a value no data type can read is
|
|
29
|
+
* left out too, since nothing says which of its strings are pages: a Group sub-value whose
|
|
30
|
+
* sub-type is missing (`sub.missing`: no data type answers its id), a Group key the Group does not
|
|
31
|
+
* declare, and a whole list whose item type is missing (answered as `undefined`). A sub-type that
|
|
32
|
+
* is only not nestable (its plugin switched off) or unreadable for its depth keeps its value. Each
|
|
33
|
+
* such deletion of a non-empty value counts one in `removed` and in `untyped` (an empty one,
|
|
34
|
+
* null, [] or {}, is left out uncounted). Without the option nothing changes.
|
|
35
|
+
* The walk follows the tree, which is at most NESTING_DEPTH_MAX composites deep.
|
|
36
|
+
*/
|
|
37
|
+
export declare function removePickedPages(tree: DataTypeTree, value: unknown, drop: (id: string) => boolean, options?: {
|
|
38
|
+
dropUntyped?: boolean;
|
|
39
|
+
}): {
|
|
40
|
+
value: unknown;
|
|
41
|
+
removed: number;
|
|
42
|
+
untyped: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Every page id a stored value picks or links to, lowercased, walking every list item and every
|
|
46
|
+
* picker entry with no cap (`pickedPagesInValue` stops where the validator's limits do). The copy
|
|
47
|
+
* prune reads these, so it decides every id `removePickedPages` will ask about.
|
|
48
|
+
*/
|
|
49
|
+
export declare function everyPickedPageId(tree: DataTypeTree, value: unknown): Set<string>;
|
|
50
|
+
/** M32 I5 (D12): an empty stored value (null, [] or {}) holds nothing, so leaving it out of a copy
|
|
51
|
+
* is not counted as a value left out. */
|
|
52
|
+
export declare function isEmptyStored(value: unknown): boolean;
|
|
53
|
+
export {};
|