@decocms/blocks 8.7.0 → 8.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/protocol/conformance/cases/changes.d.ts.map +1 -1
- package/dist/protocol/conformance/cases/changes.js +14 -3
- package/dist/protocol/conformance/cases/changes.js.map +1 -1
- package/dist/protocol/conformance/cases/guards.d.ts.map +1 -1
- package/dist/protocol/conformance/cases/guards.js +19 -42
- package/dist/protocol/conformance/cases/guards.js.map +1 -1
- package/dist/protocol/conformance/cases/overlay.d.ts +3 -0
- package/dist/protocol/conformance/cases/overlay.d.ts.map +1 -0
- package/dist/protocol/conformance/cases/overlay.js +164 -0
- package/dist/protocol/conformance/cases/overlay.js.map +1 -0
- package/dist/protocol/conformance/cases/reads.js +5 -5
- package/dist/protocol/conformance/cases/reads.js.map +1 -1
- package/dist/protocol/conformance/cases/writes.d.ts.map +1 -1
- package/dist/protocol/conformance/cases/writes.js +15 -3
- package/dist/protocol/conformance/cases/writes.js.map +1 -1
- package/dist/protocol/conformance/context.d.ts +0 -10
- package/dist/protocol/conformance/context.d.ts.map +1 -1
- package/dist/protocol/conformance/context.js.map +1 -1
- package/dist/protocol/conformance/index.d.ts.map +1 -1
- package/dist/protocol/conformance/index.js +2 -0
- package/dist/protocol/conformance/index.js.map +1 -1
- package/dist/protocol/server/content.d.ts +8 -1
- package/dist/protocol/server/content.d.ts.map +1 -1
- package/dist/protocol/server/content.js +18 -3
- package/dist/protocol/server/content.js.map +1 -1
- package/dist/protocol/server/core.d.ts +0 -6
- package/dist/protocol/server/core.d.ts.map +1 -1
- package/dist/protocol/server/core.js +0 -2
- package/dist/protocol/server/core.js.map +1 -1
- package/dist/protocol/server/methods/apply.d.ts +16 -5
- package/dist/protocol/server/methods/apply.d.ts.map +1 -1
- package/dist/protocol/server/methods/apply.js +42 -38
- package/dist/protocol/server/methods/apply.js.map +1 -1
- package/dist/protocol/server/methods/changes.d.ts.map +1 -1
- package/dist/protocol/server/methods/changes.js +31 -3
- package/dist/protocol/server/methods/changes.js.map +1 -1
- package/dist/protocol/server/methods/read.d.ts.map +1 -1
- package/dist/protocol/server/methods/read.js +2 -23
- package/dist/protocol/server/methods/read.js.map +1 -1
- package/dist/protocol/storage/fs/index.d.ts.map +1 -1
- package/dist/protocol/storage/fs/index.js +0 -18
- package/dist/protocol/storage/fs/index.js.map +1 -1
- package/dist/protocol/storage/memory.d.ts +11 -3
- package/dist/protocol/storage/memory.d.ts.map +1 -1
- package/dist/protocol/storage/memory.js +114 -45
- package/dist/protocol/storage/memory.js.map +1 -1
- package/dist/protocol/storage.d.ts +68 -18
- package/dist/protocol/storage.d.ts.map +1 -1
- package/dist/protocol/storage.js +7 -0
- package/dist/protocol/storage.js.map +1 -1
- package/dist/protocol/types.d.ts +51 -8
- package/dist/protocol/types.d.ts.map +1 -1
- package/dist/protocol/types.js +5 -3
- package/dist/protocol/types.js.map +1 -1
- package/dist/v8/builtins/index.d.ts +1 -4
- package/dist/v8/builtins/index.d.ts.map +1 -1
- package/dist/v8/builtins/index.js +1 -6
- package/dist/v8/builtins/index.js.map +1 -1
- package/dist/v8/builtins/legacy.d.ts +4 -4
- package/dist/v8/builtins/legacy.d.ts.map +1 -1
- package/dist/v8/builtins/legacy.js +4 -5
- package/dist/v8/builtins/legacy.js.map +1 -1
- package/dist/v8/cli/builtins.d.ts.map +1 -1
- package/dist/v8/cli/builtins.js +0 -1
- package/dist/v8/cli/builtins.js.map +1 -1
- package/dist/v8/cli/check/index.d.ts +1 -1
- package/dist/v8/cli/check/index.d.ts.map +1 -1
- package/dist/v8/cli/check/index.js +13 -33
- package/dist/v8/cli/check/index.js.map +1 -1
- package/dist/v8/cli/schema/builtinSchemas.d.ts.map +1 -1
- package/dist/v8/cli/schema/builtinSchemas.js +0 -8
- package/dist/v8/cli/schema/builtinSchemas.js.map +1 -1
- package/dist/v8/cli/schema/generate.d.ts.map +1 -1
- package/dist/v8/cli/schema/generate.js +1 -8
- package/dist/v8/cli/schema/generate.js.map +1 -1
- package/dist/v8/cli/schema/typeToSchema.d.ts +0 -1
- package/dist/v8/cli/schema/typeToSchema.d.ts.map +1 -1
- package/dist/v8/cli/schema/typeToSchema.js +5 -30
- package/dist/v8/cli/schema/typeToSchema.js.map +1 -1
- package/dist/v8/client.d.ts +1 -1
- package/dist/v8/client.d.ts.map +1 -1
- package/dist/v8/cms.d.ts.map +1 -1
- package/dist/v8/cms.js +5 -13
- package/dist/v8/cms.js.map +1 -1
- package/dist/v8/index.d.ts +1 -1
- package/dist/v8/index.d.ts.map +1 -1
- package/dist/v8/resolver.d.ts +1 -1
- package/dist/v8/resolver.d.ts.map +1 -1
- package/dist/v8/telemetry.d.ts +0 -2
- package/dist/v8/telemetry.d.ts.map +1 -1
- package/dist/v8/telemetry.js +5 -20
- package/dist/v8/telemetry.js.map +1 -1
- package/dist/v8/types.d.ts +0 -8
- package/dist/v8/types.d.ts.map +1 -1
- package/package.json +1 -6
- package/src/index.ts +1 -2
- package/src/protocol/conformance/cases/changes.ts +16 -4
- package/src/protocol/conformance/cases/guards.ts +19 -55
- package/src/protocol/conformance/cases/overlay.ts +195 -0
- package/src/protocol/conformance/cases/reads.ts +4 -4
- package/src/protocol/conformance/cases/writes.ts +15 -3
- package/src/protocol/conformance/context.ts +0 -7
- package/src/protocol/conformance/index.ts +2 -0
- package/src/protocol/server/content.ts +30 -4
- package/src/protocol/server/core.ts +0 -3
- package/src/protocol/server/methods/apply.ts +43 -38
- package/src/protocol/server/methods/changes.ts +42 -4
- package/src/protocol/server/methods/read.ts +2 -24
- package/src/protocol/storage/fs/index.ts +0 -18
- package/src/protocol/storage/memory.ts +124 -46
- package/src/protocol/storage.ts +69 -18
- package/src/protocol/types.ts +51 -8
- package/src/v8/builtins/index.ts +1 -6
- package/src/v8/builtins/legacy.ts +4 -5
- package/src/v8/cli/builtins.ts +0 -1
- package/src/v8/cli/check/index.ts +15 -34
- package/src/v8/cli/schema/builtinSchemas.ts +0 -8
- package/src/v8/cli/schema/generate.ts +1 -8
- package/src/v8/cli/schema/typeToSchema.ts +5 -31
- package/src/v8/client.ts +1 -1
- package/src/v8/cms.ts +5 -14
- package/src/v8/index.ts +0 -1
- package/src/v8/resolver.ts +1 -1
- package/src/v8/telemetry.ts +5 -20
- package/src/v8/types.ts +0 -5
- package/dist/protocol/ciphertext.d.ts +0 -7
- package/dist/protocol/ciphertext.d.ts.map +0 -1
- package/dist/protocol/ciphertext.js +0 -7
- package/dist/protocol/ciphertext.js.map +0 -1
- package/dist/protocol/secrets.d.ts +0 -22
- package/dist/protocol/secrets.d.ts.map +0 -1
- package/dist/protocol/secrets.js +0 -207
- package/dist/protocol/secrets.js.map +0 -1
- package/dist/v8/builtins/secret.d.ts +0 -7
- package/dist/v8/builtins/secret.d.ts.map +0 -1
- package/dist/v8/builtins/secret.js +0 -68
- package/dist/v8/builtins/secret.js.map +0 -1
- package/dist/v8/ciphertext.d.ts +0 -58
- package/dist/v8/ciphertext.d.ts.map +0 -1
- package/dist/v8/ciphertext.js +0 -134
- package/dist/v8/ciphertext.js.map +0 -1
- package/dist/v8/secrets.d.ts +0 -9
- package/dist/v8/secrets.d.ts.map +0 -1
- package/dist/v8/secrets.js +0 -14
- package/dist/v8/secrets.js.map +0 -1
- package/src/protocol/ciphertext.ts +0 -6
- package/src/protocol/secrets.ts +0 -239
- package/src/v8/builtins/secret.ts +0 -82
- package/src/v8/ciphertext.ts +0 -158
- package/src/v8/secrets.ts +0 -17
package/src/protocol/storage.ts
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
* base (what `changes.*` compares the content with: the files that differ
|
|
7
7
|
* from it, and reading base bodies).
|
|
8
8
|
* The protocol core (`createContentHandler`) owns everything else: the
|
|
9
|
-
* JSON-RPC layer, validation, the file-name rule,
|
|
10
|
-
* retries. Storages deal in *files* inside `<root>/.deco/blocks`; entry names
|
|
9
|
+
* JSON-RPC layer, validation, the file-name rule, limits and retries. Storages deal in *files* inside `<root>/.deco/blocks`; entry names
|
|
11
10
|
* are the core's business.
|
|
12
11
|
*
|
|
13
12
|
* Browser-safe: types and small error classes only.
|
|
@@ -34,8 +33,22 @@ export interface StorageFile {
|
|
|
34
33
|
version: string;
|
|
35
34
|
/** The file's size in bytes, when the storage knows it without reading the body. */
|
|
36
35
|
size?: number;
|
|
36
|
+
/**
|
|
37
|
+
* `true` for a tombstone: a deletion an overlay storage records over its
|
|
38
|
+
* base, listed only by `writeSnapshot()`. It has no body, and its
|
|
39
|
+
* `version` is the tombstone's (see `TOMBSTONE_VERSION`).
|
|
40
|
+
*/
|
|
41
|
+
deleted?: true;
|
|
37
42
|
}
|
|
38
43
|
|
|
44
|
+
/**
|
|
45
|
+
* The version an overlay storage reports for a deletion it records (a
|
|
46
|
+
* tombstone), in `writeSnapshot()`, `changes()` and a commit's result. Any
|
|
47
|
+
* value no file content has works; the reference storage uses this one, and
|
|
48
|
+
* a storage that shares clients with it should too.
|
|
49
|
+
*/
|
|
50
|
+
export const TOMBSTONE_VERSION = "tombstone";
|
|
51
|
+
|
|
39
52
|
/** Every saved-block file at one point in time. */
|
|
40
53
|
export interface StorageSnapshot {
|
|
41
54
|
/** An opaque revision of the whole set, compared only for equality. */
|
|
@@ -67,25 +80,32 @@ export interface StoredSchema {
|
|
|
67
80
|
|
|
68
81
|
/** One atomic commit attempt. */
|
|
69
82
|
export interface CommitAttempt {
|
|
70
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* The snapshot the core validated against: `writeSnapshot()`'s for an
|
|
85
|
+
* overlay storage (`blocks.apply`), `snapshot()`'s otherwise.
|
|
86
|
+
*/
|
|
71
87
|
base: StorageSnapshot;
|
|
72
88
|
/** Files to write, by file name, with their full content. */
|
|
73
89
|
put: Record<string, string>;
|
|
74
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* Files to delete. A file that's already gone is fine. For an overlay
|
|
92
|
+
* storage, `blocks.apply` also names files the overlay doesn't hold: the
|
|
93
|
+
* storage records the deletion over its base (a file only the base has
|
|
94
|
+
* must disappear from `snapshot()`, and `writeSnapshot()` lists it as a
|
|
95
|
+
* tombstone). One neither side has it may drop, or record as a tombstone
|
|
96
|
+
* too (a storage whose write never reads the base can't tell them apart);
|
|
97
|
+
* the core treats such a tombstone like any other.
|
|
98
|
+
*/
|
|
75
99
|
delete: string[];
|
|
76
100
|
/**
|
|
77
101
|
* Versions the files must still have for the commit to land (`null` = must
|
|
78
|
-
* not exist)
|
|
79
|
-
*
|
|
102
|
+
* not exist), in the snapshot `base` came from (the overlay, for an overlay
|
|
103
|
+
* storage's `blocks.apply`, where a tombstone has its tombstone version
|
|
104
|
+
* and so is not `null`). A storage MUST reject the attempt as stale
|
|
105
|
+
* when any of them changed, and MAY reject it when anything else changed
|
|
106
|
+
* since `base`.
|
|
80
107
|
*/
|
|
81
108
|
expected: Record<string, string | null>;
|
|
82
|
-
/**
|
|
83
|
-
* The schema version the core validated against (`null` = no schema), when
|
|
84
|
-
* the write depends on it (the secret guard checks `set` against it). When set,
|
|
85
|
-
* a storage MUST reject the attempt as stale if the schema's version at
|
|
86
|
-
* commit time differs, checked atomically with `expected`.
|
|
87
|
-
*/
|
|
88
|
-
expectedSchemaVersion?: string | null;
|
|
89
109
|
/**
|
|
90
110
|
* The base revision (`StorageBase.revision`) the core computed the write
|
|
91
111
|
* from, when the write depends on it (`changes.discard` restores base
|
|
@@ -96,7 +116,9 @@ export interface CommitAttempt {
|
|
|
96
116
|
/**
|
|
97
117
|
* Why the core commits: `apply` (default) or `discard`. For logs, and a
|
|
98
118
|
* storage with a staging area (the fs storage's git index) also unstages
|
|
99
|
-
* the files a `discard` writes or deletes, in the same commit.
|
|
119
|
+
* the files a `discard` writes or deletes, in the same commit. An overlay
|
|
120
|
+
* storage applies a `discard` by dropping those files from the overlay, so
|
|
121
|
+
* the base shows through (`put` holds the base's own bytes).
|
|
100
122
|
*/
|
|
101
123
|
reason?: "apply" | "discard";
|
|
102
124
|
}
|
|
@@ -116,9 +138,18 @@ export interface StorageChanges {
|
|
|
116
138
|
* in the base, in the base and not in the snapshot, or in both with
|
|
117
139
|
* different content. A file whose content equals the base's (the storage
|
|
118
140
|
* decides equality, such as honouring git's eol conversion) MUST NOT be
|
|
119
|
-
* listed, so a file a discard just restored is never listed again.
|
|
141
|
+
* listed, so a file a discard just restored is never listed again. An
|
|
142
|
+
* overlay storage instead lists exactly the files its overlay holds, and
|
|
143
|
+
* the deletions it records of files the base has, even a file equal to the
|
|
144
|
+
* base's: the overlay's own entries are the changes.
|
|
120
145
|
*/
|
|
121
146
|
files: string[];
|
|
147
|
+
/**
|
|
148
|
+
* An overlay storage: the tombstones among `files` (the deletions it
|
|
149
|
+
* records), with the versions `writeSnapshot()` lists them with, which
|
|
150
|
+
* `changes.list` reports as the deletions' versions. Absent otherwise.
|
|
151
|
+
*/
|
|
152
|
+
tombstones?: StorageFile[];
|
|
122
153
|
/**
|
|
123
154
|
* The base's files, with their versions in the base: at least every file
|
|
124
155
|
* whose spelling group (`spellingKey`) a file in `files` belongs to; more
|
|
@@ -130,8 +161,13 @@ export interface StorageChanges {
|
|
|
130
161
|
export type CommitResult =
|
|
131
162
|
| {
|
|
132
163
|
status: "committed";
|
|
164
|
+
/** The revision `snapshot()` reports right after the commit (`blocks.list`'s). */
|
|
133
165
|
revision: string;
|
|
134
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* The new version of every file in `put`, and for an overlay storage
|
|
168
|
+
* the tombstone version of every file in `delete` it recorded as a
|
|
169
|
+
* tombstone (not one it dropped because neither side has it).
|
|
170
|
+
*/
|
|
135
171
|
versions: Record<string, string>;
|
|
136
172
|
}
|
|
137
173
|
| { status: "stale" };
|
|
@@ -152,8 +188,23 @@ export interface ContentStorage {
|
|
|
152
188
|
readFiles(snapshot: StorageSnapshot, files: string[]): Promise<Record<string, StoredFileBody>>;
|
|
153
189
|
/** Reads `schema.gen.json`, falling back to `meta.gen.json`; `null` when neither exists. */
|
|
154
190
|
readSchema(): Promise<StoredSchema | null>;
|
|
155
|
-
/**
|
|
156
|
-
|
|
191
|
+
/**
|
|
192
|
+
* An overlay storage's own files: what it holds over its base (a hosted
|
|
193
|
+
* draft's blocks over the published branch), read without reading the
|
|
194
|
+
* base. Its presence makes the endpoint an overlay (`describe.overlay`):
|
|
195
|
+
* `blocks.apply` validates and checks `ifMatch` against this snapshot
|
|
196
|
+
* instead of `snapshot()`, and commits with it as `base`; `readFiles`
|
|
197
|
+
* reads its files too. A deletion the overlay records is listed as a
|
|
198
|
+
* tombstone (`deleted: true`, with its tombstone version): for a guard the
|
|
199
|
+
* overlay holds it, so `ifMatch: null` on it fails and its tombstone
|
|
200
|
+
* version passes. The
|
|
201
|
+
* revision `snapshot()` reports must move whenever the overlay does, even
|
|
202
|
+
* when the content it shows doesn't (an entry saved with the base's
|
|
203
|
+
* value). Absent
|
|
204
|
+
* for a storage that writes its content directly (a working tree, a
|
|
205
|
+
* branch).
|
|
206
|
+
*/
|
|
207
|
+
writeSnapshot?(): Promise<StorageSnapshot>;
|
|
157
208
|
/** One all-or-nothing commit attempt; durable when it resolves. */
|
|
158
209
|
commit(attempt: CommitAttempt): Promise<CommitResult>;
|
|
159
210
|
/**
|
package/src/protocol/types.ts
CHANGED
|
@@ -8,10 +8,12 @@ export const PROTOCOL_NAME = "deco-content";
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Minors only add. A client refuses another major, and a server older than
|
|
11
|
-
* `REQUIRED_PROTOCOL_MINOR
|
|
12
|
-
*
|
|
11
|
+
* `REQUIRED_PROTOCOL_MINOR`. 1.0 is `@decocms/blocks` 8.1.x and older; 1.1
|
|
12
|
+
* added `changes.*`; 1.2 added overlay endpoints (`describe.overlay`), and
|
|
13
|
+
* `blocks.apply` no longer reads the schema (`describe.secrets` is always
|
|
14
|
+
* `null`: secrets live in the deploy platform, not in content).
|
|
13
15
|
*/
|
|
14
|
-
export const PROTOCOL_VERSION = { major: 1, minor:
|
|
16
|
+
export const PROTOCOL_VERSION = { major: 1, minor: 2 } as const;
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* The oldest minor this package's client talks to. Bump it only when the
|
|
@@ -62,8 +64,24 @@ export interface DescribeResult {
|
|
|
62
64
|
preview: null | { url: string };
|
|
63
65
|
/** Dir relative to the repository root; `null` when read-only or uploads go to hosted storage. */
|
|
64
66
|
assets: null | { dir: string; urlPrefix: typeof ASSETS_URL_PREFIX; maxBytes: number };
|
|
65
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Always `null` from protocol 1.2 on: content holds no secrets (they live
|
|
69
|
+
* in the deploy platform, and the site's code passes them as params). A
|
|
70
|
+
* 1.0 or 1.1 server reported `<root>/.deco/secrets.pub` here.
|
|
71
|
+
*/
|
|
66
72
|
secrets: null | { publicKey: string };
|
|
73
|
+
/**
|
|
74
|
+
* `true` when the endpoint writes to an overlay over its base, such as a
|
|
75
|
+
* hosted draft over the published branch (protocol 1.2). Then
|
|
76
|
+
* `blocks.apply`'s `ifMatch` compares with the overlay alone: an entry the
|
|
77
|
+
* overlay doesn't hold is `null`, whatever the base has, and an entry it
|
|
78
|
+
* holds has the `version` `changes.list` reports for it. A deletion the
|
|
79
|
+
* overlay records is held too: `changes.list` reports it as a `delete`
|
|
80
|
+
* with its tombstone version, which `ifMatch` must name (`null` fails).
|
|
81
|
+
* `changes.list` lists every entry the overlay holds, even one equal to the
|
|
82
|
+
* base. Absent: `ifMatch` compares with the content `blocks.list` reports.
|
|
83
|
+
*/
|
|
84
|
+
overlay?: true;
|
|
67
85
|
}
|
|
68
86
|
|
|
69
87
|
/** The schema file, in the site editor's `deco-meta@1` format. */
|
|
@@ -125,12 +143,24 @@ export interface BlocksApplyParams {
|
|
|
125
143
|
set?: Record<string, Record<string, unknown>>;
|
|
126
144
|
/** A missing name counts as deleted. */
|
|
127
145
|
delete?: string[];
|
|
128
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* A version the entry must have; `null` = must not exist. On an overlay
|
|
148
|
+
* endpoint (`describe.overlay`), the version it has in the overlay (for a
|
|
149
|
+
* deletion the overlay records, its tombstone version); `null` = the
|
|
150
|
+
* overlay doesn't hold it.
|
|
151
|
+
*/
|
|
129
152
|
ifMatch?: Record<string, string | null>;
|
|
130
153
|
}
|
|
131
154
|
|
|
132
155
|
export interface BlocksApplyResult {
|
|
133
156
|
revision: string;
|
|
157
|
+
/**
|
|
158
|
+
* Every name written or deleted, with its version now: `null` for a
|
|
159
|
+
* deleted name, except on an overlay endpoint, where a deletion the
|
|
160
|
+
* overlay records reports its tombstone version (what the next `ifMatch`
|
|
161
|
+
* on it must name). An overlay may record one even for a name the base
|
|
162
|
+
* lacks; a client treats it like any tombstone.
|
|
163
|
+
*/
|
|
134
164
|
versions: Record<string, string | null>;
|
|
135
165
|
}
|
|
136
166
|
|
|
@@ -148,9 +178,18 @@ export interface ChangesBase {
|
|
|
148
178
|
|
|
149
179
|
/** One entry that differs from the base. */
|
|
150
180
|
export interface Change {
|
|
151
|
-
/**
|
|
181
|
+
/**
|
|
182
|
+
* `set`: the entry exists and differs from the base, or is new. `delete`:
|
|
183
|
+
* it's in the base and gone now; on an overlay endpoint, also a tombstone
|
|
184
|
+
* the overlay holds for a name the base lacks (`baseVersion: null`).
|
|
185
|
+
*/
|
|
152
186
|
kind: "set" | "delete";
|
|
153
|
-
/**
|
|
187
|
+
/**
|
|
188
|
+
* The entry's current version, as `blocks.list` reports it (usable in
|
|
189
|
+
* `ifMatch`). For a `delete`, `null`, except on an overlay endpoint
|
|
190
|
+
* (`describe.overlay`), where it's the deletion's tombstone version: the
|
|
191
|
+
* overlay holds the deletion, so a save of the entry must name it.
|
|
192
|
+
*/
|
|
154
193
|
version: string | null;
|
|
155
194
|
/**
|
|
156
195
|
* The entry's version in the base; `null` when the base doesn't have it (a
|
|
@@ -207,7 +246,11 @@ export interface ChangesGetResult {
|
|
|
207
246
|
export interface ChangesDiscardParams {
|
|
208
247
|
/** Entries to drop back to the base. A name without a change is a no-op. */
|
|
209
248
|
names: string[];
|
|
210
|
-
/**
|
|
249
|
+
/**
|
|
250
|
+
* The version the entry must have now, as `changes.list` reports it; `null`
|
|
251
|
+
* = must not exist. On an overlay endpoint, a deletion the overlay holds
|
|
252
|
+
* has its tombstone version, and `null` on it fails.
|
|
253
|
+
*/
|
|
211
254
|
ifMatch?: Record<string, string | null>;
|
|
212
255
|
}
|
|
213
256
|
|
package/src/v8/builtins/index.ts
CHANGED
|
@@ -5,12 +5,8 @@ import { experiment, SPLIT_TRAFFIC_TYPE, splitTraffic } from "./experiments.ts";
|
|
|
5
5
|
import { lazy } from "./lazy.ts";
|
|
6
6
|
import { always, never } from "./matchers.ts";
|
|
7
7
|
import { multivariate } from "./multivariate.ts";
|
|
8
|
-
import { secretBlock } from "./secret.ts";
|
|
9
8
|
|
|
10
|
-
/**
|
|
11
|
-
* The built-in blocks every block map gets. `secret` here has no key, so it
|
|
12
|
-
* always fails; each CMS replaces it with one holding its `secrets.key`.
|
|
13
|
-
*/
|
|
9
|
+
/** The built-in blocks every block map gets. */
|
|
14
10
|
export const builtIns: Readonly<Record<string, BlockFunction>> = Object.freeze({
|
|
15
11
|
lazy,
|
|
16
12
|
multivariate,
|
|
@@ -21,7 +17,6 @@ export const builtIns: Readonly<Record<string, BlockFunction>> = Object.freeze({
|
|
|
21
17
|
page,
|
|
22
18
|
redirect,
|
|
23
19
|
[SETTINGS_TYPE]: cmsSettings,
|
|
24
|
-
secret: secretBlock(),
|
|
25
20
|
[SPLIT_TRAFFIC_TYPE]: splitTraffic,
|
|
26
21
|
[CALENDAR_TYPE]: calendar,
|
|
27
22
|
});
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
*
|
|
10
10
|
* - Redirects keep v7's nested shape: `redirect` returns its arguments as
|
|
11
11
|
* saved, and `matchRoute` accepts both shapes.
|
|
12
|
-
* - `website/loaders/secret.ts`
|
|
13
|
-
*
|
|
14
|
-
* /next/renames-and-migrations#secrets)
|
|
15
|
-
*
|
|
12
|
+
* - `website/loaders/secret.ts` has no alias: secrets live in the deploy
|
|
13
|
+
* platform, read by the site's code and passed as params (see
|
|
14
|
+
* /next/renames-and-migrations#secrets), so a leftover v7 secret block
|
|
15
|
+
* fails with `UNKNOWN_BLOCK` and `deco check` points it out.
|
|
16
16
|
* - Legacy variants are saved as plain values; on the way to `multivariate`
|
|
17
17
|
* each one is wrapped in a `lazy` block, so only the chosen one runs.
|
|
18
18
|
*/
|
|
@@ -36,7 +36,6 @@ export const LEGACY_ALIASES: Readonly<Record<string, string>> = Object.freeze({
|
|
|
36
36
|
"website/matchers/always.ts": "always",
|
|
37
37
|
"website/matchers/never.ts": "never",
|
|
38
38
|
"website/loaders/redirect.ts": "redirect",
|
|
39
|
-
"website/loaders/secret.ts": "secret",
|
|
40
39
|
});
|
|
41
40
|
|
|
42
41
|
/**
|
package/src/v8/cli/builtins.ts
CHANGED
|
@@ -28,7 +28,6 @@ export const BUILT_IN_USES: Readonly<Record<string, string>> = Object.freeze({
|
|
|
28
28
|
page: "Studio's page list and page editor rely on it",
|
|
29
29
|
redirect: "Studio's redirect list relies on it",
|
|
30
30
|
"cms-settings": "the saved block CMS relies on it, and Studio's settings edit that block",
|
|
31
|
-
secret: "Studio's secret fields rely on it to keep their values encrypted",
|
|
32
31
|
"split-traffic":
|
|
33
32
|
"the saved block experiments relies on it, and Studio's Experiments view edits its percentages",
|
|
34
33
|
calendar: "the saved block campaigns relies on it, and Studio's Campaigns view edits its dates",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* - the walk resolves each name (block type, built-in, alias or saved block),
|
|
11
11
|
* checks that the block fits the field it sits in (by the field's list of
|
|
12
12
|
* functions whose return type fits it), and handles the structural blocks
|
|
13
|
-
* (`multivariate`, `lazy
|
|
13
|
+
* (`multivariate`, `lazy`) and references;
|
|
14
14
|
* - Ajv checks one block's props at a time. Its schema is the generated one
|
|
15
15
|
* with every field also accepting any block, so nested blocks never show up
|
|
16
16
|
* as union noise in the parent: the walk checks them on their own, against
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
|
|
20
20
|
import fs from "node:fs";
|
|
21
21
|
import { Ajv, type ValidateFunction } from "ajv";
|
|
22
|
-
import { isWellFormedCiphertext } from "../../../protocol/secrets.ts";
|
|
23
22
|
import { BLOCKS_MAJOR } from "../../../protocol/types.ts";
|
|
24
23
|
import {
|
|
25
24
|
CALENDAR_TYPE,
|
|
@@ -72,23 +71,23 @@ function isLazyShape(schema: Json): boolean {
|
|
|
72
71
|
return !!e && e.length === 1 && e[0] === "lazy" && !!schema.properties.value;
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
/** A `secret` block's shape inline in a field: the field is `Secret`. */
|
|
76
|
-
function isSecretShape(schema: Json): boolean {
|
|
77
|
-
const e = resolveTypeEnum(schema);
|
|
78
|
-
return !!e && e.length === 1 && e[0] === "secret" && schema.format === "secret";
|
|
79
|
-
}
|
|
80
|
-
|
|
81
74
|
/** The definition key of a block type, if `schema` is a block type's definition. */
|
|
82
75
|
function blockDefinitionName(schema: Json): string | null {
|
|
83
76
|
const e = resolveTypeEnum(schema);
|
|
84
77
|
return e && e.length === 1 && typeof schema.title === "string" && !schema.format ? e[0] : null;
|
|
85
78
|
}
|
|
86
79
|
|
|
80
|
+
/** Where a secret goes instead of a block. */
|
|
81
|
+
const SECRETS_MOVED =
|
|
82
|
+
"secrets live in your deploy platform's secrets, not in content: read the value in your site's code and pass it as a param, then delete this block; see /next/built-in-blocks#secrets";
|
|
83
|
+
|
|
87
84
|
/** Prerelease built-ins folded into the CMS settings block, or renamed, with no alias. */
|
|
88
85
|
const FOLDED_BUILT_INS: Record<string, string> = {
|
|
89
86
|
telemetry: `the built-in is now the telemetry section of the "${SETTINGS_BLOCK}" block (type "${SETTINGS_TYPE}"); see /next/renames-and-migrations#site-settings`,
|
|
90
87
|
analytics: `the built-in is now the analytics section of the "${SETTINGS_BLOCK}" block (type "${SETTINGS_TYPE}"); see /next/renames-and-migrations#site-settings`,
|
|
91
88
|
"date-windows": `the built-in is now "${CALENDAR_TYPE}": set the saved block "${CAMPAIGNS_BLOCK}" to { "__resolveType": "${CALENDAR_TYPE}", … }`,
|
|
89
|
+
secret: SECRETS_MOVED,
|
|
90
|
+
"website/loaders/secret.ts": SECRETS_MOVED,
|
|
92
91
|
};
|
|
93
92
|
|
|
94
93
|
/** A `CMS` block saved with preview hosts, which Studio keeps now (in the release it publishes). */
|
|
@@ -160,12 +159,12 @@ class ValidationDocument {
|
|
|
160
159
|
|
|
161
160
|
private transform(node: Json, wrap: boolean, top = false): Json {
|
|
162
161
|
if (!isObject(node)) return node;
|
|
163
|
-
// Fields that hold a structural block (Lazy<T
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
if (!top &&
|
|
162
|
+
// Fields that hold a structural block (Lazy<T>), as a field or a list
|
|
163
|
+
// item, are entirely the walk's job: it reports a plain value there and
|
|
164
|
+
// checks a block on its own. Ajv accepts anything in them.
|
|
165
|
+
if (!top && isLazyShape(node)) {
|
|
167
166
|
// Still register the lazy value's form: the walk validates it.
|
|
168
|
-
|
|
167
|
+
this.transform(node.properties.value, true);
|
|
169
168
|
return {};
|
|
170
169
|
}
|
|
171
170
|
const copy: Record<string, Json> = {};
|
|
@@ -315,8 +314,6 @@ function formatsFor(doc: Json): Record<string, true | ((value: string) => boolea
|
|
|
315
314
|
return formats;
|
|
316
315
|
}
|
|
317
316
|
|
|
318
|
-
const CIPHERTEXT_PROBLEM = "not a well-formed ciphertext (v1.<wrappedKey>.<iv>.<ciphertext>)";
|
|
319
|
-
|
|
320
317
|
// ---------------------------------------------------------------------------
|
|
321
318
|
// The checker
|
|
322
319
|
// ---------------------------------------------------------------------------
|
|
@@ -562,9 +559,6 @@ class Checker {
|
|
|
562
559
|
return isLazyShape(resolved) ? null : "a lazy block only fits a Lazy<T> field";
|
|
563
560
|
}
|
|
564
561
|
if (isLazyShape(resolved)) return "this field is Lazy<T>: wrap the value in a lazy block";
|
|
565
|
-
if (isSecretShape(resolved)) {
|
|
566
|
-
return type === "secret" ? null : "this field is a Secret: it takes a secret block";
|
|
567
|
-
}
|
|
568
562
|
const allowed = this.allowedTypes(field);
|
|
569
563
|
if (allowed.has(type)) return null;
|
|
570
564
|
if (allowed.size === 0) return "this field takes a plain value";
|
|
@@ -589,9 +583,9 @@ class Checker {
|
|
|
589
583
|
|
|
590
584
|
/**
|
|
591
585
|
* A plain value in a field that only takes a structural block: `Lazy<T>`
|
|
592
|
-
* needs a `lazy` block
|
|
593
|
-
*
|
|
594
|
-
*
|
|
586
|
+
* needs a `lazy` block, in a list item or a union member as much as in a
|
|
587
|
+
* field of its own. Reports it and returns true when the field is one
|
|
588
|
+
* (nothing else to check then).
|
|
595
589
|
*/
|
|
596
590
|
private structuralProblem(ctx: Context, value: Json, path: string, field: Json): boolean {
|
|
597
591
|
const resolved = this.deref(field);
|
|
@@ -601,12 +595,6 @@ class Checker {
|
|
|
601
595
|
}
|
|
602
596
|
return true;
|
|
603
597
|
}
|
|
604
|
-
if (isSecretShape(resolved)) {
|
|
605
|
-
if (value !== undefined && value !== null) {
|
|
606
|
-
this.report(ctx, path, "plain text in a Secret field: save it as a secret block");
|
|
607
|
-
}
|
|
608
|
-
return true;
|
|
609
|
-
}
|
|
610
598
|
return false;
|
|
611
599
|
}
|
|
612
600
|
|
|
@@ -727,13 +715,6 @@ class Checker {
|
|
|
727
715
|
if ("value" in block) this.checkValue(ctx, block.value, joinPath(path, "/value"), inner);
|
|
728
716
|
return;
|
|
729
717
|
}
|
|
730
|
-
case "secret": {
|
|
731
|
-
this.checkProps(ctx, block, path, false);
|
|
732
|
-
if ("ciphertext" in block && !isWellFormedCiphertext(block.ciphertext)) {
|
|
733
|
-
this.report(ctx, joinPath(path, "/ciphertext"), CIPHERTEXT_PROBLEM);
|
|
734
|
-
}
|
|
735
|
-
return;
|
|
736
|
-
}
|
|
737
718
|
case EXPERIMENT_RULE: {
|
|
738
719
|
this.checkProps(ctx, block, path, true);
|
|
739
720
|
const name = this.ruleInputs(block, EXPERIMENT_RULE)?.name;
|
|
@@ -17,7 +17,6 @@ export const BUILT_IN_GROUPS: Record<string, ManifestGroup> = {
|
|
|
17
17
|
page: "pages",
|
|
18
18
|
redirect: "redirects",
|
|
19
19
|
"cms-settings": "content",
|
|
20
|
-
secret: "loaders",
|
|
21
20
|
"split-traffic": "content",
|
|
22
21
|
calendar: "content",
|
|
23
22
|
};
|
|
@@ -60,7 +59,6 @@ const BUILT_IN_DOCS: Record<string, { title: string; description: string; icon?:
|
|
|
60
59
|
"Campaigns: each name with its start and end; resolves to whether each is running now. The type of the saved block campaigns",
|
|
61
60
|
icon: "calendar-event",
|
|
62
61
|
},
|
|
63
|
-
secret: { title: "Secret", description: "An encrypted value, decrypted on the server" },
|
|
64
62
|
};
|
|
65
63
|
|
|
66
64
|
/** The form of each test in a `split-traffic` block: a whole percentage. */
|
|
@@ -266,12 +264,6 @@ function builtInProps(name: string, ctx: BuiltInContext): any {
|
|
|
266
264
|
},
|
|
267
265
|
},
|
|
268
266
|
};
|
|
269
|
-
case "secret":
|
|
270
|
-
return {
|
|
271
|
-
type: "object",
|
|
272
|
-
required: ["ciphertext"],
|
|
273
|
-
properties: { ciphertext: { type: "string", title: "Ciphertext", writeOnly: true } },
|
|
274
|
-
};
|
|
275
267
|
}
|
|
276
268
|
}
|
|
277
269
|
|
|
@@ -284,14 +284,7 @@ export async function generateSchema(paths: DecoPaths): Promise<SchemaResult> {
|
|
|
284
284
|
// -------------------------------------------------------------------------
|
|
285
285
|
// 2. Fields → blocks: which functions' return types fit an object field.
|
|
286
286
|
// -------------------------------------------------------------------------
|
|
287
|
-
const STRUCTURAL = new Set<string>([
|
|
288
|
-
"lazy",
|
|
289
|
-
"multivariate",
|
|
290
|
-
"secret",
|
|
291
|
-
"always",
|
|
292
|
-
"never",
|
|
293
|
-
"campaign",
|
|
294
|
-
]);
|
|
287
|
+
const STRUCTURAL = new Set<string>(["lazy", "multivariate", "always", "never", "campaign"]);
|
|
295
288
|
const candidates: Pick<BlockInfo, "key" | "returnType">[] = infos.filter(
|
|
296
289
|
(info) =>
|
|
297
290
|
info.group !== "sections" &&
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* return type fits it, decided by TypeScript assignability, not by type
|
|
14
14
|
* name (spec: schema › Interchangeable blocks).
|
|
15
15
|
* - `Lazy<T>` is a `lazy` block whose `value` has the form of `T`.
|
|
16
|
-
* - `Secret` holds a `secret` block, never a plain string.
|
|
17
16
|
* - `@options` with a literal list becomes an `enum`; a function-backed list
|
|
18
17
|
* falls back to a text field, since the site editor never runs site code.
|
|
19
18
|
*
|
|
@@ -212,6 +211,8 @@ const WIDGET_TYPE_FORMATS: Record<string, string> = {
|
|
|
212
211
|
TextArea: "textarea",
|
|
213
212
|
Code: "code",
|
|
214
213
|
DateTimeWidget: "date-time",
|
|
214
|
+
// v7's masked text box. A plain string in content: keep real secrets in the deploy platform.
|
|
215
|
+
Secret: "password",
|
|
215
216
|
};
|
|
216
217
|
|
|
217
218
|
/** Apply the format of a widget alias named in `typeHint` to the right inner schema. */
|
|
@@ -326,16 +327,6 @@ function lazyInner(type: Type, typeHint = ""): Type | null {
|
|
|
326
327
|
return inner;
|
|
327
328
|
}
|
|
328
329
|
|
|
329
|
-
/** `Secret`, from `@decocms/blocks` (`string & { readonly __secret: true }`). */
|
|
330
|
-
function isSecretType(type: Type, typeHint = ""): boolean {
|
|
331
|
-
if (type.getAliasSymbol()?.getName() === "Secret") return true;
|
|
332
|
-
if (/^(\w+\.)?Secret$/.test(typeHint.trim())) return true;
|
|
333
|
-
return (
|
|
334
|
-
type.isIntersection() &&
|
|
335
|
-
type.getIntersectionTypes().some((t) => t.getProperty("__secret") !== undefined)
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
330
|
/**
|
|
340
331
|
* The awaited type: `Promise<T>` is `T`. With `strict`, anything that isn't a
|
|
341
332
|
* promise returns null (used to recognize `() => Promise<T>`).
|
|
@@ -426,7 +417,7 @@ export function titleCase(name: string): string {
|
|
|
426
417
|
.replace(/^./, (c) => c.toUpperCase());
|
|
427
418
|
}
|
|
428
419
|
|
|
429
|
-
/** `
|
|
420
|
+
/** `Lazy<T> | undefined` → `Lazy<T>`: the annotation without its nullish members. */
|
|
430
421
|
function stripNullish(typeHint: string): string {
|
|
431
422
|
return typeHint.replace(/\s*\|\s*(null|undefined)\b/g, "").trim();
|
|
432
423
|
}
|
|
@@ -447,20 +438,6 @@ export function lazySchema(value: any): any {
|
|
|
447
438
|
};
|
|
448
439
|
}
|
|
449
440
|
|
|
450
|
-
/** The schema of a `secret` block: a write-only field saved encrypted. */
|
|
451
|
-
function secretSchema(): any {
|
|
452
|
-
return {
|
|
453
|
-
type: "object",
|
|
454
|
-
format: "secret",
|
|
455
|
-
writeOnly: true,
|
|
456
|
-
required: ["__resolveType", "ciphertext"],
|
|
457
|
-
properties: {
|
|
458
|
-
__resolveType: { type: "string", enum: ["secret"], default: "secret" },
|
|
459
|
-
ciphertext: { type: "string" },
|
|
460
|
-
},
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
|
|
464
441
|
/**
|
|
465
442
|
* The schema of one field: everything a type means at a property position,
|
|
466
443
|
* before the property's own JSDoc and title are applied.
|
|
@@ -474,8 +451,6 @@ function fieldSchema(
|
|
|
474
451
|
const lazy = lazyInner(nonNullable(propType), stripNullish(typeHint));
|
|
475
452
|
if (lazy) return lazySchema(fieldSchema(lazy, lazy.getText(), ctx, visited));
|
|
476
453
|
|
|
477
|
-
if (isSecretType(nonNullable(propType), stripNullish(typeHint))) return secretSchema();
|
|
478
|
-
|
|
479
454
|
if (ctx && isObjectLike(propType) && !isSectionType(nonNullable(propType))) {
|
|
480
455
|
const fits = ctx.fitting(propType);
|
|
481
456
|
if (fits.length > 0) {
|
|
@@ -598,8 +573,7 @@ export function typeToJsonSchema(
|
|
|
598
573
|
if (type.isAny() || type.isUnknown()) return {};
|
|
599
574
|
|
|
600
575
|
// Structural blocks wherever the type appears, not only as a whole field:
|
|
601
|
-
// `
|
|
602
|
-
if (isSecretType(type)) return secretSchema();
|
|
576
|
+
// `Lazy<T>[]` is a list of lazy blocks.
|
|
603
577
|
const lazy = lazyInner(type);
|
|
604
578
|
if (lazy) return lazySchema(fieldSchema(lazy, lazy.getText(), ctx, visited));
|
|
605
579
|
|
|
@@ -742,7 +716,7 @@ export function typeToJsonSchema(
|
|
|
742
716
|
const tags = getJsDocTags(prop);
|
|
743
717
|
if (tags.ignore) continue;
|
|
744
718
|
|
|
745
|
-
// The annotation as written (`ImageWidget`, `Section[]`, `
|
|
719
|
+
// The annotation as written (`ImageWidget`, `Section[]`, `Lazy<T>`),
|
|
746
720
|
// before the checker resolves aliases away.
|
|
747
721
|
const typeNode = decl.getTypeNode();
|
|
748
722
|
const typeHint: string = typeNode ? typeNode.getText() : propType.getText();
|
package/src/v8/client.ts
CHANGED
|
@@ -25,7 +25,7 @@ interface ClientOptions {
|
|
|
25
25
|
/** Loads this client's snapshot; called at most once. */
|
|
26
26
|
load: () => Promise<Snapshot>;
|
|
27
27
|
blocks: Blocks;
|
|
28
|
-
/** The built-
|
|
28
|
+
/** The built-in blocks. */
|
|
29
29
|
builtIns: Readonly<Blocks>;
|
|
30
30
|
/** Who is visiting (copied and frozen); `null` for none. */
|
|
31
31
|
visitor?: Visitor | null;
|
package/src/v8/cms.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import { runInBackground } from "./background.ts";
|
|
10
10
|
import { SETTINGS_BLOCK, SETTINGS_TYPE } from "./builtins/data.ts";
|
|
11
11
|
import { builtIns } from "./builtins/index.ts";
|
|
12
|
-
import { secretBlock } from "./builtins/secret.ts";
|
|
13
12
|
import { CMSClient } from "./client.ts";
|
|
14
13
|
import { ContentStore, isLoader, isSnapshot } from "./content.ts";
|
|
15
14
|
import type { Overrides } from "./current.ts";
|
|
@@ -62,13 +61,12 @@ interface Fingerprint {
|
|
|
62
61
|
interval: number;
|
|
63
62
|
telemetry: string;
|
|
64
63
|
preview: string;
|
|
65
|
-
secrets: string;
|
|
66
64
|
token: string;
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
/**
|
|
70
68
|
* The state one content root shares across `createCMS` calls: the content
|
|
71
|
-
* store, caps
|
|
69
|
+
* store, caps and telemetry. Each call gets its own handle
|
|
72
70
|
* holding its own block map (see `CMSHandle`).
|
|
73
71
|
*/
|
|
74
72
|
class CMSInstance {
|
|
@@ -77,8 +75,6 @@ class CMSInstance {
|
|
|
77
75
|
readonly #store: ContentStore;
|
|
78
76
|
readonly #interval: number;
|
|
79
77
|
readonly #warned = new Set<string>();
|
|
80
|
-
/** The built-ins with a `secret` that holds this instance's key (the first call's). */
|
|
81
|
-
readonly #builtIns: Readonly<Blocks>;
|
|
82
78
|
readonly #telemetry: TelemetryPipeline | undefined;
|
|
83
79
|
readonly #caps: SettingsCaps;
|
|
84
80
|
/** Settings of a `CMS` block with nothing to run, per release snapshot. */
|
|
@@ -107,10 +103,6 @@ class CMSInstance {
|
|
|
107
103
|
this.#telemetry = new TelemetryPipeline(destination);
|
|
108
104
|
setCurrentTelemetry(this.#telemetry);
|
|
109
105
|
}
|
|
110
|
-
// Decrypted values never leave in telemetry: the pipeline redacts each one.
|
|
111
|
-
const telemetry = this.#telemetry;
|
|
112
|
-
const secret = secretBlock(config.secrets?.key, (value) => telemetry?.redact(value));
|
|
113
|
-
this.#builtIns = Object.freeze({ ...builtIns, secret });
|
|
114
106
|
}
|
|
115
107
|
|
|
116
108
|
/**
|
|
@@ -233,7 +225,7 @@ class CMSInstance {
|
|
|
233
225
|
new CMSClient({
|
|
234
226
|
load: () => Promise.resolve(snapshot),
|
|
235
227
|
blocks,
|
|
236
|
-
builtIns
|
|
228
|
+
builtIns,
|
|
237
229
|
date: Date.now(),
|
|
238
230
|
onCollision: (name) => this.#warnCollision(name),
|
|
239
231
|
}),
|
|
@@ -298,7 +290,7 @@ class CMSInstance {
|
|
|
298
290
|
return new CMSClient({
|
|
299
291
|
load,
|
|
300
292
|
blocks,
|
|
301
|
-
builtIns
|
|
293
|
+
builtIns,
|
|
302
294
|
...inputs,
|
|
303
295
|
onCollision: (name) => this.#warnCollision(name),
|
|
304
296
|
telemetry: this.#telemetry?.forClient(),
|
|
@@ -336,8 +328,8 @@ const INSTANCE = Symbol.for("decocms.blocks.cms.instance");
|
|
|
336
328
|
|
|
337
329
|
/**
|
|
338
330
|
* What `createCMS` returns: the shared instance plus the block map of this
|
|
339
|
-
* call. Every handle on one content root shares its content, caps
|
|
340
|
-
*
|
|
331
|
+
* call. Every handle on one content root shares its content, caps and
|
|
332
|
+
* telemetry; each resolves with the block map it was created with.
|
|
341
333
|
*/
|
|
342
334
|
class CMSHandle implements CMS {
|
|
343
335
|
readonly #instance: CMSInstance;
|
|
@@ -552,7 +544,6 @@ function fingerprintOf(config: CMSConfig, interval: number): Fingerprint {
|
|
|
552
544
|
interval,
|
|
553
545
|
telemetry: stableJson(config.telemetry ?? null),
|
|
554
546
|
preview: stableJson(config.preview ?? null),
|
|
555
|
-
secrets: config.secrets?.key ? fnv1a(config.secrets.key) : "",
|
|
556
547
|
token: config.token ? fnv1a(config.token) : "",
|
|
557
548
|
};
|
|
558
549
|
}
|