@crvouga/mockingbird-service-kms 1.9.0 → 1.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-kms
2
2
 
3
+ ## 1.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
  ## 1.9.0 (2026-10-21)
4
15
 
5
16
  ### Features
@@ -4527,15 +4527,24 @@ var Collection = class {
4527
4527
  sqlite;
4528
4528
  namespace;
4529
4529
  collectionName;
4530
+ statements = /* @__PURE__ */ new Map();
4531
+ prepare(sql) {
4532
+ let statement = this.statements.get(sql);
4533
+ if (!statement) {
4534
+ statement = this.sqlite.prepare(sql);
4535
+ this.statements.set(sql, statement);
4536
+ }
4537
+ return statement;
4538
+ }
4530
4539
  constructor(sqlite, namespace, collectionName) {
4531
4540
  this.sqlite = sqlite;
4532
4541
  this.namespace = namespace;
4533
4542
  this.collectionName = collectionName;
4534
4543
  }
4535
4544
  bumpCollectionSeq() {
4536
- const row = this.sqlite.prepare("SELECT value FROM mockingbird_sequences WHERE namespace = ? AND name = ? AND kind = 'collection'").get(this.namespace, this.collectionName);
4545
+ const row = this.prepare("SELECT value FROM mockingbird_sequences WHERE namespace = ? AND name = ? AND kind = 'collection'").get(this.namespace, this.collectionName);
4537
4546
  const next = (row?.value ?? 0) + 1;
4538
- this.sqlite.prepare(`INSERT INTO mockingbird_sequences (namespace, name, kind, value) VALUES (?, ?, 'collection', ?)
4547
+ this.prepare(`INSERT INTO mockingbird_sequences (namespace, name, kind, value) VALUES (?, ?, 'collection', ?)
4539
4548
  ON CONFLICT(namespace, name, kind) DO UPDATE SET value = excluded.value`).run(this.namespace, this.collectionName, next);
4540
4549
  return next;
4541
4550
  }
@@ -4543,13 +4552,13 @@ var Collection = class {
4543
4552
  return this.sqlite.transaction(() => this.bumpCollectionSeq());
4544
4553
  }
4545
4554
  get(id) {
4546
- const row = this.sqlite.prepare("SELECT value FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
4555
+ const row = this.prepare("SELECT value FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
4547
4556
  if (!row)
4548
4557
  return void 0;
4549
4558
  return JSON.parse(row.value).value;
4550
4559
  }
4551
4560
  has(id) {
4552
- const row = this.sqlite.prepare("SELECT 1 AS ok FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
4561
+ const row = this.prepare("SELECT 1 AS ok FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
4553
4562
  return row !== void 0;
4554
4563
  }
4555
4564
  /** Insert a new record, assigning it the next sequence number. */
@@ -4557,7 +4566,7 @@ var Collection = class {
4557
4566
  return this.sqlite.transaction(() => {
4558
4567
  const seq = this.bumpCollectionSeq();
4559
4568
  const stored = { seq, value };
4560
- this.sqlite.prepare(`INSERT INTO mockingbird_records (namespace, collection, id, seq, value)
4569
+ this.prepare(`INSERT INTO mockingbird_records (namespace, collection, id, seq, value)
4561
4570
  VALUES (?, ?, ?, ?, ?)
4562
4571
  ON CONFLICT(namespace, collection, id) DO UPDATE SET seq = excluded.seq, value = excluded.value`).run(this.namespace, this.collectionName, id, seq, JSON.stringify(stored));
4563
4572
  return stored;
@@ -4566,25 +4575,25 @@ var Collection = class {
4566
4575
  /** Replace an existing record's value, keeping its position. */
4567
4576
  update(id, value) {
4568
4577
  return this.sqlite.transaction(() => {
4569
- const row = this.sqlite.prepare("SELECT seq, value FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
4578
+ const row = this.prepare("SELECT seq, value FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").get(this.namespace, this.collectionName, id);
4570
4579
  if (!row)
4571
4580
  return void 0;
4572
4581
  const stored = { seq: row.seq, value };
4573
- this.sqlite.prepare("UPDATE mockingbird_records SET value = ? WHERE namespace = ? AND collection = ? AND id = ?").run(JSON.stringify(stored), this.namespace, this.collectionName, id);
4582
+ this.prepare("UPDATE mockingbird_records SET value = ? WHERE namespace = ? AND collection = ? AND id = ?").run(JSON.stringify(stored), this.namespace, this.collectionName, id);
4574
4583
  return stored;
4575
4584
  });
4576
4585
  }
4577
4586
  delete(id) {
4578
- const result = this.sqlite.prepare("DELETE FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").run(this.namespace, this.collectionName, id);
4587
+ const result = this.prepare("DELETE FROM mockingbird_records WHERE namespace = ? AND collection = ? AND id = ?").run(this.namespace, this.collectionName, id);
4579
4588
  return result.changes > 0;
4580
4589
  }
4581
4590
  /** How many records the collection holds, without reading them. */
4582
4591
  count() {
4583
- const row = this.sqlite.prepare("SELECT COUNT(*) AS n FROM mockingbird_records WHERE namespace = ? AND collection = ?").get(this.namespace, this.collectionName);
4592
+ const row = this.prepare("SELECT COUNT(*) AS n FROM mockingbird_records WHERE namespace = ? AND collection = ?").get(this.namespace, this.collectionName);
4584
4593
  return Number(row?.n ?? 0);
4585
4594
  }
4586
4595
  list(options = {}) {
4587
- const rows = this.sqlite.prepare("SELECT id, seq, value FROM mockingbird_records WHERE namespace = ? AND collection = ?").all(this.namespace, this.collectionName);
4596
+ const rows = this.prepare("SELECT id, seq, value FROM mockingbird_records WHERE namespace = ? AND collection = ?").all(this.namespace, this.collectionName);
4588
4597
  const out = [];
4589
4598
  for (const row of rows) {
4590
4599
  const stored = JSON.parse(row.value);
@@ -8192,7 +8201,7 @@ var stateAdminRoutes = (routes) => {
8192
8201
  };
8193
8202
 
8194
8203
  // ../core/dist/version.js
8195
- var PACKAGE_VERSION = true ? "1.9.0" : UNRELEASED_VERSION;
8204
+ var PACKAGE_VERSION = true ? "1.10.0" : UNRELEASED_VERSION;
8196
8205
 
8197
8206
  // ../core/dist/webhooks.js
8198
8207
  var json4 = (status, body) => new Response(JSON.stringify(body), {
@@ -9825,4 +9834,4 @@ export {
9825
9834
  createRuntime2 as createRuntime,
9826
9835
  KmsAPI
9827
9836
  };
9828
- //# sourceMappingURL=chunk-W6RICL63.js.map
9837
+ //# sourceMappingURL=chunk-74IR63G7.js.map