@crvouga/mockingbird-service-flex 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-flex
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
@@ -331,15 +331,24 @@ var Collection = class {
331
331
  sqlite;
332
332
  namespace;
333
333
  collectionName;
334
+ statements = /* @__PURE__ */ new Map();
335
+ prepare(sql) {
336
+ let statement = this.statements.get(sql);
337
+ if (!statement) {
338
+ statement = this.sqlite.prepare(sql);
339
+ this.statements.set(sql, statement);
340
+ }
341
+ return statement;
342
+ }
334
343
  constructor(sqlite, namespace, collectionName) {
335
344
  this.sqlite = sqlite;
336
345
  this.namespace = namespace;
337
346
  this.collectionName = collectionName;
338
347
  }
339
348
  bumpCollectionSeq() {
340
- const row = this.sqlite.prepare("SELECT value FROM mockingbird_sequences WHERE namespace = ? AND name = ? AND kind = 'collection'").get(this.namespace, this.collectionName);
349
+ const row = this.prepare("SELECT value FROM mockingbird_sequences WHERE namespace = ? AND name = ? AND kind = 'collection'").get(this.namespace, this.collectionName);
341
350
  const next = (row?.value ?? 0) + 1;
342
- this.sqlite.prepare(`INSERT INTO mockingbird_sequences (namespace, name, kind, value) VALUES (?, ?, 'collection', ?)
351
+ this.prepare(`INSERT INTO mockingbird_sequences (namespace, name, kind, value) VALUES (?, ?, 'collection', ?)
343
352
  ON CONFLICT(namespace, name, kind) DO UPDATE SET value = excluded.value`).run(this.namespace, this.collectionName, next);
344
353
  return next;
345
354
  }
@@ -347,13 +356,13 @@ var Collection = class {
347
356
  return this.sqlite.transaction(() => this.bumpCollectionSeq());
348
357
  }
349
358
  get(id) {
350
- const row = this.sqlite.prepare("SELECT value FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
359
+ const row = this.prepare("SELECT value FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
351
360
  if (!row)
352
361
  return void 0;
353
362
  return JSON.parse(row.value).value;
354
363
  }
355
364
  has(id) {
356
- const row = this.sqlite.prepare("SELECT 1 AS ok FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
365
+ const row = this.prepare("SELECT 1 AS ok FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
357
366
  return row !== void 0;
358
367
  }
359
368
  /** Insert a new record, assigning it the next sequence number. */
@@ -361,7 +370,7 @@ var Collection = class {
361
370
  return this.sqlite.transaction(() => {
362
371
  const seq = this.bumpCollectionSeq();
363
372
  const stored = { seq, value };
364
- this.sqlite.prepare(`INSERT INTO mockingbird_records (namespace, collection, id, seq, value)
373
+ this.prepare(`INSERT INTO mockingbird_records (namespace, collection, id, seq, value)
365
374
  VALUES (?, ?, ?, ?, ?)
366
375
  ON CONFLICT(namespace, collection, id) DO UPDATE SET seq = excluded.seq, value = excluded.value`).run(this.namespace, this.collectionName, id, seq, JSON.stringify(stored));
367
376
  return stored;
@@ -370,25 +379,25 @@ var Collection = class {
370
379
  /** Replace an existing record's value, keeping its position. */
371
380
  update(id, value) {
372
381
  return this.sqlite.transaction(() => {
373
- const row = this.sqlite.prepare("SELECT seq, value FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
382
+ const row = this.prepare("SELECT seq, value FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
374
383
  if (!row)
375
384
  return void 0;
376
385
  const stored = { seq: row.seq, value };
377
- this.sqlite.prepare("UPDATE mockingbird_records SET value = ? WHERE namespace = ? AND collection = ? AND id = ?").run(JSON.stringify(stored), this.namespace, this.collectionName, id);
386
+ this.prepare("UPDATE mockingbird_records SET value = ? WHERE namespace = ? AND collection = ? AND id = ?").run(JSON.stringify(stored), this.namespace, this.collectionName, id);
378
387
  return stored;
379
388
  });
380
389
  }
381
390
  delete(id) {
382
- const result = this.sqlite.prepare("DELETE FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").run(this.namespace, this.collectionName, id);
391
+ const result = this.prepare("DELETE FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").run(this.namespace, this.collectionName, id);
383
392
  return result.changes > 0;
384
393
  }
385
394
  /** How many records the collection holds, without reading them. */
386
395
  count() {
387
- const row = this.sqlite.prepare("SELECT COUNT(*) AS n FROM mockingbird_records WHERE namespace = ? AND collection = ?").get(this.namespace, this.collectionName);
396
+ const row = this.prepare("SELECT COUNT(*) AS n FROM mockingbird_records WHERE namespace = ? AND collection = ?").get(this.namespace, this.collectionName);
388
397
  return Number(row?.n ?? 0);
389
398
  }
390
399
  list(options = {}) {
391
- const rows = this.sqlite.prepare("SELECT id, seq, value FROM mockingbird_records WHERE namespace = ? AND collection = ?").all(this.namespace, this.collectionName);
400
+ const rows = this.prepare("SELECT id, seq, value FROM mockingbird_records WHERE namespace = ? AND collection = ?").all(this.namespace, this.collectionName);
392
401
  const out = [];
393
402
  for (const row of rows) {
394
403
  const stored = JSON.parse(row.value);
@@ -4088,7 +4097,7 @@ var stateAdminRoutes = (routes) => {
4088
4097
  };
4089
4098
 
4090
4099
  // ../core/dist/version.js
4091
- var PACKAGE_VERSION = true ? "3.9.0" : UNRELEASED_VERSION;
4100
+ var PACKAGE_VERSION = true ? "3.10.0" : UNRELEASED_VERSION;
4092
4101
 
4093
4102
  // ../core/dist/signing.js
4094
4103
  var encoder = new TextEncoder();
@@ -8323,4 +8332,4 @@ export {
8323
8332
  FlexAPI,
8324
8333
  isNextActionType
8325
8334
  };
8326
- //# sourceMappingURL=chunk-5DQQEGW6.js.map
8335
+ //# sourceMappingURL=chunk-NKBXNJ5B.js.map