@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,124 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { contributionIssuesAt, contributionOf } from "./contribution-issues.js";
|
|
3
|
+
import { PluginLabelSchema } from "./plugin-labels.js";
|
|
4
|
+
// M35 U2b (W8, design 4.13): the four visitor points. Rules shared by the SDK's manifest schema, the
|
|
5
|
+
// delivery check `visitor accounts` and the door. The functions (`data`, `export`, `erase`) are
|
|
6
|
+
// checked by the SDK's runtime schema: manifest.json carries none.
|
|
7
|
+
export const PLUGIN_VISITOR_GROUPS_MAX = 20;
|
|
8
|
+
export const PLUGIN_VISITOR_ACCOUNT_SECTIONS_MAX = 3;
|
|
9
|
+
export const PLUGIN_VISITOR_POINT_ID_MAX = 40;
|
|
10
|
+
/** A declared group's or section's id: 1 to 40 of a-z, 0-9, "-" and "_", a letter first. A linear scan. */
|
|
11
|
+
export function isPluginVisitorPointId(value) {
|
|
12
|
+
if (typeof value !== "string" || value.length === 0 || value.length > PLUGIN_VISITOR_POINT_ID_MAX)
|
|
13
|
+
return false;
|
|
14
|
+
for (let i = 0; i < value.length; i++) {
|
|
15
|
+
const c = value.charCodeAt(i);
|
|
16
|
+
const letter = c >= 97 && c <= 122;
|
|
17
|
+
if (i === 0 ? !letter : !(letter || (c >= 48 && c <= 57) || c === 45 || c === 95))
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
const PointId = z.string().max(PLUGIN_VISITOR_POINT_ID_MAX).refine(isPluginVisitorPointId, { message: "An id is 1 to 40 of a-z, 0-9, '-' and '_', a letter first." });
|
|
23
|
+
export const PluginVisitorIdentitySchema = z.strictObject({ email: z.literal(true).optional() });
|
|
24
|
+
export const PluginVisitorGroupsSchema = z.array(z.strictObject({ id: PointId, label: PluginLabelSchema })).min(1).max(PLUGIN_VISITOR_GROUPS_MAX);
|
|
25
|
+
export const PluginVisitorAccountSectionsSchema = z
|
|
26
|
+
.array(z.object({ id: PointId, label: PluginLabelSchema, partial: z.string().min(1).max(191) }))
|
|
27
|
+
.min(1)
|
|
28
|
+
.max(PLUGIN_VISITOR_ACCOUNT_SECTIONS_MAX);
|
|
29
|
+
export const PluginVisitorDataSchema = z.object({});
|
|
30
|
+
export function pluginVisitorGroupKey(pluginId, id) {
|
|
31
|
+
return `${pluginId}/${id}`;
|
|
32
|
+
}
|
|
33
|
+
export const VISITOR_POINTS_WITHOUT_DATA_WARNING = "declares visitorIdentity without visitorData: if it keeps anything by visitor id, declare visitorData so an account's export and deletion reach it";
|
|
34
|
+
const issuesAt = contributionIssuesAt;
|
|
35
|
+
/** The most `templates` entries read for a section's partial: a section naming a partial past it is refused (the safe side). */
|
|
36
|
+
export const VISITOR_SECTION_PARTIAL_SCAN_MAX = 2000;
|
|
37
|
+
/** The aliases of the plugin's own templates of kind `partial`. */
|
|
38
|
+
function partialAliasesOf(manifest) {
|
|
39
|
+
const templates = contributionOf(manifest, "templates");
|
|
40
|
+
const out = new Set();
|
|
41
|
+
if (!Array.isArray(templates))
|
|
42
|
+
return out;
|
|
43
|
+
for (const entry of templates.slice(0, VISITOR_SECTION_PARTIAL_SCAN_MAX)) {
|
|
44
|
+
if (entry === null || typeof entry !== "object")
|
|
45
|
+
continue;
|
|
46
|
+
const { alias, kind } = entry;
|
|
47
|
+
if (kind === "partial" && typeof alias === "string")
|
|
48
|
+
out.add(alias);
|
|
49
|
+
}
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
function twiceIssues(key, entries) {
|
|
53
|
+
const seen = new Set();
|
|
54
|
+
const out = [];
|
|
55
|
+
entries.forEach((entry, index) => {
|
|
56
|
+
if (seen.has(entry.id))
|
|
57
|
+
out.push({ path: ["contributions", key, index, "id"], message: `${key} id "${entry.id}" is declared twice` });
|
|
58
|
+
seen.add(entry.id);
|
|
59
|
+
});
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
/** An array longer than `max`: refused by its length alone, before any entry is parsed. */
|
|
63
|
+
function overLength(value, max) {
|
|
64
|
+
return Array.isArray(value) && value.length > max;
|
|
65
|
+
}
|
|
66
|
+
function tooManyIssue(key, max) {
|
|
67
|
+
return { path: ["contributions", key], message: `${key} declares at most ${max} entries` };
|
|
68
|
+
}
|
|
69
|
+
const NEEDS_IDENTITY = ["visitorGroups", "visitorAccountSections", "visitorData"];
|
|
70
|
+
/** The issues of a manifest's visitor point declarations, in order: each declared key against its schema,
|
|
71
|
+
* a point declared without visitorIdentity, an id declared twice, a section naming a partial the plugin
|
|
72
|
+
* does not ship. A manifest that declares none has none. */
|
|
73
|
+
export function checkVisitorPointDeclarations(manifest) {
|
|
74
|
+
const issues = [];
|
|
75
|
+
const identity = contributionOf(manifest, "visitorIdentity");
|
|
76
|
+
const groups = contributionOf(manifest, "visitorGroups");
|
|
77
|
+
const sections = contributionOf(manifest, "visitorAccountSections");
|
|
78
|
+
const data = contributionOf(manifest, "visitorData");
|
|
79
|
+
// An array over its bound is refused by its length alone, before any entry is parsed.
|
|
80
|
+
const groupsTooMany = overLength(groups, PLUGIN_VISITOR_GROUPS_MAX);
|
|
81
|
+
const sectionsTooMany = overLength(sections, PLUGIN_VISITOR_ACCOUNT_SECTIONS_MAX);
|
|
82
|
+
const parsedGroups = groups === undefined || groupsTooMany ? undefined : PluginVisitorGroupsSchema.safeParse(groups);
|
|
83
|
+
const parsedSections = sections === undefined || sectionsTooMany ? undefined : PluginVisitorAccountSectionsSchema.safeParse(sections);
|
|
84
|
+
if (identity !== undefined) {
|
|
85
|
+
const parsed = PluginVisitorIdentitySchema.safeParse(identity);
|
|
86
|
+
if (!parsed.success)
|
|
87
|
+
issues.push(...issuesAt("visitorIdentity", parsed.error));
|
|
88
|
+
}
|
|
89
|
+
if (groupsTooMany)
|
|
90
|
+
issues.push(tooManyIssue("visitorGroups", PLUGIN_VISITOR_GROUPS_MAX));
|
|
91
|
+
if (parsedGroups !== undefined && !parsedGroups.success)
|
|
92
|
+
issues.push(...issuesAt("visitorGroups", parsedGroups.error));
|
|
93
|
+
if (sectionsTooMany)
|
|
94
|
+
issues.push(tooManyIssue("visitorAccountSections", PLUGIN_VISITOR_ACCOUNT_SECTIONS_MAX));
|
|
95
|
+
if (parsedSections !== undefined && !parsedSections.success)
|
|
96
|
+
issues.push(...issuesAt("visitorAccountSections", parsedSections.error));
|
|
97
|
+
if (data !== undefined) {
|
|
98
|
+
const parsed = PluginVisitorDataSchema.safeParse(data);
|
|
99
|
+
if (!parsed.success)
|
|
100
|
+
issues.push(...issuesAt("visitorData", parsed.error));
|
|
101
|
+
}
|
|
102
|
+
if (identity === undefined) {
|
|
103
|
+
for (const key of NEEDS_IDENTITY) {
|
|
104
|
+
if (contributionOf(manifest, key) !== undefined)
|
|
105
|
+
issues.push({ path: ["contributions", key], message: `${key} needs visitorIdentity` });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (parsedGroups?.success)
|
|
109
|
+
issues.push(...twiceIssues("visitorGroups", parsedGroups.data));
|
|
110
|
+
if (parsedSections?.success)
|
|
111
|
+
issues.push(...twiceIssues("visitorAccountSections", parsedSections.data));
|
|
112
|
+
if (parsedSections?.success) {
|
|
113
|
+
const partials = partialAliasesOf(manifest);
|
|
114
|
+
parsedSections.data.forEach((section, index) => {
|
|
115
|
+
if (!partials.has(section.partial)) {
|
|
116
|
+
issues.push({
|
|
117
|
+
path: ["contributions", "visitorAccountSections", index, "partial"],
|
|
118
|
+
message: `visitorAccountSections "${section.id}" names partial "${section.partial}", which is not one of this plugin's partial templates`,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return issues;
|
|
124
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The core's dependency tag kinds: a page printed, a page whose children or descendants were listed, a type listed,
|
|
3
|
+
* and an ancestor of the rendered page (`under:<id>`, so a change of a page purges every page below it).
|
|
4
|
+
*/
|
|
5
|
+
export declare const RENDER_CACHE_TAG_KINDS: readonly ["page", "list", "type", "under"];
|
|
6
|
+
export type RenderCacheTagKind = (typeof RENDER_CACHE_TAG_KINDS)[number];
|
|
7
|
+
/** The tag of a render any change can alter (a search, an overflow); every change's tags include it. */
|
|
8
|
+
export declare const RENDER_CACHE_TAG_ALL = "all";
|
|
9
|
+
/** The tags one render keeps at most; past it the render's tags are its page and `all`. */
|
|
10
|
+
export declare const RENDER_DEPENDENCY_TAGS_MAX = 100;
|
|
11
|
+
/** The ancestors a change's tags name at most, and the nearest ancestors a render notes as `under:` tags. */
|
|
12
|
+
export declare const RENDER_CACHE_ANCESTORS_MAX = 64;
|
|
13
|
+
/** `<kind>:<id>`; the caller hands a page or type id (a UUID), written in lower case as the stored ids are. */
|
|
14
|
+
export declare function renderCacheTag(kind: RenderCacheTagKind, id: string): string;
|
|
15
|
+
/** Whether `tag` is one the core writes: `all`, or a kind, ":" and a UUID. The length is checked first. */
|
|
16
|
+
export declare function isRenderCacheTag(tag: unknown): tag is string;
|
|
17
|
+
/** The plugins asked for one page's cache answer, in plugin id order; a fifth is skipped and logged. */
|
|
18
|
+
export declare const PAGE_CACHE_PLUGINS_MAX = 4;
|
|
19
|
+
/** How long the core waits for one plugin's answer, in milliseconds. */
|
|
20
|
+
export declare const PAGE_CACHE_TIME_MS = 50;
|
|
21
|
+
/** How long the core waits for every plugin's answer of one response together, the plugins' calls only. */
|
|
22
|
+
export declare const PAGE_CACHE_TIME_PER_RESPONSE_MS = 100;
|
|
23
|
+
/** The longest max-age or s-maxage, one year, in seconds. */
|
|
24
|
+
export declare const PAGE_CACHE_AGE_MAX = 31536000;
|
|
25
|
+
/** The longest stale-while-revalidate or stale-if-error, one week, in seconds. */
|
|
26
|
+
export declare const PAGE_CACHE_STALE_MAX = 604800;
|
|
27
|
+
/** The longest tag, in characters. */
|
|
28
|
+
export declare const PAGE_CACHE_TAG_MAX = 100;
|
|
29
|
+
/** The tags one plugin's answer gives at most; more refuses the answer. As many as a response carries, so a plugin can
|
|
30
|
+
* hand back every one of the render's RENDER_DEPENDENCY_TAGS_MAX dependencies with tags of its own. */
|
|
31
|
+
export declare const PAGE_CACHE_TAGS_PER_PLUGIN_MAX = 128;
|
|
32
|
+
/** The tags one response carries at most, all plugins together. */
|
|
33
|
+
export declare const PAGE_CACHE_TAGS_MAX = 128;
|
|
34
|
+
/** The bytes of tags one response carries at most (each tag and one separator). */
|
|
35
|
+
export declare const PAGE_CACHE_TAG_BYTES_MAX = 8192;
|
|
36
|
+
/** M35 P4 (W32): what a plugin's `pageCache.headers` answers. The core writes the headers itself. */
|
|
37
|
+
export interface PageCacheAnswer {
|
|
38
|
+
maxAgeSeconds?: number;
|
|
39
|
+
sharedMaxAgeSeconds?: number;
|
|
40
|
+
staleWhileRevalidateSeconds?: number;
|
|
41
|
+
staleIfErrorSeconds?: number;
|
|
42
|
+
tags?: readonly string[];
|
|
43
|
+
noStore?: true;
|
|
44
|
+
}
|
|
45
|
+
/** Why a tag is refused, or null: 1 to PAGE_CACHE_TAG_MAX letters, digits, "-", "_", "." and ":", so no CDN's list separator can split it. */
|
|
46
|
+
export declare function pageCacheTagProblem(tag: unknown): string | null;
|
|
47
|
+
/**
|
|
48
|
+
* A page cache answer read without trusting it: a plain object (prototype Object or none) of the known keys only,
|
|
49
|
+
* whole seconds within their caps, `noStore` only as `true`, at most PAGE_CACHE_TAGS_PER_PLUGIN_MAX tags. A tag the
|
|
50
|
+
* tag rule refuses is dropped and counted; anything else refuses the whole answer. A getter is the plugin's code: a
|
|
51
|
+
* throw while reading refuses the answer.
|
|
52
|
+
*/
|
|
53
|
+
export declare function readPageCacheAnswer(raw: unknown): {
|
|
54
|
+
ok: true;
|
|
55
|
+
answer: PageCacheAnswer;
|
|
56
|
+
refusedTags: number;
|
|
57
|
+
} | {
|
|
58
|
+
ok: false;
|
|
59
|
+
};
|
|
60
|
+
/** M35 P4 (W32): several plugins' answers as one: the strictest. */
|
|
61
|
+
export interface MergedPageCache {
|
|
62
|
+
noStore: boolean;
|
|
63
|
+
maxAgeSeconds: number | null;
|
|
64
|
+
sharedMaxAgeSeconds: number | null;
|
|
65
|
+
staleWhileRevalidateSeconds: number | null;
|
|
66
|
+
staleIfErrorSeconds: number | null;
|
|
67
|
+
tags: string[];
|
|
68
|
+
/** Tags left out past PAGE_CACHE_TAGS_MAX or PAGE_CACHE_TAG_BYTES_MAX. */
|
|
69
|
+
droppedTags: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* `noStore` from any answer wins; the tags are the union in answer order, capped, a dropped tag counted once. Each
|
|
73
|
+
* age is the strictest of what each answer alone would write (M35 P4 fix wave): an answer that gives an age counts
|
|
74
|
+
* as `max-age` its maxAgeSeconds or 0, as its shared age its sharedMaxAgeSeconds or else its maxAgeSeconds (max-age
|
|
75
|
+
* alone bounds shared caches too), and as each stale time the one it gives or 0; an answer that gives no age bounds
|
|
76
|
+
* only the stale times it gives. A merged value is null when no answer gives that kind.
|
|
77
|
+
*/
|
|
78
|
+
export declare function mergePageCacheAnswers(answers: readonly PageCacheAnswer[]): MergedPageCache;
|
|
79
|
+
/**
|
|
80
|
+
* The header lines for a merged answer: `Cache-Control: no-store` alone; else a `public` Cache-Control when an age is
|
|
81
|
+
* given (`s-maxage` only when it differs from `max-age`, stale times only beside an age), `Vary: Accept-Language`
|
|
82
|
+
* whenever any line is written and the language came from the visitor's header (a CDN keeps an answer of tags alone
|
|
83
|
+
* for its own default time), and the tags as `Surrogate-Key` (space separated) and `Cache-Tag` (comma separated).
|
|
84
|
+
*/
|
|
85
|
+
export declare function pageCacheHeaderLines(merged: MergedPageCache, options: {
|
|
86
|
+
varyLanguage: boolean;
|
|
87
|
+
}): Array<[string, string]>;
|
|
88
|
+
/** The page gates asked a page, in plugin id order; a fifth is skipped and logged. */
|
|
89
|
+
export declare const PAGE_GATES_MAX = 4;
|
|
90
|
+
/** How long the core waits for one gate, in milliseconds. */
|
|
91
|
+
export declare const PAGE_GATE_TIME_MS = 50;
|
|
92
|
+
/** How long the core waits for all gates of one page together, the plugins' calls only. */
|
|
93
|
+
export declare const PAGE_GATE_TIME_PER_REQUEST_MS = 100;
|
|
94
|
+
/** One plugin's renders running at once at most. */
|
|
95
|
+
export declare const RENDER_PAGE_RUNNING_PER_PLUGIN_MAX = 2;
|
|
96
|
+
/** All plugins' renders running at once on one server at most. */
|
|
97
|
+
export declare const RENDER_PAGE_RUNNING_MAX = 4;
|
|
98
|
+
/** The renders one plugin starts in one minute at most. */
|
|
99
|
+
export declare const RENDER_PAGE_PER_MINUTE_MAX = 120;
|
|
100
|
+
/** How long the core waits for one render, in milliseconds. */
|
|
101
|
+
export declare const RENDER_PAGE_TIME_MS = 10000;
|
|
102
|
+
/** The largest page renderPage hands back, 5 MiB (a site route answer's cap). */
|
|
103
|
+
export declare const RENDER_PAGE_HTML_MAX_BYTES = 5242880;
|
|
104
|
+
/** Why renderPage refused (RenderPageRefusedError.reason). */
|
|
105
|
+
export declare const RENDER_PAGE_REFUSALS: readonly ["unavailable", "inactive", "nested", "busy", "timeout", "tooLarge", "failed"];
|
|
106
|
+
export type RenderPageRefusal = (typeof RENDER_PAGE_REFUSALS)[number];
|
|
107
|
+
/** M35 P4 (W32): what `context.renderCache.purge` takes. */
|
|
108
|
+
export type RenderCachePurgeTarget = {
|
|
109
|
+
tags: string[];
|
|
110
|
+
} | {
|
|
111
|
+
all: true;
|
|
112
|
+
};
|
|
113
|
+
/** A purge target read without trusting it: `{ all: true }`, or `{ tags }` of 1 to PAGE_CACHE_TAGS_MAX core tags. */
|
|
114
|
+
export declare function readRenderCachePurgeTarget(raw: unknown): {
|
|
115
|
+
ok: true;
|
|
116
|
+
target: RenderCachePurgeTarget;
|
|
117
|
+
} | {
|
|
118
|
+
ok: false;
|
|
119
|
+
problem: string;
|
|
120
|
+
};
|
|
121
|
+
/** The query keys a template reads at most; the rest are ignored. */
|
|
122
|
+
export declare const TEMPLATE_QUERY_PARAMS_MAX = 20;
|
|
123
|
+
/** The longest query key a template reads, in characters. */
|
|
124
|
+
export declare const TEMPLATE_QUERY_KEY_MAX = 64;
|
|
125
|
+
/** The longest query value a template reads, in characters; a longer one is left out. */
|
|
126
|
+
export declare const TEMPLATE_QUERY_VALUE_MAX = 500;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { UuidStringSchema } from "./uuid.schema.js";
|
|
2
|
+
// M35 P4 (W32, W46, W53): the render cache, the page gate and rendering a page on demand. Every rule over
|
|
3
|
+
// a plugin's answer or a tag is one forward loop over a length-capped string, never a pattern match.
|
|
4
|
+
/**
|
|
5
|
+
* The core's dependency tag kinds: a page printed, a page whose children or descendants were listed, a type listed,
|
|
6
|
+
* and an ancestor of the rendered page (`under:<id>`, so a change of a page purges every page below it).
|
|
7
|
+
*/
|
|
8
|
+
export const RENDER_CACHE_TAG_KINDS = ["page", "list", "type", "under"];
|
|
9
|
+
/** The tag of a render any change can alter (a search, an overflow); every change's tags include it. */
|
|
10
|
+
export const RENDER_CACHE_TAG_ALL = "all";
|
|
11
|
+
/** The tags one render keeps at most; past it the render's tags are its page and `all`. */
|
|
12
|
+
export const RENDER_DEPENDENCY_TAGS_MAX = 100;
|
|
13
|
+
/** The ancestors a change's tags name at most, and the nearest ancestors a render notes as `under:` tags. */
|
|
14
|
+
export const RENDER_CACHE_ANCESTORS_MAX = 64;
|
|
15
|
+
/** The longest core tag: the longest kind ("under"), ":" and a UUID. */
|
|
16
|
+
const RENDER_CACHE_TAG_LENGTH_MAX = "under:".length + 36;
|
|
17
|
+
/** `<kind>:<id>`; the caller hands a page or type id (a UUID), written in lower case as the stored ids are. */
|
|
18
|
+
export function renderCacheTag(kind, id) {
|
|
19
|
+
return `${kind}:${id.toLowerCase()}`;
|
|
20
|
+
}
|
|
21
|
+
/** Whether `tag` is one the core writes: `all`, or a kind, ":" and a UUID. The length is checked first. */
|
|
22
|
+
export function isRenderCacheTag(tag) {
|
|
23
|
+
if (typeof tag !== "string" || tag.length === 0 || tag.length > RENDER_CACHE_TAG_LENGTH_MAX)
|
|
24
|
+
return false;
|
|
25
|
+
if (tag === RENDER_CACHE_TAG_ALL)
|
|
26
|
+
return true;
|
|
27
|
+
const colon = tag.indexOf(":");
|
|
28
|
+
if (colon < 0)
|
|
29
|
+
return false;
|
|
30
|
+
const kind = tag.slice(0, colon);
|
|
31
|
+
if (!RENDER_CACHE_TAG_KINDS.includes(kind))
|
|
32
|
+
return false;
|
|
33
|
+
const id = tag.slice(colon + 1);
|
|
34
|
+
return id.length === 36 && UuidStringSchema.safeParse(id).success;
|
|
35
|
+
}
|
|
36
|
+
/** The plugins asked for one page's cache answer, in plugin id order; a fifth is skipped and logged. */
|
|
37
|
+
export const PAGE_CACHE_PLUGINS_MAX = 4;
|
|
38
|
+
/** How long the core waits for one plugin's answer, in milliseconds. */
|
|
39
|
+
export const PAGE_CACHE_TIME_MS = 50;
|
|
40
|
+
/** How long the core waits for every plugin's answer of one response together, the plugins' calls only. */
|
|
41
|
+
export const PAGE_CACHE_TIME_PER_RESPONSE_MS = 100;
|
|
42
|
+
/** The longest max-age or s-maxage, one year, in seconds. */
|
|
43
|
+
export const PAGE_CACHE_AGE_MAX = 31_536_000;
|
|
44
|
+
/** The longest stale-while-revalidate or stale-if-error, one week, in seconds. */
|
|
45
|
+
export const PAGE_CACHE_STALE_MAX = 604_800;
|
|
46
|
+
/** The longest tag, in characters. */
|
|
47
|
+
export const PAGE_CACHE_TAG_MAX = 100;
|
|
48
|
+
/** The tags one plugin's answer gives at most; more refuses the answer. As many as a response carries, so a plugin can
|
|
49
|
+
* hand back every one of the render's RENDER_DEPENDENCY_TAGS_MAX dependencies with tags of its own. */
|
|
50
|
+
export const PAGE_CACHE_TAGS_PER_PLUGIN_MAX = 128;
|
|
51
|
+
/** The tags one response carries at most, all plugins together. */
|
|
52
|
+
export const PAGE_CACHE_TAGS_MAX = 128;
|
|
53
|
+
/** The bytes of tags one response carries at most (each tag and one separator). */
|
|
54
|
+
export const PAGE_CACHE_TAG_BYTES_MAX = 8_192;
|
|
55
|
+
const AGE_KEYS = ["maxAgeSeconds", "sharedMaxAgeSeconds"];
|
|
56
|
+
const STALE_KEYS = ["staleWhileRevalidateSeconds", "staleIfErrorSeconds"];
|
|
57
|
+
const ANSWER_KEYS = new Set([...AGE_KEYS, ...STALE_KEYS, "tags", "noStore"]);
|
|
58
|
+
const isTagCharacter = (code) => (code >= 0x30 && code <= 0x39) || (code >= 0x41 && code <= 0x5a) || (code >= 0x61 && code <= 0x7a) || code === 0x2d || code === 0x5f || code === 0x2e || code === 0x3a;
|
|
59
|
+
/** Why a tag is refused, or null: 1 to PAGE_CACHE_TAG_MAX letters, digits, "-", "_", "." and ":", so no CDN's list separator can split it. */
|
|
60
|
+
export function pageCacheTagProblem(tag) {
|
|
61
|
+
if (typeof tag !== "string")
|
|
62
|
+
return "is not a string";
|
|
63
|
+
if (tag.length === 0 || tag.length > PAGE_CACHE_TAG_MAX)
|
|
64
|
+
return `is 1 to ${PAGE_CACHE_TAG_MAX} characters`;
|
|
65
|
+
for (let index = 0; index < tag.length; index += 1) {
|
|
66
|
+
if (!isTagCharacter(tag.charCodeAt(index)))
|
|
67
|
+
return 'holds letters, digits, "-", "_", "." and ":" only';
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const wholeWithin = (value, max) => typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= max;
|
|
72
|
+
/**
|
|
73
|
+
* A page cache answer read without trusting it: a plain object (prototype Object or none) of the known keys only,
|
|
74
|
+
* whole seconds within their caps, `noStore` only as `true`, at most PAGE_CACHE_TAGS_PER_PLUGIN_MAX tags. A tag the
|
|
75
|
+
* tag rule refuses is dropped and counted; anything else refuses the whole answer. A getter is the plugin's code: a
|
|
76
|
+
* throw while reading refuses the answer.
|
|
77
|
+
*/
|
|
78
|
+
export function readPageCacheAnswer(raw) {
|
|
79
|
+
if (raw === null || typeof raw !== "object")
|
|
80
|
+
return { ok: false };
|
|
81
|
+
try {
|
|
82
|
+
if (Array.isArray(raw))
|
|
83
|
+
return { ok: false };
|
|
84
|
+
const prototype = Object.getPrototypeOf(raw);
|
|
85
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
86
|
+
return { ok: false };
|
|
87
|
+
const keys = Object.keys(raw);
|
|
88
|
+
if (keys.length > ANSWER_KEYS.size || keys.some((key) => !ANSWER_KEYS.has(key)))
|
|
89
|
+
return { ok: false };
|
|
90
|
+
const record = raw;
|
|
91
|
+
const answer = {};
|
|
92
|
+
for (const key of AGE_KEYS) {
|
|
93
|
+
const value = record[key];
|
|
94
|
+
if (value === undefined)
|
|
95
|
+
continue;
|
|
96
|
+
if (!wholeWithin(value, PAGE_CACHE_AGE_MAX))
|
|
97
|
+
return { ok: false };
|
|
98
|
+
answer[key] = value;
|
|
99
|
+
}
|
|
100
|
+
for (const key of STALE_KEYS) {
|
|
101
|
+
const value = record[key];
|
|
102
|
+
if (value === undefined)
|
|
103
|
+
continue;
|
|
104
|
+
if (!wholeWithin(value, PAGE_CACHE_STALE_MAX))
|
|
105
|
+
return { ok: false };
|
|
106
|
+
answer[key] = value;
|
|
107
|
+
}
|
|
108
|
+
const noStore = record.noStore;
|
|
109
|
+
if (noStore !== undefined) {
|
|
110
|
+
if (noStore !== true)
|
|
111
|
+
return { ok: false };
|
|
112
|
+
answer.noStore = true;
|
|
113
|
+
}
|
|
114
|
+
let refusedTags = 0;
|
|
115
|
+
const tags = record.tags;
|
|
116
|
+
if (tags !== undefined) {
|
|
117
|
+
if (!Array.isArray(tags) || tags.length > PAGE_CACHE_TAGS_PER_PLUGIN_MAX)
|
|
118
|
+
return { ok: false };
|
|
119
|
+
const kept = [];
|
|
120
|
+
for (let index = 0; index < tags.length; index += 1) {
|
|
121
|
+
const tag = tags[index];
|
|
122
|
+
if (pageCacheTagProblem(tag) === null)
|
|
123
|
+
kept.push(tag);
|
|
124
|
+
else
|
|
125
|
+
refusedTags += 1;
|
|
126
|
+
}
|
|
127
|
+
answer.tags = kept;
|
|
128
|
+
}
|
|
129
|
+
return { ok: true, answer, refusedTags };
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return { ok: false };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const smaller = (held, next) => (next === undefined ? held : held === null ? next : Math.min(held, next));
|
|
136
|
+
/**
|
|
137
|
+
* `noStore` from any answer wins; the tags are the union in answer order, capped, a dropped tag counted once. Each
|
|
138
|
+
* age is the strictest of what each answer alone would write (M35 P4 fix wave): an answer that gives an age counts
|
|
139
|
+
* as `max-age` its maxAgeSeconds or 0, as its shared age its sharedMaxAgeSeconds or else its maxAgeSeconds (max-age
|
|
140
|
+
* alone bounds shared caches too), and as each stale time the one it gives or 0; an answer that gives no age bounds
|
|
141
|
+
* only the stale times it gives. A merged value is null when no answer gives that kind.
|
|
142
|
+
*/
|
|
143
|
+
export function mergePageCacheAnswers(answers) {
|
|
144
|
+
const merged = { noStore: false, maxAgeSeconds: null, sharedMaxAgeSeconds: null, staleWhileRevalidateSeconds: null, staleIfErrorSeconds: null, tags: [], droppedTags: 0 };
|
|
145
|
+
const seen = new Set();
|
|
146
|
+
let bytes = 0;
|
|
147
|
+
const givesStale = (key) => answers.some((answer) => answer[key] !== undefined);
|
|
148
|
+
const staleWhileRevalidateGiven = givesStale("staleWhileRevalidateSeconds");
|
|
149
|
+
const staleIfErrorGiven = givesStale("staleIfErrorSeconds");
|
|
150
|
+
for (const answer of answers) {
|
|
151
|
+
if (answer.noStore === true)
|
|
152
|
+
merged.noStore = true;
|
|
153
|
+
if (answer.maxAgeSeconds !== undefined || answer.sharedMaxAgeSeconds !== undefined) {
|
|
154
|
+
merged.maxAgeSeconds = smaller(merged.maxAgeSeconds, answer.maxAgeSeconds ?? 0);
|
|
155
|
+
merged.sharedMaxAgeSeconds = smaller(merged.sharedMaxAgeSeconds, answer.sharedMaxAgeSeconds ?? answer.maxAgeSeconds);
|
|
156
|
+
if (staleWhileRevalidateGiven)
|
|
157
|
+
merged.staleWhileRevalidateSeconds = smaller(merged.staleWhileRevalidateSeconds, answer.staleWhileRevalidateSeconds ?? 0);
|
|
158
|
+
if (staleIfErrorGiven)
|
|
159
|
+
merged.staleIfErrorSeconds = smaller(merged.staleIfErrorSeconds, answer.staleIfErrorSeconds ?? 0);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
merged.staleWhileRevalidateSeconds = smaller(merged.staleWhileRevalidateSeconds, answer.staleWhileRevalidateSeconds);
|
|
163
|
+
merged.staleIfErrorSeconds = smaller(merged.staleIfErrorSeconds, answer.staleIfErrorSeconds);
|
|
164
|
+
}
|
|
165
|
+
for (const tag of answer.tags ?? []) {
|
|
166
|
+
if (seen.has(tag))
|
|
167
|
+
continue;
|
|
168
|
+
seen.add(tag);
|
|
169
|
+
if (merged.tags.length >= PAGE_CACHE_TAGS_MAX || bytes + tag.length + 1 > PAGE_CACHE_TAG_BYTES_MAX) {
|
|
170
|
+
merged.droppedTags += 1;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
bytes += tag.length + 1;
|
|
174
|
+
merged.tags.push(tag);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return merged;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The header lines for a merged answer: `Cache-Control: no-store` alone; else a `public` Cache-Control when an age is
|
|
181
|
+
* given (`s-maxage` only when it differs from `max-age`, stale times only beside an age), `Vary: Accept-Language`
|
|
182
|
+
* whenever any line is written and the language came from the visitor's header (a CDN keeps an answer of tags alone
|
|
183
|
+
* for its own default time), and the tags as `Surrogate-Key` (space separated) and `Cache-Tag` (comma separated).
|
|
184
|
+
*/
|
|
185
|
+
export function pageCacheHeaderLines(merged, options) {
|
|
186
|
+
if (merged.noStore)
|
|
187
|
+
return [["Cache-Control", "no-store"]];
|
|
188
|
+
const lines = [];
|
|
189
|
+
if (merged.maxAgeSeconds !== null || merged.sharedMaxAgeSeconds !== null) {
|
|
190
|
+
const maxAge = merged.maxAgeSeconds ?? 0;
|
|
191
|
+
const parts = ["public", `max-age=${maxAge}`];
|
|
192
|
+
if (merged.sharedMaxAgeSeconds !== null && merged.sharedMaxAgeSeconds !== maxAge)
|
|
193
|
+
parts.push(`s-maxage=${merged.sharedMaxAgeSeconds}`);
|
|
194
|
+
if (merged.staleWhileRevalidateSeconds !== null)
|
|
195
|
+
parts.push(`stale-while-revalidate=${merged.staleWhileRevalidateSeconds}`);
|
|
196
|
+
if (merged.staleIfErrorSeconds !== null)
|
|
197
|
+
parts.push(`stale-if-error=${merged.staleIfErrorSeconds}`);
|
|
198
|
+
lines.push(["Cache-Control", parts.join(", ")]);
|
|
199
|
+
}
|
|
200
|
+
if (options.varyLanguage && (lines.length > 0 || merged.tags.length > 0))
|
|
201
|
+
lines.push(["Vary", "Accept-Language"]);
|
|
202
|
+
if (merged.tags.length > 0) {
|
|
203
|
+
lines.push(["Surrogate-Key", merged.tags.join(" ")]);
|
|
204
|
+
lines.push(["Cache-Tag", merged.tags.join(",")]);
|
|
205
|
+
}
|
|
206
|
+
return lines;
|
|
207
|
+
}
|
|
208
|
+
/** The page gates asked a page, in plugin id order; a fifth is skipped and logged. */
|
|
209
|
+
export const PAGE_GATES_MAX = 4;
|
|
210
|
+
/** How long the core waits for one gate, in milliseconds. */
|
|
211
|
+
export const PAGE_GATE_TIME_MS = 50;
|
|
212
|
+
/** How long the core waits for all gates of one page together, the plugins' calls only. */
|
|
213
|
+
export const PAGE_GATE_TIME_PER_REQUEST_MS = 100;
|
|
214
|
+
/** One plugin's renders running at once at most. */
|
|
215
|
+
export const RENDER_PAGE_RUNNING_PER_PLUGIN_MAX = 2;
|
|
216
|
+
/** All plugins' renders running at once on one server at most. */
|
|
217
|
+
export const RENDER_PAGE_RUNNING_MAX = 4;
|
|
218
|
+
/** The renders one plugin starts in one minute at most. */
|
|
219
|
+
export const RENDER_PAGE_PER_MINUTE_MAX = 120;
|
|
220
|
+
/** How long the core waits for one render, in milliseconds. */
|
|
221
|
+
export const RENDER_PAGE_TIME_MS = 10_000;
|
|
222
|
+
/** The largest page renderPage hands back, 5 MiB (a site route answer's cap). */
|
|
223
|
+
export const RENDER_PAGE_HTML_MAX_BYTES = 5_242_880;
|
|
224
|
+
/** Why renderPage refused (RenderPageRefusedError.reason). */
|
|
225
|
+
export const RENDER_PAGE_REFUSALS = ["unavailable", "inactive", "nested", "busy", "timeout", "tooLarge", "failed"];
|
|
226
|
+
/** A purge target read without trusting it: `{ all: true }`, or `{ tags }` of 1 to PAGE_CACHE_TAGS_MAX core tags. */
|
|
227
|
+
export function readRenderCachePurgeTarget(raw) {
|
|
228
|
+
const no = (problem) => ({ ok: false, problem });
|
|
229
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
230
|
+
return no("purge takes { tags } or { all: true }");
|
|
231
|
+
let keys;
|
|
232
|
+
let all;
|
|
233
|
+
let tags;
|
|
234
|
+
try {
|
|
235
|
+
keys = Object.keys(raw);
|
|
236
|
+
all = raw.all;
|
|
237
|
+
tags = raw.tags;
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
return no("purge takes { tags } or { all: true }");
|
|
241
|
+
}
|
|
242
|
+
if (keys.length !== 1)
|
|
243
|
+
return no("purge takes { tags } or { all: true }");
|
|
244
|
+
if (keys[0] === "all")
|
|
245
|
+
return all === true ? { ok: true, target: { all: true } } : no("all is true");
|
|
246
|
+
if (keys[0] !== "tags" || !Array.isArray(tags) || tags.length === 0 || tags.length > PAGE_CACHE_TAGS_MAX)
|
|
247
|
+
return no(`tags holds 1 to ${PAGE_CACHE_TAGS_MAX} core tags`);
|
|
248
|
+
const out = [];
|
|
249
|
+
for (let index = 0; index < tags.length; index += 1) {
|
|
250
|
+
const tag = tags[index];
|
|
251
|
+
if (!isRenderCacheTag(tag))
|
|
252
|
+
return no('each tag is "all" or a page:, list:, type: or under: tag tagsOf answers');
|
|
253
|
+
// The stored ids are lower case; a kind and "all" are already.
|
|
254
|
+
out.push(tag.toLowerCase());
|
|
255
|
+
}
|
|
256
|
+
return { ok: true, target: { tags: out } };
|
|
257
|
+
}
|
|
258
|
+
/** The query keys a template reads at most; the rest are ignored. */
|
|
259
|
+
export const TEMPLATE_QUERY_PARAMS_MAX = 20;
|
|
260
|
+
/** The longest query key a template reads, in characters. */
|
|
261
|
+
export const TEMPLATE_QUERY_KEY_MAX = 64;
|
|
262
|
+
/** The longest query value a template reads, in characters; a longer one is left out. */
|
|
263
|
+
export const TEMPLATE_QUERY_VALUE_MAX = 500;
|