@askdb/client 1.0.0-beta.8 → 1.0.0-beta.9

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/README.md +6 -5
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -50,17 +50,18 @@ const { sql } = await askdb.ask("count active users", {
50
50
  ```ts
51
51
  const result = await askdb.ask("How many cities does Colorado have?", { tenantScope });
52
52
 
53
- await pool.query(result.sql);
53
+ // Tenant IDs are driver parameters by default (tenantSqlMode: "sql-params").
54
+ await pool.query(result.sql, result.tenantParams);
54
55
  await pool.query(result.unboundSql!, result.params);
55
56
 
56
57
  // A new value, no model call.
57
58
  const rebound = await askdb.bind(result.preparedQuery!, { state_name: "Utah" }, { tenantScope });
58
- await pool.query(rebound.sql);
59
+ await pool.query(rebound.sql, rebound.tenantParams ?? []);
59
60
  ```
60
61
 
61
- Every `ask()` is still one model call. Set `{ parameterize: false }` to opt out of the extra output tokens. Prefer `params` over `tenantParams` when using the new fields.
62
+ Every `ask()` is still one model call. Set `{ parameterize: false }` to opt out of the extra output tokens. Each SQL form runs with its own array: `sql` with `tenantParams`, `unboundSql` with `params` (which already holds the tenant IDs); never concatenate them. Set `tenantSqlMode: "sql-only"` to get the tenant IDs inlined in `sql` instead.
62
63
 
63
- `askdb.bind(prepared, values, options?)` wraps `@askdb/core`'s `bindPreparedQuery()`: it checks the stored template under the client's schema (or `options.schema`), the `tenantScope` you pass and the modes (`sensitiveGuardrailMode`, `acceptWarnings`), expands a `subtree` scope with `options.resolveTenantDescendants`, and renders the tenant IDs from the scope. Authorizing that scope remains the host's job, as for `ask()`.
64
+ `askdb.bind(prepared, values, options?)` wraps `@askdb/core`'s `bindPreparedQuery()`: it checks the stored template under the client's schema (or `options.schema`), the `tenantScope` you pass and the modes (`sensitiveGuardrailMode`, `acceptWarnings`), under the `dialect` you pass when `ask()` ran with your own `DialectSpec`, expands a `subtree` scope with `options.resolveTenantDescendants`, and renders the tenant IDs from the scope. Authorizing that scope remains the host's job, as for `ask()`.
64
65
 
65
66
  ## Multi-tenant usage
66
67
 
@@ -70,7 +71,7 @@ The schema and model caches are **per-client-instance**. For multi-tenant server
70
71
 
71
72
  ## `reload()`
72
73
 
73
- Drops the cached schema and model so the next `ask()` re-resolves them from config:
74
+ Drops the cached schema, model and AI config, so the next call resolves them again from the config snapshot the client was created with. To pick up a changed `askdb.config.*`, create a new client.
74
75
 
75
76
  ```ts
76
77
  askdb.reload();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askdb/client",
3
- "version": "1.0.0-beta.8",
3
+ "version": "1.0.0-beta.9",
4
4
  "description": "Config-aware AskDB facade: resolves schema, model, and dialect from config so callers only pass a question.",
5
5
  "keywords": [
6
6
  "askdb",
@@ -44,8 +44,8 @@
44
44
  "@ai-sdk/azure": "^4.0.0",
45
45
  "@ai-sdk/google": "^4.0.0",
46
46
  "@ai-sdk/openai": "^4.0.0",
47
- "@askdb/config": "^1.0.0-beta.14",
48
- "@askdb/core": "^1.0.0-beta.45",
47
+ "@askdb/config": "^1.0.0-beta.15",
48
+ "@askdb/core": "^1.0.0-beta.46",
49
49
  "ai": "^7.0.51"
50
50
  },
51
51
  "peerDependenciesMeta": {
@@ -63,8 +63,8 @@
63
63
  }
64
64
  },
65
65
  "devDependencies": {
66
- "@askdb/config": "1.0.0-beta.14",
67
- "@askdb/core": "1.0.0-beta.45",
66
+ "@askdb/config": "1.0.0-beta.15",
67
+ "@askdb/core": "1.0.0-beta.46",
68
68
  "ai": "^7.0.127",
69
69
  "typescript": "^6.0.3",
70
70
  "vitest": "^5.0.5"