@crvouga/mockingbird-runtime 0.2.0 → 0.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.
Files changed (44) hide show
  1. package/README.md +15 -1
  2. package/dist/adapter-node.d.ts +38 -11
  3. package/dist/adapter-node.js +82 -174
  4. package/dist/adapter-node.js.map +4 -4
  5. package/dist/{chunk-OISPHKE2.js → chunk-KD6FHYQP.js} +98 -17
  6. package/dist/{chunk-OISPHKE2.js.map → chunk-KD6FHYQP.js.map} +4 -4
  7. package/dist/{chunk-LL6NKAJO.js → chunk-M4HUKBLC.js} +3 -2
  8. package/dist/chunk-M4HUKBLC.js.map +7 -0
  9. package/dist/chunk-RI2UQCHP.js +21 -0
  10. package/dist/chunk-RI2UQCHP.js.map +7 -0
  11. package/dist/{chunk-2Y25NPCV.js → chunk-U36J5GCB.js} +290 -1
  12. package/dist/{chunk-2Y25NPCV.js.map → chunk-U36J5GCB.js.map} +3 -3
  13. package/dist/{chunk-5WW5N4TU.js → chunk-ZQBZSSSP.js} +3 -3
  14. package/dist/core.d.ts +86 -2
  15. package/dist/core.js +23 -1
  16. package/dist/http-provider.d.ts +2 -0
  17. package/dist/http-provider.js +7 -7
  18. package/dist/http-provider.js.map +1 -1
  19. package/dist/mqtt-broker/node.d.ts +2 -0
  20. package/dist/mqtt-broker/node.js +4 -4
  21. package/dist/mqtt-broker.d.ts +2 -0
  22. package/dist/mqtt-broker.js +4 -4
  23. package/dist/preview/artifacts.d.ts +4 -9
  24. package/dist/preview/artifacts.js +4 -16
  25. package/dist/preview/artifacts.js.map +2 -2
  26. package/dist/preview/bridge.d.ts +8 -8
  27. package/dist/preview/bridge.js +1 -1
  28. package/dist/preview/harness.d.ts +1 -1
  29. package/dist/preview/harness.js +10 -56
  30. package/dist/preview/harness.js.map +2 -2
  31. package/dist/preview/host.d.ts +4 -9
  32. package/dist/preview/host.js +30 -37
  33. package/dist/preview/host.js.map +2 -2
  34. package/dist/service/admin.js +2 -2
  35. package/dist/service.d.ts +11 -4
  36. package/dist/service.js +6 -4
  37. package/dist/ui.d.ts +1 -37
  38. package/dist/ui.js +2 -701
  39. package/dist/ui.js.map +3 -3
  40. package/package.json +7 -6
  41. package/dist/chunk-EBGYPQPA.js +0 -198
  42. package/dist/chunk-EBGYPQPA.js.map +0 -7
  43. package/dist/chunk-LL6NKAJO.js.map +0 -7
  44. /package/dist/{chunk-5WW5N4TU.js.map → chunk-ZQBZSSSP.js.map} +0 -0
package/dist/core.d.ts CHANGED
@@ -190,6 +190,87 @@ declare class LocalStorageDurabilityBackend implements DurabilityBackend {
190
190
  commit(key: string, expectedRevision: number, patch: DurablePatch): Promise<number>;
191
191
  }
192
192
 
193
+ type FleetArchive = {
194
+ format: "mockingbird.fleet/v1";
195
+ createdAt: string;
196
+ sourceId: string;
197
+ /** Application-owned non-secret tags, independent of participant codecs. */
198
+ compatibility?: ArchiveCompatibilityTags;
199
+ namespaces: Record<string, {
200
+ clock: {
201
+ now: number;
202
+ frozen: boolean;
203
+ };
204
+ services: Record<string, {
205
+ protocol: "http" | "postgres" | "redis" | "external";
206
+ version: 1;
207
+ packageVersion?: string;
208
+ target?: string;
209
+ state: unknown;
210
+ }>;
211
+ }>;
212
+ sha256: string;
213
+ };
214
+ type ArchiveCompatibilityTags = Readonly<Record<string, string>>;
215
+ type ArchiveCompatibilityPolicy = {
216
+ tags: ArchiveCompatibilityTags;
217
+ /** Legacy archives are rejected by default when tags are required. */
218
+ missing?: "reject" | "allow";
219
+ };
220
+ declare function validateCompatibilityTags(tags: unknown): asserts tags is ArchiveCompatibilityTags;
221
+ declare function assertCompatibilityTags(tags: unknown, policy?: ArchiveCompatibilityPolicy): void;
222
+ declare function assertArchiveCompatibility(input: unknown, policy?: ArchiveCompatibilityPolicy): FleetArchive;
223
+ /** An explicit application migration works on a clone and produces a new verified identity. */
224
+ declare function migrateApplicationArchive(input: unknown, migration: {
225
+ from: ArchiveCompatibilityPolicy;
226
+ to: ArchiveCompatibilityTags;
227
+ transform(archive: FleetArchive): FleetArchive | Promise<FleetArchive>;
228
+ }): Promise<FleetArchive>;
229
+ declare const canonical: (value: unknown) => string;
230
+ declare const digest: (value: unknown) => string;
231
+ declare const sealArchive: (content: Omit<FleetArchive, "sha256">) => FleetArchive;
232
+ declare function validateArchive(value: unknown): FleetArchive;
233
+ /** Read-only semantic summaries; values are omitted unless explicitly requested. */
234
+ declare function inspectArchive(input: unknown): {
235
+ namespaces: {
236
+ [k: string]: {
237
+ clock: {
238
+ now: number;
239
+ frozen: boolean;
240
+ };
241
+ services: {
242
+ [k: string]: {
243
+ protocol: "http" | "postgres" | "redis" | "external";
244
+ version: 1;
245
+ bytes: number;
246
+ };
247
+ };
248
+ };
249
+ };
250
+ compatibility?: Readonly<Record<string, string>>;
251
+ format: "mockingbird.fleet/v1";
252
+ createdAt: string;
253
+ sha256: string;
254
+ };
255
+ declare function diffArchives(left: unknown, right: unknown, options?: {
256
+ namespace?: string;
257
+ service?: string;
258
+ values?: boolean;
259
+ limit?: number;
260
+ }): {
261
+ format: string;
262
+ total: number;
263
+ truncated: boolean;
264
+ changes: {
265
+ namespace: string;
266
+ service: string;
267
+ path: string;
268
+ kind: string;
269
+ before?: unknown;
270
+ after?: unknown;
271
+ }[];
272
+ };
273
+
193
274
  type Key = string | number | bigint;
194
275
  /**
195
276
  * An insertion-ordered map for primitive storage keys with O(1) forks. Writes detach
@@ -256,6 +337,9 @@ type MountedAPI = FetchAPI & {
256
337
  /** Embed a native API under an application's origin without owning another listener or state. */
257
338
  declare function mount(api: FetchAPI, path: string, relativePath?: (request: Request) => string): MountedAPI;
258
339
 
340
+ /** SHA-256 as lowercase hex, for deterministic portable archive identities and Redis ACLs. */
341
+ declare function sha256Hex(input: Uint8Array): string;
342
+
259
343
  /** A stable identifier for a point in a {@link Timeline}. */
260
344
  type CheckpointId = string;
261
345
  /** An immutable node in a timeline's checkpoint DAG. */
@@ -352,5 +436,5 @@ declare const toFetchHandler: (api: FetchAPI) => FetchHandler;
352
436
  /** Wrap a plain handler as a {@link FetchAPI}. */
353
437
  declare const fromFetchHandler: (handler: FetchHandler) => FetchAPI;
354
438
 
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 };
439
+ export { DurabilityConflictError, ForkMap, IndexedDBDurabilityBackend, LocalStorageDurabilityBackend, MemoryDurabilityBackend, Timeline, applyDurablePatch, assertArchiveCompatibility, assertCompatibilityTags, browserDurabilityLifecycle, canonical, diffArchives, digest, encodeDurableCheckpoint, forwardMountContext, fromFetchHandler, inspectArchive, isDurableJournal, migrateApplicationArchive, mount, openBufferedDurable, openDurable, packDurableRecord, readDurableJournal, requestBaseUrl, sealArchive, sha256Hex, toFetchHandler, unpackDurableRecord, validateArchive, validateCompatibilityTags, validateDurableCommit, validateDurablePatch, withDurability };
440
+ export type { ArchiveCompatibilityPolicy, ArchiveCompatibilityTags, BufferedDurabilityObserver, BufferedDurabilityOptions, BufferedDurable, Checkpoint, CheckpointId, CommitOptions, DurabilityBackend, DurabilityCodec, DurabilityLifecycle, DurabilityScheduler, Durable, DurableImage, DurableOptions, DurablePatch, FetchAPI, FetchHandler, FleetArchive, ForkOptions, IncrementalCapture, IncrementalDurabilityCodec, IndexedDBDurabilityOptions, LocalStorageDurabilityOptions, MountedAPI, TimelineOptions };
package/dist/core.js CHANGED
@@ -6,23 +6,34 @@ import {
6
6
  MemoryDurabilityBackend,
7
7
  Timeline,
8
8
  applyDurablePatch,
9
+ assertArchiveCompatibility,
10
+ assertCompatibilityTags,
9
11
  browserDurabilityLifecycle,
12
+ canonical,
13
+ diffArchives,
14
+ digest,
10
15
  encodeDurableCheckpoint,
11
16
  forwardMountContext,
12
17
  fromFetchHandler,
18
+ inspectArchive,
13
19
  isDurableJournal,
20
+ migrateApplicationArchive,
14
21
  mount,
15
22
  openBufferedDurable,
16
23
  openDurable,
17
24
  packDurableRecord,
18
25
  readDurableJournal,
19
26
  requestBaseUrl,
27
+ sealArchive,
28
+ sha256Hex,
20
29
  toFetchHandler,
21
30
  unpackDurableRecord,
31
+ validateArchive,
32
+ validateCompatibilityTags,
22
33
  validateDurableCommit,
23
34
  validateDurablePatch,
24
35
  withDurability
25
- } from "./chunk-2Y25NPCV.js";
36
+ } from "./chunk-U36J5GCB.js";
26
37
  export {
27
38
  DurabilityConflictError,
28
39
  ForkMap,
@@ -31,19 +42,30 @@ export {
31
42
  MemoryDurabilityBackend,
32
43
  Timeline,
33
44
  applyDurablePatch,
45
+ assertArchiveCompatibility,
46
+ assertCompatibilityTags,
34
47
  browserDurabilityLifecycle,
48
+ canonical,
49
+ diffArchives,
50
+ digest,
35
51
  encodeDurableCheckpoint,
36
52
  forwardMountContext,
37
53
  fromFetchHandler,
54
+ inspectArchive,
38
55
  isDurableJournal,
56
+ migrateApplicationArchive,
39
57
  mount,
40
58
  openBufferedDurable,
41
59
  openDurable,
42
60
  packDurableRecord,
43
61
  readDurableJournal,
44
62
  requestBaseUrl,
63
+ sealArchive,
64
+ sha256Hex,
45
65
  toFetchHandler,
46
66
  unpackDurableRecord,
67
+ validateArchive,
68
+ validateCompatibilityTags,
47
69
  validateDurableCommit,
48
70
  validateDurablePatch,
49
71
  withDurability
@@ -329,6 +329,8 @@ declare class Collection$1<T> {
329
329
  namespace: string,
330
330
  /** Table name inside the namespace. Stable across resets of the rows themselves. */
331
331
  collectionName: string);
332
+ /** Note the record's current row in every open rollback journal that has not seen it yet. */
333
+ private journalRecord;
332
334
  private bumpCollectionSeq;
333
335
  nextSequence(): number;
334
336
  get(id: string): T | undefined;
@@ -18,14 +18,14 @@ import {
18
18
  import {
19
19
  Collection,
20
20
  bootSqlite
21
- } from "./chunk-OISPHKE2.js";
21
+ } from "./chunk-KD6FHYQP.js";
22
22
  import {
23
23
  clearNamespace
24
24
  } from "./chunk-2KDYLZXC.js";
25
- import "./chunk-LL6NKAJO.js";
25
+ import "./chunk-M4HUKBLC.js";
26
26
  import {
27
27
  requestBaseUrl
28
- } from "./chunk-2Y25NPCV.js";
28
+ } from "./chunk-U36J5GCB.js";
29
29
  import {
30
30
  operationMetadata
31
31
  } from "./chunk-EQLY2YOA.js";
@@ -1178,15 +1178,15 @@ body{
1178
1178
  .checkout-form-side{padding:32px 20px;}
1179
1179
  }
1180
1180
  `;
1181
- var POWERED_BY = `<div class="powered-by">Powered by <a href="https://github.com/crvouga/mockingbird" target="_blank" rel="noopener">Mockingbird</a></div>`;
1181
+ var POWERED_BY = `<div class="powered-by">Powered by <a href="https://github.com/crvouga-organization/mockingbird" target="_blank" rel="noopener">Mockingbird</a></div>`;
1182
1182
  function emuBar(service) {
1183
1183
  const title = service ? `${escapeHtml(service)} Emulator` : "Emulator";
1184
1184
  return `<div class="emu-bar">
1185
1185
  <span class="emu-bar-title">${title}</span>
1186
1186
  <nav class="emu-bar-links">
1187
- <a href="https://github.com/crvouga/mockingbird/issues" target="_blank" rel="noopener"><span class="full">Report Issue</span><span class="short">Report</span></a>
1188
- <a href="https://github.com/crvouga/mockingbird" target="_blank" rel="noopener"><span class="full">Source Code</span><span class="short">Source</span></a>
1189
- <a href="https://github.com/crvouga/mockingbird" target="_blank" rel="noopener"><span class="full">Learn More</span><span class="short">Learn</span></a>
1187
+ <a href="https://github.com/crvouga-organization/mockingbird/issues" target="_blank" rel="noopener"><span class="full">Report Issue</span><span class="short">Report</span></a>
1188
+ <a href="https://github.com/crvouga-organization/mockingbird" target="_blank" rel="noopener"><span class="full">Source Code</span><span class="short">Source</span></a>
1189
+ <a href="https://github.com/crvouga-organization/mockingbird" target="_blank" rel="noopener"><span class="full">Learn More</span><span class="short">Learn</span></a>
1190
1190
  </nav>
1191
1191
  </div>`;
1192
1192
  }