@decocms/blocks 8.1.0-next.0 → 8.1.0-next.2
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/bin/deco.js +5 -12
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol/assets.d.ts +46 -0
- package/dist/protocol/assets.d.ts.map +1 -0
- package/dist/protocol/assets.js +105 -0
- package/dist/protocol/assets.js.map +1 -0
- package/dist/protocol/canonical.d.ts +8 -0
- package/dist/protocol/canonical.d.ts.map +1 -0
- package/dist/protocol/canonical.js +8 -0
- package/dist/protocol/canonical.js.map +1 -0
- package/dist/protocol/ciphertext.d.ts +7 -0
- package/dist/protocol/ciphertext.d.ts.map +1 -0
- package/dist/protocol/ciphertext.js +7 -0
- package/dist/protocol/ciphertext.js.map +1 -0
- package/dist/protocol/client.d.ts +54 -0
- package/dist/protocol/client.d.ts.map +1 -0
- package/dist/protocol/client.js +104 -0
- package/dist/protocol/client.js.map +1 -0
- package/dist/protocol/conformance/cases/assets.d.ts +3 -0
- package/dist/protocol/conformance/cases/assets.d.ts.map +1 -0
- package/dist/protocol/conformance/cases/assets.js +71 -0
- package/dist/protocol/conformance/cases/assets.js.map +1 -0
- package/dist/protocol/conformance/cases/guards.d.ts +3 -0
- package/dist/protocol/conformance/cases/guards.d.ts.map +1 -0
- package/dist/protocol/conformance/cases/guards.js +265 -0
- package/dist/protocol/conformance/cases/guards.js.map +1 -0
- package/dist/protocol/conformance/cases/reads.d.ts +3 -0
- package/dist/protocol/conformance/cases/reads.d.ts.map +1 -0
- package/dist/protocol/conformance/cases/reads.js +140 -0
- package/dist/protocol/conformance/cases/reads.js.map +1 -0
- package/dist/protocol/conformance/cases/types.d.ts +9 -0
- package/dist/protocol/conformance/cases/types.d.ts.map +1 -0
- package/dist/protocol/conformance/cases/types.js +2 -0
- package/dist/protocol/conformance/cases/types.js.map +1 -0
- package/dist/protocol/conformance/cases/wire.d.ts +3 -0
- package/dist/protocol/conformance/cases/wire.d.ts.map +1 -0
- package/dist/protocol/conformance/cases/wire.js +130 -0
- package/dist/protocol/conformance/cases/wire.js.map +1 -0
- package/dist/protocol/conformance/cases/writes.d.ts +3 -0
- package/dist/protocol/conformance/cases/writes.d.ts.map +1 -0
- package/dist/protocol/conformance/cases/writes.js +278 -0
- package/dist/protocol/conformance/cases/writes.js.map +1 -0
- package/dist/protocol/conformance/contentHashFixtures.d.ts +22 -0
- package/dist/protocol/conformance/contentHashFixtures.d.ts.map +1 -0
- package/dist/protocol/conformance/contentHashFixtures.js +64 -0
- package/dist/protocol/conformance/contentHashFixtures.js.map +1 -0
- package/dist/protocol/conformance/context.d.ts +100 -0
- package/dist/protocol/conformance/context.d.ts.map +1 -0
- package/dist/protocol/conformance/context.js +155 -0
- package/dist/protocol/conformance/context.js.map +1 -0
- package/dist/protocol/conformance/index.d.ts +32 -0
- package/dist/protocol/conformance/index.d.ts.map +1 -0
- package/dist/protocol/conformance/index.js +90 -0
- package/dist/protocol/conformance/index.js.map +1 -0
- package/dist/protocol/errors.d.ts +85 -0
- package/dist/protocol/errors.d.ts.map +1 -0
- package/dist/protocol/errors.js +62 -0
- package/dist/protocol/errors.js.map +1 -0
- package/dist/protocol/index.d.ts +25 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +25 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/protocol/keys.d.ts +101 -0
- package/dist/protocol/keys.d.ts.map +1 -0
- package/dist/protocol/keys.js +223 -0
- package/dist/protocol/keys.js.map +1 -0
- package/dist/protocol/params.d.ts +10 -0
- package/dist/protocol/params.d.ts.map +1 -0
- package/dist/protocol/params.js +54 -0
- package/dist/protocol/params.js.map +1 -0
- package/dist/protocol/secrets.d.ts +22 -0
- package/dist/protocol/secrets.d.ts.map +1 -0
- package/dist/protocol/secrets.js +200 -0
- package/dist/protocol/secrets.js.map +1 -0
- package/dist/protocol/server/assets.d.ts +20 -0
- package/dist/protocol/server/assets.d.ts.map +1 -0
- package/dist/protocol/server/assets.js +77 -0
- package/dist/protocol/server/assets.js.map +1 -0
- package/dist/protocol/server/auth.d.ts +31 -0
- package/dist/protocol/server/auth.d.ts.map +1 -0
- package/dist/protocol/server/auth.js +32 -0
- package/dist/protocol/server/auth.js.map +1 -0
- package/dist/protocol/server/bodyCache.d.ts +28 -0
- package/dist/protocol/server/bodyCache.d.ts.map +1 -0
- package/dist/protocol/server/bodyCache.js +75 -0
- package/dist/protocol/server/bodyCache.js.map +1 -0
- package/dist/protocol/server/content.d.ts +44 -0
- package/dist/protocol/server/content.d.ts.map +1 -0
- package/dist/protocol/server/content.js +132 -0
- package/dist/protocol/server/content.js.map +1 -0
- package/dist/protocol/server/core.d.ts +63 -0
- package/dist/protocol/server/core.d.ts.map +1 -0
- package/dist/protocol/server/core.js +77 -0
- package/dist/protocol/server/core.js.map +1 -0
- package/dist/protocol/server/handler.d.ts +5 -0
- package/dist/protocol/server/handler.d.ts.map +1 -0
- package/dist/protocol/server/handler.js +70 -0
- package/dist/protocol/server/handler.js.map +1 -0
- package/dist/protocol/server/http.d.ts +24 -0
- package/dist/protocol/server/http.d.ts.map +1 -0
- package/dist/protocol/server/http.js +133 -0
- package/dist/protocol/server/http.js.map +1 -0
- package/dist/protocol/server/index.d.ts +11 -0
- package/dist/protocol/server/index.d.ts.map +1 -0
- package/dist/protocol/server/index.js +9 -0
- package/dist/protocol/server/index.js.map +1 -0
- package/dist/protocol/server/methods/apply.d.ts +4 -0
- package/dist/protocol/server/methods/apply.d.ts.map +1 -0
- package/dist/protocol/server/methods/apply.js +275 -0
- package/dist/protocol/server/methods/apply.js.map +1 -0
- package/dist/protocol/server/methods/read.d.ts +14 -0
- package/dist/protocol/server/methods/read.d.ts.map +1 -0
- package/dist/protocol/server/methods/read.js +132 -0
- package/dist/protocol/server/methods/read.js.map +1 -0
- package/dist/protocol/server/rpc.d.ts +7 -0
- package/dist/protocol/server/rpc.d.ts.map +1 -0
- package/dist/protocol/server/rpc.js +115 -0
- package/dist/protocol/server/rpc.js.map +1 -0
- package/dist/protocol/storage/fs/hash.d.ts +8 -0
- package/dist/protocol/storage/fs/hash.d.ts.map +1 -0
- package/dist/protocol/storage/fs/hash.js +20 -0
- package/dist/protocol/storage/fs/hash.js.map +1 -0
- package/dist/protocol/storage/fs/index.d.ts +30 -0
- package/dist/protocol/storage/fs/index.d.ts.map +1 -0
- package/dist/protocol/storage/fs/index.js +301 -0
- package/dist/protocol/storage/fs/index.js.map +1 -0
- package/dist/protocol/storage/fs/lock.d.ts +8 -0
- package/dist/protocol/storage/fs/lock.d.ts.map +1 -0
- package/dist/protocol/storage/fs/lock.js +61 -0
- package/dist/protocol/storage/fs/lock.js.map +1 -0
- package/dist/protocol/storage/fs/transaction.d.ts +19 -0
- package/dist/protocol/storage/fs/transaction.d.ts.map +1 -0
- package/dist/protocol/storage/fs/transaction.js +174 -0
- package/dist/protocol/storage/fs/transaction.js.map +1 -0
- package/dist/protocol/storage/fs/unsupported.d.ts +10 -0
- package/dist/protocol/storage/fs/unsupported.d.ts.map +1 -0
- package/dist/protocol/storage/fs/unsupported.js +4 -0
- package/dist/protocol/storage/fs/unsupported.js.map +1 -0
- package/dist/protocol/storage/memory.d.ts +40 -0
- package/dist/protocol/storage/memory.d.ts.map +1 -0
- package/dist/protocol/storage/memory.js +179 -0
- package/dist/protocol/storage/memory.js.map +1 -0
- package/dist/protocol/storage.d.ts +178 -0
- package/dist/protocol/storage.d.ts.map +1 -0
- package/dist/protocol/storage.js +29 -0
- package/dist/protocol/storage.js.map +1 -0
- package/dist/protocol/types.d.ts +194 -0
- package/dist/protocol/types.d.ts.map +1 -0
- package/dist/protocol/types.js +31 -0
- package/dist/protocol/types.js.map +1 -0
- package/dist/v8/analytics.d.ts +31 -0
- package/dist/v8/analytics.d.ts.map +1 -0
- package/dist/v8/analytics.js +46 -0
- package/dist/v8/analytics.js.map +1 -0
- package/dist/v8/background.d.ts +26 -0
- package/dist/v8/background.d.ts.map +1 -0
- package/dist/v8/background.js +95 -0
- package/dist/v8/background.js.map +1 -0
- package/dist/v8/builtins/data.d.ts +15 -0
- package/dist/v8/builtins/data.d.ts.map +1 -0
- package/dist/v8/builtins/data.js +18 -0
- package/dist/v8/builtins/data.js.map +1 -0
- package/dist/v8/builtins/index.d.ts +9 -0
- package/dist/v8/builtins/index.d.ts.map +1 -0
- package/dist/v8/builtins/index.js +24 -0
- package/dist/v8/builtins/index.js.map +1 -0
- package/dist/v8/builtins/lazy.d.ts +17 -0
- package/dist/v8/builtins/lazy.d.ts.map +1 -0
- package/dist/v8/builtins/lazy.js +13 -0
- package/dist/v8/builtins/lazy.js.map +1 -0
- package/dist/v8/builtins/legacy.d.ts +41 -0
- package/dist/v8/builtins/legacy.d.ts.map +1 -0
- package/dist/v8/builtins/legacy.js +62 -0
- package/dist/v8/builtins/legacy.js.map +1 -0
- package/dist/v8/builtins/matchers.d.ts +19 -0
- package/dist/v8/builtins/matchers.d.ts.map +1 -0
- package/dist/v8/builtins/matchers.js +24 -0
- package/dist/v8/builtins/matchers.js.map +1 -0
- package/dist/v8/builtins/multivariate.d.ts +15 -0
- package/dist/v8/builtins/multivariate.d.ts.map +1 -0
- package/dist/v8/builtins/multivariate.js +18 -0
- package/dist/v8/builtins/multivariate.js.map +1 -0
- package/dist/v8/builtins/secret.d.ts +7 -0
- package/dist/v8/builtins/secret.d.ts.map +1 -0
- package/dist/v8/builtins/secret.js +68 -0
- package/dist/v8/builtins/secret.js.map +1 -0
- package/dist/v8/canonical.d.ts +42 -0
- package/dist/v8/canonical.d.ts.map +1 -0
- package/dist/v8/canonical.js +111 -0
- package/dist/v8/canonical.js.map +1 -0
- package/dist/v8/ciphertext.d.ts +58 -0
- package/dist/v8/ciphertext.d.ts.map +1 -0
- package/dist/v8/ciphertext.js +134 -0
- package/dist/v8/ciphertext.js.map +1 -0
- package/dist/v8/cli/builtins.d.ts +11 -0
- package/dist/v8/cli/builtins.d.ts.map +1 -0
- package/dist/v8/cli/builtins.js +18 -0
- package/dist/v8/cli/builtins.js.map +1 -0
- package/dist/v8/cli/check/index.d.ts +41 -0
- package/dist/v8/cli/check/index.d.ts.map +1 -0
- package/dist/v8/cli/check/index.js +713 -0
- package/dist/v8/cli/check/index.js.map +1 -0
- package/dist/v8/cli/check/messages.d.ts +24 -0
- package/dist/v8/cli/check/messages.d.ts.map +1 -0
- package/dist/v8/cli/check/messages.js +150 -0
- package/dist/v8/cli/check/messages.js.map +1 -0
- package/dist/v8/cli/content.d.ts +60 -0
- package/dist/v8/cli/content.d.ts.map +1 -0
- package/dist/v8/cli/content.js +231 -0
- package/dist/v8/cli/content.js.map +1 -0
- package/dist/v8/cli/index.d.ts +18 -0
- package/dist/v8/cli/index.d.ts.map +1 -0
- package/dist/v8/cli/index.js +18 -0
- package/dist/v8/cli/index.js.map +1 -0
- package/dist/v8/cli/log.d.ts +9 -0
- package/dist/v8/cli/log.d.ts.map +1 -0
- package/dist/v8/cli/log.js +11 -0
- package/dist/v8/cli/log.js.map +1 -0
- package/dist/v8/cli/main.d.ts +2 -0
- package/dist/v8/cli/main.d.ts.map +1 -0
- package/dist/v8/cli/main.js +9 -0
- package/dist/v8/cli/main.js.map +1 -0
- package/dist/v8/cli/root.d.ts +28 -0
- package/dist/v8/cli/root.d.ts.map +1 -0
- package/dist/v8/cli/root.js +64 -0
- package/dist/v8/cli/root.js.map +1 -0
- package/dist/v8/cli/run.d.ts +13 -0
- package/dist/v8/cli/run.d.ts.map +1 -0
- package/dist/v8/cli/run.js +210 -0
- package/dist/v8/cli/run.js.map +1 -0
- package/dist/v8/cli/schema/builtinSchemas.d.ts +22 -0
- package/dist/v8/cli/schema/builtinSchemas.d.ts.map +1 -0
- package/dist/v8/cli/schema/builtinSchemas.js +213 -0
- package/dist/v8/cli/schema/builtinSchemas.js.map +1 -0
- package/dist/v8/cli/schema/generate.d.ts +50 -0
- package/dist/v8/cli/schema/generate.d.ts.map +1 -0
- package/dist/v8/cli/schema/generate.js +415 -0
- package/dist/v8/cli/schema/generate.js.map +1 -0
- package/dist/v8/cli/schema/index.d.ts +21 -0
- package/dist/v8/cli/schema/index.d.ts.map +1 -0
- package/dist/v8/cli/schema/index.js +51 -0
- package/dist/v8/cli/schema/index.js.map +1 -0
- package/dist/v8/cli/schema/tsProgram.d.ts +120 -0
- package/dist/v8/cli/schema/tsProgram.d.ts.map +1 -0
- package/dist/v8/cli/schema/tsProgram.js +418 -0
- package/dist/v8/cli/schema/tsProgram.js.map +1 -0
- package/dist/v8/cli/schema/typeToSchema.d.ts +81 -0
- package/dist/v8/cli/schema/typeToSchema.d.ts.map +1 -0
- package/dist/v8/cli/schema/typeToSchema.js +683 -0
- package/dist/v8/cli/schema/typeToSchema.js.map +1 -0
- package/dist/v8/cli/serve/server.d.ts +31 -0
- package/dist/v8/cli/serve/server.d.ts.map +1 -0
- package/dist/v8/cli/serve/server.js +247 -0
- package/dist/v8/cli/serve/server.js.map +1 -0
- package/dist/v8/cli/watch.d.ts +20 -0
- package/dist/v8/cli/watch.d.ts.map +1 -0
- package/dist/v8/cli/watch.js +79 -0
- package/dist/v8/cli/watch.js.map +1 -0
- package/dist/v8/client.d.ts +20 -0
- package/dist/v8/client.d.ts.map +1 -0
- package/dist/v8/client.js +115 -0
- package/dist/v8/client.js.map +1 -0
- package/dist/v8/cms.d.ts +9 -0
- package/dist/v8/cms.d.ts.map +1 -0
- package/dist/v8/cms.js +206 -0
- package/dist/v8/cms.js.map +1 -0
- package/dist/v8/content.d.ts +35 -0
- package/dist/v8/content.d.ts.map +1 -0
- package/dist/v8/content.js +183 -0
- package/dist/v8/content.js.map +1 -0
- package/dist/v8/draft.d.ts +44 -0
- package/dist/v8/draft.d.ts.map +1 -0
- package/dist/v8/draft.js +133 -0
- package/dist/v8/draft.js.map +1 -0
- package/dist/v8/errors.d.ts +21 -0
- package/dist/v8/errors.d.ts.map +1 -0
- package/dist/v8/errors.js +39 -0
- package/dist/v8/errors.js.map +1 -0
- package/dist/v8/fetch.d.ts +26 -0
- package/dist/v8/fetch.d.ts.map +1 -0
- package/dist/v8/fetch.js +98 -0
- package/dist/v8/fetch.js.map +1 -0
- package/dist/v8/identity.d.ts +19 -0
- package/dist/v8/identity.d.ts.map +1 -0
- package/dist/v8/identity.js +54 -0
- package/dist/v8/identity.js.map +1 -0
- package/dist/v8/index.d.ts +11 -0
- package/dist/v8/index.d.ts.map +1 -0
- package/dist/v8/index.js +10 -0
- package/dist/v8/index.js.map +1 -0
- package/dist/v8/json.d.ts +19 -0
- package/dist/v8/json.d.ts.map +1 -0
- package/dist/v8/json.js +65 -0
- package/dist/v8/json.js.map +1 -0
- package/dist/v8/matchRoute.d.ts +30 -0
- package/dist/v8/matchRoute.d.ts.map +1 -0
- package/dist/v8/matchRoute.js +175 -0
- package/dist/v8/matchRoute.js.map +1 -0
- package/dist/v8/remoteLoader.d.ts +16 -0
- package/dist/v8/remoteLoader.d.ts.map +1 -0
- package/dist/v8/remoteLoader.js +243 -0
- package/dist/v8/remoteLoader.js.map +1 -0
- package/dist/v8/resolver.d.ts +34 -0
- package/dist/v8/resolver.d.ts.map +1 -0
- package/dist/v8/resolver.js +219 -0
- package/dist/v8/resolver.js.map +1 -0
- package/dist/v8/secrets.d.ts +9 -0
- package/dist/v8/secrets.d.ts.map +1 -0
- package/dist/v8/secrets.js +14 -0
- package/dist/v8/secrets.js.map +1 -0
- package/dist/v8/telemetry.d.ts +61 -0
- package/dist/v8/telemetry.d.ts.map +1 -0
- package/dist/v8/telemetry.js +460 -0
- package/dist/v8/telemetry.js.map +1 -0
- package/dist/v8/types.d.ts +214 -0
- package/dist/v8/types.d.ts.map +1 -0
- package/dist/v8/types.js +2 -0
- package/dist/v8/types.js.map +1 -0
- package/package.json +65 -105
- package/src/index.ts +3 -13
- package/src/protocol/canonical.ts +1 -1
- package/src/protocol/ciphertext.ts +1 -1
- package/src/protocol/client.ts +2 -2
- package/src/protocol/conformance/cases/assets.ts +3 -3
- package/src/protocol/conformance/cases/guards.ts +4 -4
- package/src/protocol/conformance/cases/reads.ts +4 -4
- package/src/protocol/conformance/cases/types.ts +1 -1
- package/src/protocol/conformance/cases/wire.ts +4 -4
- package/src/protocol/conformance/cases/writes.ts +4 -4
- package/src/protocol/conformance/context.ts +4 -4
- package/src/protocol/conformance/index.ts +10 -10
- package/src/protocol/index.ts +6 -6
- package/src/protocol/params.ts +2 -2
- package/src/protocol/secrets.ts +3 -3
- package/src/protocol/server/assets.ts +6 -6
- package/src/protocol/server/auth.ts +1 -1
- package/src/protocol/server/content.ts +5 -5
- package/src/protocol/server/core.ts +12 -6
- package/src/protocol/server/handler.ts +6 -6
- package/src/protocol/server/http.ts +1 -1
- package/src/protocol/server/index.ts +3 -3
- package/src/protocol/server/methods/apply.ts +9 -9
- package/src/protocol/server/methods/read.ts +5 -5
- package/src/protocol/server/rpc.ts +6 -6
- package/src/protocol/storage/fs/index.ts +7 -7
- package/src/protocol/storage/fs/lock.ts +1 -1
- package/src/protocol/storage/fs/unsupported.ts +2 -2
- package/src/protocol/storage/memory.ts +5 -5
- package/src/protocol/storage.ts +1 -1
- package/src/v8/analytics.ts +2 -2
- package/src/v8/background.ts +3 -3
- package/src/v8/builtins/data.ts +1 -1
- package/src/v8/builtins/index.ts +6 -6
- package/src/v8/builtins/lazy.ts +1 -1
- package/src/v8/builtins/legacy.ts +2 -2
- package/src/v8/builtins/multivariate.ts +1 -1
- package/src/v8/builtins/secret.ts +2 -2
- package/src/v8/cli/builtins.ts +2 -2
- package/src/v8/cli/check/index.ts +11 -11
- package/src/v8/cli/content.ts +6 -6
- package/src/v8/cli/index.ts +8 -8
- package/src/v8/cli/main.ts +1 -1
- package/src/v8/cli/run.ts +7 -7
- package/src/v8/cli/schema/builtinSchemas.ts +1 -1
- package/src/v8/cli/schema/generate.ts +6 -6
- package/src/v8/cli/schema/index.ts +4 -4
- package/src/v8/cli/schema/tsProgram.ts +1 -1
- package/src/v8/cli/schema/typeToSchema.ts +24 -2
- package/src/v8/cli/serve/server.ts +9 -9
- package/src/v8/client.ts +5 -5
- package/src/v8/cms.ts +9 -9
- package/src/v8/content.ts +4 -4
- package/src/v8/draft.ts +1 -1
- package/src/v8/errors.ts +1 -1
- package/src/v8/fetch.ts +9 -28
- package/src/v8/identity.ts +1 -1
- package/src/v8/index.ts +5 -5
- package/src/v8/matchRoute.ts +1 -1
- package/src/v8/remoteLoader.ts +7 -7
- package/src/v8/resolver.ts +6 -6
- package/src/v8/secrets.ts +1 -1
- package/src/v8/telemetry.ts +6 -6
- package/src/cms/applySectionConventions.ts +0 -148
- package/src/cms/blockSource.ts +0 -228
- package/src/cms/client.ts +0 -85
- package/src/cms/deferredTrigger.ts +0 -58
- package/src/cms/draftSource.ts +0 -476
- package/src/cms/index.ts +0 -180
- package/src/cms/loadDecofileDirectory.ts +0 -89
- package/src/cms/loader.ts +0 -563
- package/src/cms/registry.ts +0 -264
- package/src/cms/renderJson.ts +0 -179
- package/src/cms/resolve.ts +0 -2583
- package/src/cms/schema.ts +0 -1219
- package/src/cms/sectionLoaderContext.ts +0 -113
- package/src/cms/sectionLoaders.ts +0 -686
- package/src/cms/sectionMixins.ts +0 -153
- package/src/flags/audience.ts +0 -56
- package/src/flags/everyone.ts +0 -29
- package/src/flags/flag.ts +0 -15
- package/src/flags/multivariate/image.ts +0 -11
- package/src/flags/multivariate/message.ts +0 -11
- package/src/flags/multivariate/page.ts +0 -16
- package/src/flags/multivariate/section.ts +0 -16
- package/src/flags/multivariate.ts +0 -1
- package/src/flags/types.ts +0 -59
- package/src/flags/utils/multivariate.ts +0 -20
- package/src/hooks/Image.tsx +0 -314
- package/src/hooks/JsonLd.tsx +0 -353
- package/src/hooks/LazySection.tsx +0 -121
- package/src/hooks/LiveControls.tsx +0 -144
- package/src/hooks/Picture.tsx +0 -127
- package/src/hooks/RenderSection.tsx +0 -91
- package/src/hooks/SectionErrorFallback.tsx +0 -97
- package/src/hooks/Stats.tsx +0 -134
- package/src/hooks/index.ts +0 -35
- package/src/hooks/useLoadMore.ts +0 -100
- package/src/matchers/builtins.ts +0 -459
- package/src/matchers/countryNames.ts +0 -104
- package/src/matchers/override.ts +0 -136
- package/src/matchers/posthog.ts +0 -154
- package/src/middleware/decoState.ts +0 -55
- package/src/middleware/healthMetrics.ts +0 -133
- package/src/middleware/hydrationContext.ts +0 -79
- package/src/middleware/index.ts +0 -88
- package/src/middleware/liveness.ts +0 -21
- package/src/middleware/observability.ts +0 -800
- package/src/middleware/validateSection.ts +0 -100
- package/src/preview/DraftPreviewBadge.tsx +0 -306
- package/src/preview/decoMark.ts +0 -11
- package/src/preview/index.ts +0 -8
- package/src/sdk/abTesting.ts +0 -556
- package/src/sdk/analytics.ts +0 -147
- package/src/sdk/cacheHeaders.ts +0 -633
- package/src/sdk/cacheStorage.ts +0 -287
- package/src/sdk/cachedLoader.ts +0 -556
- package/src/sdk/clx.ts +0 -5
- package/src/sdk/cn.ts +0 -28
- package/src/sdk/composite.ts +0 -114
- package/src/sdk/cookie.ts +0 -129
- package/src/sdk/crypto.ts +0 -199
- package/src/sdk/csp.ts +0 -59
- package/src/sdk/deepOmit.ts +0 -52
- package/src/sdk/detectDevice.ts +0 -45
- package/src/sdk/djb2.ts +0 -20
- package/src/sdk/encoding.ts +0 -44
- package/src/sdk/env.ts +0 -54
- package/src/sdk/experiments.ts +0 -314
- package/src/sdk/fetchCache.ts +0 -269
- package/src/sdk/fetchTimeout.ts +0 -58
- package/src/sdk/flags.ts +0 -138
- package/src/sdk/http.ts +0 -124
- package/src/sdk/index.ts +0 -97
- package/src/sdk/inflightTimeout.ts +0 -53
- package/src/sdk/instrumentedFetch.ts +0 -362
- package/src/sdk/invoke.ts +0 -298
- package/src/sdk/logger.ts +0 -304
- package/src/sdk/mergeCacheControl.ts +0 -150
- package/src/sdk/nonce.ts +0 -46
- package/src/sdk/normalizeUrls.ts +0 -91
- package/src/sdk/observability.ts +0 -116
- package/src/sdk/otel.ts +0 -1118
- package/src/sdk/otelAdapters/clickhouseCollector.ts +0 -65
- package/src/sdk/otelAdapters.ts +0 -144
- package/src/sdk/otelHttpLog.ts +0 -419
- package/src/sdk/otelHttpMeter.ts +0 -532
- package/src/sdk/otelHttpTracer.ts +0 -543
- package/src/sdk/redirects.ts +0 -336
- package/src/sdk/requestContext.ts +0 -281
- package/src/sdk/requestContextStorage.browser.ts +0 -43
- package/src/sdk/requestContextStorage.ts +0 -35
- package/src/sdk/responseCache.ts +0 -82
- package/src/sdk/retry.ts +0 -45
- package/src/sdk/serverTimings.ts +0 -68
- package/src/sdk/signal.ts +0 -42
- package/src/sdk/sitemap.ts +0 -160
- package/src/sdk/urlRedaction.ts +0 -82
- package/src/sdk/urlUtils.ts +0 -183
- package/src/sdk/useDevice.ts +0 -89
- package/src/sdk/useDeviceContext.tsx +0 -108
- package/src/sdk/useId.ts +0 -7
- package/src/sdk/useScript.ts +0 -210
- package/src/sdk/useSuggestions.ts +0 -188
- package/src/sdk/wrapCaughtErrors.ts +0 -107
- package/src/setup.ts +0 -120
- package/src/types/index.ts +0 -53
- package/src/types/widgets.ts +0 -14
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work that runs beside requests, never in front of them: release checks and
|
|
3
|
+
* telemetry batches (see /next/hosted-releases-internals and
|
|
4
|
+
* /next/telemetry-internals#sending-in-the-background).
|
|
5
|
+
*
|
|
6
|
+
* Where it runs, in order:
|
|
7
|
+
* - a hook the host installs under {@link BACKGROUND_HOOK};
|
|
8
|
+
* - on Cloudflare Workers, which run no timers between requests, the
|
|
9
|
+
* platform's `waitUntil` (from `cloudflare:workers`), so the task runs
|
|
10
|
+
* after the response with no binding and no user code: the core installs
|
|
11
|
+
* that hook itself;
|
|
12
|
+
* - `requestIdleCallback` (browsers, React Native);
|
|
13
|
+
* - `scheduler.postTask({ priority: "background" })`;
|
|
14
|
+
* - an unref'd `setTimeout` (so Node never stays alive for it), then
|
|
15
|
+
* `setImmediate` where it exists.
|
|
16
|
+
*
|
|
17
|
+
* A task never throws into its caller: errors and rejections are swallowed.
|
|
18
|
+
*/
|
|
19
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
20
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
21
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
22
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return path;
|
|
26
|
+
};
|
|
27
|
+
/** Where a host installs `(task) => void` to run background work its own way. */
|
|
28
|
+
const BACKGROUND_HOOK = Symbol.for("decocms.blocks.background");
|
|
29
|
+
/** Workers identify themselves in `navigator.userAgent`. */
|
|
30
|
+
function onWorkers() {
|
|
31
|
+
return (globalThis.navigator?.userAgent ===
|
|
32
|
+
"Cloudflare-Workers");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `cloudflare:workers`, loaded once. The specifier is computed so bundlers
|
|
36
|
+
* for other targets (browsers, Node) never try to resolve it.
|
|
37
|
+
*/
|
|
38
|
+
let workers;
|
|
39
|
+
function workersWaitUntil() {
|
|
40
|
+
const specifier = ["cloudflare", "workers"].join(":");
|
|
41
|
+
workers ??= import(__rewriteRelativeImportExtension(/* @vite-ignore */ /* webpackIgnore: true */ specifier)).then((mod) => typeof mod.waitUntil === "function" ? mod.waitUntil : undefined, () => undefined);
|
|
42
|
+
return workers;
|
|
43
|
+
}
|
|
44
|
+
export function runInBackground(task) {
|
|
45
|
+
const run = async () => {
|
|
46
|
+
try {
|
|
47
|
+
await task();
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// Background work fails quietly; nothing reaches a request.
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const g = globalThis;
|
|
54
|
+
const hook = g[BACKGROUND_HOOK];
|
|
55
|
+
if (typeof hook === "function") {
|
|
56
|
+
hook(run);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (onWorkers()) {
|
|
60
|
+
void workersWaitUntil().then((waitUntil) => {
|
|
61
|
+
if (waitUntil === undefined)
|
|
62
|
+
return void run();
|
|
63
|
+
// From now on, hand every task straight to the platform.
|
|
64
|
+
if (typeof g[BACKGROUND_HOOK] !== "function") {
|
|
65
|
+
g[BACKGROUND_HOOK] = (next) => waitUntil(next());
|
|
66
|
+
}
|
|
67
|
+
g[BACKGROUND_HOOK]?.(run);
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (typeof g.requestIdleCallback === "function") {
|
|
72
|
+
g.requestIdleCallback(() => void run());
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (typeof g.scheduler?.postTask === "function") {
|
|
76
|
+
g.scheduler.postTask(() => void run(), { priority: "background" }).catch(() => { });
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
later(0, () => {
|
|
80
|
+
if (typeof g.setImmediate === "function")
|
|
81
|
+
g.setImmediate(() => void run());
|
|
82
|
+
else
|
|
83
|
+
void run();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/** `setTimeout` that never keeps a Node process alive. */
|
|
87
|
+
export function later(ms, callback) {
|
|
88
|
+
const timer = setTimeout(callback, ms);
|
|
89
|
+
timer?.unref?.();
|
|
90
|
+
}
|
|
91
|
+
/** Whether a host installed a background hook (then batches go out after each response). */
|
|
92
|
+
export function hasBackgroundHook() {
|
|
93
|
+
return typeof globalThis[BACKGROUND_HOOK] === "function";
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=background.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background.js","sourceRoot":"","sources":["../../src/v8/background.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;AAEH,iFAAiF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U,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Analytics, Redirect, Telemetry } from "../types.ts";
|
|
2
|
+
/** The hosted Deco CMS collector: where page views go when `collector` is left out. */
|
|
3
|
+
export declare const HOSTED_ANALYTICS_COLLECTOR = "https://d.lilstts.com/events";
|
|
4
|
+
/**
|
|
5
|
+
* `page`: its inputs are already resolved (`seo` and every block in
|
|
6
|
+
* `sections`), so the page is its input.
|
|
7
|
+
*/
|
|
8
|
+
export declare const page: <P>(props: P) => P;
|
|
9
|
+
/** `redirect`: returns its arguments as saved. */
|
|
10
|
+
export declare const redirect: (props: Redirect) => Redirect;
|
|
11
|
+
/** `telemetry`: the type of the well-known `Telemetry` saved block; returns its arguments. */
|
|
12
|
+
export declare const telemetry: (props?: Telemetry) => Telemetry;
|
|
13
|
+
/** `analytics`: returns its input with the defaults filled in. */
|
|
14
|
+
export declare const analytics: (props?: Analytics) => Required<Analytics>;
|
|
15
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/v8/builtins/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAElE,uFAAuF;AACvF,eAAO,MAAM,0BAA0B,iCAAiC,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,CAAC,KAAG,CAAU,CAAC;AAE9C,kDAAkD;AAClD,eAAO,MAAM,QAAQ,UAAW,QAAQ,KAAG,QAAiB,CAAC;AAE7D,8FAA8F;AAC9F,eAAO,MAAM,SAAS,WAAW,SAAS,KAAQ,SAAkB,CAAC;AAErE,kEAAkE;AAClE,eAAO,MAAM,SAAS,WAAW,SAAS,KAAQ,QAAQ,CAAC,SAAS,CAIlE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The hosted Deco CMS collector: where page views go when `collector` is left out. */
|
|
2
|
+
export const HOSTED_ANALYTICS_COLLECTOR = "https://d.lilstts.com/events";
|
|
3
|
+
/**
|
|
4
|
+
* `page`: its inputs are already resolved (`seo` and every block in
|
|
5
|
+
* `sections`), so the page is its input.
|
|
6
|
+
*/
|
|
7
|
+
export const page = (props) => props;
|
|
8
|
+
/** `redirect`: returns its arguments as saved. */
|
|
9
|
+
export const redirect = (props) => props;
|
|
10
|
+
/** `telemetry`: the type of the well-known `Telemetry` saved block; returns its arguments. */
|
|
11
|
+
export const telemetry = (props = {}) => props;
|
|
12
|
+
/** `analytics`: returns its input with the defaults filled in. */
|
|
13
|
+
export const analytics = (props = {}) => ({
|
|
14
|
+
...props,
|
|
15
|
+
collector: props.collector ?? HOSTED_ANALYTICS_COLLECTOR,
|
|
16
|
+
enabled: props.enabled ?? true,
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../../src/v8/builtins/data.ts"],"names":[],"mappings":"AAEA,uFAAuF;AACvF,MAAM,CAAC,MAAM,0BAA0B,GAAG,8BAA8B,CAAC;AAEzE;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAI,KAAQ,EAAK,EAAE,CAAC,KAAK,CAAC;AAE9C,kDAAkD;AAClD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAe,EAAY,EAAE,CAAC,KAAK,CAAC;AAE7D,8FAA8F;AAC9F,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAK,GAAc,EAAE,EAAa,EAAE,CAAC,KAAK,CAAC;AAErE,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAK,GAAc,EAAE,EAAuB,EAAE,CAAC,CAAC;IACxE,GAAG,KAAK;IACR,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,0BAA0B;IACxD,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI;CAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BlockFunction } from "../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The built-in blocks every block map gets. `secret` here has no key, so it
|
|
4
|
+
* always fails; each CMS replaces it with one holding its `secrets.key`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const builtIns: Readonly<Record<string, BlockFunction>>;
|
|
7
|
+
/** Names no saved block can take (see /next/saved-blocks#names). */
|
|
8
|
+
export declare const RESERVED_NAMES: ReadonlySet<string>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v8/builtins/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAOjD;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAW3D,CAAC;AAEH,oEAAoE;AACpE,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,CAAkC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { analytics, page, redirect, telemetry } from "./data.js";
|
|
2
|
+
import { lazy } from "./lazy.js";
|
|
3
|
+
import { always, date, never } from "./matchers.js";
|
|
4
|
+
import { multivariate } from "./multivariate.js";
|
|
5
|
+
import { secretBlock } from "./secret.js";
|
|
6
|
+
/**
|
|
7
|
+
* The built-in blocks every block map gets. `secret` here has no key, so it
|
|
8
|
+
* always fails; each CMS replaces it with one holding its `secrets.key`.
|
|
9
|
+
*/
|
|
10
|
+
export const builtIns = Object.freeze({
|
|
11
|
+
lazy,
|
|
12
|
+
multivariate,
|
|
13
|
+
always,
|
|
14
|
+
never,
|
|
15
|
+
date,
|
|
16
|
+
page,
|
|
17
|
+
redirect,
|
|
18
|
+
telemetry,
|
|
19
|
+
analytics,
|
|
20
|
+
secret: secretBlock(),
|
|
21
|
+
});
|
|
22
|
+
/** Names no saved block can take (see /next/saved-blocks#names). */
|
|
23
|
+
export const RESERVED_NAMES = new Set(Object.keys(builtIns));
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v8/builtins/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA4C,MAAM,CAAC,MAAM,CAAC;IAC7E,IAAI;IACJ,YAAY;IACZ,MAAM;IACN,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,SAAS;IACT,SAAS;IACT,MAAM,EAAE,WAAW,EAAE;CACtB,CAAC,CAAC;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Lazy } from "../types.ts";
|
|
2
|
+
/** Marks the built-in `lazy` function, the resolver's one special case. */
|
|
3
|
+
declare const LAZY_BLOCK: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* The built-in `lazy` block. The resolver never calls it: it sees the marker
|
|
6
|
+
* and hands the parent a memoized `() => Promise<T>` that resolves `value`
|
|
7
|
+
* only when called. Called directly (outside the resolver), it wraps an
|
|
8
|
+
* already-resolved value, so it still honours the `Lazy<T>` contract.
|
|
9
|
+
*/
|
|
10
|
+
export declare const lazy: (<T>({ value }: {
|
|
11
|
+
value: T;
|
|
12
|
+
}) => Lazy<T>) & {
|
|
13
|
+
[LAZY_BLOCK]: true;
|
|
14
|
+
};
|
|
15
|
+
export declare function isLazyBuiltin(fn: unknown): boolean;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../src/v8/builtins/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC,2EAA2E;AAC3E,QAAA,MAAM,UAAU,EAAE,OAAO,MAA6C,CAAC;AAEvE;;;;;GAKG;AACH,eAAO,MAAM,IAAI,IACd,CAAC,aAAa;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,KAAG,IAAI,CAAC,CAAC,CAAC;;CAItC,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAIlD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Marks the built-in `lazy` function, the resolver's one special case. */
|
|
2
|
+
const LAZY_BLOCK = Symbol.for("decocms.blocks.v8.lazy");
|
|
3
|
+
/**
|
|
4
|
+
* The built-in `lazy` block. The resolver never calls it: it sees the marker
|
|
5
|
+
* and hands the parent a memoized `() => Promise<T>` that resolves `value`
|
|
6
|
+
* only when called. Called directly (outside the resolver), it wraps an
|
|
7
|
+
* already-resolved value, so it still honours the `Lazy<T>` contract.
|
|
8
|
+
*/
|
|
9
|
+
export const lazy = Object.assign(({ value }) => () => Promise.resolve(value), { [LAZY_BLOCK]: true });
|
|
10
|
+
export function isLazyBuiltin(fn) {
|
|
11
|
+
return (typeof fn === "function" && fn[LAZY_BLOCK] === true);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=lazy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.js","sourceRoot":"","sources":["../../../src/v8/builtins/lazy.ts"],"names":[],"mappings":"AAEA,2EAA2E;AAC3E,MAAM,UAAU,GAAkB,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAC/B,CAAI,EAAE,KAAK,EAAgB,EAAW,EAAE,CACtC,GAAG,EAAE,CACH,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAC1B,EAAE,CAAC,UAAU,CAAC,EAAE,IAAa,EAAE,CAChC,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,EAAW;IACvC,OAAO,CACL,OAAO,EAAE,KAAK,UAAU,IAAK,EAAyC,CAAC,UAAU,CAAC,KAAK,IAAI,CAC5F,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The legacy alias bridge: the well-known Fresh/Deno and v7 type names the
|
|
3
|
+
* site editor still writes, mapped to the built-ins, so v7 content resolves
|
|
4
|
+
* without a block-map entry (see /next/studio-compatibility#well-known-types-and-the-alias-table
|
|
5
|
+
* and /next/renames-and-migrations#rename-a-type-with-an-alias).
|
|
6
|
+
*
|
|
7
|
+
* A snapshot's own `aliases` (the table `deco content` writes) win over these, and a key in the block map wins over
|
|
8
|
+
* both, so a site can still register a legacy name itself.
|
|
9
|
+
*
|
|
10
|
+
* - Redirects keep v7's nested shape: `redirect` returns its arguments as
|
|
11
|
+
* saved, and `matchRoute` accepts both shapes.
|
|
12
|
+
* - `website/loaders/secret.ts` resolves as `secret`, which needs the
|
|
13
|
+
* `ciphertext` the one-time re-encryption writes (see
|
|
14
|
+
* /next/renames-and-migrations#secrets); a v7 `encrypted` value fails that
|
|
15
|
+
* block with `BLOCK_FAILED`.
|
|
16
|
+
* - Legacy variants are saved as plain values; on the way to `multivariate`
|
|
17
|
+
* each one is wrapped in a `lazy` block, so only the chosen one runs.
|
|
18
|
+
*/
|
|
19
|
+
import { type JsonObject } from "../json.ts";
|
|
20
|
+
/**
|
|
21
|
+
* Legacy type name → built-in. The one table: the runtime falls back to it,
|
|
22
|
+
* and `deco schema` / `deco content` write it into the schema and the content
|
|
23
|
+
* module. Exactly the names the site editor's special screens look for
|
|
24
|
+
* (/next/studio-compatibility#well-known-types-and-the-alias-table); other
|
|
25
|
+
* legacy names (`$live/…`, the per-kind multivariate files, the date
|
|
26
|
+
* matcher) are rewritten to these by the one-time migration
|
|
27
|
+
* (the `deco-v7-to-v8-migration` skill), and types with no built-in counterpart are
|
|
28
|
+
* left to the site's block map.
|
|
29
|
+
*/
|
|
30
|
+
export declare const LEGACY_ALIASES: Readonly<Record<string, string>>;
|
|
31
|
+
/**
|
|
32
|
+
* Whether a legacy name stores its variants' values plain (every legacy name
|
|
33
|
+
* for `multivariate`); under the short name each value carries a `lazy`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function storesPlainVariants(type: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* A legacy variants block with each plain `value` wrapped in `lazy`; any
|
|
38
|
+
* other block as is. A value that already is a `lazy` block stays one.
|
|
39
|
+
*/
|
|
40
|
+
export declare function wrapLegacyVariants(type: string, node: JsonObject): JsonObject;
|
|
41
|
+
//# sourceMappingURL=legacy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../../src/v8/builtins/legacy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAE5D;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAS1D,CAAC;AAEH;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CAW7E"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The legacy alias bridge: the well-known Fresh/Deno and v7 type names the
|
|
3
|
+
* site editor still writes, mapped to the built-ins, so v7 content resolves
|
|
4
|
+
* without a block-map entry (see /next/studio-compatibility#well-known-types-and-the-alias-table
|
|
5
|
+
* and /next/renames-and-migrations#rename-a-type-with-an-alias).
|
|
6
|
+
*
|
|
7
|
+
* A snapshot's own `aliases` (the table `deco content` writes) win over these, and a key in the block map wins over
|
|
8
|
+
* both, so a site can still register a legacy name itself.
|
|
9
|
+
*
|
|
10
|
+
* - Redirects keep v7's nested shape: `redirect` returns its arguments as
|
|
11
|
+
* saved, and `matchRoute` accepts both shapes.
|
|
12
|
+
* - `website/loaders/secret.ts` resolves as `secret`, which needs the
|
|
13
|
+
* `ciphertext` the one-time re-encryption writes (see
|
|
14
|
+
* /next/renames-and-migrations#secrets); a v7 `encrypted` value fails that
|
|
15
|
+
* block with `BLOCK_FAILED`.
|
|
16
|
+
* - Legacy variants are saved as plain values; on the way to `multivariate`
|
|
17
|
+
* each one is wrapped in a `lazy` block, so only the chosen one runs.
|
|
18
|
+
*/
|
|
19
|
+
import { isPlainObject } from "../json.js";
|
|
20
|
+
/**
|
|
21
|
+
* Legacy type name → built-in. The one table: the runtime falls back to it,
|
|
22
|
+
* and `deco schema` / `deco content` write it into the schema and the content
|
|
23
|
+
* module. Exactly the names the site editor's special screens look for
|
|
24
|
+
* (/next/studio-compatibility#well-known-types-and-the-alias-table); other
|
|
25
|
+
* legacy names (`$live/…`, the per-kind multivariate files, the date
|
|
26
|
+
* matcher) are rewritten to these by the one-time migration
|
|
27
|
+
* (the `deco-v7-to-v8-migration` skill), and types with no built-in counterpart are
|
|
28
|
+
* left to the site's block map.
|
|
29
|
+
*/
|
|
30
|
+
export const LEGACY_ALIASES = Object.freeze({
|
|
31
|
+
"website/pages/Page.tsx": "page",
|
|
32
|
+
"$live/pages/LivePage.tsx": "page",
|
|
33
|
+
"website/flags/multivariate.ts": "multivariate",
|
|
34
|
+
"website/flags/multivariate/section.ts": "multivariate",
|
|
35
|
+
"website/matchers/always.ts": "always",
|
|
36
|
+
"website/matchers/never.ts": "never",
|
|
37
|
+
"website/loaders/redirect.ts": "redirect",
|
|
38
|
+
"website/loaders/secret.ts": "secret",
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Whether a legacy name stores its variants' values plain (every legacy name
|
|
42
|
+
* for `multivariate`); under the short name each value carries a `lazy`.
|
|
43
|
+
*/
|
|
44
|
+
export function storesPlainVariants(type) {
|
|
45
|
+
return Object.hasOwn(LEGACY_ALIASES, type) && LEGACY_ALIASES[type] === "multivariate";
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A legacy variants block with each plain `value` wrapped in `lazy`; any
|
|
49
|
+
* other block as is. A value that already is a `lazy` block stays one.
|
|
50
|
+
*/
|
|
51
|
+
export function wrapLegacyVariants(type, node) {
|
|
52
|
+
if (!storesPlainVariants(type) || !Array.isArray(node.variants))
|
|
53
|
+
return node;
|
|
54
|
+
return {
|
|
55
|
+
...node,
|
|
56
|
+
variants: node.variants.map((variant) => isPlainObject(variant) &&
|
|
57
|
+
!(isPlainObject(variant.value) && variant.value.__resolveType === "lazy")
|
|
58
|
+
? { ...variant, value: { __resolveType: "lazy", value: variant.value } }
|
|
59
|
+
: variant),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=legacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../../src/v8/builtins/legacy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE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
|
3
|
+
/** `never`: the rule the site editor uses to hide a block. */
|
|
4
|
+
export declare const never: () => boolean;
|
|
5
|
+
/** Inputs of the built-in `date` matcher: ISO 8601 strings, both optional. */
|
|
6
|
+
interface DateProps {
|
|
7
|
+
/** Inclusive. */
|
|
8
|
+
start?: string;
|
|
9
|
+
/** Exclusive: `end` itself doesn't match. */
|
|
10
|
+
end?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* `date`: `true` from `start` (inclusive) until `end` (exclusive). A date
|
|
14
|
+
* without a time means midnight UTC. An unparseable bound never matches, so a
|
|
15
|
+
* typo can't switch a campaign on.
|
|
16
|
+
*/
|
|
17
|
+
export declare const date: ({ start, end }?: DateProps) => boolean;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=matchers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../../../src/v8/builtins/matchers.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,eAAO,MAAM,MAAM,QAAO,OAAe,CAAC;AAE1C,8DAA8D;AAC9D,eAAO,MAAM,KAAK,QAAO,OAAgB,CAAC;AAE1C,8EAA8E;AAC9E,UAAU,SAAS;IACjB,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,eAAO,MAAM,IAAI,oBAAoB,SAAS,KAAQ,OAWrD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** `always`: the fallback rule. */
|
|
2
|
+
export const always = () => true;
|
|
3
|
+
/** `never`: the rule the site editor uses to hide a block. */
|
|
4
|
+
export const never = () => false;
|
|
5
|
+
/**
|
|
6
|
+
* `date`: `true` from `start` (inclusive) until `end` (exclusive). A date
|
|
7
|
+
* without a time means midnight UTC. An unparseable bound never matches, so a
|
|
8
|
+
* typo can't switch a campaign on.
|
|
9
|
+
*/
|
|
10
|
+
export const date = ({ start, end } = {}) => {
|
|
11
|
+
const now = Date.now();
|
|
12
|
+
if (start !== undefined && start !== null && start !== "") {
|
|
13
|
+
const from = Date.parse(start);
|
|
14
|
+
if (Number.isNaN(from) || now < from)
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (end !== undefined && end !== null && end !== "") {
|
|
18
|
+
const until = Date.parse(end);
|
|
19
|
+
if (Number.isNaN(until) || now >= until)
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=matchers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchers.js","sourceRoot":"","sources":["../../../src/v8/builtins/matchers.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAY,EAAE,CAAC,IAAI,CAAC;AAE1C,8DAA8D;AAC9D,MAAM,CAAC,MAAM,KAAK,GAAG,GAAY,EAAE,CAAC,KAAK,CAAC;AAU1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,GAAc,EAAE,EAAW,EAAE;IAC9D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,IAAI;YAAE,OAAO,KAAK,CAAC;IACrD,CAAC;IACD,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;IACxD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Variant } from "../types.ts";
|
|
2
|
+
interface MultivariateProps<T> {
|
|
3
|
+
variants?: Variant<T>[];
|
|
4
|
+
/** The stable ID of an A/B test; results are kept per ID. */
|
|
5
|
+
experiment?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* `multivariate`: runs the first variant whose rule is `true` and returns its
|
|
9
|
+
* value, or `undefined` when no rule is. Only the chosen variant runs, because
|
|
10
|
+
* each `value` is a `Lazy<T>`. A value saved without the `lazy` wrapper (which
|
|
11
|
+
* `deco check` flags) is returned as is rather than failing the page.
|
|
12
|
+
*/
|
|
13
|
+
export declare const multivariate: <T>({ variants, }?: MultivariateProps<T>) => Promise<T | undefined>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=multivariate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multivariate.d.ts","sourceRoot":"","sources":["../../../src/v8/builtins/multivariate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,UAAU,iBAAiB,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAU,CAAC,kBAEjC,iBAAiB,CAAC,CAAC,CAAC,KAAQ,OAAO,CAAC,CAAC,GAAG,SAAS,CAQnD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `multivariate`: runs the first variant whose rule is `true` and returns its
|
|
3
|
+
* value, or `undefined` when no rule is. Only the chosen variant runs, because
|
|
4
|
+
* each `value` is a `Lazy<T>`. A value saved without the `lazy` wrapper (which
|
|
5
|
+
* `deco check` flags) is returned as is rather than failing the page.
|
|
6
|
+
*/
|
|
7
|
+
export const multivariate = async ({ variants, } = {}) => {
|
|
8
|
+
if (!Array.isArray(variants))
|
|
9
|
+
return undefined;
|
|
10
|
+
for (const variant of variants) {
|
|
11
|
+
if (variant?.rule !== true)
|
|
12
|
+
continue;
|
|
13
|
+
const value = variant.value;
|
|
14
|
+
return typeof value === "function" ? await value() : value;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=multivariate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multivariate.js","sourceRoot":"","sources":["../../../src/v8/builtins/multivariate.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAK,EACpC,QAAQ,GACT,GAAyB,EAAE,EAA0B,EAAE;IACtD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,OAAO,EAAE,IAAI,KAAK,IAAI;YAAE,SAAS;QACrC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAgB,CAAC;QACvC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,MAAO,KAA0B,EAAE,CAAC,CAAC,CAAE,KAAW,CAAC;IAC1F,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BlockFunction } from "../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The `secret` block for one private key. The CMS creates one per instance;
|
|
4
|
+
* the built-in list holds the keyless one, which always fails.
|
|
5
|
+
*/
|
|
6
|
+
export declare function secretBlock(key?: string, onDecrypt?: (value: string) => void): BlockFunction;
|
|
7
|
+
//# sourceMappingURL=secret.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret.d.ts","sourceRoot":"","sources":["../../../src/v8/builtins/secret.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAcjD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,aAAa,CA2C5F"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in `secret` block (see /next/built-in-blocks#secrets):
|
|
3
|
+
* `{ "__resolveType": "secret", "ciphertext": "v1.…" }` resolves to the
|
|
4
|
+
* decrypted string, on the server only.
|
|
5
|
+
*
|
|
6
|
+
* The ciphertext format lives in `../ciphertext` (a leaf module with no
|
|
7
|
+
* imports, which the protocol re-exports): a fresh AES-256-GCM key per value, wrapped with the
|
|
8
|
+
* site's RSA public key using RSA-OAEP and SHA-256. Decrypting takes the
|
|
9
|
+
* matching PKCS#8 private key, the PEM `createCMS({ secrets: { key } })` gets.
|
|
10
|
+
*
|
|
11
|
+
* Every failure (no key, the wrong key, a malformed ciphertext, a browser)
|
|
12
|
+
* throws, so the resolver reports `BLOCK_FAILED` for that block alone. No
|
|
13
|
+
* message ever includes the key or a decrypted value. `{ run: false }` and
|
|
14
|
+
* `client.list` never run functions, so they return the ciphertext as saved.
|
|
15
|
+
*
|
|
16
|
+
* Every decrypted value is handed to `onDecrypt` (the CMS redacts it from
|
|
17
|
+
* telemetry). A decrypted value stays on the server because it's resolved
|
|
18
|
+
* there; tainting it (React's taint API) is up to the site's own code.
|
|
19
|
+
*/
|
|
20
|
+
import { parseCiphertext } from "../ciphertext.js";
|
|
21
|
+
/** True in a browser, where a secret must never be decrypted. */
|
|
22
|
+
function inBrowser() {
|
|
23
|
+
const scope = globalThis;
|
|
24
|
+
return typeof scope.window === "object" && typeof scope.document === "object";
|
|
25
|
+
}
|
|
26
|
+
/** The DER bytes of a single `PRIVATE KEY` (PKCS#8) PEM block. */
|
|
27
|
+
function privateKeyDer(pem) {
|
|
28
|
+
const match = /-----BEGIN PRIVATE KEY-----([\s\S]*?)-----END PRIVATE KEY-----/.exec(pem);
|
|
29
|
+
return Uint8Array.from(atob(match?.[1]?.replace(/\s+/g, "") ?? ""), (c) => c.charCodeAt(0));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The `secret` block for one private key. The CMS creates one per instance;
|
|
33
|
+
* the built-in list holds the keyless one, which always fails.
|
|
34
|
+
*/
|
|
35
|
+
export function secretBlock(key, onDecrypt) {
|
|
36
|
+
let imported;
|
|
37
|
+
return async ({ ciphertext } = {}) => {
|
|
38
|
+
if (inBrowser())
|
|
39
|
+
throw new Error("a secret block resolves on the server only");
|
|
40
|
+
if (!key)
|
|
41
|
+
throw new Error("no key to decrypt secrets: pass createCMS({ secrets: { key } })");
|
|
42
|
+
const parts = parseCiphertext(ciphertext);
|
|
43
|
+
if (!parts)
|
|
44
|
+
throw new Error("the ciphertext is not well formed");
|
|
45
|
+
imported ??= Promise.resolve().then(() => crypto.subtle.importKey("pkcs8", privateKeyDer(key), { name: "RSA-OAEP", hash: "SHA-256" }, false, ["decrypt"]));
|
|
46
|
+
let rsa;
|
|
47
|
+
try {
|
|
48
|
+
rsa = await imported;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new Error("the secrets key is not an RSA private key in PKCS#8 PEM");
|
|
52
|
+
}
|
|
53
|
+
let value;
|
|
54
|
+
try {
|
|
55
|
+
const raw = await crypto.subtle.decrypt({ name: "RSA-OAEP" }, rsa, parts.wrappedKey);
|
|
56
|
+
const aes = await crypto.subtle.importKey("raw", raw, "AES-GCM", false, ["decrypt"]);
|
|
57
|
+
const plain = await crypto.subtle.decrypt({ name: "AES-GCM", iv: parts.iv }, aes, parts.ciphertext);
|
|
58
|
+
value = new TextDecoder().decode(plain);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// Web Crypto's errors say nothing useful, and this one never names the value.
|
|
62
|
+
throw new Error("the secret could not be decrypted with this key");
|
|
63
|
+
}
|
|
64
|
+
onDecrypt?.(value);
|
|
65
|
+
return value;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=secret.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret.js","sourceRoot":"","sources":["../../../src/v8/builtins/secret.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,iEAAiE;AACjE,SAAS,SAAS;IAChB,MAAM,KAAK,GAAG,UAAsD,CAAC;IACrE,OAAO,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC;AAChF,CAAC;AAED,kEAAkE;AAClE,SAAS,aAAa,CAAC,GAAW;IAChC,MAAM,KAAK,GAAG,gEAAgE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzF,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY,EAAE,SAAmC;IAC3E,IAAI,QAAwC,CAAC;IAC7C,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,GAA6B,EAAE,EAAmB,EAAE;QAC9E,IAA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AAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC;QAAC,MAAM,CAAC;YACP,8EAA8E;YAC9E,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QACD,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC;QACnB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical JSON and hashing shared by the protocol's request digests.
|
|
3
|
+
*
|
|
4
|
+
* Canonical form: object keys recursively sorted in JavaScript code-unit
|
|
5
|
+
* order, array order preserved, compact UTF-8 JSON with no trailing newline,
|
|
6
|
+
* JSON string escaping and number encoding (negative zero becomes zero).
|
|
7
|
+
* Values JSON can't represent (undefined, functions, symbols, bigints,
|
|
8
|
+
* non-finite numbers, cycles) are rejected rather than silently dropped.
|
|
9
|
+
*
|
|
10
|
+
* Uses Web Crypto, so it runs in browsers, on Workers and on Node.
|
|
11
|
+
*/
|
|
12
|
+
export declare class CanonicalJsonError extends Error {
|
|
13
|
+
constructor(message: string);
|
|
14
|
+
}
|
|
15
|
+
/** Serializes `value` to canonical JSON. Throws CanonicalJsonError for values JSON can't represent. */
|
|
16
|
+
export declare function canonicalJson(value: unknown): string;
|
|
17
|
+
/** SHA-256 of `data` (strings are UTF-8 encoded), as lowercase hex. */
|
|
18
|
+
export declare function sha256Hex(data: string | Uint8Array): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* The version of the canonical content-hashing format below. A snapshot
|
|
21
|
+
* envelope records it beside the revision; the revision itself is excluded
|
|
22
|
+
* from its own hash.
|
|
23
|
+
*/
|
|
24
|
+
export declare const CONTENT_HASH_FORMAT = 1;
|
|
25
|
+
/**
|
|
26
|
+
* The content revision of a `blocks` map: SHA-256 over its canonical JSON,
|
|
27
|
+
* lowercase hex. The one definition the CLI, the release materializer and
|
|
28
|
+
* the site editor's backend share; `contentHashFixtures` (in
|
|
29
|
+
* `@decocms/blocks/protocol/conformance`) pins its output.
|
|
30
|
+
*
|
|
31
|
+
* This identifies content, not storage: a storage's `blocks.list` revision
|
|
32
|
+
* is opaque and may be computed differently (from file versions).
|
|
33
|
+
*/
|
|
34
|
+
export declare function computeContentRevision(blocks: Record<string, unknown>): Promise<string>;
|
|
35
|
+
/** The domain prefix of `blocks.apply` request digests, so they never equal another hash. */
|
|
36
|
+
export declare const APPLY_DIGEST_DOMAIN = "deco-content/blocks.apply@1\n";
|
|
37
|
+
/**
|
|
38
|
+
* The digest a request key is bound to: SHA-256 over the domain prefix and
|
|
39
|
+
* the canonical JSON of every supplied parameter.
|
|
40
|
+
*/
|
|
41
|
+
export declare function applyRequestDigest(params: object): Promise<string>;
|
|
42
|
+
//# sourceMappingURL=canonical.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../src/v8/canonical.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAsDD,uGAAuG;AACvG,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAIpD;AAKD,uEAAuE;AACvE,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAG1E;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7F;AAED,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,kCAAkC,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAElE"}
|