@smithers-orchestrator/control-plane 0.21.0 → 0.22.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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +10 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithers-orchestrator/control-plane",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "Durable organization, project, billing, usage, secret-reference, and audit primitives for hosted Smithers control planes.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -20,7 +20,7 @@
20
20
  "src/"
21
21
  ],
22
22
  "dependencies": {
23
- "@smithers-orchestrator/errors": "0.21.0"
23
+ "@smithers-orchestrator/errors": "0.22.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/bun": "latest",
package/src/index.js CHANGED
@@ -768,7 +768,11 @@ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
768
768
  observedAtMs,
769
769
  JSON.stringify(metadata),
770
770
  );
771
- const id = this.sqlite.query("SELECT last_insert_rowid() AS id").get().id;
771
+ const idRow = this.sqlite.query("SELECT last_insert_rowid() AS id").get();
772
+ if (!idRow) {
773
+ throw new Error("control-plane: failed to read last_insert_rowid() after inserting usage event");
774
+ }
775
+ const id = idRow.id;
772
776
  const row = this.sqlite.query(`
773
777
  SELECT id, org_id AS orgId, project_id AS projectId, run_id AS runId, metric, quantity, unit, observed_at_ms AS observedAtMs, metadata_json AS metadataJson
774
778
  FROM _smithers_cp_usage_events
@@ -990,7 +994,11 @@ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
990
994
  occurredAtMs,
991
995
  JSON.stringify(metadata),
992
996
  );
993
- const id = this.sqlite.query("SELECT last_insert_rowid() AS id").get().id;
997
+ const idRow = this.sqlite.query("SELECT last_insert_rowid() AS id").get();
998
+ if (!idRow) {
999
+ throw new Error("control-plane: failed to read last_insert_rowid() after inserting audit event");
1000
+ }
1001
+ const id = idRow.id;
994
1002
  const row = this.sqlite.query(`
995
1003
  SELECT id, org_id AS orgId, project_id AS projectId, actor_id AS actorId, action, target_type AS targetType, target_id AS targetId, occurred_at_ms AS occurredAtMs, metadata_json AS metadataJson
996
1004
  FROM _smithers_cp_audit_events