@tinycloud/sdk-services 3.2.6-beta.2 → 3.3.0-beta.11
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/{BaseService-4wwJq1Gn.d.cts → BaseService-Cc6Ueicm.d.cts} +1 -1
- package/dist/{BaseService-BGr2slUz.d.ts → BaseService-DOdXd7sr.d.ts} +1 -1
- package/dist/encryption/index.cjs +10 -0
- package/dist/encryption/index.cjs.map +1 -1
- package/dist/encryption/index.d.cts +2 -2
- package/dist/encryption/index.d.ts +2 -2
- package/dist/encryption/index.js +10 -0
- package/dist/encryption/index.js.map +1 -1
- package/dist/index.cjs +360 -210
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +116 -13
- package/dist/index.d.ts +116 -13
- package/dist/index.js +359 -210
- package/dist/index.js.map +1 -1
- package/dist/internal/decrypt-transport-response-error.d.cts +1 -1
- package/dist/internal/decrypt-transport-response-error.d.ts +1 -1
- package/dist/kv/index.cjs +68 -21
- package/dist/kv/index.cjs.map +1 -1
- package/dist/kv/index.d.cts +7 -4
- package/dist/kv/index.d.ts +7 -4
- package/dist/kv/index.js +68 -21
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/replication/contractConstants.cjs +115 -0
- package/dist/kv/replication/contractConstants.cjs.map +1 -0
- package/dist/kv/replication/contractConstants.d.cts +77 -0
- package/dist/kv/replication/contractConstants.d.ts +77 -0
- package/dist/kv/replication/contractConstants.js +75 -0
- package/dist/kv/replication/contractConstants.js.map +1 -0
- package/dist/kv/replication/grantPolicy.cjs +82 -0
- package/dist/kv/replication/grantPolicy.cjs.map +1 -0
- package/dist/kv/replication/grantPolicy.d.cts +19 -0
- package/dist/kv/replication/grantPolicy.d.ts +19 -0
- package/dist/kv/replication/grantPolicy.js +50 -0
- package/dist/kv/replication/grantPolicy.js.map +1 -0
- package/dist/kv/replication/grantPolicyConstants.cjs +42 -0
- package/dist/kv/replication/grantPolicyConstants.cjs.map +1 -0
- package/dist/kv/replication/grantPolicyConstants.d.cts +10 -0
- package/dist/kv/replication/grantPolicyConstants.d.ts +10 -0
- package/dist/kv/replication/grantPolicyConstants.js +14 -0
- package/dist/kv/replication/grantPolicyConstants.js.map +1 -0
- package/dist/kv/replication/grantPolicyTypes.cjs +19 -0
- package/dist/kv/replication/grantPolicyTypes.cjs.map +1 -0
- package/dist/kv/replication/grantPolicyTypes.d.cts +87 -0
- package/dist/kv/replication/grantPolicyTypes.d.ts +87 -0
- package/dist/kv/replication/grantPolicyTypes.js +1 -0
- package/dist/kv/replication/grantPolicyTypes.js.map +1 -0
- package/dist/kv/replication/index.cjs +575 -131
- package/dist/kv/replication/index.cjs.map +1 -1
- package/dist/kv/replication/index.d.cts +6 -3
- package/dist/kv/replication/index.d.ts +6 -3
- package/dist/kv/replication/index.js +575 -131
- package/dist/kv/replication/index.js.map +1 -1
- package/dist/scope-B-m6cKH-.d.ts +1962 -0
- package/dist/scope-B7oeKdLM.d.cts +1962 -0
- package/dist/sql/index.cjs +72 -36
- package/dist/sql/index.cjs.map +1 -1
- package/dist/sql/index.d.cts +2 -2
- package/dist/sql/index.d.ts +2 -2
- package/dist/sql/index.js +72 -36
- package/dist/sql/index.js.map +1 -1
- package/dist/{types-D-9A3Sut.d.cts → types-BjH0ZtGy.d.cts} +8 -0
- package/dist/{types-D-9A3Sut.d.ts → types-BjH0ZtGy.d.ts} +8 -0
- package/package.json +55 -2
- package/dist/scope-CoKKmMiI.d.ts +0 -957
- package/dist/scope-D7wmjbMH.d.cts +0 -957
|
@@ -1,957 +0,0 @@
|
|
|
1
|
-
import { R as Result, F as FetchFunction } from './types-D-9A3Sut.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* KV Service Types
|
|
5
|
-
*
|
|
6
|
-
* Type definitions for the KV (Key-Value) service operations.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Configuration for KVService.
|
|
11
|
-
*/
|
|
12
|
-
interface KVServiceConfig {
|
|
13
|
-
/**
|
|
14
|
-
* Default prefix for all keys.
|
|
15
|
-
* Useful for namespacing data within a space.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* const kv = new KVService({ prefix: 'myapp/settings' });
|
|
20
|
-
* await kv.put('theme', 'dark'); // Stores at 'myapp/settings/theme'
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
prefix?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Default timeout in milliseconds for each KV request, including reading
|
|
26
|
-
* the response body. When it elapses the request is aborted and the
|
|
27
|
-
* operation returns an `ErrorCodes.TIMEOUT` error. A per-call `timeout`
|
|
28
|
-
* option overrides it. Unset (the default), `0`, or `Infinity` means no
|
|
29
|
-
* timeout.
|
|
30
|
-
*/
|
|
31
|
-
timeout?: number;
|
|
32
|
-
/** Allow additional config properties */
|
|
33
|
-
[key: string]: unknown;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Options for KV get operations.
|
|
37
|
-
*/
|
|
38
|
-
interface KVGetOptions {
|
|
39
|
-
/**
|
|
40
|
-
* Override the default prefix for this operation.
|
|
41
|
-
*/
|
|
42
|
-
prefix?: string;
|
|
43
|
-
/**
|
|
44
|
-
* Require this read to bypass replication and use the network directly.
|
|
45
|
-
* A configured read-through observer receives `NETWORK_REQUESTED` after the
|
|
46
|
-
* network result settles, with its outcome and latency. This is supported by
|
|
47
|
-
* `get` and `list`; `head`, `batchGet`, `batchHead` and signed URL operations
|
|
48
|
-
* always use the network.
|
|
49
|
-
*/
|
|
50
|
-
source?: "network";
|
|
51
|
-
/**
|
|
52
|
-
* Return raw response instead of parsed JSON.
|
|
53
|
-
* When true, data will be the raw response text.
|
|
54
|
-
*/
|
|
55
|
-
raw?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Return the raw response bytes as a Uint8Array instead of parsed/text data.
|
|
58
|
-
* Use this to read back binary values (e.g. images) byte-identically. Takes
|
|
59
|
-
* precedence over {@link raw}.
|
|
60
|
-
*/
|
|
61
|
-
binary?: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Ask the node to reject the response when the stored value exceeds this
|
|
64
|
-
* number of bytes. This bounds downloads before the response body is read.
|
|
65
|
-
*/
|
|
66
|
-
maxResponseBytes?: number;
|
|
67
|
-
/**
|
|
68
|
-
* Custom timeout for this operation in milliseconds. Overrides
|
|
69
|
-
* `KVServiceConfig.timeout`; `0` disables a configured timeout.
|
|
70
|
-
*/
|
|
71
|
-
timeout?: number;
|
|
72
|
-
/**
|
|
73
|
-
* Custom abort signal for this operation.
|
|
74
|
-
*/
|
|
75
|
-
signal?: AbortSignal;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Options for KV put operations.
|
|
79
|
-
*/
|
|
80
|
-
interface KVPutOptions {
|
|
81
|
-
/**
|
|
82
|
-
* Override the default prefix for this operation.
|
|
83
|
-
*/
|
|
84
|
-
prefix?: string;
|
|
85
|
-
/**
|
|
86
|
-
* Content type for the value.
|
|
87
|
-
* Defaults to 'application/json' for objects.
|
|
88
|
-
*/
|
|
89
|
-
contentType?: string;
|
|
90
|
-
/**
|
|
91
|
-
* Custom metadata headers to store with the value.
|
|
92
|
-
*/
|
|
93
|
-
metadata?: Record<string, string>;
|
|
94
|
-
/** Only write when the current object has this strong ETag. */
|
|
95
|
-
ifMatch?: string;
|
|
96
|
-
/** Only write when the key does not exist. */
|
|
97
|
-
ifNoneMatch?: "*";
|
|
98
|
-
/**
|
|
99
|
-
* Custom timeout for this operation in milliseconds. Overrides
|
|
100
|
-
* `KVServiceConfig.timeout`; `0` disables a configured timeout.
|
|
101
|
-
*/
|
|
102
|
-
timeout?: number;
|
|
103
|
-
/**
|
|
104
|
-
* Custom abort signal for this operation.
|
|
105
|
-
*/
|
|
106
|
-
signal?: AbortSignal;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* One entry in a KV batch put request.
|
|
110
|
-
*/
|
|
111
|
-
interface KVBatchPutItem {
|
|
112
|
-
/**
|
|
113
|
-
* The key to store under.
|
|
114
|
-
*/
|
|
115
|
-
key: string;
|
|
116
|
-
/**
|
|
117
|
-
* The value to store.
|
|
118
|
-
*
|
|
119
|
-
* Objects are JSON stringified. Strings are stored as text. Binary values
|
|
120
|
-
* should be supplied as Blob, ArrayBuffer, or Uint8Array.
|
|
121
|
-
*/
|
|
122
|
-
value: unknown;
|
|
123
|
-
/**
|
|
124
|
-
* Content type for this item. Defaults to application/json for objects and
|
|
125
|
-
* application/octet-stream for binary values.
|
|
126
|
-
*/
|
|
127
|
-
contentType?: string;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Options for KV batch put operations.
|
|
131
|
-
*/
|
|
132
|
-
interface KVBatchPutOptions {
|
|
133
|
-
/**
|
|
134
|
-
* Override the default prefix for all entries in this batch.
|
|
135
|
-
*/
|
|
136
|
-
prefix?: string;
|
|
137
|
-
/**
|
|
138
|
-
* Custom timeout for this operation in milliseconds. Overrides
|
|
139
|
-
* `KVServiceConfig.timeout`; `0` disables a configured timeout.
|
|
140
|
-
*/
|
|
141
|
-
timeout?: number;
|
|
142
|
-
/**
|
|
143
|
-
* Custom abort signal for this operation.
|
|
144
|
-
*/
|
|
145
|
-
signal?: AbortSignal;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Response from KV batch put operations.
|
|
149
|
-
*/
|
|
150
|
-
interface KVBatchPutResponse {
|
|
151
|
-
/**
|
|
152
|
-
* Keys successfully written by the batch.
|
|
153
|
-
*/
|
|
154
|
-
written: string[];
|
|
155
|
-
/**
|
|
156
|
-
* Number of written keys.
|
|
157
|
-
*/
|
|
158
|
-
count: number;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Response from a KV batch read. Transport or authorization failures are
|
|
162
|
-
* returned by the outer Result; each requested key has its own Result so a
|
|
163
|
-
* missing key does not discard successful siblings.
|
|
164
|
-
*/
|
|
165
|
-
interface KVBatchReadResponse<T = unknown> {
|
|
166
|
-
results: Array<{
|
|
167
|
-
key: string;
|
|
168
|
-
result: Result<KVResponse<T>>;
|
|
169
|
-
}>;
|
|
170
|
-
count: number;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Options for KV list operations.
|
|
174
|
-
*/
|
|
175
|
-
interface KVListOptions {
|
|
176
|
-
/**
|
|
177
|
-
* Override the default prefix for this operation.
|
|
178
|
-
*/
|
|
179
|
-
prefix?: string;
|
|
180
|
-
/**
|
|
181
|
-
* Require this read to bypass replication and use the network directly. A
|
|
182
|
-
* configured read-through observer receives `NETWORK_REQUESTED` after the
|
|
183
|
-
* network result settles, with its outcome and latency.
|
|
184
|
-
*/
|
|
185
|
-
source?: "network";
|
|
186
|
-
/**
|
|
187
|
-
* Additional path to append to the prefix.
|
|
188
|
-
*/
|
|
189
|
-
path?: string;
|
|
190
|
-
/**
|
|
191
|
-
* Whether to remove the prefix from returned keys.
|
|
192
|
-
* When true, keys are returned relative to the prefix.
|
|
193
|
-
*/
|
|
194
|
-
removePrefix?: boolean;
|
|
195
|
-
/**
|
|
196
|
-
* Return raw response instead of parsed JSON.
|
|
197
|
-
*/
|
|
198
|
-
raw?: boolean;
|
|
199
|
-
/** Maximum number of keys the node may return. */
|
|
200
|
-
limit?: number;
|
|
201
|
-
/** Opaque scope-bound cursor returned by a previous bounded list. */
|
|
202
|
-
cursor?: string;
|
|
203
|
-
/**
|
|
204
|
-
* Custom timeout for this operation in milliseconds. Overrides
|
|
205
|
-
* `KVServiceConfig.timeout`; `0` disables a configured timeout.
|
|
206
|
-
*/
|
|
207
|
-
timeout?: number;
|
|
208
|
-
/**
|
|
209
|
-
* Custom abort signal for this operation.
|
|
210
|
-
*/
|
|
211
|
-
signal?: AbortSignal;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Options for KV delete operations.
|
|
215
|
-
*/
|
|
216
|
-
interface KVDeleteOptions {
|
|
217
|
-
/**
|
|
218
|
-
* Override the default prefix for this operation.
|
|
219
|
-
*/
|
|
220
|
-
prefix?: string;
|
|
221
|
-
/** Only delete when the current object has this strong ETag. */
|
|
222
|
-
ifMatch?: string;
|
|
223
|
-
/**
|
|
224
|
-
* Custom timeout for this operation in milliseconds. Overrides
|
|
225
|
-
* `KVServiceConfig.timeout`; `0` disables a configured timeout.
|
|
226
|
-
*/
|
|
227
|
-
timeout?: number;
|
|
228
|
-
/**
|
|
229
|
-
* Custom abort signal for this operation.
|
|
230
|
-
*/
|
|
231
|
-
signal?: AbortSignal;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Options for KV head (metadata) operations.
|
|
235
|
-
*/
|
|
236
|
-
interface KVHeadOptions {
|
|
237
|
-
/**
|
|
238
|
-
* Override the default prefix for this operation.
|
|
239
|
-
*/
|
|
240
|
-
prefix?: string;
|
|
241
|
-
/**
|
|
242
|
-
* Custom timeout for this operation in milliseconds. Overrides
|
|
243
|
-
* `KVServiceConfig.timeout`; `0` disables a configured timeout.
|
|
244
|
-
*/
|
|
245
|
-
timeout?: number;
|
|
246
|
-
/**
|
|
247
|
-
* Custom abort signal for this operation.
|
|
248
|
-
*/
|
|
249
|
-
signal?: AbortSignal;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Default lifetime for signed KV read URLs when a caller omits expiresInSeconds.
|
|
253
|
-
* SDK duration defaults are stored in milliseconds; createSignedReadUrl converts
|
|
254
|
-
* this to the node endpoint's ttl_seconds field.
|
|
255
|
-
*
|
|
256
|
-
* Keep this in sync with EXPIRY.SIGNED_READ_URL_MS in @tinycloud/sdk-core.
|
|
257
|
-
* sdk-services cannot import sdk-core because sdk-core depends on sdk-services.
|
|
258
|
-
*/
|
|
259
|
-
declare const DEFAULT_SIGNED_READ_URL_EXPIRY_MS: number;
|
|
260
|
-
/**
|
|
261
|
-
* Options for creating a signed KV read URL.
|
|
262
|
-
*/
|
|
263
|
-
interface KVCreateSignedReadUrlOptions {
|
|
264
|
-
/**
|
|
265
|
-
* Override the default prefix for this operation.
|
|
266
|
-
*/
|
|
267
|
-
prefix?: string;
|
|
268
|
-
/**
|
|
269
|
-
* Requested URL lifetime in seconds.
|
|
270
|
-
* Defaults to {@link DEFAULT_SIGNED_READ_URL_EXPIRY_MS} converted to seconds.
|
|
271
|
-
* The node may cap this by its configured maximum, the invocation expiry,
|
|
272
|
-
* or the parent delegation expiry.
|
|
273
|
-
*/
|
|
274
|
-
expiresInSeconds?: number;
|
|
275
|
-
/**
|
|
276
|
-
* Optional blake3 content hash to bind the signed URL to a specific object.
|
|
277
|
-
*/
|
|
278
|
-
contentHash?: string;
|
|
279
|
-
/**
|
|
280
|
-
* Optional ETag to bind the signed URL to a specific object version.
|
|
281
|
-
*/
|
|
282
|
-
etag?: string;
|
|
283
|
-
/**
|
|
284
|
-
* Custom timeout for this operation in milliseconds. Overrides
|
|
285
|
-
* `KVServiceConfig.timeout`; `0` disables a configured timeout.
|
|
286
|
-
*/
|
|
287
|
-
timeout?: number;
|
|
288
|
-
/**
|
|
289
|
-
* Custom abort signal for this operation.
|
|
290
|
-
*/
|
|
291
|
-
signal?: AbortSignal;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Response headers from KV operations.
|
|
295
|
-
*/
|
|
296
|
-
interface KVResponseHeaders {
|
|
297
|
-
/**
|
|
298
|
-
* ETag for conditional requests.
|
|
299
|
-
*/
|
|
300
|
-
etag?: string;
|
|
301
|
-
/**
|
|
302
|
-
* Content type of the stored value.
|
|
303
|
-
*/
|
|
304
|
-
contentType?: string;
|
|
305
|
-
/**
|
|
306
|
-
* Last modification timestamp.
|
|
307
|
-
*/
|
|
308
|
-
lastModified?: string;
|
|
309
|
-
/**
|
|
310
|
-
* Content length in bytes.
|
|
311
|
-
*/
|
|
312
|
-
contentLength?: number;
|
|
313
|
-
/**
|
|
314
|
-
* Get a header value by name.
|
|
315
|
-
* @param name - Header name (case-insensitive)
|
|
316
|
-
*/
|
|
317
|
-
get(name: string): string | null;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Response from KV get/put operations.
|
|
321
|
-
*
|
|
322
|
-
* @template T - Type of the data payload
|
|
323
|
-
*/
|
|
324
|
-
interface KVResponse<T = unknown> {
|
|
325
|
-
/**
|
|
326
|
-
* The data payload.
|
|
327
|
-
* For get: the stored value.
|
|
328
|
-
* For put: undefined.
|
|
329
|
-
*/
|
|
330
|
-
data: T;
|
|
331
|
-
/**
|
|
332
|
-
* Response headers with metadata.
|
|
333
|
-
*/
|
|
334
|
-
headers: KVResponseHeaders;
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Response from KV list operations.
|
|
338
|
-
*/
|
|
339
|
-
interface KVListResponse {
|
|
340
|
-
/**
|
|
341
|
-
* Array of keys matching the list criteria.
|
|
342
|
-
*/
|
|
343
|
-
keys: string[];
|
|
344
|
-
/** True when more matching keys exist than the requested limit. */
|
|
345
|
-
truncated?: boolean;
|
|
346
|
-
/** Opaque cursor for the next page, when the node returned one. */
|
|
347
|
-
nextCursor?: string;
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Options for {@link IKVService.changes}, the `tinycloud.kv/sync` change feed.
|
|
351
|
-
*/
|
|
352
|
-
interface KVChangesOptions {
|
|
353
|
-
/**
|
|
354
|
-
* The space-relative KV prefix to follow, sent as the invocation path. It
|
|
355
|
-
* is not joined with the service's configured prefix, and must be non-empty.
|
|
356
|
-
* Prefixes match whole path segments: `notes` covers `notes` and
|
|
357
|
-
* `notes/a`, while `notes/` covers everything under `notes/` but not
|
|
358
|
-
* `notes` itself. The session must hold `tinycloud.kv/sync` on it by name.
|
|
359
|
-
*
|
|
360
|
-
* Returned `changes[].key` values are full paths in the space, like this
|
|
361
|
-
* prefix. On a service with a configured prefix (for example
|
|
362
|
-
* `DelegatedAccess.kv`, whose prefix is the delegation path), `get` joins
|
|
363
|
-
* that prefix again, so strip it from the key first, or follow the feed
|
|
364
|
-
* with `kv.withPrefix(...).changes()`, which returns relative keys.
|
|
365
|
-
*/
|
|
366
|
-
prefix: string;
|
|
367
|
-
/**
|
|
368
|
-
* The `cursor` from the previous page. Omit it to bootstrap from the start
|
|
369
|
-
* of the prefix. Opaque; never parse or build one.
|
|
370
|
-
*/
|
|
371
|
-
cursor?: string;
|
|
372
|
-
/**
|
|
373
|
-
* Page size, 1 through 1000 (node default 500). A page never splits one
|
|
374
|
-
* invocation's changes, so it can hold more than `limit` changes.
|
|
375
|
-
*/
|
|
376
|
-
limit?: number;
|
|
377
|
-
/**
|
|
378
|
-
* CID of a never-invoked delegation carrying `tinycloud.kv/retain` on the
|
|
379
|
-
* prefix. When valid, the node attests `authority.retainUntil`.
|
|
380
|
-
*/
|
|
381
|
-
retentionGrant?: string;
|
|
382
|
-
/**
|
|
383
|
-
* Custom timeout for this operation in milliseconds. Overrides
|
|
384
|
-
* `KVServiceConfig.timeout`; `0` disables a configured timeout.
|
|
385
|
-
*/
|
|
386
|
-
timeout?: number;
|
|
387
|
-
/**
|
|
388
|
-
* Custom abort signal for this operation.
|
|
389
|
-
*/
|
|
390
|
-
signal?: AbortSignal;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* One key's latest state in a change feed page. Content is not included:
|
|
394
|
-
* read it with `get`/`batchGet` and check it against `etag`.
|
|
395
|
-
*/
|
|
396
|
-
type KVChange = {
|
|
397
|
-
key: string;
|
|
398
|
-
deleted: false;
|
|
399
|
-
/** The strong ETag `get` returns for this state. */
|
|
400
|
-
etag: string;
|
|
401
|
-
metadata: Record<string, string>;
|
|
402
|
-
} | {
|
|
403
|
-
key: string;
|
|
404
|
-
deleted: true;
|
|
405
|
-
};
|
|
406
|
-
/**
|
|
407
|
-
* The node-attested window in which the caller's authority holds. Values are
|
|
408
|
-
* RFC 3339 timestamps, or `null` when nothing in the chain sets one.
|
|
409
|
-
*/
|
|
410
|
-
interface KVChangesAuthority {
|
|
411
|
-
/** The latest `nbf` across the invocation's whole delegation chain. */
|
|
412
|
-
notBefore: string | null;
|
|
413
|
-
/** The earliest `exp` across the invocation's whole delegation chain. */
|
|
414
|
-
expiresAt: string | null;
|
|
415
|
-
/**
|
|
416
|
-
* The earliest `exp` across a valid retention grant's own chain. `null`
|
|
417
|
-
* means no retention: none was presented, or its chain sets no expiry.
|
|
418
|
-
*/
|
|
419
|
-
retainUntil: string | null;
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* One page of the `tinycloud.kv/sync` change feed.
|
|
423
|
-
*/
|
|
424
|
-
interface KVChangesResponse {
|
|
425
|
-
/** Each changed key's latest state, in commit order. */
|
|
426
|
-
changes: KVChange[];
|
|
427
|
-
/**
|
|
428
|
-
* More changes are available now. A page may be empty with `more: true`;
|
|
429
|
-
* keep paging with the returned cursor.
|
|
430
|
-
*/
|
|
431
|
-
more: boolean;
|
|
432
|
-
/**
|
|
433
|
-
* The cursor for the next request. An empty poll returns the request's
|
|
434
|
-
* cursor unchanged.
|
|
435
|
-
*/
|
|
436
|
-
cursor: string;
|
|
437
|
-
/** The node, space and prefix that served the page. */
|
|
438
|
-
source: {
|
|
439
|
-
nodeDid: string;
|
|
440
|
-
space: string;
|
|
441
|
-
prefix: string;
|
|
442
|
-
};
|
|
443
|
-
authority: KVChangesAuthority;
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Response from signed KV read URL creation.
|
|
447
|
-
*/
|
|
448
|
-
interface KVSignedReadUrlResponse {
|
|
449
|
-
/**
|
|
450
|
-
* Absolute URL suitable for passing to external readers.
|
|
451
|
-
*/
|
|
452
|
-
url: string;
|
|
453
|
-
/**
|
|
454
|
-
* Opaque URL returned by tinycloud-node, usually relative to the node host.
|
|
455
|
-
*/
|
|
456
|
-
relativeUrl: string;
|
|
457
|
-
/**
|
|
458
|
-
* Opaque signed KV ticket identifier.
|
|
459
|
-
*/
|
|
460
|
-
ticketId: string;
|
|
461
|
-
/**
|
|
462
|
-
* Expiry timestamp as returned by tinycloud-node.
|
|
463
|
-
*/
|
|
464
|
-
expiresAt: string;
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* KV service action types.
|
|
468
|
-
*/
|
|
469
|
-
declare const KVAction: {
|
|
470
|
-
readonly GET: "tinycloud.kv/get";
|
|
471
|
-
readonly PUT: "tinycloud.kv/put";
|
|
472
|
-
readonly LIST: "tinycloud.kv/list";
|
|
473
|
-
readonly DELETE: "tinycloud.kv/del";
|
|
474
|
-
readonly HEAD: "tinycloud.kv/metadata";
|
|
475
|
-
/** The change feed; never implied by `*` or `tinycloud.kv/*`. */
|
|
476
|
-
readonly SYNC: "tinycloud.kv/sync";
|
|
477
|
-
/** Retention attestation; presented through `retentionGrant`, never invoked or implied. */
|
|
478
|
-
readonly RETAIN: "tinycloud.kv/retain";
|
|
479
|
-
};
|
|
480
|
-
type KVActionType = (typeof KVAction)[keyof typeof KVAction];
|
|
481
|
-
|
|
482
|
-
interface ReplicationIdentity {
|
|
483
|
-
/** Canonical HTTP(S) URL: origin + path without trailing slash; no credentials/query/fragment. */
|
|
484
|
-
host: string;
|
|
485
|
-
/** Full TinyCloud space id; only the EIP-155 address segment is lower-cased. */
|
|
486
|
-
space: string;
|
|
487
|
-
/** Principal `did:pkh:eip155:…`; only the EIP-155 address segment is lower-cased. */
|
|
488
|
-
principal: string;
|
|
489
|
-
}
|
|
490
|
-
type ReplicaCoverage = "empty" | "bootstrapping" | "complete";
|
|
491
|
-
type ReplicaAuthorityState = "valid" | "expired" | "revoked" | "not-yet-valid";
|
|
492
|
-
interface LocalReadMeta {
|
|
493
|
-
asOf: string | null;
|
|
494
|
-
coverage: ReplicaCoverage;
|
|
495
|
-
authority: ReplicaAuthorityState;
|
|
496
|
-
/** Durable identity commit epoch captured before the last successful sync began. */
|
|
497
|
-
syncedThroughEpoch: number;
|
|
498
|
-
}
|
|
499
|
-
type LocalGetResult = {
|
|
500
|
-
status: "present";
|
|
501
|
-
key: string;
|
|
502
|
-
value: Uint8Array;
|
|
503
|
-
etag: string;
|
|
504
|
-
metadata: Record<string, string>;
|
|
505
|
-
meta: LocalReadMeta;
|
|
506
|
-
} | {
|
|
507
|
-
status: "content_missing";
|
|
508
|
-
key: string;
|
|
509
|
-
etag: string;
|
|
510
|
-
metadata: Record<string, string>;
|
|
511
|
-
meta: LocalReadMeta;
|
|
512
|
-
} | {
|
|
513
|
-
status: "deleted" | "absent" | "coverage_incomplete" | "not_covered";
|
|
514
|
-
key: string;
|
|
515
|
-
meta: LocalReadMeta;
|
|
516
|
-
};
|
|
517
|
-
/** Live keys under a plain `startsWith` prefix, after-exclusive UTF-8 byte ordering, at most limit. */
|
|
518
|
-
interface LocalListResult {
|
|
519
|
-
keys: string[];
|
|
520
|
-
meta: LocalReadMeta;
|
|
521
|
-
}
|
|
522
|
-
type LocalSyncResult = {
|
|
523
|
-
status: "synced";
|
|
524
|
-
pages: number;
|
|
525
|
-
changes: number;
|
|
526
|
-
deleted: number;
|
|
527
|
-
fetched: number;
|
|
528
|
-
contentMissing: number;
|
|
529
|
-
coverage: ReplicaCoverage;
|
|
530
|
-
/** The input syncStartEpoch, persisted atomically only when this sync succeeds. */
|
|
531
|
-
syncedThroughEpoch: number;
|
|
532
|
-
} | {
|
|
533
|
-
status: "busy";
|
|
534
|
-
};
|
|
535
|
-
interface ReplicaGrantInfo {
|
|
536
|
-
cid: string;
|
|
537
|
-
parentCid: string | null;
|
|
538
|
-
expiresAt: number | null;
|
|
539
|
-
/** Grant lifecycle: pending until confirmed/activated by a successful replica sync. */
|
|
540
|
-
state: "active" | "pending";
|
|
541
|
-
/** Both get and sync in the grant carry no caveats. */
|
|
542
|
-
unconstrained: boolean;
|
|
543
|
-
}
|
|
544
|
-
interface LocalReplicaStatus {
|
|
545
|
-
coverage: ReplicaCoverage;
|
|
546
|
-
lastSyncAt: string | null;
|
|
547
|
-
/** Durable identity commit epoch captured before the last successful sync began. */
|
|
548
|
-
syncedThroughEpoch: number;
|
|
549
|
-
authority: {
|
|
550
|
-
state: ReplicaAuthorityState;
|
|
551
|
-
expiresAt: string | null;
|
|
552
|
-
};
|
|
553
|
-
grant: ReplicaGrantInfo | null;
|
|
554
|
-
counts: {
|
|
555
|
-
keys: number;
|
|
556
|
-
contentMissing: number;
|
|
557
|
-
tombstones: number;
|
|
558
|
-
};
|
|
559
|
-
bytes: number;
|
|
560
|
-
lastError: {
|
|
561
|
-
at: string;
|
|
562
|
-
code: string;
|
|
563
|
-
message: string;
|
|
564
|
-
} | null;
|
|
565
|
-
}
|
|
566
|
-
interface ReplicaDevice {
|
|
567
|
-
did: string;
|
|
568
|
-
jwk: object;
|
|
569
|
-
}
|
|
570
|
-
/** Identity is canonical; `space` is the session's verbatim space id for replica calls. */
|
|
571
|
-
interface KVReplicaSpec {
|
|
572
|
-
identity: ReplicationIdentity;
|
|
573
|
-
space: string;
|
|
574
|
-
prefix: string;
|
|
575
|
-
allowSecrets: boolean;
|
|
576
|
-
/**
|
|
577
|
-
* When present, adapters MUST use this device for partition naming, grant audience checks,
|
|
578
|
-
* and signing sync requests; they MUST NOT load or create their own device key for this handle.
|
|
579
|
-
*/
|
|
580
|
-
device?: ReplicaDevice;
|
|
581
|
-
/** Graph-scoped fetch for main-thread adapters; worker adapters ignore it. */
|
|
582
|
-
fetch?: FetchFunction;
|
|
583
|
-
}
|
|
584
|
-
interface KVReplicaHandle {
|
|
585
|
-
readonly spec: KVReplicaSpec;
|
|
586
|
-
/** Always equals `spec.device.did` when an explicit device was provided. */
|
|
587
|
-
readonly deviceDid: string;
|
|
588
|
-
get(key: string): Promise<LocalGetResult>;
|
|
589
|
-
list(o: {
|
|
590
|
-
prefix: string;
|
|
591
|
-
after?: string;
|
|
592
|
-
limit?: number;
|
|
593
|
-
}): Promise<LocalListResult>;
|
|
594
|
-
grant(): Promise<ReplicaGrantInfo | null>;
|
|
595
|
-
installGrant(ucan: string): Promise<ReplicaGrantInfo>;
|
|
596
|
-
/**
|
|
597
|
-
* The controller supplies syncStartEpoch, captured from this identity's committedEpoch before
|
|
598
|
-
* starting the sync. Every adapter, including the browser worker, MUST persist that exact epoch
|
|
599
|
-
* atomically with the successful replica sync; failed and busy syncs MUST leave the prior fence
|
|
600
|
-
* unchanged. A successful result returns that persisted value as syncedThroughEpoch.
|
|
601
|
-
*/
|
|
602
|
-
sync(o: {
|
|
603
|
-
signal: AbortSignal;
|
|
604
|
-
syncStartEpoch: number;
|
|
605
|
-
}): Promise<LocalSyncResult>;
|
|
606
|
-
/** Status reports the durable syncedThroughEpoch, including after reopening this handle. */
|
|
607
|
-
status(): Promise<LocalReplicaStatus>;
|
|
608
|
-
/** Cancels and awaits in-flight syncs before closing. */
|
|
609
|
-
close(): Promise<void>;
|
|
610
|
-
}
|
|
611
|
-
interface PurgeTarget {
|
|
612
|
-
identity: ReplicationIdentity;
|
|
613
|
-
/** Verbatim session space id used by the corresponding replica handle. */
|
|
614
|
-
space: string;
|
|
615
|
-
prefix: string;
|
|
616
|
-
/** Session device in delegate posture, when one is used. */
|
|
617
|
-
sessionDeviceDid?: string;
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* Replica persistence adapters. B-node's Node/CLI adapter MUST provide durable pending state.
|
|
621
|
-
* If that state cannot be opened (for example, a file-store failure), it MUST surface the
|
|
622
|
-
* unavailable/error to the controller; the controller MUST fail closed to network reads and
|
|
623
|
-
* MUST NOT silently substitute memory.
|
|
624
|
-
*/
|
|
625
|
-
interface KVReplicaStorage {
|
|
626
|
-
readonly kind: "sqlite" | "indexeddb";
|
|
627
|
-
open(spec: KVReplicaSpec): Promise<KVReplicaHandle>;
|
|
628
|
-
/**
|
|
629
|
-
* Read an existing replica's durable status without creating or mutating storage or waiting
|
|
630
|
-
* for a mutation guard. Missing replicas return undefined. Implementations must honor abort.
|
|
631
|
-
*/
|
|
632
|
-
inspectStatus?(spec: KVReplicaSpec, options: {
|
|
633
|
-
signal: AbortSignal;
|
|
634
|
-
}): Promise<LocalReplicaStatus | undefined>;
|
|
635
|
-
/**
|
|
636
|
-
* Erases replicas for the identity and prefix across the deduplicated union of the adapter's
|
|
637
|
-
* stored device (if any) and `sessionDeviceDid`. A missing stored device never skips the
|
|
638
|
-
* session-device purge. Does not open, mint, or sync. Erasure removes entries, blobs, grant,
|
|
639
|
-
* config, and authority; earlier handles reject with RESET_REQUIRED. A contentless tombstone
|
|
640
|
-
* may remain. Rejects with an error carrying `code` on failure.
|
|
641
|
-
*/
|
|
642
|
-
purge(target: PurgeTarget): Promise<void>;
|
|
643
|
-
/**
|
|
644
|
-
* Optional only for volatile runtimes. Omission means an in-memory store with `durable: false`.
|
|
645
|
-
* B-node's Node/CLI adapter MUST provide a durable store and surface open failures, never
|
|
646
|
-
* silently fall back to memory.
|
|
647
|
-
*/
|
|
648
|
-
pendingWrites?(identity: ReplicationIdentity): PendingWriteStore;
|
|
649
|
-
}
|
|
650
|
-
interface PendingWriteRecord {
|
|
651
|
-
opId: string;
|
|
652
|
-
seq: number;
|
|
653
|
-
key: string;
|
|
654
|
-
op: "put" | "delete";
|
|
655
|
-
state: "in_flight" | "committed" | "ambiguous";
|
|
656
|
-
epoch: number | null;
|
|
657
|
-
at: string;
|
|
658
|
-
settledAt: string | null;
|
|
659
|
-
code?: string;
|
|
660
|
-
}
|
|
661
|
-
/** One identity-scoped pending state, with a monotonically increasing commit epoch and sequence. */
|
|
662
|
-
interface PendingWriteState {
|
|
663
|
-
v: 2;
|
|
664
|
-
identity: ReplicationIdentity;
|
|
665
|
-
committedEpoch: number;
|
|
666
|
-
seq: number;
|
|
667
|
-
records: PendingWriteRecord[];
|
|
668
|
-
}
|
|
669
|
-
/** Identity-scoped pending state and its restart-durability guarantee. */
|
|
670
|
-
interface PendingWriteStore {
|
|
671
|
-
/**
|
|
672
|
-
* True only when committedEpoch and all records survive process restarts; false for memory or
|
|
673
|
-
* other volatile stores.
|
|
674
|
-
*/
|
|
675
|
-
readonly durable: boolean;
|
|
676
|
-
readonly identity: ReplicationIdentity;
|
|
677
|
-
/** Consistent lock-free snapshot, e.g. a read of an atomic file replacement. */
|
|
678
|
-
read(): Promise<PendingWriteState>;
|
|
679
|
-
/** Read an existing durable snapshot without initializing storage; undefined means no file exists. */
|
|
680
|
-
readExisting?(): Promise<PendingWriteState | undefined>;
|
|
681
|
-
/** Serialized read-modify-write; durable stores persist before resolve. Errors on mismatch/failure. */
|
|
682
|
-
update<T>(mutate: (s: PendingWriteState) => T): Promise<T>;
|
|
683
|
-
}
|
|
684
|
-
type AuthorityRefusal = {
|
|
685
|
-
refused: "NOT_COVERED" | "CAVEATED_AUTHORITY" | "SESSION_EXPIRING";
|
|
686
|
-
};
|
|
687
|
-
interface ReplicationAuthority {
|
|
688
|
-
/**
|
|
689
|
-
* Restrict this authority to the current session's grant. When true, the controller MUST NOT
|
|
690
|
-
* consult the plan, mint a grant, or treat an installed storage grant as serving authority.
|
|
691
|
-
*/
|
|
692
|
-
sessionOnly?: boolean;
|
|
693
|
-
sessionGrant(prefix: string): {
|
|
694
|
-
ucan: string;
|
|
695
|
-
device: ReplicaDevice;
|
|
696
|
-
} | AuthorityRefusal;
|
|
697
|
-
plan(prefix: string): {
|
|
698
|
-
path: "session" | "runtime";
|
|
699
|
-
parentCid: string;
|
|
700
|
-
expiresAt: number;
|
|
701
|
-
} | AuthorityRefusal;
|
|
702
|
-
mint(deviceDid: string, prefix: string, signal: AbortSignal): Promise<{
|
|
703
|
-
ucan: string;
|
|
704
|
-
parentCid: string;
|
|
705
|
-
expiresAt: number;
|
|
706
|
-
}>;
|
|
707
|
-
}
|
|
708
|
-
interface ReplicationScheduler {
|
|
709
|
-
now(): number;
|
|
710
|
-
setTimeout(fn: () => void, ms: number): () => void;
|
|
711
|
-
}
|
|
712
|
-
interface KVReplicationDeps {
|
|
713
|
-
options: ResolvedReplicationOptions;
|
|
714
|
-
mode: "background" | "foreground";
|
|
715
|
-
storage: KVReplicaStorage;
|
|
716
|
-
identity: ReplicationIdentity;
|
|
717
|
-
session: {
|
|
718
|
-
id: string;
|
|
719
|
-
did: string;
|
|
720
|
-
space: string;
|
|
721
|
-
};
|
|
722
|
-
authority: ReplicationAuthority;
|
|
723
|
-
/**
|
|
724
|
-
* The controller MUST enforce the catch-up trust invariant. With durable pending state,
|
|
725
|
-
* committedEpoch and records survive restarts, so the syncedThroughEpoch fence applies normally.
|
|
726
|
-
* With non-durable state, a replica may serve local reads only after a successful sync that
|
|
727
|
-
* started in this process after this store was created. Until then, every read MUST use the
|
|
728
|
-
* network with REPLICA_UNPROVEN_SINCE_START; an older durable syncedThroughEpoch is not proof
|
|
729
|
-
* after restart. Pending-state failures also fail closed to network reads.
|
|
730
|
-
*/
|
|
731
|
-
pending: PendingWriteStore;
|
|
732
|
-
/** Node `/info` features discovered on sign-in for protocol gating. */
|
|
733
|
-
nodeFeatures?: readonly string[];
|
|
734
|
-
scheduler: ReplicationScheduler;
|
|
735
|
-
emit(event: ReplicationEvent): void;
|
|
736
|
-
fetch?: FetchFunction;
|
|
737
|
-
previous?: Promise<void>;
|
|
738
|
-
}
|
|
739
|
-
interface KVListPage {
|
|
740
|
-
keys: string[];
|
|
741
|
-
truncated?: boolean;
|
|
742
|
-
nextCursor?: string;
|
|
743
|
-
}
|
|
744
|
-
interface KVReadThrough {
|
|
745
|
-
/** The callback executes the complete existing network implementation under the caller's signal. */
|
|
746
|
-
get<T>(r: {
|
|
747
|
-
space: string;
|
|
748
|
-
key: string;
|
|
749
|
-
path: string;
|
|
750
|
-
options: KVGetOptions | undefined;
|
|
751
|
-
signal: AbortSignal;
|
|
752
|
-
network: () => Promise<Result<KVResponse<T>>>;
|
|
753
|
-
}): Promise<Result<KVResponse<T>>>;
|
|
754
|
-
list(r: {
|
|
755
|
-
space: string;
|
|
756
|
-
listPath: string;
|
|
757
|
-
options: KVListOptions | undefined;
|
|
758
|
-
signal: AbortSignal;
|
|
759
|
-
network: () => Promise<Result<KVListPage>>;
|
|
760
|
-
}): Promise<Result<KVListPage>>;
|
|
761
|
-
write<T>(r: {
|
|
762
|
-
op: "put" | "delete" | "batchPut";
|
|
763
|
-
space: string;
|
|
764
|
-
entries: ReadonlyArray<{
|
|
765
|
-
path: string;
|
|
766
|
-
body?: Blob | string;
|
|
767
|
-
}>;
|
|
768
|
-
signal: AbortSignal;
|
|
769
|
-
conditional?: boolean;
|
|
770
|
-
network: () => Promise<Result<T>>;
|
|
771
|
-
}): Promise<Result<T>>;
|
|
772
|
-
/**
|
|
773
|
-
* Best-effort observation for a caller-forced network read, invoked after it settles. This
|
|
774
|
-
* synchronous event hook MUST NOT read replica storage or start a sync. KVService catches and
|
|
775
|
-
* ignores thrown errors so the observation cannot change the network read.
|
|
776
|
-
*/
|
|
777
|
-
observeNetworkRequested(r: {
|
|
778
|
-
op: "get" | "list";
|
|
779
|
-
space: string;
|
|
780
|
-
/** Absolute get path, or the fully resolved list path. */
|
|
781
|
-
path: string;
|
|
782
|
-
reason: "NETWORK_REQUESTED";
|
|
783
|
-
outcome: "found" | "not_found" | "error";
|
|
784
|
-
latencyMs: number;
|
|
785
|
-
}): void;
|
|
786
|
-
}
|
|
787
|
-
interface KVReplicationController extends KVReadThrough {
|
|
788
|
-
status(): Promise<ReplicaStatusEntry[]>;
|
|
789
|
-
sync(o?: {
|
|
790
|
-
prefix?: string;
|
|
791
|
-
signal?: AbortSignal;
|
|
792
|
-
}): Promise<void>;
|
|
793
|
-
/** Not async: synchronously stops timers/syncs and blocks new local opens before returning its promise. */
|
|
794
|
-
purge(o?: {
|
|
795
|
-
timeoutMs?: number;
|
|
796
|
-
}): Promise<ReplicationPurgeReport>;
|
|
797
|
-
clearPending(): Promise<number>;
|
|
798
|
-
/** Synchronously aborts syncs; resolves after settlement and handle closure. */
|
|
799
|
-
close(): Promise<void>;
|
|
800
|
-
}
|
|
801
|
-
interface ReplicationControl {
|
|
802
|
-
status(): Promise<ReplicaStatusEntry[]>;
|
|
803
|
-
sync(o?: {
|
|
804
|
-
prefix?: string;
|
|
805
|
-
}): Promise<void>;
|
|
806
|
-
/**
|
|
807
|
-
* Synchronous stop phase; promise never rejects. Awaits aborted syncs (bounded by timeout),
|
|
808
|
-
* closes handles, purges every configured prefix of the bound/last identity, and clears only
|
|
809
|
-
* records beneath successfully purged prefixes. Failures are returned and emitted.
|
|
810
|
-
*/
|
|
811
|
-
purge(o?: {
|
|
812
|
-
timeoutMs?: number;
|
|
813
|
-
}): Promise<ReplicationPurgeReport>;
|
|
814
|
-
/**
|
|
815
|
-
* Removes all ambiguous records and in-flight records older than ten minutes; younger in-flight
|
|
816
|
-
* and committed records remain. Exposed callers MUST show CLEAR_PENDING_WARNING first.
|
|
817
|
-
*/
|
|
818
|
-
clearPending(): Promise<number>;
|
|
819
|
-
close(): Promise<void>;
|
|
820
|
-
}
|
|
821
|
-
interface ReplicationOptions {
|
|
822
|
-
enabled: boolean;
|
|
823
|
-
/** Non-empty list of folder prefixes ending in `/`, or `/` for the whole space. */
|
|
824
|
-
prefixes: string[];
|
|
825
|
-
/** Required for prefixes/spaces where requiresSecretsOptIn returns true. */
|
|
826
|
-
allowSecrets?: boolean;
|
|
827
|
-
/** Background interval; default 60 seconds. */
|
|
828
|
-
syncIntervalMs?: number;
|
|
829
|
-
maxStalenessMs?: number;
|
|
830
|
-
staleSyncTimeoutMs?: number;
|
|
831
|
-
verify?: boolean;
|
|
832
|
-
onEvent?: (event: ReplicationEvent) => void;
|
|
833
|
-
}
|
|
834
|
-
interface ResolvedReplicationOptions extends ReplicationOptions {
|
|
835
|
-
syncIntervalMs: number;
|
|
836
|
-
maxStalenessMs: number;
|
|
837
|
-
staleSyncTimeoutMs: number;
|
|
838
|
-
allowSecrets: boolean;
|
|
839
|
-
verify: boolean;
|
|
840
|
-
}
|
|
841
|
-
interface ReplicationPurgeReport {
|
|
842
|
-
purged: string[];
|
|
843
|
-
failed: Array<{
|
|
844
|
-
prefix: string;
|
|
845
|
-
code: string;
|
|
846
|
-
}>;
|
|
847
|
-
}
|
|
848
|
-
interface PinnedKey {
|
|
849
|
-
key: string;
|
|
850
|
-
state: "in_flight" | "ambiguous";
|
|
851
|
-
op: "put" | "delete";
|
|
852
|
-
since: string;
|
|
853
|
-
code?: string;
|
|
854
|
-
likelyOrphaned: boolean;
|
|
855
|
-
}
|
|
856
|
-
interface ReplicaStatusEntry extends Partial<LocalReplicaStatus> {
|
|
857
|
-
prefix: string;
|
|
858
|
-
state: ReplicaState;
|
|
859
|
-
reason?: ReplicationReason;
|
|
860
|
-
errorCode?: string;
|
|
861
|
-
pending: {
|
|
862
|
-
inFlight: number;
|
|
863
|
-
committed: number;
|
|
864
|
-
ambiguous: number;
|
|
865
|
-
};
|
|
866
|
-
pinned: PinnedKey[];
|
|
867
|
-
lagMs: number | null;
|
|
868
|
-
}
|
|
869
|
-
type ReplicaState = "idle" | "ready" | "grant_missing" | "runtime_unsupported" | "unavailable" | "revoked" | "closed";
|
|
870
|
-
type ReplicationReason = "hit" | "absent" | "deleted" | "content_missing" | "coverage_incomplete" | "not_covered" | "pending_write" | "grant_missing" | "grant_expired" | "grant_revoked" | "grant_not_yet_valid" | "stale" | "replica_error" | "runtime_unsupported" | "replica_unavailable" | "unsupported_option" | "network_cursor" | "cursor_restart" | "aborted" | "REPLICA_BEHIND_OWN_WRITES" | "REPLICA_UNPROVEN_SINCE_START" | "NETWORK_REQUESTED";
|
|
871
|
-
type ReplicationEvent = {
|
|
872
|
-
type: "replication.read";
|
|
873
|
-
at: string;
|
|
874
|
-
op: "get" | "list";
|
|
875
|
-
space: string;
|
|
876
|
-
key: string;
|
|
877
|
-
replica: string | null;
|
|
878
|
-
source: "replica" | "network" | "none";
|
|
879
|
-
reason: ReplicationReason;
|
|
880
|
-
outcome: "found" | "not_found" | "error";
|
|
881
|
-
latencyMs: number;
|
|
882
|
-
stalenessMs: number | null;
|
|
883
|
-
coverage: ReplicaCoverage | null;
|
|
884
|
-
authority: ReplicaAuthorityState | null;
|
|
885
|
-
code?: string;
|
|
886
|
-
syncError?: string;
|
|
887
|
-
syncedBeforeRead?: boolean;
|
|
888
|
-
pendingState?: "in_flight" | "committed" | "ambiguous";
|
|
889
|
-
verify?: "match" | "diverged" | "error" | "aborted";
|
|
890
|
-
count?: number;
|
|
891
|
-
} | {
|
|
892
|
-
type: "replication.write";
|
|
893
|
-
at: string;
|
|
894
|
-
op: "put" | "delete" | "batchPut";
|
|
895
|
-
space: string;
|
|
896
|
-
keys: string[];
|
|
897
|
-
outcome: "committed" | "failed" | "ambiguous";
|
|
898
|
-
code?: string;
|
|
899
|
-
latencyMs: number;
|
|
900
|
-
} | {
|
|
901
|
-
type: "replication.sync";
|
|
902
|
-
at: string;
|
|
903
|
-
space: string;
|
|
904
|
-
replica: string;
|
|
905
|
-
trigger: "start" | "interval" | "stale_read" | "manual";
|
|
906
|
-
outcome: "ok" | "busy" | "error" | "aborted";
|
|
907
|
-
class?: "offline" | "authority" | "storage" | "node";
|
|
908
|
-
code?: string;
|
|
909
|
-
durationMs: number;
|
|
910
|
-
lagMs: number | null;
|
|
911
|
-
pendingCleared?: number;
|
|
912
|
-
pages?: number;
|
|
913
|
-
changes?: number;
|
|
914
|
-
deleted?: number;
|
|
915
|
-
fetched?: number;
|
|
916
|
-
contentMissing?: number;
|
|
917
|
-
coverage?: ReplicaCoverage;
|
|
918
|
-
} | {
|
|
919
|
-
type: "replication.state";
|
|
920
|
-
at: string;
|
|
921
|
-
space?: string;
|
|
922
|
-
replica?: string;
|
|
923
|
-
state: "opened" | "grant_installed" | "grant_missing" | "runtime_unsupported" | "unavailable" | "revoked" | "recreated" | "purged" | "purge_failed" | "pending_store_error" | "pinned" | "pending_cleared" | "closed";
|
|
924
|
-
code?: string;
|
|
925
|
-
strategy?: "session" | "minted" | "installed";
|
|
926
|
-
count?: number;
|
|
927
|
-
keys?: string[];
|
|
928
|
-
} | {
|
|
929
|
-
type: "replication.divergence";
|
|
930
|
-
at: string;
|
|
931
|
-
op: "get" | "list";
|
|
932
|
-
space: string;
|
|
933
|
-
key: string;
|
|
934
|
-
replica: string;
|
|
935
|
-
kind: "value" | "missing_local" | "extra_local" | "keys" | "order";
|
|
936
|
-
localEtag?: string | null;
|
|
937
|
-
networkEtag?: string | null;
|
|
938
|
-
localOnly?: string[];
|
|
939
|
-
networkOnly?: string[];
|
|
940
|
-
stalenessMs: number | null;
|
|
941
|
-
};
|
|
942
|
-
|
|
943
|
-
declare const CLEAR_PENDING_WARNING = "Clearing pending writes surrenders read-your-writes protection for the cleared keys. If a write whose record was cleared had an unknown outcome or never finished, it may commit now or later; this device can serve an older value until the next sync after that commit, as it would for a write from another device.";
|
|
944
|
-
|
|
945
|
-
/**
|
|
946
|
-
* Pure canonicalization: lower-cases only EIP-155 address segments and preserves all other
|
|
947
|
-
* space/principal bytes. Rejects non-HTTP(S) hosts, credentials, query/fragment, and non-full
|
|
948
|
-
* TinyCloud space ids or non-pkh principals.
|
|
949
|
-
*/
|
|
950
|
-
declare function canonicalReplicationIdentity(raw: ReplicationIdentity): ReplicationIdentity;
|
|
951
|
-
/** Stable in-memory key; durable adapters hash its UTF-8 bytes with their platform crypto. */
|
|
952
|
-
declare function replicationIdentityKey(id: ReplicationIdentity): string;
|
|
953
|
-
|
|
954
|
-
/** Whether replicating this space/prefix can copy encrypted secret material to disk. */
|
|
955
|
-
declare function requiresSecretsOptIn(space: string, prefix: string): boolean;
|
|
956
|
-
|
|
957
|
-
export { type KVListResponse as $, type AuthorityRefusal as A, type ReplicationScheduler as B, CLEAR_PENDING_WARNING as C, type ResolvedReplicationOptions as D, canonicalReplicationIdentity as E, replicationIdentityKey as F, requiresSecretsOptIn as G, DEFAULT_SIGNED_READ_URL_EXPIRY_MS as H, KVAction as I, type KVActionType as J, type KVReplicationDeps as K, type LocalGetResult as L, type KVBatchPutItem as M, type KVBatchPutOptions as N, type KVBatchPutResponse as O, type PendingWriteStore as P, type KVBatchReadResponse as Q, type ReplicationIdentity as R, type KVChange as S, type KVChangesAuthority as T, type KVChangesOptions as U, type KVChangesResponse as V, type KVCreateSignedReadUrlOptions as W, type KVDeleteOptions as X, type KVGetOptions as Y, type KVHeadOptions as Z, type KVListOptions as _, type KVReplicationController as a, type KVPutOptions as a0, type KVResponse as a1, type KVResponseHeaders as a2, type KVServiceConfig as a3, type KVSignedReadUrlResponse as a4, type KVListPage as b, type KVReadThrough as c, type KVReplicaHandle as d, type KVReplicaSpec as e, type KVReplicaStorage as f, type LocalListResult as g, type LocalReadMeta as h, type LocalReplicaStatus as i, type LocalSyncResult as j, type PendingWriteRecord as k, type PendingWriteState as l, type PinnedKey as m, type PurgeTarget as n, type ReplicaAuthorityState as o, type ReplicaCoverage as p, type ReplicaDevice as q, type ReplicaGrantInfo as r, type ReplicaState as s, type ReplicaStatusEntry as t, type ReplicationAuthority as u, type ReplicationControl as v, type ReplicationEvent as w, type ReplicationOptions as x, type ReplicationPurgeReport as y, type ReplicationReason as z };
|