@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,191 @@
|
|
|
1
|
+
import { assetNode, isAssetNode, isReferenceNode, referenceNode } from './envelopes';
|
|
2
|
+
// --- Rich-text internal-link conventions (the conversion/migration home) -----------
|
|
3
|
+
/**
|
|
4
|
+
* The legacy fuzzy href prefixes (EC-025) self-typing REPLACES. Internal links used
|
|
5
|
+
* to encode their target in the `href` string; EC-277 carries it as a structured
|
|
6
|
+
* `attrs.ref` envelope instead, leaving `href` for external URLs only. These
|
|
7
|
+
* constants live here because this lens is the one place that still READS them — to
|
|
8
|
+
* migrate them away.
|
|
9
|
+
*/
|
|
10
|
+
const RICH_TEXT_DOCUMENT_HREF_PREFIX = 'elytra:document/';
|
|
11
|
+
const RICH_TEXT_ASSET_HREF_PREFIX = 'elytra:asset/';
|
|
12
|
+
function isPlainRecord(value) {
|
|
13
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
14
|
+
}
|
|
15
|
+
function selfTypeRelationValue(value) {
|
|
16
|
+
if (isReferenceNode(value))
|
|
17
|
+
return value;
|
|
18
|
+
if (isPlainRecord(value) &&
|
|
19
|
+
typeof value.collection === 'string' &&
|
|
20
|
+
typeof value.id === 'string') {
|
|
21
|
+
return referenceNode({ collection: value.collection, id: value.id });
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
function selfTypeAssetValue(value) {
|
|
26
|
+
if (isAssetNode(value))
|
|
27
|
+
return value;
|
|
28
|
+
if (typeof value === 'string' && value.length > 0)
|
|
29
|
+
return assetNode(value);
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
// --- Composition (blocks) -----------------------------------------------------------
|
|
33
|
+
/** Self-type one composition node's static props (via the manifest) + recurse slots. */
|
|
34
|
+
function selfTypeComponentNode(node, options) {
|
|
35
|
+
const next = { ...node };
|
|
36
|
+
const propDefs = options.lookupManifest?.(node.componentId);
|
|
37
|
+
if (node.props && propDefs) {
|
|
38
|
+
const props = {};
|
|
39
|
+
for (const [name, prop] of Object.entries(node.props)) {
|
|
40
|
+
const def = propDefs[name];
|
|
41
|
+
// Only STATIC props carry self-typed values; bindings are parked (EC-187).
|
|
42
|
+
props[name] =
|
|
43
|
+
prop.kind === 'static' && def
|
|
44
|
+
? { kind: 'static', value: selfTypeFieldValue(def, prop.value, options) }
|
|
45
|
+
: prop;
|
|
46
|
+
}
|
|
47
|
+
next.props = props;
|
|
48
|
+
}
|
|
49
|
+
if (node.slots) {
|
|
50
|
+
next.slots = Object.fromEntries(Object.entries(node.slots).map(([slot, children]) => [
|
|
51
|
+
slot,
|
|
52
|
+
children.map((child) => selfTypeComponentNode(child, options)),
|
|
53
|
+
]));
|
|
54
|
+
}
|
|
55
|
+
return next;
|
|
56
|
+
}
|
|
57
|
+
function selfTypeBlocksValue(value, options) {
|
|
58
|
+
if (Array.isArray(value))
|
|
59
|
+
return value.map((root) => selfTypeBlocksValue(root, options));
|
|
60
|
+
if (isComponentNodeShape(value))
|
|
61
|
+
return selfTypeComponentNode(value, options);
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
function isComponentNodeShape(value) {
|
|
65
|
+
return isPlainRecord(value) && typeof value.id === 'string' && typeof value.componentId === 'string';
|
|
66
|
+
}
|
|
67
|
+
// --- Rich text ----------------------------------------------------------------------
|
|
68
|
+
/** Convert a legacy internal `elytra:` href to a self-typed `ref` envelope (or undefined). */
|
|
69
|
+
function refFromLegacyHref(href) {
|
|
70
|
+
if (href.startsWith(RICH_TEXT_DOCUMENT_HREF_PREFIX)) {
|
|
71
|
+
const [collection, id] = href.slice(RICH_TEXT_DOCUMENT_HREF_PREFIX.length).split('/');
|
|
72
|
+
if (collection && id)
|
|
73
|
+
return referenceNode({ collection, id });
|
|
74
|
+
}
|
|
75
|
+
else if (href.startsWith(RICH_TEXT_ASSET_HREF_PREFIX)) {
|
|
76
|
+
const id = href.slice(RICH_TEXT_ASSET_HREF_PREFIX.length);
|
|
77
|
+
if (id)
|
|
78
|
+
return assetNode(id);
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
/** Self-type a rich-text attrs bag: legacy href / docRef / assetId → structured `ref`. */
|
|
83
|
+
function selfTypeRichTextAttrs(attrs) {
|
|
84
|
+
if (isReferenceNode(attrs.ref) || isAssetNode(attrs.ref))
|
|
85
|
+
return attrs; // already self-typed
|
|
86
|
+
const next = { ...attrs };
|
|
87
|
+
if (typeof attrs.href === 'string') {
|
|
88
|
+
const ref = refFromLegacyHref(attrs.href);
|
|
89
|
+
if (ref) {
|
|
90
|
+
next.ref = ref;
|
|
91
|
+
delete next.href; // internal link: target now lives in `ref`, not the href string
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (isPlainRecord(attrs.docRef) && typeof attrs.docRef.collection === 'string' && typeof attrs.docRef.id === 'string') {
|
|
95
|
+
next.ref = referenceNode({ collection: attrs.docRef.collection, id: attrs.docRef.id });
|
|
96
|
+
delete next.docRef;
|
|
97
|
+
}
|
|
98
|
+
else if (typeof attrs.assetId === 'string' && attrs.assetId.length > 0) {
|
|
99
|
+
next.ref = assetNode(attrs.assetId);
|
|
100
|
+
delete next.assetId;
|
|
101
|
+
}
|
|
102
|
+
return next;
|
|
103
|
+
}
|
|
104
|
+
function selfTypeRichTextNode(node, options) {
|
|
105
|
+
if (!isPlainRecord(node))
|
|
106
|
+
return node;
|
|
107
|
+
const next = { ...node };
|
|
108
|
+
if (isPlainRecord(node.attrs)) {
|
|
109
|
+
let attrs = selfTypeRichTextAttrs(node.attrs);
|
|
110
|
+
// EC-189: a `componentEmbed` node nests a ComponentNode under `attrs.node`.
|
|
111
|
+
if (isComponentNodeShape(attrs.node)) {
|
|
112
|
+
attrs = { ...attrs, node: selfTypeComponentNode(attrs.node, options) };
|
|
113
|
+
}
|
|
114
|
+
next.attrs = attrs;
|
|
115
|
+
}
|
|
116
|
+
if (Array.isArray(node.marks)) {
|
|
117
|
+
next.marks = node.marks.map((mark) => isPlainRecord(mark) && isPlainRecord(mark.attrs)
|
|
118
|
+
? { ...mark, attrs: selfTypeRichTextAttrs(mark.attrs) }
|
|
119
|
+
: mark);
|
|
120
|
+
}
|
|
121
|
+
if (Array.isArray(node.content)) {
|
|
122
|
+
next.content = node.content.map((child) => selfTypeRichTextNode(child, options));
|
|
123
|
+
}
|
|
124
|
+
return next;
|
|
125
|
+
}
|
|
126
|
+
function selfTypeRichTextValue(value, options) {
|
|
127
|
+
if (!isPlainRecord(value) || !isPlainRecord(value.doc) || value.doc.type !== 'doc')
|
|
128
|
+
return value;
|
|
129
|
+
return { ...value, doc: selfTypeRichTextNode(value.doc, options) };
|
|
130
|
+
}
|
|
131
|
+
// --- Field / document entry points --------------------------------------------------
|
|
132
|
+
/** Self-type one field value through the lens of its field-def. Idempotent. */
|
|
133
|
+
export function selfTypeFieldValue(field, value, options = {}) {
|
|
134
|
+
if (value === undefined || value === null)
|
|
135
|
+
return value;
|
|
136
|
+
switch (field.type) {
|
|
137
|
+
case 'relation':
|
|
138
|
+
return Array.isArray(value) ? value.map(selfTypeRelationValue) : selfTypeRelationValue(value);
|
|
139
|
+
case 'asset':
|
|
140
|
+
return Array.isArray(value) ? value.map(selfTypeAssetValue) : selfTypeAssetValue(value);
|
|
141
|
+
case 'blocks':
|
|
142
|
+
return selfTypeBlocksValue(value, options);
|
|
143
|
+
case 'richText':
|
|
144
|
+
return selfTypeRichTextValue(value, options);
|
|
145
|
+
case 'object': {
|
|
146
|
+
const one = (item) => {
|
|
147
|
+
if (!isPlainRecord(item))
|
|
148
|
+
return item;
|
|
149
|
+
const next = { ...item };
|
|
150
|
+
for (const sub of field.fields) {
|
|
151
|
+
if (sub.name in next)
|
|
152
|
+
next[sub.name] = selfTypeFieldValue(sub, next[sub.name], options);
|
|
153
|
+
}
|
|
154
|
+
return next;
|
|
155
|
+
};
|
|
156
|
+
return field.cardinality === 'many' && Array.isArray(value) ? value.map(one) : one(value);
|
|
157
|
+
}
|
|
158
|
+
default:
|
|
159
|
+
// text/number/boolean/date/select carry no references.
|
|
160
|
+
return value;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/** Self-type a bag of field values through a collection's field-defs. */
|
|
164
|
+
function selfTypeValues(fields, values, options) {
|
|
165
|
+
const next = { ...values };
|
|
166
|
+
for (const field of fields) {
|
|
167
|
+
if (field.name in next)
|
|
168
|
+
next[field.name] = selfTypeFieldValue(field, next[field.name], options);
|
|
169
|
+
}
|
|
170
|
+
return next;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Self-type a whole document (its `values` and every `localized` locale) through the
|
|
174
|
+
* collection schema. Returns a new document; the input is not mutated. A document
|
|
175
|
+
* whose collection is absent from the schema is returned unchanged (drift-tolerant —
|
|
176
|
+
* AD-14: the store never blocks on schema divergence).
|
|
177
|
+
*/
|
|
178
|
+
export function selfTypeDocument(document, collection, options = {}) {
|
|
179
|
+
const next = {
|
|
180
|
+
...document,
|
|
181
|
+
values: selfTypeValues(collection.fields, document.values ?? {}, options),
|
|
182
|
+
};
|
|
183
|
+
if (document.localized) {
|
|
184
|
+
next.localized = Object.fromEntries(Object.entries(document.localized).map(([locale, values]) => [
|
|
185
|
+
locale,
|
|
186
|
+
selfTypeValues(collection.fields, values, options),
|
|
187
|
+
]));
|
|
188
|
+
}
|
|
189
|
+
return next;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=self-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-type.js","sourceRoot":"","sources":["../../src/cms-core/self-type.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAmCpF,sFAAsF;AAEtF;;;;;;GAMG;AACH,MAAM,8BAA8B,GAAG,kBAAkB,CAAA;AACzD,MAAM,2BAA2B,GAAG,eAAe,CAAA;AAEnD,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc;IAC3C,IAAI,eAAe,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IACxC,IACE,aAAa,CAAC,KAAK,CAAC;QACpB,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ;QACpC,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ,EAC5B,CAAC;QACD,OAAO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AM,IAAI,GAAgB;QACxB,GAAG,QAAQ;QACX,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,IAAI,EAAE,EAAE,OAAO,CAAC;KAC1E,CAAA;IACD,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,CACjC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;YAC3D,MAAM;YACN,cAAc,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC;SACnD,CAAC,CACH,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { CollectionDef } from './collections';
|
|
2
|
+
import type { CmsDocument } from './documents';
|
|
3
|
+
import type { LocaleConfig } from './localization';
|
|
4
|
+
import type { HierarchyConfig } from './hierarchy';
|
|
5
|
+
import type { RouteRecord } from './routes';
|
|
6
|
+
export interface DocumentUrlConfig {
|
|
7
|
+
/** The project's route records (config-sourced, EC-207). */
|
|
8
|
+
routes: readonly RouteRecord[];
|
|
9
|
+
/** Public base URL (EC-215). When set, the result carries an absolute `href`. */
|
|
10
|
+
frontendUrl?: string;
|
|
11
|
+
/** Locale config — enables locale prefixing + localized slug resolution. */
|
|
12
|
+
localeConfig?: LocaleConfig;
|
|
13
|
+
/** Hierarchy field names (EC-218); defaults to `parent`/`slug`. */
|
|
14
|
+
hierarchy?: HierarchyConfig;
|
|
15
|
+
}
|
|
16
|
+
export interface DocumentUrl {
|
|
17
|
+
/** The resolved path, always starting with `/` (locale prefix applied). */
|
|
18
|
+
path: string;
|
|
19
|
+
/** Absolute URL — present only when `frontendUrl` was provided. */
|
|
20
|
+
href?: string;
|
|
21
|
+
/** The route record that addresses the document. */
|
|
22
|
+
route: RouteRecord;
|
|
23
|
+
}
|
|
24
|
+
export interface UrlForDocumentContext {
|
|
25
|
+
/**
|
|
26
|
+
* Sibling documents in the same collection — required to compose a nested
|
|
27
|
+
* (hierarchy-mount) path from the parent chain. Defaults to `[doc]`.
|
|
28
|
+
*/
|
|
29
|
+
siblings?: readonly CmsDocument[];
|
|
30
|
+
/** Locale to build the URL for; defaults to `localeConfig.default`. */
|
|
31
|
+
locale?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Derive a document's public URL from the project's routes (EC-216), or
|
|
35
|
+
* `undefined` when no route addresses it (a non-routable collection, or a
|
|
36
|
+
* hierarchy page with no slug / a broken parent chain). Pure: the URL is always
|
|
37
|
+
* derived, never read from a stored field.
|
|
38
|
+
*/
|
|
39
|
+
export declare function urlForDocument(config: DocumentUrlConfig, collection: CollectionDef, doc: CmsDocument, context?: UrlForDocumentContext): DocumentUrl | undefined;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { resolveField } from './localization';
|
|
2
|
+
import { composePath, hierarchyMount, isHierarchyTemplate } from './hierarchy';
|
|
3
|
+
import { splitPath } from './routes';
|
|
4
|
+
/**
|
|
5
|
+
* Documents know their URL (EC-216). The inverse of route resolution: given a
|
|
6
|
+
* document and the project's config-sourced routes (EC-207), DERIVE its public
|
|
7
|
+
* URL — never store it (AD-11). This mirrors delivery's forward resolution
|
|
8
|
+
* (`@elytracms/core/content`) exactly so the URL a document advertises is the one the
|
|
9
|
+
* live site serves:
|
|
10
|
+
*
|
|
11
|
+
* - A literal-id route (`/about` → `page:about`) addresses only its one document.
|
|
12
|
+
* - A template route (`/blog/:slug` → `post::slug`) is filled from the document's
|
|
13
|
+
* `slug` field, falling back to its id — the inverse of delivery's
|
|
14
|
+
* `lookup.document(id) ?? findBySlug(slug)`.
|
|
15
|
+
* - A hierarchy mount (`/:path*`, EC-218) composes the full nested path from the
|
|
16
|
+
* parent chain, so renaming a parent re-derives every descendant's URL.
|
|
17
|
+
*
|
|
18
|
+
* The locale prefix follows the host's own convention (`splitLocalePath` in
|
|
19
|
+
* `@elytracms/next`): the default locale serves at the root, other locales are
|
|
20
|
+
* `/{locale}`-prefixed. Patterns are locale-agnostic; the prefix is applied here.
|
|
21
|
+
*
|
|
22
|
+
* Perspective: the URL is derived from the documents you pass in. In the studio
|
|
23
|
+
* those are the DRAFT rows, so a published document whose `slug` (or a parent's)
|
|
24
|
+
* was edited but not yet re-published advertises its *pending* URL — the one that
|
|
25
|
+
* goes live on the next publish. For the common case (slug unchanged since
|
|
26
|
+
* publish) this equals the live URL; the studio publish-gates the "open live"
|
|
27
|
+
* action so an unpublished document never links anywhere.
|
|
28
|
+
*/
|
|
29
|
+
const SLUG_FIELD = 'slug';
|
|
30
|
+
/** The document's `slug` field value (locale-resolved when possible), or undefined. */
|
|
31
|
+
function readSlugValue(doc, collection, locale, localeConfig) {
|
|
32
|
+
if (!collection.fields.some((f) => f.name === SLUG_FIELD))
|
|
33
|
+
return undefined;
|
|
34
|
+
const raw = localeConfig && locale !== undefined
|
|
35
|
+
? resolveField(collection, doc, SLUG_FIELD, locale, localeConfig).value
|
|
36
|
+
: doc.values[SLUG_FIELD];
|
|
37
|
+
return typeof raw === 'string' && raw.length > 0 ? raw : undefined;
|
|
38
|
+
}
|
|
39
|
+
/** Build the (locale-agnostic) path a single route would serve for `doc`, or undefined. */
|
|
40
|
+
function pathForRoute(route, doc, collection, locale, localeConfig, getById, hierarchy) {
|
|
41
|
+
const target = route.document;
|
|
42
|
+
if (!target || target.collection !== collection.id)
|
|
43
|
+
return undefined;
|
|
44
|
+
// Hierarchy mount (EC-218): the path is the composed nested chain.
|
|
45
|
+
if (isHierarchyTemplate(route)) {
|
|
46
|
+
const mount = hierarchyMount(route);
|
|
47
|
+
if (!mount)
|
|
48
|
+
return undefined;
|
|
49
|
+
const composed = composePath(doc, getById, hierarchy);
|
|
50
|
+
if (!composed.ok)
|
|
51
|
+
return undefined;
|
|
52
|
+
return '/' + [...mount.prefix, ...composed.segments].join('/');
|
|
53
|
+
}
|
|
54
|
+
const idParam = target.id.startsWith(':') ? target.id.slice(1) : null;
|
|
55
|
+
// A literal-id route addresses only its one bound document.
|
|
56
|
+
if (idParam === null && target.id !== doc.id)
|
|
57
|
+
return undefined;
|
|
58
|
+
// The doc-id param resolves to the slug field, else the id. Delivery is
|
|
59
|
+
// id-FIRST (`lookup.document(id) ?? findBySlug(slug)`), so if this document's
|
|
60
|
+
// slug equals a DIFFERENT sibling's id, emitting the slug would round-trip to
|
|
61
|
+
// that other document — fall back to this doc's id to stay correct. (Detectable
|
|
62
|
+
// only when siblings are supplied; the bare-helper default cannot see them.)
|
|
63
|
+
const slugValue = readSlugValue(doc, collection, locale, localeConfig);
|
|
64
|
+
const collides = slugValue !== undefined && slugValue !== doc.id && getById(slugValue) !== undefined;
|
|
65
|
+
const identValue = slugValue !== undefined && !collides ? slugValue : doc.id;
|
|
66
|
+
const segments = [];
|
|
67
|
+
for (const seg of splitPath(route.pattern)) {
|
|
68
|
+
if (!seg.startsWith(':')) {
|
|
69
|
+
segments.push(seg);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const name = seg.replace(/[*+?]$/, '').slice(1);
|
|
73
|
+
if (idParam !== null && name === idParam) {
|
|
74
|
+
segments.push(encodeURIComponent(identValue));
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
// Any other pattern param is filled from the document's same-named field.
|
|
78
|
+
const value = doc.values[name];
|
|
79
|
+
if (typeof value !== 'string' || value.length === 0)
|
|
80
|
+
return undefined;
|
|
81
|
+
segments.push(encodeURIComponent(value));
|
|
82
|
+
}
|
|
83
|
+
return '/' + segments.join('/');
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Rank addressing routes so the most specific wins, mirroring the router's
|
|
87
|
+
* precedence: an exact locale match, then an explicit route over the catch-all
|
|
88
|
+
* mount, then more static segments / fewer params.
|
|
89
|
+
*/
|
|
90
|
+
function routeRank(route, locale) {
|
|
91
|
+
let score = 0;
|
|
92
|
+
if (route.locale !== undefined && route.locale === locale)
|
|
93
|
+
score += 1000;
|
|
94
|
+
if (!isHierarchyTemplate(route))
|
|
95
|
+
score += 100;
|
|
96
|
+
const segs = splitPath(route.pattern);
|
|
97
|
+
const statics = segs.filter((s) => !s.startsWith(':')).length;
|
|
98
|
+
score += statics * 10 - (segs.length - statics);
|
|
99
|
+
return score;
|
|
100
|
+
}
|
|
101
|
+
/** Apply the host's locale-prefix convention: default at root, others `/{locale}`. */
|
|
102
|
+
function applyLocalePrefix(path, locale, config) {
|
|
103
|
+
if (!config || locale === undefined || locale === config.default)
|
|
104
|
+
return path;
|
|
105
|
+
return path === '/' ? `/${locale}` : `/${locale}${path}`;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Derive a document's public URL from the project's routes (EC-216), or
|
|
109
|
+
* `undefined` when no route addresses it (a non-routable collection, or a
|
|
110
|
+
* hierarchy page with no slug / a broken parent chain). Pure: the URL is always
|
|
111
|
+
* derived, never read from a stored field.
|
|
112
|
+
*/
|
|
113
|
+
export function urlForDocument(config, collection, doc, context = {}) {
|
|
114
|
+
const locale = context.locale ?? config.localeConfig?.default;
|
|
115
|
+
const byId = new Map((context.siblings ?? [doc]).map((d) => [d.id, d]));
|
|
116
|
+
byId.set(doc.id, doc); // the document itself is always resolvable
|
|
117
|
+
const getById = (id) => byId.get(id);
|
|
118
|
+
let best;
|
|
119
|
+
for (const route of config.routes) {
|
|
120
|
+
// A locale-specific route serving a different locale cannot address this URL.
|
|
121
|
+
if (route.locale !== undefined && locale !== undefined && route.locale !== locale)
|
|
122
|
+
continue;
|
|
123
|
+
const path = pathForRoute(route, doc, collection, locale, config.localeConfig, getById, config.hierarchy);
|
|
124
|
+
if (path === undefined)
|
|
125
|
+
continue;
|
|
126
|
+
const rank = routeRank(route, locale);
|
|
127
|
+
// Deterministic tie-break on equal rank: the lower route id wins.
|
|
128
|
+
if (!best || rank > best.rank || (rank === best.rank && route.id < best.route.id)) {
|
|
129
|
+
best = { route, path, rank };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (!best)
|
|
133
|
+
return undefined;
|
|
134
|
+
const path = applyLocalePrefix(best.path, locale, config.localeConfig);
|
|
135
|
+
const href = config.frontendUrl !== undefined ? config.frontendUrl.replace(/\/+$/, '') + path : undefined;
|
|
136
|
+
return { path, ...(href !== undefined ? { href } : {}), route: best.route };
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=url-for-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-for-document.js","sourceRoot":"","sources":["../../src/cms-core/url-for-document.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,UAAU,GAAG,MAAM,CAAA;AAgCzB,uFAAuF;AACvF,SAAS,aAAa,CACpB,GAAgB,EAChB,UAAyB,EACzB,MAA0B,EAC1B,YAAsC;IAEtC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC;QAAE,OAAO,SAAS,CAAA;IAC3E,MAAM,GAAG,GACP,YAAY,IAAI,MAAM,KAAK,SAAS;QAClC,CAAC,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,KAAK;QACvE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IAC5B,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAA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CAAC,CAAC,SAAS,CAAA;IAC9F,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAA;AAC7E,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { CollectionRegistry } from './collections';
|
|
2
|
+
import type { BlocksFieldDef, FieldDef, RichTextFieldDef } from './fields';
|
|
3
|
+
import type { CmsDocument, DocumentRef, FieldValues } from './documents';
|
|
4
|
+
import type { LocaleConfig } from './localization';
|
|
5
|
+
import type { CmsValidationIssue } from './issues';
|
|
6
|
+
/** Index of documents by identity, used to validate relation/asset targets. */
|
|
7
|
+
export interface DocumentStore {
|
|
8
|
+
has(ref: DocumentRef): boolean;
|
|
9
|
+
get(ref: DocumentRef): CmsDocument | undefined;
|
|
10
|
+
}
|
|
11
|
+
/** Build a `DocumentStore` from a flat list of documents. */
|
|
12
|
+
export declare function createDocumentStore(docs: readonly CmsDocument[]): DocumentStore & {
|
|
13
|
+
list(): CmsDocument[];
|
|
14
|
+
issues: readonly CmsValidationIssue[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A composition-validation finding, returned by the injected `validateComposition`
|
|
18
|
+
* callback (EC-188). cms-core stays free of `@elytracms/core/project-graph`: the studio
|
|
19
|
+
* wires the callback to `validateCompositionValue` + the component registry and
|
|
20
|
+
* returns these plain findings, which cms-core wraps into `CmsValidationIssue`s
|
|
21
|
+
* keyed on the field (so they surface inline like every other field issue).
|
|
22
|
+
*/
|
|
23
|
+
export interface CompositionIssue {
|
|
24
|
+
message: string;
|
|
25
|
+
severity?: 'error' | 'warning';
|
|
26
|
+
/** Slash-joined node path within the composition tree, for richer surfacing. */
|
|
27
|
+
nodePath?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ValidateDocumentOptions {
|
|
30
|
+
/** When provided, relation/asset targets are checked for existence (EC-017). */
|
|
31
|
+
store?: DocumentStore;
|
|
32
|
+
/** When provided, localized required fields are checked across all locales (EC-018). */
|
|
33
|
+
localeConfig?: LocaleConfig;
|
|
34
|
+
/**
|
|
35
|
+
* When provided, `blocks` composition field values are validated (EC-188).
|
|
36
|
+
* Injected so cms-core does not depend on `@elytracms/core/project-graph`; the studio
|
|
37
|
+
* binds it to `validateCompositionValue(value, { allow, components })`.
|
|
38
|
+
*/
|
|
39
|
+
validateComposition?: (value: unknown, field: BlocksFieldDef) => readonly CompositionIssue[];
|
|
40
|
+
/**
|
|
41
|
+
* When provided, the composition embeds inside a `richText` field value are
|
|
42
|
+
* validated (EC-189). Injected so cms-core depends on neither
|
|
43
|
+
* `@elytracms/core/project-graph` nor `@elytracms/core/rich-text`; the studio binds it to walk
|
|
44
|
+
* the value's `componentEmbed` nodes and validate each embedded `ComponentNode`
|
|
45
|
+
* via `validateCompositionValue(node, { allow, components })` against the field's
|
|
46
|
+
* `allow` vocabulary. Findings carry the rich-text node path.
|
|
47
|
+
*/
|
|
48
|
+
validateRichTextEmbeds?: (value: unknown, field: RichTextFieldDef) => readonly CompositionIssue[];
|
|
49
|
+
/**
|
|
50
|
+
* Published-ness oracle for the EC-173 weak-reference warning (EC-224): does a
|
|
51
|
+
* given document ref serve the published site? Sourced from the version
|
|
52
|
+
* pointer by the caller (the studio passes `cms.isPublished`). Absent → treated
|
|
53
|
+
* as "nothing is published", so the warning simply does not fire — the flat
|
|
54
|
+
* `state` flag is never consulted.
|
|
55
|
+
*/
|
|
56
|
+
isPublished?: (ref: DocumentRef) => boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Asset-existence oracle (EC-212 follow-up): assets live in their own
|
|
59
|
+
* repository, not as CMS documents, so the studio passes a predicate over the
|
|
60
|
+
* real asset library. When provided, it is the source of truth for asset-field
|
|
61
|
+
* existence; otherwise existence falls back to the document `store` (fixtures
|
|
62
|
+
* that model assets as documents). With neither, asset existence is not checked.
|
|
63
|
+
*/
|
|
64
|
+
assetExists?: (id: string) => boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Validate a document against its collection (EC-016/017/018). Returns structured
|
|
68
|
+
* issues; never throws. Checks unknown collection, missing required fields,
|
|
69
|
+
* scalar type correctness, declared constraints, relation targets, asset
|
|
70
|
+
* references, and required localized values across configured locales.
|
|
71
|
+
*/
|
|
72
|
+
export declare function validateDocument(registry: CollectionRegistry, doc: CmsDocument, options?: ValidateDocumentOptions): CmsValidationIssue[];
|
|
73
|
+
/** Validate every document in a list against the registry. */
|
|
74
|
+
export declare function validateDocuments(registry: CollectionRegistry, docs: readonly CmsDocument[], options?: ValidateDocumentOptions): CmsValidationIssue[];
|
|
75
|
+
/**
|
|
76
|
+
* Pure scalar/structural type check for a field value (EC-190). Returns a human
|
|
77
|
+
* detail string when the value is the wrong shape for the field type, or null
|
|
78
|
+
* when it is acceptable. Existence checks (relation/asset targets) are NOT done
|
|
79
|
+
* here — they need a document store. Assumes a present value (the `required`
|
|
80
|
+
* check owns presence).
|
|
81
|
+
*/
|
|
82
|
+
export declare function checkScalarType(field: FieldDef, value: unknown): string | null;
|
|
83
|
+
/**
|
|
84
|
+
* Pure declarative-constraint check (min/max/pattern) for a field value (EC-190).
|
|
85
|
+
* Returns the list of human detail strings for each violation (empty = valid).
|
|
86
|
+
* Mirrors `validateConstraints` without the issue-construction coupling.
|
|
87
|
+
*/
|
|
88
|
+
export declare function checkConstraints(field: FieldDef, value: unknown): string[];
|
|
89
|
+
/**
|
|
90
|
+
* Build a pure, store-free validator for a single field-def's value (EC-190).
|
|
91
|
+
* Used by the renderer (invalid static prop → EC-015 visible fallback) and the
|
|
92
|
+
* inspector. Returns true when the value is structurally acceptable for the field
|
|
93
|
+
* type; absent values (undefined/null/'') are acceptable — the `required` check
|
|
94
|
+
* owns presence. Relation/asset existence and composition depth are validated
|
|
95
|
+
* elsewhere (they need a store / registry).
|
|
96
|
+
*/
|
|
97
|
+
export declare function fieldValueValidator(field: FieldDef): (value: unknown) => boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Lint a field-def used as a component prop (EC-190): document-only attributes
|
|
100
|
+
* (`filterable`, `validation.unique`) make no sense on a prop and surface as
|
|
101
|
+
* structured issues, never silently ignored. Returns [] for a valid prop
|
|
102
|
+
* field-def.
|
|
103
|
+
*/
|
|
104
|
+
export declare function assertPropFieldDef(field: FieldDef): CmsValidationIssue[];
|
|
105
|
+
export interface ValidateComponentPropsOptions {
|
|
106
|
+
/**
|
|
107
|
+
* When provided, `blocks` prop values are validated (EC-188 callback wired to
|
|
108
|
+
* `validateCompositionValue` + the component registry by the studio).
|
|
109
|
+
*/
|
|
110
|
+
validateComposition?: ValidateDocumentOptions['validateComposition'];
|
|
111
|
+
/**
|
|
112
|
+
* When provided, the composition embeds inside a `richText` prop value are
|
|
113
|
+
* validated (EC-189) — the prop-side mirror of the document callback.
|
|
114
|
+
*/
|
|
115
|
+
validateRichTextEmbeds?: ValidateDocumentOptions['validateRichTextEmbeds'];
|
|
116
|
+
}
|
|
117
|
+
export declare function validateComponentProps(fieldDefs: readonly FieldDef[], props: Record<string, unknown>, options?: ValidateComponentPropsOptions): CmsValidationIssue[];
|
|
118
|
+
/** Resolve a relation value into the referenced documents (EC-017). */
|
|
119
|
+
export declare function resolveRelation(store: DocumentStore, value: unknown): CmsDocument[];
|
|
120
|
+
/** Build a flat values bag (non-localized only) — convenience for tests/consumers. */
|
|
121
|
+
export declare function plainValues(doc: CmsDocument): FieldValues;
|