@elytracms/core 0.0.6
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/LICENSE +21 -0
- package/dist/clipboard/build.d.ts +77 -0
- package/dist/clipboard/build.js +128 -0
- package/dist/clipboard/build.js.map +1 -0
- package/dist/clipboard/clipboard.d.ts +33 -0
- package/dist/clipboard/clipboard.js +45 -0
- package/dist/clipboard/clipboard.js.map +1 -0
- package/dist/clipboard/fragment.d.ts +112 -0
- package/dist/clipboard/fragment.js +79 -0
- package/dist/clipboard/fragment.js.map +1 -0
- package/dist/clipboard/html.d.ts +26 -0
- package/dist/clipboard/html.js +82 -0
- package/dist/clipboard/html.js.map +1 -0
- package/dist/clipboard/index.d.ts +15 -0
- package/dist/clipboard/index.js +16 -0
- package/dist/clipboard/index.js.map +1 -0
- package/dist/clipboard/references.d.ts +50 -0
- package/dist/clipboard/references.js +0 -0
- package/dist/clipboard/references.js.map +1 -0
- package/dist/clipboard/serialize.d.ts +69 -0
- package/dist/clipboard/serialize.js +130 -0
- package/dist/clipboard/serialize.js.map +1 -0
- package/dist/cms-core/collections.d.ts +82 -0
- package/dist/cms-core/collections.js +187 -0
- package/dist/cms-core/collections.js.map +1 -0
- package/dist/cms-core/documents.d.ts +71 -0
- package/dist/cms-core/documents.js +67 -0
- package/dist/cms-core/documents.js.map +1 -0
- package/dist/cms-core/envelopes.d.ts +80 -0
- package/dist/cms-core/envelopes.js +124 -0
- package/dist/cms-core/envelopes.js.map +1 -0
- package/dist/cms-core/fields.d.ts +220 -0
- package/dist/cms-core/fields.js +250 -0
- package/dist/cms-core/fields.js.map +1 -0
- package/dist/cms-core/fixtures.d.ts +92 -0
- package/dist/cms-core/fixtures.js +357 -0
- package/dist/cms-core/fixtures.js.map +1 -0
- package/dist/cms-core/hierarchy.d.ts +113 -0
- package/dist/cms-core/hierarchy.js +223 -0
- package/dist/cms-core/hierarchy.js.map +1 -0
- package/dist/cms-core/index.d.ts +25 -0
- package/dist/cms-core/index.js +26 -0
- package/dist/cms-core/index.js.map +1 -0
- package/dist/cms-core/infer.d.ts +103 -0
- package/dist/cms-core/infer.js +57 -0
- package/dist/cms-core/infer.js.map +1 -0
- package/dist/cms-core/issues.d.ts +92 -0
- package/dist/cms-core/issues.js +74 -0
- package/dist/cms-core/issues.js.map +1 -0
- package/dist/cms-core/json-schema.d.ts +25 -0
- package/dist/cms-core/json-schema.js +110 -0
- package/dist/cms-core/json-schema.js.map +1 -0
- package/dist/cms-core/localization.d.ts +51 -0
- package/dist/cms-core/localization.js +89 -0
- package/dist/cms-core/localization.js.map +1 -0
- package/dist/cms-core/routes.d.ts +76 -0
- package/dist/cms-core/routes.js +220 -0
- package/dist/cms-core/routes.js.map +1 -0
- package/dist/cms-core/self-type.d.ts +41 -0
- package/dist/cms-core/self-type.js +191 -0
- package/dist/cms-core/self-type.js.map +1 -0
- package/dist/cms-core/url-for-document.d.ts +39 -0
- package/dist/cms-core/url-for-document.js +138 -0
- package/dist/cms-core/url-for-document.js.map +1 -0
- package/dist/cms-core/validate-document.d.ts +121 -0
- package/dist/cms-core/validate-document.js +871 -0
- package/dist/cms-core/validate-document.js.map +1 -0
- package/dist/cms-core/versions.d.ts +75 -0
- package/dist/cms-core/versions.js +97 -0
- package/dist/cms-core/versions.js.map +1 -0
- package/dist/collaboration/approval.d.ts +68 -0
- package/dist/collaboration/approval.js +104 -0
- package/dist/collaboration/approval.js.map +1 -0
- package/dist/collaboration/collaboration.d.ts +49 -0
- package/dist/collaboration/collaboration.js +56 -0
- package/dist/collaboration/collaboration.js.map +1 -0
- package/dist/collaboration/comments.d.ts +72 -0
- package/dist/collaboration/comments.js +118 -0
- package/dist/collaboration/comments.js.map +1 -0
- package/dist/collaboration/core.d.ts +25 -0
- package/dist/collaboration/core.js +26 -0
- package/dist/collaboration/core.js.map +1 -0
- package/dist/collaboration/index.d.ts +14 -0
- package/dist/collaboration/index.js +15 -0
- package/dist/collaboration/index.js.map +1 -0
- package/dist/collaboration/presence.d.ts +62 -0
- package/dist/collaboration/presence.js +85 -0
- package/dist/collaboration/presence.js.map +1 -0
- package/dist/collaboration/publishing.d.ts +60 -0
- package/dist/collaboration/publishing.js +93 -0
- package/dist/collaboration/publishing.js.map +1 -0
- package/dist/collaboration/versions.d.ts +52 -0
- package/dist/collaboration/versions.js +81 -0
- package/dist/collaboration/versions.js.map +1 -0
- package/dist/component-registry/index.d.ts +3 -0
- package/dist/component-registry/index.js +4 -0
- package/dist/component-registry/index.js.map +1 -0
- package/dist/component-registry/issues.d.ts +6 -0
- package/dist/component-registry/issues.js +2 -0
- package/dist/component-registry/issues.js.map +1 -0
- package/dist/component-registry/manifest.d.ts +164 -0
- package/dist/component-registry/manifest.js +129 -0
- package/dist/component-registry/manifest.js.map +1 -0
- package/dist/component-registry/registry.d.ts +33 -0
- package/dist/component-registry/registry.js +90 -0
- package/dist/component-registry/registry.js.map +1 -0
- package/dist/content/__fixtures__/filterable-collections.d.ts +14 -0
- package/dist/content/__fixtures__/filterable-collections.js +15 -0
- package/dist/content/__fixtures__/filterable-collections.js.map +1 -0
- package/dist/content/__fixtures__/sample-accessor-types.d.ts +56 -0
- package/dist/content/__fixtures__/sample-accessor-types.js +5 -0
- package/dist/content/__fixtures__/sample-accessor-types.js.map +1 -0
- package/dist/content/__fixtures__/sample-delivery-types.d.ts +122 -0
- package/dist/content/__fixtures__/sample-delivery-types.js +5 -0
- package/dist/content/__fixtures__/sample-delivery-types.js.map +1 -0
- package/dist/content/assets.d.ts +53 -0
- package/dist/content/assets.js +38 -0
- package/dist/content/assets.js.map +1 -0
- package/dist/content/binding-sources.d.ts +53 -0
- package/dist/content/binding-sources.js +73 -0
- package/dist/content/binding-sources.js.map +1 -0
- package/dist/content/client.d.ts +90 -0
- package/dist/content/client.js +383 -0
- package/dist/content/client.js.map +1 -0
- package/dist/content/codegen.d.ts +54 -0
- package/dist/content/codegen.js +305 -0
- package/dist/content/codegen.js.map +1 -0
- package/dist/content/context.d.ts +38 -0
- package/dist/content/context.js +21 -0
- package/dist/content/context.js.map +1 -0
- package/dist/content/cursor.d.ts +33 -0
- package/dist/content/cursor.js +104 -0
- package/dist/content/cursor.js.map +1 -0
- package/dist/content/index.d.ts +28 -0
- package/dist/content/index.js +29 -0
- package/dist/content/index.js.map +1 -0
- package/dist/content/locale.d.ts +30 -0
- package/dist/content/locale.js +26 -0
- package/dist/content/locale.js.map +1 -0
- package/dist/content/perspective.d.ts +29 -0
- package/dist/content/perspective.js +31 -0
- package/dist/content/perspective.js.map +1 -0
- package/dist/content/populate.d.ts +25 -0
- package/dist/content/populate.js +22 -0
- package/dist/content/populate.js.map +1 -0
- package/dist/content/query.d.ts +122 -0
- package/dist/content/query.js +257 -0
- package/dist/content/query.js.map +1 -0
- package/dist/content/raw.d.ts +13 -0
- package/dist/content/raw.js +14 -0
- package/dist/content/raw.js.map +1 -0
- package/dist/content/resolve.d.ts +97 -0
- package/dist/content/resolve.js +261 -0
- package/dist/content/resolve.js.map +1 -0
- package/dist/content/serialize.d.ts +30 -0
- package/dist/content/serialize.js +57 -0
- package/dist/content/serialize.js.map +1 -0
- package/dist/content/tags.d.ts +54 -0
- package/dist/content/tags.js +40 -0
- package/dist/content/tags.js.map +1 -0
- package/dist/data-binding/fixtures.d.ts +20 -0
- package/dist/data-binding/fixtures.js +47 -0
- package/dist/data-binding/fixtures.js.map +1 -0
- package/dist/data-binding/index.d.ts +14 -0
- package/dist/data-binding/index.js +15 -0
- package/dist/data-binding/index.js.map +1 -0
- package/dist/data-binding/issues.d.ts +45 -0
- package/dist/data-binding/issues.js +46 -0
- package/dist/data-binding/issues.js.map +1 -0
- package/dist/data-binding/resolve.d.ts +87 -0
- package/dist/data-binding/resolve.js +204 -0
- package/dist/data-binding/resolve.js.map +1 -0
- package/dist/data-binding/sample.d.ts +21 -0
- package/dist/data-binding/sample.js +23 -0
- package/dist/data-binding/sample.js.map +1 -0
- package/dist/data-binding/sources.d.ts +225 -0
- package/dist/data-binding/sources.js +154 -0
- package/dist/data-binding/sources.js.map +1 -0
- package/dist/data-binding/tokens.d.ts +62 -0
- package/dist/data-binding/tokens.js +150 -0
- package/dist/data-binding/tokens.js.map +1 -0
- package/dist/design-tokens/css.d.ts +34 -0
- package/dist/design-tokens/css.js +51 -0
- package/dist/design-tokens/css.js.map +1 -0
- package/dist/design-tokens/index.d.ts +10 -0
- package/dist/design-tokens/index.js +11 -0
- package/dist/design-tokens/index.js.map +1 -0
- package/dist/design-tokens/style-guide.d.ts +30 -0
- package/dist/design-tokens/style-guide.js +31 -0
- package/dist/design-tokens/style-guide.js.map +1 -0
- package/dist/design-tokens/tokens.d.ts +89 -0
- package/dist/design-tokens/tokens.js +112 -0
- package/dist/design-tokens/tokens.js.map +1 -0
- package/dist/export-sync/builder-source.d.ts +85 -0
- package/dist/export-sync/builder-source.js +124 -0
- package/dist/export-sync/builder-source.js.map +1 -0
- package/dist/export-sync/check.d.ts +61 -0
- package/dist/export-sync/check.js +126 -0
- package/dist/export-sync/check.js.map +1 -0
- package/dist/export-sync/cli.d.ts +89 -0
- package/dist/export-sync/cli.js +323 -0
- package/dist/export-sync/cli.js.map +1 -0
- package/dist/export-sync/core.d.ts +58 -0
- package/dist/export-sync/core.js +41 -0
- package/dist/export-sync/core.js.map +1 -0
- package/dist/export-sync/eject.d.ts +28 -0
- package/dist/export-sync/eject.js +21 -0
- package/dist/export-sync/eject.js.map +1 -0
- package/dist/export-sync/fixtures.d.ts +25 -0
- package/dist/export-sync/fixtures.js +87 -0
- package/dist/export-sync/fixtures.js.map +1 -0
- package/dist/export-sync/generate.d.ts +7 -0
- package/dist/export-sync/generate.js +505 -0
- package/dist/export-sync/generate.js.map +1 -0
- package/dist/export-sync/index.d.ts +37 -0
- package/dist/export-sync/index.js +39 -0
- package/dist/export-sync/index.js.map +1 -0
- package/dist/export-sync/init.d.ts +123 -0
- package/dist/export-sync/init.js +234 -0
- package/dist/export-sync/init.js.map +1 -0
- package/dist/export-sync/manifest-host.d.ts +48 -0
- package/dist/export-sync/manifest-host.js +73 -0
- package/dist/export-sync/manifest-host.js.map +1 -0
- package/dist/export-sync/node.d.ts +20 -0
- package/dist/export-sync/node.js +101 -0
- package/dist/export-sync/node.js.map +1 -0
- package/dist/export-sync/push.d.ts +76 -0
- package/dist/export-sync/push.js +197 -0
- package/dist/export-sync/push.js.map +1 -0
- package/dist/export-sync/registry-sync-client.d.ts +59 -0
- package/dist/export-sync/registry-sync-client.js +97 -0
- package/dist/export-sync/registry-sync-client.js.map +1 -0
- package/dist/export-sync/sync.d.ts +47 -0
- package/dist/export-sync/sync.js +47 -0
- package/dist/export-sync/sync.js.map +1 -0
- package/dist/export-sync/typegen.d.ts +40 -0
- package/dist/export-sync/typegen.js +45 -0
- package/dist/export-sync/typegen.js.map +1 -0
- package/dist/export-sync/validate.d.ts +19 -0
- package/dist/export-sync/validate.js +102 -0
- package/dist/export-sync/validate.js.map +1 -0
- package/dist/export-sync/watch.d.ts +66 -0
- package/dist/export-sync/watch.js +70 -0
- package/dist/export-sync/watch.js.map +1 -0
- package/dist/operations/assets.d.ts +198 -0
- package/dist/operations/assets.js +75 -0
- package/dist/operations/assets.js.map +1 -0
- package/dist/operations/authorization.d.ts +49 -0
- package/dist/operations/authorization.js +128 -0
- package/dist/operations/authorization.js.map +1 -0
- package/dist/operations/changesets.d.ts +160 -0
- package/dist/operations/changesets.js +442 -0
- package/dist/operations/changesets.js.map +1 -0
- package/dist/operations/client.d.ts +49 -0
- package/dist/operations/client.js +57 -0
- package/dist/operations/client.js.map +1 -0
- package/dist/operations/core.d.ts +238 -0
- package/dist/operations/core.js +269 -0
- package/dist/operations/core.js.map +1 -0
- package/dist/operations/documents.d.ts +432 -0
- package/dist/operations/documents.js +344 -0
- package/dist/operations/documents.js.map +1 -0
- package/dist/operations/graph.d.ts +138 -0
- package/dist/operations/graph.js +78 -0
- package/dist/operations/graph.js.map +1 -0
- package/dist/operations/index.d.ts +19 -0
- package/dist/operations/index.js +20 -0
- package/dist/operations/index.js.map +1 -0
- package/dist/operations/members.d.ts +87 -0
- package/dist/operations/members.js +56 -0
- package/dist/operations/members.js.map +1 -0
- package/dist/operations/publishing.d.ts +89 -0
- package/dist/operations/publishing.js +57 -0
- package/dist/operations/publishing.js.map +1 -0
- package/dist/operations/references.d.ts +222 -0
- package/dist/operations/references.js +177 -0
- package/dist/operations/references.js.map +1 -0
- package/dist/operations/schema.d.ts +413 -0
- package/dist/operations/schema.js +138 -0
- package/dist/operations/schema.js.map +1 -0
- package/dist/operations/tokens.d.ts +79 -0
- package/dist/operations/tokens.js +102 -0
- package/dist/operations/tokens.js.map +1 -0
- package/dist/persistence/adapter.d.ts +79 -0
- package/dist/persistence/adapter.js +55 -0
- package/dist/persistence/adapter.js.map +1 -0
- package/dist/persistence/assets.d.ts +120 -0
- package/dist/persistence/assets.js +141 -0
- package/dist/persistence/assets.js.map +1 -0
- package/dist/persistence/backend-validation.d.ts +43 -0
- package/dist/persistence/backend-validation.js +57 -0
- package/dist/persistence/backend-validation.js.map +1 -0
- package/dist/persistence/cli-tokens.d.ts +50 -0
- package/dist/persistence/cli-tokens.js +66 -0
- package/dist/persistence/cli-tokens.js.map +1 -0
- package/dist/persistence/cms.d.ts +148 -0
- package/dist/persistence/cms.js +232 -0
- package/dist/persistence/cms.js.map +1 -0
- package/dist/persistence/contract-scenarios.d.ts +73 -0
- package/dist/persistence/contract-scenarios.js +496 -0
- package/dist/persistence/contract-scenarios.js.map +1 -0
- package/dist/persistence/core.d.ts +96 -0
- package/dist/persistence/core.js +110 -0
- package/dist/persistence/core.js.map +1 -0
- package/dist/persistence/graph.d.ts +61 -0
- package/dist/persistence/graph.js +98 -0
- package/dist/persistence/graph.js.map +1 -0
- package/dist/persistence/index.d.ts +22 -0
- package/dist/persistence/index.js +23 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/members.d.ts +70 -0
- package/dist/persistence/members.js +0 -0
- package/dist/persistence/members.js.map +1 -0
- package/dist/persistence/publishing.d.ts +59 -0
- package/dist/persistence/publishing.js +95 -0
- package/dist/persistence/publishing.js.map +1 -0
- package/dist/persistence/reference-extraction.d.ts +44 -0
- package/dist/persistence/reference-extraction.js +204 -0
- package/dist/persistence/reference-extraction.js.map +1 -0
- package/dist/persistence/reference-indexing.d.ts +68 -0
- package/dist/persistence/reference-indexing.js +112 -0
- package/dist/persistence/reference-indexing.js.map +1 -0
- package/dist/persistence/references.d.ts +257 -0
- package/dist/persistence/references.js +0 -0
- package/dist/persistence/references.js.map +1 -0
- package/dist/persistence/seed.d.ts +55 -0
- package/dist/persistence/seed.js +102 -0
- package/dist/persistence/seed.js.map +1 -0
- package/dist/persistence/self-maintaining-adapter.d.ts +41 -0
- package/dist/persistence/self-maintaining-adapter.js +79 -0
- package/dist/persistence/self-maintaining-adapter.js.map +1 -0
- package/dist/plugins/asset-storage.d.ts +76 -0
- package/dist/plugins/asset-storage.js +104 -0
- package/dist/plugins/asset-storage.js.map +1 -0
- package/dist/plugins/component-package.d.ts +54 -0
- package/dist/plugins/component-package.js +92 -0
- package/dist/plugins/component-package.js.map +1 -0
- package/dist/plugins/data-sources.d.ts +78 -0
- package/dist/plugins/data-sources.js +99 -0
- package/dist/plugins/data-sources.js.map +1 -0
- package/dist/plugins/examples.d.ts +47 -0
- package/dist/plugins/examples.js +205 -0
- package/dist/plugins/examples.js.map +1 -0
- package/dist/plugins/export-targets.d.ts +47 -0
- package/dist/plugins/export-targets.js +78 -0
- package/dist/plugins/export-targets.js.map +1 -0
- package/dist/plugins/field-types.d.ts +86 -0
- package/dist/plugins/field-types.js +93 -0
- package/dist/plugins/field-types.js.map +1 -0
- package/dist/plugins/hooks.d.ts +60 -0
- package/dist/plugins/hooks.js +94 -0
- package/dist/plugins/hooks.js.map +1 -0
- package/dist/plugins/index.d.ts +27 -0
- package/dist/plugins/index.js +28 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/marketplace.d.ts +90 -0
- package/dist/plugins/marketplace.js +110 -0
- package/dist/plugins/marketplace.js.map +1 -0
- package/dist/plugins/plugin.d.ts +107 -0
- package/dist/plugins/plugin.js +122 -0
- package/dist/plugins/plugin.js.map +1 -0
- package/dist/plugins/templates.d.ts +66 -0
- package/dist/plugins/templates.js +74 -0
- package/dist/plugins/templates.js.map +1 -0
- package/dist/project-graph/binding.d.ts +68 -0
- package/dist/project-graph/binding.js +39 -0
- package/dist/project-graph/binding.js.map +1 -0
- package/dist/project-graph/container.d.ts +126 -0
- package/dist/project-graph/container.js +221 -0
- package/dist/project-graph/container.js.map +1 -0
- package/dist/project-graph/edit.d.ts +66 -0
- package/dist/project-graph/edit.js +201 -0
- package/dist/project-graph/edit.js.map +1 -0
- package/dist/project-graph/fixtures.d.ts +51 -0
- package/dist/project-graph/fixtures.js +224 -0
- package/dist/project-graph/fixtures.js.map +1 -0
- package/dist/project-graph/ids.d.ts +17 -0
- package/dist/project-graph/ids.js +19 -0
- package/dist/project-graph/ids.js.map +1 -0
- package/dist/project-graph/index.d.ts +12 -0
- package/dist/project-graph/index.js +13 -0
- package/dist/project-graph/index.js.map +1 -0
- package/dist/project-graph/issues.d.ts +61 -0
- package/dist/project-graph/issues.js +44 -0
- package/dist/project-graph/issues.js.map +1 -0
- package/dist/project-graph/json.d.ts +6 -0
- package/dist/project-graph/json.js +10 -0
- package/dist/project-graph/json.js.map +1 -0
- package/dist/project-graph/node.d.ts +48 -0
- package/dist/project-graph/node.js +42 -0
- package/dist/project-graph/node.js.map +1 -0
- package/dist/project-graph/normalize.d.ts +17 -0
- package/dist/project-graph/normalize.js +110 -0
- package/dist/project-graph/normalize.js.map +1 -0
- package/dist/project-graph/serialize.d.ts +36 -0
- package/dist/project-graph/serialize.js +51 -0
- package/dist/project-graph/serialize.js.map +1 -0
- package/dist/project-graph/structure.d.ts +40 -0
- package/dist/project-graph/structure.js +36 -0
- package/dist/project-graph/structure.js.map +1 -0
- package/dist/project-graph/validate.d.ts +84 -0
- package/dist/project-graph/validate.js +158 -0
- package/dist/project-graph/validate.js.map +1 -0
- package/dist/rich-text/adapter.d.ts +43 -0
- package/dist/rich-text/adapter.js +24 -0
- package/dist/rich-text/adapter.js.map +1 -0
- package/dist/rich-text/dom-editor.d.ts +101 -0
- package/dist/rich-text/dom-editor.js +482 -0
- package/dist/rich-text/dom-editor.js.map +1 -0
- package/dist/rich-text/embed.d.ts +70 -0
- package/dist/rich-text/embed.js +70 -0
- package/dist/rich-text/embed.js.map +1 -0
- package/dist/rich-text/fixtures.d.ts +25 -0
- package/dist/rich-text/fixtures.js +115 -0
- package/dist/rich-text/fixtures.js.map +1 -0
- package/dist/rich-text/html.d.ts +5 -0
- package/dist/rich-text/html.js +309 -0
- package/dist/rich-text/html.js.map +1 -0
- package/dist/rich-text/index.d.ts +19 -0
- package/dist/rich-text/index.js +20 -0
- package/dist/rich-text/index.js.map +1 -0
- package/dist/rich-text/markdown.d.ts +7 -0
- package/dist/rich-text/markdown.js +235 -0
- package/dist/rich-text/markdown.js.map +1 -0
- package/dist/rich-text/portable-text.d.ts +50 -0
- package/dist/rich-text/portable-text.js +223 -0
- package/dist/rich-text/portable-text.js.map +1 -0
- package/dist/rich-text/registry.d.ts +48 -0
- package/dist/rich-text/registry.js +16 -0
- package/dist/rich-text/registry.js.map +1 -0
- package/dist/rich-text/render.d.ts +69 -0
- package/dist/rich-text/render.js +205 -0
- package/dist/rich-text/render.js.map +1 -0
- package/dist/rich-text/schema.d.ts +86 -0
- package/dist/rich-text/schema.js +80 -0
- package/dist/rich-text/schema.js.map +1 -0
- package/dist/rich-text/test-support.d.ts +7 -0
- package/dist/rich-text/test-support.js +8 -0
- package/dist/rich-text/test-support.js.map +1 -0
- package/dist/runtime-renderer/client.d.ts +14 -0
- package/dist/runtime-renderer/client.js +15 -0
- package/dist/runtime-renderer/client.js.map +1 -0
- package/dist/runtime-renderer/condition.d.ts +8 -0
- package/dist/runtime-renderer/condition.js +48 -0
- package/dist/runtime-renderer/condition.js.map +1 -0
- package/dist/runtime-renderer/content-client.d.ts +62 -0
- package/dist/runtime-renderer/content-client.js +37 -0
- package/dist/runtime-renderer/content-client.js.map +1 -0
- package/dist/runtime-renderer/context.d.ts +185 -0
- package/dist/runtime-renderer/context.js +7 -0
- package/dist/runtime-renderer/context.js.map +1 -0
- package/dist/runtime-renderer/fallback.d.ts +39 -0
- package/dist/runtime-renderer/fallback.js +45 -0
- package/dist/runtime-renderer/fallback.js.map +1 -0
- package/dist/runtime-renderer/index.d.ts +13 -0
- package/dist/runtime-renderer/index.js +13 -0
- package/dist/runtime-renderer/index.js.map +1 -0
- package/dist/runtime-renderer/primitives.d.ts +85 -0
- package/dist/runtime-renderer/primitives.js +442 -0
- package/dist/runtime-renderer/primitives.js.map +1 -0
- package/dist/runtime-renderer/render.d.ts +138 -0
- package/dist/runtime-renderer/render.js +825 -0
- package/dist/runtime-renderer/render.js.map +1 -0
- package/dist/runtime-renderer/rich-text.d.ts +26 -0
- package/dist/runtime-renderer/rich-text.js +113 -0
- package/dist/runtime-renderer/rich-text.js.map +1 -0
- package/dist/starter-kits/index.d.ts +13 -0
- package/dist/starter-kits/index.js +14 -0
- package/dist/starter-kits/index.js.map +1 -0
- package/dist/starter-kits/instantiate.d.ts +29 -0
- package/dist/starter-kits/instantiate.js +24 -0
- package/dist/starter-kits/instantiate.js.map +1 -0
- package/dist/starter-kits/kit.d.ts +61 -0
- package/dist/starter-kits/kit.js +37 -0
- package/dist/starter-kits/kit.js.map +1 -0
- package/dist/starter-kits/kits.d.ts +7 -0
- package/dist/starter-kits/kits.js +201 -0
- package/dist/starter-kits/kits.js.map +1 -0
- package/dist/starter-kits/manifests.d.ts +7 -0
- package/dist/starter-kits/manifests.js +111 -0
- package/dist/starter-kits/manifests.js.map +1 -0
- package/dist/starter-kits/upgrade.d.ts +39 -0
- package/dist/starter-kits/upgrade.js +54 -0
- package/dist/starter-kits/upgrade.js.map +1 -0
- package/dist/starter-kits/validate.d.ts +16 -0
- package/dist/starter-kits/validate.js +77 -0
- package/dist/starter-kits/validate.js.map +1 -0
- package/dist/studio-core/context.d.ts +27 -0
- package/dist/studio-core/context.js +44 -0
- package/dist/studio-core/context.js.map +1 -0
- package/dist/studio-core/errors.d.ts +58 -0
- package/dist/studio-core/errors.js +74 -0
- package/dist/studio-core/errors.js.map +1 -0
- package/dist/studio-core/fixtures.d.ts +18 -0
- package/dist/studio-core/fixtures.js +83 -0
- package/dist/studio-core/fixtures.js.map +1 -0
- package/dist/studio-core/ids.d.ts +22 -0
- package/dist/studio-core/ids.js +33 -0
- package/dist/studio-core/ids.js.map +1 -0
- package/dist/studio-core/index.d.ts +11 -0
- package/dist/studio-core/index.js +12 -0
- package/dist/studio-core/index.js.map +1 -0
- package/dist/studio-core/issues.d.ts +50 -0
- package/dist/studio-core/issues.js +33 -0
- package/dist/studio-core/issues.js.map +1 -0
- package/dist/studio-core/metadata.d.ts +109 -0
- package/dist/studio-core/metadata.js +74 -0
- package/dist/studio-core/metadata.js.map +1 -0
- package/dist/studio-core/repository.d.ts +73 -0
- package/dist/studio-core/repository.js +202 -0
- package/dist/studio-core/repository.js.map +1 -0
- package/dist/studio-core/sections.d.ts +73 -0
- package/dist/studio-core/sections.js +68 -0
- package/dist/studio-core/sections.js.map +1 -0
- package/dist/studio-core/validate.d.ts +15 -0
- package/dist/studio-core/validate.js +119 -0
- package/dist/studio-core/validate.js.map +1 -0
- package/dist/studio-core/workspace-config.d.ts +587 -0
- package/dist/studio-core/workspace-config.js +434 -0
- package/dist/studio-core/workspace-config.js.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @elytracms/clipboard — the spec'd, versioned clipboard fragment (EC-174,
|
|
3
|
+
* vision 3.7). Copy/paste as a real interchange format: a Zod-validated
|
|
4
|
+
* envelope carrying a graph subtree, manifest references, binding declarations,
|
|
5
|
+
* asset references, and source metadata, serialized to the OS clipboard as
|
|
6
|
+
* canonical JSON with a human-readable (and losslessly round-tripping) HTML
|
|
7
|
+
* fallback. Package-level only — EC-175 wires it into the studio.
|
|
8
|
+
*/
|
|
9
|
+
export const PACKAGE = '@elytracms/core/clipboard';
|
|
10
|
+
export * from './fragment';
|
|
11
|
+
export * from './references';
|
|
12
|
+
export * from './serialize';
|
|
13
|
+
export * from './build';
|
|
14
|
+
export * from './html';
|
|
15
|
+
export * from './clipboard';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/clipboard/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,2BAA2B,CAAA;AAElD,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { BindingReference, ComponentNode } from '@elytracms/core/project-graph';
|
|
2
|
+
import type { AssetRef, ClipboardFragment, ManifestRef } from './fragment';
|
|
3
|
+
/**
|
|
4
|
+
* Reference collection: deterministic, structural walks over a fragment subtree
|
|
5
|
+
* that enumerate everything it points at — component ids, binding declarations,
|
|
6
|
+
* asset ids. Builders use these to populate the payload's reference lists;
|
|
7
|
+
* `parseFragment` recomputes them so consumers can diff a pasted fragment
|
|
8
|
+
* against their registry/sources without re-walking the tree themselves.
|
|
9
|
+
*
|
|
10
|
+
* All collectors are pure, never throw, and return sorted, de-duplicated lists
|
|
11
|
+
* so equal subtrees yield byte-identical fragments.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Convention for asset references inside static prop values (shared with
|
|
15
|
+
* rich-text link marks and persistence reference extraction, EC-155):
|
|
16
|
+
* `elytra:asset/<id>` strings, or objects carrying an `assetId` string.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ASSET_REFERENCE_PREFIX = "elytra:asset/";
|
|
19
|
+
/** Every component id used anywhere in the subtree (sorted, unique). */
|
|
20
|
+
export declare function collectComponentIds(root: ComponentNode): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Every binding declaration referenced by the subtree's bound props and render
|
|
23
|
+
* conditions (sorted by source id, token, mode; unique).
|
|
24
|
+
*/
|
|
25
|
+
export declare function collectBindingDeclarations(root: ComponentNode): BindingReference[];
|
|
26
|
+
/**
|
|
27
|
+
* Every asset id referenced by static prop values in the subtree (sorted,
|
|
28
|
+
* unique). Detects the `elytra:asset/<id>` string convention and embedded
|
|
29
|
+
* `assetId` attributes (e.g. rich-text image nodes).
|
|
30
|
+
*/
|
|
31
|
+
export declare function collectAssetIds(root: ComponentNode): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Everything a fragment references, enumerated for the consumer: the component
|
|
34
|
+
* ids actually used by the subtree, the declared manifest refs, and the binding
|
|
35
|
+
* and asset declarations. Paste targets diff these against their registry and
|
|
36
|
+
* data sources — a mismatch is the consumer's structured issue, never a parse
|
|
37
|
+
* failure here.
|
|
38
|
+
*/
|
|
39
|
+
export interface FragmentReferences {
|
|
40
|
+
/** Component ids used anywhere in the subtree (sorted, unique). */
|
|
41
|
+
componentIds: string[];
|
|
42
|
+
/** Manifest references declared in the payload (`name@version`). */
|
|
43
|
+
manifests: ManifestRef[];
|
|
44
|
+
/** Binding declarations referenced by props/conditions. */
|
|
45
|
+
bindings: BindingReference[];
|
|
46
|
+
/** Asset references declared in the payload. */
|
|
47
|
+
assets: AssetRef[];
|
|
48
|
+
}
|
|
49
|
+
/** Enumerate a fragment's references (recomputed from the subtree, plus declared lists). */
|
|
50
|
+
export declare function collectFragmentReferences(fragment: ClipboardFragment): FragmentReferences;
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.js","sourceRoot":"","sources":["../../src/clipboard/references.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CAAA;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AC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;QACjE,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;QACtE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;KAC/D,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ClipboardFragment } from './fragment';
|
|
2
|
+
import type { FragmentReferences } from './references';
|
|
3
|
+
/**
|
|
4
|
+
* Fragment serialization, following `@elytracms/core/project-graph`'s conventions:
|
|
5
|
+
* parse-before-serialize (the output contains no runtime-only values) and a
|
|
6
|
+
* never-throw parse. On top of that, serialization is *canonical* — object keys
|
|
7
|
+
* are sorted recursively — so build → serialize → parse → serialize is
|
|
8
|
+
* byte-identical regardless of property insertion order. Canonical bytes are
|
|
9
|
+
* what goes onto the OS clipboard (and into the HTML fallback's data
|
|
10
|
+
* attribute), so two copies of the same subtree are comparable as strings.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Deterministic JSON: arrays in order, object keys sorted recursively,
|
|
14
|
+
* `undefined` object values dropped (matching `JSON.stringify`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function canonicalJsonStringify(value: unknown): string;
|
|
17
|
+
/**
|
|
18
|
+
* Serialize a fragment to canonical JSON. Parsing first guarantees the output
|
|
19
|
+
* is exactly the spec'd envelope (programmer error in the input throws — this
|
|
20
|
+
* is the trusted, in-process direction; `parseFragment` owns untrusted input).
|
|
21
|
+
*/
|
|
22
|
+
export declare function serializeFragment(fragment: ClipboardFragment): string;
|
|
23
|
+
/** One schema violation, flattened to a path string for display/logging. */
|
|
24
|
+
export interface FragmentIssue {
|
|
25
|
+
path: string;
|
|
26
|
+
message: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The closed taxonomy of parse failures. Every way untrusted clipboard content
|
|
30
|
+
* can be wrong maps to exactly one structured code — never an exception:
|
|
31
|
+
*
|
|
32
|
+
* - `corrupt-json` the string is not JSON at all
|
|
33
|
+
* - `foreign-format` valid JSON, but not an Elytra fragment envelope
|
|
34
|
+
* - `unsupported-version` our format, but a spec version this package does not read
|
|
35
|
+
* - `invalid-payload` our format + version, but the payload violates the schema
|
|
36
|
+
*/
|
|
37
|
+
export type FragmentParseError = {
|
|
38
|
+
code: 'corrupt-json';
|
|
39
|
+
message: string;
|
|
40
|
+
} | {
|
|
41
|
+
code: 'foreign-format';
|
|
42
|
+
message: string;
|
|
43
|
+
format?: string;
|
|
44
|
+
} | {
|
|
45
|
+
code: 'unsupported-version';
|
|
46
|
+
message: string;
|
|
47
|
+
version: number;
|
|
48
|
+
} | {
|
|
49
|
+
code: 'invalid-payload';
|
|
50
|
+
message: string;
|
|
51
|
+
issues: FragmentIssue[];
|
|
52
|
+
};
|
|
53
|
+
export type ParseFragmentResult = {
|
|
54
|
+
ok: true;
|
|
55
|
+
fragment: ClipboardFragment;
|
|
56
|
+
references: FragmentReferences;
|
|
57
|
+
} | {
|
|
58
|
+
ok: false;
|
|
59
|
+
error: FragmentParseError;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Parse a fragment from a JSON string or an already-parsed value. Never throws.
|
|
63
|
+
*
|
|
64
|
+
* Permissive by design: components unknown to the receiving registry and
|
|
65
|
+
* bindings the target cannot resolve still parse — the result's `references`
|
|
66
|
+
* enumerate every component/binding/asset the fragment points at so the
|
|
67
|
+
* consumer can diff them against its registry and raise its own issues.
|
|
68
|
+
*/
|
|
69
|
+
export declare function parseFragment(input: string | unknown): ParseFragmentResult;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { CLIPBOARD_FRAGMENT_FORMAT, CLIPBOARD_FRAGMENT_VERSION, clipboardFragmentSchema } from './fragment';
|
|
2
|
+
import { collectFragmentReferences } from './references';
|
|
3
|
+
/**
|
|
4
|
+
* Fragment serialization, following `@elytracms/core/project-graph`'s conventions:
|
|
5
|
+
* parse-before-serialize (the output contains no runtime-only values) and a
|
|
6
|
+
* never-throw parse. On top of that, serialization is *canonical* — object keys
|
|
7
|
+
* are sorted recursively — so build → serialize → parse → serialize is
|
|
8
|
+
* byte-identical regardless of property insertion order. Canonical bytes are
|
|
9
|
+
* what goes onto the OS clipboard (and into the HTML fallback's data
|
|
10
|
+
* attribute), so two copies of the same subtree are comparable as strings.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Deterministic JSON: arrays in order, object keys sorted recursively,
|
|
14
|
+
* `undefined` object values dropped (matching `JSON.stringify`).
|
|
15
|
+
*/
|
|
16
|
+
export function canonicalJsonStringify(value) {
|
|
17
|
+
return canonicalize(value) ?? 'null';
|
|
18
|
+
}
|
|
19
|
+
function canonicalize(value) {
|
|
20
|
+
if (value === null)
|
|
21
|
+
return 'null';
|
|
22
|
+
switch (typeof value) {
|
|
23
|
+
case 'string':
|
|
24
|
+
case 'number':
|
|
25
|
+
case 'boolean':
|
|
26
|
+
return JSON.stringify(value);
|
|
27
|
+
case 'object': {
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
// JSON.stringify renders un-serializable array items as null — match it.
|
|
30
|
+
return `[${value.map((item) => canonicalize(item) ?? 'null').join(',')}]`;
|
|
31
|
+
}
|
|
32
|
+
const entries = Object.entries(value)
|
|
33
|
+
.map(([key, item]) => [key, canonicalize(item)])
|
|
34
|
+
.filter((entry) => entry[1] !== undefined)
|
|
35
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
36
|
+
.map(([key, item]) => `${JSON.stringify(key)}:${item}`);
|
|
37
|
+
return `{${entries.join(',')}}`;
|
|
38
|
+
}
|
|
39
|
+
default:
|
|
40
|
+
// undefined / function / symbol — not representable, dropped by the caller.
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Serialize a fragment to canonical JSON. Parsing first guarantees the output
|
|
46
|
+
* is exactly the spec'd envelope (programmer error in the input throws — this
|
|
47
|
+
* is the trusted, in-process direction; `parseFragment` owns untrusted input).
|
|
48
|
+
*/
|
|
49
|
+
export function serializeFragment(fragment) {
|
|
50
|
+
const parsed = clipboardFragmentSchema.parse(fragment);
|
|
51
|
+
return canonicalJsonStringify(parsed);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Parse a fragment from a JSON string or an already-parsed value. Never throws.
|
|
55
|
+
*
|
|
56
|
+
* Permissive by design: components unknown to the receiving registry and
|
|
57
|
+
* bindings the target cannot resolve still parse — the result's `references`
|
|
58
|
+
* enumerate every component/binding/asset the fragment points at so the
|
|
59
|
+
* consumer can diff them against its registry and raise its own issues.
|
|
60
|
+
*/
|
|
61
|
+
export function parseFragment(input) {
|
|
62
|
+
let json;
|
|
63
|
+
if (typeof input === 'string') {
|
|
64
|
+
try {
|
|
65
|
+
json = JSON.parse(input);
|
|
66
|
+
}
|
|
67
|
+
catch (cause) {
|
|
68
|
+
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
69
|
+
return {
|
|
70
|
+
ok: false,
|
|
71
|
+
error: { code: 'corrupt-json', message: `Clipboard content is not valid JSON: ${detail}` },
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
json = input;
|
|
77
|
+
}
|
|
78
|
+
if (typeof json !== 'object' || json === null || Array.isArray(json)) {
|
|
79
|
+
return {
|
|
80
|
+
ok: false,
|
|
81
|
+
error: {
|
|
82
|
+
code: 'foreign-format',
|
|
83
|
+
message: 'Clipboard content is not an Elytra fragment envelope.',
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const probe = json;
|
|
88
|
+
if (probe.format !== CLIPBOARD_FRAGMENT_FORMAT) {
|
|
89
|
+
return {
|
|
90
|
+
ok: false,
|
|
91
|
+
error: {
|
|
92
|
+
code: 'foreign-format',
|
|
93
|
+
message: `Clipboard content is not an Elytra fragment (expected format "${CLIPBOARD_FRAGMENT_FORMAT}").`,
|
|
94
|
+
...(typeof probe.format === 'string' ? { format: probe.format } : {}),
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (typeof probe.version === 'number' && probe.version !== CLIPBOARD_FRAGMENT_VERSION) {
|
|
99
|
+
return {
|
|
100
|
+
ok: false,
|
|
101
|
+
error: {
|
|
102
|
+
code: 'unsupported-version',
|
|
103
|
+
message: probe.version > CLIPBOARD_FRAGMENT_VERSION
|
|
104
|
+
? `Fragment version ${probe.version} is newer than this studio supports (version ${CLIPBOARD_FRAGMENT_VERSION}).`
|
|
105
|
+
: `Fragment version ${probe.version} is not supported (this studio reads version ${CLIPBOARD_FRAGMENT_VERSION}).`,
|
|
106
|
+
version: probe.version,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const result = clipboardFragmentSchema.safeParse(json);
|
|
111
|
+
if (!result.success) {
|
|
112
|
+
return {
|
|
113
|
+
ok: false,
|
|
114
|
+
error: {
|
|
115
|
+
code: 'invalid-payload',
|
|
116
|
+
message: 'Clipboard fragment violates the fragment schema.',
|
|
117
|
+
issues: result.error.issues.map((issue) => ({
|
|
118
|
+
path: issue.path.map(String).join('/'),
|
|
119
|
+
message: issue.message,
|
|
120
|
+
})),
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
ok: true,
|
|
126
|
+
fragment: result.data,
|
|
127
|
+
references: collectFragmentReferences(result.data),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=serialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.js","sourceRoot":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AkD;gBAC3D,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBAC1C,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;oBACtC,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB,CAAC,CAAC;aACJ;SACF,CAAA;IACH,CAAC;IACD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,QAAQ,EAAE,MAAM,CAAC,IAAI;QACrB,UAAU,EAAE,yBAAyB,CAAC,MAAM,CAAC,IAAI,CAAC;KACnD,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { FieldDef } from './fields';
|
|
3
|
+
import type { CmsValidationIssue } from './issues';
|
|
4
|
+
/**
|
|
5
|
+
* The kind of a collection (brief §7.4).
|
|
6
|
+
* - `document` ordinary content collection (posts, pages, authors…).
|
|
7
|
+
* - `asset` the asset collection concept: holds uploaded media/files that
|
|
8
|
+
* `asset` fields point at (EC-017).
|
|
9
|
+
*/
|
|
10
|
+
export declare const collectionKindSchema: z.ZodEnum<{
|
|
11
|
+
asset: "asset";
|
|
12
|
+
document: "document";
|
|
13
|
+
}>;
|
|
14
|
+
export type CollectionKind = z.infer<typeof collectionKindSchema>;
|
|
15
|
+
/** Form metadata at the collection level (labels, ordering of groups/tabs). */
|
|
16
|
+
export declare const collectionFormMetaSchema: z.ZodObject<{
|
|
17
|
+
label: z.ZodOptional<z.ZodString>;
|
|
18
|
+
labelSingular: z.ZodOptional<z.ZodString>;
|
|
19
|
+
description: z.ZodOptional<z.ZodString>;
|
|
20
|
+
groups: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
+
tabs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type CollectionFormMeta = z.infer<typeof collectionFormMetaSchema>;
|
|
24
|
+
/**
|
|
25
|
+
* A collection definition: an id, a kind, an ordered list of fields, and
|
|
26
|
+
* optional form metadata. The field whose value identifies a document for
|
|
27
|
+
* routing/display defaults to `title` when present (see `titleFieldOf`).
|
|
28
|
+
*/
|
|
29
|
+
export declare const collectionDefSchema: z.ZodObject<{
|
|
30
|
+
id: z.ZodString;
|
|
31
|
+
kind: z.ZodDefault<z.ZodEnum<{
|
|
32
|
+
asset: "asset";
|
|
33
|
+
document: "document";
|
|
34
|
+
}>>;
|
|
35
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodType<FieldDef, unknown, z.core.$ZodTypeInternals<FieldDef, unknown>>>>;
|
|
36
|
+
form: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
label: z.ZodOptional<z.ZodString>;
|
|
38
|
+
labelSingular: z.ZodOptional<z.ZodString>;
|
|
39
|
+
description: z.ZodOptional<z.ZodString>;
|
|
40
|
+
groups: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
41
|
+
tabs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
+
titleField: z.ZodOptional<z.ZodString>;
|
|
45
|
+
singleton: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export type CollectionDef = z.infer<typeof collectionDefSchema>;
|
|
48
|
+
/** Look up a field by name within a collection. */
|
|
49
|
+
export declare function fieldOf(collection: CollectionDef, name: string): FieldDef | undefined;
|
|
50
|
+
/** The field used as the display title, if resolvable. */
|
|
51
|
+
export declare function titleFieldOf(collection: CollectionDef): FieldDef | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Is this a singleton collection — one fixed document, no list view (EC-217)?
|
|
54
|
+
* A singleton `asset` collection is a config error (asset collections are
|
|
55
|
+
* inherently multi-document); we defensively treat it as a normal asset
|
|
56
|
+
* collection so routing never mis-branches, and the registry surfaces the
|
|
57
|
+
* misconfiguration as an `invalid-collection-config` issue.
|
|
58
|
+
*/
|
|
59
|
+
export declare function isSingleton(collection: CollectionDef): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* The fixed document id for a singleton collection (EC-217): the collection id
|
|
62
|
+
* itself, so the one document is predictable and addressable
|
|
63
|
+
* (`{ collection: 'settings', id: 'settings' }`) without a generated key.
|
|
64
|
+
*/
|
|
65
|
+
export declare function singletonDocId(collection: CollectionDef): string;
|
|
66
|
+
/**
|
|
67
|
+
* A metadata registry of collections, keyed by id (brief §7.4 "metadata
|
|
68
|
+
* registries"). Construction validates structural invariants (duplicate
|
|
69
|
+
* collection/field ids) and surfaces them as structured issues rather than
|
|
70
|
+
* throwing — an invalid registry is still inspectable.
|
|
71
|
+
*/
|
|
72
|
+
export interface CollectionRegistry {
|
|
73
|
+
readonly collections: ReadonlyMap<string, CollectionDef>;
|
|
74
|
+
readonly issues: readonly CmsValidationIssue[];
|
|
75
|
+
get(id: string): CollectionDef | undefined;
|
|
76
|
+
has(id: string): boolean;
|
|
77
|
+
list(): CollectionDef[];
|
|
78
|
+
/** Asset-kind collections only (EC-017). */
|
|
79
|
+
assetCollections(): CollectionDef[];
|
|
80
|
+
}
|
|
81
|
+
/** Build a collection registry from definitions, collecting structural issues. */
|
|
82
|
+
export declare function createCollectionRegistry(defs: readonly CollectionDef[]): CollectionRegistry;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { RESERVED_NODE_KEYS } from './envelopes';
|
|
3
|
+
import { fieldDefSchema } from './fields';
|
|
4
|
+
import { cmsIssue } from './issues';
|
|
5
|
+
/**
|
|
6
|
+
* The kind of a collection (brief §7.4).
|
|
7
|
+
* - `document` ordinary content collection (posts, pages, authors…).
|
|
8
|
+
* - `asset` the asset collection concept: holds uploaded media/files that
|
|
9
|
+
* `asset` fields point at (EC-017).
|
|
10
|
+
*/
|
|
11
|
+
export const collectionKindSchema = z.enum(['document', 'asset']);
|
|
12
|
+
/** Form metadata at the collection level (labels, ordering of groups/tabs). */
|
|
13
|
+
export const collectionFormMetaSchema = z.object({
|
|
14
|
+
/** Plural human label, e.g. "Blog Posts". */
|
|
15
|
+
label: z.string().optional(),
|
|
16
|
+
/** Singular human label, e.g. "Blog Post". */
|
|
17
|
+
labelSingular: z.string().optional(),
|
|
18
|
+
description: z.string().optional(),
|
|
19
|
+
/** Declared ordering of form groups (fieldsets). */
|
|
20
|
+
groups: z.array(z.string()).optional(),
|
|
21
|
+
/** Declared ordering of form tabs. */
|
|
22
|
+
tabs: z.array(z.string()).optional(),
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* A collection definition: an id, a kind, an ordered list of fields, and
|
|
26
|
+
* optional form metadata. The field whose value identifies a document for
|
|
27
|
+
* routing/display defaults to `title` when present (see `titleFieldOf`).
|
|
28
|
+
*/
|
|
29
|
+
export const collectionDefSchema = z.object({
|
|
30
|
+
id: z.string().min(1),
|
|
31
|
+
kind: collectionKindSchema.default('document'),
|
|
32
|
+
fields: z.array(fieldDefSchema).default([]),
|
|
33
|
+
form: collectionFormMetaSchema.optional(),
|
|
34
|
+
/** When true, documents in this collection support localized variants (EC-018). */
|
|
35
|
+
localized: z.boolean().optional(),
|
|
36
|
+
/** Name of the field used as the document's display title (defaults to `title`). */
|
|
37
|
+
titleField: z.string().optional(),
|
|
38
|
+
/**
|
|
39
|
+
* When true, this collection holds exactly ONE fixed document — Settings,
|
|
40
|
+
* Menus, Footer, Homepage SEO… (EC-217). The studio skips the list view and
|
|
41
|
+
* opens the detail editor directly on the single document. Pure authoring
|
|
42
|
+
* sugar: internally identical to a `document` collection, so the engine,
|
|
43
|
+
* delivery, and validation paths are unchanged. Meaningless on an `asset`
|
|
44
|
+
* collection (flagged as `invalid-collection-config`).
|
|
45
|
+
*/
|
|
46
|
+
singleton: z.boolean().optional(),
|
|
47
|
+
});
|
|
48
|
+
/** Look up a field by name within a collection. */
|
|
49
|
+
export function fieldOf(collection, name) {
|
|
50
|
+
return collection.fields.find((f) => f.name === name);
|
|
51
|
+
}
|
|
52
|
+
/** The field used as the display title, if resolvable. */
|
|
53
|
+
export function titleFieldOf(collection) {
|
|
54
|
+
const name = collection.titleField ?? 'title';
|
|
55
|
+
return fieldOf(collection, name);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Is this a singleton collection — one fixed document, no list view (EC-217)?
|
|
59
|
+
* A singleton `asset` collection is a config error (asset collections are
|
|
60
|
+
* inherently multi-document); we defensively treat it as a normal asset
|
|
61
|
+
* collection so routing never mis-branches, and the registry surfaces the
|
|
62
|
+
* misconfiguration as an `invalid-collection-config` issue.
|
|
63
|
+
*/
|
|
64
|
+
export function isSingleton(collection) {
|
|
65
|
+
return collection.singleton === true && collection.kind !== 'asset';
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The fixed document id for a singleton collection (EC-217): the collection id
|
|
69
|
+
* itself, so the one document is predictable and addressable
|
|
70
|
+
* (`{ collection: 'settings', id: 'settings' }`) without a generated key.
|
|
71
|
+
*/
|
|
72
|
+
export function singletonDocId(collection) {
|
|
73
|
+
return collection.id;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Recursively validate a single field's shape (EC-253): select-option uniqueness,
|
|
77
|
+
* plus — for an `object` field — unique subfield names and the same checks applied
|
|
78
|
+
* recursively to its nested fields. Pure; collects structured issues, never throws.
|
|
79
|
+
*/
|
|
80
|
+
function validateFieldShape(field, fieldPath, collectionId, issues) {
|
|
81
|
+
// EC-277 (AD-15): `type` is reserved as the self-describing node discriminator, so
|
|
82
|
+
// a value object can never carry a user field that collides with it. The schema
|
|
83
|
+
// lens forbids declaring such a field — surfaced as a visible issue, never silent.
|
|
84
|
+
if (RESERVED_NODE_KEYS.has(field.name)) {
|
|
85
|
+
issues.push(cmsIssue({
|
|
86
|
+
code: 'reserved-field-name',
|
|
87
|
+
message: `Field name "${field.name}" is reserved (the self-describing node discriminator).`,
|
|
88
|
+
path: [...fieldPath, 'name'],
|
|
89
|
+
collectionId,
|
|
90
|
+
meta: { field: field.name },
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
// select fields must declare at least one option (schema enforces min(1), but a
|
|
94
|
+
// select with duplicate option values is a config error we surface).
|
|
95
|
+
if (field.type === 'select') {
|
|
96
|
+
const values = new Set();
|
|
97
|
+
for (const opt of field.options) {
|
|
98
|
+
if (values.has(opt.value)) {
|
|
99
|
+
issues.push(cmsIssue({
|
|
100
|
+
code: 'invalid-field-config',
|
|
101
|
+
message: `Duplicate select option "${opt.value}" on field "${field.name}".`,
|
|
102
|
+
path: [...fieldPath, 'options'],
|
|
103
|
+
collectionId,
|
|
104
|
+
meta: { field: field.name, option: opt.value },
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
values.add(opt.value);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else if (field.type === 'object') {
|
|
111
|
+
const seen = new Set();
|
|
112
|
+
field.fields.forEach((sub, i) => {
|
|
113
|
+
if (seen.has(sub.name)) {
|
|
114
|
+
issues.push(cmsIssue({
|
|
115
|
+
code: 'duplicate-field',
|
|
116
|
+
message: `Duplicate field "${sub.name}" in object field "${field.name}".`,
|
|
117
|
+
path: [...fieldPath, 'fields', i],
|
|
118
|
+
collectionId,
|
|
119
|
+
meta: { field: sub.name },
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
seen.add(sub.name);
|
|
124
|
+
}
|
|
125
|
+
validateFieldShape(sub, [...fieldPath, 'fields', i], collectionId, issues);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function validateCollectionShape(collection) {
|
|
130
|
+
const issues = [];
|
|
131
|
+
// EC-217: an asset collection is inherently multi-document — `singleton` is a
|
|
132
|
+
// nonsensical combination, surfaced rather than silently ignored.
|
|
133
|
+
if (collection.singleton === true && collection.kind === 'asset') {
|
|
134
|
+
issues.push(cmsIssue({
|
|
135
|
+
code: 'invalid-collection-config',
|
|
136
|
+
message: `Asset collection "${collection.id}" cannot be a singleton.`,
|
|
137
|
+
path: ['collections', collection.id],
|
|
138
|
+
collectionId: collection.id,
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
const seenFields = new Set();
|
|
142
|
+
collection.fields.forEach((field, i) => {
|
|
143
|
+
if (seenFields.has(field.name)) {
|
|
144
|
+
issues.push(cmsIssue({
|
|
145
|
+
code: 'duplicate-field',
|
|
146
|
+
message: `Duplicate field "${field.name}" in collection "${collection.id}".`,
|
|
147
|
+
path: ['collections', collection.id, 'fields', i],
|
|
148
|
+
collectionId: collection.id,
|
|
149
|
+
meta: { field: field.name },
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
seenFields.add(field.name);
|
|
154
|
+
}
|
|
155
|
+
validateFieldShape(field, ['collections', collection.id, 'fields', i], collection.id, issues);
|
|
156
|
+
});
|
|
157
|
+
return issues;
|
|
158
|
+
}
|
|
159
|
+
/** Build a collection registry from definitions, collecting structural issues. */
|
|
160
|
+
export function createCollectionRegistry(defs) {
|
|
161
|
+
const collections = new Map();
|
|
162
|
+
const issues = [];
|
|
163
|
+
for (const raw of defs) {
|
|
164
|
+
// Apply schema defaults (kind, fields) deterministically.
|
|
165
|
+
const def = collectionDefSchema.parse(raw);
|
|
166
|
+
if (collections.has(def.id)) {
|
|
167
|
+
issues.push(cmsIssue({
|
|
168
|
+
code: 'duplicate-collection',
|
|
169
|
+
message: `Duplicate collection id "${def.id}".`,
|
|
170
|
+
path: ['collections', def.id],
|
|
171
|
+
collectionId: def.id,
|
|
172
|
+
}));
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
collections.set(def.id, def);
|
|
176
|
+
issues.push(...validateCollectionShape(def));
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
collections,
|
|
180
|
+
issues,
|
|
181
|
+
get: (id) => collections.get(id),
|
|
182
|
+
has: (id) => collections.has(id),
|
|
183
|
+
list: () => [...collections.values()],
|
|
184
|
+
assetCollections: () => [...collections.values()].filter((c) => c.kind === 'asset'),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=collections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/cms-core/collections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGnC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAA;AAGjE,+EAA+E;AAC/E,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,6CAA6C;IAC7C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,8CAA8C;IAC9C,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACpC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,oDAAoD;IACpD,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACtC,sCAAsC;IACtC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAA;AAGF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,CAAC,CAAC,MA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E,GAAG,CAAC,EAAE,CAAC;gBAC7B,YAAY,EAAE,GAAG,CAAC,EAAE;aACrB,CAAC,CACH,CAAA;YACD,SAAQ;QACV,CAAC;QACD,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;QAC5B,MAAM,CAAC,IAAI,CAAC,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED,OAAO;QACL,WAAW;QACX,MAAM;QACN,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC;QACrC,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC;KACpF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* A locale code (BCP-47-ish, e.g. `en`, `en-US`, `de`). Kept as a plain
|
|
4
|
+
* non-empty string so unusual locales still parse; validity against a project's
|
|
5
|
+
* declared locale set is checked semantically (EC-018).
|
|
6
|
+
*/
|
|
7
|
+
export declare const localeSchema: z.ZodString;
|
|
8
|
+
export type Locale = z.infer<typeof localeSchema>;
|
|
9
|
+
/**
|
|
10
|
+
* A document identity (EC-017): the stable pointer to a piece of content. A
|
|
11
|
+
* document belongs to exactly one collection and has a stable id. For localized
|
|
12
|
+
* content the *identity* is collection+id; a specific localized variant is
|
|
13
|
+
* addressed by additionally carrying a locale (see `LocaleAwareDocumentRef`).
|
|
14
|
+
*/
|
|
15
|
+
export declare const documentRefSchema: z.ZodObject<{
|
|
16
|
+
collection: z.ZodString;
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type DocumentRef = z.infer<typeof documentRefSchema>;
|
|
20
|
+
/** A document identity together with a specific locale (EC-018). */
|
|
21
|
+
export declare const localeAwareDocumentRefSchema: z.ZodObject<{
|
|
22
|
+
collection: z.ZodString;
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
locale: z.ZodString;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export type LocaleAwareDocumentRef = z.infer<typeof localeAwareDocumentRefSchema>;
|
|
27
|
+
/** Stable string key for a document identity. */
|
|
28
|
+
export declare function documentKey(ref: DocumentRef): string;
|
|
29
|
+
/** Stable string key for a locale-aware document identity. */
|
|
30
|
+
export declare function localeAwareDocumentKey(ref: LocaleAwareDocumentRef): string;
|
|
31
|
+
/** Equality on document identity (collection + id), ignoring locale. */
|
|
32
|
+
export declare function documentRefEquals(a: DocumentRef, b: DocumentRef): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Target state of a publish/unpublish *action* (EC-021). No longer a stored
|
|
35
|
+
* document field (EC-224 retired it — publish-ness is the version pointer, see
|
|
36
|
+
* `publishedVersion`); this enum names the *intent* of a bulk publish/unpublish
|
|
37
|
+
* action (the studio's `applyState` contract), not a property a row carries.
|
|
38
|
+
*/
|
|
39
|
+
export declare const publicationStateSchema: z.ZodEnum<{
|
|
40
|
+
draft: "draft";
|
|
41
|
+
published: "published";
|
|
42
|
+
}>;
|
|
43
|
+
export type PublicationState = z.infer<typeof publicationStateSchema>;
|
|
44
|
+
/**
|
|
45
|
+
* A bag of field values for a single (locale of a) document. Values are arbitrary
|
|
46
|
+
* JSON — validated against the collection's fields by `validateDocument`, not at
|
|
47
|
+
* this layer. Relations store `DocumentRef`(s); assets store asset ids.
|
|
48
|
+
*/
|
|
49
|
+
export type FieldValues = Record<string, unknown>;
|
|
50
|
+
/**
|
|
51
|
+
* A stored document (EC-016/017/018). The live row is the continuous DRAFT
|
|
52
|
+
* (the Sanity model, EC-224). Holds:
|
|
53
|
+
* - identity (`collection` + `id`),
|
|
54
|
+
* - non-localized field values in `values`,
|
|
55
|
+
* - per-locale field values in `localized` (only for localized fields).
|
|
56
|
+
*
|
|
57
|
+
* Publish-ness is NOT a field here: a document is published when an append-only
|
|
58
|
+
* version is pinned via the record's `publishedVersion` pointer (EC-224). The
|
|
59
|
+
* delivery `published` perspective serves that pinned snapshot; this live row
|
|
60
|
+
* is always the working draft.
|
|
61
|
+
*/
|
|
62
|
+
export declare const documentSchema: z.ZodObject<{
|
|
63
|
+
collection: z.ZodString;
|
|
64
|
+
id: z.ZodString;
|
|
65
|
+
values: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
66
|
+
localized: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
67
|
+
defaultLocale: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
export type CmsDocument = z.infer<typeof documentSchema>;
|
|
70
|
+
/** The identity of a stored document. */
|
|
71
|
+
export declare function refOf(doc: CmsDocument): DocumentRef;
|