@decocms/blocks 8.1.0-next.1 → 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 +64 -18
- package/src/index.ts +1 -1
- 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 +4 -4
- package/src/protocol/storage.ts +1 -1
- package/src/v8/analytics.ts +2 -2
- 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 +1 -1
- 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 +7 -7
- 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 +1 -1
- 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 +6 -6
- package/src/v8/resolver.ts +6 -6
- package/src/v8/secrets.ts +1 -1
- package/src/v8/telemetry.ts +5 -5
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types of the next-major (v8) core SDK. See the API reference
|
|
3
|
+
* (`/next/api-reference#types`) — every type here is documented there.
|
|
4
|
+
*/
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
/**
|
|
7
|
+
* A block as stored: the JSON in `.deco/blocks`, and what `client.list` and
|
|
8
|
+
* `{ run: false }` return. Props never use it: a field's type is the value the
|
|
9
|
+
* function receives.
|
|
10
|
+
*/
|
|
11
|
+
export type Block = {
|
|
12
|
+
__resolveType: string;
|
|
13
|
+
[input: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
/** A function a block can call. */
|
|
16
|
+
export type BlockFunction = (inputs: any) => unknown | Promise<unknown>;
|
|
17
|
+
/** A block map: what `.deco/index.ts` exports and the CLI reads. */
|
|
18
|
+
export type Blocks = Record<string, BlockFunction>;
|
|
19
|
+
/** One fixed copy of the content: what the content module exports and `load()` returns. */
|
|
20
|
+
export type Snapshot = {
|
|
21
|
+
revision: string;
|
|
22
|
+
/** The content map: entry name → saved JSON. */
|
|
23
|
+
blocks: Record<string, unknown>;
|
|
24
|
+
/** The alias table `deco content` writes: old type name → your type. */
|
|
25
|
+
aliases?: Record<string, string>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The content module `deco content` writes: a snapshot plus `root`, the
|
|
29
|
+
* `.deco` folder it was generated from, which `createCMS` keys its instance
|
|
30
|
+
* on (see /next/api-reference#one-instance-per-process). Not exported.
|
|
31
|
+
*/
|
|
32
|
+
export type ContentModule = Snapshot & {
|
|
33
|
+
root?: string;
|
|
34
|
+
};
|
|
35
|
+
/** A source of content. `load()` is the release; `load(pointer)` is a draft. */
|
|
36
|
+
export interface Loader {
|
|
37
|
+
load(pointer?: string | null): Promise<Snapshot>;
|
|
38
|
+
update?(): Promise<{
|
|
39
|
+
updated: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
/** The parts of a draft pointer, `<host[:port]><path[?query]>@<version>`. */
|
|
43
|
+
export interface DraftPointer {
|
|
44
|
+
/** `host[:port]` of the content source that holds the draft. */
|
|
45
|
+
host: string;
|
|
46
|
+
/** Starts with `/`; opaque to the app. */
|
|
47
|
+
path: string;
|
|
48
|
+
/** Opaque and immutable: the branch head or ETag. */
|
|
49
|
+
version: string;
|
|
50
|
+
}
|
|
51
|
+
/** An entry that lives at a URL. Extend it to make a type routable. */
|
|
52
|
+
export interface Route {
|
|
53
|
+
/** @title Name */
|
|
54
|
+
name: string;
|
|
55
|
+
/** @title Path */
|
|
56
|
+
path: string;
|
|
57
|
+
}
|
|
58
|
+
export interface Seo {
|
|
59
|
+
title: string;
|
|
60
|
+
description: string;
|
|
61
|
+
}
|
|
62
|
+
/** The built-in `page` block, resolved: without `seo`, the site's defaults apply. */
|
|
63
|
+
export interface Page extends Route {
|
|
64
|
+
seo?: Seo;
|
|
65
|
+
sections: ReactNode[];
|
|
66
|
+
}
|
|
67
|
+
/** The built-in `redirect` block. */
|
|
68
|
+
export interface Redirect {
|
|
69
|
+
/** Literal path or template (`:name` segments, an optional trailing `/*`). */
|
|
70
|
+
from: string;
|
|
71
|
+
to: string;
|
|
72
|
+
/** `true` for a 301, `false` for a 302. */
|
|
73
|
+
permanent: boolean;
|
|
74
|
+
/** Wins over `permanent`. */
|
|
75
|
+
status?: RedirectStatus;
|
|
76
|
+
/** Drop the request's query string instead of carrying it over. */
|
|
77
|
+
discardQueryParameters?: boolean;
|
|
78
|
+
}
|
|
79
|
+
export type RedirectStatus = 301 | 302 | 307 | 308;
|
|
80
|
+
/**
|
|
81
|
+
* The nested redirect shape v7 content stores (`website/loaders/redirect.ts`).
|
|
82
|
+
* `matchRoute` accepts it next to {@link Redirect}: `permanent` is a 301 and
|
|
83
|
+
* anything else a 307, the status the site editor has always written for it.
|
|
84
|
+
*/
|
|
85
|
+
export interface LegacyRedirect {
|
|
86
|
+
redirect: {
|
|
87
|
+
from: string;
|
|
88
|
+
to: string;
|
|
89
|
+
type?: "permanent" | "temporary";
|
|
90
|
+
discardQueryParameters?: boolean;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** A field the site editor saves encrypted, as a `secret` block. */
|
|
94
|
+
export type Secret = string & {
|
|
95
|
+
readonly __secret: true;
|
|
96
|
+
};
|
|
97
|
+
/** A prop the built-in `lazy` block fills; resolves its value when called, at most once. */
|
|
98
|
+
export type Lazy<T> = () => Promise<T>;
|
|
99
|
+
/** One entry of `variants`: a rule and the variant it shows. */
|
|
100
|
+
export interface Variant<T> {
|
|
101
|
+
rule: boolean;
|
|
102
|
+
value: Lazy<T>;
|
|
103
|
+
}
|
|
104
|
+
/** The `Telemetry` saved block's type (built-in `telemetry`). */
|
|
105
|
+
export interface Telemetry {
|
|
106
|
+
/** Default `true`; `false` switches telemetry off. */
|
|
107
|
+
enabled?: boolean;
|
|
108
|
+
/** Default `true`. */
|
|
109
|
+
metrics?: boolean;
|
|
110
|
+
/** Default 0.05, capped by `telemetry.limits`. */
|
|
111
|
+
errorSampleRate?: number;
|
|
112
|
+
/** Default 0, capped by `telemetry.limits`. */
|
|
113
|
+
traceSampleRate?: number;
|
|
114
|
+
}
|
|
115
|
+
/** The built-in `analytics` block's props. Separate from telemetry. */
|
|
116
|
+
export interface Analytics {
|
|
117
|
+
/** An endpoint that accepts the One Dollar Stats format; default: the hosted Deco CMS collector. */
|
|
118
|
+
collector?: string;
|
|
119
|
+
/** Default `true`; `false` makes `AnalyticsScript` render nothing. */
|
|
120
|
+
enabled?: boolean;
|
|
121
|
+
}
|
|
122
|
+
export type CMSErrorCode = "NOT_FOUND" | "UNKNOWN_BLOCK" | "CYCLE" | "BLOCK_FAILED" | "LOADER_FAILED";
|
|
123
|
+
export interface CMSError {
|
|
124
|
+
code: CMSErrorCode;
|
|
125
|
+
message: string;
|
|
126
|
+
/** Where in the tree it happened, such as `["sections", 2, "product"]`. */
|
|
127
|
+
path: (string | number)[];
|
|
128
|
+
/** The original error, for `BLOCK_FAILED` and `LOADER_FAILED`. */
|
|
129
|
+
cause?: unknown;
|
|
130
|
+
}
|
|
131
|
+
export type Result<T> = [T, null] | [null, CMSError];
|
|
132
|
+
export type Match<T> = {
|
|
133
|
+
kind: "match";
|
|
134
|
+
entry: T;
|
|
135
|
+
params: Record<string, string>;
|
|
136
|
+
} | {
|
|
137
|
+
kind: "redirect";
|
|
138
|
+
location: string;
|
|
139
|
+
status: RedirectStatus;
|
|
140
|
+
} | {
|
|
141
|
+
kind: "not-found";
|
|
142
|
+
};
|
|
143
|
+
export type TelemetryConfig = ({
|
|
144
|
+
site: string;
|
|
145
|
+
token: string;
|
|
146
|
+
} | {
|
|
147
|
+
endpoint: string;
|
|
148
|
+
headers?: Record<string, string>;
|
|
149
|
+
}) & {
|
|
150
|
+
limits?: {
|
|
151
|
+
errorSampleRate?: number;
|
|
152
|
+
traceSampleRate?: number;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
export interface CMSConfig {
|
|
156
|
+
/** Your block functions; the CMS uses `{ ...builtIns, ...blocks }`. */
|
|
157
|
+
blocks: Blocks;
|
|
158
|
+
/** The content module (`.deco/blocks.gen.ts`), or any {@link Loader}. */
|
|
159
|
+
content: ContentModule | Loader;
|
|
160
|
+
/** ms between `update()` checks of a content source that has one; minimum 60 000. */
|
|
161
|
+
interval?: number;
|
|
162
|
+
/** Where telemetry goes; see /next/telemetry. */
|
|
163
|
+
telemetry?: false | TelemetryConfig;
|
|
164
|
+
/** The private key that decrypts `secret` blocks. */
|
|
165
|
+
secrets?: {
|
|
166
|
+
key?: string;
|
|
167
|
+
};
|
|
168
|
+
/** Your site's ID, for hosted releases and drafts. */
|
|
169
|
+
site?: string;
|
|
170
|
+
/** Your site token (secret), for hosted releases and drafts. */
|
|
171
|
+
token?: string;
|
|
172
|
+
}
|
|
173
|
+
export interface ResolveOptions {
|
|
174
|
+
/** `false` reads without running: saved blocks expand, no function runs. */
|
|
175
|
+
run?: boolean;
|
|
176
|
+
}
|
|
177
|
+
export interface ListOptions<T> {
|
|
178
|
+
where?: (entry: T) => boolean;
|
|
179
|
+
sort?: (a: T, b: T) => number;
|
|
180
|
+
limit?: number;
|
|
181
|
+
run?: boolean;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Reads one revision for one request.
|
|
185
|
+
*
|
|
186
|
+
* Results are read-only. A client runs each block function once per distinct
|
|
187
|
+
* input, so the same block at two places in a request hands both places the
|
|
188
|
+
* same object; mutating it in place changes the other occurrence too. Copy a
|
|
189
|
+
* result before changing it. (The memo belongs to one client, so nothing is
|
|
190
|
+
* shared across requests.)
|
|
191
|
+
*/
|
|
192
|
+
export interface Client {
|
|
193
|
+
resolve<T = unknown>(target: unknown, options?: ResolveOptions): Promise<Result<T>>;
|
|
194
|
+
list<T = Block>(type: string, options?: ListOptions<T>): Promise<Result<T[]>>;
|
|
195
|
+
/**
|
|
196
|
+
* The revision this client reads (loads it on first use). Unlike `resolve`
|
|
197
|
+
* and `list`, it rejects with the `LOADER_FAILED` error when the content
|
|
198
|
+
* can't load, since there is no revision to report.
|
|
199
|
+
*/
|
|
200
|
+
revision(): Promise<string>;
|
|
201
|
+
}
|
|
202
|
+
export interface CMS {
|
|
203
|
+
/** A client reading the current release. */
|
|
204
|
+
forRelease(): Client;
|
|
205
|
+
/** A client reading the draft a pointer names. */
|
|
206
|
+
forDraft(pointer: string): Client;
|
|
207
|
+
/** A client pinned to a revision this CMS has served; an unknown revision behaves like the release. */
|
|
208
|
+
forRevision(revision: string): Client;
|
|
209
|
+
/** Ask the content source for newer content now; never throws. */
|
|
210
|
+
update(): Promise<{
|
|
211
|
+
updated: boolean;
|
|
212
|
+
}>;
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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;AAMvC;;;;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,2FAA2F;AAC3F,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD,gFAAgF;AAChF,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,CAAC,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC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AAO,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,MAAM;IACrB,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACpF,IAAI,CAAC,CAAC,GAAG,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9E;;;;OAIG;IACH,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,GAAG;IAClB,4CAA4C;IAC5C,UAAU,IAAI,MAAM,CAAC;IACrB,kDAAkD;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,uGAAuG;IACvG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IACtC,kEAAkE;IAClE,MAAM,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACzC"}
|
package/dist/v8/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/v8/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/blocks",
|
|
3
|
-
"version": "8.1.0-next.
|
|
3
|
+
"version": "8.1.0-next.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24"
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
"url": "https://github.com/decocms/blocks.git",
|
|
12
12
|
"directory": "packages/blocks"
|
|
13
13
|
},
|
|
14
|
-
"main": "./
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
15
16
|
"files": [
|
|
16
17
|
"bin",
|
|
18
|
+
"dist",
|
|
17
19
|
"src",
|
|
18
20
|
"!src/**/*.test.ts",
|
|
19
21
|
"!src/**/*.test.tsx",
|
|
@@ -26,28 +28,72 @@
|
|
|
26
28
|
"deco": "./bin/deco.js"
|
|
27
29
|
},
|
|
28
30
|
"exports": {
|
|
29
|
-
".":
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"./
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"source": "./src/index.ts",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./analytics": {
|
|
37
|
+
"types": "./dist/v8/analytics.d.ts",
|
|
38
|
+
"source": "./src/v8/analytics.ts",
|
|
39
|
+
"default": "./dist/v8/analytics.js"
|
|
40
|
+
},
|
|
41
|
+
"./cli": {
|
|
42
|
+
"types": "./dist/v8/cli/index.d.ts",
|
|
43
|
+
"source": "./src/v8/cli/index.ts",
|
|
44
|
+
"default": "./dist/v8/cli/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./fetch": {
|
|
47
|
+
"types": "./dist/v8/fetch.d.ts",
|
|
48
|
+
"source": "./src/v8/fetch.ts",
|
|
49
|
+
"default": "./dist/v8/fetch.js"
|
|
50
|
+
},
|
|
51
|
+
"./secrets": {
|
|
52
|
+
"types": "./dist/v8/secrets.d.ts",
|
|
53
|
+
"source": "./src/v8/secrets.ts",
|
|
54
|
+
"default": "./dist/v8/secrets.js"
|
|
55
|
+
},
|
|
56
|
+
"./protocol": {
|
|
57
|
+
"types": "./dist/protocol/index.d.ts",
|
|
58
|
+
"source": "./src/protocol/index.ts",
|
|
59
|
+
"default": "./dist/protocol/index.js"
|
|
60
|
+
},
|
|
61
|
+
"./protocol/keys": {
|
|
62
|
+
"types": "./dist/protocol/keys.d.ts",
|
|
63
|
+
"source": "./src/protocol/keys.ts",
|
|
64
|
+
"default": "./dist/protocol/keys.js"
|
|
65
|
+
},
|
|
66
|
+
"./protocol/server": {
|
|
67
|
+
"types": "./dist/protocol/server/index.d.ts",
|
|
68
|
+
"source": "./src/protocol/server/index.ts",
|
|
69
|
+
"default": "./dist/protocol/server/index.js"
|
|
70
|
+
},
|
|
37
71
|
"./protocol/storage/fs": {
|
|
38
|
-
"node":
|
|
39
|
-
|
|
72
|
+
"node": {
|
|
73
|
+
"types": "./dist/protocol/storage/fs/index.d.ts",
|
|
74
|
+
"source": "./src/protocol/storage/fs/index.ts",
|
|
75
|
+
"default": "./dist/protocol/storage/fs/index.js"
|
|
76
|
+
},
|
|
77
|
+
"default": {
|
|
78
|
+
"types": "./dist/protocol/storage/fs/unsupported.d.ts",
|
|
79
|
+
"source": "./src/protocol/storage/fs/unsupported.ts",
|
|
80
|
+
"default": "./dist/protocol/storage/fs/unsupported.js"
|
|
81
|
+
}
|
|
40
82
|
},
|
|
41
|
-
"./protocol/conformance":
|
|
83
|
+
"./protocol/conformance": {
|
|
84
|
+
"types": "./dist/protocol/conformance/index.d.ts",
|
|
85
|
+
"source": "./src/protocol/conformance/index.ts",
|
|
86
|
+
"default": "./dist/protocol/conformance/index.js"
|
|
87
|
+
}
|
|
42
88
|
},
|
|
43
89
|
"scripts": {
|
|
44
|
-
"build": "tsc",
|
|
90
|
+
"build": "node ../../scripts/tsc.mjs --clean dist -p tsconfig.build.json",
|
|
91
|
+
"prepack": "npm run build",
|
|
45
92
|
"test": "vitest run --root ../.. packages/blocks/",
|
|
46
|
-
"typecheck": "tsc
|
|
93
|
+
"typecheck": "node ../../scripts/tsc.mjs -p tsconfig.json"
|
|
47
94
|
},
|
|
48
95
|
"dependencies": {
|
|
49
96
|
"ajv": "^8.20.0",
|
|
50
|
-
"tsx": "^4.22.5",
|
|
51
97
|
"zod": "^4.4.3"
|
|
52
98
|
},
|
|
53
99
|
"peerDependencies": {
|
|
@@ -55,11 +101,11 @@
|
|
|
55
101
|
"typescript": "^5.0.0"
|
|
56
102
|
},
|
|
57
103
|
"devDependencies": {
|
|
104
|
+
"@opentelemetry/api": "^1.9.1",
|
|
58
105
|
"@types/react": "^19.0.0",
|
|
59
106
|
"@types/react-dom": "^19.0.0",
|
|
60
107
|
"esbuild": "^0.27.3",
|
|
61
|
-
"react-dom": "^19.0.0"
|
|
62
|
-
"typescript": "^5.9.0"
|
|
108
|
+
"react-dom": "^19.0.0"
|
|
63
109
|
},
|
|
64
110
|
"publishConfig": {
|
|
65
111
|
"registry": "https://registry.npmjs.org",
|
package/src/index.ts
CHANGED
package/src/protocol/client.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* A small content-protocol client: one method per protocol method, plus
|
|
3
3
|
* batches. Uses `fetch`, so it runs in browsers, on Workers and on Node.
|
|
4
4
|
*/
|
|
5
|
-
import { ContentProtocolError, ErrorCode, type RpcErrorObject } from "./errors";
|
|
5
|
+
import { ContentProtocolError, ErrorCode, type RpcErrorObject } from "./errors.ts";
|
|
6
6
|
import {
|
|
7
7
|
type DescribeResult,
|
|
8
8
|
type MethodName,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
PROTOCOL_NAME,
|
|
11
11
|
PROTOCOL_VERSION,
|
|
12
12
|
type RpcId,
|
|
13
|
-
} from "./types";
|
|
13
|
+
} from "./types.ts";
|
|
14
14
|
|
|
15
15
|
export interface ContentClientOptions {
|
|
16
16
|
/** The endpoint URL, such as `http://127.0.0.1:4545/rpc`. */
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Uploads beside the protocol: `PUT /assets/<name>`. These cases run only
|
|
3
3
|
* when the harness passes `assetsEndpoint`.
|
|
4
4
|
*/
|
|
5
|
-
import { ErrorCode } from "../../errors";
|
|
6
|
-
import { assert, assertEqual, type ConformanceContext, rawErrorCode } from "../context";
|
|
7
|
-
import type { ConformanceCase } from "./types";
|
|
5
|
+
import { ErrorCode } from "../../errors.ts";
|
|
6
|
+
import { assert, assertEqual, type ConformanceContext, rawErrorCode } from "../context.ts";
|
|
7
|
+
import type { ConformanceCase } from "./types.ts";
|
|
8
8
|
|
|
9
9
|
/** The smallest PNG header: enough bytes for an upload, never executed. */
|
|
10
10
|
const PNG = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Limits, the secret guard and request-key idempotency.
|
|
3
3
|
*/
|
|
4
|
-
import { encryptToCiphertext, publicKeyPemFromDer } from "../../ciphertext";
|
|
5
|
-
import { ErrorCode, type InvalidBlockData } from "../../errors";
|
|
4
|
+
import { encryptToCiphertext, publicKeyPemFromDer } from "../../ciphertext.ts";
|
|
5
|
+
import { ErrorCode, type InvalidBlockData } from "../../errors.ts";
|
|
6
6
|
import {
|
|
7
7
|
assert,
|
|
8
8
|
assertEqual,
|
|
9
9
|
type ConformanceContext,
|
|
10
10
|
expectError,
|
|
11
11
|
rawErrorCode,
|
|
12
|
-
} from "../context";
|
|
13
|
-
import type { ConformanceCase } from "./types";
|
|
12
|
+
} from "../context.ts";
|
|
13
|
+
import type { ConformanceCase } from "./types.ts";
|
|
14
14
|
|
|
15
15
|
async function writable(ctx: ConformanceContext) {
|
|
16
16
|
const d = await ctx.describe();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `describe`, `schema.get` and `blocks.list`, including conditional reads.
|
|
3
3
|
*/
|
|
4
|
-
import { ErrorCode } from "../../errors";
|
|
5
|
-
import { PROTOCOL_NAME, SCHEMA_FORMAT } from "../../types";
|
|
6
|
-
import { assert, assertEqual, expectError } from "../context";
|
|
7
|
-
import type { ConformanceCase } from "./types";
|
|
4
|
+
import { ErrorCode } from "../../errors.ts";
|
|
5
|
+
import { PROTOCOL_NAME, SCHEMA_FORMAT } from "../../types.ts";
|
|
6
|
+
import { assert, assertEqual, expectError } from "../context.ts";
|
|
7
|
+
import type { ConformanceCase } from "./types.ts";
|
|
8
8
|
|
|
9
9
|
const LIMIT_KEYS = [
|
|
10
10
|
"maxOpsPerApply",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The wire format: JSON-RPC 2.0 envelopes, batches, HTTP status codes, gzip.
|
|
3
3
|
*/
|
|
4
|
-
import { ErrorCode } from "../../errors";
|
|
5
|
-
import { MAX_BATCH_CALLS } from "../../types";
|
|
6
|
-
import { assert, assertEqual, rawErrorCode } from "../context";
|
|
7
|
-
import type { ConformanceCase } from "./types";
|
|
4
|
+
import { ErrorCode } from "../../errors.ts";
|
|
5
|
+
import { MAX_BATCH_CALLS } from "../../types.ts";
|
|
6
|
+
import { assert, assertEqual, rawErrorCode } from "../context.ts";
|
|
7
|
+
import type { ConformanceCase } from "./types.ts";
|
|
8
8
|
|
|
9
9
|
const req = (id: unknown, method: string, params?: unknown) =>
|
|
10
10
|
params === undefined ? { jsonrpc: "2.0", id, method } : { jsonrpc: "2.0", id, method, params };
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* `blocks.apply`: atomic set and delete, set precedence, validation, the
|
|
3
3
|
* file-name rule and preconditions.
|
|
4
4
|
*/
|
|
5
|
-
import { ErrorCode, type InvalidBlockData } from "../../errors";
|
|
6
|
-
import type { BlocksListResult } from "../../types";
|
|
7
|
-
import { assert, assertEqual, type ConformanceContext, expectError } from "../context";
|
|
8
|
-
import type { ConformanceCase } from "./types";
|
|
5
|
+
import { ErrorCode, type InvalidBlockData } from "../../errors.ts";
|
|
6
|
+
import type { BlocksListResult } from "../../types.ts";
|
|
7
|
+
import { assert, assertEqual, type ConformanceContext, expectError } from "../context.ts";
|
|
8
|
+
import type { ConformanceCase } from "./types.ts";
|
|
9
9
|
|
|
10
10
|
type FullList = Extract<BlocksListResult, { notModified: false }>;
|
|
11
11
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* What every conformance case gets: a client, raw HTTP access, the endpoint's
|
|
3
3
|
* `describe`, unique names and assertion helpers.
|
|
4
4
|
*/
|
|
5
|
-
import { canonicalJson } from "../canonical";
|
|
6
|
-
import { type ContentClient, createContentClient, readResponseJson } from "../client";
|
|
7
|
-
import { ContentProtocolError } from "../errors";
|
|
8
|
-
import type { DescribeResult } from "../types";
|
|
5
|
+
import { canonicalJson } from "../canonical.ts";
|
|
6
|
+
import { type ContentClient, createContentClient, readResponseJson } from "../client.ts";
|
|
7
|
+
import { ContentProtocolError } from "../errors.ts";
|
|
8
|
+
import type { DescribeResult } from "../types.ts";
|
|
9
9
|
|
|
10
10
|
export interface ConformanceOptions {
|
|
11
11
|
/** The endpoint URL, such as `http://127.0.0.1:4545/rpc`. */
|
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
* don't apply to an endpoint (a read-only one, one without request keys)
|
|
20
20
|
* skip themselves. Browser-safe: it only needs `fetch`.
|
|
21
21
|
*/
|
|
22
|
-
import { assetCases } from "./cases/assets";
|
|
23
|
-
import { guardCases } from "./cases/guards";
|
|
24
|
-
import { readCases } from "./cases/reads";
|
|
25
|
-
import type { ConformanceCase } from "./cases/types";
|
|
26
|
-
import { wireCases } from "./cases/wire";
|
|
27
|
-
import { writeCases } from "./cases/writes";
|
|
28
|
-
import { ConformanceContext, type ConformanceOptions, SkipCase } from "./context";
|
|
22
|
+
import { assetCases } from "./cases/assets.ts";
|
|
23
|
+
import { guardCases } from "./cases/guards.ts";
|
|
24
|
+
import { readCases } from "./cases/reads.ts";
|
|
25
|
+
import type { ConformanceCase } from "./cases/types.ts";
|
|
26
|
+
import { wireCases } from "./cases/wire.ts";
|
|
27
|
+
import { writeCases } from "./cases/writes.ts";
|
|
28
|
+
import { ConformanceContext, type ConformanceOptions, SkipCase } from "./context.ts";
|
|
29
29
|
|
|
30
|
-
export type { ConformanceCase } from "./cases/types";
|
|
31
|
-
export { type ContentHashFixture, contentHashFixtures } from "./contentHashFixtures";
|
|
32
|
-
export type { ConformanceOptions } from "./context";
|
|
30
|
+
export type { ConformanceCase } from "./cases/types.ts";
|
|
31
|
+
export { type ContentHashFixture, contentHashFixtures } from "./contentHashFixtures.ts";
|
|
32
|
+
export type { ConformanceOptions } from "./context.ts";
|
|
33
33
|
|
|
34
34
|
/** Every conformance case, in the order they run. */
|
|
35
35
|
export const conformanceCases: readonly ConformanceCase[] = [
|
package/src/protocol/index.ts
CHANGED
|
@@ -24,7 +24,7 @@ export {
|
|
|
24
24
|
canonicalJson,
|
|
25
25
|
computeContentRevision,
|
|
26
26
|
sha256Hex,
|
|
27
|
-
} from "./canonical";
|
|
27
|
+
} from "./canonical.ts";
|
|
28
28
|
export {
|
|
29
29
|
assertSupportedEndpoint,
|
|
30
30
|
type BatchCall,
|
|
@@ -32,8 +32,8 @@ export {
|
|
|
32
32
|
type ContentClient,
|
|
33
33
|
type ContentClientOptions,
|
|
34
34
|
createContentClient,
|
|
35
|
-
} from "./client";
|
|
36
|
-
export * from "./errors";
|
|
37
|
-
export * from "./keys";
|
|
38
|
-
export * from "./storage";
|
|
39
|
-
export * from "./types";
|
|
35
|
+
} from "./client.ts";
|
|
36
|
+
export * from "./errors.ts";
|
|
37
|
+
export * from "./keys.ts";
|
|
38
|
+
export * from "./storage.ts";
|
|
39
|
+
export * from "./types.ts";
|
package/src/protocol/params.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* parsed copy of a record would turn an own `__proto__` key into a prototype.
|
|
8
8
|
*/
|
|
9
9
|
import { z } from "zod";
|
|
10
|
-
import { invalidParams } from "./errors";
|
|
11
|
-
import type { BlocksApplyParams, MethodName, ReadParams } from "./types";
|
|
10
|
+
import { invalidParams } from "./errors.ts";
|
|
11
|
+
import type { BlocksApplyParams, MethodName, ReadParams } from "./types.ts";
|
|
12
12
|
|
|
13
13
|
const opaque = z.string().min(1).max(1024);
|
|
14
14
|
|
package/src/protocol/secrets.ts
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* The schema marks a `Secret` field with `"format": "secret"` — the contract
|
|
12
12
|
* `deco schema` emits for the `Secret` type. Browser-safe.
|
|
13
13
|
*/
|
|
14
|
-
import { parseCiphertext } from "./ciphertext";
|
|
15
|
-
import type { BlockViolation } from "./errors";
|
|
16
|
-
import type { DecoMeta } from "./types";
|
|
14
|
+
import { parseCiphertext } from "./ciphertext.ts";
|
|
15
|
+
import type { BlockViolation } from "./errors.ts";
|
|
16
|
+
import type { DecoMeta } from "./types.ts";
|
|
17
17
|
|
|
18
18
|
/** The built-in block type that holds an encrypted value. */
|
|
19
19
|
export const SECRET_BLOCK_TYPE = "secret";
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
assetNameForType,
|
|
18
18
|
isAcceptedAssetType,
|
|
19
19
|
sanitizeAssetName,
|
|
20
|
-
} from "../assets";
|
|
20
|
+
} from "../assets.ts";
|
|
21
21
|
import {
|
|
22
22
|
type ContentProtocolError,
|
|
23
23
|
ErrorCode,
|
|
@@ -27,11 +27,11 @@ import {
|
|
|
27
27
|
readOnly,
|
|
28
28
|
unauthorized,
|
|
29
29
|
unsupported,
|
|
30
|
-
} from "../errors";
|
|
31
|
-
import type { ContentStorage } from "../storage";
|
|
32
|
-
import { ASSETS_URL_PREFIX } from "../types";
|
|
33
|
-
import { type AuthOptions, assertAuthOptions, authenticate } from "./auth";
|
|
34
|
-
import { BodyEncodingError, BodyTooLargeError, jsonResponse, readBody } from "./http";
|
|
30
|
+
} from "../errors.ts";
|
|
31
|
+
import type { ContentStorage } from "../storage.ts";
|
|
32
|
+
import { ASSETS_URL_PREFIX } from "../types.ts";
|
|
33
|
+
import { type AuthOptions, assertAuthOptions, authenticate } from "./auth.ts";
|
|
34
|
+
import { BodyEncodingError, BodyTooLargeError, jsonResponse, readBody } from "./http.ts";
|
|
35
35
|
|
|
36
36
|
const STATUS: Record<number, number> = {
|
|
37
37
|
[ErrorCode.Unauthorized]: 401,
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Shared by `blocks.list` (which needs every body) and `blocks.apply` (which
|
|
5
5
|
* needs bodies only to break ties between spellings).
|
|
6
6
|
*/
|
|
7
|
-
import { limitExceeded, unavailable } from "../errors";
|
|
8
|
-
import { entryHasPath, fullyDecodeFileName, isBlockFileName, resolveSpellings } from "../keys";
|
|
9
|
-
import type { ContentStorage, StorageFile, StorageSnapshot } from "../storage";
|
|
10
|
-
import type { Diagnostic, Limits } from "../types";
|
|
11
|
-
import { type BodyCache, type ParsedBody, parseBody } from "./bodyCache";
|
|
7
|
+
import { limitExceeded, unavailable } from "../errors.ts";
|
|
8
|
+
import { entryHasPath, fullyDecodeFileName, isBlockFileName, resolveSpellings } from "../keys.ts";
|
|
9
|
+
import type { ContentStorage, StorageFile, StorageSnapshot } from "../storage.ts";
|
|
10
|
+
import type { Diagnostic, Limits } from "../types.ts";
|
|
11
|
+
import { type BodyCache, type ParsedBody, parseBody } from "./bodyCache.ts";
|
|
12
12
|
|
|
13
13
|
export interface LoadedEntry {
|
|
14
14
|
file: string;
|