@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
package/dist/v8/types.d.ts
CHANGED
|
@@ -17,36 +17,22 @@ export type Block = {
|
|
|
17
17
|
export type BlockFunction = (inputs: any) => unknown | Promise<unknown>;
|
|
18
18
|
/** A block map: what `.deco/index.ts` exports and the CLI reads. */
|
|
19
19
|
export type Blocks = Record<string, BlockFunction>;
|
|
20
|
-
/** One fixed copy of the content: what
|
|
20
|
+
/** One fixed copy of the content: what a content module exports and `load()` returns. */
|
|
21
21
|
export type Snapshot = {
|
|
22
22
|
revision: string;
|
|
23
23
|
/** The content map: entry name → saved JSON. */
|
|
24
24
|
blocks: Record<string, unknown>;
|
|
25
|
-
/**
|
|
25
|
+
/** An alias table: old type name → your type. */
|
|
26
26
|
aliases?: Record<string, string>;
|
|
27
27
|
/**
|
|
28
|
-
* The
|
|
29
|
-
*
|
|
30
|
-
* `
|
|
31
|
-
*/
|
|
32
|
-
schemaHash?: string;
|
|
33
|
-
/**
|
|
34
|
-
* The commit time of the git HEAD `deco content` built this content from
|
|
35
|
-
* (committer date, ISO 8601). A hosted release is swapped in only when its
|
|
36
|
-
* `publishedAt` is later; without one (a custom loader, an older content
|
|
37
|
-
* module, a build outside git), the bundled content counts as the oldest.
|
|
38
|
-
*/
|
|
39
|
-
committedAt?: string;
|
|
40
|
-
/**
|
|
41
|
-
* The hosts this release may be previewed on (host patterns), as Studio
|
|
42
|
-
* wrote them into the release metadata on delivery.decocms.com
|
|
43
|
-
* (`latest.json` and `revisions/<sha>.json`). Previews are checked against
|
|
44
|
-
* the current release's list; the bundled content has none.
|
|
28
|
+
* The hosts this content may be previewed on (host patterns), for content
|
|
29
|
+
* with no remote site. A hosted release's list is Studio's, in
|
|
30
|
+
* `latest.json` on delivery.decocms.com, and the CMS reads it from there.
|
|
45
31
|
*/
|
|
46
32
|
previewHosts?: string[];
|
|
47
33
|
};
|
|
48
34
|
/**
|
|
49
|
-
* The content module `
|
|
35
|
+
* The content module the CLI's `content()` writes: a snapshot plus `root`, the
|
|
50
36
|
* `.deco` folder it was generated from, which `createCMS` keys its instance
|
|
51
37
|
* on (see /next/api-reference#one-instance-per-process). Not exported.
|
|
52
38
|
*/
|
|
@@ -69,7 +55,7 @@ export interface DraftPointer {
|
|
|
69
55
|
host: string;
|
|
70
56
|
/** Starts with `/`; opaque to the app. Never carries the `__variant` parameters. */
|
|
71
57
|
path: string;
|
|
72
|
-
/** Opaque: identifies the editor's last save. `"local"` names no draft (
|
|
58
|
+
/** Opaque: identifies the editor's last save. `"local"` names no draft (the release itself). */
|
|
73
59
|
version: string;
|
|
74
60
|
/** The variants this preview forces (the query's `__variant` parameters); absent when none. */
|
|
75
61
|
variants?: ForcedVariant[];
|
|
@@ -114,7 +100,7 @@ export interface Redirect {
|
|
|
114
100
|
*/
|
|
115
101
|
from: string;
|
|
116
102
|
to: string;
|
|
117
|
-
/** `true` for a 301, `false` for a
|
|
103
|
+
/** `true` for a 301, `false` (a temporary redirect) for a 307. */
|
|
118
104
|
permanent: boolean;
|
|
119
105
|
/** Wins over `permanent`. */
|
|
120
106
|
status?: RedirectStatus;
|
|
@@ -241,17 +227,14 @@ export interface TelemetryConfig {
|
|
|
241
227
|
export interface CMSConfig {
|
|
242
228
|
/** Your block functions; the CMS uses `{ ...builtIns, ...blocks }`. */
|
|
243
229
|
blocks: Blocks;
|
|
244
|
-
/** The content module (`.deco/blocks.gen.ts`), or any {@link Loader}. */
|
|
245
|
-
content: ContentModule | Loader;
|
|
246
|
-
/** ms between `update()` checks of a content source that has one; minimum 60 000. */
|
|
247
|
-
interval?: number;
|
|
248
230
|
/**
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
* to override that, e.g. `dev: import.meta.env.DEV` or `dev: false`.
|
|
231
|
+
* The content without `site`: a snapshot, or any {@link Loader}. With
|
|
232
|
+
* `site`, leave it out: content comes from the delivery CDN at runtime,
|
|
233
|
+
* never from the bundle (passing both is an error).
|
|
253
234
|
*/
|
|
254
|
-
|
|
235
|
+
content?: ContentModule | Loader;
|
|
236
|
+
/** ms between `update()` checks of a content source that has one; minimum 60 000. */
|
|
237
|
+
interval?: number;
|
|
255
238
|
/** Where telemetry goes; see /next/telemetry. */
|
|
256
239
|
telemetry?: false | TelemetryConfig;
|
|
257
240
|
preview?: {
|
|
@@ -272,8 +255,11 @@ export interface CMSConfig {
|
|
|
272
255
|
draftHosts?: string[];
|
|
273
256
|
};
|
|
274
257
|
/**
|
|
275
|
-
* Your site ID (Studio's site slug):
|
|
276
|
-
* `delivery.decocms.com
|
|
258
|
+
* Your site ID (Studio's site slug): the content is the site's latest
|
|
259
|
+
* release on `delivery.decocms.com`, fetched at runtime (the first client
|
|
260
|
+
* loads it, with 10 s per fetch; until a load succeeds, clients answer
|
|
261
|
+
* `LOADER_FAILED` with a `ContentUnavailableError` cause) and followed
|
|
262
|
+
* every `interval`. Drafts don't need it.
|
|
277
263
|
*/
|
|
278
264
|
site?: string;
|
|
279
265
|
/**
|
|
@@ -304,7 +290,33 @@ export interface ListOptions<T> {
|
|
|
304
290
|
*/
|
|
305
291
|
export interface Client {
|
|
306
292
|
resolve<T = unknown>(target: unknown, options?: ResolveOptions): Promise<Result<T>>;
|
|
293
|
+
/**
|
|
294
|
+
* Every saved block of a type, read whole. For tools and type lists; routing
|
|
295
|
+
* reads `routes()` and `redirects()`, which need no body (a `page` or
|
|
296
|
+
* `redirect` list warns outside production).
|
|
297
|
+
*/
|
|
307
298
|
list<T = Block>(type: string, options?: ListOptions<T>): Promise<Result<T[]>>;
|
|
299
|
+
/**
|
|
300
|
+
* `{ name, path }` of every page (a saved block whose type is `page`, or an
|
|
301
|
+
* alias of it, with a `path`), from the index alone, in code-unit order of
|
|
302
|
+
* name so the same page wins a path conflict everywhere. The same array for
|
|
303
|
+
* the same revision, so `matchRoute` builds its trie once per revision.
|
|
304
|
+
* `name` is the saved block's name: `resolve(name)` reads the page.
|
|
305
|
+
*/
|
|
306
|
+
routes(): Promise<Result<Route[]>>;
|
|
307
|
+
/**
|
|
308
|
+
* The rules of the site's redirects block (the saved block of type
|
|
309
|
+
* `redirects`; the first in code-unit order of name when there are
|
|
310
|
+
* several), `[]` when there is none.
|
|
311
|
+
*/
|
|
312
|
+
redirects(): Promise<Result<Redirect[]>>;
|
|
313
|
+
/**
|
|
314
|
+
* Starts fetching the saved block `name` and everything it references,
|
|
315
|
+
* with the redirects block, in one parallel wave, so `redirects()` and
|
|
316
|
+
* `resolve(name)` find them in memory. Never throws; a block that can't be
|
|
317
|
+
* fetched fails where it is read.
|
|
318
|
+
*/
|
|
319
|
+
prefetch(name: string): void;
|
|
308
320
|
/**
|
|
309
321
|
* The revision this client reads (loads it on first use). Unlike `resolve`
|
|
310
322
|
* and `list`, it rejects with the `LOADER_FAILED` error when the content
|
|
@@ -314,8 +326,8 @@ export interface Client {
|
|
|
314
326
|
/** Who is visiting, as passed to `cms.client()` (a frozen copy); `null` for none. */
|
|
315
327
|
readonly visitor: Visitor | null;
|
|
316
328
|
/**
|
|
317
|
-
* The version it reads: the release's
|
|
318
|
-
* passed to `cms.client()`. For the current release, the
|
|
329
|
+
* The version it reads: the release's revision id, or the draft pointer, as
|
|
330
|
+
* passed to `cms.client()`. For the current release, the id of the release
|
|
319
331
|
* it loaded (`undefined` until its first `resolve`, `list` or `revision()`).
|
|
320
332
|
*/
|
|
321
333
|
readonly version: string | undefined;
|
|
@@ -332,7 +344,7 @@ export interface Client {
|
|
|
332
344
|
export interface ClientOptions {
|
|
333
345
|
/**
|
|
334
346
|
* What to read: `undefined` (or `null`) for the current release; a
|
|
335
|
-
* published release's
|
|
347
|
+
* published release's revision id (`<inv>-<uuidv7>`), read from hosted
|
|
336
348
|
* releases; or a draft pointer, the draft's changes over the current
|
|
337
349
|
* release. Only a version: a Studio link's moment and switched tests are
|
|
338
350
|
* the options below (`cms.readVersion(request)` reads all of them).
|
|
@@ -343,7 +355,7 @@ export interface ClientOptions {
|
|
|
343
355
|
* (`cms.checkRelease()`), so the draft waits for it instead of making a
|
|
344
356
|
* check of its own; one request, one read of the release metadata. An id
|
|
345
357
|
* this CMS didn't make (another process's) is a check of its own. Ignored
|
|
346
|
-
* for the release and a release's
|
|
358
|
+
* for the release and a release's revision id.
|
|
347
359
|
*/
|
|
348
360
|
releaseCheck?: string | null;
|
|
349
361
|
/**
|
|
@@ -376,7 +388,7 @@ export interface ClientOptions {
|
|
|
376
388
|
* in the shape of `ClientOptions`, so it spreads into `cms.client()`.
|
|
377
389
|
*/
|
|
378
390
|
export interface RequestVersion {
|
|
379
|
-
/** A draft pointer, or a published release's
|
|
391
|
+
/** A draft pointer, or a published release's revision id. */
|
|
380
392
|
version: string;
|
|
381
393
|
/** The moment the preview shows (`__at`). */
|
|
382
394
|
date?: Date;
|
|
@@ -435,7 +447,7 @@ export interface CMS {
|
|
|
435
447
|
settings(): Promise<EffectiveSettings>;
|
|
436
448
|
/**
|
|
437
449
|
* What a Studio link asks for: `?__draft=` first, then the `__deco_draft`
|
|
438
|
-
* cookie, holding a draft pointer or a published release's
|
|
450
|
+
* cookie, holding a draft pointer or a published release's revision id,
|
|
439
451
|
* with the preview's moment (`__at`) and switched tests (`__test`) and
|
|
440
452
|
* campaigns (`__campaign`) as `date`, `experiments` and `campaigns`.
|
|
441
453
|
* `null` when neither is present, for `?__draft=off`, on a host outside
|
|
@@ -445,7 +457,7 @@ export interface CMS {
|
|
|
445
457
|
* `preview.hosts`; no host while the metadata can't be read, besides
|
|
446
458
|
* `preview.hosts`), and for a value that doesn't parse (ignored,
|
|
447
459
|
* as if absent): in each case the request gets the current release. A
|
|
448
|
-
* draft and an older release's
|
|
460
|
+
* draft and an older release's id are both checked against the current
|
|
449
461
|
* release's list.
|
|
450
462
|
*
|
|
451
463
|
* ```ts
|
package/dist/v8/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/v8/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM7D;;;;GAIG;AACH,MAAM,MAAM,KAAK,GAAG;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAExE,mCAAmC;AACnC,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAExE,oEAAoE;AACpE,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAEnD,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/v8/types.ts"],"names":[],"mappings":"AAAA;;;GA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M,CAAC;IACxC,4DAA4D;IAC5D,UAAU,IAAI,MAAM,CAAC;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAC;IACjE;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5D,kEAAkE;IAClE,MAAM,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACxC;;;;OAIG;IACH,QAAQ,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACvC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACjG,sFAAsF;IACtF,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3D;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC3D"}
|
package/dist/v8/variants.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import type { ForcedVariant
|
|
2
|
-
|
|
1
|
+
import type { ForcedVariant } from "./types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* One saved block's body with the variants forced on it (those whose `block`
|
|
4
|
+
* is `name`), copied along the addressed paths only; the body itself when none
|
|
5
|
+
* applies. How a request applies forced variants to bodies it reads lazily.
|
|
6
|
+
*/
|
|
7
|
+
export declare function forceBody(name: string, body: unknown, variants: readonly ForcedVariant[], aliases: Readonly<Record<string, string>> | undefined): unknown;
|
|
3
8
|
//# sourceMappingURL=variants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../src/v8/variants.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../src/v8/variants.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,GACpD,OAAO,CAOT"}
|
package/dist/v8/variants.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Forced variants (see /next/releases-and-drafts#preview-a-variant): the
|
|
3
|
-
* variants a draft pointer's `__variant` parameters name, applied to
|
|
4
|
-
*
|
|
5
|
-
* variant, with the rule `true`, so it shows that variant's
|
|
6
|
-
* rule runs.
|
|
7
|
-
* one is never touched.
|
|
3
|
+
* variants a draft pointer's `__variant` parameters name, applied to each body
|
|
4
|
+
* a preview request reads (see ./pin.ts). Each addressed multivariate keeps
|
|
5
|
+
* only the forced variant, with the rule `true`, so it shows that variant's
|
|
6
|
+
* value and no other rule runs. A body is copied along the addressed paths
|
|
7
|
+
* only; the shared one is never touched.
|
|
8
8
|
*
|
|
9
9
|
* An address that doesn't reach a multivariate block with that variant (a
|
|
10
10
|
* renamed block, a moved section, an index past the end) is ignored, so a
|
|
@@ -12,32 +12,29 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { LEGACY_ALIASES } from "./builtins/legacy.js";
|
|
14
14
|
import { isPlainObject, own } from "./json.js";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
/**
|
|
16
|
+
* One saved block's body with the variants forced on it (those whose `block`
|
|
17
|
+
* is `name`), copied along the addressed paths only; the body itself when none
|
|
18
|
+
* applies. How a request applies forced variants to bodies it reads lazily.
|
|
19
|
+
*/
|
|
20
|
+
export function forceBody(name, body, variants, aliases) {
|
|
21
|
+
let out = body;
|
|
19
22
|
for (const { block, path, index } of variants) {
|
|
20
|
-
|
|
21
|
-
if (entry === undefined)
|
|
22
|
-
continue;
|
|
23
|
-
const keys = path === "" ? [] : path.split(".");
|
|
24
|
-
const next = forceAt(entry, keys, index, snapshot);
|
|
25
|
-
if (next === entry)
|
|
23
|
+
if (block !== name)
|
|
26
24
|
continue;
|
|
27
|
-
|
|
28
|
-
blocks[block] = next;
|
|
25
|
+
out = forceAt(out, path === "" ? [] : path.split("."), index, aliases);
|
|
29
26
|
}
|
|
30
|
-
return
|
|
27
|
+
return out;
|
|
31
28
|
}
|
|
32
|
-
function forceAt(node, keys, index,
|
|
29
|
+
function forceAt(node, keys, index, aliases) {
|
|
33
30
|
if (keys.length === 0)
|
|
34
|
-
return forceNode(node, index,
|
|
31
|
+
return forceNode(node, index, aliases);
|
|
35
32
|
const [key, ...rest] = keys;
|
|
36
33
|
if (Array.isArray(node)) {
|
|
37
34
|
const i = Number(key);
|
|
38
35
|
if (!Number.isInteger(i) || String(i) !== key || i < 0 || i >= node.length)
|
|
39
36
|
return node;
|
|
40
|
-
const child = forceAt(node[i], rest, index,
|
|
37
|
+
const child = forceAt(node[i], rest, index, aliases);
|
|
41
38
|
if (child === node[i])
|
|
42
39
|
return node;
|
|
43
40
|
const copy = node.slice();
|
|
@@ -46,15 +43,15 @@ function forceAt(node, keys, index, snapshot) {
|
|
|
46
43
|
}
|
|
47
44
|
if (!isPlainObject(node) || !Object.hasOwn(node, key))
|
|
48
45
|
return node;
|
|
49
|
-
const child = forceAt(node[key], rest, index,
|
|
46
|
+
const child = forceAt(node[key], rest, index, aliases);
|
|
50
47
|
return child === node[key] ? node : { ...node, [key]: child };
|
|
51
48
|
}
|
|
52
49
|
/** A multivariate block (by its own name or an alias) with only `variants[index]`, ruled `true`. */
|
|
53
|
-
function forceNode(node, index,
|
|
50
|
+
function forceNode(node, index, aliases) {
|
|
54
51
|
if (!isPlainObject(node) || typeof node.__resolveType !== "string")
|
|
55
52
|
return node;
|
|
56
53
|
const type = node.__resolveType;
|
|
57
|
-
const canonical = own(
|
|
54
|
+
const canonical = own(aliases, type) ?? own(LEGACY_ALIASES, type) ?? type;
|
|
58
55
|
if (canonical !== "multivariate" || !Array.isArray(node.variants))
|
|
59
56
|
return node;
|
|
60
57
|
const variant = node.variants[index];
|
package/dist/v8/variants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variants.js","sourceRoot":"","sources":["../../src/v8/variants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAG/C,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"variants.js","sourceRoot":"","sources":["../../src/v8/variants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAG/C;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,IAAa,EACb,QAAkC,EAClC,OAAqD;IAErD,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC9C,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QAC7B,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,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,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;AAChE,CAAC;AAED,oGAAoG;AACpG,SAAS,SAAS,CAAC,IAAa,EAAE,KAAa,EAAE,OAAgB;IAC/D,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,aAAa,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAChF,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC;IAChC,MAAM,SAAS,GACb,GAAG,CAAC,OAA6C,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC;IAChG,IAAI,SAAS,KAAK,cAAc,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/E,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACzC,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAC7D,CAAC"}
|
package/dist/v8/vite/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* block in open pages during `vite dev`. Vite sites add it to
|
|
4
4
|
* `vite.config.ts`; Next.js sites don't use it.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Whatever rewrites `.deco/blocks.gen.ts` (content without a site: the
|
|
7
|
+
* CLI's `content()`) triggers it. In `vite dev`, in the server
|
|
8
8
|
* environments, the plugin makes each module that imports it (usually
|
|
9
9
|
* `src/cms.ts`) accept that import's updates: the new content goes into the
|
|
10
10
|
* CMS already created for its `.deco` folder (`adoptContent`), and only then
|
package/dist/v8/vite/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export const CONTENT_UPDATED_EVENT = "decocms:content-updated";
|
|
|
4
4
|
const RELOAD_DELAY_MS = 100;
|
|
5
5
|
/** The module the footer imports `adoptContent` from. */
|
|
6
6
|
const HOT_MODULE = "@decocms/blocks/vite/hot";
|
|
7
|
-
/** The content module `
|
|
7
|
+
/** The content module (the CLI's `content()` writes it), wherever the `.deco` folder is. */
|
|
8
8
|
const CONTENT_MODULE = /(?:^|[\\/])\.deco[\\/]blocks\.gen\.ts$/;
|
|
9
9
|
/** Source files whose imports the plugin reads. */
|
|
10
10
|
const SOURCE_FILE = /\.(?:[cm]?[jt]sx?)$/;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v8/vite/index.ts"],"names":[],"mappings":"AA2BA,oHAAoH;AACpH,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAE/D,iGAAiG;AACjG,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,yDAAyD;AACzD,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAE9C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v8/vite/index.ts"],"names":[],"mappings":"AA2BA,oHAAoH;AACpH,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAE/D,iGAAiG;AACjG,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,yDAAyD;AACzD,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAE9C,4FAA4F;AAC5F,MAAM,cAAc,GAAG,wCAAwC,CAAC;AAEhE,mDAAmD;AACnD,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAE1C,iGAAiG;AACjG,MAAM,aAAa,GACjB,gGAAgG,CAAC;AAEnG,gGAAgG;AAChG,MAAM,WAAW,GAAG,oDAAoD,CAAC;AAEzE,qDAAqD;AACrD,MAAM,QAAQ,GAAG,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BACtB,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC;oBAC9D,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;gBACvC,CAAC,EAAE,eAAe,CAAC,CAAC;YACtB,CAAC,CAAC;YACF,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,MAAM,CAClE,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAC1D,CAAC;YACF,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;gBACvC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/blocks",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24"
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"files": [
|
|
46
46
|
"bin",
|
|
47
47
|
"dist",
|
|
48
|
+
"skills",
|
|
48
49
|
"src",
|
|
49
50
|
"!src/**/*.test.ts",
|
|
50
51
|
"!src/**/*.test.tsx",
|
|
@@ -141,7 +142,7 @@
|
|
|
141
142
|
}
|
|
142
143
|
},
|
|
143
144
|
"scripts": {
|
|
144
|
-
"build": "node ../../scripts/tsc.mjs --clean dist -p tsconfig.build.json",
|
|
145
|
+
"build": "node ../../scripts/tsc.mjs --clean dist -p tsconfig.build.json && node ../../scripts/pack-skills.mjs",
|
|
145
146
|
"prepack": "npm run build",
|
|
146
147
|
"test": "vitest run --root ../.. packages/blocks/",
|
|
147
148
|
"typecheck": "node ../../scripts/tsc.mjs -p tsconfig.json"
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deco-apps
|
|
3
|
+
description: "The thin upstream clients of @decocms/blocks 8: @decocms/apps-vtex, apps-shopify, apps-wake, apps-magento, apps-algolia, apps-resend and apps-sfmc-personalization. Covers creating and configuring each client (settings as arguments, credentials from the deploy platform's secrets), what each call returns and throws, retries and the circuit breaker (VTEX only), telemetry through createInstrumentedFetch, upstream caching through the site's own fetch, v7 app loaders vendored into src/vendor and moved onto a client, the schema.org commerce types and helpers in @decocms/compat-v7/commerce, and VTEX specifics: forwarding shopper cookies and Set-Cookie, VtexIdclientAutCookie and headless login hosts, sales channel and regionId, orderForm sections, Intelligent Search cookies, and caching only shopper-invariant responses. Load it when a site calls a commerce, search, email or personalization backend, when a cart, sign-in, price or region is wrong, or when porting a v7 loader to a v8 client."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Upstream clients (`@decocms/apps-*`)
|
|
7
|
+
|
|
8
|
+
On v8 each backend has one thin client package. A client is a factory that takes its
|
|
9
|
+
settings as arguments and returns typed request functions. Every request goes through
|
|
10
|
+
`createInstrumentedFetch` from `@decocms/blocks/fetch`, so it is measured once and
|
|
11
|
+
reported to the CMS telemetry.
|
|
12
|
+
|
|
13
|
+
A client does **not** read environment variables, read the incoming request, cache,
|
|
14
|
+
convert to commerce types, or ship hooks, loaders or actions. Those are site code:
|
|
15
|
+
|
|
16
|
+
- `src/clients/<app>.ts` creates the client (the v7 → v8 migration script writes it).
|
|
17
|
+
- `src/vendor/<app>/…` holds the v7 loaders, actions and converters the content calls.
|
|
18
|
+
- Server functions or route handlers run the cart, session and sign-in calls, because
|
|
19
|
+
they have the shopper's request.
|
|
20
|
+
|
|
21
|
+
Use this skill when the site talks to a backend. For wiring the binding, writing
|
|
22
|
+
sections or caching pages, see the skills listed at the end.
|
|
23
|
+
|
|
24
|
+
## The packages
|
|
25
|
+
|
|
26
|
+
| Package | Factory | Entry points | Retries and breaker |
|
|
27
|
+
|---|---|---|---|
|
|
28
|
+
| `@decocms/apps-vtex` | `createVtexClient(config)` | `.`, `/image` | On by default |
|
|
29
|
+
| `@decocms/apps-shopify` | `createShopifyClient(config, { fetch? })` | `.`, `/image` | Off |
|
|
30
|
+
| `@decocms/apps-wake` | `createWakeClient(config, { fetch? })` | `.`, `/storefront`, `/storefront/types` | Off |
|
|
31
|
+
| `@decocms/apps-magento` | `createMagentoClient(config, { fetch? })` | `.` | Off |
|
|
32
|
+
| `@decocms/apps-algolia` | `createAlgoliaClient(config, { fetch? })` | `.` | Off |
|
|
33
|
+
| `@decocms/apps-resend` | `createResendClient(config, { fetch? })` | `.` | Off |
|
|
34
|
+
| `@decocms/apps-sfmc-personalization` | `createSfmcPersonalizationClient(config, { fetch? })` | `.` | Off |
|
|
35
|
+
|
|
36
|
+
Each takes `@decocms/blocks` `^8.4.0` as a peer. All packages of this repo release in
|
|
37
|
+
lockstep at one version, so install the client at the same version as `@decocms/blocks`.
|
|
38
|
+
VTEX takes `fetch` inside its config; the others take it in a second argument.
|
|
39
|
+
|
|
40
|
+
## When to load what
|
|
41
|
+
|
|
42
|
+
| Reference | Load it when |
|
|
43
|
+
|---|---|
|
|
44
|
+
| [`references/instrumented-fetch.md`](./references/instrumented-fetch.md) | Errors you need to handle, retries, the circuit breaker, telemetry labels, adding an upstream cache, calling an endpoint no client covers |
|
|
45
|
+
| [`references/vendored-loaders.md`](./references/vendored-loaders.md) | After the migration script: `src/clients/<app>.ts`, `src/vendor/`, moving a v7 loader or action onto the v8 client, keeping v7's client instead |
|
|
46
|
+
| [`references/commerce-types.md`](./references/commerce-types.md) | Typing `Product`, `Offer`, `ProductListingPage`; `useOffer`, `formatPrice`, analytics mappers; mapping VTEX fields to schema.org |
|
|
47
|
+
| [`references/vtex.md`](./references/vtex.md) | Configuring `createVtexClient`, its operations, sales channel, `regionId`, locale, orderForm sections, Master Data, IO GraphQL, image URLs |
|
|
48
|
+
| [`references/vtex-cookies-auth.md`](./references/vtex-cookies-auth.md) | Empty cart after add-to-cart, lost session, sign-in loops, `VtexIdclientAutCookie`, Intelligent Search cookies, what may be cached |
|
|
49
|
+
| [`references/shopify.md`](./references/shopify.md) | Storefront or Admin GraphQL on Shopify, API version, `ShopifyError` codes |
|
|
50
|
+
| [`references/wake.md`](./references/wake.md) | Wake Storefront operations and types, `getLogin` |
|
|
51
|
+
| [`references/magento.md`](./references/magento.md) | Magento REST and GraphQL, bearer token, customer tokens, origin header |
|
|
52
|
+
| [`references/algolia.md`](./references/algolia.md) | Algolia multi-query search, API keys |
|
|
53
|
+
| [`references/messaging.md`](./references/messaging.md) | Sending email with Resend, Salesforce Marketing Cloud Personalization events |
|
|
54
|
+
|
|
55
|
+
## Rules that hold for every client
|
|
56
|
+
|
|
57
|
+
- **Create the client once per isolate, on first use** (`client ??= createVtexClient(…)`).
|
|
58
|
+
The circuit breaker and its failure count live in the client instance. A client per
|
|
59
|
+
request never opens its breaker.
|
|
60
|
+
- **Credentials come from the deploy platform's secrets**, read where the site creates
|
|
61
|
+
the client (the Worker's `env` on TanStack Start, `process.env` on Next.js). Content
|
|
62
|
+
holds no secrets on v8.
|
|
63
|
+
- **Call clients on the server only**: block functions, server functions, route
|
|
64
|
+
handlers. A client carries app keys and tokens. Never import it into a client component.
|
|
65
|
+
- **Errors carry the operation and the status, never a body, URL, token or cookie.**
|
|
66
|
+
Network failures and an open circuit are thrown as they are, not as the client's
|
|
67
|
+
error class. See [`instrumented-fetch.md`](./references/instrumented-fetch.md).
|
|
68
|
+
- **Clients never cache.** The site caches, by passing its own `fetch`, and caches
|
|
69
|
+
only responses that are the same for every shopper.
|
|
70
|
+
- **Shopper data is per request.** A block function gets only its inputs, with no
|
|
71
|
+
request. Cart, session and profile calls need the shopper's `Cookie` header, so they
|
|
72
|
+
run in a server function or route handler, and their responses are private.
|
|
73
|
+
|
|
74
|
+
## Related skills
|
|
75
|
+
|
|
76
|
+
- `deco-v7-to-v8-migration`: the script that writes `src/clients/` and `src/vendor/`.
|
|
77
|
+
- `deco-site-authoring`: block functions and loaders that call these clients.
|
|
78
|
+
- `deco-tanstack-site`, `deco-nextjs-site`: server functions, route handlers, the worker.
|
|
79
|
+
- `deco-storefront-caching`: page cache, segments, private responses.
|
|
80
|
+
- `deco-storefront-performance`: duplicate upstream calls, payload size.
|
|
81
|
+
- `deco-images-media`: the `/image` providers of apps-vtex and apps-shopify.
|
|
82
|
+
- `vtex-delivery-promise` (decocms/skills): delivery badges, regionalization, postal-code capture on VTEX.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# `@decocms/apps-algolia`
|
|
2
|
+
|
|
3
|
+
A client for Algolia's Search REST API. It calls the REST API directly, not through the
|
|
4
|
+
`algoliasearch` SDK, so every request is measured like any other client's.
|
|
5
|
+
|
|
6
|
+
## Configure
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import { createAlgoliaClient } from "@decocms/apps-algolia";
|
|
10
|
+
|
|
11
|
+
export const algolia = createAlgoliaClient(
|
|
12
|
+
{ applicationId: "APP123", apiKey: secrets.ALGOLIA_SEARCH_KEY },
|
|
13
|
+
{ fetch: cachedFetch }, // optional
|
|
14
|
+
);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- `applicationId` must be letters and digits only, or the factory throws
|
|
18
|
+
`"algolia: invalid applicationId"`. It becomes part of the host
|
|
19
|
+
(`https://{applicationId}-dsn.algolia.net`), so nothing else is accepted.
|
|
20
|
+
- Use a **search-only** API key. The client runs on the server, but a key that can write
|
|
21
|
+
to indices has no business in a storefront.
|
|
22
|
+
- Exports: `createAlgoliaClient`, `AlgoliaClient`, `AlgoliaClientConfig`,
|
|
23
|
+
`AlgoliaSearchRequest`, `AlgoliaSearchResponse`, `AlgoliaHit`, `AlgoliaError`.
|
|
24
|
+
|
|
25
|
+
## Search
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
const { results } = await algolia.search<ProductRecord>([
|
|
29
|
+
{ indexName: "products", query: "linen shirt", hitsPerPage: 12, filters: "inStock:true" },
|
|
30
|
+
{ indexName: "products_suggestions", query: "linen", hitsPerPage: 5 },
|
|
31
|
+
]);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- `search(requests)` posts all queries in one request to `/1/indexes/*/queries` and
|
|
35
|
+
returns `{ results }`, one `AlgoliaSearchResponse` per query, in order.
|
|
36
|
+
- Each request is `indexName` plus search parameters as the REST API names them
|
|
37
|
+
(`query`, `hitsPerPage`, `page`, `filters`, `facets`…). The client passes them through.
|
|
38
|
+
- Each hit is your record type plus `objectID`.
|
|
39
|
+
- It is the only operation; the telemetry label is `search`. Batch a page's queries
|
|
40
|
+
into one call instead of several.
|
|
41
|
+
|
|
42
|
+
## Errors and caching
|
|
43
|
+
|
|
44
|
+
`AlgoliaError` has `operation` and `status`. No retries or circuit breaker: one attempt.
|
|
45
|
+
|
|
46
|
+
A search with the same parameters returns the same result for every shopper, so it can
|
|
47
|
+
be cached by the site, keyed on the request body (every query and parameter):
|
|
48
|
+
[`instrumented-fetch.md`](./instrumented-fetch.md).
|
|
49
|
+
|
|
50
|
+
No converter to commerce types ships with it. Map hits to `Product` in site code, keeping
|
|
51
|
+
the rules in [`commerce-types.md`](./commerce-types.md).
|