@crvouga/mockingbird-service-google-calendar 2.2.0 → 2.3.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/CHANGELOG.md +22 -1
- package/dist/chunk-QOKTCQ7O.js +4672 -0
- package/dist/chunk-QOKTCQ7O.js.map +7 -0
- package/dist/{chunk-74NKRZ5I.js → chunk-XR34BTZM.js} +2 -2
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +149 -145
- package/dist/index.js +1 -1
- package/dist/server.d.ts +281 -273
- package/dist/server.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-ULHPKJB6.js +0 -4617
- package/dist/chunk-ULHPKJB6.js.map +0 -7
- /package/dist/{chunk-74NKRZ5I.js.map → chunk-XR34BTZM.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createRuntime,
|
|
4
4
|
parseDuration,
|
|
5
5
|
resolveAdminPrefix
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QOKTCQ7O.js";
|
|
7
7
|
|
|
8
8
|
// ../../adapters/node/dist/cli.js
|
|
9
9
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
@@ -848,4 +848,4 @@ export {
|
|
|
848
848
|
createServer2 as createServer,
|
|
849
849
|
serveTarget
|
|
850
850
|
};
|
|
851
|
-
//# sourceMappingURL=chunk-
|
|
851
|
+
//# sourceMappingURL=chunk-XR34BTZM.js.map
|
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -10,36 +10,6 @@ interface FetchAPI$1 {
|
|
|
10
10
|
fetch(request: Request): Promise<Response>;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* The single source of time for a service.
|
|
15
|
-
*
|
|
16
|
-
* Every timestamp a mock writes reads from here, so a suite moves time instead of
|
|
17
|
-
* sleeping: appointment windows, result delays and expiries become reachable in
|
|
18
|
-
* milliseconds. A frozen clock also makes timestamps reproducible from a seed.
|
|
19
|
-
*/
|
|
20
|
-
type ClockState = {
|
|
21
|
-
/** Current epoch milliseconds. */
|
|
22
|
-
now: number;
|
|
23
|
-
/** True while time does not advance on its own. */
|
|
24
|
-
frozen: boolean;
|
|
25
|
-
/** Milliseconds this clock adds to its underlying source. */
|
|
26
|
-
offsetMs: number;
|
|
27
|
-
};
|
|
28
|
-
type Clock = {
|
|
29
|
-
now(): number;
|
|
30
|
-
/** Pin the clock to an exact instant, keeping it frozen if it already was. */
|
|
31
|
-
set(epochMs: number): void;
|
|
32
|
-
/** Move the clock forward, or back with a negative delta. */
|
|
33
|
-
advance(deltaMs: number): void;
|
|
34
|
-
/** Stop time at the current instant. */
|
|
35
|
-
freeze(): void;
|
|
36
|
-
/** Resume from the current instant. */
|
|
37
|
-
unfreeze(): void;
|
|
38
|
-
/** Drop back to the underlying source, live. */
|
|
39
|
-
reset(): void;
|
|
40
|
-
state(): ClockState;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
13
|
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
44
14
|
type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
|
|
45
15
|
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
@@ -111,6 +81,151 @@ declare class Collection<T> {
|
|
|
111
81
|
}>;
|
|
112
82
|
}
|
|
113
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
86
|
+
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
87
|
+
*/
|
|
88
|
+
declare class IdSequence {
|
|
89
|
+
private readonly sqlite;
|
|
90
|
+
private readonly namespace;
|
|
91
|
+
private readonly salt;
|
|
92
|
+
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
93
|
+
next(prefix: string, length?: number): string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** A stable identifier for a point in a {@link Timeline}. */
|
|
97
|
+
type CheckpointId = string;
|
|
98
|
+
/** An immutable node in a timeline's checkpoint DAG. */
|
|
99
|
+
type Checkpoint<T> = Readonly<{
|
|
100
|
+
id: CheckpointId;
|
|
101
|
+
branch: string;
|
|
102
|
+
parent: CheckpointId | null;
|
|
103
|
+
/** Logical time supplied by the timeline's injected clock. */
|
|
104
|
+
at: number;
|
|
105
|
+
value: T;
|
|
106
|
+
}>;
|
|
107
|
+
type TimelineOptions = {
|
|
108
|
+
/** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
|
|
109
|
+
now?: () => number;
|
|
110
|
+
/** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
|
|
111
|
+
maxCheckpoints?: number;
|
|
112
|
+
/** Customize deterministic checkpoint IDs. */
|
|
113
|
+
id?: (sequence: number) => CheckpointId;
|
|
114
|
+
};
|
|
115
|
+
type CommitOptions = {
|
|
116
|
+
branch?: string;
|
|
117
|
+
/** Parent checkpoint. Defaults to the selected branch's current head. */
|
|
118
|
+
parent?: CheckpointId | null;
|
|
119
|
+
};
|
|
120
|
+
type ForkOptions = {
|
|
121
|
+
/** Checkpoint to fork from. Defaults to the main branch's head. */
|
|
122
|
+
from?: CheckpointId;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
|
|
126
|
+
* records, namespace images, or copy-on-write SQL engine snapshots.
|
|
127
|
+
*
|
|
128
|
+
* Values are retained by reference. Engines can therefore use persistent/COW snapshots while
|
|
129
|
+
* simpler services can use immutable values. IDs and GC order are deterministic, and all IO
|
|
130
|
+
* (the logical clock) is injected.
|
|
131
|
+
*/
|
|
132
|
+
declare class Timeline<T> {
|
|
133
|
+
readonly maxCheckpoints: number;
|
|
134
|
+
private readonly now;
|
|
135
|
+
private readonly makeId;
|
|
136
|
+
private readonly nodes;
|
|
137
|
+
private readonly heads;
|
|
138
|
+
/** Unreferenced nodes in the exact order they became collectible. */
|
|
139
|
+
private readonly evictable;
|
|
140
|
+
/** Branch heads plus explicit retainers. Absent means zero. */
|
|
141
|
+
private readonly references;
|
|
142
|
+
private readonly explicitPins;
|
|
143
|
+
private sequence;
|
|
144
|
+
constructor(options?: TimelineOptions);
|
|
145
|
+
/** Capture a new immutable value and move `branch` to it. */
|
|
146
|
+
commit(value: T, options?: CommitOptions): Checkpoint<T>;
|
|
147
|
+
/** Create a branch pointer without copying its checkpoint value. */
|
|
148
|
+
fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
|
|
149
|
+
/** Move a branch pointer to an existing checkpoint. */
|
|
150
|
+
checkout(branch: string, id: CheckpointId): Checkpoint<T>;
|
|
151
|
+
get(id: CheckpointId): Checkpoint<T>;
|
|
152
|
+
head(branch?: string): Checkpoint<T> | undefined;
|
|
153
|
+
hasBranch(branch: string): boolean;
|
|
154
|
+
branches(): Readonly<Record<string, CheckpointId>>;
|
|
155
|
+
checkpoints(): readonly Checkpoint<T>[];
|
|
156
|
+
/** Number of retained checkpoints without allocating an array. */
|
|
157
|
+
get size(): number;
|
|
158
|
+
/** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
|
|
159
|
+
retain(id: CheckpointId): Checkpoint<T>;
|
|
160
|
+
/** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
|
|
161
|
+
release(id: CheckpointId): boolean;
|
|
162
|
+
deleteBranch(branch: string): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
|
|
165
|
+
* commits never scan pinned nodes or the retained history. Parents are metadata rather than a
|
|
166
|
+
* storage dependency, so a retained node remains usable after pruning.
|
|
167
|
+
*/
|
|
168
|
+
gc(max?: number): CheckpointId[];
|
|
169
|
+
private collect;
|
|
170
|
+
private moveHead;
|
|
171
|
+
private addReference;
|
|
172
|
+
private removeReference;
|
|
173
|
+
private assertBranch;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Anything that can answer a Fetch `Request` with a `Response`.
|
|
178
|
+
*
|
|
179
|
+
* Every Mockingbird service implements this, and every runtime adapter consumes it.
|
|
180
|
+
* It is the only contract shared across the whole graph.
|
|
181
|
+
*/
|
|
182
|
+
interface FetchAPI {
|
|
183
|
+
fetch(request: Request): Promise<Response>;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Options every provider constructor accepts. */
|
|
187
|
+
type APIOptions = {
|
|
188
|
+
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
189
|
+
sqlite?: SqliteClient$1;
|
|
190
|
+
/** Clock used for `created`-style fields. Default `Date.now`. */
|
|
191
|
+
now?: () => number;
|
|
192
|
+
/**
|
|
193
|
+
* Storage namespace for this instance's records. Instances sharing one SQLite
|
|
194
|
+
* client stay isolated when their namespaces differ. Defaults to the service name.
|
|
195
|
+
*/
|
|
196
|
+
namespace?: string;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* The single source of time for a service.
|
|
201
|
+
*
|
|
202
|
+
* Every timestamp a mock writes reads from here, so a suite moves time instead of
|
|
203
|
+
* sleeping: appointment windows, result delays and expiries become reachable in
|
|
204
|
+
* milliseconds. A frozen clock also makes timestamps reproducible from a seed.
|
|
205
|
+
*/
|
|
206
|
+
type ClockState = {
|
|
207
|
+
/** Current epoch milliseconds. */
|
|
208
|
+
now: number;
|
|
209
|
+
/** True while time does not advance on its own. */
|
|
210
|
+
frozen: boolean;
|
|
211
|
+
/** Milliseconds this clock adds to its underlying source. */
|
|
212
|
+
offsetMs: number;
|
|
213
|
+
};
|
|
214
|
+
type Clock = {
|
|
215
|
+
now(): number;
|
|
216
|
+
/** Pin the clock to an exact instant, keeping it frozen if it already was. */
|
|
217
|
+
set(epochMs: number): void;
|
|
218
|
+
/** Move the clock forward, or back with a negative delta. */
|
|
219
|
+
advance(deltaMs: number): void;
|
|
220
|
+
/** Stop time at the current instant. */
|
|
221
|
+
freeze(): void;
|
|
222
|
+
/** Resume from the current instant. */
|
|
223
|
+
unfreeze(): void;
|
|
224
|
+
/** Drop back to the underlying source, live. */
|
|
225
|
+
reset(): void;
|
|
226
|
+
state(): ClockState;
|
|
227
|
+
};
|
|
228
|
+
|
|
114
229
|
/**
|
|
115
230
|
* Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
|
|
116
231
|
* request a percentage fault hits — is reproducible from a seed.
|
|
@@ -251,109 +366,6 @@ type FaultRegistry = {
|
|
|
251
366
|
take(candidate: FaultCandidate): Promise<FaultHit[]>;
|
|
252
367
|
};
|
|
253
368
|
|
|
254
|
-
/** A stable identifier for a point in a {@link Timeline}. */
|
|
255
|
-
type CheckpointId = string;
|
|
256
|
-
/** An immutable node in a timeline's checkpoint DAG. */
|
|
257
|
-
type Checkpoint<T> = Readonly<{
|
|
258
|
-
id: CheckpointId;
|
|
259
|
-
branch: string;
|
|
260
|
-
parent: CheckpointId | null;
|
|
261
|
-
/** Logical time supplied by the timeline's injected clock. */
|
|
262
|
-
at: number;
|
|
263
|
-
value: T;
|
|
264
|
-
}>;
|
|
265
|
-
type TimelineOptions = {
|
|
266
|
-
/** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
|
|
267
|
-
now?: () => number;
|
|
268
|
-
/** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
|
|
269
|
-
maxCheckpoints?: number;
|
|
270
|
-
/** Customize deterministic checkpoint IDs. */
|
|
271
|
-
id?: (sequence: number) => CheckpointId;
|
|
272
|
-
};
|
|
273
|
-
type CommitOptions = {
|
|
274
|
-
branch?: string;
|
|
275
|
-
/** Parent checkpoint. Defaults to the selected branch's current head. */
|
|
276
|
-
parent?: CheckpointId | null;
|
|
277
|
-
};
|
|
278
|
-
type ForkOptions = {
|
|
279
|
-
/** Checkpoint to fork from. Defaults to the main branch's head. */
|
|
280
|
-
from?: CheckpointId;
|
|
281
|
-
};
|
|
282
|
-
/**
|
|
283
|
-
* Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
|
|
284
|
-
* records, namespace images, or copy-on-write SQL engine snapshots.
|
|
285
|
-
*
|
|
286
|
-
* Values are retained by reference. Engines can therefore use persistent/COW snapshots while
|
|
287
|
-
* simpler services can use immutable values. IDs and GC order are deterministic, and all IO
|
|
288
|
-
* (the logical clock) is injected.
|
|
289
|
-
*/
|
|
290
|
-
declare class Timeline<T> {
|
|
291
|
-
readonly maxCheckpoints: number;
|
|
292
|
-
private readonly now;
|
|
293
|
-
private readonly makeId;
|
|
294
|
-
private readonly nodes;
|
|
295
|
-
private readonly heads;
|
|
296
|
-
/** Unreferenced nodes in the exact order they became collectible. */
|
|
297
|
-
private readonly evictable;
|
|
298
|
-
/** Branch heads plus explicit retainers. Absent means zero. */
|
|
299
|
-
private readonly references;
|
|
300
|
-
private readonly explicitPins;
|
|
301
|
-
private sequence;
|
|
302
|
-
constructor(options?: TimelineOptions);
|
|
303
|
-
/** Capture a new immutable value and move `branch` to it. */
|
|
304
|
-
commit(value: T, options?: CommitOptions): Checkpoint<T>;
|
|
305
|
-
/** Create a branch pointer without copying its checkpoint value. */
|
|
306
|
-
fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
|
|
307
|
-
/** Move a branch pointer to an existing checkpoint. */
|
|
308
|
-
checkout(branch: string, id: CheckpointId): Checkpoint<T>;
|
|
309
|
-
get(id: CheckpointId): Checkpoint<T>;
|
|
310
|
-
head(branch?: string): Checkpoint<T> | undefined;
|
|
311
|
-
hasBranch(branch: string): boolean;
|
|
312
|
-
branches(): Readonly<Record<string, CheckpointId>>;
|
|
313
|
-
checkpoints(): readonly Checkpoint<T>[];
|
|
314
|
-
/** Number of retained checkpoints without allocating an array. */
|
|
315
|
-
get size(): number;
|
|
316
|
-
/** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
|
|
317
|
-
retain(id: CheckpointId): Checkpoint<T>;
|
|
318
|
-
/** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
|
|
319
|
-
release(id: CheckpointId): boolean;
|
|
320
|
-
deleteBranch(branch: string): boolean;
|
|
321
|
-
/**
|
|
322
|
-
* Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
|
|
323
|
-
* commits never scan pinned nodes or the retained history. Parents are metadata rather than a
|
|
324
|
-
* storage dependency, so a retained node remains usable after pruning.
|
|
325
|
-
*/
|
|
326
|
-
gc(max?: number): CheckpointId[];
|
|
327
|
-
private collect;
|
|
328
|
-
private moveHead;
|
|
329
|
-
private addReference;
|
|
330
|
-
private removeReference;
|
|
331
|
-
private assertBranch;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Anything that can answer a Fetch `Request` with a `Response`.
|
|
336
|
-
*
|
|
337
|
-
* Every Mockingbird service implements this, and every runtime adapter consumes it.
|
|
338
|
-
* It is the only contract shared across the whole graph.
|
|
339
|
-
*/
|
|
340
|
-
interface FetchAPI {
|
|
341
|
-
fetch(request: Request): Promise<Response>;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/** Options every provider constructor accepts. */
|
|
345
|
-
type APIOptions = {
|
|
346
|
-
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
347
|
-
sqlite?: SqliteClient$1;
|
|
348
|
-
/** Clock used for `created`-style fields. Default `Date.now`. */
|
|
349
|
-
now?: () => number;
|
|
350
|
-
/**
|
|
351
|
-
* Storage namespace for this instance's records. Instances sharing one SQLite
|
|
352
|
-
* client stay isolated when their namespaces differ. Defaults to the service name.
|
|
353
|
-
*/
|
|
354
|
-
namespace?: string;
|
|
355
|
-
};
|
|
356
|
-
|
|
357
369
|
/**
|
|
358
370
|
* One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
|
|
359
371
|
* `kind` is `media_type` when the body is present but its media type is not one the operation
|
|
@@ -395,6 +407,10 @@ type RequestLog = {
|
|
|
395
407
|
ids?: Record<string, string>;
|
|
396
408
|
/** Set when the service created a resource the request referred to but that did not exist. */
|
|
397
409
|
adopted?: boolean;
|
|
410
|
+
/** Explicit durable acceptance, independent of response delivery. */
|
|
411
|
+
accepted?: boolean;
|
|
412
|
+
/** Checkpoint captured at explicit acceptance. */
|
|
413
|
+
checkpoint?: string;
|
|
398
414
|
/** Set on a rejection (status ≥ 400) the mock produced itself, never on a scripted fault. */
|
|
399
415
|
request?: RejectedRequest;
|
|
400
416
|
/** The validation issues behind a rejection, when the service found any. */
|
|
@@ -458,18 +474,6 @@ type CredentialRegistry = {
|
|
|
458
474
|
}[];
|
|
459
475
|
};
|
|
460
476
|
|
|
461
|
-
/**
|
|
462
|
-
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
463
|
-
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
464
|
-
*/
|
|
465
|
-
declare class IdSequence {
|
|
466
|
-
private readonly sqlite;
|
|
467
|
-
private readonly namespace;
|
|
468
|
-
private readonly salt;
|
|
469
|
-
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
470
|
-
next(prefix: string, length?: number): string;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
477
|
/**
|
|
474
478
|
* A point-in-time copy of everything a service namespace holds.
|
|
475
479
|
*
|