@kardalum/plugin-sdk 0.20.0 → 0.21.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 +70 -0
- package/dist/admin-section-registry.d.ts +33 -1
- package/dist/admin-section-registry.js +67 -0
- package/dist/capabilities.js +46 -1
- package/dist/consent-entry.d.ts +11 -0
- package/dist/consent-entry.js +18 -0
- package/dist/content-library.d.ts +17 -0
- package/dist/content-list-extensions.d.ts +50 -0
- package/dist/content-list-extensions.js +11 -0
- package/dist/content-picker/page-picker-sheet.d.ts +2 -0
- package/dist/content-picker/page-picker-sheet.js +1 -1
- package/dist/content-picker/page-picker.d.ts +18 -0
- package/dist/content-picker/page-picker.js +20 -0
- package/dist/datatype-validation.js +10 -2
- package/dist/datatypes-entry.d.ts +1 -0
- package/dist/datatypes-entry.js +2 -0
- package/dist/entitlement-types.d.ts +18 -1
- package/dist/host-entry.d.ts +7 -1
- package/dist/host-entry.js +14 -1
- package/dist/index.d.ts +35 -7
- package/dist/index.js +46 -5
- package/dist/mail.d.ts +6 -2
- package/dist/manifest-entry.d.ts +22 -4
- package/dist/manifest-entry.js +25 -1
- package/dist/manifest-schema.d.ts +570 -31
- package/dist/manifest-schema.js +240 -12
- package/dist/manifest.d.ts +757 -32
- package/dist/manifest.js +8 -4
- package/dist/plugin-context.d.ts +47 -0
- package/dist/plugin-context.js +27 -0
- package/dist/plugin-permissions.d.ts +18 -0
- package/dist/plugin-permissions.js +25 -0
- package/dist/plugin-screen-context.d.ts +152 -11
- package/dist/plugin-screen-context.js +30 -0
- package/dist/providers.d.ts +47 -2
- package/dist/render-page.d.ts +15 -0
- package/dist/render-page.js +20 -0
- package/dist/richtext/block-panel.d.ts +12 -1
- package/dist/richtext/block-panel.js +27 -21
- package/dist/richtext/button-view.d.ts +11 -0
- package/dist/richtext/button-view.js +45 -0
- package/dist/richtext/content-guard.d.ts +4 -0
- package/dist/richtext/content-guard.js +27 -0
- package/dist/richtext/editor-handle.d.ts +34 -0
- package/dist/richtext/editor-handle.js +225 -0
- package/dist/richtext/extensions.d.ts +6 -0
- package/dist/richtext/extensions.js +16 -0
- package/dist/richtext/insert-menu.d.ts +6 -1
- package/dist/richtext/insert-menu.js +38 -18
- package/dist/richtext/item-attributes.d.ts +6 -0
- package/dist/richtext/item-attributes.js +19 -0
- package/dist/richtext/item-panel.d.ts +25 -0
- package/dist/richtext/item-panel.js +118 -0
- package/dist/richtext/item-view.d.ts +58 -0
- package/dist/richtext/item-view.js +172 -0
- package/dist/richtext/mark-form.d.ts +10 -0
- package/dist/richtext/mark-form.js +38 -0
- package/dist/richtext/paste-choice.d.ts +9 -0
- package/dist/richtext/paste-choice.js +13 -0
- package/dist/richtext/plugin-items.d.ts +72 -0
- package/dist/richtext/plugin-items.js +562 -0
- package/dist/richtext/plugin-mark-tooltips.d.ts +5 -0
- package/dist/richtext/plugin-mark-tooltips.js +44 -0
- package/dist/richtext/plugin-toolbar.d.ts +57 -0
- package/dist/richtext/plugin-toolbar.js +186 -0
- package/dist/richtext/rich-item-icons.d.ts +5 -0
- package/dist/richtext/rich-item-icons.js +42 -0
- package/dist/richtext/rich-items.d.ts +42 -0
- package/dist/richtext/rich-items.js +68 -0
- package/dist/richtext/rich-text-view-host.d.ts +24 -0
- package/dist/richtext/rich-text-view-host.js +11 -0
- package/dist/richtext/toolbar-button.d.ts +16 -0
- package/dist/richtext/toolbar-button.js +9 -0
- package/dist/richtext/url-paste.d.ts +20 -0
- package/dist/richtext/url-paste.js +82 -0
- package/dist/richtext-html-entry.d.ts +5 -0
- package/dist/richtext-html-entry.js +11 -0
- package/dist/sdk-strings.d.ts +59 -0
- package/dist/sdk-strings.js +64 -0
- package/dist/service-contract.d.ts +17 -0
- package/dist/service-contract.js +39 -0
- package/dist/services.d.ts +114 -0
- package/dist/services.js +1 -0
- package/dist/structured-storage-types.d.ts +124 -4
- package/dist/tailwind.js +10 -5
- package/dist/template-reads.d.ts +16 -0
- package/dist/template-reads.js +21 -0
- package/dist/testing-entry.d.ts +38 -0
- package/dist/testing-entry.js +173 -0
- package/dist/text-entry.d.ts +1 -1
- package/dist/text-entry.js +3 -2
- package/dist/tokens/system-dark.css +1 -0
- package/dist/tokens/tailwind-theme.css +2 -0
- package/dist/tokens/tokens.css +4 -0
- package/dist/tokens/tokens.json +5 -1
- package/dist/uploads.d.ts +43 -0
- package/dist/uploads.js +1 -0
- package/dist/user-library.d.ts +51 -0
- package/dist/user-library.js +15 -0
- package/dist/view-helpers.d.ts +18 -0
- package/dist/view-helpers.js +64 -0
- package/dist/views/content-list-view.js +207 -8
- package/dist/views/content-picker-view.js +1 -1
- package/dist/views/rich-text-view.d.ts +2 -0
- package/dist/views/rich-text-view.js +182 -24
- package/dist/views/unreadable-rich-text.d.ts +17 -0
- package/dist/views/unreadable-rich-text.js +40 -0
- package/dist/visitors.d.ts +81 -0
- package/dist/visitors.js +1 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-app-hosts.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-app-hosts.js +39 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-app-redirects.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-app-redirects.js +31 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.d.ts +127 -8
- package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.js +82 -7
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +5 -1
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +2 -2
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.js +11 -0
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.js +18 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +80 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +41 -2
- package/node_modules/@kardalum/api-schemas/dist/content-reads.schema.d.ts +213 -0
- package/node_modules/@kardalum/api-schemas/dist/content-reads.schema.js +234 -0
- package/node_modules/@kardalum/api-schemas/dist/contribution-issues.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/contribution-issues.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +50 -13
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +19 -10
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +77 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +37 -0
- package/node_modules/@kardalum/api-schemas/dist/experimental-points.d.ts +19 -0
- package/node_modules/@kardalum/api-schemas/dist/experimental-points.js +250 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection-callers.d.ts +29 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection-callers.js +31 -0
- package/node_modules/@kardalum/api-schemas/dist/html-scan.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/html-scan.js +122 -0
- package/node_modules/@kardalum/api-schemas/dist/html-start-tags.d.ts +48 -0
- package/node_modules/@kardalum/api-schemas/dist/html-start-tags.js +381 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +52 -14
- package/node_modules/@kardalum/api-schemas/dist/index.js +53 -9
- package/node_modules/@kardalum/api-schemas/dist/json-depth.d.ts +3 -0
- package/node_modules/@kardalum/api-schemas/dist/json-depth.js +20 -0
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.d.ts +4 -2
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.js +6 -1
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +178 -2
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +10 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.d.ts +3 -3
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +16 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.js +51 -2
- package/node_modules/@kardalum/api-schemas/dist/page-audience.schema.d.ts +87 -0
- package/node_modules/@kardalum/api-schemas/dist/page-audience.schema.js +44 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-admin-slots.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-admin-slots.js +61 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.d.ts +4 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.js +12 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-slots.d.ts +136 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-slots.js +254 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-checks.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-checks.js +66 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-document.d.ts +130 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-document.js +173 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-fetch.d.ts +16 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-fetch.js +112 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-schema.d.ts +70 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-schema.js +380 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-types.d.ts +3 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-types.js +68 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +18 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +18 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +5 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.d.ts +10 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.js +48 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.d.ts +5 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.js +6 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-events.d.ts +24 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-events.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-guards.d.ts +112 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-guards.js +118 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +67 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +15 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-kept-parts.d.ts +138 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-kept-parts.js +110 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +80 -15
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +67 -23
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +10 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +33 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +2 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +7 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.d.ts +43 -7
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.js +36 -5
- package/node_modules/@kardalum/api-schemas/dist/plugin-rich-text.d.ts +638 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-rich-text.js +533 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-call.d.ts +36 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-call.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-connections.d.ts +193 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-connections.js +123 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-declarations.d.ts +209 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-declarations.js +372 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-services.d.ts +90 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-services.js +204 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-settings.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-settings.js +10 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.d.ts +171 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.js +406 -42
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-requests.d.ts +69 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-requests.js +149 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-styles.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-styles.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-uploads.d.ts +96 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-uploads.js +185 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-user-accounts.d.ts +213 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-user-accounts.js +131 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-view-kit.d.ts +54 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-view-kit.js +154 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-visitor-points.d.ts +37 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-visitor-points.js +124 -0
- package/node_modules/@kardalum/api-schemas/dist/render-cache.d.ts +126 -0
- package/node_modules/@kardalum/api-schemas/dist/render-cache.js +263 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +303 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +61 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-paste-hosts.d.ts +14 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-paste-hosts.js +108 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.d.ts +66 -1
- package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.js +465 -7
- package/node_modules/@kardalum/api-schemas/dist/rich-text-text.js +15 -118
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +110 -0
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +36 -0
- package/node_modules/@kardalum/api-schemas/dist/security-overview.schema.d.ts +64 -0
- package/node_modules/@kardalum/api-schemas/dist/security-overview.schema.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.d.ts +9 -2
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +7 -2
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/sign-in-steps.d.ts +724 -0
- package/node_modules/@kardalum/api-schemas/dist/sign-in-steps.js +408 -0
- package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.d.ts +5 -3
- package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.js +3 -1
- package/node_modules/@kardalum/api-schemas/dist/site-consent.d.ts +77 -0
- package/node_modules/@kardalum/api-schemas/dist/site-consent.js +122 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.js +28 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +33 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +26 -1
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +14 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +2 -0
- package/node_modules/@kardalum/api-schemas/dist/visitor-accounts.d.ts +482 -0
- package/node_modules/@kardalum/api-schemas/dist/visitor-accounts.js +380 -0
- package/node_modules/@kardalum/api-schemas/dist/visitor-groups.d.ts +109 -0
- package/node_modules/@kardalum/api-schemas/dist/visitor-groups.js +62 -0
- package/node_modules/@kardalum/api-schemas/package.json +1 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +9 -1
- package/node_modules/@kardalum/design-tokens/dist/system-dark.css +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +4 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +6 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +5 -1
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +4 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +9 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +276 -19
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +23 -0
- package/node_modules/@kardalum/plugin-package/dist/contract-fingerprint.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/contract-fingerprint.js +39 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/admin-styles.d.ts +23 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/admin-styles.js +351 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.js +21 -8
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.js +23 -10
- package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +3 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +30 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.js +6 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.js +24 -6
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +15 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/rich-text.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/rich-text.js +173 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.js +14 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/services-events.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/services-events.js +35 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sign-in-steps.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sign-in-steps.js +71 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.js +44 -11
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +7 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/user-accounts.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/user-accounts.js +36 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/visitor-points.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/visitor-points.js +33 -0
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -0
- package/node_modules/@kardalum/plugin-package/dist/index.js +5 -0
- package/node_modules/@kardalum/plugin-package/dist/public-suffix.d.ts +7 -0
- package/node_modules/@kardalum/plugin-package/dist/public-suffix.js +23 -0
- package/node_modules/@kardalum/plugin-package/dist/rich-text-summary.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/rich-text-summary.js +27 -0
- package/node_modules/@kardalum/plugin-package/dist/stylesheet-load-hook.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/stylesheet-load-hook.js +28 -0
- package/node_modules/@kardalum/plugin-package/package.json +4 -0
- package/node_modules/@kardalum/ui/dist/components/select.d.ts +6 -0
- package/node_modules/@kardalum/ui/dist/components/select.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/textarea.d.ts +6 -0
- package/node_modules/@kardalum/ui/dist/components/textarea.js +7 -0
- package/node_modules/@kardalum/ui/dist/index.d.ts +2 -0
- package/node_modules/@kardalum/ui/dist/index.js +2 -0
- package/package.json +15 -3
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { CONTRACT_DOWNLOAD_BYTES_MAX, ContractDownloadSchema, OwnerContractsSchema } from "./plugin-contract-document.js";
|
|
2
|
+
import { isPluginManifestId } from "./plugin-id-rules.js";
|
|
3
|
+
import { parseContractId, parseContractRange, parseContractVersion } from "./plugin-services.js";
|
|
4
|
+
// M35 B1c (plan decision 5): the two public contract routes, read by the scaffold, the CLI and the
|
|
5
|
+
// server alike. The answer is read up to CONTRACT_DOWNLOAD_BYTES_MAX bytes and only through its schema.
|
|
6
|
+
export const CONTRACT_FETCH_TIME_MS = 10_000;
|
|
7
|
+
export class ContractFetchError extends Error {
|
|
8
|
+
kind;
|
|
9
|
+
status;
|
|
10
|
+
/** A 404's own `code` (`owner_unknown`, `contract_unknown`, `no_version_in_range`), when its body names one. */
|
|
11
|
+
code;
|
|
12
|
+
constructor(kind, message, status = null, code = null) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "ContractFetchError";
|
|
15
|
+
this.kind = kind;
|
|
16
|
+
this.status = status;
|
|
17
|
+
this.code = code;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function readCapped(response) {
|
|
21
|
+
const declared = Number(response.headers.get("content-length") ?? "0");
|
|
22
|
+
if (Number.isFinite(declared) && declared > CONTRACT_DOWNLOAD_BYTES_MAX) {
|
|
23
|
+
// Closed now, so a refused answer does not hold its connection open until the timeout.
|
|
24
|
+
if (response.body !== null)
|
|
25
|
+
await response.body.getReader().cancel().catch(() => undefined);
|
|
26
|
+
throw new ContractFetchError("invalid", "the marketplace's answer is too large");
|
|
27
|
+
}
|
|
28
|
+
if (response.body === null)
|
|
29
|
+
return "";
|
|
30
|
+
const reader = response.body.getReader();
|
|
31
|
+
const chunks = [];
|
|
32
|
+
let size = 0;
|
|
33
|
+
for (;;) {
|
|
34
|
+
const { done, value } = await reader.read();
|
|
35
|
+
if (done)
|
|
36
|
+
break;
|
|
37
|
+
size += value.byteLength;
|
|
38
|
+
if (size > CONTRACT_DOWNLOAD_BYTES_MAX) {
|
|
39
|
+
await reader.cancel();
|
|
40
|
+
throw new ContractFetchError("invalid", "the marketplace's answer is too large");
|
|
41
|
+
}
|
|
42
|
+
chunks.push(value);
|
|
43
|
+
}
|
|
44
|
+
const all = new Uint8Array(size);
|
|
45
|
+
let at = 0;
|
|
46
|
+
for (const chunk of chunks) {
|
|
47
|
+
all.set(chunk, at);
|
|
48
|
+
at += chunk.byteLength;
|
|
49
|
+
}
|
|
50
|
+
return new TextDecoder().decode(all);
|
|
51
|
+
}
|
|
52
|
+
async function getJson(url, fetchImpl) {
|
|
53
|
+
let response;
|
|
54
|
+
try {
|
|
55
|
+
response = await fetchImpl(url.toString(), { signal: AbortSignal.timeout(CONTRACT_FETCH_TIME_MS), headers: { accept: "application/json" } });
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
throw new ContractFetchError("unreachable", `could not reach the marketplace at ${url.origin}`);
|
|
59
|
+
}
|
|
60
|
+
if (response.status === 404) {
|
|
61
|
+
let code = null;
|
|
62
|
+
try {
|
|
63
|
+
const body = JSON.parse(await readCapped(response));
|
|
64
|
+
if (typeof body.code === "string" && body.code.length <= 40)
|
|
65
|
+
code = body.code;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// a 404 without a readable body names no code
|
|
69
|
+
}
|
|
70
|
+
throw new ContractFetchError("notFound", "the marketplace has no such contract", 404, code);
|
|
71
|
+
}
|
|
72
|
+
if (!response.ok)
|
|
73
|
+
throw new ContractFetchError("unreachable", `the marketplace answered ${response.status}`, response.status);
|
|
74
|
+
const text = await readCapped(response);
|
|
75
|
+
try {
|
|
76
|
+
return JSON.parse(text);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
throw new ContractFetchError("invalid", "the marketplace's answer is not JSON");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export async function fetchContractDownload(registryUrl, contract, select, fetchImpl = fetch) {
|
|
83
|
+
const id = parseContractId(contract);
|
|
84
|
+
if (id === null)
|
|
85
|
+
throw new ContractFetchError("invalid", "not a contract id <owner plugin id>/<contract name>");
|
|
86
|
+
// Plan decision 5: one or the other, so the route's precedence never decides a caller's mistake.
|
|
87
|
+
if (select.version !== undefined && select.range !== undefined)
|
|
88
|
+
throw new ContractFetchError("invalid", "a version or a range, not both");
|
|
89
|
+
if (select.version !== undefined && parseContractVersion(select.version) === null)
|
|
90
|
+
throw new ContractFetchError("invalid", "not a version <major>.<minor>");
|
|
91
|
+
if (select.range !== undefined && parseContractRange(select.range) === null)
|
|
92
|
+
throw new ContractFetchError("invalid", "not a range ^<major>.<minor>");
|
|
93
|
+
const url = new URL(`/api/v1/contracts/${encodeURIComponent(id.ownerId)}/${encodeURIComponent(id.name)}`, registryUrl);
|
|
94
|
+
if (select.version !== undefined)
|
|
95
|
+
url.searchParams.set("version", select.version);
|
|
96
|
+
if (select.range !== undefined)
|
|
97
|
+
url.searchParams.set("range", select.range);
|
|
98
|
+
const parsed = ContractDownloadSchema.safeParse(await getJson(url, fetchImpl));
|
|
99
|
+
if (!parsed.success || parsed.data.document.contract !== contract)
|
|
100
|
+
throw new ContractFetchError("invalid", "the marketplace's answer is not a contract document");
|
|
101
|
+
return parsed.data;
|
|
102
|
+
}
|
|
103
|
+
export async function fetchOwnerContracts(registryUrl, ownerId, fetchImpl = fetch) {
|
|
104
|
+
if (!isPluginManifestId(ownerId))
|
|
105
|
+
throw new ContractFetchError("invalid", "not a plugin id");
|
|
106
|
+
const parsed = OwnerContractsSchema.safeParse(await getJson(new URL(`/api/v1/contracts/${encodeURIComponent(ownerId)}`, registryUrl), fetchImpl));
|
|
107
|
+
if (!parsed.success || parsed.data.owner.id !== ownerId)
|
|
108
|
+
throw new ContractFetchError("invalid", "the marketplace's answer is not a contract list");
|
|
109
|
+
return parsed.data;
|
|
110
|
+
}
|
|
111
|
+
// M35 C4b (C4b-D13): the same capped read, for `kardalum plugin validate --online`'s listing read.
|
|
112
|
+
export { readCapped as readCappedJsonText };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export declare const CONTRACT_SCHEMA_DEPTH_MAX = 8;
|
|
2
|
+
export declare const CONTRACT_SCHEMA_NODES_MAX = 512;
|
|
3
|
+
export declare const CONTRACT_SCHEMA_PROPERTIES_MAX = 64;
|
|
4
|
+
export declare const CONTRACT_SCHEMA_ENUM_MAX = 64;
|
|
5
|
+
export declare const CONTRACT_SCHEMA_TEXT_MAX = 200;
|
|
6
|
+
export declare const CONTRACT_PROPERTY_NAME_MAX = 64;
|
|
7
|
+
declare const FORMATS: readonly ["uuid", "email", "date-time", "uri"];
|
|
8
|
+
type ContractFormat = (typeof FORMATS)[number];
|
|
9
|
+
interface NodeBase {
|
|
10
|
+
personal?: true;
|
|
11
|
+
nullable?: true;
|
|
12
|
+
}
|
|
13
|
+
export type ContractSchema = (NodeBase & {
|
|
14
|
+
type: "object";
|
|
15
|
+
properties: Array<{
|
|
16
|
+
name: string;
|
|
17
|
+
schema: ContractSchema;
|
|
18
|
+
required: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
}) | (NodeBase & {
|
|
21
|
+
type: "array";
|
|
22
|
+
items: ContractSchema;
|
|
23
|
+
minItems?: number;
|
|
24
|
+
maxItems?: number;
|
|
25
|
+
}) | (NodeBase & {
|
|
26
|
+
type: "string";
|
|
27
|
+
minLength?: number;
|
|
28
|
+
maxLength?: number;
|
|
29
|
+
enum?: string[];
|
|
30
|
+
format?: ContractFormat;
|
|
31
|
+
}) | (NodeBase & {
|
|
32
|
+
type: "number" | "integer";
|
|
33
|
+
minimum?: number;
|
|
34
|
+
maximum?: number;
|
|
35
|
+
exclusiveMinimum?: number;
|
|
36
|
+
exclusiveMaximum?: number;
|
|
37
|
+
}) | (NodeBase & {
|
|
38
|
+
type: "boolean";
|
|
39
|
+
}) | (NodeBase & {
|
|
40
|
+
type: "null";
|
|
41
|
+
});
|
|
42
|
+
/** Reads `value` as a contract schema, or refuses it with the first problem's path. */
|
|
43
|
+
export declare function readContractSchema(value: unknown, options?: {
|
|
44
|
+
root?: "object";
|
|
45
|
+
}): {
|
|
46
|
+
ok: true;
|
|
47
|
+
schema: ContractSchema;
|
|
48
|
+
} | {
|
|
49
|
+
ok: false;
|
|
50
|
+
problem: string;
|
|
51
|
+
};
|
|
52
|
+
/** Checks `value` (already plain data: the broker parses its JSON first) and answers a copy with only the declared properties. */
|
|
53
|
+
export declare function checkContractValue(schema: ContractSchema, value: unknown): {
|
|
54
|
+
ok: true;
|
|
55
|
+
value: unknown;
|
|
56
|
+
} | {
|
|
57
|
+
ok: false;
|
|
58
|
+
problem: string;
|
|
59
|
+
};
|
|
60
|
+
/** The paths of every field marked personal: `a.b` for a property, `a[].b` inside a list, in declaration order. */
|
|
61
|
+
export declare function personalPaths(schema: ContractSchema): string[];
|
|
62
|
+
/** Every property name in the tree, in walk order (the secret-like name guard reads these). */
|
|
63
|
+
export declare function schemaPropertyNames(schema: ContractSchema): string[];
|
|
64
|
+
/** Whether an object schema declares a top-level property named `refused` (refused in an output, plan decision 4). */
|
|
65
|
+
export declare function declaresRefusedKey(schema: ContractSchema): boolean;
|
|
66
|
+
/** Design 4.5: within one major an input and an output may only gain optional properties, and an output's enums may gain values. */
|
|
67
|
+
export declare function contractSchemaGrowthProblems(previous: ContractSchema, next: ContractSchema, side: "input" | "output", at?: string): string[];
|
|
68
|
+
/** Whether two schemas are the same contract part (no growth either way). */
|
|
69
|
+
export declare function sameContractSchema(a: ContractSchema, b: ContractSchema): boolean;
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { REFUSAL_ANSWER_KEY } from "./plugin-services.js";
|
|
2
|
+
// M35 B1a (W16, design 4.2 and 4.5): the JSON Schema a contract's methods use, read into one canonical
|
|
3
|
+
// form the server checks every call with, the door compares versions with and the install screen reads
|
|
4
|
+
// the personal marks from. Only plain data: objects, lists, text, numbers, booleans, null, enums, an
|
|
5
|
+
// optional or nullable member. Every reader walks a bounded tree once; no pattern is ever applied to a
|
|
6
|
+
// value, and a problem names a path, never a value.
|
|
7
|
+
export const CONTRACT_SCHEMA_DEPTH_MAX = 8;
|
|
8
|
+
export const CONTRACT_SCHEMA_NODES_MAX = 512;
|
|
9
|
+
export const CONTRACT_SCHEMA_PROPERTIES_MAX = 64;
|
|
10
|
+
export const CONTRACT_SCHEMA_ENUM_MAX = 64;
|
|
11
|
+
export const CONTRACT_SCHEMA_TEXT_MAX = 200;
|
|
12
|
+
export const CONTRACT_PROPERTY_NAME_MAX = 64;
|
|
13
|
+
const FORMATS = ["uuid", "email", "date-time", "uri"];
|
|
14
|
+
/** Keys that describe a node for people and carry nothing the checker reads. */
|
|
15
|
+
const IGNORED = new Set(["$schema", "$id", "title", "description", "default", "examples", "additionalProperties"]);
|
|
16
|
+
const ALLOWED = {
|
|
17
|
+
object: new Set(["type", "properties", "required", "personal"]),
|
|
18
|
+
array: new Set(["type", "items", "minItems", "maxItems", "personal"]),
|
|
19
|
+
// `pattern` only beside a `format`: Zod writes its format's own pattern there, and the format's linear
|
|
20
|
+
// check below stands in for it. The pattern itself is never applied.
|
|
21
|
+
string: new Set(["type", "minLength", "maxLength", "enum", "format", "pattern", "personal"]),
|
|
22
|
+
number: new Set(["type", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "personal"]),
|
|
23
|
+
integer: new Set(["type", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "personal"]),
|
|
24
|
+
boolean: new Set(["type", "personal"]),
|
|
25
|
+
null: new Set(["type", "personal"]),
|
|
26
|
+
};
|
|
27
|
+
function isRecord(value) {
|
|
28
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
29
|
+
return false;
|
|
30
|
+
const proto = Object.getPrototypeOf(value);
|
|
31
|
+
return proto === Object.prototype || proto === null;
|
|
32
|
+
}
|
|
33
|
+
class Refused extends Error {
|
|
34
|
+
}
|
|
35
|
+
const join = (at, name) => (at === "" ? name : `${at}.${name}`);
|
|
36
|
+
const keyName = (key) => (key.length > 64 ? "a key" : key);
|
|
37
|
+
function nonNegativeInteger(value, at) {
|
|
38
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)
|
|
39
|
+
throw new Refused(`${at}: a whole number of 0 or more`);
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
function finite(value, at) {
|
|
43
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
44
|
+
throw new Refused(`${at}: a finite number`);
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
/** Reads `value` as a contract schema, or refuses it with the first problem's path. */
|
|
48
|
+
export function readContractSchema(value, options = {}) {
|
|
49
|
+
let nodes = 0;
|
|
50
|
+
const node = (raw, at, depth) => {
|
|
51
|
+
nodes += 1;
|
|
52
|
+
if (nodes > CONTRACT_SCHEMA_NODES_MAX)
|
|
53
|
+
throw new Refused(`the schema has more than ${CONTRACT_SCHEMA_NODES_MAX} parts`);
|
|
54
|
+
if (depth > CONTRACT_SCHEMA_DEPTH_MAX)
|
|
55
|
+
throw new Refused(`${at || "the schema"}: nested deeper than ${CONTRACT_SCHEMA_DEPTH_MAX}`);
|
|
56
|
+
if (!isRecord(raw))
|
|
57
|
+
throw new Refused(`${at || "the schema"}: a schema object`);
|
|
58
|
+
if (raw.personal !== undefined && raw.personal !== true)
|
|
59
|
+
throw new Refused(`${at || "the schema"}: personal must be true`);
|
|
60
|
+
const personal = raw.personal === true ? { personal: true } : {};
|
|
61
|
+
// { anyOf: [X, { type: "null" }] } in either order is X, nullable.
|
|
62
|
+
if (Object.hasOwn(raw, "anyOf")) {
|
|
63
|
+
for (const key of Object.keys(raw))
|
|
64
|
+
if (key !== "anyOf" && key !== "personal" && !IGNORED.has(key))
|
|
65
|
+
throw new Refused(`${at || "the schema"}: ${keyName(key)} beside anyOf`);
|
|
66
|
+
const branches = raw.anyOf;
|
|
67
|
+
if (!Array.isArray(branches) || branches.length !== 2)
|
|
68
|
+
throw new Refused(`${at || "the schema"}: anyOf only as one schema or null`);
|
|
69
|
+
const nullAt = branches.findIndex((branch) => isRecord(branch) && branch.type === "null" && Object.keys(branch).every((key) => key === "type" || IGNORED.has(key)));
|
|
70
|
+
if (nullAt === -1)
|
|
71
|
+
throw new Refused(`${at || "the schema"}: anyOf only as one schema or null`);
|
|
72
|
+
const inner = node(branches[1 - nullAt], at, depth);
|
|
73
|
+
return { ...inner, nullable: true, ...personal };
|
|
74
|
+
}
|
|
75
|
+
if (Object.hasOwn(raw, "const")) {
|
|
76
|
+
for (const key of Object.keys(raw))
|
|
77
|
+
if (key !== "const" && key !== "type" && key !== "personal" && !IGNORED.has(key))
|
|
78
|
+
throw new Refused(`${at || "the schema"}: ${keyName(key)} beside const`);
|
|
79
|
+
if (typeof raw.const !== "string" || raw.const.length > CONTRACT_SCHEMA_TEXT_MAX)
|
|
80
|
+
throw new Refused(`${at || "the schema"}: const only as text`);
|
|
81
|
+
return { type: "string", enum: [raw.const], ...personal };
|
|
82
|
+
}
|
|
83
|
+
// { type: [X, "null"] } in either order is X, nullable: z.toJSONSchema writes `.nullable()` on a node
|
|
84
|
+
// with no other keyword this way (`z.string().nullable()`), and as the anyOf above otherwise. Any other
|
|
85
|
+
// type list is refused below.
|
|
86
|
+
if (Array.isArray(raw.type) && raw.type.length === 2) {
|
|
87
|
+
const nullAt = raw.type.indexOf("null");
|
|
88
|
+
const other = nullAt === -1 ? undefined : raw.type[1 - nullAt];
|
|
89
|
+
if (typeof other === "string" && other !== "null" && Object.hasOwn(ALLOWED, other)) {
|
|
90
|
+
return { ...node({ ...raw, type: other }, at, depth), nullable: true };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const type = raw.type;
|
|
94
|
+
if (typeof type !== "string" || !Object.hasOwn(ALLOWED, type))
|
|
95
|
+
throw new Refused(`${at || "the schema"}: type must be one of object, array, string, number, integer, boolean, null`);
|
|
96
|
+
const allowed = ALLOWED[type];
|
|
97
|
+
for (const key of Object.keys(raw)) {
|
|
98
|
+
if (!IGNORED.has(key) && !allowed.has(key))
|
|
99
|
+
throw new Refused(`${at || "the schema"}: ${keyName(key)} is not part of a contract schema`);
|
|
100
|
+
}
|
|
101
|
+
switch (type) {
|
|
102
|
+
case "object": {
|
|
103
|
+
const properties = raw.properties ?? {};
|
|
104
|
+
if (!isRecord(properties))
|
|
105
|
+
throw new Refused(`${at || "the schema"}: properties must be an object`);
|
|
106
|
+
const names = Object.keys(properties);
|
|
107
|
+
if (names.length > CONTRACT_SCHEMA_PROPERTIES_MAX)
|
|
108
|
+
throw new Refused(`${at || "the schema"}: more than ${CONTRACT_SCHEMA_PROPERTIES_MAX} properties`);
|
|
109
|
+
const required = raw.required ?? [];
|
|
110
|
+
if (!Array.isArray(required) || required.some((name) => typeof name !== "string" || !names.includes(name)))
|
|
111
|
+
throw new Refused(`${at || "the schema"}: required must name declared properties`);
|
|
112
|
+
return {
|
|
113
|
+
type: "object",
|
|
114
|
+
...personal,
|
|
115
|
+
properties: names.map((name) => {
|
|
116
|
+
if (name.length === 0 || name.length > CONTRACT_PROPERTY_NAME_MAX)
|
|
117
|
+
throw new Refused(`${at || "the schema"}: a property name of 1 to ${CONTRACT_PROPERTY_NAME_MAX} characters`);
|
|
118
|
+
return { name, schema: node(properties[name], join(join(at, "properties"), name), depth + 1), required: required.includes(name) };
|
|
119
|
+
}),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
case "array":
|
|
123
|
+
return {
|
|
124
|
+
type: "array",
|
|
125
|
+
...personal,
|
|
126
|
+
items: node(raw.items, join(at, "items"), depth + 1),
|
|
127
|
+
...(raw.minItems !== undefined ? { minItems: nonNegativeInteger(raw.minItems, join(at, "minItems")) } : {}),
|
|
128
|
+
...(raw.maxItems !== undefined ? { maxItems: nonNegativeInteger(raw.maxItems, join(at, "maxItems")) } : {}),
|
|
129
|
+
};
|
|
130
|
+
case "string": {
|
|
131
|
+
const values = raw.enum;
|
|
132
|
+
if (values !== undefined && (!Array.isArray(values) || values.length === 0 || values.length > CONTRACT_SCHEMA_ENUM_MAX || values.some((v) => typeof v !== "string" || v.length > CONTRACT_SCHEMA_TEXT_MAX))) {
|
|
133
|
+
throw new Refused(`${at || "the schema"}: enum must list 1 to ${CONTRACT_SCHEMA_ENUM_MAX} texts`);
|
|
134
|
+
}
|
|
135
|
+
if (raw.format !== undefined && !FORMATS.some((format) => format === raw.format))
|
|
136
|
+
throw new Refused(`${at || "the schema"}: format must be one of ${FORMATS.join(", ")}`);
|
|
137
|
+
if (raw.pattern !== undefined && raw.format === undefined)
|
|
138
|
+
throw new Refused(`${at || "the schema"}: pattern is not part of a contract schema (only beside a format, whose own check stands in for it)`);
|
|
139
|
+
return {
|
|
140
|
+
type: "string",
|
|
141
|
+
...personal,
|
|
142
|
+
...(raw.minLength !== undefined ? { minLength: nonNegativeInteger(raw.minLength, join(at, "minLength")) } : {}),
|
|
143
|
+
...(raw.maxLength !== undefined ? { maxLength: nonNegativeInteger(raw.maxLength, join(at, "maxLength")) } : {}),
|
|
144
|
+
...(values !== undefined ? { enum: [...values] } : {}),
|
|
145
|
+
...(raw.format !== undefined ? { format: raw.format } : {}),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
case "number":
|
|
149
|
+
case "integer":
|
|
150
|
+
if (Object.hasOwn(raw, "enum"))
|
|
151
|
+
throw new Refused(`${at || "the schema"}: enum only on text`);
|
|
152
|
+
return {
|
|
153
|
+
type,
|
|
154
|
+
...personal,
|
|
155
|
+
...(raw.minimum !== undefined ? { minimum: finite(raw.minimum, join(at, "minimum")) } : {}),
|
|
156
|
+
...(raw.maximum !== undefined ? { maximum: finite(raw.maximum, join(at, "maximum")) } : {}),
|
|
157
|
+
...(raw.exclusiveMinimum !== undefined ? { exclusiveMinimum: finite(raw.exclusiveMinimum, join(at, "exclusiveMinimum")) } : {}),
|
|
158
|
+
...(raw.exclusiveMaximum !== undefined ? { exclusiveMaximum: finite(raw.exclusiveMaximum, join(at, "exclusiveMaximum")) } : {}),
|
|
159
|
+
};
|
|
160
|
+
default:
|
|
161
|
+
return { type: type, ...personal };
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
try {
|
|
165
|
+
const schema = node(value, "", 0);
|
|
166
|
+
if (options.root === "object" && (schema.type !== "object" || schema.nullable === true))
|
|
167
|
+
return { ok: false, problem: "the schema must be an object" };
|
|
168
|
+
return { ok: true, schema };
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
return { ok: false, problem: error instanceof Refused ? error.message : "the schema could not be read" };
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/** A UUID's 36 characters: hyphens at 8, 13, 18 and 23, hex digits elsewhere. */
|
|
175
|
+
function isUuid(text) {
|
|
176
|
+
if (text.length !== 36)
|
|
177
|
+
return false;
|
|
178
|
+
for (let i = 0; i < 36; i++) {
|
|
179
|
+
const code = text.charCodeAt(i);
|
|
180
|
+
if (i === 8 || i === 13 || i === 18 || i === 23) {
|
|
181
|
+
if (code !== 45)
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
else if (!((code >= 48 && code <= 57) || (code >= 97 && code <= 102) || (code >= 65 && code <= 70)))
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
/** A light form check: one "@" with text on both sides and no space. The two plugins judge the rest. */
|
|
190
|
+
function isEmailShaped(text) {
|
|
191
|
+
const at = text.indexOf("@");
|
|
192
|
+
return at > 0 && at === text.lastIndexOf("@") && at < text.length - 1 && !text.includes(" ");
|
|
193
|
+
}
|
|
194
|
+
function formatHolds(format, text) {
|
|
195
|
+
if (format === "uuid")
|
|
196
|
+
return isUuid(text);
|
|
197
|
+
if (format === "email")
|
|
198
|
+
return isEmailShaped(text);
|
|
199
|
+
if (format === "date-time")
|
|
200
|
+
return text.length <= 40 && !Number.isNaN(Date.parse(text));
|
|
201
|
+
if (text.length > 2048)
|
|
202
|
+
return false;
|
|
203
|
+
try {
|
|
204
|
+
new URL(text);
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/** Checks `value` (already plain data: the broker parses its JSON first) and answers a copy with only the declared properties. */
|
|
212
|
+
export function checkContractValue(schema, value) {
|
|
213
|
+
const walk = (node, current, at) => {
|
|
214
|
+
const where = at || "the value";
|
|
215
|
+
if (current === null) {
|
|
216
|
+
if (node.nullable === true || node.type === "null")
|
|
217
|
+
return null;
|
|
218
|
+
throw new Refused(`${where}: null is not allowed`);
|
|
219
|
+
}
|
|
220
|
+
switch (node.type) {
|
|
221
|
+
case "object": {
|
|
222
|
+
if (!isRecord(current))
|
|
223
|
+
throw new Refused(`${where}: an object`);
|
|
224
|
+
const out = {};
|
|
225
|
+
for (const property of node.properties) {
|
|
226
|
+
const present = Object.hasOwn(current, property.name) && current[property.name] !== undefined;
|
|
227
|
+
if (!present) {
|
|
228
|
+
if (property.required)
|
|
229
|
+
throw new Refused(`${join(at, property.name)}: missing`);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
out[property.name] = walk(property.schema, current[property.name], join(at, property.name));
|
|
233
|
+
}
|
|
234
|
+
return out;
|
|
235
|
+
}
|
|
236
|
+
case "array": {
|
|
237
|
+
if (!Array.isArray(current))
|
|
238
|
+
throw new Refused(`${where}: a list`);
|
|
239
|
+
if (node.maxItems !== undefined && current.length > node.maxItems)
|
|
240
|
+
throw new Refused(`${where}: at most ${node.maxItems} items`);
|
|
241
|
+
if (node.minItems !== undefined && current.length < node.minItems)
|
|
242
|
+
throw new Refused(`${where}: at least ${node.minItems} items`);
|
|
243
|
+
return current.map((item, index) => walk(node.items, item, `${at}[${index}]`));
|
|
244
|
+
}
|
|
245
|
+
case "string": {
|
|
246
|
+
if (typeof current !== "string")
|
|
247
|
+
throw new Refused(`${where}: text`);
|
|
248
|
+
if (node.maxLength !== undefined && current.length > node.maxLength)
|
|
249
|
+
throw new Refused(`${where}: at most ${node.maxLength} characters`);
|
|
250
|
+
if (node.minLength !== undefined && current.length < node.minLength)
|
|
251
|
+
throw new Refused(`${where}: at least ${node.minLength} characters`);
|
|
252
|
+
if (node.enum !== undefined && !node.enum.includes(current))
|
|
253
|
+
throw new Refused(`${where}: not one of its values`);
|
|
254
|
+
if (node.format !== undefined && !formatHolds(node.format, current))
|
|
255
|
+
throw new Refused(`${where}: not a ${node.format}`);
|
|
256
|
+
return current;
|
|
257
|
+
}
|
|
258
|
+
case "number":
|
|
259
|
+
case "integer": {
|
|
260
|
+
if (typeof current !== "number" || !Number.isFinite(current))
|
|
261
|
+
throw new Refused(`${where}: a number`);
|
|
262
|
+
if (node.type === "integer" && !Number.isSafeInteger(current))
|
|
263
|
+
throw new Refused(`${where}: a whole number`);
|
|
264
|
+
if (node.minimum !== undefined && current < node.minimum)
|
|
265
|
+
throw new Refused(`${where}: below its minimum`);
|
|
266
|
+
if (node.maximum !== undefined && current > node.maximum)
|
|
267
|
+
throw new Refused(`${where}: above its maximum`);
|
|
268
|
+
if (node.exclusiveMinimum !== undefined && current <= node.exclusiveMinimum)
|
|
269
|
+
throw new Refused(`${where}: below its minimum`);
|
|
270
|
+
if (node.exclusiveMaximum !== undefined && current >= node.exclusiveMaximum)
|
|
271
|
+
throw new Refused(`${where}: above its maximum`);
|
|
272
|
+
return current;
|
|
273
|
+
}
|
|
274
|
+
case "boolean":
|
|
275
|
+
if (typeof current !== "boolean")
|
|
276
|
+
throw new Refused(`${where}: true or false`);
|
|
277
|
+
return current;
|
|
278
|
+
default:
|
|
279
|
+
throw new Refused(`${where}: null`);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
try {
|
|
283
|
+
return { ok: true, value: walk(schema, value, "") };
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
return { ok: false, problem: error instanceof Refused ? error.message : "the value could not be checked" };
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/** The paths of every field marked personal: `a.b` for a property, `a[].b` inside a list, in declaration order. */
|
|
290
|
+
export function personalPaths(schema) {
|
|
291
|
+
const out = [];
|
|
292
|
+
const walk = (node, at) => {
|
|
293
|
+
if (node.personal === true && at !== "")
|
|
294
|
+
out.push(at);
|
|
295
|
+
if (node.type === "object")
|
|
296
|
+
for (const property of node.properties)
|
|
297
|
+
walk(property.schema, join(at, property.name));
|
|
298
|
+
if (node.type === "array")
|
|
299
|
+
walk(node.items, `${at}[]`);
|
|
300
|
+
};
|
|
301
|
+
walk(schema, "");
|
|
302
|
+
return out;
|
|
303
|
+
}
|
|
304
|
+
/** Every property name in the tree, in walk order (the secret-like name guard reads these). */
|
|
305
|
+
export function schemaPropertyNames(schema) {
|
|
306
|
+
const out = [];
|
|
307
|
+
const walk = (node) => {
|
|
308
|
+
if (node.type === "object") {
|
|
309
|
+
for (const property of node.properties) {
|
|
310
|
+
out.push(property.name);
|
|
311
|
+
walk(property.schema);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (node.type === "array")
|
|
315
|
+
walk(node.items);
|
|
316
|
+
};
|
|
317
|
+
walk(schema);
|
|
318
|
+
return out;
|
|
319
|
+
}
|
|
320
|
+
/** Whether an object schema declares a top-level property named `refused` (refused in an output, plan decision 4). */
|
|
321
|
+
export function declaresRefusedKey(schema) {
|
|
322
|
+
return schema.type === "object" && schema.properties.some((property) => property.name === REFUSAL_ANSWER_KEY);
|
|
323
|
+
}
|
|
324
|
+
/** The node's own limits as one comparable text (its bounds and format, never its children). */
|
|
325
|
+
function limitsOf(node) {
|
|
326
|
+
if (node.type === "string")
|
|
327
|
+
return JSON.stringify([node.minLength, node.maxLength, node.format]);
|
|
328
|
+
if (node.type === "number" || node.type === "integer")
|
|
329
|
+
return JSON.stringify([node.minimum, node.maximum, node.exclusiveMinimum, node.exclusiveMaximum]);
|
|
330
|
+
if (node.type === "array")
|
|
331
|
+
return JSON.stringify([node.minItems, node.maxItems]);
|
|
332
|
+
return "";
|
|
333
|
+
}
|
|
334
|
+
/** Design 4.5: within one major an input and an output may only gain optional properties, and an output's enums may gain values. */
|
|
335
|
+
export function contractSchemaGrowthProblems(previous, next, side, at = "") {
|
|
336
|
+
const where = at === "" ? "the schema" : at;
|
|
337
|
+
if (previous.type !== next.type)
|
|
338
|
+
return [`${where}: its type changed`];
|
|
339
|
+
if ((previous.nullable === true) !== (next.nullable === true))
|
|
340
|
+
return [`${where}: its null rule changed`];
|
|
341
|
+
if ((previous.personal === true) !== (next.personal === true))
|
|
342
|
+
return [`${where}: its personal mark changed`];
|
|
343
|
+
if (limitsOf(previous) !== limitsOf(next))
|
|
344
|
+
return [`${where}: its limits changed`];
|
|
345
|
+
const problems = [];
|
|
346
|
+
if (previous.type === "string" && next.type === "string" && (previous.enum !== undefined || next.enum !== undefined)) {
|
|
347
|
+
const before = previous.enum;
|
|
348
|
+
const after = next.enum;
|
|
349
|
+
const grew = before !== undefined && after !== undefined && before.every((value) => after.includes(value));
|
|
350
|
+
const same = grew && after.length === before.length;
|
|
351
|
+
if (!(same || (side === "output" && grew)))
|
|
352
|
+
problems.push(`${where}: its values changed`);
|
|
353
|
+
}
|
|
354
|
+
if (previous.type === "array" && next.type === "array")
|
|
355
|
+
problems.push(...contractSchemaGrowthProblems(previous.items, next.items, side, `${at}[]`));
|
|
356
|
+
if (previous.type === "object" && next.type === "object") {
|
|
357
|
+
for (const before of previous.properties) {
|
|
358
|
+
const after = next.properties.find((property) => property.name === before.name);
|
|
359
|
+
const path = join(at, before.name);
|
|
360
|
+
if (after === undefined) {
|
|
361
|
+
problems.push(`${path}: removed`);
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (!before.required && after.required)
|
|
365
|
+
problems.push(`${path}: made required`);
|
|
366
|
+
else if (before.required && !after.required)
|
|
367
|
+
problems.push(`${path}: made optional`);
|
|
368
|
+
problems.push(...contractSchemaGrowthProblems(before.schema, after.schema, side, path));
|
|
369
|
+
}
|
|
370
|
+
for (const after of next.properties) {
|
|
371
|
+
if (after.required && !previous.properties.some((property) => property.name === after.name))
|
|
372
|
+
problems.push(`${join(at, after.name)}: added as required`);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return problems;
|
|
376
|
+
}
|
|
377
|
+
/** Whether two schemas are the same contract part (no growth either way). */
|
|
378
|
+
export function sameContractSchema(a, b) {
|
|
379
|
+
return contractSchemaGrowthProblems(a, b, "input").length === 0 && contractSchemaGrowthProblems(b, a, "input").length === 0;
|
|
380
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { contractOfDocument } from "./plugin-contract-document.js";
|
|
2
|
+
// M35 B1c (design 4.9a point 1b): the TypeScript an author's project keeps beside a contract copy, made
|
|
3
|
+
// locally from a checked document. Every identifier printed is a checked camel member name (or one made
|
|
4
|
+
// from it); every key and enum value goes through JSON.stringify; no label, description or other free
|
|
5
|
+
// text is printed, so a document cannot put code into the author's build.
|
|
6
|
+
export function pascalName(member) {
|
|
7
|
+
return member.charAt(0).toUpperCase() + member.slice(1);
|
|
8
|
+
}
|
|
9
|
+
function typeOf(node, indent) {
|
|
10
|
+
let body;
|
|
11
|
+
switch (node.type) {
|
|
12
|
+
case "object": {
|
|
13
|
+
if (node.properties.length === 0)
|
|
14
|
+
body = "Record<string, never>";
|
|
15
|
+
else {
|
|
16
|
+
const inner = `${indent} `;
|
|
17
|
+
const lines = node.properties.map((property) => `${property.schema.personal === true ? `${inner}/** Personal data. */\n` : ""}${inner}${JSON.stringify(property.name)}${property.required ? "" : "?"}: ${typeOf(property.schema, inner)};`);
|
|
18
|
+
body = `{\n${lines.join("\n")}\n${indent}}`;
|
|
19
|
+
}
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
case "array":
|
|
23
|
+
body = `Array<${typeOf(node.items, indent)}>`;
|
|
24
|
+
break;
|
|
25
|
+
case "string":
|
|
26
|
+
body = node.enum !== undefined ? node.enum.map((value) => JSON.stringify(value)).join(" | ") : "string";
|
|
27
|
+
break;
|
|
28
|
+
case "number":
|
|
29
|
+
case "integer":
|
|
30
|
+
body = "number";
|
|
31
|
+
break;
|
|
32
|
+
case "boolean":
|
|
33
|
+
body = "boolean";
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
body = "null";
|
|
37
|
+
}
|
|
38
|
+
return node.nullable === true && node.type !== "null" ? `${body} | null` : body;
|
|
39
|
+
}
|
|
40
|
+
export function contractTypesSource(document) {
|
|
41
|
+
const contract = contractOfDocument(document);
|
|
42
|
+
if (contract === null)
|
|
43
|
+
throw new TypeError("contractTypesSource: the document's methods do not read as a contract");
|
|
44
|
+
const out = [
|
|
45
|
+
`// Generated by Kardalum from ${document.contract} ${document.version}. Do not edit:`,
|
|
46
|
+
"// run `kardalum plugin contract add` to refresh it.",
|
|
47
|
+
'import type { PluginServiceContext } from "@kardalum/plugin-sdk/manifest";',
|
|
48
|
+
"",
|
|
49
|
+
`export const CONTRACT = ${JSON.stringify(document.contract)} as const;`,
|
|
50
|
+
`export const VERSION = ${JSON.stringify(document.version)} as const;`,
|
|
51
|
+
"",
|
|
52
|
+
];
|
|
53
|
+
const methods = [];
|
|
54
|
+
const implementation = [];
|
|
55
|
+
for (const method of contract.methods) {
|
|
56
|
+
const name = pascalName(method.name);
|
|
57
|
+
// An interface needs an object body; an input with no properties is `Record<string, never>`, which only a type alias can name.
|
|
58
|
+
out.push(method.input.type === "object" && method.input.properties.length > 0 ? `export interface ${name}Input ${typeOf(method.input, "")}` : `export type ${name}Input = ${typeOf(method.input, "")};`);
|
|
59
|
+
out.push(`export type ${name}Output = ${typeOf(method.output, "")};`);
|
|
60
|
+
out.push(`export type ${name}Refusal = ${method.refusals.length === 0 ? "never" : method.refusals.map((code) => JSON.stringify(code)).join(" | ")};`);
|
|
61
|
+
out.push(`export type ${name}Answer = ${method.refusals.length === 0 ? `${name}Output` : `${name}Output | { refused: ${name}Refusal }`};`);
|
|
62
|
+
out.push("");
|
|
63
|
+
methods.push(` ${method.name}: { input: ${name}Input; output: ${name}Output; refusal: ${name}Refusal };`);
|
|
64
|
+
implementation.push(` ${method.name}(input: ${name}Input, context: PluginServiceContext): ${name}Answer | Promise<${name}Answer>;`);
|
|
65
|
+
}
|
|
66
|
+
out.push(`export interface Methods {\n${methods.join("\n")}\n}`, "", `export interface Implementation {\n${implementation.join("\n")}\n}`, "");
|
|
67
|
+
return out.join("\n");
|
|
68
|
+
}
|
|
@@ -179,6 +179,24 @@ export declare const PluginDocsReferenceResponseSchema: z.ZodObject<{
|
|
|
179
179
|
id: z.ZodString;
|
|
180
180
|
action: z.ZodString;
|
|
181
181
|
}, z.core.$strict>>>;
|
|
182
|
+
contentSlots: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
183
|
+
kind: z.ZodEnum<{
|
|
184
|
+
filter: "filter";
|
|
185
|
+
column: "column";
|
|
186
|
+
badge: "badge";
|
|
187
|
+
bulkAction: "bulkAction";
|
|
188
|
+
}>;
|
|
189
|
+
label: z.ZodString;
|
|
190
|
+
documentTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
191
|
+
id: z.ZodString;
|
|
192
|
+
action: z.ZodString;
|
|
193
|
+
}, z.core.$strict>>>;
|
|
194
|
+
adminSlots: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
195
|
+
slot: z.ZodString;
|
|
196
|
+
label: z.ZodString;
|
|
197
|
+
id: z.ZodString;
|
|
198
|
+
action: z.ZodString;
|
|
199
|
+
}, z.core.$strict>>>;
|
|
182
200
|
hooks: z.ZodArray<z.ZodString>;
|
|
183
201
|
scheduledTasks: z.ZodArray<z.ZodObject<{
|
|
184
202
|
id: z.ZodString;
|