@crvouga/mockingbird-service-junction 3.9.0 → 3.10.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog — @crvouga/mockingbird-service-junction
2
2
 
3
+ ## 3.10.0 (2026-10-24)
4
+
5
+ ### Features
6
+
7
+ - add buffered SQL durability ([288bdcc](https://github.com/crvouga/mockingbird/commit/288bdcca84582787a54c4fdf9e803db9aac0b8d7))
8
+ - add efficient browser durability ([a8be579](https://github.com/crvouga/mockingbird/commit/a8be5799a883ddf6f731208e06f399410de4661a))
9
+
10
+ ### Dependencies
11
+
12
+ - `@crvouga/mockingbird-service-sqlite`
13
+
3
14
  ## 3.9.0 (2026-10-21)
4
15
 
5
16
  ### Features
@@ -13,7 +13,7 @@ import {
13
13
  pullCorpus,
14
14
  resolveAdminPrefix,
15
15
  restoreClock
16
- } from "./chunk-ES4WU54W.js";
16
+ } from "./chunk-GOEPHSRP.js";
17
17
  import {
18
18
  defaultCorpus
19
19
  } from "./chunk-2FZJPMTR.js";
@@ -3070,7 +3070,7 @@ async function preflightFleet(config, options) {
3070
3070
  break;
3071
3071
  }
3072
3072
  }
3073
- targets.set(name, { ...target, packageVersion: packageVersion ?? "3.9.0" });
3073
+ targets.set(name, { ...target, packageVersion: packageVersion ?? "3.10.0" });
3074
3074
  } catch (error) {
3075
3075
  throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
3076
3076
  }
@@ -5264,4 +5264,4 @@ export {
5264
5264
  createServer2 as createServer,
5265
5265
  serveTarget
5266
5266
  };
5267
- //# sourceMappingURL=chunk-VHKUGUXZ.js.map
5267
+ //# sourceMappingURL=chunk-ES5GJACF.js.map
@@ -335,15 +335,24 @@ var Collection = class {
335
335
  sqlite;
336
336
  namespace;
337
337
  collectionName;
338
+ statements = /* @__PURE__ */ new Map();
339
+ prepare(sql) {
340
+ let statement = this.statements.get(sql);
341
+ if (!statement) {
342
+ statement = this.sqlite.prepare(sql);
343
+ this.statements.set(sql, statement);
344
+ }
345
+ return statement;
346
+ }
338
347
  constructor(sqlite, namespace, collectionName) {
339
348
  this.sqlite = sqlite;
340
349
  this.namespace = namespace;
341
350
  this.collectionName = collectionName;
342
351
  }
343
352
  bumpCollectionSeq() {
344
- const row = this.sqlite.prepare("SELECT value FROM mockingbird_sequences WHERE namespace = ? AND name = ? AND kind = 'collection'").get(this.namespace, this.collectionName);
353
+ const row = this.prepare("SELECT value FROM mockingbird_sequences WHERE namespace = ? AND name = ? AND kind = 'collection'").get(this.namespace, this.collectionName);
345
354
  const next = (row?.value ?? 0) + 1;
346
- this.sqlite.prepare(`INSERT INTO mockingbird_sequences (namespace, name, kind, value) VALUES (?, ?, 'collection', ?)
355
+ this.prepare(`INSERT INTO mockingbird_sequences (namespace, name, kind, value) VALUES (?, ?, 'collection', ?)
347
356
  ON CONFLICT(namespace, name, kind) DO UPDATE SET value = excluded.value`).run(this.namespace, this.collectionName, next);
348
357
  return next;
349
358
  }
@@ -351,13 +360,13 @@ var Collection = class {
351
360
  return this.sqlite.transaction(() => this.bumpCollectionSeq());
352
361
  }
353
362
  get(id) {
354
- const row = this.sqlite.prepare("SELECT value FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
363
+ const row = this.prepare("SELECT value FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
355
364
  if (!row)
356
365
  return void 0;
357
366
  return JSON.parse(row.value).value;
358
367
  }
359
368
  has(id) {
360
- const row = this.sqlite.prepare("SELECT 1 AS ok FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
369
+ const row = this.prepare("SELECT 1 AS ok FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
361
370
  return row !== void 0;
362
371
  }
363
372
  /** Insert a new record, assigning it the next sequence number. */
@@ -365,7 +374,7 @@ var Collection = class {
365
374
  return this.sqlite.transaction(() => {
366
375
  const seq = this.bumpCollectionSeq();
367
376
  const stored = { seq, value };
368
- this.sqlite.prepare(`INSERT INTO mockingbird_records (namespace, collection, id, seq, value)
377
+ this.prepare(`INSERT INTO mockingbird_records (namespace, collection, id, seq, value)
369
378
  VALUES (?, ?, ?, ?, ?)
370
379
  ON CONFLICT(namespace, collection, id) DO UPDATE SET seq = excluded.seq, value = excluded.value`).run(this.namespace, this.collectionName, id, seq, JSON.stringify(stored));
371
380
  return stored;
@@ -374,25 +383,25 @@ var Collection = class {
374
383
  /** Replace an existing record's value, keeping its position. */
375
384
  update(id, value) {
376
385
  return this.sqlite.transaction(() => {
377
- const row = this.sqlite.prepare("SELECT seq, value FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
386
+ const row = this.prepare("SELECT seq, value FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
378
387
  if (!row)
379
388
  return void 0;
380
389
  const stored = { seq: row.seq, value };
381
- this.sqlite.prepare("UPDATE mockingbird_records SET value = ? WHERE namespace = ? AND collection = ? AND id = ?").run(JSON.stringify(stored), this.namespace, this.collectionName, id);
390
+ this.prepare("UPDATE mockingbird_records SET value = ? WHERE namespace = ? AND collection = ? AND id = ?").run(JSON.stringify(stored), this.namespace, this.collectionName, id);
382
391
  return stored;
383
392
  });
384
393
  }
385
394
  delete(id) {
386
- const result = this.sqlite.prepare("DELETE FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").run(this.namespace, this.collectionName, id);
395
+ const result = this.prepare("DELETE FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").run(this.namespace, this.collectionName, id);
387
396
  return result.changes > 0;
388
397
  }
389
398
  /** How many records the collection holds, without reading them. */
390
399
  count() {
391
- const row = this.sqlite.prepare("SELECT COUNT(*) AS n FROM mockingbird_records WHERE namespace = ? AND collection = ?").get(this.namespace, this.collectionName);
400
+ const row = this.prepare("SELECT COUNT(*) AS n FROM mockingbird_records WHERE namespace = ? AND collection = ?").get(this.namespace, this.collectionName);
392
401
  return Number(row?.n ?? 0);
393
402
  }
394
403
  list(options = {}) {
395
- const rows = this.sqlite.prepare("SELECT id, seq, value FROM mockingbird_records WHERE namespace = ? AND collection = ?").all(this.namespace, this.collectionName);
404
+ const rows = this.prepare("SELECT id, seq, value FROM mockingbird_records WHERE namespace = ? AND collection = ?").all(this.namespace, this.collectionName);
396
405
  const out = [];
397
406
  for (const row of rows) {
398
407
  const stored = JSON.parse(row.value);
@@ -3760,7 +3769,7 @@ var stateAdminRoutes = (routes) => {
3760
3769
  };
3761
3770
 
3762
3771
  // ../core/dist/version.js
3763
- var PACKAGE_VERSION = true ? "3.9.0" : UNRELEASED_VERSION;
3772
+ var PACKAGE_VERSION = true ? "3.10.0" : UNRELEASED_VERSION;
3764
3773
 
3765
3774
  // ../core/dist/webhooks.js
3766
3775
  var json4 = (status, body) => new Response(JSON.stringify(body), {
@@ -13894,4 +13903,4 @@ export {
13894
13903
  JunctionAPI,
13895
13904
  LabAccountConflict
13896
13905
  };
13897
- //# sourceMappingURL=chunk-ES4WU54W.js.map
13906
+ //# sourceMappingURL=chunk-GOEPHSRP.js.map