@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
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { NESTED_ISSUES_MAX, isPlainRecord } from "./nested-fields.schema.js";
|
|
2
|
+
import { CONTENT_PICKER_EDITOR_ID, LINK_EDITOR_ID, pickedPageIdsOf, readLinkValue, readPickedIds } from "./structured-fields.schema.js";
|
|
3
|
+
function defaultEmpty(value) {
|
|
4
|
+
return value === undefined || value === null || value === "";
|
|
5
|
+
}
|
|
6
|
+
export function isNestedEmpty(tree, value, lookup) {
|
|
7
|
+
if (!tree)
|
|
8
|
+
return defaultEmpty(value);
|
|
9
|
+
if (tree.group) {
|
|
10
|
+
if (!isPlainRecord(value))
|
|
11
|
+
return true;
|
|
12
|
+
return tree.group.fields.every((sub) => isNestedEmpty(sub.type, Object.prototype.hasOwnProperty.call(value, sub.alias) ? value[sub.alias] : undefined, lookup));
|
|
13
|
+
}
|
|
14
|
+
if (tree.list)
|
|
15
|
+
return !Array.isArray(value) || value.length === 0;
|
|
16
|
+
if (value === undefined || value === null)
|
|
17
|
+
return true;
|
|
18
|
+
try {
|
|
19
|
+
const isEmpty = lookup(tree.editorId)?.isEmpty;
|
|
20
|
+
if (isEmpty)
|
|
21
|
+
return isEmpty(value);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// fall back to the default test
|
|
25
|
+
}
|
|
26
|
+
return defaultEmpty(value);
|
|
27
|
+
}
|
|
28
|
+
function pathOf(segments) {
|
|
29
|
+
return segments.length > 0 ? { path: segments.join("/") } : {};
|
|
30
|
+
}
|
|
31
|
+
export function validateNestedValue(tree, value, lookup) {
|
|
32
|
+
const issues = [];
|
|
33
|
+
const full = () => issues.length >= NESTED_ISSUES_MAX;
|
|
34
|
+
const push = (issue) => {
|
|
35
|
+
if (!full())
|
|
36
|
+
issues.push(issue);
|
|
37
|
+
};
|
|
38
|
+
const walk = (node, v, segments) => {
|
|
39
|
+
if (full())
|
|
40
|
+
return;
|
|
41
|
+
if (node.group) {
|
|
42
|
+
if (!isPlainRecord(v)) {
|
|
43
|
+
push({ key: "dataTypes.group.errors.invalid", ...pathOf(segments) });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
for (const sub of node.group.fields) {
|
|
47
|
+
if (full())
|
|
48
|
+
return;
|
|
49
|
+
if (!sub.type)
|
|
50
|
+
continue;
|
|
51
|
+
const own = Object.prototype.hasOwnProperty.call(v, sub.alias) ? v[sub.alias] : undefined;
|
|
52
|
+
const at = [...segments, sub.alias];
|
|
53
|
+
if (isNestedEmpty(sub.type, own, lookup)) {
|
|
54
|
+
if (sub.required)
|
|
55
|
+
push({ key: "documentTypeForm.errors.required", path: at.join("/") });
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
walk(sub.type, own, at);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (node.list) {
|
|
64
|
+
if (!Array.isArray(v)) {
|
|
65
|
+
push({ key: "dataTypes.repeatableList.errors.invalid", ...pathOf(segments) });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const { max, min, item } = node.list;
|
|
69
|
+
if (v.length > max)
|
|
70
|
+
push({ key: "dataTypes.repeatableList.errors.tooMany", params: { max }, ...pathOf(segments) });
|
|
71
|
+
if (v.length > 0 && min !== null && v.length < min) {
|
|
72
|
+
push({ key: "dataTypes.repeatableList.errors.tooFew", params: { min }, ...pathOf(segments) });
|
|
73
|
+
}
|
|
74
|
+
if (!item)
|
|
75
|
+
return;
|
|
76
|
+
const count = Math.min(v.length, max);
|
|
77
|
+
for (let i = 0; i < count; i++) {
|
|
78
|
+
if (full())
|
|
79
|
+
return;
|
|
80
|
+
const at = [...segments, String(i + 1)];
|
|
81
|
+
if (isNestedEmpty(item, v[i], lookup))
|
|
82
|
+
push({ key: "dataTypes.repeatableList.errors.emptyItem", path: at.join("/") });
|
|
83
|
+
else
|
|
84
|
+
walk(item, v[i], at);
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const entry = lookup(node.editorId);
|
|
89
|
+
if (!entry?.validate)
|
|
90
|
+
return;
|
|
91
|
+
const settings = Object.keys(node.settings).length > 0 ? node.settings : (entry.defaultSettings ?? {});
|
|
92
|
+
// M32 F4d (D15): a leaf may be a plugin's type, so its answer is untrusted: anything but a list
|
|
93
|
+
// (a promise among them), or an issue that throws while read, is no verdict for this leaf.
|
|
94
|
+
const read = [];
|
|
95
|
+
try {
|
|
96
|
+
const found = entry.validate(v, { settings });
|
|
97
|
+
if (found === undefined || found === null)
|
|
98
|
+
return;
|
|
99
|
+
if (!Array.isArray(found))
|
|
100
|
+
return;
|
|
101
|
+
for (const issue of found.slice(0, NESTED_ISSUES_MAX)) {
|
|
102
|
+
const path = [...segments, issue.path].filter(Boolean).join("/");
|
|
103
|
+
const { path: _own, ...rest } = issue;
|
|
104
|
+
read.push(path ? { ...rest, path } : rest);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
for (const issue of read)
|
|
111
|
+
push(issue);
|
|
112
|
+
};
|
|
113
|
+
walk(tree, value, []);
|
|
114
|
+
return issues;
|
|
115
|
+
}
|
|
116
|
+
export function pickedPagesInValue(tree, value) {
|
|
117
|
+
const out = [];
|
|
118
|
+
const walk = (node, v, segments) => {
|
|
119
|
+
if (node.group) {
|
|
120
|
+
if (!isPlainRecord(v))
|
|
121
|
+
return;
|
|
122
|
+
for (const sub of node.group.fields) {
|
|
123
|
+
if (!sub.type || !Object.prototype.hasOwnProperty.call(v, sub.alias))
|
|
124
|
+
continue;
|
|
125
|
+
walk(sub.type, v[sub.alias], [...segments, sub.alias]);
|
|
126
|
+
}
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (node.list) {
|
|
130
|
+
if (!Array.isArray(v) || !node.list.item)
|
|
131
|
+
return;
|
|
132
|
+
const count = Math.min(v.length, node.list.max);
|
|
133
|
+
for (let i = 0; i < count; i++)
|
|
134
|
+
walk(node.list.item, v[i], [...segments, String(i + 1)]);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (node.editorId !== CONTENT_PICKER_EDITOR_ID && node.editorId !== LINK_EDITOR_ID)
|
|
138
|
+
return;
|
|
139
|
+
const ids = pickedPageIdsOf(node.editorId, v);
|
|
140
|
+
const numbered = node.editorId === CONTENT_PICKER_EDITOR_ID && Array.isArray(v);
|
|
141
|
+
const listed = numbered ? readPickedIds(v) : [];
|
|
142
|
+
for (const id of ids) {
|
|
143
|
+
const at = numbered ? [...segments, String(listed.indexOf(id) + 1)] : segments;
|
|
144
|
+
out.push({ id, editorId: node.editorId, settings: node.settings, path: at.join("/") });
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
walk(tree, value, []);
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* M32 I2 (A5): the value with every picked page `drop` names taken out. A Content Picker loses
|
|
152
|
+
* the id (a single pick becomes null), a Link to a dropped page becomes null. Groups and lists
|
|
153
|
+
* are walked as `pickedPagesInValue` walks them; the input is never mutated, and a branch with
|
|
154
|
+
* nothing to drop is returned as it was.
|
|
155
|
+
*
|
|
156
|
+
* M32 I5 (D12): with `dropUntyped` (a copy made by a person), a value no data type can read is
|
|
157
|
+
* left out too, since nothing says which of its strings are pages: a Group sub-value whose
|
|
158
|
+
* sub-type is missing (`sub.missing`: no data type answers its id), a Group key the Group does not
|
|
159
|
+
* declare, and a whole list whose item type is missing (answered as `undefined`). A sub-type that
|
|
160
|
+
* is only not nestable (its plugin switched off) or unreadable for its depth keeps its value. Each
|
|
161
|
+
* such deletion of a non-empty value counts one in `removed` and in `untyped` (an empty one,
|
|
162
|
+
* null, [] or {}, is left out uncounted). Without the option nothing changes.
|
|
163
|
+
* The walk follows the tree, which is at most NESTING_DEPTH_MAX composites deep.
|
|
164
|
+
*/
|
|
165
|
+
export function removePickedPages(tree, value, drop, options) {
|
|
166
|
+
const dropUntyped = options?.dropUntyped === true;
|
|
167
|
+
let removed = 0;
|
|
168
|
+
let untyped = 0;
|
|
169
|
+
const walk = (node, v) => {
|
|
170
|
+
if (node.group) {
|
|
171
|
+
if (!isPlainRecord(v))
|
|
172
|
+
return v;
|
|
173
|
+
let copy = null;
|
|
174
|
+
if (dropUntyped) {
|
|
175
|
+
const declared = new Set(node.group.fields.map((sub) => sub.alias));
|
|
176
|
+
for (const key of Object.keys(v)) {
|
|
177
|
+
if (declared.has(key))
|
|
178
|
+
continue;
|
|
179
|
+
copy ??= { ...v };
|
|
180
|
+
delete copy[key];
|
|
181
|
+
if (!isEmptyStored(v[key]))
|
|
182
|
+
untyped += 1;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
for (const sub of node.group.fields) {
|
|
186
|
+
if (!Object.prototype.hasOwnProperty.call(v, sub.alias))
|
|
187
|
+
continue;
|
|
188
|
+
if (!sub.type) {
|
|
189
|
+
if (!dropUntyped || !sub.missing)
|
|
190
|
+
continue;
|
|
191
|
+
copy ??= { ...v };
|
|
192
|
+
delete copy[sub.alias];
|
|
193
|
+
if (!isEmptyStored(v[sub.alias]))
|
|
194
|
+
untyped += 1;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
const next = walk(sub.type, v[sub.alias]);
|
|
198
|
+
if (next !== v[sub.alias]) {
|
|
199
|
+
copy ??= { ...v };
|
|
200
|
+
if (next === undefined)
|
|
201
|
+
delete copy[sub.alias];
|
|
202
|
+
else
|
|
203
|
+
copy[sub.alias] = next;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return copy ?? v;
|
|
207
|
+
}
|
|
208
|
+
if (node.list) {
|
|
209
|
+
if (!node.list.item) {
|
|
210
|
+
if (!dropUntyped || !node.list.itemMissing || v === undefined)
|
|
211
|
+
return v;
|
|
212
|
+
if (!isEmptyStored(v))
|
|
213
|
+
untyped += 1;
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
if (!Array.isArray(v))
|
|
217
|
+
return v;
|
|
218
|
+
// Every stored item, not only the first list.max: a value that predates a rule can hold more.
|
|
219
|
+
let copy = null;
|
|
220
|
+
for (let i = 0; i < v.length; i++) {
|
|
221
|
+
const next = walk(node.list.item, v[i]);
|
|
222
|
+
if (next !== v[i]) {
|
|
223
|
+
copy ??= [...v];
|
|
224
|
+
copy[i] = next;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// An item answered as `undefined` (a list inside a list whose items no type reads) is left out.
|
|
228
|
+
return copy ? copy.filter((item) => item !== undefined) : v;
|
|
229
|
+
}
|
|
230
|
+
if (node.editorId === CONTENT_PICKER_EDITOR_ID) {
|
|
231
|
+
// Each stored entry is read on its own (lowercased, as the validator accepts an upper-case
|
|
232
|
+
// uuid and stores it as sent), with no item cap, so a value over the cap is pruned whole.
|
|
233
|
+
const gone = new Set();
|
|
234
|
+
const entries = Array.isArray(v) ? v : [v];
|
|
235
|
+
const kept = entries.filter((entry) => {
|
|
236
|
+
const id = pickedIdOf(entry);
|
|
237
|
+
if (id === null || !drop(id))
|
|
238
|
+
return true;
|
|
239
|
+
gone.add(id);
|
|
240
|
+
return false;
|
|
241
|
+
});
|
|
242
|
+
if (gone.size === 0)
|
|
243
|
+
return v;
|
|
244
|
+
removed += gone.size;
|
|
245
|
+
return Array.isArray(v) ? kept : null;
|
|
246
|
+
}
|
|
247
|
+
if (node.editorId === LINK_EDITOR_ID) {
|
|
248
|
+
const link = readLinkValue(v);
|
|
249
|
+
if (link?.page === undefined || !drop(link.page))
|
|
250
|
+
return v;
|
|
251
|
+
removed += 1;
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
return v;
|
|
255
|
+
};
|
|
256
|
+
const result = walk(tree, value);
|
|
257
|
+
return { value: result, removed: removed + untyped, untyped };
|
|
258
|
+
}
|
|
259
|
+
/** One stored picker entry's page id, lowercased, or null when it names no page. */
|
|
260
|
+
function pickedIdOf(entry) {
|
|
261
|
+
return readPickedIds([entry])[0] ?? null;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Every page id a stored value picks or links to, lowercased, walking every list item and every
|
|
265
|
+
* picker entry with no cap (`pickedPagesInValue` stops where the validator's limits do). The copy
|
|
266
|
+
* prune reads these, so it decides every id `removePickedPages` will ask about.
|
|
267
|
+
*/
|
|
268
|
+
export function everyPickedPageId(tree, value) {
|
|
269
|
+
const ids = new Set();
|
|
270
|
+
removePickedPages(tree, value, (id) => {
|
|
271
|
+
ids.add(id);
|
|
272
|
+
return false;
|
|
273
|
+
});
|
|
274
|
+
return ids;
|
|
275
|
+
}
|
|
276
|
+
/** M32 I5 (D12): an empty stored value (null, [] or {}) holds nothing, so leaving it out of a copy
|
|
277
|
+
* is not counted as a value left out. */
|
|
278
|
+
export function isEmptyStored(value) {
|
|
279
|
+
if (value === null || value === undefined)
|
|
280
|
+
return true;
|
|
281
|
+
if (Array.isArray(value))
|
|
282
|
+
return value.length === 0;
|
|
283
|
+
return isPlainRecord(value) && Object.keys(value).length === 0;
|
|
284
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const NEWS_KINDS: readonly ["announcement", "release", "plugin"];
|
|
3
3
|
export declare const NewsKindSchema: z.ZodEnum<{
|
|
4
|
+
plugin: "plugin";
|
|
4
5
|
announcement: "announcement";
|
|
5
6
|
release: "release";
|
|
6
|
-
plugin: "plugin";
|
|
7
7
|
}>;
|
|
8
8
|
export type NewsKind = z.infer<typeof NewsKindSchema>;
|
|
9
9
|
export declare const NEWS_STATES: readonly ["draft", "published", "unpublished"];
|
|
@@ -24,9 +24,9 @@ export declare const NEWS_ITEMS_MAX = 3;
|
|
|
24
24
|
/** What the operator's editor saves: every field of an item but its state and its dates. */
|
|
25
25
|
export declare const NewsItemInputSchema: z.ZodObject<{
|
|
26
26
|
kind: z.ZodEnum<{
|
|
27
|
+
plugin: "plugin";
|
|
27
28
|
announcement: "announcement";
|
|
28
29
|
release: "release";
|
|
29
|
-
plugin: "plugin";
|
|
30
30
|
}>;
|
|
31
31
|
pluginId: z.ZodNullable<z.ZodString>;
|
|
32
32
|
titleEn: z.ZodString;
|
|
@@ -39,9 +39,9 @@ export type NewsItemInput = z.infer<typeof NewsItemInputSchema>;
|
|
|
39
39
|
export declare const MarketplaceNewsItemSchema: z.ZodObject<{
|
|
40
40
|
id: z.ZodString;
|
|
41
41
|
kind: z.ZodEnum<{
|
|
42
|
+
plugin: "plugin";
|
|
42
43
|
announcement: "announcement";
|
|
43
44
|
release: "release";
|
|
44
|
-
plugin: "plugin";
|
|
45
45
|
}>;
|
|
46
46
|
pluginId: z.ZodNullable<z.ZodString>;
|
|
47
47
|
titleEn: z.ZodString;
|
|
@@ -57,9 +57,9 @@ export declare const MarketplaceNewsResponseSchema: z.ZodObject<{
|
|
|
57
57
|
items: z.ZodArray<z.ZodObject<{
|
|
58
58
|
id: z.ZodString;
|
|
59
59
|
kind: z.ZodEnum<{
|
|
60
|
+
plugin: "plugin";
|
|
60
61
|
announcement: "announcement";
|
|
61
62
|
release: "release";
|
|
62
|
-
plugin: "plugin";
|
|
63
63
|
}>;
|
|
64
64
|
pluginId: z.ZodNullable<z.ZodString>;
|
|
65
65
|
titleEn: z.ZodString;
|
|
@@ -76,9 +76,9 @@ export declare const HomeNewsResponseSchema: z.ZodObject<{
|
|
|
76
76
|
items: z.ZodArray<z.ZodObject<{
|
|
77
77
|
id: z.ZodString;
|
|
78
78
|
kind: z.ZodEnum<{
|
|
79
|
+
plugin: "plugin";
|
|
79
80
|
announcement: "announcement";
|
|
80
81
|
release: "release";
|
|
81
|
-
plugin: "plugin";
|
|
82
82
|
}>;
|
|
83
83
|
pluginId: z.ZodNullable<z.ZodString>;
|
|
84
84
|
titleEn: z.ZodString;
|
|
@@ -594,8 +594,7 @@ export declare const ExplainSubjectQuerySchema: z.ZodObject<{
|
|
|
594
594
|
}, z.core.$strip>;
|
|
595
595
|
export type ExplainSubjectQuery = z.infer<typeof ExplainSubjectQuerySchema>;
|
|
596
596
|
/** One requirement as the decision evaluated it, labelled for the asker.
|
|
597
|
-
* `roleAction` is the role action checked
|
|
598
|
-
* Delete row). `decidedAt` is the deciding entry in S278b's shape (labels,
|
|
597
|
+
* `roleAction` is the role action checked: content.restore for a restore's Delete row and content.unpublish for an unpublish's Publish row, because neither is restrictable and the row's entries are another action's. `decidedAt` is the deciding entry in S278b's shape (labels,
|
|
599
598
|
* never emails), null when no entry decided. `askedAt` is where the
|
|
600
599
|
* requirement was asked: the page itself, a page under it, or the
|
|
601
600
|
* destination; the top level has the empty id and the path "/".
|
|
@@ -291,8 +291,7 @@ export const ExplainSubjectQuerySchema = z.object({
|
|
|
291
291
|
subjectId: z.string().min(1).max(NODE_ACCESS_SUBJECT_ID_MAX),
|
|
292
292
|
});
|
|
293
293
|
/** One requirement as the decision evaluated it, labelled for the asker.
|
|
294
|
-
* `roleAction` is the role action checked
|
|
295
|
-
* Delete row). `decidedAt` is the deciding entry in S278b's shape (labels,
|
|
294
|
+
* `roleAction` is the role action checked: content.restore for a restore's Delete row and content.unpublish for an unpublish's Publish row, because neither is restrictable and the row's entries are another action's. `decidedAt` is the deciding entry in S278b's shape (labels,
|
|
296
295
|
* never emails), null when no entry decided. `askedAt` is where the
|
|
297
296
|
* requirement was asked: the page itself, a page under it, or the
|
|
298
297
|
* destination; the top level has the empty id and the path "/".
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const NOTIFICATION_KINDS_PER_PLUGIN_MAX = 20;
|
|
3
|
+
export declare const NOTIFICATION_KIND_ID_MAX = 40;
|
|
4
|
+
export declare const NOTIFICATION_KIND_KEY_MAX = 191;
|
|
5
|
+
export declare const NOTIFICATION_CHOICE_KINDS_MAX = 500;
|
|
6
|
+
/** A kind id: a letter, then letters, digits or underscores. A linear scan, the length checked first. */
|
|
7
|
+
export declare function isNotificationKindId(value: string): boolean;
|
|
8
|
+
export declare const CORE_NOTIFICATION_KIND_IDS: readonly ["message", "pluginUpdate", "kardalumUpdate", "licence"];
|
|
9
|
+
export type CoreNotificationKindId = (typeof CORE_NOTIFICATION_KIND_IDS)[number];
|
|
10
|
+
export interface CoreNotificationKind {
|
|
11
|
+
id: CoreNotificationKindId;
|
|
12
|
+
/** English; the admin translates by id. */
|
|
13
|
+
label: string;
|
|
14
|
+
audience: {
|
|
15
|
+
anyone: true;
|
|
16
|
+
} | {
|
|
17
|
+
actions: readonly string[];
|
|
18
|
+
};
|
|
19
|
+
/** M32 I6f: email goes out unless the person opts out (opt-out row: `emailOptOutKindId`). */
|
|
20
|
+
emailByDefault?: true;
|
|
21
|
+
}
|
|
22
|
+
/** The choice row's kind id for an opt-out of an email-by-default kind (M32 I6f). */
|
|
23
|
+
export declare function emailOptOutKindId(kindId: string): string;
|
|
24
|
+
export declare const CORE_NOTIFICATION_KINDS: readonly CoreNotificationKind[];
|
|
25
|
+
/** A plugin kind's key, `pluginId/kindId`; throws on a part that would not parse back. */
|
|
26
|
+
export declare function pluginKindKey(pluginId: string, kindId: string): string;
|
|
27
|
+
export declare function parseKindKey(key: string): {
|
|
28
|
+
source: "core";
|
|
29
|
+
id: CoreNotificationKindId;
|
|
30
|
+
} | {
|
|
31
|
+
source: "plugin";
|
|
32
|
+
pluginId: string;
|
|
33
|
+
kindId: string;
|
|
34
|
+
} | null;
|
|
35
|
+
export declare const NotificationKindAudienceSchema: z.ZodObject<{
|
|
36
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
37
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
38
|
+
}, z.core.$strict>;
|
|
39
|
+
export declare const PluginNotificationKindSchema: z.ZodObject<{
|
|
40
|
+
id: z.ZodString;
|
|
41
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodPreprocess<z.ZodObject<{
|
|
42
|
+
en: z.ZodString;
|
|
43
|
+
}, z.core.$catchall<z.ZodString>>, unknown>]>;
|
|
44
|
+
description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPreprocess<z.ZodObject<{
|
|
45
|
+
en: z.ZodString;
|
|
46
|
+
}, z.core.$catchall<z.ZodString>>, unknown>]>>;
|
|
47
|
+
audience: z.ZodObject<{
|
|
48
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
49
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
50
|
+
}, z.core.$strict>;
|
|
51
|
+
}, z.core.$strict>;
|
|
52
|
+
export type PluginNotificationKind = z.infer<typeof PluginNotificationKindSchema>;
|
|
53
|
+
export declare const PluginNotificationKindsSchema: z.ZodArray<z.ZodObject<{
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodPreprocess<z.ZodObject<{
|
|
56
|
+
en: z.ZodString;
|
|
57
|
+
}, z.core.$catchall<z.ZodString>>, unknown>]>;
|
|
58
|
+
description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPreprocess<z.ZodObject<{
|
|
59
|
+
en: z.ZodString;
|
|
60
|
+
}, z.core.$catchall<z.ZodString>>, unknown>]>>;
|
|
61
|
+
audience: z.ZodObject<{
|
|
62
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
+
}, z.core.$strict>;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
export interface NotificationKindsProblem {
|
|
67
|
+
path: (string | number)[];
|
|
68
|
+
message: string;
|
|
69
|
+
}
|
|
70
|
+
/** The cross-checks the schema cannot do alone: ids, actions and roles against the plugin's own declarations. */
|
|
71
|
+
export declare function checkNotificationKinds(kinds: readonly PluginNotificationKind[], plugin: {
|
|
72
|
+
pluginId: string;
|
|
73
|
+
declaredActions: readonly string[];
|
|
74
|
+
offeredRoleIds: readonly string[];
|
|
75
|
+
}): NotificationKindsProblem[];
|
|
76
|
+
export declare const PluginNotifyRequestSchema: z.ZodObject<{
|
|
77
|
+
kind: z.ZodString;
|
|
78
|
+
title: z.ZodString;
|
|
79
|
+
text: z.ZodDefault<z.ZodString>;
|
|
80
|
+
link: z.ZodDefault<z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
81
|
+
kind: z.ZodLiteral<"none">;
|
|
82
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
83
|
+
kind: z.ZodLiteral<"page">;
|
|
84
|
+
nodeId: z.ZodString;
|
|
85
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
86
|
+
kind: z.ZodLiteral<"url">;
|
|
87
|
+
url: z.ZodURL;
|
|
88
|
+
}, z.core.$strict>], "kind">, z.ZodUnion<readonly [z.ZodObject<{
|
|
89
|
+
kind: z.ZodLiteral<"screen">;
|
|
90
|
+
section: z.ZodString;
|
|
91
|
+
entry: z.ZodOptional<z.ZodString>;
|
|
92
|
+
item: z.ZodOptional<z.ZodString>;
|
|
93
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
94
|
+
kind: z.ZodLiteral<"screen">;
|
|
95
|
+
builtIn: z.ZodEnum<{
|
|
96
|
+
media: "media";
|
|
97
|
+
content: "content";
|
|
98
|
+
settings: "settings";
|
|
99
|
+
users: "users";
|
|
100
|
+
}>;
|
|
101
|
+
entry: z.ZodString;
|
|
102
|
+
item: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, z.core.$strict>]>]>>;
|
|
104
|
+
}, z.core.$strict>;
|
|
105
|
+
export type PluginNotifyRequestInput = z.input<typeof PluginNotifyRequestSchema>;
|
|
106
|
+
export declare const NotificationChoiceKindSchema: z.ZodObject<{
|
|
107
|
+
id: z.ZodString;
|
|
108
|
+
source: z.ZodEnum<{
|
|
109
|
+
plugin: "plugin";
|
|
110
|
+
core: "core";
|
|
111
|
+
}>;
|
|
112
|
+
pluginId: z.ZodOptional<z.ZodString>;
|
|
113
|
+
pluginName: z.ZodOptional<z.ZodString>;
|
|
114
|
+
label: z.ZodString;
|
|
115
|
+
description: z.ZodOptional<z.ZodString>;
|
|
116
|
+
email: z.ZodBoolean;
|
|
117
|
+
}, z.core.$strip>;
|
|
118
|
+
export type NotificationChoiceKind = z.infer<typeof NotificationChoiceKindSchema>;
|
|
119
|
+
export declare const NotificationChoicesSchema: z.ZodObject<{
|
|
120
|
+
emailReady: z.ZodBoolean;
|
|
121
|
+
kinds: z.ZodArray<z.ZodObject<{
|
|
122
|
+
id: z.ZodString;
|
|
123
|
+
source: z.ZodEnum<{
|
|
124
|
+
plugin: "plugin";
|
|
125
|
+
core: "core";
|
|
126
|
+
}>;
|
|
127
|
+
pluginId: z.ZodOptional<z.ZodString>;
|
|
128
|
+
pluginName: z.ZodOptional<z.ZodString>;
|
|
129
|
+
label: z.ZodString;
|
|
130
|
+
description: z.ZodOptional<z.ZodString>;
|
|
131
|
+
email: z.ZodBoolean;
|
|
132
|
+
}, z.core.$strip>>;
|
|
133
|
+
}, z.core.$strip>;
|
|
134
|
+
export type NotificationChoices = z.infer<typeof NotificationChoicesSchema>;
|
|
135
|
+
export declare const NotificationChoicesQuerySchema: z.ZodObject<{
|
|
136
|
+
lang: z.ZodDefault<z.ZodEnum<{
|
|
137
|
+
en: "en";
|
|
138
|
+
ar: "ar";
|
|
139
|
+
de: "de";
|
|
140
|
+
}>>;
|
|
141
|
+
}, z.core.$strip>;
|
|
142
|
+
export declare const UpdateNotificationChoicesSchema: z.ZodObject<{
|
|
143
|
+
email: z.ZodRecord<z.ZodString, z.ZodBoolean>;
|
|
144
|
+
}, z.core.$strict>;
|
|
145
|
+
export type UpdateNotificationChoices = z.infer<typeof UpdateNotificationChoicesSchema>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ActionStringSchema, isPluginActionFor } from "./action.schema.js";
|
|
3
|
+
import { isCoreAction } from "./core-actions.js";
|
|
4
|
+
import { PluginLabelSchema } from "./plugin-labels.js";
|
|
5
|
+
import { RoleIdSchema, SEEDED_ROLE_IDS } from "./role.schema.js";
|
|
6
|
+
import { ADMIN_LOCALES } from "./user-api.schema.js";
|
|
7
|
+
import { PLUGIN_ID_MAX } from "./plugin-id-rules.js";
|
|
8
|
+
import { NOTIFICATION_ACTIONS_MAX, NOTIFICATION_ROLES_MAX, NOTIFICATION_TEXT_MAX, NOTIFICATION_TITLE_MAX, PluginNotificationLinkInputSchema, } from "./notification.schema.js";
|
|
9
|
+
// M32 G (G1, G2, G3, G5, G9): the kinds of notification, their keys and the email choice shapes.
|
|
10
|
+
export const NOTIFICATION_KINDS_PER_PLUGIN_MAX = 20;
|
|
11
|
+
export const NOTIFICATION_KIND_ID_MAX = 40;
|
|
12
|
+
export const NOTIFICATION_KIND_KEY_MAX = 191;
|
|
13
|
+
export const NOTIFICATION_CHOICE_KINDS_MAX = 500;
|
|
14
|
+
function isLetter(code) {
|
|
15
|
+
return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
|
|
16
|
+
}
|
|
17
|
+
function isDigit(code) {
|
|
18
|
+
return code >= 48 && code <= 57;
|
|
19
|
+
}
|
|
20
|
+
/** A kind id: a letter, then letters, digits or underscores. A linear scan, the length checked first. */
|
|
21
|
+
export function isNotificationKindId(value) {
|
|
22
|
+
if (typeof value !== "string" || value.length === 0 || value.length > NOTIFICATION_KIND_ID_MAX)
|
|
23
|
+
return false;
|
|
24
|
+
if (!isLetter(value.charCodeAt(0)))
|
|
25
|
+
return false;
|
|
26
|
+
for (let i = 1; i < value.length; i++) {
|
|
27
|
+
const c = value.charCodeAt(i);
|
|
28
|
+
if (!isLetter(c) && !isDigit(c) && c !== 95)
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
export const CORE_NOTIFICATION_KIND_IDS = ["message", "pluginUpdate", "kardalumUpdate", "licence"];
|
|
34
|
+
/** The choice row's kind id for an opt-out of an email-by-default kind (M32 I6f). */
|
|
35
|
+
export function emailOptOutKindId(kindId) {
|
|
36
|
+
return `${kindId}:no-email`;
|
|
37
|
+
}
|
|
38
|
+
export const CORE_NOTIFICATION_KINDS = [
|
|
39
|
+
{ id: "message", label: "Notes from people", audience: { anyone: true } },
|
|
40
|
+
{ id: "pluginUpdate", label: "Plugin updates", audience: { actions: ["plugins.install"] } },
|
|
41
|
+
{ id: "kardalumUpdate", label: "Kardalum updates", audience: { actions: ["settings.update"] } },
|
|
42
|
+
{ id: "licence", label: "Licences", audience: { actions: ["plugins.update"] }, emailByDefault: true },
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* The plugin id part of a kind key: 1 to PLUGIN_ID_MAX characters, none of them a slash, a
|
|
46
|
+
* space or a control character. A linear scan, the length checked first. It is not the full
|
|
47
|
+
* manifest id rule: a key names a plugin, it does not admit one.
|
|
48
|
+
*/
|
|
49
|
+
function isKindKeyPluginPart(value) {
|
|
50
|
+
if (value.length === 0 || value.length > PLUGIN_ID_MAX)
|
|
51
|
+
return false;
|
|
52
|
+
for (let i = 0; i < value.length; i++) {
|
|
53
|
+
const c = value.charCodeAt(i);
|
|
54
|
+
if (c <= 32 || c === 127 || c === 47 || (c >= 128 && c <= 159))
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
/** A plugin kind's key, `pluginId/kindId`; throws on a part that would not parse back. */
|
|
60
|
+
export function pluginKindKey(pluginId, kindId) {
|
|
61
|
+
if (!isKindKeyPluginPart(pluginId) || !isNotificationKindId(kindId)) {
|
|
62
|
+
throw new Error("A plugin kind key needs a plugin id and a kind id that pass the key rule.");
|
|
63
|
+
}
|
|
64
|
+
return `${pluginId}/${kindId}`;
|
|
65
|
+
}
|
|
66
|
+
export function parseKindKey(key) {
|
|
67
|
+
if (typeof key !== "string" || key.length === 0 || key.length > NOTIFICATION_KIND_KEY_MAX)
|
|
68
|
+
return null;
|
|
69
|
+
const slash = key.indexOf("/");
|
|
70
|
+
if (slash === -1) {
|
|
71
|
+
return CORE_NOTIFICATION_KIND_IDS.includes(key) ? { source: "core", id: key } : null;
|
|
72
|
+
}
|
|
73
|
+
if (key.indexOf("/", slash + 1) !== -1)
|
|
74
|
+
return null;
|
|
75
|
+
const pluginId = key.slice(0, slash);
|
|
76
|
+
const kindId = key.slice(slash + 1);
|
|
77
|
+
if (!isKindKeyPluginPart(pluginId) || !isNotificationKindId(kindId))
|
|
78
|
+
return null;
|
|
79
|
+
return { source: "plugin", pluginId, kindId };
|
|
80
|
+
}
|
|
81
|
+
export const NotificationKindAudienceSchema = z
|
|
82
|
+
.object({
|
|
83
|
+
actions: z.array(ActionStringSchema).max(NOTIFICATION_ACTIONS_MAX, `An audience names at most ${NOTIFICATION_ACTIONS_MAX} actions.`).optional(),
|
|
84
|
+
roles: z.array(RoleIdSchema).max(NOTIFICATION_ROLES_MAX, `An audience names at most ${NOTIFICATION_ROLES_MAX} roles.`).optional(),
|
|
85
|
+
})
|
|
86
|
+
.strict()
|
|
87
|
+
.refine((a) => (a.actions?.length ?? 0) + (a.roles?.length ?? 0) > 0, { message: "Name at least one action or role." });
|
|
88
|
+
export const PluginNotificationKindSchema = z
|
|
89
|
+
.object({
|
|
90
|
+
id: z.string().refine(isNotificationKindId, {
|
|
91
|
+
message: `A kind id is a letter, then letters, digits or underscores, at most ${NOTIFICATION_KIND_ID_MAX} characters.`,
|
|
92
|
+
}),
|
|
93
|
+
label: PluginLabelSchema,
|
|
94
|
+
description: PluginLabelSchema.optional(),
|
|
95
|
+
audience: NotificationKindAudienceSchema,
|
|
96
|
+
})
|
|
97
|
+
.strict();
|
|
98
|
+
export const PluginNotificationKindsSchema = z.array(PluginNotificationKindSchema).max(NOTIFICATION_KINDS_PER_PLUGIN_MAX);
|
|
99
|
+
/** The cross-checks the schema cannot do alone: ids, actions and roles against the plugin's own declarations. */
|
|
100
|
+
export function checkNotificationKinds(kinds, plugin) {
|
|
101
|
+
const problems = [];
|
|
102
|
+
if (kinds.length > NOTIFICATION_KINDS_PER_PLUGIN_MAX) {
|
|
103
|
+
problems.push({ path: [], message: `A plugin declares at most ${NOTIFICATION_KINDS_PER_PLUGIN_MAX} notification kinds.` });
|
|
104
|
+
}
|
|
105
|
+
const seen = new Set();
|
|
106
|
+
kinds.forEach((kind, i) => {
|
|
107
|
+
if (seen.has(kind.id))
|
|
108
|
+
problems.push({ path: [i, "id"], message: `The kind id "${kind.id}" is declared twice.` });
|
|
109
|
+
seen.add(kind.id);
|
|
110
|
+
const actions = kind.audience.actions ?? [];
|
|
111
|
+
const seenActions = new Set();
|
|
112
|
+
actions.forEach((action, j) => {
|
|
113
|
+
if (seenActions.has(action)) {
|
|
114
|
+
problems.push({ path: [i, "audience", "actions", j], message: `The action "${action}" is named twice.` });
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
seenActions.add(action);
|
|
118
|
+
if (isCoreAction(action))
|
|
119
|
+
return;
|
|
120
|
+
if (isPluginActionFor(action, plugin.pluginId)) {
|
|
121
|
+
if (!plugin.declaredActions.includes(action)) {
|
|
122
|
+
problems.push({ path: [i, "audience", "actions", j], message: `The action "${action}" is not declared by this plugin.` });
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
problems.push({ path: [i, "audience", "actions", j], message: `The action "${action}" is neither a core action nor one of this plugin's own.` });
|
|
127
|
+
});
|
|
128
|
+
const roles = kind.audience.roles ?? [];
|
|
129
|
+
const seenRoles = new Set();
|
|
130
|
+
roles.forEach((role, j) => {
|
|
131
|
+
if (seenRoles.has(role)) {
|
|
132
|
+
problems.push({ path: [i, "audience", "roles", j], message: `The role "${role}" is named twice.` });
|
|
133
|
+
}
|
|
134
|
+
seenRoles.add(role);
|
|
135
|
+
const known = role === SEEDED_ROLE_IDS.admin || role === SEEDED_ROLE_IDS.editor || plugin.offeredRoleIds.includes(role);
|
|
136
|
+
if (!known) {
|
|
137
|
+
problems.push({ path: [i, "audience", "roles", j], message: `The role "${role}" is not admin, editor or a role this plugin offers.` });
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
return problems;
|
|
142
|
+
}
|
|
143
|
+
export const PluginNotifyRequestSchema = z
|
|
144
|
+
.object({
|
|
145
|
+
kind: z.string().refine(isNotificationKindId, { message: "Name one of the kinds the plugin declared." }),
|
|
146
|
+
title: z
|
|
147
|
+
.string()
|
|
148
|
+
.trim()
|
|
149
|
+
.min(1, "A notification needs a title.")
|
|
150
|
+
.max(NOTIFICATION_TITLE_MAX, `A title has at most ${NOTIFICATION_TITLE_MAX} characters.`),
|
|
151
|
+
text: z.string().max(NOTIFICATION_TEXT_MAX, `A text has at most ${NOTIFICATION_TEXT_MAX} characters.`).default(""),
|
|
152
|
+
// M33 K6: a plugin may also link one of its own screens.
|
|
153
|
+
link: PluginNotificationLinkInputSchema.default({ kind: "none" }),
|
|
154
|
+
})
|
|
155
|
+
.strict();
|
|
156
|
+
export const NotificationChoiceKindSchema = z.object({
|
|
157
|
+
id: z.string(),
|
|
158
|
+
source: z.enum(["core", "plugin"]),
|
|
159
|
+
pluginId: z.string().optional(),
|
|
160
|
+
pluginName: z.string().optional(),
|
|
161
|
+
label: z.string(),
|
|
162
|
+
description: z.string().optional(),
|
|
163
|
+
email: z.boolean(),
|
|
164
|
+
});
|
|
165
|
+
export const NotificationChoicesSchema = z.object({
|
|
166
|
+
emailReady: z.boolean(),
|
|
167
|
+
kinds: z.array(NotificationChoiceKindSchema).max(NOTIFICATION_CHOICE_KINDS_MAX),
|
|
168
|
+
});
|
|
169
|
+
export const NotificationChoicesQuerySchema = z.object({ lang: z.enum(ADMIN_LOCALES).default("en") });
|
|
170
|
+
export const UpdateNotificationChoicesSchema = z
|
|
171
|
+
.object({
|
|
172
|
+
email: z.record(z.string().max(NOTIFICATION_KIND_KEY_MAX), z.boolean()).refine((r) => {
|
|
173
|
+
const n = Object.keys(r).length;
|
|
174
|
+
return n >= 1 && n <= NOTIFICATION_CHOICE_KINDS_MAX;
|
|
175
|
+
}, { message: `Send between 1 and ${NOTIFICATION_CHOICE_KINDS_MAX} choices.` }),
|
|
176
|
+
})
|
|
177
|
+
.strict();
|