@askdb/client 0.1.0-beta.1 → 1.0.0-beta.11
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/README.md +32 -9
- package/dist/client.d.ts +56 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +72 -26
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +34 -13
package/README.md
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
# @askdb/client
|
|
2
2
|
|
|
3
|
-
Config-aware AskDB facade. Resolves schema, model, and
|
|
3
|
+
Config-aware AskDB facade. Resolves schema, model, dialect, and mode from your runtime config so callers only pass a question.
|
|
4
4
|
|
|
5
5
|
## Quick start
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
import { bootstrapAskDbEnv, getAskDbRuntimeConfig } from "@askdb/config";
|
|
9
|
-
import { createAiRegistry } from "@askdb/ai";
|
|
10
|
-
import { openaiProvider } from "@askdb/ai-openai";
|
|
11
9
|
import { createAskDb } from "@askdb/client";
|
|
12
10
|
|
|
13
11
|
// bootstrapAskDbEnv() reads .env and askdb.config.* into an in-memory snapshot.
|
|
@@ -15,22 +13,28 @@ import { createAskDb } from "@askdb/client";
|
|
|
15
13
|
// Both calls are needed: bootstrap populates the store; getAskDbRuntimeConfig reads it.
|
|
16
14
|
bootstrapAskDbEnv();
|
|
17
15
|
const askdb = createAskDb({
|
|
18
|
-
config: getAskDbRuntimeConfig(),
|
|
19
|
-
registry: createAiRegistry([openaiProvider]),
|
|
16
|
+
config: getAskDbRuntimeConfig(), // ai.provider in askdb.config.* picks the model
|
|
20
17
|
});
|
|
21
18
|
|
|
22
19
|
const { sql } = await askdb.ask("top 10 customers by revenue");
|
|
23
20
|
```
|
|
24
21
|
|
|
22
|
+
Install the AI SDK package for whichever `ai.provider` your config selects — e.g. `npm i @askdb/client @askdb/core @askdb/config ai @ai-sdk/openai` (`@askdb/core` and `ai`, AI SDK 7, are required peers of the client; npm adds them for you, Yarn doesn't). With no `providers`/`registry` option, the client registers every provider built into `@askdb/ai` (OpenAI, Azure/Foundry, Google, Anthropic, Vercel AI Gateway); each loads its `@ai-sdk/*` package only when first used, and a missing one fails with an `npm i @ai-sdk/<provider>` hint.
|
|
23
|
+
|
|
24
|
+
Options: `providers: ["openai"]` restricts the set to named built-ins, and `AiProviderAdapter` objects add custom providers (`providers: ["openai", myAdapter]`). Advanced alternative: build a registry yourself with `createAiRegistry` from `@askdb/ai` and pass it as `registry` (e.g. to share one registry across several clients). Pass at most one of `providers` or `registry`.
|
|
25
|
+
|
|
26
|
+
To bypass config-driven model selection entirely, pass an AI SDK `LanguageModel` per call (`askdb.ask(q, { model })`) or call `ask()` from `@askdb/core` directly.
|
|
27
|
+
|
|
25
28
|
## Per-call overrides
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
Each resolution axis accepts an optional per-call override:
|
|
28
31
|
|
|
29
32
|
| Override | Type | Default |
|
|
30
33
|
|---|---|---|
|
|
31
|
-
| `schema` | `{ path }` \| `{ json }` \| `{ schema }` \| `NormalizedSchema` | From `createAskDb({ schema })` → config `host.
|
|
34
|
+
| `schema` | `{ path }` \| `{ json }` \| `{ schema }` \| `NormalizedSchema` | From `createAskDb({ schema })` → config `host.schemaJson` → `host.schemaPath` |
|
|
32
35
|
| `model` | `AskDbLanguageModel` | From registry via config `ai.aiEnv` |
|
|
33
36
|
| `dialect` | `AskDialectInput` | Config `dialect` → schema `provider` → `"postgres"` |
|
|
37
|
+
| `mode` | `AskDbModeV1` | Config `modes.askdbMode` → `"schema_only"`. A per-call mode can only tighten it: `"bounded_results"` runs the config mode (ADR 0025). |
|
|
34
38
|
|
|
35
39
|
```ts
|
|
36
40
|
const { sql } = await askdb.ask("count active users", {
|
|
@@ -39,6 +43,26 @@ const { sql } = await askdb.ask("count active users", {
|
|
|
39
43
|
});
|
|
40
44
|
```
|
|
41
45
|
|
|
46
|
+
## Parameterized output
|
|
47
|
+
|
|
48
|
+
`askdb.ask()` returns the same `AskPipelineResult` as `@askdb/core`'s `ask()`, including optional `unboundSql`, `params`, `parameters`, and `preparedQuery` when the model complies (default `parameterize: true`). The facade forwards options and returns the core result verbatim, `verdict` included.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
const result = await askdb.ask("How many cities does Colorado have?", { tenantScope });
|
|
52
|
+
|
|
53
|
+
// Tenant IDs are driver parameters by default (tenantSqlMode: "sql-params").
|
|
54
|
+
await pool.query(result.sql, result.tenantParams);
|
|
55
|
+
await pool.query(result.unboundSql!, result.params);
|
|
56
|
+
|
|
57
|
+
// A new value, no model call.
|
|
58
|
+
const rebound = await askdb.bind(result.preparedQuery!, { state_name: "Utah" }, { tenantScope });
|
|
59
|
+
await pool.query(rebound.sql, rebound.tenantParams ?? []);
|
|
60
|
+
```
|
|
61
|
+
|
|
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.
|
|
63
|
+
|
|
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()`.
|
|
65
|
+
|
|
42
66
|
## Multi-tenant usage
|
|
43
67
|
|
|
44
68
|
The schema and model caches are **per-client-instance**. For multi-tenant servers where each tenant has a different schema, either:
|
|
@@ -47,7 +71,7 @@ The schema and model caches are **per-client-instance**. For multi-tenant server
|
|
|
47
71
|
|
|
48
72
|
## `reload()`
|
|
49
73
|
|
|
50
|
-
Drops the cached schema and
|
|
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.
|
|
51
75
|
|
|
52
76
|
```ts
|
|
53
77
|
askdb.reload();
|
|
@@ -60,7 +84,6 @@ Inspect how schema, model, and dialect resolved on each call — useful for logg
|
|
|
60
84
|
```ts
|
|
61
85
|
const askdb = createAskDb({
|
|
62
86
|
config,
|
|
63
|
-
registry,
|
|
64
87
|
onResolve: ({ dialect, modelSource }) => {
|
|
65
88
|
console.log(`dialect=${dialect.dialect} (${dialect.source}), model=${modelSource}`);
|
|
66
89
|
},
|
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AiProviderAdapters, type AiRegistry, type ReasoningEffort } from "@askdb/ai";
|
|
2
2
|
import type { AskDbRuntimeConfig } from "@askdb/config";
|
|
3
|
-
import { type AnyNormalizedSchema, type AskDbLanguageModel, type AskDialectInput, type AskPipelineOptions, type AskPipelineResult } from "@askdb/core";
|
|
4
|
-
import type { BuiltInDialectId } from "@askdb/core";
|
|
3
|
+
import { type AnyNormalizedSchema, type AskDbLanguageModel, type AskDbModeV1, type AskDialectInput, type AskPipelineOptions, type AskPipelineResult, type BindGuardrails, type BuiltInDialectId, type BoundQuery, type PreparedQuery, type QueryParameterValue, type ResolveTenantDescendants } from "@askdb/core";
|
|
5
4
|
/** Where a schema comes from. A pre-loaded object short-circuits loading. */
|
|
6
5
|
export type SchemaSource = {
|
|
7
6
|
path: string;
|
|
@@ -10,11 +9,32 @@ export type SchemaSource = {
|
|
|
10
9
|
} | {
|
|
11
10
|
schema: AnyNormalizedSchema;
|
|
12
11
|
};
|
|
13
|
-
/**
|
|
14
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Per-call options. Everything is optional; anything set overrides the client default,
|
|
14
|
+
* except the two config `modes` settings, which a call can only tighten.
|
|
15
|
+
*/
|
|
16
|
+
export type AskOverrides = Omit<AskPipelineOptions, "question" | "schema" | "model" | "dialect" | "mode"> & {
|
|
17
|
+
/**
|
|
18
|
+
* Trust boundary for this call. Config `modes.askdbMode` (unset: `"schema_only"`) is the
|
|
19
|
+
* loosest mode a call gets: `"schema_only"` tightens it, `"bounded_results"` can't loosen it.
|
|
20
|
+
*/
|
|
21
|
+
mode?: AskDbModeV1;
|
|
15
22
|
schema?: SchemaSource | AnyNormalizedSchema;
|
|
16
23
|
model?: AskDbLanguageModel;
|
|
17
24
|
dialect?: AskDialectInput;
|
|
25
|
+
/**
|
|
26
|
+
* Provider-portable reasoning/latency effort for this call, overriding the
|
|
27
|
+
* client default and `askdb.config.ts`'s `ai.reasoning.nlToSql`/`effort`.
|
|
28
|
+
* Ignored when `model` or `deps.generateText` is also set (BYO paths).
|
|
29
|
+
*/
|
|
30
|
+
reasoningEffort?: ReasoningEffort;
|
|
31
|
+
};
|
|
32
|
+
/** Options for {@link AskDbClient.bind}. Everything is optional; `schema` overrides the client's schema. */
|
|
33
|
+
export type BindOptions = Omit<BindGuardrails, "schema"> & {
|
|
34
|
+
/** The schema to check the template under. Defaults to the schema `ask()` resolves. */
|
|
35
|
+
schema?: SchemaSource | AnyNormalizedSchema;
|
|
36
|
+
/** Expands a `subtree` `tenantScope` before binding, as in `ask()`. */
|
|
37
|
+
resolveTenantDescendants?: ResolveTenantDescendants;
|
|
18
38
|
};
|
|
19
39
|
export type DialectResolution = {
|
|
20
40
|
dialect: AskDialectInput;
|
|
@@ -25,9 +45,23 @@ export type DialectResolution = {
|
|
|
25
45
|
export type CreateAskDbOptions = {
|
|
26
46
|
/** Runtime snapshot, e.g. from `getAskDbRuntimeConfig()`. */
|
|
27
47
|
config: AskDbRuntimeConfig;
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Which AI providers the client can build models for. Optional: when neither
|
|
50
|
+
* `providers` nor `registry` is passed, every provider built into `@askdb/ai`
|
|
51
|
+
* is registered and `ai.provider` in your config picks one — install the
|
|
52
|
+
* matching SDK (e.g. `@ai-sdk/openai`), which is loaded on first use.
|
|
53
|
+
*
|
|
54
|
+
* Pass built-in names to restrict the set (`providers: ["openai"]`), or
|
|
55
|
+
* `AiProviderAdapter` objects for custom providers (mixable with names).
|
|
56
|
+
* Pass at most one of `providers` or `registry`.
|
|
57
|
+
*/
|
|
58
|
+
providers?: AiProviderAdapters;
|
|
59
|
+
/**
|
|
60
|
+
* Prebuilt AI registry from `createAiRegistry(...)` — advanced alternative
|
|
61
|
+
* to `providers`, e.g. to share one registry across several clients.
|
|
62
|
+
*/
|
|
63
|
+
registry?: AiRegistry;
|
|
64
|
+
/** Default schema source. Falls back to config `host.schemaJson`, then `host.schemaPath`. */
|
|
31
65
|
schema?: SchemaSource;
|
|
32
66
|
/** Default dialect override. Falls back to config.dialect → schema.provider → "postgres". */
|
|
33
67
|
dialect?: BuiltInDialectId;
|
|
@@ -41,9 +75,23 @@ export type CreateAskDbOptions = {
|
|
|
41
75
|
dialect: DialectResolution;
|
|
42
76
|
modelSource: "override" | "registry" | "mock";
|
|
43
77
|
}) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Client-level default reasoning/latency effort for NL→SQL generation
|
|
80
|
+
* (`ask()`). When set, takes precedence over `askdb.config.ts`'s
|
|
81
|
+
* `ai.reasoning.nlToSql`/`effort` env resolution; overridden per-call by
|
|
82
|
+
* `AskOverrides.reasoningEffort`.
|
|
83
|
+
*/
|
|
84
|
+
reasoningEffort?: ReasoningEffort;
|
|
44
85
|
};
|
|
45
86
|
export type AskDbClient = {
|
|
46
87
|
ask(question: string, overrides?: AskOverrides): Promise<AskPipelineResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Rebind a stored `preparedQuery` with new values, without calling the model. Checks the
|
|
90
|
+
* template under the client's schema (the one `ask()` resolves, unless `options.schema`
|
|
91
|
+
* is set), the given tenant scope and modes, expands a `subtree` scope with
|
|
92
|
+
* `options.resolveTenantDescendants`, and forwards to `@askdb/core`'s `bindPreparedQuery()`.
|
|
93
|
+
*/
|
|
94
|
+
bind(prepared: PreparedQuery, values: Record<string, QueryParameterValue | readonly QueryParameterValue[]>, options?: BindOptions): Promise<BoundQuery>;
|
|
47
95
|
/** Drop cached schema + model so the next ask() re-resolves them. */
|
|
48
96
|
reload(): void;
|
|
49
97
|
};
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EASL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC9B,MAAM,aAAa,CAAC;AAQrB,6EAA6E;AAC7E,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,MAAM,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAEpC;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,kBAAkB,EAClB,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CACrD,GAAG;IACF;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,YAAY,GAAG,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AAM,EAAE,SAAS,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC5E;;;;;OAKG;IACH,IAAI,CACF,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,mBAAmB,EAAE,CAAC,EAC5E,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,qEAAqE;IACrE,MAAM,IAAI,IAAI,CAAC;CAChB,CAAC;AAYF,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAsMpE"}
|
package/dist/client.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createAiRegistry, resolveReasoningEffort, } from "@askdb/ai";
|
|
2
|
+
import { ask, bindPreparedQuery, expandTenantScope, isBuiltInDialectId, loadSchema, loadSchemaFromJson, parseAskDbModeV1, SUPPORTED_DIALECT_IDS, } from "@askdb/core";
|
|
2
3
|
import { DialectNotSupportedError, ModelNotConfiguredError, SchemaLoadError, SchemaNotConfiguredError, } from "./errors.js";
|
|
4
|
+
function resolveRegistry(options) {
|
|
5
|
+
if (options.registry && options.providers) {
|
|
6
|
+
throw new Error("createAskDb: pass either `providers` or `registry`, not both.");
|
|
7
|
+
}
|
|
8
|
+
if (options.registry)
|
|
9
|
+
return options.registry;
|
|
10
|
+
// No providers/registry: register every built-in provider (each loads its
|
|
11
|
+
// @ai-sdk/* package lazily), so `createAskDb({ config })` is enough.
|
|
12
|
+
return createAiRegistry(options.providers);
|
|
13
|
+
}
|
|
3
14
|
export function createAskDb(options) {
|
|
4
|
-
const { config
|
|
15
|
+
const { config } = options;
|
|
16
|
+
const registry = resolveRegistry(options);
|
|
5
17
|
let cachedSchema;
|
|
6
18
|
let cachedModel;
|
|
19
|
+
let cachedAiConfig;
|
|
7
20
|
function schemaSourceLabel(src) {
|
|
8
|
-
if ("schemaId" in src)
|
|
9
|
-
return "schema";
|
|
10
21
|
if ("schema" in src)
|
|
11
22
|
return "schema";
|
|
12
23
|
if ("json" in src)
|
|
@@ -14,7 +25,8 @@ export function createAskDb(options) {
|
|
|
14
25
|
return `path (${src.path})`;
|
|
15
26
|
}
|
|
16
27
|
function loadFromSource(src, label) {
|
|
17
|
-
|
|
28
|
+
// A normalized schema, v1 or v2, passed as is: every one has `tables`, no SchemaSource does.
|
|
29
|
+
if ("tables" in src)
|
|
18
30
|
return src;
|
|
19
31
|
if ("schema" in src)
|
|
20
32
|
return src.schema;
|
|
@@ -35,23 +47,20 @@ export function createAskDb(options) {
|
|
|
35
47
|
return cachedSchema;
|
|
36
48
|
}
|
|
37
49
|
const host = config.structured.host;
|
|
38
|
-
const
|
|
39
|
-
const json = (host?.schemaJson?.trim() || env["ASKDB_SCHEMA_JSON"]?.trim()) || undefined;
|
|
50
|
+
const json = host?.schemaJson?.trim();
|
|
40
51
|
if (json) {
|
|
41
|
-
cachedSchema = loadFromSource({ json },
|
|
52
|
+
cachedSchema = loadFromSource({ json }, "host.schemaJson");
|
|
42
53
|
return cachedSchema;
|
|
43
54
|
}
|
|
44
|
-
const path =
|
|
55
|
+
const path = host?.schemaPath?.trim();
|
|
45
56
|
if (path) {
|
|
46
|
-
cachedSchema = loadFromSource({ path },
|
|
57
|
+
cachedSchema = loadFromSource({ path }, `host.schemaPath (${path})`);
|
|
47
58
|
return cachedSchema;
|
|
48
59
|
}
|
|
49
60
|
throw new SchemaNotConfiguredError("No schema configured. Pass `schema` to createAskDb() or per-call, or set host.schemaPath / host.schemaJson in askdb.config.*.");
|
|
50
61
|
}
|
|
51
62
|
function schemaProviderOf(schema) {
|
|
52
|
-
return "provider" in schema && typeof schema
|
|
53
|
-
? schema["provider"]
|
|
54
|
-
: undefined;
|
|
63
|
+
return "provider" in schema && typeof schema.provider === "string" ? schema.provider : undefined;
|
|
55
64
|
}
|
|
56
65
|
function resolveDialect(schema, override) {
|
|
57
66
|
if (override)
|
|
@@ -85,46 +94,83 @@ export function createAskDb(options) {
|
|
|
85
94
|
}
|
|
86
95
|
return { dialect: "postgres", source: "default" };
|
|
87
96
|
}
|
|
88
|
-
async function resolveModel(override, deps) {
|
|
97
|
+
async function resolveModel(override, deps, reasoningEffortOverride) {
|
|
89
98
|
if (override)
|
|
90
99
|
return { model: override, source: "override" };
|
|
91
100
|
if (deps?.generateText) {
|
|
92
|
-
return { model: undefined,
|
|
101
|
+
return { model: undefined, source: "mock", mockDeps: deps };
|
|
93
102
|
}
|
|
94
103
|
const mockSql = config.dev.mockSql;
|
|
95
104
|
if (mockSql !== undefined) {
|
|
96
105
|
return {
|
|
97
106
|
model: undefined,
|
|
98
|
-
deps: { generateText: (async () => ({ text: mockSql })) },
|
|
99
107
|
source: "mock",
|
|
108
|
+
mockDeps: { generateText: (async () => ({ text: mockSql })) },
|
|
100
109
|
};
|
|
101
110
|
}
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
cachedModel
|
|
108
|
-
|
|
111
|
+
if (!cachedAiConfig) {
|
|
112
|
+
cachedAiConfig = registry.resolveAiConfig(config.ai.aiEnv);
|
|
113
|
+
if (!cachedAiConfig)
|
|
114
|
+
throw new ModelNotConfiguredError(registry.keyMissingMessage("NL→SQL generation"));
|
|
115
|
+
}
|
|
116
|
+
if (!cachedModel) {
|
|
117
|
+
cachedModel = await registry.createLanguageModel(cachedAiConfig);
|
|
118
|
+
}
|
|
119
|
+
const reasoningEffort = resolveReasoningEffort(config.ai.aiEnv, "nlToSql", reasoningEffortOverride ?? options.reasoningEffort);
|
|
120
|
+
const providerOptions = reasoningEffort
|
|
121
|
+
? registry.resolveProviderOptions(cachedAiConfig, { reasoningEffort })
|
|
122
|
+
: undefined;
|
|
123
|
+
return { model: cachedModel, source: "registry", providerOptions };
|
|
109
124
|
}
|
|
110
125
|
return {
|
|
111
126
|
reload() {
|
|
112
127
|
cachedSchema = undefined;
|
|
113
128
|
cachedModel = undefined;
|
|
129
|
+
cachedAiConfig = undefined;
|
|
130
|
+
},
|
|
131
|
+
async bind(prepared, values, options = {}) {
|
|
132
|
+
const { schema: schemaOverride, resolveTenantDescendants, tenantScope, ...guardrails } = options;
|
|
133
|
+
const schema = schemaOverride ? loadFromSource(schemaOverride, "request") : resolveDefaultSchema();
|
|
134
|
+
const tenantPolicy = "schemaId" in schema ? schema.tenantPolicy : undefined;
|
|
135
|
+
// The same subtree expansion ask() runs, so a host never builds it by hand (ADR 0014).
|
|
136
|
+
const scope = tenantPolicy && tenantScope
|
|
137
|
+
? await expandTenantScope(tenantPolicy, tenantScope, resolveTenantDescendants)
|
|
138
|
+
: tenantScope;
|
|
139
|
+
return bindPreparedQuery(prepared, values, { ...guardrails, schema, ...(scope ? { tenantScope: scope } : {}) });
|
|
114
140
|
},
|
|
115
141
|
async ask(question, overrides = {}) {
|
|
116
|
-
const { schema: schemaOverride, model: modelOverride, dialect: dialectOverride, deps, ...rest } = overrides;
|
|
142
|
+
const { schema: schemaOverride, model: modelOverride, dialect: dialectOverride, deps, reasoningEffort, omitSensitiveIdentifiersFromNlToSqlPrompt, mode: callMode, ...rest } = overrides;
|
|
117
143
|
const schema = schemaOverride ? loadFromSource(schemaOverride, "request") : resolveDefaultSchema();
|
|
118
144
|
const dialect = resolveDialect(schema, dialectOverride);
|
|
119
|
-
const resolvedModel = await resolveModel(modelOverride, deps);
|
|
145
|
+
const resolvedModel = await resolveModel(modelOverride, deps, reasoningEffort);
|
|
120
146
|
options.onResolve?.({ dialect, modelSource: resolvedModel.source });
|
|
147
|
+
// An explicit `deps.providerOptions` from the caller always wins over
|
|
148
|
+
// the computed one; otherwise merge the resolved reasoning effort in.
|
|
149
|
+
const finalDeps = resolvedModel.mockDeps ??
|
|
150
|
+
(deps?.providerOptions !== undefined
|
|
151
|
+
? deps
|
|
152
|
+
: resolvedModel.providerOptions !== undefined
|
|
153
|
+
? { ...deps, providerOptions: resolvedModel.providerOptions }
|
|
154
|
+
: deps);
|
|
155
|
+
// Config `modes.omitSensitiveFromPrompt` is a floor: a per-call override can
|
|
156
|
+
// tighten it (true) but never loosen it (false) when the operator enabled it.
|
|
157
|
+
const omitSensitive = omitSensitiveIdentifiersFromNlToSqlPrompt === true ||
|
|
158
|
+
config.modes?.omitSensitiveFromPrompt === true;
|
|
159
|
+
// Config `modes.askdbMode` (unset: `schema_only`) is the loosest mode a call gets:
|
|
160
|
+
// a per-call `mode` can tighten it to `schema_only`, never loosen it (ADR 0025). Both go
|
|
161
|
+
// through the same parser, so any accepted spelling tightens and an unknown mode throws.
|
|
162
|
+
const configMode = parseAskDbModeV1(config.modes?.askdbMode);
|
|
163
|
+
const requested = callMode == null ? undefined : parseAskDbModeV1(callMode);
|
|
164
|
+
const mode = requested === "schema_only" ? requested : configMode;
|
|
121
165
|
return ask({
|
|
122
166
|
...rest,
|
|
167
|
+
mode,
|
|
168
|
+
...(omitSensitive ? { omitSensitiveIdentifiersFromNlToSqlPrompt: true } : {}),
|
|
123
169
|
question,
|
|
124
170
|
schema,
|
|
125
171
|
model: resolvedModel.model,
|
|
126
172
|
dialect: dialect.dialect,
|
|
127
|
-
...(
|
|
173
|
+
...(finalDeps ? { deps: finalDeps } : {}),
|
|
128
174
|
});
|
|
129
175
|
},
|
|
130
176
|
};
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,sBAAsB,GAKvB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,GAAG,EACH,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,GActB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,wBAAwB,EACxB,uBAAu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CAAC,OAAO;gBACxB,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC1C,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createAskDb, type AskDbClient, type CreateAskDbOptions, type AskOverrides, type SchemaSource, type DialectResolution, } from "./client.js";
|
|
1
|
+
export { createAskDb, type AskDbClient, type CreateAskDbOptions, type AskOverrides, type BindOptions, type SchemaSource, type DialectResolution, } from "./client.js";
|
|
2
2
|
export { DialectNotSupportedError, ModelNotConfiguredError, SchemaLoadError, SchemaNotConfiguredError, } from "./errors.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,eAAe,EACf,wBAAwB,GACzB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,eAAe,EACf,wBAAwB,GACzB,MAAM,aAAa,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAOZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,eAAe,EACf,wBAAwB,GACzB,MAAM,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askdb/client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0-beta.11",
|
|
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",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"facade",
|
|
9
9
|
"client"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://askdb.tools/reference/client-api/",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/Ygilany/AskDB/issues"
|
|
14
14
|
},
|
|
@@ -20,12 +20,14 @@
|
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"author": "Yahya Gilany",
|
|
22
22
|
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
23
24
|
"main": "./dist/index.js",
|
|
24
25
|
"types": "./dist/index.d.ts",
|
|
25
26
|
"exports": {
|
|
26
27
|
".": {
|
|
27
28
|
"types": "./dist/index.d.ts",
|
|
28
|
-
"import": "./dist/index.js"
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"default": "./dist/index.js"
|
|
29
31
|
}
|
|
30
32
|
},
|
|
31
33
|
"files": [
|
|
@@ -35,21 +37,40 @@
|
|
|
35
37
|
"NOTICE"
|
|
36
38
|
],
|
|
37
39
|
"engines": {
|
|
38
|
-
"node": ">=
|
|
40
|
+
"node": ">=22.23.4"
|
|
39
41
|
},
|
|
40
42
|
"peerDependencies": {
|
|
41
|
-
"ai": "^
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
43
|
+
"@ai-sdk/anthropic": "^4.0.0",
|
|
44
|
+
"@ai-sdk/azure": "^4.0.0",
|
|
45
|
+
"@ai-sdk/google": "^4.0.0",
|
|
46
|
+
"@ai-sdk/openai": "^4.0.0",
|
|
47
|
+
"@askdb/config": "^1.0.0-beta.17",
|
|
48
|
+
"@askdb/core": "^1.0.0-beta.48",
|
|
49
|
+
"ai": "^7.0.51"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"@ai-sdk/anthropic": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"@ai-sdk/azure": {
|
|
56
|
+
"optional": true
|
|
57
|
+
},
|
|
58
|
+
"@ai-sdk/google": {
|
|
59
|
+
"optional": true
|
|
60
|
+
},
|
|
61
|
+
"@ai-sdk/openai": {
|
|
62
|
+
"optional": true
|
|
63
|
+
}
|
|
45
64
|
},
|
|
46
65
|
"devDependencies": {
|
|
47
|
-
"
|
|
66
|
+
"@askdb/config": "1.0.0-beta.17",
|
|
67
|
+
"@askdb/core": "1.0.0-beta.48",
|
|
68
|
+
"ai": "^7.0.127",
|
|
48
69
|
"typescript": "^6.0.3",
|
|
49
|
-
"vitest": "^
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"@askdb/
|
|
70
|
+
"vitest": "^5.0.5"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@askdb/ai": "^0.1.0-beta.10"
|
|
53
74
|
},
|
|
54
75
|
"scripts": {
|
|
55
76
|
"build": "tsc -p tsconfig.build.json",
|