@jini-ai/db 0.3.2 → 0.3.3

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,3 +1,7 @@
1
+ ## 0.3.3 — 2026-10-12
2
+
3
+ - Vault `findDefault` restates the default group in the normalized expressions and binds `is_default` as a dialect literal, so a host's partial default index is matched (SQLite and Postgres). Raw-column filters stay; results are unchanged.
4
+
1
5
  ## 0.3.1 — 2026-10-08
2
6
 
3
7
  - Tovu clean-up release: code Tovu moved into Jini, plus the Jini clean-up (see the commit log).
@@ -2,7 +2,8 @@ import { type VaultBatchOp, type VaultBatchResult, type VaultDefaultQuery, type
2
2
  import type { StorageKernel } from "../kernel/port.js";
3
3
  /** Fixed columns consumed by the adapter; hosts own DDL, foreign keys and migration provenance.
4
4
  * A partial unique default index and label index use the same scope as VaultRepoPort.
5
- * Nullable principal/provider scope columns must be normalized in those index expressions.
5
+ * Nullable principal/provider scope columns must be normalized in those index expressions, spelled
6
+ * as findDefault spells them, and the default index's predicate is `is_default = 1` on SQLite, `= true` on Postgres.
6
7
  * Read indexes: (workspace_id,kind,owner_key,principal_id,provider,is_default), and the same
7
8
  * group prefix plus (updated_at DESC,id DESC) with binary/C ID collation for promotion.
8
9
  * Singleton reads use the lookup index's (workspace_id,kind) prefix, optionally owner/principal.
@@ -56,7 +57,10 @@ export declare class SqlSecretsVaultRepo implements VaultRepoPort {
56
57
  applyBatch({ ops }: {
57
58
  ops: readonly VaultBatchOp[];
58
59
  }, _options?: VaultOptions): Promise<VaultBatchResult[]>;
59
- /** One indexed exact-group lookup; ciphertext is loaded only for the chosen default. */
60
+ /** One indexed exact-group lookup; ciphertext is loaded only for the chosen default.
61
+ * The group is restated in the default index's normalized expressions and `is_default` is a
62
+ * literal, else neither SQLite nor a generic Postgres plan can match the partial index (Tovu
63
+ * EXPLAIN 2026-10-12: SQLite fell back to a raw-column index, Postgres to the label index). */
60
64
  findDefault(input: VaultDefaultQuery, _options?: VaultOptions): Promise<VaultRecord | null>;
61
65
  list(input: VaultQuery, _options?: VaultOptions): Promise<VaultRecord[]>;
62
66
  put(input: {
@@ -86,10 +86,15 @@ export class SqlSecretsVaultRepo {
86
86
  return results;
87
87
  });
88
88
  }
89
- /** One indexed exact-group lookup; ciphertext is loaded only for the chosen default. */
89
+ /** One indexed exact-group lookup; ciphertext is loaded only for the chosen default.
90
+ * The group is restated in the default index's normalized expressions and `is_default` is a
91
+ * literal, else neither SQLite nor a generic Postgres plan can match the partial index (Tovu
92
+ * EXPLAIN 2026-10-12: SQLite fell back to a raw-column index, Postgres to the label index). */
90
93
  async findDefault(input, _options = {}) {
91
94
  const row = await this.kernel.run(db => this.scoped({ db, input }).selectAll()
92
- .where("is_default", "=", true).limit(1).executeTakeFirst());
95
+ .where(sql `(principal_id IS NULL)`, "=", input.principalId === null).where(sql `coalesce(principal_id,'')`, "=", input.principalId ?? "")
96
+ .where(sql `(provider IS NULL)`, "=", input.provider === null).where(sql `coalesce(provider,'')`, "=", input.provider ?? "")
97
+ .where(sql `is_default = ${sql.raw(this.kernel.dialect === "sqlite" ? "1" : "true")}`).limit(1).executeTakeFirst());
93
98
  return row ? fromRow(row) : null;
94
99
  }
95
100
  async list(input, _options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/db",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Database ports, connection helpers, ownership, isolated Kysely kernels and migrations. All peers are optional; drivers are injected.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -193,7 +193,7 @@
193
193
  },
194
194
  "dependencies": {
195
195
  "@jini-ai/core": "^0.4.3",
196
- "@jini-ai/platform": "^0.5.3"
196
+ "@jini-ai/platform": "^0.5.4"
197
197
  },
198
198
  "peerDependencies": {
199
199
  "kysely": "^0.29.6",