@decocms/blocks 8.9.1 → 8.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/protocol/channel.d.ts +98 -0
- package/dist/protocol/channel.d.ts.map +1 -0
- package/dist/protocol/channel.js +58 -0
- package/dist/protocol/channel.js.map +1 -0
- package/dist/protocol/client.js +2 -2
- package/dist/protocol/client.js.map +1 -1
- package/dist/protocol/conformance/blockMetaVectors.json +214 -0
- package/dist/protocol/conformance/contentHashFixtures.d.ts +22 -0
- package/dist/protocol/conformance/contentHashFixtures.d.ts.map +1 -1
- package/dist/protocol/conformance/contentHashFixtures.js +55 -0
- package/dist/protocol/conformance/contentHashFixtures.js.map +1 -1
- package/dist/protocol/conformance/index.d.ts +2 -1
- package/dist/protocol/conformance/index.d.ts.map +1 -1
- package/dist/protocol/conformance/index.js +2 -1
- package/dist/protocol/conformance/index.js.map +1 -1
- package/dist/protocol/conformance/vectors.d.ts +33 -0
- package/dist/protocol/conformance/vectors.d.ts.map +1 -0
- package/dist/protocol/conformance/vectors.js +3 -0
- package/dist/protocol/conformance/vectors.js.map +1 -0
- package/dist/protocol/index.d.ts +11 -1
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/protocol/index.js +11 -1
- package/dist/protocol/index.js.map +1 -1
- package/dist/protocol/keys.d.ts +1 -1
- package/dist/protocol/keys.js +1 -1
- package/dist/v8/background.d.ts +13 -0
- package/dist/v8/background.d.ts.map +1 -1
- package/dist/v8/background.js +41 -0
- package/dist/v8/background.js.map +1 -1
- package/dist/v8/blockMeta.d.ts +27 -0
- package/dist/v8/blockMeta.d.ts.map +1 -0
- package/dist/v8/blockMeta.js +75 -0
- package/dist/v8/blockMeta.js.map +1 -0
- package/dist/v8/blockStore.d.ts +43 -0
- package/dist/v8/blockStore.d.ts.map +1 -0
- package/dist/v8/blockStore.js +95 -0
- package/dist/v8/blockStore.js.map +1 -0
- package/dist/v8/boundedJson.d.ts +5 -0
- package/dist/v8/boundedJson.d.ts.map +1 -1
- package/dist/v8/boundedJson.js +10 -2
- package/dist/v8/boundedJson.js.map +1 -1
- package/dist/v8/boundedMap.d.ts +19 -0
- package/dist/v8/boundedMap.d.ts.map +1 -0
- package/dist/v8/boundedMap.js +52 -0
- package/dist/v8/boundedMap.js.map +1 -0
- package/dist/v8/builtins/data.d.ts +18 -2
- package/dist/v8/builtins/data.d.ts.map +1 -1
- package/dist/v8/builtins/data.js +17 -1
- package/dist/v8/builtins/data.js.map +1 -1
- package/dist/v8/builtins/index.d.ts.map +1 -1
- package/dist/v8/builtins/index.js +2 -1
- package/dist/v8/builtins/index.js.map +1 -1
- package/dist/v8/builtins/legacy.d.ts +6 -3
- package/dist/v8/builtins/legacy.d.ts.map +1 -1
- package/dist/v8/builtins/legacy.js +6 -3
- package/dist/v8/builtins/legacy.js.map +1 -1
- package/dist/v8/canonical.d.ts +8 -0
- package/dist/v8/canonical.d.ts.map +1 -1
- package/dist/v8/canonical.js +15 -0
- package/dist/v8/canonical.js.map +1 -1
- package/dist/v8/cli/builtins.d.ts.map +1 -1
- package/dist/v8/cli/builtins.js +1 -0
- package/dist/v8/cli/builtins.js.map +1 -1
- package/dist/v8/cli/check/index.d.ts +10 -0
- package/dist/v8/cli/check/index.d.ts.map +1 -1
- package/dist/v8/cli/check/index.js +91 -7
- package/dist/v8/cli/check/index.js.map +1 -1
- package/dist/v8/cli/content.d.ts +12 -25
- package/dist/v8/cli/content.d.ts.map +1 -1
- package/dist/v8/cli/content.js +46 -75
- package/dist/v8/cli/content.js.map +1 -1
- package/dist/v8/cli/index.d.ts +2 -2
- package/dist/v8/cli/index.d.ts.map +1 -1
- package/dist/v8/cli/index.js +2 -2
- package/dist/v8/cli/index.js.map +1 -1
- package/dist/v8/cli/remote/commands.d.ts +71 -0
- package/dist/v8/cli/remote/commands.d.ts.map +1 -0
- package/dist/v8/cli/remote/commands.js +644 -0
- package/dist/v8/cli/remote/commands.js.map +1 -0
- package/dist/v8/cli/remote/diff.d.ts +15 -0
- package/dist/v8/cli/remote/diff.d.ts.map +1 -0
- package/dist/v8/cli/remote/diff.js +102 -0
- package/dist/v8/cli/remote/diff.js.map +1 -0
- package/dist/v8/cli/remote/env.d.ts +35 -0
- package/dist/v8/cli/remote/env.d.ts.map +1 -0
- package/dist/v8/cli/remote/env.js +84 -0
- package/dist/v8/cli/remote/env.js.map +1 -0
- package/dist/v8/cli/remote/http.d.ts +149 -0
- package/dist/v8/cli/remote/http.d.ts.map +1 -0
- package/dist/v8/cli/remote/http.js +381 -0
- package/dist/v8/cli/remote/http.js.map +1 -0
- package/dist/v8/cli/remote/local.d.ts +90 -0
- package/dist/v8/cli/remote/local.d.ts.map +1 -0
- package/dist/v8/cli/remote/local.js +309 -0
- package/dist/v8/cli/remote/local.js.map +1 -0
- package/dist/v8/cli/root.d.ts +29 -0
- package/dist/v8/cli/root.d.ts.map +1 -1
- package/dist/v8/cli/root.js +28 -0
- package/dist/v8/cli/root.js.map +1 -1
- package/dist/v8/cli/run.d.ts +13 -1
- package/dist/v8/cli/run.d.ts.map +1 -1
- package/dist/v8/cli/run.js +310 -124
- package/dist/v8/cli/run.js.map +1 -1
- package/dist/v8/cli/schema/builtinSchemas.d.ts.map +1 -1
- package/dist/v8/cli/schema/builtinSchemas.js +28 -10
- package/dist/v8/cli/schema/builtinSchemas.js.map +1 -1
- package/dist/v8/cli/schema/generate.js +1 -1
- package/dist/v8/cli/schema/generate.js.map +1 -1
- package/dist/v8/cli/skills.d.ts +25 -0
- package/dist/v8/cli/skills.d.ts.map +1 -0
- package/dist/v8/cli/skills.js +70 -0
- package/dist/v8/cli/skills.js.map +1 -0
- package/dist/v8/client.d.ts +9 -9
- package/dist/v8/client.d.ts.map +1 -1
- package/dist/v8/client.js +138 -50
- package/dist/v8/client.js.map +1 -1
- package/dist/v8/cms.d.ts +2 -1
- package/dist/v8/cms.d.ts.map +1 -1
- package/dist/v8/cms.js +55 -46
- package/dist/v8/cms.js.map +1 -1
- package/dist/v8/content.d.ts +39 -78
- package/dist/v8/content.d.ts.map +1 -1
- package/dist/v8/content.js +155 -195
- package/dist/v8/content.js.map +1 -1
- package/dist/v8/contentIndex.d.ts +71 -0
- package/dist/v8/contentIndex.d.ts.map +1 -0
- package/dist/v8/contentIndex.js +137 -0
- package/dist/v8/contentIndex.js.map +1 -0
- package/dist/v8/draft.d.ts +7 -7
- package/dist/v8/draft.d.ts.map +1 -1
- package/dist/v8/draft.js +10 -9
- package/dist/v8/draft.js.map +1 -1
- package/dist/v8/draftChanges.d.ts +59 -32
- package/dist/v8/draftChanges.d.ts.map +1 -1
- package/dist/v8/draftChanges.js +139 -75
- package/dist/v8/draftChanges.js.map +1 -1
- package/dist/v8/errors.d.ts +21 -0
- package/dist/v8/errors.d.ts.map +1 -1
- package/dist/v8/errors.js +22 -0
- package/dist/v8/errors.js.map +1 -1
- package/dist/v8/hostedSource.d.ts +57 -0
- package/dist/v8/hostedSource.d.ts.map +1 -0
- package/dist/v8/hostedSource.js +18 -0
- package/dist/v8/hostedSource.js.map +1 -0
- package/dist/v8/identity.d.ts +1 -1
- package/dist/v8/identity.js +1 -1
- package/dist/v8/index.d.ts +1 -0
- package/dist/v8/index.d.ts.map +1 -1
- package/dist/v8/index.js +1 -0
- package/dist/v8/index.js.map +1 -1
- package/dist/v8/matchRoute.js +7 -4
- package/dist/v8/matchRoute.js.map +1 -1
- package/dist/v8/pin.d.ts +34 -0
- package/dist/v8/pin.d.ts.map +1 -0
- package/dist/v8/pin.js +156 -0
- package/dist/v8/pin.js.map +1 -0
- package/dist/v8/preview/StudioBridge.d.ts +8 -8
- package/dist/v8/preview/StudioBridge.d.ts.map +1 -1
- package/dist/v8/preview/StudioBridge.js +8 -10
- package/dist/v8/preview/StudioBridge.js.map +1 -1
- package/dist/v8/preview/StudioChannel.d.ts +51 -0
- package/dist/v8/preview/StudioChannel.d.ts.map +1 -0
- package/dist/v8/preview/StudioChannel.js +104 -0
- package/dist/v8/preview/StudioChannel.js.map +1 -0
- package/dist/v8/preview/index.d.ts +3 -0
- package/dist/v8/preview/index.d.ts.map +1 -1
- package/dist/v8/preview/index.js +3 -0
- package/dist/v8/preview/index.js.map +1 -1
- package/dist/v8/remoteLoader.d.ts +42 -5
- package/dist/v8/remoteLoader.d.ts.map +1 -1
- package/dist/v8/remoteLoader.js +317 -259
- package/dist/v8/remoteLoader.js.map +1 -1
- package/dist/v8/resolver.d.ts +22 -8
- package/dist/v8/resolver.d.ts.map +1 -1
- package/dist/v8/resolver.js +37 -32
- package/dist/v8/resolver.js.map +1 -1
- package/dist/v8/revisionId.d.ts +11 -0
- package/dist/v8/revisionId.d.ts.map +1 -0
- package/dist/v8/revisionId.js +13 -0
- package/dist/v8/revisionId.js.map +1 -0
- package/dist/v8/settings.d.ts +6 -6
- package/dist/v8/settings.d.ts.map +1 -1
- package/dist/v8/settings.js +8 -7
- package/dist/v8/settings.js.map +1 -1
- package/dist/v8/telemetry.d.ts +4 -2
- package/dist/v8/telemetry.d.ts.map +1 -1
- package/dist/v8/telemetry.js +2 -2
- package/dist/v8/telemetry.js.map +1 -1
- package/dist/v8/types.d.ts +52 -40
- package/dist/v8/types.d.ts.map +1 -1
- package/dist/v8/variants.d.ts +7 -2
- package/dist/v8/variants.d.ts.map +1 -1
- package/dist/v8/variants.js +21 -24
- package/dist/v8/variants.js.map +1 -1
- package/dist/v8/vite/index.d.ts +2 -2
- package/dist/v8/vite/index.js +1 -1
- package/dist/v8/vite/index.js.map +1 -1
- package/package.json +3 -2
- package/skills/deco-apps/SKILL.md +82 -0
- package/skills/deco-apps/references/algolia.md +51 -0
- package/skills/deco-apps/references/commerce-types.md +132 -0
- package/skills/deco-apps/references/instrumented-fetch.md +144 -0
- package/skills/deco-apps/references/magento.md +55 -0
- package/skills/deco-apps/references/messaging.md +76 -0
- package/skills/deco-apps/references/shopify.md +69 -0
- package/skills/deco-apps/references/vendored-loaders.md +135 -0
- package/skills/deco-apps/references/vtex-cookies-auth.md +146 -0
- package/skills/deco-apps/references/vtex.md +150 -0
- package/skills/deco-apps/references/wake.md +75 -0
- package/skills/deco-cms-schema/SKILL.md +80 -0
- package/skills/deco-cms-schema/references/annotations.md +147 -0
- package/skills/deco-cms-schema/references/content-hygiene.md +91 -0
- package/skills/deco-cms-schema/references/formats-and-widgets.md +112 -0
- package/skills/deco-cms-schema/references/shapes-that-break-the-form.md +165 -0
- package/skills/deco-cms-schema/references/types-to-fields.md +112 -0
- package/skills/deco-go-live/SKILL.md +127 -0
- package/skills/deco-go-live/references/content-releases.md +90 -0
- package/skills/deco-go-live/references/process.md +106 -0
- package/skills/deco-go-live/references/proxy-headers-checkout.md +139 -0
- package/skills/deco-go-live/references/qa-checklist-template.md +150 -0
- package/skills/deco-go-live/references/qa-inventory.md +120 -0
- package/skills/deco-go-live/references/react-spa.md +183 -0
- package/skills/deco-go-live/references/seo-analytics.md +114 -0
- package/skills/deco-go-live/references/traffic-ramp.md +87 -0
- package/skills/deco-go-live/references/worker-runtime.md +93 -0
- package/skills/deco-go-live/scripts/preflight.sh +221 -0
- package/skills/deco-images-media/SKILL.md +64 -0
- package/skills/deco-images-media/references/asset-upload.md +191 -0
- package/skills/deco-images-media/references/components-per-binding.md +167 -0
- package/skills/deco-images-media/references/providers-and-cdn.md +145 -0
- package/skills/deco-images-media/references/quality-and-lcp.md +93 -0
- package/skills/deco-images-media/references/troubleshooting.md +147 -0
- package/skills/deco-images-media/references/video.md +122 -0
- package/skills/deco-make-editable/SKILL.md +94 -0
- package/skills/deco-make-editable/references/a11y-and-e2e.md +104 -0
- package/skills/deco-make-editable/references/content-shapes.md +198 -0
- package/skills/deco-make-editable/references/from-figma.md +110 -0
- package/skills/deco-make-editable/references/i18n-fields.md +112 -0
- package/skills/deco-make-editable/references/inventory.md +79 -0
- package/skills/deco-make-editable/references/pixel-parity.md +175 -0
- package/skills/deco-make-editable/references/seeding-content.md +119 -0
- package/skills/deco-nextjs-site/SKILL.md +74 -0
- package/skills/deco-nextjs-site/references/caching.md +116 -0
- package/skills/deco-nextjs-site/references/metadata-seo.md +100 -0
- package/skills/deco-nextjs-site/references/proxy-and-drafts.md +177 -0
- package/skills/deco-nextjs-site/references/rendering.md +171 -0
- package/skills/deco-nextjs-site/references/setup.md +190 -0
- package/skills/deco-nextjs-site/references/studio-bridge.md +130 -0
- package/skills/deco-site-authoring/SKILL.md +75 -0
- package/skills/deco-site-authoring/references/lazy-blocks.md +155 -0
- package/skills/deco-site-authoring/references/loaders.md +192 -0
- package/skills/deco-site-authoring/references/pages.md +156 -0
- package/skills/deco-site-authoring/references/review-before-publish.md +95 -0
- package/skills/deco-site-authoring/references/sections.md +158 -0
- package/skills/deco-site-authoring/references/seo.md +116 -0
- package/skills/deco-site-workflow/SKILL.md +92 -0
- package/skills/deco-site-workflow/references/check.md +116 -0
- package/skills/deco-site-workflow/references/cli-reference.md +104 -0
- package/skills/deco-site-workflow/references/content-layout.md +93 -0
- package/skills/deco-site-workflow/references/content-sync.md +146 -0
- package/skills/deco-site-workflow/references/delivery.md +51 -0
- package/skills/deco-site-workflow/references/deploy.md +87 -0
- package/skills/deco-site-workflow/references/schema.md +173 -0
- package/skills/deco-site-workflow/references/serve-and-studio.md +138 -0
- package/skills/deco-storefront-caching/SKILL.md +67 -0
- package/skills/deco-storefront-caching/references/cache-keys.md +129 -0
- package/skills/deco-storefront-caching/references/case-study.md +82 -0
- package/skills/deco-storefront-caching/references/egress-traps.md +153 -0
- package/skills/deco-storefront-caching/references/nextjs.md +60 -0
- package/skills/deco-storefront-caching/references/perf-guardrails-e2e.md +123 -0
- package/skills/deco-storefront-caching/references/verification.md +136 -0
- package/skills/deco-storefront-caching/references/worker-page-cache.md +160 -0
- package/skills/deco-storefront-caching/scripts/html-anatomy.mjs +97 -0
- package/skills/deco-storefront-performance/SKILL.md +81 -0
- package/skills/deco-storefront-performance/references/cls-third-party.md +90 -0
- package/skills/deco-storefront-performance/references/hydration.md +116 -0
- package/skills/deco-storefront-performance/references/loaders-n-plus-1.md +107 -0
- package/skills/deco-storefront-performance/references/navigation-ux.md +130 -0
- package/skills/deco-storefront-performance/references/payload-trim.md +163 -0
- package/skills/deco-storefront-performance/references/render-location.md +152 -0
- package/skills/deco-storefront-performance/references/request-dedupe.md +147 -0
- package/skills/deco-storefront-performance/references/trace-reading.md +79 -0
- package/skills/deco-storefront-performance/references/worker-memory.md +176 -0
- package/skills/deco-tanstack-site/SKILL.md +68 -0
- package/skills/deco-tanstack-site/references/document-and-security.md +155 -0
- package/skills/deco-tanstack-site/references/router-and-navigation.md +137 -0
- package/skills/deco-tanstack-site/references/routes-and-pages.md +183 -0
- package/skills/deco-tanstack-site/references/server-functions.md +123 -0
- package/skills/deco-tanstack-site/references/setup.md +153 -0
- package/skills/deco-tanstack-site/references/worker-entry.md +152 -0
- package/skills/deco-v7-to-v8-migration/SKILL.md +122 -0
- package/skills/deco-v7-to-v8-migration/references/caching-and-privacy.md +10 -0
- package/skills/deco-v7-to-v8-migration/references/content.md +25 -0
- package/skills/deco-v7-to-v8-migration/references/editor-forms.md +27 -0
- package/skills/deco-v7-to-v8-migration/references/faststore.md +40 -0
- package/skills/deco-v7-to-v8-migration/references/framework-code.md +53 -0
- package/skills/deco-v7-to-v8-migration/references/hosted-releases.md +16 -0
- package/skills/deco-v7-to-v8-migration/references/import-map.md +81 -0
- package/skills/deco-v7-to-v8-migration/references/legacy-names.md +33 -0
- package/skills/deco-v7-to-v8-migration/references/manual-steps.md +10 -0
- package/skills/deco-v7-to-v8-migration/references/native-apps.md +43 -0
- package/skills/deco-v7-to-v8-migration/references/nextjs.md +19 -0
- package/skills/deco-v7-to-v8-migration/references/parity.md +66 -0
- package/skills/deco-v7-to-v8-migration/references/rendering.md +13 -0
- package/skills/deco-v7-to-v8-migration/references/running-the-script.md +29 -0
- package/skills/deco-v7-to-v8-migration/references/script-steps.md +13 -0
- package/skills/deco-v7-to-v8-migration/references/server-functions.md +15 -0
- package/skills/deco-v7-to-v8-migration/references/sibling-port.md +11 -0
- package/skills/deco-v7-to-v8-migration/references/site-code.md +15 -0
- package/skills/deco-v7-to-v8-migration/references/telemetry.md +10 -0
- package/skills/deco-v7-to-v8-migration/references/verify.md +20 -0
- package/skills/deco-v7-to-v8-migration/scripts/apps.ts +297 -0
- package/skills/deco-v7-to-v8-migration/scripts/asyncRendering.ts +73 -0
- package/skills/deco-v7-to-v8-migration/scripts/blockMap.ts +584 -0
- package/skills/deco-v7-to-v8-migration/scripts/ciSchemaCheck.ts +145 -0
- package/skills/deco-v7-to-v8-migration/scripts/compat.ts +357 -0
- package/skills/deco-v7-to-v8-migration/scripts/content.ts +121 -0
- package/skills/deco-v7-to-v8-migration/scripts/experiments.ts +81 -0
- package/skills/deco-v7-to-v8-migration/scripts/framework.ts +61 -0
- package/skills/deco-v7-to-v8-migration/scripts/imageCopy.ts +276 -0
- package/skills/deco-v7-to-v8-migration/scripts/imageModule.ts +285 -0
- package/skills/deco-v7-to-v8-migration/scripts/imports.ts +942 -0
- package/skills/deco-v7-to-v8-migration/scripts/invoke.ts +624 -0
- package/skills/deco-v7-to-v8-migration/scripts/legacyNames.ts +45 -0
- package/skills/deco-v7-to-v8-migration/scripts/main.ts +59 -0
- package/skills/deco-v7-to-v8-migration/scripts/matchers.ts +41 -0
- package/skills/deco-v7-to-v8-migration/scripts/migrate.ts +176 -0
- package/skills/deco-v7-to-v8-migration/scripts/redirects.ts +455 -0
- package/skills/deco-v7-to-v8-migration/scripts/report.ts +50 -0
- package/skills/deco-v7-to-v8-migration/scripts/scaffold.ts +1119 -0
- package/skills/deco-v7-to-v8-migration/scripts/secrets.ts +35 -0
- package/skills/deco-v7-to-v8-migration/scripts/sectionLoaders.ts +216 -0
- package/skills/deco-v7-to-v8-migration/scripts/siteSettings.ts +261 -0
- package/skills/deco-v7-to-v8-migration/scripts/stubs.ts +388 -0
- package/skills/deco-v7-to-v8-migration/scripts/tsconfig.json +7 -0
- package/skills/deco-v7-to-v8-migration/scripts/vendor.ts +249 -0
- package/skills/deco-v7-to-v8-migration/scripts/vtexInvoke.ts +240 -0
- package/skills/deco-v7-to-v8-migration/scripts/walk.ts +30 -0
- package/skills/deco-variants/SKILL.md +57 -0
- package/skills/deco-variants/references/caching-variants.md +63 -0
- package/skills/deco-variants/references/custom-matchers.md +83 -0
- package/skills/deco-variants/references/draft-preview.md +59 -0
- package/skills/deco-variants/references/experiments-and-campaigns.md +104 -0
- package/skills/deco-variants/references/multivariate.md +85 -0
- package/skills/deco-variants/references/v7-matchers.md +71 -0
- package/src/index.ts +2 -0
- package/src/protocol/channel.ts +127 -0
- package/src/protocol/client.ts +2 -2
- package/src/protocol/conformance/blockMetaVectors.json +214 -0
- package/src/protocol/conformance/contentHashFixtures.ts +74 -0
- package/src/protocol/conformance/index.ts +9 -1
- package/src/protocol/conformance/vectors.ts +36 -0
- package/src/protocol/index.ts +32 -0
- package/src/protocol/keys.ts +1 -1
- package/src/v8/background.ts +42 -0
- package/src/v8/blockMeta.ts +100 -0
- package/src/v8/blockStore.ts +124 -0
- package/src/v8/boundedJson.ts +20 -2
- package/src/v8/boundedMap.ts +53 -0
- package/src/v8/builtins/data.ts +26 -2
- package/src/v8/builtins/index.ts +2 -1
- package/src/v8/builtins/legacy.ts +6 -3
- package/src/v8/canonical.ts +15 -0
- package/src/v8/cli/builtins.ts +1 -0
- package/src/v8/cli/check/index.ts +97 -7
- package/src/v8/cli/content.ts +49 -91
- package/src/v8/cli/index.ts +2 -2
- package/src/v8/cli/remote/commands.ts +834 -0
- package/src/v8/cli/remote/diff.ts +100 -0
- package/src/v8/cli/remote/env.ts +107 -0
- package/src/v8/cli/remote/http.ts +484 -0
- package/src/v8/cli/remote/local.ts +343 -0
- package/src/v8/cli/root.ts +40 -0
- package/src/v8/cli/run.ts +366 -135
- package/src/v8/cli/schema/builtinSchemas.ts +29 -10
- package/src/v8/cli/schema/generate.ts +1 -1
- package/src/v8/cli/skills.ts +91 -0
- package/src/v8/client.ts +162 -60
- package/src/v8/cms.ts +62 -53
- package/src/v8/content.ts +179 -229
- package/src/v8/contentIndex.ts +183 -0
- package/src/v8/draft.ts +15 -14
- package/src/v8/draftChanges.ts +151 -85
- package/src/v8/errors.ts +37 -0
- package/src/v8/hostedSource.ts +67 -0
- package/src/v8/identity.ts +1 -1
- package/src/v8/index.ts +1 -0
- package/src/v8/matchRoute.ts +7 -4
- package/src/v8/pin.ts +176 -0
- package/src/v8/preview/StudioBridge.ts +8 -10
- package/src/v8/preview/StudioChannel.ts +116 -0
- package/src/v8/preview/index.ts +3 -0
- package/src/v8/remoteLoader.ts +350 -286
- package/src/v8/resolver.ts +56 -33
- package/src/v8/revisionId.ts +14 -0
- package/src/v8/settings.ts +10 -9
- package/src/v8/telemetry.ts +3 -3
- package/src/v8/types.ts +52 -40
- package/src/v8/variants.ts +30 -26
- package/src/v8/vite/index.ts +3 -3
- package/dist/v8/cli/serve/server.d.ts +0 -29
- package/dist/v8/cli/serve/server.d.ts.map +0 -1
- package/dist/v8/cli/serve/server.js +0 -296
- package/dist/v8/cli/serve/server.js.map +0 -1
- package/src/v8/cli/serve/server.ts +0 -348
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# The `multivariate` block
|
|
2
|
+
|
|
3
|
+
`multivariate` is a built-in block (`packages/blocks/src/v8/builtins/multivariate.ts`). Its `variants` is a list of `{ rule, value }`. The result is the value of the first variant whose rule resolves to `true`, or `undefined` when no rule does.
|
|
4
|
+
|
|
5
|
+
## Shape
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"__resolveType": "multivariate",
|
|
10
|
+
"variants": [
|
|
11
|
+
{ "rule": { "__resolveType": "campaign", "name": "black-friday" },
|
|
12
|
+
"value": { "__resolveType": "lazy", "value": "Black Friday: up to 70% off" } },
|
|
13
|
+
{ "rule": { "__resolveType": "always" },
|
|
14
|
+
"value": { "__resolveType": "lazy", "value": "Free shipping over $50" } }
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- `rule` is any block whose function returns a boolean (or a promise of one). In Studio's schema the rule field points at the `matchers` group, which holds every block function `deco schema` sees returning a boolean.
|
|
20
|
+
- `value` is wrapped in a `lazy` block. The TypeScript type is `Variant<T> = { rule: boolean; value: Lazy<T> }`, exported from `@decocms/blocks`, with `Lazy<T> = () => Promise<T>`. The wrapper is what makes only the winning value resolve. A section, a loader or a fetch inside a losing variant never runs.
|
|
21
|
+
- The value can be anything a field can hold: a section, a string, a list, a loader call, another `multivariate`.
|
|
22
|
+
- A `multivariate` can sit anywhere a value can: as a page section, inside one field of a section (a single title), or as a saved block of its own.
|
|
23
|
+
- The optional `experiment` field (a string, "the stable ID of an A/B test" in the schema) is not read by the runtime. The rules decide.
|
|
24
|
+
|
|
25
|
+
`deco check` reports a value saved without the `lazy` wrapper: "a variant's value must be a lazy block". At runtime such a value is returned as is instead of failing the page, but it was resolved before the rules ran, so every variant's value did its work.
|
|
26
|
+
|
|
27
|
+
## How it resolves
|
|
28
|
+
|
|
29
|
+
The resolver treats `multivariate` as a special case (`packages/blocks/src/v8/resolver.ts`, `#resolveFirstMatch`):
|
|
30
|
+
|
|
31
|
+
1. The other fields resolve as usual.
|
|
32
|
+
2. The variants resolve one at a time, in order. For each one, the rule resolves first.
|
|
33
|
+
3. At the first rule that is `true`, it stops. Later variants are left out, so their rules never run.
|
|
34
|
+
4. The function gets the variants up to the winner and calls the winner's lazy value.
|
|
35
|
+
|
|
36
|
+
What follows from that:
|
|
37
|
+
|
|
38
|
+
- **Order is the logic.** Narrow rules first, `always` last. A `never` rule is how the editor hides a variant.
|
|
39
|
+
- **No fallback, no value.** Without an `always` at the end, a visitor that matches nothing gets `undefined`. Sometimes that is the goal ("desktop only"), often it is a bug.
|
|
40
|
+
- **Later rules have no side effects.** A rule after the winner never runs. With v7's sticky `random`, that means no draw and no cookie for that test on this request, as in v7.
|
|
41
|
+
- **Rules run in sequence, not in parallel.** Each async rule waits for the one before it. A slow rule early in the list delays the whole slot. The built-in `experiment` and `campaign` read a saved block once per client, however many rules ask.
|
|
42
|
+
- **Results are memoized per request.** The resolver keeps one result per block function and inputs for the life of a client, so two identical rules on one page run once. Treat results as read-only.
|
|
43
|
+
- **A rule that throws fails the block** with `BLOCK_FAILED`. v7's matchers from `@decocms/compat-v7/matchers` catch their own errors and answer `false`, as v7 did. A site's own rule should do the same if a failure should mean "no match" (see [`custom-matchers.md`](./custom-matchers.md)).
|
|
44
|
+
|
|
45
|
+
## Rules as saved blocks
|
|
46
|
+
|
|
47
|
+
A rule can be a saved block, reused by name. A saved block named `Hero test` with `{ "__resolveType": "experiment", "name": "hero" }` is used as:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{ "rule": { "__resolveType": "Hero test" }, "value": { "__resolveType": "lazy", "value": "…" } }
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The resolver merges `{ ...saved, ...arguments }` and looks the type up again, so a reference can override the saved inputs. `deco check` follows the reference when it checks the `name` of an `experiment` or `campaign` rule.
|
|
54
|
+
|
|
55
|
+
## Replacing the built-in
|
|
56
|
+
|
|
57
|
+
A key named `multivariate` in the site's block map replaces the built-in. It is then an ordinary block: every rule resolves before the function runs, and the first-match short-circuit is gone. Do not do this unless you need every rule's result.
|
|
58
|
+
|
|
59
|
+
## Content from v7 and Fresh
|
|
60
|
+
|
|
61
|
+
The well-known legacy names resolve without a block-map entry (`packages/blocks/src/v8/builtins/legacy.ts`):
|
|
62
|
+
|
|
63
|
+
| Legacy type | Built-in |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `website/flags/multivariate.ts` | `multivariate` |
|
|
66
|
+
| `website/flags/multivariate/section.ts` | `multivariate` |
|
|
67
|
+
| `website/matchers/always.ts` | `always` |
|
|
68
|
+
| `website/matchers/never.ts` | `never` |
|
|
69
|
+
|
|
70
|
+
Under a legacy name, values are saved plain, and the runtime wraps each in `lazy` on the way in, so only the winner runs there too.
|
|
71
|
+
|
|
72
|
+
The other per-kind flag types (`image`, `message`, `page`), `$live/flags/multivariate.ts`, `$live/matchers/MatchAlways.ts` and v7's date matcher have no alias. The one-time migration (the `deco-v7-to-v8-migration` skill) renames the flag and always types to the names above, and renames the date matcher to `date`, which `deco check` then reports with how to move it into `campaigns`. v7's other matchers are in [`v7-matchers.md`](./v7-matchers.md).
|
|
73
|
+
|
|
74
|
+
In v7 a "custom flag type" was a file per value type. v8 has no such files: `multivariate` is generic over its value, so there is nothing to write per type.
|
|
75
|
+
|
|
76
|
+
## Symptoms
|
|
77
|
+
|
|
78
|
+
| Symptom | Likely cause |
|
|
79
|
+
|---|---|
|
|
80
|
+
| The slot is empty for some visitors | No `always` variant at the end |
|
|
81
|
+
| The second variant never shows | An `always` (or a rule that is always true) sits above it |
|
|
82
|
+
| Every variant's loader runs | Values saved without `lazy`; run `deco check` |
|
|
83
|
+
| `UNKNOWN_BLOCK` on a rule | A v7 matcher that is not registered (see [`v7-matchers.md`](./v7-matchers.md)), or a saved rule that was deleted |
|
|
84
|
+
| `deco check`: "no test … this rule is always false" | The test name is not in the saved block `experiments` (see [`experiments-and-campaigns.md`](./experiments-and-campaigns.md)) |
|
|
85
|
+
| Variant right on a fresh load, wrong from cache | A rule reads something the cache key does not hold (see [`caching-variants.md`](./caching-variants.md)) |
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# v7's matchers on v8
|
|
2
|
+
|
|
3
|
+
`@decocms/compat-v7/matchers` has v7's website matchers with v7's results (`packages/compat-v7/src/matchers/`). They are not registered for you. A site that keeps content with v7 matcher types registers each one in its block map under v7's name. Without that, the rule fails with `UNKNOWN_BLOCK`.
|
|
4
|
+
|
|
5
|
+
Use them for content migrated from v7. For new A/B tests and dates, prefer the built-in `experiment` and `campaign` (see [`experiments-and-campaigns.md`](./experiments-and-campaigns.md)): they are decided at the edge and the page cache keys on them.
|
|
6
|
+
|
|
7
|
+
## What is there
|
|
8
|
+
|
|
9
|
+
| Export | v7 type it stands for | Matches |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| `device` | `website/matchers/device.ts` | `mobile`, `tablet`, `desktop` ticks, from the user agent (tablet checked first). No tick matches everyone |
|
|
12
|
+
| `cookie` | `website/matchers/cookie.ts` | A cookie `name`, with `value` or any value |
|
|
13
|
+
| `host` | `website/matchers/host.ts` | The host (`includes`, `match`, or the older `host`) |
|
|
14
|
+
| `pathname` | `website/matchers/pathname.ts` | The page's path (`case`, `pattern`, `includes`, `excludes`) |
|
|
15
|
+
| `queryString` | `website/matchers/queryString.ts` | Query parameters, with `Exists`, `Equals`, `Greater`, `GreaterOrEquals`, `Lesser`, `LesserOrEquals`, `Includes` |
|
|
16
|
+
| `location` | `website/matchers/location.ts` | Country, region, city or coordinates, included or excluded. Reads the `cf-*` headers, then the Workers `request.cf`, then the `__cf_geo_*` cookies |
|
|
17
|
+
| `multi` | `website/matchers/multi.ts` | `op: "and"` or `"or"` over its `matchers`. No rules matches everyone |
|
|
18
|
+
| `random` | `website/matchers/random.ts` | v7's sticky random: a `traffic` share (0 to 1, default 0.5) keyed on a `cohort` |
|
|
19
|
+
| `environment` | `website/matchers/environment.ts` | Always throws: it read the process environment, which no v8 package does. Register your own rule under that name |
|
|
20
|
+
|
|
21
|
+
`always` and `never` are v8 built-ins, and v7's names for them are aliases (see [`multivariate.md`](./multivariate.md)). v7's date matcher became the `campaign` rule and the saved block `campaigns`.
|
|
22
|
+
|
|
23
|
+
Not in v8 at all: v7's `cron`, `userAgent`, `site` and `negate` matchers. Write a custom rule if you need one (see [`custom-matchers.md`](./custom-matchers.md)).
|
|
24
|
+
|
|
25
|
+
Every matcher except `multi` and `environment` takes the request as a second argument, because a v8 block function gets only its inputs. A matcher that throws counts as not matched, as in v7. `multi` gets its inner rules' results, since v8 resolves them before it runs.
|
|
26
|
+
|
|
27
|
+
## Wiring on TanStack Start
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
// the block map
|
|
31
|
+
import type { Blocks } from "@decocms/blocks";
|
|
32
|
+
import { device, type DeviceProps, random, type RandomProps } from "@decocms/compat-v7/matchers";
|
|
33
|
+
import { matcherContext } from "@decocms/compat-v7/tanstack/server";
|
|
34
|
+
|
|
35
|
+
export default {
|
|
36
|
+
"website/matchers/device.ts": (props: DeviceProps) => device(props, matcherContext()),
|
|
37
|
+
"website/matchers/random.ts": (props: RandomProps) => random(props, matcherContext()),
|
|
38
|
+
} satisfies Blocks;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- `matcherContext(pageUrl?)` gives the matcher the request being served (TanStack Start's `getRequest()`), the page's URL and one `flags` array per request.
|
|
42
|
+
- On a client-side navigation the request is the server-function call, not the page. Pass the page's URL there: `matcherContext(new URL(href, request.url))`. Without it, the call throws instead of matching `/_serverFn/…`.
|
|
43
|
+
- After the page resolved, in the page's server function, call `commitSegmentCookie()` to set `deco_segment` with the decisions `random` made. It sets nothing when the cookie already says the same.
|
|
44
|
+
- `cohortSegment(request)` gives v7's A/B split of the cache key (`{ abf: <token> }` for a visitor in a test, `{}` otherwise). Spread it into the segment of the site's page cache.
|
|
45
|
+
|
|
46
|
+
## Wiring on Next.js
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
// the block map
|
|
50
|
+
import { matcherContext } from "@decocms/compat-v7/nextjs/server";
|
|
51
|
+
"website/matchers/random.ts": async (props: RandomProps) => random(props, await matcherContext()),
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- The matchers need the page's URL. Forward it from the proxy with `pageUrlRequestHeaders` from `@decocms/compat-v7/nextjs/proxy`, or pass it to `matcherContext(url)`.
|
|
55
|
+
- Render `<SegmentCookie />` from `@decocms/compat-v7/nextjs/server` as the last child of the page, after the content resolved. A server component cannot set a cookie, so it renders a one-line script (and an effect after a client-side navigation) that sets it.
|
|
56
|
+
- A page that reads the request is dynamic: Next never shares it between visitors. Keep a CDN in front from caching it too.
|
|
57
|
+
|
|
58
|
+
## The sticky `random`
|
|
59
|
+
|
|
60
|
+
- A visitor keeps their group through `deco_segment` until the traffic share changes, then is drawn again once. The draw is `Math.random()`, as in v7.
|
|
61
|
+
- The cookie is keyed on the **cohort**: in v7, the name of the saved matcher block. A v8 block does not know its own name, so the name travels in the `cohort` prop. Set it to the v7 saved block's name. The migration script does not register `random` or fill `cohort`: it reports each random test to move into `experiments`. A random rule written inline uses `website/matchers/random.ts` as its cohort, as v7 did.
|
|
62
|
+
- Keep the cohort when changing the share. Renaming it puts every visitor in a new test.
|
|
63
|
+
- `decideRandom(props, request)` returns `{ value, isFresh, setCookie }` when you need the decision and the cookie together.
|
|
64
|
+
- A response that sets `deco_segment` must not be cached for other visitors.
|
|
65
|
+
- Inside `multi`, a `random` is sticky too. v7 drew it again on every request.
|
|
66
|
+
|
|
67
|
+
The better path for a v7 random test is to move it into the saved block `experiments` under the same name, so visitors keep their groups and the binding owns the cookie. Do not run both on one site.
|
|
68
|
+
|
|
69
|
+
## The legacy-origin split
|
|
70
|
+
|
|
71
|
+
v7's `withABTesting` (a split of traffic between the new site and the site it replaces, driven by a KV entry) is `abTestingRoutes` from `@decocms/compat-v7/tanstack/worker`, a handler for `createDecoWorker`'s `routes`. It is a traffic split between two deployments, not a content variant. `packages/compat-v7/README.md` documents it.
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Studio channel: how code that belongs to Deco Studio's site editor
|
|
3
|
+
* runs inside the site's page when Studio frames it. Browser-safe, no
|
|
4
|
+
* dependencies; types plus a few constants, shared by the page's bootstrap
|
|
5
|
+
* (`StudioChannel` in `@decocms/blocks/preview`, which every binding mounts on
|
|
6
|
+
* every page) and Studio, which hosts the modules.
|
|
7
|
+
*
|
|
8
|
+
* The page trusts a list of Studio origins (the binding's: Studio's production
|
|
9
|
+
* and staging origins by default, {@link DEFAULT_STUDIO_ORIGINS}), each
|
|
10
|
+
* compared exactly, no wildcard. It is the only way Studio runs code in the
|
|
11
|
+
* page: no message makes the page evaluate a script.
|
|
12
|
+
*
|
|
13
|
+
* 1. A framed page (`window.parent !== window`) posts `{ type: "deco:ready" }`
|
|
14
|
+
* to its parent once per trusted origin, each as the `targetOrigin` (the
|
|
15
|
+
* browser delivers it only if the parent is at that origin, so a parent of
|
|
16
|
+
* any other origin never receives it). Where the browser names the parent's
|
|
17
|
+
* origin (`location.ancestorOrigins`), the page posts to that origin alone,
|
|
18
|
+
* and only when it is trusted.
|
|
19
|
+
* 2. Studio answers `{ type: "deco:load", url }`: an absolute URL of an ES
|
|
20
|
+
* module on Studio's own origin (versioned, served with CORS).
|
|
21
|
+
* 3. The page accepts the message only when `event.origin` is one of the
|
|
22
|
+
* trusted origins, the sender is the parent window, and the module URL's
|
|
23
|
+
* origin is the origin of that message; then it `import()`s the URL, once
|
|
24
|
+
* per URL, and calls the module's default export with a
|
|
25
|
+
* {@link StudioChannelContext} bound to that origin. It answers
|
|
26
|
+
* `{ type: "deco:loaded", url }`, or `{ type: "deco:load-error", url,
|
|
27
|
+
* message }` (a failed URL may be sent again), to that origin.
|
|
28
|
+
* 4. Every later message from that origin whose `type` doesn't start with
|
|
29
|
+
* `deco:` (reserved for the channel) is handed to the listeners of each
|
|
30
|
+
* module it loaded; a module talks back with `send`, to that origin only.
|
|
31
|
+
*
|
|
32
|
+
* Not framed, framed by another origin, or a message that fails a check: the
|
|
33
|
+
* bootstrap does nothing. The binding adds the same origins to the page's
|
|
34
|
+
* Content Security Policy (`script-src`, for the modules, and
|
|
35
|
+
* `frame-ancestors`); the bootstrap's inline script takes the site's `nonce`.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/** Studio's production origin. */
|
|
39
|
+
export const DEFAULT_STUDIO_ORIGIN = "https://studio.decocms.com";
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The origins a page trusts unless the binding option or `DECO_STUDIO_ORIGIN`
|
|
43
|
+
* (comma-separated) says otherwise: Studio's production and staging origins.
|
|
44
|
+
*/
|
|
45
|
+
export const DEFAULT_STUDIO_ORIGINS: readonly string[] = Object.freeze([
|
|
46
|
+
DEFAULT_STUDIO_ORIGIN,
|
|
47
|
+
"https://studio-stg.decocms.com",
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
/** The channel's own message types; a module's message types never start with `deco:`. */
|
|
51
|
+
export const CHANNEL_MESSAGE = Object.freeze({
|
|
52
|
+
ready: "deco:ready",
|
|
53
|
+
load: "deco:load",
|
|
54
|
+
loaded: "deco:loaded",
|
|
55
|
+
loadError: "deco:load-error",
|
|
56
|
+
} as const);
|
|
57
|
+
|
|
58
|
+
/** Page → Studio: the framed page's bootstrap is listening. */
|
|
59
|
+
export interface ChannelReadyMessage {
|
|
60
|
+
type: "deco:ready";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Studio → page: import this module (an absolute URL on Studio's origin). */
|
|
64
|
+
export interface ChannelLoadMessage {
|
|
65
|
+
type: "deco:load";
|
|
66
|
+
url: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Page → Studio: the module at `url` was imported and its default export ran. */
|
|
70
|
+
export interface ChannelLoadedMessage {
|
|
71
|
+
type: "deco:loaded";
|
|
72
|
+
url: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Page → Studio: the module at `url` failed to import or to start. */
|
|
76
|
+
export interface ChannelLoadErrorMessage {
|
|
77
|
+
type: "deco:load-error";
|
|
78
|
+
url: string;
|
|
79
|
+
message: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** What the page's bootstrap posts to Studio. */
|
|
83
|
+
export type PageChannelMessage =
|
|
84
|
+
| ChannelReadyMessage
|
|
85
|
+
| ChannelLoadedMessage
|
|
86
|
+
| ChannelLoadErrorMessage;
|
|
87
|
+
|
|
88
|
+
/** What the page's bootstrap acts on itself; any other message goes to the modules. */
|
|
89
|
+
export type StudioChannelMessage = ChannelLoadMessage;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A message between Studio and one of its modules: any structured-cloneable
|
|
93
|
+
* object with a `type` that doesn't start with `deco:` (by convention the
|
|
94
|
+
* module's name, `wireframe:hover`).
|
|
95
|
+
*/
|
|
96
|
+
export interface ModuleMessage {
|
|
97
|
+
type: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** What a module's default export is called with. */
|
|
101
|
+
export interface StudioChannelContext<
|
|
102
|
+
In extends ModuleMessage = ModuleMessage,
|
|
103
|
+
Out extends ModuleMessage = ModuleMessage,
|
|
104
|
+
> {
|
|
105
|
+
/** The Studio origin this module was loaded from (the `deco:load` message's, checked exactly). */
|
|
106
|
+
readonly studioOrigin: string;
|
|
107
|
+
/** The URL this module was loaded from. */
|
|
108
|
+
readonly url: string;
|
|
109
|
+
/** Posts a message to Studio (addressed to `studioOrigin` only). */
|
|
110
|
+
send(message: Out): void;
|
|
111
|
+
/** Listens to Studio's module messages from `studioOrigin`; returns the unsubscribe. */
|
|
112
|
+
on(listener: (message: In) => void): () => void;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** A module's default export. The page answers `deco:loaded` once it returns (or its promise resolves). */
|
|
116
|
+
export type StudioChannelModule<
|
|
117
|
+
In extends ModuleMessage = ModuleMessage,
|
|
118
|
+
Out extends ModuleMessage = ModuleMessage,
|
|
119
|
+
> = (context: StudioChannelContext<In, Out>) => void | Promise<void>;
|
|
120
|
+
|
|
121
|
+
/** Types a module's default export: `export default defineStudioModule<In, Out>((channel) => …)`. */
|
|
122
|
+
export function defineStudioModule<
|
|
123
|
+
In extends ModuleMessage = ModuleMessage,
|
|
124
|
+
Out extends ModuleMessage = ModuleMessage,
|
|
125
|
+
>(module: StudioChannelModule<In, Out>): StudioChannelModule<In, Out> {
|
|
126
|
+
return module;
|
|
127
|
+
}
|
package/src/protocol/client.ts
CHANGED
|
@@ -93,8 +93,8 @@ const REQUIRED_VERSION = { major: PROTOCOL_VERSION.major, minor: REQUIRED_PROTOC
|
|
|
93
93
|
/** The guidance for a server older than this client: update it. */
|
|
94
94
|
const OUTDATED_MESSAGE =
|
|
95
95
|
`the endpoint speaks an older ${PROTOCOL_NAME} than this client needs ` +
|
|
96
|
-
`(${REQUIRED_VERSION.major}.${REQUIRED_VERSION.minor} or newer): update @decocms/blocks
|
|
97
|
-
"(8.2.0 or newer)
|
|
96
|
+
`(${REQUIRED_VERSION.major}.${REQUIRED_VERSION.minor} or newer): update @decocms/blocks ` +
|
|
97
|
+
"(8.2.0 or newer) where the endpoint runs";
|
|
98
98
|
|
|
99
99
|
function unsupportedEndpoint(
|
|
100
100
|
message: string,
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
{
|
|
2
|
+
"names": [
|
|
3
|
+
"CMS",
|
|
4
|
+
"extends",
|
|
5
|
+
"footer",
|
|
6
|
+
"footer-a",
|
|
7
|
+
"header",
|
|
8
|
+
"home",
|
|
9
|
+
"plain",
|
|
10
|
+
"redirects",
|
|
11
|
+
"variants"
|
|
12
|
+
],
|
|
13
|
+
"cases": [
|
|
14
|
+
{
|
|
15
|
+
"name": "home",
|
|
16
|
+
"body": {
|
|
17
|
+
"__resolveType": "website/pages/Page.tsx",
|
|
18
|
+
"path": "/",
|
|
19
|
+
"sections": [
|
|
20
|
+
{
|
|
21
|
+
"__resolveType": "header"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"__resolveType": "footer"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"__resolveType": "site/sections/Hero.tsx",
|
|
28
|
+
"title": "Olá"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"version": "D8NyAZf7d5YahxJT5yN79A",
|
|
33
|
+
"meta": {
|
|
34
|
+
"type": "website/pages/Page.tsx",
|
|
35
|
+
"path": "/",
|
|
36
|
+
"refs": ["footer", "header"]
|
|
37
|
+
},
|
|
38
|
+
"entry": {
|
|
39
|
+
"version": "D8NyAZf7d5YahxJT5yN79A",
|
|
40
|
+
"meta": {
|
|
41
|
+
"type": "website/pages/Page.tsx",
|
|
42
|
+
"path": "/",
|
|
43
|
+
"refs": ["footer", "header"]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "footer",
|
|
49
|
+
"body": {
|
|
50
|
+
"__resolveType": "site/sections/Footer.tsx",
|
|
51
|
+
"columns": [
|
|
52
|
+
{
|
|
53
|
+
"__resolveType": "footer-b"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"__resolveType": "footer-a"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"__resolveType": "footer-a"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"version": "6-WZ8yiUs_rKrbuJOftvQA",
|
|
64
|
+
"meta": {
|
|
65
|
+
"type": "site/sections/Footer.tsx",
|
|
66
|
+
"refs": ["footer-a"]
|
|
67
|
+
},
|
|
68
|
+
"entry": {
|
|
69
|
+
"version": "6-WZ8yiUs_rKrbuJOftvQA",
|
|
70
|
+
"meta": {
|
|
71
|
+
"type": "site/sections/Footer.tsx",
|
|
72
|
+
"refs": ["footer-a"]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "footer-a",
|
|
78
|
+
"body": {
|
|
79
|
+
"__resolveType": "site/sections/Links.tsx",
|
|
80
|
+
"links": []
|
|
81
|
+
},
|
|
82
|
+
"version": "FKbaI1TQOkKUaJDToMSDXg",
|
|
83
|
+
"meta": {
|
|
84
|
+
"type": "site/sections/Links.tsx"
|
|
85
|
+
},
|
|
86
|
+
"entry": {
|
|
87
|
+
"version": "FKbaI1TQOkKUaJDToMSDXg",
|
|
88
|
+
"meta": {
|
|
89
|
+
"type": "site/sections/Links.tsx"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "plain",
|
|
95
|
+
"body": {
|
|
96
|
+
"title": "no type"
|
|
97
|
+
},
|
|
98
|
+
"version": "nDqa9jpXsR-37zvd7Y5rrw",
|
|
99
|
+
"meta": {},
|
|
100
|
+
"entry": {
|
|
101
|
+
"version": "nDqa9jpXsR-37zvd7Y5rrw"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "variants",
|
|
106
|
+
"body": {
|
|
107
|
+
"__resolveType": "multivariate",
|
|
108
|
+
"variants": [
|
|
109
|
+
{
|
|
110
|
+
"rule": {
|
|
111
|
+
"__resolveType": "never"
|
|
112
|
+
},
|
|
113
|
+
"value": {
|
|
114
|
+
"__resolveType": "Promo"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"rule": {
|
|
119
|
+
"__resolveType": "always"
|
|
120
|
+
},
|
|
121
|
+
"value": {
|
|
122
|
+
"__resolveType": "lazy",
|
|
123
|
+
"value": {
|
|
124
|
+
"__resolveType": "header"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
"version": "NY3fN7vf-0QANkzlwdvuKg",
|
|
131
|
+
"meta": {
|
|
132
|
+
"type": "multivariate",
|
|
133
|
+
"refs": ["header"]
|
|
134
|
+
},
|
|
135
|
+
"entry": {
|
|
136
|
+
"version": "NY3fN7vf-0QANkzlwdvuKg",
|
|
137
|
+
"meta": {
|
|
138
|
+
"type": "multivariate",
|
|
139
|
+
"refs": ["header"]
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"name": "extends",
|
|
145
|
+
"body": {
|
|
146
|
+
"__resolveType": "header",
|
|
147
|
+
"title": "override",
|
|
148
|
+
"path": "/x"
|
|
149
|
+
},
|
|
150
|
+
"version": "zuj5u8YTRDdaEv_7wSwnjg",
|
|
151
|
+
"meta": {
|
|
152
|
+
"type": "header",
|
|
153
|
+
"path": "/x",
|
|
154
|
+
"refs": ["header"]
|
|
155
|
+
},
|
|
156
|
+
"entry": {
|
|
157
|
+
"version": "zuj5u8YTRDdaEv_7wSwnjg",
|
|
158
|
+
"meta": {
|
|
159
|
+
"type": "header",
|
|
160
|
+
"path": "/x",
|
|
161
|
+
"refs": ["header"]
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"name": "redirects",
|
|
167
|
+
"body": {
|
|
168
|
+
"__resolveType": "website/loaders/redirects.ts",
|
|
169
|
+
"redirects": [
|
|
170
|
+
{
|
|
171
|
+
"from": "/old",
|
|
172
|
+
"to": "/new",
|
|
173
|
+
"type": "permanent"
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
},
|
|
177
|
+
"version": "b5gi6Yu1_tmkwW6fWbs02Q",
|
|
178
|
+
"meta": {
|
|
179
|
+
"type": "website/loaders/redirects.ts"
|
|
180
|
+
},
|
|
181
|
+
"entry": {
|
|
182
|
+
"version": "b5gi6Yu1_tmkwW6fWbs02Q",
|
|
183
|
+
"meta": {
|
|
184
|
+
"type": "website/loaders/redirects.ts"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"name": "CMS",
|
|
190
|
+
"body": {
|
|
191
|
+
"__resolveType": "cms-settings",
|
|
192
|
+
"telemetry": {
|
|
193
|
+
"enabled": false
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"version": "sBqXj5u549za_Plbqc6R_g",
|
|
197
|
+
"meta": {
|
|
198
|
+
"type": "cms-settings"
|
|
199
|
+
},
|
|
200
|
+
"entry": {
|
|
201
|
+
"version": "sBqXj5u549za_Plbqc6R_g",
|
|
202
|
+
"meta": {
|
|
203
|
+
"type": "cms-settings"
|
|
204
|
+
},
|
|
205
|
+
"data": {
|
|
206
|
+
"__resolveType": "cms-settings",
|
|
207
|
+
"telemetry": {
|
|
208
|
+
"enabled": false
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
}
|
|
@@ -77,3 +77,77 @@ export const contentHashFixtures: readonly ContentHashFixture[] = [
|
|
|
77
77
|
revision: "6913c5e6aa28f441d3b0102177b372e4fb7c08bc09bdd8698df85e597282ac96",
|
|
78
78
|
},
|
|
79
79
|
];
|
|
80
|
+
|
|
81
|
+
export interface BlockVersionFixture {
|
|
82
|
+
id: string;
|
|
83
|
+
/** The block (any JSON value). */
|
|
84
|
+
block: unknown;
|
|
85
|
+
/** Its canonical JSON. */
|
|
86
|
+
canonical: string;
|
|
87
|
+
/** `blockVersion(block)`: the first 16 bytes of SHA-256 over the canonical JSON, base64url, no padding. */
|
|
88
|
+
version: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Golden fixtures for block versions (`blockVersion`, in
|
|
93
|
+
* `@decocms/blocks/protocol`): every implementation that writes or checks
|
|
94
|
+
* `ifMatch` produces these exact versions.
|
|
95
|
+
*/
|
|
96
|
+
export const blockVersionFixtures: readonly BlockVersionFixture[] = [
|
|
97
|
+
{ id: "empty", block: {}, canonical: "{}", version: "RBNvo1WzZ4oRRq0W9-hkng" },
|
|
98
|
+
{
|
|
99
|
+
id: "key-order",
|
|
100
|
+
block: { b: 1, a: [true, null, "x"] },
|
|
101
|
+
canonical: '{"a":[true,null,"x"],"b":1}',
|
|
102
|
+
version: "VKZUFa03AiiFGh2ksxtv1A",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: "unicode-numbers",
|
|
106
|
+
block: {
|
|
107
|
+
__resolveType: "site/sections/Hero.tsx",
|
|
108
|
+
title: "Olá — ünïcode 😀",
|
|
109
|
+
n: -0,
|
|
110
|
+
f: 1.5e-7,
|
|
111
|
+
big: 1e21,
|
|
112
|
+
int: 10,
|
|
113
|
+
},
|
|
114
|
+
canonical:
|
|
115
|
+
'{"__resolveType":"site/sections/Hero.tsx","big":1e+21,"f":1.5e-7,"int":10,"n":0,"title":"Olá — ünïcode 😀"}',
|
|
116
|
+
version: "cvNhsZmxtnrgaCwRg73Kxw",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: "code-unit-order",
|
|
120
|
+
block: { é: 1, Z: 2, a: 3, aa: 4, "": 0 },
|
|
121
|
+
canonical: '{"":0,"Z":2,"a":3,"aa":4,"é":1}',
|
|
122
|
+
version: "psFj7dEx0yLDzHd3f9mabQ",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: "nested-escapes",
|
|
126
|
+
block: { nested: { z: { y: [1, { b: 2, a: 1 }] }, a: 'line\nbreak "q" \\ \u0001' } },
|
|
127
|
+
canonical: '{"nested":{"a":"line\\nbreak \\"q\\" \\\\ \\u0001","z":{"y":[1,{"a":1,"b":2}]}}}',
|
|
128
|
+
version: "-F2yA3CkzEaGhmts3kOA3w",
|
|
129
|
+
},
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
export interface RevisionIdFixture {
|
|
133
|
+
id: string;
|
|
134
|
+
/** Whether it has the shape of a revision id (`isRevisionId`). */
|
|
135
|
+
valid: boolean;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Revision ids (`<inv>-<uuidv7>`) and strings that aren't one. */
|
|
139
|
+
export const revisionIdFixtures: readonly RevisionIdFixture[] = [
|
|
140
|
+
{ id: "fe6c5e0d97ff-0193a1f2-6800-7c3e-9d2a-4b8e1f0c7a55", valid: true },
|
|
141
|
+
{ id: "fe5e5eb831ff-01a1a147-ce00-7000-8000-000000000000", valid: true },
|
|
142
|
+
{ id: "fe5e5eb831fe-01a1a147-ce01-7fff-bfff-ffffffffffff", valid: true },
|
|
143
|
+
// A git commit SHA, a content hash, a bare UUIDv7.
|
|
144
|
+
{ id: "1".repeat(40), valid: false },
|
|
145
|
+
{ id: "f".repeat(64), valid: false },
|
|
146
|
+
{ id: "0193a1f2-6800-7c3e-9d2a-4b8e1f0c7a55", valid: false },
|
|
147
|
+
// Uppercase, another UUID version, the wrong variant, a path.
|
|
148
|
+
{ id: "FE6C5E0D97FF-0193A1F2-6800-7C3E-9D2A-4B8E1F0C7A55", valid: false },
|
|
149
|
+
{ id: "fe6c5e0d97ff-0193a1f2-6800-4c3e-9d2a-4b8e1f0c7a55", valid: false },
|
|
150
|
+
{ id: "fe6c5e0d97ff-0193a1f2-6800-7c3e-cd2a-4b8e1f0c7a55", valid: false },
|
|
151
|
+
{ id: "fe6c5e0d97ff-0193a1f2-6800-7c3e-9d2a-4b8e1f0c7a55/../x", valid: false },
|
|
152
|
+
{ id: "", valid: false },
|
|
153
|
+
];
|
|
@@ -31,8 +31,16 @@ import { writeCases } from "./cases/writes.ts";
|
|
|
31
31
|
import { ConformanceContext, type ConformanceOptions, SkipCase } from "./context.ts";
|
|
32
32
|
|
|
33
33
|
export type { ConformanceCase } from "./cases/types.ts";
|
|
34
|
-
export {
|
|
34
|
+
export {
|
|
35
|
+
type BlockVersionFixture,
|
|
36
|
+
blockVersionFixtures,
|
|
37
|
+
type ContentHashFixture,
|
|
38
|
+
contentHashFixtures,
|
|
39
|
+
type RevisionIdFixture,
|
|
40
|
+
revisionIdFixtures,
|
|
41
|
+
} from "./contentHashFixtures.ts";
|
|
35
42
|
export type { ConformanceOptions } from "./context.ts";
|
|
43
|
+
export { type BlockMetaVector, type BlockMetaVectors, blockMetaVectors } from "./vectors.ts";
|
|
36
44
|
|
|
37
45
|
/** Every conformance case, in the order they run. */
|
|
38
46
|
export const conformanceCases: readonly ConformanceCase[] = [
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Golden vectors for `blockMeta` and `indexEntry` (see
|
|
3
|
+
* `@decocms/blocks/protocol`): every implementation that writes or reads a
|
|
4
|
+
* revision index (the SDK, the CLI, Studio's publish) checks it computes these
|
|
5
|
+
* exact entries. The JSON file is shared byte for byte with Studio's vendored
|
|
6
|
+
* copy.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { blockMetaVectors } from "@decocms/blocks/protocol/conformance";
|
|
10
|
+
* for (const c of blockMetaVectors.cases) {
|
|
11
|
+
* expect(blockMeta(c.body, blockMetaVectors.names)).toEqual(c.meta);
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import type { BlockMeta, IndexEntry } from "../../v8/blockMeta.ts";
|
|
16
|
+
import vectors from "./blockMetaVectors.json" with { type: "json" };
|
|
17
|
+
|
|
18
|
+
export interface BlockMetaVector {
|
|
19
|
+
/** The block's name in the index. */
|
|
20
|
+
name: string;
|
|
21
|
+
body: unknown;
|
|
22
|
+
/** `blockVersion(body)`. */
|
|
23
|
+
version: string;
|
|
24
|
+
/** `blockMeta(body, names)`. */
|
|
25
|
+
meta: BlockMeta;
|
|
26
|
+
/** `indexEntry(name, body, names)`. */
|
|
27
|
+
entry: IndexEntry;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface BlockMetaVectors {
|
|
31
|
+
/** The block names of the index the cases are computed for. */
|
|
32
|
+
names: readonly string[];
|
|
33
|
+
cases: readonly BlockMetaVector[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const blockMetaVectors: BlockMetaVectors = vectors as BlockMetaVectors;
|