@crvouga/mockingbird-runtime 0.0.0-stage → 0.0.1

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.
Files changed (81) hide show
  1. package/README.md +131 -2
  2. package/dist/adapter-node.d.ts +2521 -0
  3. package/dist/adapter-node.js +6920 -0
  4. package/dist/adapter-node.js.map +7 -0
  5. package/dist/admin-ui.js +25 -0
  6. package/dist/admin-ui.js.map +7 -0
  7. package/dist/chunk-2KDYLZXC.js +118 -0
  8. package/dist/chunk-2KDYLZXC.js.map +7 -0
  9. package/dist/chunk-2Y25NPCV.js +1289 -0
  10. package/dist/chunk-2Y25NPCV.js.map +7 -0
  11. package/dist/chunk-4SAK6MQT.js +246 -0
  12. package/dist/chunk-4SAK6MQT.js.map +7 -0
  13. package/dist/chunk-ANCCZFF2.js +778 -0
  14. package/dist/chunk-ANCCZFF2.js.map +7 -0
  15. package/dist/chunk-EBGYPQPA.js +198 -0
  16. package/dist/chunk-EBGYPQPA.js.map +7 -0
  17. package/dist/chunk-EQLY2YOA.js +274 -0
  18. package/dist/chunk-EQLY2YOA.js.map +7 -0
  19. package/dist/chunk-G62YDIIJ.js +7664 -0
  20. package/dist/chunk-G62YDIIJ.js.map +7 -0
  21. package/dist/chunk-HU6IOAFC.js +437 -0
  22. package/dist/chunk-HU6IOAFC.js.map +7 -0
  23. package/dist/chunk-RNAHPNUJ.js +97 -0
  24. package/dist/chunk-RNAHPNUJ.js.map +7 -0
  25. package/dist/chunk-UP4QOSFD.js +87 -0
  26. package/dist/chunk-UP4QOSFD.js.map +7 -0
  27. package/dist/chunk-XNS34BPF.js +2489 -0
  28. package/dist/chunk-XNS34BPF.js.map +7 -0
  29. package/dist/core.d.ts +356 -0
  30. package/dist/core.js +51 -0
  31. package/dist/core.js.map +7 -0
  32. package/dist/crypto-XS5XCMRJ.js +21 -0
  33. package/dist/crypto-XS5XCMRJ.js.map +7 -0
  34. package/dist/helpers-UD7CG4WQ.js +18 -0
  35. package/dist/helpers-UD7CG4WQ.js.map +7 -0
  36. package/dist/http-codec.d.ts +72 -0
  37. package/dist/http-codec.js +25 -0
  38. package/dist/http-codec.js.map +7 -0
  39. package/dist/http-provider.d.ts +3243 -0
  40. package/dist/http-provider.js +37920 -0
  41. package/dist/http-provider.js.map +7 -0
  42. package/dist/index.d.ts +10 -0
  43. package/dist/index.js +23 -0
  44. package/dist/index.js.map +7 -0
  45. package/dist/mqtt-broker/node.d.ts +632 -0
  46. package/dist/mqtt-broker/node.js +355 -0
  47. package/dist/mqtt-broker/node.js.map +7 -0
  48. package/dist/mqtt-broker.d.ts +990 -0
  49. package/dist/mqtt-broker.js +913 -0
  50. package/dist/mqtt-broker.js.map +7 -0
  51. package/dist/openapi-metadata.d.ts +290 -0
  52. package/dist/openapi-metadata.js +28 -0
  53. package/dist/openapi-metadata.js.map +7 -0
  54. package/dist/openapi.d.ts +252 -0
  55. package/dist/openapi.js +45 -0
  56. package/dist/openapi.js.map +7 -0
  57. package/dist/preview/artifacts.d.ts +19 -0
  58. package/dist/preview/artifacts.js +40 -0
  59. package/dist/preview/artifacts.js.map +7 -0
  60. package/dist/preview/bridge.d.ts +21 -0
  61. package/dist/preview/bridge.js +9 -0
  62. package/dist/preview/bridge.js.map +7 -0
  63. package/dist/preview/harness.d.ts +12 -0
  64. package/dist/preview/harness.js +65 -0
  65. package/dist/preview/harness.js.map +7 -0
  66. package/dist/preview/host.d.ts +30 -0
  67. package/dist/preview/host.js +70 -0
  68. package/dist/preview/host.js.map +7 -0
  69. package/dist/service/admin.d.ts +106 -0
  70. package/dist/service/admin.js +340 -0
  71. package/dist/service/admin.js.map +7 -0
  72. package/dist/service.d.ts +2665 -0
  73. package/dist/service.js +264 -0
  74. package/dist/service.js.map +7 -0
  75. package/dist/sqlite.d.ts +69 -0
  76. package/dist/sqlite.js +19 -0
  77. package/dist/sqlite.js.map +7 -0
  78. package/dist/ui.d.ts +37 -0
  79. package/dist/ui.js +702 -0
  80. package/dist/ui.js.map +7 -0
  81. package/package.json +135 -4
package/dist/core.d.ts ADDED
@@ -0,0 +1,356 @@
1
+ /** Atomic binary image port. Implementations must reject stale revisions without writing. */
2
+ interface DurabilityBackend {
3
+ load(key: string): Promise<DurableImage | undefined>;
4
+ commit(key: string, expectedRevision: number, patch: DurablePatch): Promise<number>;
5
+ }
6
+ /**
7
+ * Give a Fetch emulator a durable acknowledgement boundary. Inject the handle's value into
8
+ * the service, then send every request through this wrapper. Requests serialize through the
9
+ * response's commit, so another request cannot mutate the database during a pending save.
10
+ */
11
+ declare function withDurability<RequestType, ResponseType>(api: {
12
+ fetch(request: RequestType): Promise<ResponseType>;
13
+ }, durable: Pick<Durable<unknown>, "flush">): {
14
+ fetch(request: RequestType): Promise<ResponseType>;
15
+ };
16
+ interface DurableImage {
17
+ revision: number;
18
+ bytes: Uint8Array;
19
+ pageSize: number;
20
+ }
21
+ interface DurablePatch {
22
+ byteLength: number;
23
+ pageSize: number;
24
+ /** Only changed pages; data is owned by the caller until commit resolves. */
25
+ pages: readonly {
26
+ index: number;
27
+ bytes: Uint8Array;
28
+ }[];
29
+ }
30
+ /** A second writer changed the image. Reopen before writing; never silently overwrite it. */
31
+ declare class DurabilityConflictError extends Error {
32
+ constructor();
33
+ }
34
+ /** An emulator owns its codec; storage adapters know nothing about SQL or service state. */
35
+ interface DurabilityCodec<T> {
36
+ create(): T;
37
+ decode(bytes: Uint8Array): T;
38
+ encode(value: T): Uint8Array;
39
+ close?(value: T): void | Promise<void>;
40
+ }
41
+ interface DurableOptions<T> {
42
+ backend: DurabilityBackend;
43
+ key: string;
44
+ codec: DurabilityCodec<T>;
45
+ /** Binary comparison/write granularity. Default 16 KiB. */
46
+ pageSize?: number;
47
+ }
48
+ interface Durable<T> {
49
+ readonly value: T;
50
+ /** Capture and atomically save the current state. Resolve only after storage commits. */
51
+ flush(): Promise<void>;
52
+ /** Serialize a synchronous batch and save it with one encode and storage transaction. */
53
+ write<R>(run: (value: T) => R): Promise<R>;
54
+ /** Save before closing. A failed save leaves the handle open for retry. */
55
+ close(): Promise<void>;
56
+ }
57
+ /**
58
+ * Keeps the synchronous emulator hot path free of storage IO. Batch any number of mutations,
59
+ * then await flush(), or await write(batch). A successful synchronous mutation alone is not
60
+ * durable. No unload handlers, background timers or unhandled persistence failures.
61
+ */
62
+ declare function openDurable<T>(options: DurableOptions<T>): Promise<Durable<T>>;
63
+ /** Apply a validated patch to an independently owned image. Also used by custom adapters. */
64
+ declare function applyDurablePatch(previous: Uint8Array, patch: DurablePatch): Uint8Array;
65
+ /** Validate before starting storage writes so invalid custom patches cannot partially commit. */
66
+ declare function validateDurablePatch(patch: DurablePatch): void;
67
+ /** Reject missing replacement/new pages before an adapter changes the saved image. */
68
+ declare function validateDurableCommit(patch: DurablePatch, previous?: {
69
+ byteLength: number;
70
+ pageSize: number;
71
+ }): void;
72
+ /** Reference adapter for tests and server-side ephemeral use. */
73
+ declare class MemoryDurabilityBackend implements DurabilityBackend {
74
+ private readonly images;
75
+ load(key: string): Promise<DurableImage | undefined>;
76
+ commit(key: string, expectedRevision: number, patch: DurablePatch): Promise<number>;
77
+ }
78
+
79
+ interface DurabilityScheduler {
80
+ schedule(run: () => void, delayMs: number): unknown;
81
+ cancel(handle: unknown): void;
82
+ }
83
+ interface DurabilityLifecycle {
84
+ subscribe(onSuspend: () => void): () => void;
85
+ }
86
+ interface BufferedDurabilityObserver {
87
+ changed(): void;
88
+ exposed(): void;
89
+ assertWritable(): void;
90
+ /** An independently closed engine cannot keep a background persistence loop alive. */
91
+ closed?(): void;
92
+ }
93
+ interface IncrementalCapture<Token> {
94
+ token: Token;
95
+ checkpoint: boolean;
96
+ /** Omit when the committed state has not changed. Bytes must be independently owned. */
97
+ bytes?: Uint8Array;
98
+ }
99
+ /** Engine port: capture physical committed state, never SQL text for replay. */
100
+ interface IncrementalDurabilityCodec<T, Token> extends DurabilityCodec<T> {
101
+ decodeJournal(records: readonly Uint8Array[]): T;
102
+ /** Initialize comparison state after recovery without re-encoding the checkpoint. */
103
+ baseline?(value: T): Token;
104
+ capture(value: T, previous: Token | undefined, checkpoint: boolean): IncrementalCapture<Token>;
105
+ acknowledge(value: T, token: Token): void;
106
+ canCapture(value: T): boolean;
107
+ subscribe(value: T, observer: BufferedDurabilityObserver): () => void;
108
+ }
109
+ interface BufferedDurabilityOptions {
110
+ /** First-change deadline, not a debounce. Default 1,000 ms; suspension can delay it. */
111
+ flushIntervalMs?: number;
112
+ scheduler?: DurabilityScheduler;
113
+ lifecycle?: DurabilityLifecycle;
114
+ onError?: (error: unknown) => void;
115
+ /** Default 256 successful delta batches. */
116
+ compactAfterBatches?: number;
117
+ /** Default max(4 MiB, checkpoint size). */
118
+ compactAfterBytes?: number;
119
+ }
120
+ interface BufferedDurable<T> extends Durable<T> {
121
+ readonly pending: boolean;
122
+ readonly lastError: unknown;
123
+ }
124
+ declare function isDurableJournal(bytes: Uint8Array): boolean;
125
+ /** A legacy immediate writer can retain a buffered image's richer checkpoint metadata. */
126
+ declare function encodeDurableCheckpoint(record: Uint8Array): Uint8Array;
127
+ /** Undefined identifies an unchanged legacy image; malformed envelopes fail closed. */
128
+ declare function readDurableJournal(bytes: Uint8Array): readonly Uint8Array[] | undefined;
129
+ /** Single-writer buffered persistence. Only the last append page is retained between saves. */
130
+ declare function openBufferedDurable<T, Token>(options: BufferedDurabilityOptions & {
131
+ key: string;
132
+ backend: DurabilityBackend;
133
+ codec: IncrementalDurabilityCodec<T, Token>;
134
+ pageSize?: number;
135
+ }): Promise<BufferedDurable<T>>;
136
+ /** Pack engine-specific metadata alongside a standard SQLM/PGMM snapshot. */
137
+ declare function packDurableRecord(metadata: unknown, snapshot: Uint8Array): Uint8Array;
138
+ declare function unpackDurableRecord<Metadata>(bytes: Uint8Array): {
139
+ metadata: Metadata;
140
+ snapshot: Uint8Array;
141
+ };
142
+
143
+ /** Best effort only; browsers do not wait for asynchronous pagehide work. */
144
+ declare const browserDurabilityLifecycle: DurabilityLifecycle;
145
+ interface IndexedDBDurabilityOptions {
146
+ name?: string;
147
+ /** Inject for workers, tests or a different browser realm. */
148
+ indexedDB?: {
149
+ open(name: string, version?: number): unknown;
150
+ };
151
+ /** Default strict: acknowledgement follows the browser's durable commit. */
152
+ durability?: "default" | "strict" | "relaxed";
153
+ }
154
+ /** Binary pages, changed-page writes and revision checks in one IndexedDB transaction. */
155
+ declare class IndexedDBDurabilityBackend implements DurabilityBackend {
156
+ private database;
157
+ private readonly factory;
158
+ private readonly name;
159
+ private readonly durability;
160
+ constructor(options?: IndexedDBDurabilityOptions);
161
+ private open;
162
+ load(key: string): Promise<DurableImage | undefined>;
163
+ commit(key: string, expectedRevision: number, patch: DurablePatch): Promise<number>;
164
+ /** Release this adapter's connection; does not delete any saved images. */
165
+ close(): Promise<void>;
166
+ }
167
+ interface LocalStorageDurabilityOptions {
168
+ storage?: {
169
+ getItem(key: string): string | null;
170
+ setItem(key: string, value: string): void;
171
+ };
172
+ prefix?: string;
173
+ /** Inject navigator.locks for cross-tab compare-and-swap. Required for safe shared writers. */
174
+ locks?: {
175
+ request<T>(name: string, run: () => T | PromiseLike<T>): Promise<T>;
176
+ };
177
+ }
178
+ /**
179
+ * Small-image fallback. Each commit replaces one base64 image atomically. IndexedDB avoids
180
+ * this full-image encoding and synchronous main-thread IO and is preferred for performance.
181
+ * With no Web Locks support, use one writer per key (localStorage has no native CAS).
182
+ */
183
+ declare class LocalStorageDurabilityBackend implements DurabilityBackend {
184
+ private readonly storage;
185
+ private readonly prefix;
186
+ private readonly locks;
187
+ constructor(options?: LocalStorageDurabilityOptions);
188
+ load(key: string): Promise<DurableImage | undefined>;
189
+ private read;
190
+ commit(key: string, expectedRevision: number, patch: DurablePatch): Promise<number>;
191
+ }
192
+
193
+ type Key = string | number | bigint;
194
+ /**
195
+ * An insertion-ordered map for primitive storage keys with O(1) forks. Writes detach
196
+ * two small hash directories, one native hash bucket, and a path of 32-cell order pages.
197
+ * Values retain ordinary Map reference semantics: callers own value-level copy-on-write.
198
+ */
199
+ declare class ForkMap<K extends Key, V> implements Map<K, V> {
200
+ private owner;
201
+ private index;
202
+ private order;
203
+ private shift;
204
+ private length;
205
+ private count;
206
+ private nextSequence;
207
+ private layout;
208
+ private cleared;
209
+ private version;
210
+ constructor(entries?: Iterable<readonly [K, V]>);
211
+ get size(): number;
212
+ get [Symbol.toStringTag](): string;
213
+ fork(): ForkMap<K, V>;
214
+ /** Visit changed hash buckets only. Values must be replaced, rather than mutated in place. */
215
+ changes(previous?: ForkMap<K, V>): Iterable<{
216
+ key: K;
217
+ value: V;
218
+ deleted: false;
219
+ } | {
220
+ key: K;
221
+ deleted: true;
222
+ }>;
223
+ get(key: K): V | undefined;
224
+ has(key: K): boolean;
225
+ set(key: K, value: V): this;
226
+ delete(key: K): boolean;
227
+ clear(): void;
228
+ entries(): MapIterator<[K, V]>;
229
+ keys(): MapIterator<K>;
230
+ values(): MapIterator<V>;
231
+ [Symbol.iterator](): MapIterator<[K, V]>;
232
+ forEach(callback: (value: V, key: K, map: Map<K, V>) => void, thisArg?: unknown): void;
233
+ private find;
234
+ private bucket;
235
+ private writableBucket;
236
+ private copyBucket;
237
+ private leaf;
238
+ private writeOrder;
239
+ private compact;
240
+ private iterate;
241
+ }
242
+
243
+ /** Trusted mount metadata stays on the Request, never in a spoofable HTTP header. */
244
+ declare const requestBaseUrl: (request: Request) => string;
245
+ declare const forwardMountContext: (source: Request, target: Request) => Request;
246
+ type MountedAPI = FetchAPI & {
247
+ readonly prefix: string;
248
+ GET: FetchHandler;
249
+ POST: FetchHandler;
250
+ PUT: FetchHandler;
251
+ PATCH: FetchHandler;
252
+ DELETE: FetchHandler;
253
+ HEAD: FetchHandler;
254
+ OPTIONS: FetchHandler;
255
+ };
256
+ /** Embed a native API under an application's origin without owning another listener or state. */
257
+ declare function mount(api: FetchAPI, path: string, relativePath?: (request: Request) => string): MountedAPI;
258
+
259
+ /** A stable identifier for a point in a {@link Timeline}. */
260
+ type CheckpointId = string;
261
+ /** An immutable node in a timeline's checkpoint DAG. */
262
+ type Checkpoint<T> = Readonly<{
263
+ id: CheckpointId;
264
+ branch: string;
265
+ parent: CheckpointId | null;
266
+ /** Logical time supplied by the timeline's injected clock. */
267
+ at: number;
268
+ value: T;
269
+ }>;
270
+ type TimelineOptions = {
271
+ /** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
272
+ now?: () => number;
273
+ /** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
274
+ maxCheckpoints?: number;
275
+ /** Customize deterministic checkpoint IDs. */
276
+ id?: (sequence: number) => CheckpointId;
277
+ };
278
+ type CommitOptions = {
279
+ branch?: string;
280
+ /** Parent checkpoint. Defaults to the selected branch's current head. */
281
+ parent?: CheckpointId | null;
282
+ };
283
+ type ForkOptions = {
284
+ /** Checkpoint to fork from. Defaults to the main branch's head. */
285
+ from?: CheckpointId;
286
+ };
287
+ /**
288
+ * Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
289
+ * records, namespace images, or copy-on-write SQL engine snapshots.
290
+ *
291
+ * Values are retained by reference. Engines can therefore use persistent/COW snapshots while
292
+ * simpler services can use immutable values. IDs and GC order are deterministic, and all IO
293
+ * (the logical clock) is injected.
294
+ */
295
+ declare class Timeline<T> {
296
+ readonly maxCheckpoints: number;
297
+ private readonly now;
298
+ private readonly makeId;
299
+ private readonly nodes;
300
+ private readonly heads;
301
+ /** Unreferenced nodes in the exact order they became collectible. */
302
+ private readonly evictable;
303
+ /** Branch heads plus explicit retainers. Absent means zero. */
304
+ private readonly references;
305
+ private readonly explicitPins;
306
+ private sequence;
307
+ constructor(options?: TimelineOptions);
308
+ /** Capture a new immutable value and move `branch` to it. */
309
+ commit(value: T, options?: CommitOptions): Checkpoint<T>;
310
+ /** Create a branch pointer without copying its checkpoint value. */
311
+ fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
312
+ /** Move a branch pointer to an existing checkpoint. */
313
+ checkout(branch: string, id: CheckpointId): Checkpoint<T>;
314
+ get(id: CheckpointId): Checkpoint<T>;
315
+ head(branch?: string): Checkpoint<T> | undefined;
316
+ hasBranch(branch: string): boolean;
317
+ branches(): Readonly<Record<string, CheckpointId>>;
318
+ checkpoints(): readonly Checkpoint<T>[];
319
+ /** Number of retained checkpoints without allocating an array. */
320
+ get size(): number;
321
+ /** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
322
+ retain(id: CheckpointId): Checkpoint<T>;
323
+ /** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
324
+ release(id: CheckpointId): boolean;
325
+ deleteBranch(branch: string): boolean;
326
+ /**
327
+ * Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
328
+ * commits never scan pinned nodes or the retained history. Parents are metadata rather than a
329
+ * storage dependency, so a retained node remains usable after pruning.
330
+ */
331
+ gc(max?: number): CheckpointId[];
332
+ private collect;
333
+ private moveHead;
334
+ private addReference;
335
+ private removeReference;
336
+ private assertBranch;
337
+ }
338
+
339
+ /**
340
+ * Anything that can answer a Fetch `Request` with a `Response`.
341
+ *
342
+ * Every Mockingbird service implements this, and every runtime adapter consumes it.
343
+ * It is the only contract shared across the whole graph.
344
+ */
345
+ interface FetchAPI {
346
+ fetch(request: Request): Promise<Response>;
347
+ }
348
+ /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
349
+ type FetchHandler = (request: Request) => Promise<Response>;
350
+ /** Convert a {@link FetchAPI} into a plain {@link FetchHandler}. */
351
+ declare const toFetchHandler: (api: FetchAPI) => FetchHandler;
352
+ /** Wrap a plain handler as a {@link FetchAPI}. */
353
+ declare const fromFetchHandler: (handler: FetchHandler) => FetchAPI;
354
+
355
+ export { DurabilityConflictError, ForkMap, IndexedDBDurabilityBackend, LocalStorageDurabilityBackend, MemoryDurabilityBackend, Timeline, applyDurablePatch, browserDurabilityLifecycle, encodeDurableCheckpoint, forwardMountContext, fromFetchHandler, isDurableJournal, mount, openBufferedDurable, openDurable, packDurableRecord, readDurableJournal, requestBaseUrl, toFetchHandler, unpackDurableRecord, validateDurableCommit, validateDurablePatch, withDurability };
356
+ export type { BufferedDurabilityObserver, BufferedDurabilityOptions, BufferedDurable, Checkpoint, CheckpointId, CommitOptions, DurabilityBackend, DurabilityCodec, DurabilityLifecycle, DurabilityScheduler, Durable, DurableImage, DurableOptions, DurablePatch, FetchAPI, FetchHandler, ForkOptions, IncrementalCapture, IncrementalDurabilityCodec, IndexedDBDurabilityOptions, LocalStorageDurabilityOptions, MountedAPI, TimelineOptions };
package/dist/core.js ADDED
@@ -0,0 +1,51 @@
1
+ import {
2
+ DurabilityConflictError,
3
+ ForkMap,
4
+ IndexedDBDurabilityBackend,
5
+ LocalStorageDurabilityBackend,
6
+ MemoryDurabilityBackend,
7
+ Timeline,
8
+ applyDurablePatch,
9
+ browserDurabilityLifecycle,
10
+ encodeDurableCheckpoint,
11
+ forwardMountContext,
12
+ fromFetchHandler,
13
+ isDurableJournal,
14
+ mount,
15
+ openBufferedDurable,
16
+ openDurable,
17
+ packDurableRecord,
18
+ readDurableJournal,
19
+ requestBaseUrl,
20
+ toFetchHandler,
21
+ unpackDurableRecord,
22
+ validateDurableCommit,
23
+ validateDurablePatch,
24
+ withDurability
25
+ } from "./chunk-2Y25NPCV.js";
26
+ export {
27
+ DurabilityConflictError,
28
+ ForkMap,
29
+ IndexedDBDurabilityBackend,
30
+ LocalStorageDurabilityBackend,
31
+ MemoryDurabilityBackend,
32
+ Timeline,
33
+ applyDurablePatch,
34
+ browserDurabilityLifecycle,
35
+ encodeDurableCheckpoint,
36
+ forwardMountContext,
37
+ fromFetchHandler,
38
+ isDurableJournal,
39
+ mount,
40
+ openBufferedDurable,
41
+ openDurable,
42
+ packDurableRecord,
43
+ readDurableJournal,
44
+ requestBaseUrl,
45
+ toFetchHandler,
46
+ unpackDurableRecord,
47
+ validateDurableCommit,
48
+ validateDurablePatch,
49
+ withDurability
50
+ };
51
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,21 @@
1
+ import {
2
+ createHash,
3
+ createHmac,
4
+ random,
5
+ randomBytes,
6
+ randomUUID,
7
+ timingSafeEqual,
8
+ useRandom,
9
+ withRandom
10
+ } from "./chunk-RNAHPNUJ.js";
11
+ export {
12
+ createHash,
13
+ createHmac,
14
+ random,
15
+ randomBytes,
16
+ randomUUID,
17
+ timingSafeEqual,
18
+ useRandom,
19
+ withRandom
20
+ };
21
+ //# sourceMappingURL=crypto-XS5XCMRJ.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,18 @@
1
+ import {
2
+ createDefaultEmailAddress,
3
+ createDefaultOrganization,
4
+ createDefaultUser,
5
+ generateClerkId,
6
+ nowUnix,
7
+ userDisplayName
8
+ } from "./chunk-UP4QOSFD.js";
9
+ import "./chunk-RNAHPNUJ.js";
10
+ export {
11
+ createDefaultEmailAddress,
12
+ createDefaultOrganization,
13
+ createDefaultUser,
14
+ generateClerkId,
15
+ nowUnix,
16
+ userDisplayName
17
+ };
18
+ //# sourceMappingURL=helpers-UD7CG4WQ.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,72 @@
1
+ declare const JSON_MEDIA_TYPE = "application/json";
2
+ declare const FORM_MEDIA_TYPE = "application/x-www-form-urlencoded";
3
+ /** The essence of a `Content-Type` header: lower-cased media type without parameters. */
4
+ declare const mediaTypeOf: (contentType: string | null | undefined) => string | undefined;
5
+ type DecodedBody = {
6
+ kind: "empty";
7
+ } | {
8
+ kind: "json";
9
+ value: unknown;
10
+ } | {
11
+ kind: "form";
12
+ value: Record<string, unknown>;
13
+ } | {
14
+ kind: "text";
15
+ value: string;
16
+ } | {
17
+ kind: "bytes";
18
+ value: Uint8Array;
19
+ } | {
20
+ kind: "invalid";
21
+ mediaType: string;
22
+ text: string;
23
+ error: string;
24
+ };
25
+ /**
26
+ * Decode raw bytes according to a `Content-Type`. Never throws: malformed payloads come back as
27
+ * `{ kind: "invalid" }` so callers (mock servers, the differential runner) can respond like a real
28
+ * server would instead of crashing.
29
+ */
30
+ declare const decodeBody: (contentType: string | null | undefined, bytes: Uint8Array) => DecodedBody;
31
+ /** Read and decode a Request/Response body. */
32
+ declare const readBody: (message: Request | Response) => Promise<DecodedBody>;
33
+ type EncodedBody = {
34
+ contentType: string;
35
+ body: string;
36
+ };
37
+ /** Encode a JSON-like value for the given media type. Throws for unsupported media types. */
38
+ declare const encodeBody: (mediaType: string, value: unknown) => EncodedBody;
39
+
40
+ /**
41
+ * Rails/PHP/Stripe-style bracket notation for `application/x-www-form-urlencoded` bodies and
42
+ * query strings:
43
+ *
44
+ * address[city]=Paris -> { address: { city: "Paris" } }
45
+ * items[0][name]=a -> { items: [{ name: "a" }] }
46
+ * tags[]=x&tags[]=y -> { tags: ["x", "y"] }
47
+ * metadata[k]=v -> { metadata: { k: "v" } }
48
+ *
49
+ * Decoding yields only strings, arrays and plain objects — coercion is the caller's concern,
50
+ * exactly like a real HTTP server.
51
+ */
52
+ type FormValue = string | FormValue[] | {
53
+ [key: string]: FormValue;
54
+ };
55
+ type FormObject = {
56
+ [key: string]: FormValue;
57
+ };
58
+ /**
59
+ * Encode a JSON-like value as bracket-notation pairs. Nested arrays use explicit indices
60
+ * (`a[0]`), which every bracket parser (including Stripe's) accepts; empty arrays/objects
61
+ * encode as an empty string, matching how Stripe unsets fields.
62
+ */
63
+ declare const encodeFormPairs: (value: Record<string, unknown>) => Array<[string, string]>;
64
+ /** Encode to a full `application/x-www-form-urlencoded` string. */
65
+ declare const encodeForm: (value: Record<string, unknown>) => string;
66
+ /** Decode `key=value&...` pairs (already percent-decoded) into a nested object. */
67
+ declare const decodeFormPairs: (pairs: Iterable<[string, string]>) => FormObject;
68
+ /** Decode an `application/x-www-form-urlencoded` body or a query string (with or without `?`). */
69
+ declare const decodeForm: (text: string) => FormObject;
70
+
71
+ export { FORM_MEDIA_TYPE, JSON_MEDIA_TYPE, decodeBody, decodeForm, decodeFormPairs, encodeBody, encodeForm, encodeFormPairs, mediaTypeOf, readBody };
72
+ export type { DecodedBody, EncodedBody, FormObject, FormValue };
@@ -0,0 +1,25 @@
1
+ import {
2
+ FORM_MEDIA_TYPE,
3
+ JSON_MEDIA_TYPE,
4
+ decodeBody,
5
+ decodeForm,
6
+ decodeFormPairs,
7
+ encodeBody,
8
+ encodeForm,
9
+ encodeFormPairs,
10
+ mediaTypeOf,
11
+ readBody
12
+ } from "./chunk-4SAK6MQT.js";
13
+ export {
14
+ FORM_MEDIA_TYPE,
15
+ JSON_MEDIA_TYPE,
16
+ decodeBody,
17
+ decodeForm,
18
+ decodeFormPairs,
19
+ encodeBody,
20
+ encodeForm,
21
+ encodeFormPairs,
22
+ mediaTypeOf,
23
+ readBody
24
+ };
25
+ //# sourceMappingURL=http-codec.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }