@kardalum/plugin-sdk 0.19.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 +281 -0
- package/README.md +19 -0
- package/dist/admin-section-registry.d.ts +48 -1
- package/dist/admin-section-registry.js +90 -0
- package/dist/built-in-editor-ids.d.ts +1 -1
- package/dist/built-in-editor-ids.js +2 -20
- package/dist/built-in-settings-schemas.d.ts +10 -0
- package/dist/built-in-settings-schemas.js +86 -0
- package/dist/built-in-value-schemas.js +35 -0
- package/dist/built-ins.js +38 -7
- package/dist/capabilities.d.ts +11 -1
- package/dist/capabilities.js +101 -4
- package/dist/cli.d.ts +66 -0
- package/dist/cli.js +22 -0
- package/dist/consent-entry.d.ts +11 -0
- package/dist/consent-entry.js +18 -0
- package/dist/content-library.d.ts +102 -0
- package/dist/content-library.js +15 -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 +15 -0
- package/dist/content-picker/page-picker-sheet.js +105 -0
- package/dist/content-picker/page-picker.d.ts +18 -0
- package/dist/content-picker/page-picker.js +20 -0
- package/dist/content-picker/page-tree.d.ts +25 -0
- package/dist/content-picker/page-tree.js +132 -0
- package/dist/data-type-plugin.d.ts +7 -1
- package/dist/datatype-validation.d.ts +4 -9
- package/dist/datatype-validation.js +147 -1
- package/dist/datatypes-entry.d.ts +1 -0
- package/dist/datatypes-entry.js +2 -0
- package/dist/entitlement-entry.d.ts +1 -1
- package/dist/entitlement-entry.js +1 -1
- package/dist/entitlement-gate.d.ts +14 -0
- package/dist/entitlement-gate.js +64 -7
- package/dist/entitlement-plan.d.ts +6 -0
- package/dist/entitlement-plan.js +10 -0
- package/dist/entitlement-types.d.ts +53 -12
- package/dist/entitlement.d.ts +31 -4
- package/dist/entitlement.js +58 -17
- package/dist/hook-entry.d.ts +5 -0
- package/dist/hook-entry.js +30 -0
- package/dist/host-entry.d.ts +7 -1
- package/dist/host-entry.js +14 -1
- package/dist/index.d.ts +67 -7
- package/dist/index.js +94 -6
- package/dist/mail.d.ts +34 -0
- package/dist/mail.js +1 -0
- package/dist/manifest-entry.d.ts +47 -4
- package/dist/manifest-entry.js +63 -2
- package/dist/manifest-schema.d.ts +993 -40
- package/dist/manifest-schema.js +516 -26
- package/dist/manifest.d.ts +1186 -62
- package/dist/manifest.js +8 -4
- package/dist/media/media-picker.js +31 -18
- package/dist/media/upload-error.d.ts +5 -1
- package/dist/media/upload-error.js +14 -2
- package/dist/media-library.d.ts +32 -0
- package/dist/media-library.js +15 -0
- package/dist/nested-field-host.d.ts +76 -0
- package/dist/nested-field-host.js +90 -0
- package/dist/notify.d.ts +12 -4
- package/dist/notify.js +1 -1
- package/dist/outbound.d.ts +47 -0
- package/dist/outbound.js +1 -0
- package/dist/plugin-context.d.ts +52 -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 +262 -9
- package/dist/plugin-screen-context.js +56 -0
- package/dist/providers.d.ts +313 -0
- package/dist/providers.js +74 -0
- package/dist/read-all-pages.d.ts +5 -0
- package/dist/read-all-pages.js +3 -2
- package/dist/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 +36 -25
- 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 +45 -22
- 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/style-listbox.js +6 -4
- 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 +344 -0
- package/dist/sdk-strings.js +411 -0
- package/dist/sealing.d.ts +14 -0
- package/dist/sealing.js +1 -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/simple-storage-value-provider.js +24 -24
- package/dist/structured-storage-types.d.ts +429 -9
- 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 -0
- package/dist/text-entry.js +7 -0
- package/dist/tokens/system-dark.css +1 -0
- package/dist/tokens/tailwind-theme.css +7 -0
- package/dist/tokens/tokens.css +19 -3
- package/dist/tokens/tokens.json +13 -4
- 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/asset-view.js +4 -1
- package/dist/views/content-list-preview.js +3 -1
- package/dist/views/content-list-settings-view.js +11 -7
- package/dist/views/content-list-view.d.ts +5 -3
- package/dist/views/content-list-view.js +243 -40
- package/dist/views/content-picker-view.d.ts +3 -0
- package/dist/views/content-picker-view.js +143 -0
- package/dist/views/crop-view.d.ts +4 -6
- package/dist/views/crop-view.js +22 -13
- package/dist/views/date-range-view.js +4 -1
- package/dist/views/file-upload-view.d.ts +5 -7
- package/dist/views/file-upload-view.js +16 -7
- package/dist/views/group-view.d.ts +8 -0
- package/dist/views/group-view.js +123 -0
- package/dist/views/html-view.js +7 -6
- package/dist/views/image-view.js +37 -19
- package/dist/views/link-view.d.ts +3 -0
- package/dist/views/link-view.js +150 -0
- package/dist/views/options-list-view.d.ts +3 -0
- package/dist/views/options-list-view.js +104 -0
- package/dist/views/repeatable-list-view.d.ts +3 -0
- package/dist/views/repeatable-list-view.js +113 -0
- package/dist/views/rich-text-view.d.ts +2 -0
- package/dist/views/rich-text-view.js +208 -35
- package/dist/views/suggest-key.d.ts +17 -0
- package/dist/views/suggest-key.js +55 -0
- 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 +334 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.js +254 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-context.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-context.schema.js +10 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +5 -0
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +11 -1
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +4 -2
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.d.ts +65 -0
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.js +144 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +115 -3
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +58 -11
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +137 -2
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +178 -2
- package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-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/content-search.schema.d.ts +50 -0
- package/node_modules/@kardalum/api-schemas/dist/content-search.schema.js +42 -0
- package/node_modules/@kardalum/api-schemas/dist/content-summary.schema.d.ts +37 -0
- package/node_modules/@kardalum/api-schemas/dist/content-summary.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/content-unpublish.schema.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/content-unpublish.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +3 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.js +10 -0
- package/node_modules/@kardalum/api-schemas/dist/contract-cancel.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/contract-cancel.schema.js +86 -0
- package/node_modules/@kardalum/api-schemas/dist/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 +55 -13
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +22 -10
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +25 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/data-type-issue.d.ts +35 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-issue.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +257 -15
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +78 -5
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +24 -6
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +90 -5
- 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/form-protection.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection.js +12 -0
- package/node_modules/@kardalum/api-schemas/dist/graphql-limits.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/graphql-limits.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/held-embed-words.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/held-embed-words.js +70 -0
- package/node_modules/@kardalum/api-schemas/dist/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 +162 -48
- package/node_modules/@kardalum/api-schemas/dist/index.js +137 -30
- package/node_modules/@kardalum/api-schemas/dist/install-sign-in-switched-off.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/install-sign-in-switched-off.schema.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/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/legal-anchors.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/legal-anchors.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +63 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +54 -0
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.d.ts +226 -0
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.js +409 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-leaks.schema.d.ts +145 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-leaks.schema.js +154 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +490 -10
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +53 -3
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-payouts.schema.d.ts +131 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-payouts.schema.js +272 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-profile.schema.d.ts +84 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-profile.schema.js +138 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-revocation.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-revocation.schema.js +49 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-sites.schema.d.ts +211 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-sites.schema.js +424 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.d.ts +78 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-tool-inputs.schema.d.ts +70 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-tool-inputs.schema.js +43 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +38 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +13 -1
- package/node_modules/@kardalum/api-schemas/dist/media-move.schema.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/media-move.schema.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-fields.schema.d.ts +204 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-fields.schema.js +370 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.d.ts +60 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.js +333 -0
- package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +5 -5
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +1 -2
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +1 -2
- package/node_modules/@kardalum/api-schemas/dist/notification-kinds.d.ts +145 -0
- package/node_modules/@kardalum/api-schemas/dist/notification-kinds.js +177 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +258 -7
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +96 -5
- package/node_modules/@kardalum/api-schemas/dist/page-address.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/page-address.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/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/password-reset.schema.d.ts +34 -0
- package/node_modules/@kardalum/api-schemas/dist/password-reset.schema.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +28 -3
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +55 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-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-caller.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-caller.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-cli-commands.d.ts +76 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-cli-commands.js +316 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.js +84 -0
- 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-data-type-configs.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-data-type-configs.js +131 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +44 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +44 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +16 -5
- package/node_modules/@kardalum/api-schemas/dist/plugin-document-types.d.ts +228 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-document-types.js +41 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.d.ts +34 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.js +102 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.d.ts +43 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.js +126 -0
- 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-field-info.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-field-info.js +51 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-graphql-fields.d.ts +32 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-graphql-fields.js +102 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-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 +119 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.js +216 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-https-origin.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-https-origin.js +21 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +46 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +41 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +304 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +220 -6
- 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-labels.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +29 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +32 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +120 -14
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +408 -14
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +307 -23
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +23 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +61 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-ai.d.ts +40 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-ai.js +139 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +23 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +37 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-media-access.d.ts +25 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-media-access.js +43 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.d.ts +107 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.js +150 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-package-build.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-package-build.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.d.ts +346 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.js +461 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +2 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-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-sealed-values.d.ts +45 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-sealed-values.js +99 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-secrets.d.ts +68 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-secrets.js +114 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-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 +352 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-settings.js +409 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.d.ts +347 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.js +976 -0
- 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-storage-api.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +47 -4
- 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-tasks.d.ts +45 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-tasks.js +197 -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/plural-rules.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/plural-rules.js +41 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +100 -12
- package/node_modules/@kardalum/api-schemas/dist/refund-request.schema.d.ts +189 -0
- package/node_modules/@kardalum/api-schemas/dist/refund-request.schema.js +164 -0
- package/node_modules/@kardalum/api-schemas/dist/render-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 +307 -4
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +61 -0
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +7 -3
- 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 +71 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.js +540 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-text.d.ts +66 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-text.js +394 -0
- package/node_modules/@kardalum/api-schemas/dist/sale-conditions.schema.d.ts +82 -0
- package/node_modules/@kardalum/api-schemas/dist/sale-conditions.schema.js +99 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +28 -0
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +201 -1
- 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 +97 -8
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +64 -1
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +136 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +53 -2
- 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 +386 -0
- package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.js +618 -0
- 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/snapshot-api.schema.d.ts +3 -3
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/structured-duplicate-key.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-duplicate-key.js +26 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.d.ts +70 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.js +188 -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/template.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/transaction-rolled-back.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/transaction-rolled-back.js +29 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-purge.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-purge.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +72 -1
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +36 -3
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +5 -1
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +4 -3
- package/node_modules/@kardalum/api-schemas/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 +2 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +15 -1
- package/node_modules/@kardalum/design-tokens/dist/system-dark.css +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +7 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +2 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +19 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +18 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +13 -4
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +5 -1
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +38 -2
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +17 -2
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +17 -10
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +625 -35
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +25 -0
- package/node_modules/@kardalum/plugin-package/dist/cms-range.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/cms-range.js +353 -0
- package/node_modules/@kardalum/plugin-package/dist/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/ai-declarations.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/ai-declarations.js +26 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +3 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/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.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.js +47 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +2 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.js +40 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/graphql-fields.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/graphql-fields.js +22 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +3 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +76 -6
- package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.d.ts +27 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.js +99 -0
- 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/locales.js +9 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/plugin-settings.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/plugin-settings.js +68 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.js +316 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +40 -4
- 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 +91 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.d.ts +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.js +150 -0
- 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.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.js +69 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +21 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +17 -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 +8 -2
- package/node_modules/@kardalum/plugin-package/dist/index.js +7 -1
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +75 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +123 -0
- package/node_modules/@kardalum/plugin-package/dist/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/switch.js +1 -1
- 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/components/tooltip.js +1 -2
- package/node_modules/@kardalum/ui/dist/components/truncated-text.d.ts +6 -1
- package/node_modules/@kardalum/ui/dist/components/truncated-text.js +5 -4
- package/node_modules/@kardalum/ui/dist/index.d.ts +2 -0
- package/node_modules/@kardalum/ui/dist/index.js +2 -0
- package/package.json +25 -3
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
// M33 K36 (Reading time 2.8 R3): the plain text of the editor's document and of HTML, with no
|
|
2
|
+
// dependency, no DOM and no node built-ins, so a plugin runs the same reader in its server code
|
|
3
|
+
// and in its browser bundle (`@kardalum/plugin-sdk/text`), and `@kardalum/client` re-exports
|
|
4
|
+
// `richTextToText` from here. `htmlToText` is one left-to-right pass over the input with no
|
|
5
|
+
// regular expression: every loop below moves the read position forward, so the cost is linear in
|
|
6
|
+
// the input it reads, which is itself capped.
|
|
7
|
+
//
|
|
8
|
+
// Both readers stop early on three limits and report the cut through `onCut`: `maxLength`
|
|
9
|
+
// characters of output, `RICH_TEXT_READ_NODES_MAX` nodes or tags visited (or 4 times `maxLength`
|
|
10
|
+
// with a floor of `RICH_TEXT_READ_NODES_FLOOR`, whichever is fewer, so a document of very many
|
|
11
|
+
// empty blocks, which add no character, is not walked in full), and for HTML
|
|
12
|
+
// `HTML_TO_TEXT_INPUT_MAX` characters of input. `richTextToText` called with no options reads as
|
|
13
|
+
// it did in 0.19 (`@kardalum/client`): no node cap, and the same output character for character.
|
|
14
|
+
import { RICH_TEXT_MAX_DEPTH } from "./rich-text-shape.js";
|
|
15
|
+
import { isSpace, namedTagAt, referenceAt, startsTag, tagEnd, tagNameAt } from "./html-scan.js";
|
|
16
|
+
/** How many nodes (rich text) or tags (HTML) a plain text reader visits before it stops. Not the
|
|
17
|
+
* stored shape's `RICH_TEXT_MAX_NODES` (20,000): this one bounds a read of any input. */
|
|
18
|
+
export const RICH_TEXT_READ_NODES_MAX = 100_000;
|
|
19
|
+
/** The fewest nodes or tags a reader given `maxLength` may visit, however small `maxLength` is,
|
|
20
|
+
* so a short excerpt behind a few images or empty blocks still finds its text. */
|
|
21
|
+
export const RICH_TEXT_READ_NODES_FLOOR = 1024;
|
|
22
|
+
/** How many characters of HTML `htmlToText` reads (2 MiB); the rest is not read. */
|
|
23
|
+
export const HTML_TO_TEXT_INPUT_MAX = 2 * 1024 * 1024;
|
|
24
|
+
/** Whether a value can be read as a node: an object that is not an array. */
|
|
25
|
+
export function isRichTextNode(value) {
|
|
26
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27
|
+
}
|
|
28
|
+
/** A node's children, or null when its `content` is not a list. */
|
|
29
|
+
export function richTextChildrenOf(node) {
|
|
30
|
+
return Array.isArray(node.content) ? node.content : null;
|
|
31
|
+
}
|
|
32
|
+
/** The node types that end a line of plain text. */
|
|
33
|
+
export const RICH_TEXT_TEXT_BLOCKS = new Set([
|
|
34
|
+
"paragraph",
|
|
35
|
+
"heading",
|
|
36
|
+
"listItem",
|
|
37
|
+
"blockquote",
|
|
38
|
+
"codeBlock",
|
|
39
|
+
"horizontalRule",
|
|
40
|
+
"tableRow",
|
|
41
|
+
"tableHeader",
|
|
42
|
+
"tableCell",
|
|
43
|
+
"pluginBlock",
|
|
44
|
+
"pluginWrapper",
|
|
45
|
+
]);
|
|
46
|
+
/** The collected text, with the limits it stops at. */
|
|
47
|
+
class TextSink {
|
|
48
|
+
maxLength;
|
|
49
|
+
parts = [];
|
|
50
|
+
length = 0;
|
|
51
|
+
visited = 0;
|
|
52
|
+
visitLimit;
|
|
53
|
+
/** Set once a limit is reached; the reader then stops. */
|
|
54
|
+
stopped = false;
|
|
55
|
+
cut = false;
|
|
56
|
+
/** `capped` false only for `richTextToText` called with no options, which reads as 0.19 did. */
|
|
57
|
+
constructor(maxLength, capped = true) {
|
|
58
|
+
this.maxLength = maxLength;
|
|
59
|
+
this.visitLimit = !capped
|
|
60
|
+
? Number.POSITIVE_INFINITY
|
|
61
|
+
: maxLength === Number.POSITIVE_INFINITY
|
|
62
|
+
? RICH_TEXT_READ_NODES_MAX
|
|
63
|
+
: Math.min(RICH_TEXT_READ_NODES_MAX, Math.max(RICH_TEXT_READ_NODES_FLOOR, maxLength * 4));
|
|
64
|
+
}
|
|
65
|
+
/** Counts one node or tag; false (and the reader stops) once the cap is passed. */
|
|
66
|
+
visit() {
|
|
67
|
+
if (this.stopped)
|
|
68
|
+
return false;
|
|
69
|
+
if (this.visited >= this.visitLimit) {
|
|
70
|
+
this.stop();
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
this.visited += 1;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
text(value) {
|
|
77
|
+
if (this.stopped || value.length === 0)
|
|
78
|
+
return;
|
|
79
|
+
const room = this.maxLength - this.length;
|
|
80
|
+
if (value.length <= room) {
|
|
81
|
+
this.parts.push(value);
|
|
82
|
+
this.length += value.length;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
let end = room;
|
|
86
|
+
// Never end on the first half of a surrogate pair.
|
|
87
|
+
if (end > 0 && isHighSurrogate(value.charCodeAt(end - 1)))
|
|
88
|
+
end -= 1;
|
|
89
|
+
if (end > 0) {
|
|
90
|
+
this.parts.push(value.slice(0, end));
|
|
91
|
+
this.length += end;
|
|
92
|
+
}
|
|
93
|
+
this.stop();
|
|
94
|
+
}
|
|
95
|
+
/** HTML text: each run of ASCII whitespace reads as one space, and none at the start of a
|
|
96
|
+
* line, as a browser shows it (in `pre` too). */
|
|
97
|
+
collapsedText(value) {
|
|
98
|
+
if (this.stopped || value.length === 0)
|
|
99
|
+
return;
|
|
100
|
+
const last = this.parts[this.parts.length - 1];
|
|
101
|
+
let afterSpace = last === undefined || isSpace(last.charCodeAt(last.length - 1));
|
|
102
|
+
let out = "";
|
|
103
|
+
let run = 0;
|
|
104
|
+
for (let index = 0; index < value.length; index++) {
|
|
105
|
+
if (!isSpace(value.charCodeAt(index))) {
|
|
106
|
+
afterSpace = false;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
out += value.slice(run, index);
|
|
110
|
+
if (!afterSpace) {
|
|
111
|
+
out += " ";
|
|
112
|
+
afterSpace = true;
|
|
113
|
+
}
|
|
114
|
+
run = index + 1;
|
|
115
|
+
}
|
|
116
|
+
out += value.slice(run);
|
|
117
|
+
this.text(out);
|
|
118
|
+
}
|
|
119
|
+
/** A hard break in the editor's document: a line break wherever it is, as in 0.19 (two in a
|
|
120
|
+
* row are a blank line). Past `maxLength` it is not written. */
|
|
121
|
+
hardBreak() {
|
|
122
|
+
if (this.stopped || this.length >= this.maxLength)
|
|
123
|
+
return;
|
|
124
|
+
this.parts.push("\n");
|
|
125
|
+
this.length += 1;
|
|
126
|
+
}
|
|
127
|
+
/** The end of a block in the editor's document: a line break unless nothing came yet or the
|
|
128
|
+
* last thing written was one, as in 0.19. Past `maxLength` it is not written. */
|
|
129
|
+
blockBreak() {
|
|
130
|
+
if (this.stopped)
|
|
131
|
+
return;
|
|
132
|
+
const last = this.parts[this.parts.length - 1];
|
|
133
|
+
if (last === undefined || last === "\n" || this.length >= this.maxLength)
|
|
134
|
+
return;
|
|
135
|
+
this.parts.push("\n");
|
|
136
|
+
this.length += 1;
|
|
137
|
+
}
|
|
138
|
+
/** A line break, written only after some text and never twice in a row. A break past
|
|
139
|
+
* `maxLength` is not written, and is a cut only if text follows it. */
|
|
140
|
+
lineBreak() {
|
|
141
|
+
if (this.stopped)
|
|
142
|
+
return;
|
|
143
|
+
const last = this.parts[this.parts.length - 1];
|
|
144
|
+
if (last === undefined || last.endsWith("\n"))
|
|
145
|
+
return;
|
|
146
|
+
if (this.length >= this.maxLength)
|
|
147
|
+
return;
|
|
148
|
+
this.parts.push("\n");
|
|
149
|
+
this.length += 1;
|
|
150
|
+
}
|
|
151
|
+
/** A break between two runs of HTML text: a space written just before it joins the break. */
|
|
152
|
+
softBreak() {
|
|
153
|
+
if (this.stopped)
|
|
154
|
+
return;
|
|
155
|
+
const last = this.parts[this.parts.length - 1];
|
|
156
|
+
if (last !== undefined && last.endsWith(" ")) {
|
|
157
|
+
if (last.length === 1)
|
|
158
|
+
this.parts.pop();
|
|
159
|
+
else
|
|
160
|
+
this.parts[this.parts.length - 1] = last.slice(0, -1);
|
|
161
|
+
this.length -= 1;
|
|
162
|
+
}
|
|
163
|
+
this.lineBreak();
|
|
164
|
+
}
|
|
165
|
+
/** A part of the document was left out without stopping the read (the depth cap). */
|
|
166
|
+
skipped() {
|
|
167
|
+
this.cut = true;
|
|
168
|
+
}
|
|
169
|
+
stop() {
|
|
170
|
+
this.stopped = true;
|
|
171
|
+
this.cut = true;
|
|
172
|
+
}
|
|
173
|
+
/** The text, without trailing line breaks (and, `trimSpace`, without a trailing space). */
|
|
174
|
+
result(onCut, trimSpace = false) {
|
|
175
|
+
if (this.cut)
|
|
176
|
+
onCut?.();
|
|
177
|
+
let end = this.parts.length;
|
|
178
|
+
while (end > 0 && this.parts[end - 1] === "\n")
|
|
179
|
+
end--;
|
|
180
|
+
const text = this.parts.slice(0, end).join("");
|
|
181
|
+
return trimSpace && text.endsWith(" ") ? text.slice(0, -1) : text;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function isHighSurrogate(code) {
|
|
185
|
+
return code >= 0xd800 && code <= 0xdbff;
|
|
186
|
+
}
|
|
187
|
+
function maxLengthOf(options) {
|
|
188
|
+
const maxLength = options?.maxLength;
|
|
189
|
+
if (maxLength === undefined)
|
|
190
|
+
return Number.POSITIVE_INFINITY;
|
|
191
|
+
if (typeof maxLength !== "number" || !Number.isInteger(maxLength) || maxLength < 0) {
|
|
192
|
+
throw new TypeError("maxLength must be a whole number of zero or more");
|
|
193
|
+
}
|
|
194
|
+
return maxLength;
|
|
195
|
+
}
|
|
196
|
+
function textNode(value, depth, sink) {
|
|
197
|
+
if (!isRichTextNode(value))
|
|
198
|
+
return;
|
|
199
|
+
if (depth > RICH_TEXT_MAX_DEPTH) {
|
|
200
|
+
sink.skipped();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (!sink.visit())
|
|
204
|
+
return;
|
|
205
|
+
if (value.type === "text") {
|
|
206
|
+
if (typeof value.text === "string")
|
|
207
|
+
sink.text(value.text);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (value.type === "hardBreak") {
|
|
211
|
+
sink.hardBreak();
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
// M35 C4a (design D11): a block or inline item reads as its short text; a wrapper as its content.
|
|
215
|
+
if (value.type === "pluginBlock" || value.type === "pluginInline") {
|
|
216
|
+
// M35 C4b (C4b-D5): an editorial item's short text is never plain text; a wrapper's content is read as before.
|
|
217
|
+
if (value.attrs?.editorial !== true) {
|
|
218
|
+
const text = value.attrs?.text;
|
|
219
|
+
if (typeof text === "string")
|
|
220
|
+
sink.text(text);
|
|
221
|
+
if (value.type === "pluginBlock")
|
|
222
|
+
sink.blockBreak();
|
|
223
|
+
}
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const content = richTextChildrenOf(value);
|
|
227
|
+
if (content !== null) {
|
|
228
|
+
for (const child of content) {
|
|
229
|
+
if (sink.stopped)
|
|
230
|
+
return;
|
|
231
|
+
textNode(child, depth + 1, sink);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (typeof value.type === "string" && RICH_TEXT_TEXT_BLOCKS.has(value.type))
|
|
235
|
+
sink.blockBreak();
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* A rich text field's value as plain text, for a search index, a summary or
|
|
239
|
+
* a native text view: the text runs in order, one line per block (a table
|
|
240
|
+
* cell is a block), a line break for a hard break. No markup, no escaping
|
|
241
|
+
* (the result is text, not HTML). A bare string comes back as it is (cut to
|
|
242
|
+
* `maxLength`). Stops at `maxLength` characters, and after
|
|
243
|
+
* `RICH_TEXT_READ_NODES_MAX` nodes or 4 times `maxLength` nodes (at least
|
|
244
|
+
* `RICH_TEXT_READ_NODES_FLOOR`), whichever is fewer; leaves out what lies
|
|
245
|
+
* past `RICH_TEXT_MAX_DEPTH` levels; `onCut` hears each. Called with no
|
|
246
|
+
* options (or neither option), it reads as 0.19's `@kardalum/client` did:
|
|
247
|
+
* the same text, with no node cap.
|
|
248
|
+
*/
|
|
249
|
+
export function richTextToText(doc, options) {
|
|
250
|
+
const capped = options !== undefined && (options.maxLength !== undefined || options.onCut !== undefined);
|
|
251
|
+
const sink = new TextSink(maxLengthOf(options), capped);
|
|
252
|
+
if (typeof doc === "string") {
|
|
253
|
+
sink.text(doc);
|
|
254
|
+
}
|
|
255
|
+
else if (isRichTextNode(doc)) {
|
|
256
|
+
textNode(doc, 0, sink);
|
|
257
|
+
}
|
|
258
|
+
return sink.result(options?.onCut);
|
|
259
|
+
}
|
|
260
|
+
// --- HTML ---
|
|
261
|
+
/** Elements whose contents give no text. */
|
|
262
|
+
const SKIPPED_ELEMENTS = new Set(["script", "style", "template"]);
|
|
263
|
+
/** Inline (phrasing) elements: their tags are no break, so `Kar<b>da</b>lum` reads as one word.
|
|
264
|
+
* A closed set; every other tag, `br` and `img` among them, reads as a break. */
|
|
265
|
+
const INLINE_ELEMENTS = new Set([
|
|
266
|
+
"a", "abbr", "b", "bdi", "bdo", "cite", "code", "data", "del", "dfn", "em", "font", "i", "ins",
|
|
267
|
+
"kbd", "mark", "q", "s", "samp", "small", "span", "strike", "strong", "sub", "sup", "time", "tt",
|
|
268
|
+
"u", "var", "wbr",
|
|
269
|
+
]);
|
|
270
|
+
/** The index just past the end tag of the skipped element `name` whose start tag ended at
|
|
271
|
+
* `from`, counting nested `template` tags; `end` when it is never closed. Each tag it steps
|
|
272
|
+
* over is visited. */
|
|
273
|
+
function skippedElementEnd(html, from, end, name, sink) {
|
|
274
|
+
let depth = 1;
|
|
275
|
+
let index = from;
|
|
276
|
+
while (index < end) {
|
|
277
|
+
const open = html.indexOf("<", index);
|
|
278
|
+
if (open === -1 || open >= end)
|
|
279
|
+
return end;
|
|
280
|
+
if (open + 1 < end && html.charCodeAt(open + 1) === 0x2f && namedTagAt(html, open + 2, end, name)) {
|
|
281
|
+
if (!sink.visit())
|
|
282
|
+
return end;
|
|
283
|
+
index = tagEnd(html, open, end);
|
|
284
|
+
depth -= 1;
|
|
285
|
+
if (depth === 0)
|
|
286
|
+
return index;
|
|
287
|
+
}
|
|
288
|
+
else if (name === "template" && namedTagAt(html, open + 1, end, name)) {
|
|
289
|
+
if (!sink.visit())
|
|
290
|
+
return end;
|
|
291
|
+
index = tagEnd(html, open, end);
|
|
292
|
+
depth += 1;
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
index = open + 1;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return end;
|
|
299
|
+
}
|
|
300
|
+
/** Writes the text between `from` and `to`, decoding character references. */
|
|
301
|
+
function writeText(html, from, to, sink) {
|
|
302
|
+
let run = from;
|
|
303
|
+
let index = from;
|
|
304
|
+
// A scan bounded by `to` (never `indexOf`, which would look past it on every call).
|
|
305
|
+
while (index < to && !sink.stopped) {
|
|
306
|
+
if (html.charCodeAt(index) !== 0x26) {
|
|
307
|
+
index++;
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
const reference = referenceAt(html, index, to);
|
|
311
|
+
if (reference === null) {
|
|
312
|
+
index++;
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
sink.collapsedText(html.slice(run, index));
|
|
316
|
+
sink.text(reference.text);
|
|
317
|
+
run = reference.next;
|
|
318
|
+
index = reference.next;
|
|
319
|
+
}
|
|
320
|
+
if (sink.stopped)
|
|
321
|
+
return;
|
|
322
|
+
sink.collapsedText(html.slice(run, to));
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* The text a reader sees in a piece of HTML, for a word count, a search index
|
|
326
|
+
* or an excerpt. One left-to-right pass, no regular expression, no DOM. A tag
|
|
327
|
+
* of an inline element (`a`, `b`, `em`, `span`, `strong` and the rest of a
|
|
328
|
+
* closed set) is no break, so `Kar<b>da</b>lum` is one word; every other tag
|
|
329
|
+
* (`br` and `img` too) reads as a line break, never at the start and never two
|
|
330
|
+
* in a row. Each run of ASCII whitespace reads as one space (none at the start
|
|
331
|
+
* of a line, before a break or at the end), as a browser shows it; a decoded
|
|
332
|
+
* ` ` stays. Comments and the contents of `script`, `style` and
|
|
333
|
+
* `template` give nothing; `<` starts a tag
|
|
334
|
+
* only before an ASCII letter, `/`, `!` or `?`, otherwise it is text.
|
|
335
|
+
* `&`, `<`, `>`, `"`, `'`, ` ` and numeric references
|
|
336
|
+
* (`'`, `'`) are decoded: a numeric reference to U+0000, a surrogate
|
|
337
|
+
* or past U+10FFFF becomes U+FFFD, and one longer than 7 decimal or 6 hex
|
|
338
|
+
* digits, or without its `;`, stays as written, as does any other named
|
|
339
|
+
* reference. Reads at most `HTML_TO_TEXT_INPUT_MAX` characters of input and
|
|
340
|
+
* stops at `maxLength` characters of output, or after `RICH_TEXT_READ_NODES_MAX`
|
|
341
|
+
* tags or 4 times `maxLength` tags (at least `RICH_TEXT_READ_NODES_FLOOR`),
|
|
342
|
+
* whichever is fewer; `onCut` hears each.
|
|
343
|
+
* Never throws for any string (a value that is not one gives "").
|
|
344
|
+
*/
|
|
345
|
+
export function htmlToText(html, options) {
|
|
346
|
+
const sink = new TextSink(maxLengthOf(options));
|
|
347
|
+
if (typeof html !== "string")
|
|
348
|
+
return "";
|
|
349
|
+
const end = Math.min(html.length, HTML_TO_TEXT_INPUT_MAX);
|
|
350
|
+
let index = 0;
|
|
351
|
+
let textStart = 0;
|
|
352
|
+
while (index < end && !sink.stopped) {
|
|
353
|
+
const open = html.indexOf("<", index);
|
|
354
|
+
if (open === -1 || open >= end)
|
|
355
|
+
break;
|
|
356
|
+
if (!startsTag(html, open, end)) {
|
|
357
|
+
index = open + 1;
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
writeText(html, textStart, open, sink);
|
|
361
|
+
if (sink.stopped || !sink.visit())
|
|
362
|
+
break;
|
|
363
|
+
const next = html.charCodeAt(open + 1);
|
|
364
|
+
if (next === 0x21 && html.startsWith("--", open + 2)) {
|
|
365
|
+
// A comment: skipped to its `-->`, with no break.
|
|
366
|
+
const close = html.indexOf("-->", open + 4);
|
|
367
|
+
index = close === -1 || close + 3 > end ? end : close + 3;
|
|
368
|
+
}
|
|
369
|
+
else if (next === 0x21 || next === 0x3f) {
|
|
370
|
+
// A declaration or a processing instruction: skipped to its `>`.
|
|
371
|
+
const close = html.indexOf(">", open + 2);
|
|
372
|
+
index = close === -1 || close >= end ? end : close + 1;
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
index = tagEnd(html, open, end);
|
|
376
|
+
const closing = next === 0x2f;
|
|
377
|
+
const name = tagNameAt(html, closing ? open + 2 : open + 1, end);
|
|
378
|
+
if (!INLINE_ELEMENTS.has(name))
|
|
379
|
+
sink.softBreak();
|
|
380
|
+
if (!closing) {
|
|
381
|
+
if (SKIPPED_ELEMENTS.has(name)) {
|
|
382
|
+
index = skippedElementEnd(html, index, end, name, sink);
|
|
383
|
+
sink.softBreak();
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
textStart = index;
|
|
388
|
+
}
|
|
389
|
+
if (!sink.stopped)
|
|
390
|
+
writeText(html, textStart, end, sink);
|
|
391
|
+
if (!sink.stopped && html.length > end)
|
|
392
|
+
sink.stop();
|
|
393
|
+
return sink.result(options?.onCut, true);
|
|
394
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const END_EFFECTS: readonly ["read_only", "off"];
|
|
3
|
+
export type EndEffect = (typeof END_EFFECTS)[number];
|
|
4
|
+
export declare const AFTER_DOWNLOAD_RULES: readonly ["author_decides", "not_refundable"];
|
|
5
|
+
export type AfterDownloadRule = (typeof AFTER_DOWNLOAD_RULES)[number];
|
|
6
|
+
export declare const SaleConditionsSchema: z.ZodObject<{
|
|
7
|
+
subscriptionStop: z.ZodEnum<{
|
|
8
|
+
off: "off";
|
|
9
|
+
read_only: "read_only";
|
|
10
|
+
}>;
|
|
11
|
+
subscriptionRefund: z.ZodEnum<{
|
|
12
|
+
off: "off";
|
|
13
|
+
read_only: "read_only";
|
|
14
|
+
}>;
|
|
15
|
+
oneTimeRefund: z.ZodEnum<{
|
|
16
|
+
off: "off";
|
|
17
|
+
read_only: "read_only";
|
|
18
|
+
}>;
|
|
19
|
+
afterDownload: z.ZodEnum<{
|
|
20
|
+
author_decides: "author_decides";
|
|
21
|
+
not_refundable: "not_refundable";
|
|
22
|
+
}>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
export type SaleConditions = z.infer<typeof SaleConditionsSchema>;
|
|
25
|
+
export declare const DEFAULT_SALE_CONDITIONS: SaleConditions;
|
|
26
|
+
/** A stored value read back: nothing gives the defaults; a refused value gives them with `fellBack` (the caller logs one line). */
|
|
27
|
+
export declare function readSaleConditions(raw: unknown): {
|
|
28
|
+
conditions: SaleConditions;
|
|
29
|
+
fellBack: boolean;
|
|
30
|
+
};
|
|
31
|
+
/** The metadata encoding, at most 60 characters. */
|
|
32
|
+
export declare function encodeSaleConditions(c: SaleConditions): string;
|
|
33
|
+
/** Split on the bar, never a pattern: five parts, "v1" first, then the schema. */
|
|
34
|
+
export declare function decodeSaleConditions(s: string): SaleConditions | null;
|
|
35
|
+
export type PlanShapeKind = "one_time" | "subscription";
|
|
36
|
+
export declare function planShapeKind(shape: string): PlanShapeKind | null;
|
|
37
|
+
/** The setting for an ending: a stop uses `subscriptionStop`; a refund uses `oneTimeRefund` for a one time plan, else `subscriptionRefund`. */
|
|
38
|
+
export declare function endEffectFor(c: SaleConditions, ending: "stop" | "refund", kind: PlanShapeKind): EndEffect;
|
|
39
|
+
export declare const SubmissionFieldsSchema: z.ZodObject<{
|
|
40
|
+
listingId: z.ZodOptional<z.ZodString>;
|
|
41
|
+
subscriptionStop: z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
off: "off";
|
|
43
|
+
read_only: "read_only";
|
|
44
|
+
}>>;
|
|
45
|
+
subscriptionRefund: z.ZodOptional<z.ZodEnum<{
|
|
46
|
+
off: "off";
|
|
47
|
+
read_only: "read_only";
|
|
48
|
+
}>>;
|
|
49
|
+
oneTimeRefund: z.ZodOptional<z.ZodEnum<{
|
|
50
|
+
off: "off";
|
|
51
|
+
read_only: "read_only";
|
|
52
|
+
}>>;
|
|
53
|
+
afterDownload: z.ZodOptional<z.ZodEnum<{
|
|
54
|
+
author_decides: "author_decides";
|
|
55
|
+
not_refundable: "not_refundable";
|
|
56
|
+
}>>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
export type SubmissionFields = z.infer<typeof SubmissionFieldsSchema>;
|
|
59
|
+
/** Byte limits for `receiveForm`. */
|
|
60
|
+
export declare const SUBMISSION_FIELD_LIMITS: {
|
|
61
|
+
readonly listingId: 64;
|
|
62
|
+
readonly subscriptionStop: 16;
|
|
63
|
+
readonly subscriptionRefund: 16;
|
|
64
|
+
readonly oneTimeRefund: 16;
|
|
65
|
+
readonly afterDownload: 16;
|
|
66
|
+
};
|
|
67
|
+
export declare function submissionFieldsOf(fields: Record<string, string>): {
|
|
68
|
+
listingId: string | null;
|
|
69
|
+
conditions: SaleConditions | null;
|
|
70
|
+
} | {
|
|
71
|
+
error: string;
|
|
72
|
+
};
|
|
73
|
+
/** The CMS release that reads the sale conditions; copy says "{release}". */
|
|
74
|
+
export declare const SALE_CONDITIONS_CMS_RELEASE = "0.20.0";
|
|
75
|
+
export declare const LicenseVerdictEndWireSchema: z.ZodObject<{
|
|
76
|
+
effect: z.ZodEnum<{
|
|
77
|
+
off: "off";
|
|
78
|
+
read_only: "read_only";
|
|
79
|
+
}>;
|
|
80
|
+
refunded: z.ZodBoolean;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
export type LicenseVerdictEndWire = z.infer<typeof LicenseVerdictEndWireSchema>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// M32 I6f (S1): the author's sale conditions, set once at upload on the listing:
|
|
3
|
+
// what happens on the buyer's site when a subscription stops or a sale is
|
|
4
|
+
// refunded, and whether a plugin is refundable after a download.
|
|
5
|
+
export const END_EFFECTS = ["read_only", "off"];
|
|
6
|
+
export const AFTER_DOWNLOAD_RULES = ["author_decides", "not_refundable"];
|
|
7
|
+
export const SaleConditionsSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
subscriptionStop: z.enum(END_EFFECTS),
|
|
10
|
+
subscriptionRefund: z.enum(END_EFFECTS),
|
|
11
|
+
oneTimeRefund: z.enum(END_EFFECTS),
|
|
12
|
+
afterDownload: z.enum(AFTER_DOWNLOAD_RULES),
|
|
13
|
+
})
|
|
14
|
+
.strict();
|
|
15
|
+
export const DEFAULT_SALE_CONDITIONS = {
|
|
16
|
+
subscriptionStop: "read_only",
|
|
17
|
+
subscriptionRefund: "off",
|
|
18
|
+
oneTimeRefund: "off",
|
|
19
|
+
afterDownload: "author_decides",
|
|
20
|
+
};
|
|
21
|
+
/** A stored value read back: nothing gives the defaults; a refused value gives them with `fellBack` (the caller logs one line). */
|
|
22
|
+
export function readSaleConditions(raw) {
|
|
23
|
+
if (raw === null || raw === undefined)
|
|
24
|
+
return { conditions: { ...DEFAULT_SALE_CONDITIONS }, fellBack: false };
|
|
25
|
+
const parsed = SaleConditionsSchema.safeParse(raw);
|
|
26
|
+
if (parsed.success)
|
|
27
|
+
return { conditions: parsed.data, fellBack: false };
|
|
28
|
+
return { conditions: { ...DEFAULT_SALE_CONDITIONS }, fellBack: true };
|
|
29
|
+
}
|
|
30
|
+
const ENCODING_VERSION = "v1";
|
|
31
|
+
/** The metadata encoding, at most 60 characters. */
|
|
32
|
+
export function encodeSaleConditions(c) {
|
|
33
|
+
return [ENCODING_VERSION, c.subscriptionStop, c.subscriptionRefund, c.oneTimeRefund, c.afterDownload].join("|");
|
|
34
|
+
}
|
|
35
|
+
/** Split on the bar, never a pattern: five parts, "v1" first, then the schema. */
|
|
36
|
+
export function decodeSaleConditions(s) {
|
|
37
|
+
if (typeof s !== "string" || s.length > 60)
|
|
38
|
+
return null;
|
|
39
|
+
const parts = s.split("|");
|
|
40
|
+
if (parts.length !== 5 || parts[0] !== ENCODING_VERSION)
|
|
41
|
+
return null;
|
|
42
|
+
const parsed = SaleConditionsSchema.safeParse({
|
|
43
|
+
subscriptionStop: parts[1],
|
|
44
|
+
subscriptionRefund: parts[2],
|
|
45
|
+
oneTimeRefund: parts[3],
|
|
46
|
+
afterDownload: parts[4],
|
|
47
|
+
});
|
|
48
|
+
return parsed.success ? parsed.data : null;
|
|
49
|
+
}
|
|
50
|
+
export function planShapeKind(shape) {
|
|
51
|
+
if (shape === "one_time")
|
|
52
|
+
return "one_time";
|
|
53
|
+
if (shape === "monthly" || shape === "yearly")
|
|
54
|
+
return "subscription";
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
/** The setting for an ending: a stop uses `subscriptionStop`; a refund uses `oneTimeRefund` for a one time plan, else `subscriptionRefund`. */
|
|
58
|
+
export function endEffectFor(c, ending, kind) {
|
|
59
|
+
if (ending === "stop")
|
|
60
|
+
return c.subscriptionStop;
|
|
61
|
+
return kind === "one_time" ? c.oneTimeRefund : c.subscriptionRefund;
|
|
62
|
+
}
|
|
63
|
+
export const SubmissionFieldsSchema = z
|
|
64
|
+
.object({
|
|
65
|
+
listingId: z.string().uuid().optional(),
|
|
66
|
+
subscriptionStop: z.enum(END_EFFECTS).optional(),
|
|
67
|
+
subscriptionRefund: z.enum(END_EFFECTS).optional(),
|
|
68
|
+
oneTimeRefund: z.enum(END_EFFECTS).optional(),
|
|
69
|
+
afterDownload: z.enum(AFTER_DOWNLOAD_RULES).optional(),
|
|
70
|
+
})
|
|
71
|
+
.refine((f) => {
|
|
72
|
+
const n = [f.subscriptionStop, f.subscriptionRefund, f.oneTimeRefund, f.afterDownload].filter((v) => v !== undefined).length;
|
|
73
|
+
return n === 0 || n === 4;
|
|
74
|
+
}, { message: "Choose all four sale conditions, or upload from the generic page." });
|
|
75
|
+
/** Byte limits for `receiveForm`. */
|
|
76
|
+
export const SUBMISSION_FIELD_LIMITS = { listingId: 64, subscriptionStop: 16, subscriptionRefund: 16, oneTimeRefund: 16, afterDownload: 16 };
|
|
77
|
+
export function submissionFieldsOf(fields) {
|
|
78
|
+
const pick = (k) => (typeof fields[k] === "string" && fields[k] !== "" ? fields[k] : undefined);
|
|
79
|
+
const parsed = SubmissionFieldsSchema.safeParse({
|
|
80
|
+
listingId: pick("listingId"),
|
|
81
|
+
subscriptionStop: pick("subscriptionStop"),
|
|
82
|
+
subscriptionRefund: pick("subscriptionRefund"),
|
|
83
|
+
oneTimeRefund: pick("oneTimeRefund"),
|
|
84
|
+
afterDownload: pick("afterDownload"),
|
|
85
|
+
});
|
|
86
|
+
if (!parsed.success)
|
|
87
|
+
return { error: parsed.error.issues[0]?.message ?? "The sale conditions are not valid." };
|
|
88
|
+
const f = parsed.data;
|
|
89
|
+
if (f.subscriptionStop === undefined || f.subscriptionRefund === undefined || f.oneTimeRefund === undefined || f.afterDownload === undefined) {
|
|
90
|
+
return { listingId: f.listingId ?? null, conditions: null };
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
listingId: f.listingId ?? null,
|
|
94
|
+
conditions: { subscriptionStop: f.subscriptionStop, subscriptionRefund: f.subscriptionRefund, oneTimeRefund: f.oneTimeRefund, afterDownload: f.afterDownload },
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** The CMS release that reads the sale conditions; copy says "{release}". */
|
|
98
|
+
export const SALE_CONDITIONS_CMS_RELEASE = "0.20.0";
|
|
99
|
+
export const LicenseVerdictEndWireSchema = z.object({ effect: z.enum(END_EFFECTS), refunded: z.boolean() });
|
|
@@ -42,3 +42,16 @@ export type ParsedSampleContentFile = {
|
|
|
42
42
|
* would also answer .strict()'s unknown root key, and a misspelt key would
|
|
43
43
|
* read "must be a JSON object" instead of being named. */
|
|
44
44
|
export declare function parseSampleContentFile(raw: unknown): ParsedSampleContentFile;
|
|
45
|
+
/** M32 J (J10): a string that is exactly `{{page:<slug>}}` names another page
|
|
46
|
+
* of the same file, declared before or after it, and becomes its id. */
|
|
47
|
+
export declare const SAMPLE_PAGE_TOKEN_PREFIX = "{{page:";
|
|
48
|
+
export declare const SAMPLE_PAGE_TOKEN_SUFFIX = "}}";
|
|
49
|
+
/** M32 J (J10): how deep a page token is read in a node's data (the data itself is depth 0); one
|
|
50
|
+
* deeper is not a token to the check, and the seeder leaves it as written. */
|
|
51
|
+
export declare const SAMPLE_PAGE_TOKEN_DEPTH_MAX = 32;
|
|
52
|
+
/** M32 J (J10): the slug a whole-string page token names, or null. No pattern: a prefix, a suffix, a slice. */
|
|
53
|
+
export declare function readSamplePageToken(value: unknown): string | null;
|
|
54
|
+
/** M32 J (J10): every token's slug in a node's data, in walk order, the walk's depth capped. */
|
|
55
|
+
export declare function samplePageTokens(data: unknown, depth?: number): string[];
|
|
56
|
+
/** M32 J (J10): the top-level fields the seeder leaves out at create and saves in a second version. */
|
|
57
|
+
export declare function sampleDeferredFieldIds(data: Record<string, unknown>): string[];
|
|
@@ -95,3 +95,31 @@ export function parseSampleContentFile(raw) {
|
|
|
95
95
|
return { ok: true, file: result.data };
|
|
96
96
|
return { ok: false, errors: result.error.issues.map((issue) => (issue.path.length > 0 ? `${pathText(issue.path)}: ${issue.message}` : issue.message)) };
|
|
97
97
|
}
|
|
98
|
+
/** M32 J (J10): a string that is exactly `{{page:<slug>}}` names another page
|
|
99
|
+
* of the same file, declared before or after it, and becomes its id. */
|
|
100
|
+
export const SAMPLE_PAGE_TOKEN_PREFIX = "{{page:";
|
|
101
|
+
export const SAMPLE_PAGE_TOKEN_SUFFIX = "}}";
|
|
102
|
+
/** M32 J (J10): how deep a page token is read in a node's data (the data itself is depth 0); one
|
|
103
|
+
* deeper is not a token to the check, and the seeder leaves it as written. */
|
|
104
|
+
export const SAMPLE_PAGE_TOKEN_DEPTH_MAX = 32;
|
|
105
|
+
/** M32 J (J10): the slug a whole-string page token names, or null. No pattern: a prefix, a suffix, a slice. */
|
|
106
|
+
export function readSamplePageToken(value) {
|
|
107
|
+
if (typeof value !== "string" || !value.startsWith(SAMPLE_PAGE_TOKEN_PREFIX) || !value.endsWith(SAMPLE_PAGE_TOKEN_SUFFIX))
|
|
108
|
+
return null;
|
|
109
|
+
const slug = value.slice(SAMPLE_PAGE_TOKEN_PREFIX.length, value.length - SAMPLE_PAGE_TOKEN_SUFFIX.length);
|
|
110
|
+
return slug.length > 0 && !slug.includes("}") && !slug.includes("{") ? slug : null;
|
|
111
|
+
}
|
|
112
|
+
/** M32 J (J10): every token's slug in a node's data, in walk order, the walk's depth capped. */
|
|
113
|
+
export function samplePageTokens(data, depth = 0) {
|
|
114
|
+
const slug = readSamplePageToken(data);
|
|
115
|
+
if (slug !== null)
|
|
116
|
+
return [slug];
|
|
117
|
+
if (depth >= SAMPLE_PAGE_TOKEN_DEPTH_MAX || data === null || typeof data !== "object")
|
|
118
|
+
return [];
|
|
119
|
+
const values = Array.isArray(data) ? data : Object.values(data);
|
|
120
|
+
return values.flatMap((value) => samplePageTokens(value, depth + 1));
|
|
121
|
+
}
|
|
122
|
+
/** M32 J (J10): the top-level fields the seeder leaves out at create and saves in a second version. */
|
|
123
|
+
export function sampleDeferredFieldIds(data) {
|
|
124
|
+
return Object.keys(data).filter((fieldId) => samplePageTokens(data[fieldId]).length > 0);
|
|
125
|
+
}
|