@askdb/client 1.0.0-beta.6 → 1.0.0-beta.8
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 +15 -15
- package/dist/client.d.ts +33 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +29 -7
- 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 +28 -10
package/README.md
CHANGED
|
@@ -1,12 +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 { openaiProvider } from "@askdb/ai-openai";
|
|
10
9
|
import { createAskDb } from "@askdb/client";
|
|
11
10
|
|
|
12
11
|
// bootstrapAskDbEnv() reads .env and askdb.config.* into an in-memory snapshot.
|
|
@@ -14,24 +13,28 @@ import { createAskDb } from "@askdb/client";
|
|
|
14
13
|
// Both calls are needed: bootstrap populates the store; getAskDbRuntimeConfig reads it.
|
|
15
14
|
bootstrapAskDbEnv();
|
|
16
15
|
const askdb = createAskDb({
|
|
17
|
-
config: getAskDbRuntimeConfig(),
|
|
18
|
-
providers: [openaiProvider], // the client builds its AI registry from these adapters
|
|
16
|
+
config: getAskDbRuntimeConfig(), // ai.provider in askdb.config.* picks the model
|
|
19
17
|
});
|
|
20
18
|
|
|
21
19
|
const { sql } = await askdb.ask("top 10 customers by revenue");
|
|
22
20
|
```
|
|
23
21
|
|
|
24
|
-
|
|
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.
|
|
25
27
|
|
|
26
28
|
## Per-call overrides
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
Each resolution axis accepts an optional per-call override:
|
|
29
31
|
|
|
30
32
|
| Override | Type | Default |
|
|
31
33
|
|---|---|---|
|
|
32
34
|
| `schema` | `{ path }` \| `{ json }` \| `{ schema }` \| `NormalizedSchema` | From `createAskDb({ schema })` → config `host.schemaPath`/`host.schemaJson` → env |
|
|
33
35
|
| `model` | `AskDbLanguageModel` | From registry via config `ai.aiEnv` |
|
|
34
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). |
|
|
35
38
|
|
|
36
39
|
```ts
|
|
37
40
|
const { sql } = await askdb.ask("count active users", {
|
|
@@ -42,24 +45,22 @@ const { sql } = await askdb.ask("count active users", {
|
|
|
42
45
|
|
|
43
46
|
## Parameterized output
|
|
44
47
|
|
|
45
|
-
`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
|
|
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.
|
|
46
49
|
|
|
47
50
|
```ts
|
|
48
|
-
import { bindPreparedQuery } from "@askdb/core";
|
|
49
|
-
|
|
50
51
|
const result = await askdb.ask("How many cities does Colorado have?", { tenantScope });
|
|
51
52
|
|
|
52
53
|
await pool.query(result.sql);
|
|
53
54
|
await pool.query(result.unboundSql!, result.params);
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
":tenant_agency_ids": authorizedAgencyIds,
|
|
58
|
-
});
|
|
56
|
+
// A new value, no model call.
|
|
57
|
+
const rebound = await askdb.bind(result.preparedQuery!, { state_name: "Utah" }, { tenantScope });
|
|
59
58
|
await pool.query(rebound.sql);
|
|
60
59
|
```
|
|
61
60
|
|
|
62
|
-
Every `ask()` is still one model call. Set `{ parameterize: false }` to opt out of the extra output tokens.
|
|
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
|
+
|
|
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()`.
|
|
63
64
|
|
|
64
65
|
## Multi-tenant usage
|
|
65
66
|
|
|
@@ -82,7 +83,6 @@ Inspect how schema, model, and dialect resolved on each call — useful for logg
|
|
|
82
83
|
```ts
|
|
83
84
|
const askdb = createAskDb({
|
|
84
85
|
config,
|
|
85
|
-
providers: [openaiProvider],
|
|
86
86
|
onResolve: ({ dialect, modelSource }) => {
|
|
87
87
|
console.log(`dialect=${dialect.dialect} (${dialect.source}), model=${modelSource}`);
|
|
88
88
|
},
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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";
|
|
3
|
+
import { type AnyNormalizedSchema, type AskDbLanguageModel, type AskDbModeV1, type AskDialectInput, type AskPipelineOptions, type AskPipelineResult, type BindGuardrails, type BoundQuery, type PreparedQuery, type QueryParameterValue, type ResolveTenantDescendants } from "@askdb/core";
|
|
4
4
|
import type { BuiltInDialectId } from "@askdb/core";
|
|
5
5
|
/** Where a schema comes from. A pre-loaded object short-circuits loading. */
|
|
6
6
|
export type SchemaSource = {
|
|
@@ -10,8 +10,16 @@ export type SchemaSource = {
|
|
|
10
10
|
} | {
|
|
11
11
|
schema: AnyNormalizedSchema;
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Per-call options. Everything is optional; anything set overrides the client default,
|
|
15
|
+
* except the two config `modes` settings, which a call can only tighten.
|
|
16
|
+
*/
|
|
17
|
+
export type AskOverrides = Omit<AskPipelineOptions, "question" | "schema" | "model" | "dialect" | "mode"> & {
|
|
18
|
+
/**
|
|
19
|
+
* Trust boundary for this call. Config `modes.askdbMode` (unset: `"schema_only"`) is the
|
|
20
|
+
* loosest mode a call gets: `"schema_only"` tightens it, `"bounded_results"` can't loosen it.
|
|
21
|
+
*/
|
|
22
|
+
mode?: AskDbModeV1;
|
|
15
23
|
schema?: SchemaSource | AnyNormalizedSchema;
|
|
16
24
|
model?: AskDbLanguageModel;
|
|
17
25
|
dialect?: AskDialectInput;
|
|
@@ -22,6 +30,13 @@ export type AskOverrides = Omit<AskPipelineOptions, "question" | "schema" | "mod
|
|
|
22
30
|
*/
|
|
23
31
|
reasoningEffort?: ReasoningEffort;
|
|
24
32
|
};
|
|
33
|
+
/** Options for {@link AskDbClient.bind}. Everything is optional; `schema` overrides the client's schema. */
|
|
34
|
+
export type BindOptions = Omit<BindGuardrails, "schema"> & {
|
|
35
|
+
/** The schema to check the template under. Defaults to the schema `ask()` resolves. */
|
|
36
|
+
schema?: SchemaSource | AnyNormalizedSchema;
|
|
37
|
+
/** Expands a `subtree` `tenantScope` before binding, as in `ask()`. */
|
|
38
|
+
resolveTenantDescendants?: ResolveTenantDescendants;
|
|
39
|
+
};
|
|
25
40
|
export type DialectResolution = {
|
|
26
41
|
dialect: AskDialectInput;
|
|
27
42
|
source: "override" | "config" | "schema" | "default";
|
|
@@ -32,9 +47,14 @@ export type CreateAskDbOptions = {
|
|
|
32
47
|
/** Runtime snapshot, e.g. from `getAskDbRuntimeConfig()`. */
|
|
33
48
|
config: AskDbRuntimeConfig;
|
|
34
49
|
/**
|
|
35
|
-
* AI
|
|
36
|
-
*
|
|
37
|
-
*
|
|
50
|
+
* Which AI providers the client can build models for. Optional: when neither
|
|
51
|
+
* `providers` nor `registry` is passed, every provider built into `@askdb/ai`
|
|
52
|
+
* is registered and `ai.provider` in your config picks one — install the
|
|
53
|
+
* matching SDK (e.g. `@ai-sdk/openai`), which is loaded on first use.
|
|
54
|
+
*
|
|
55
|
+
* Pass built-in names to restrict the set (`providers: ["openai"]`), or
|
|
56
|
+
* `AiProviderAdapter` objects for custom providers (mixable with names).
|
|
57
|
+
* Pass at most one of `providers` or `registry`.
|
|
38
58
|
*/
|
|
39
59
|
providers?: AiProviderAdapters;
|
|
40
60
|
/**
|
|
@@ -66,6 +86,13 @@ export type CreateAskDbOptions = {
|
|
|
66
86
|
};
|
|
67
87
|
export type AskDbClient = {
|
|
68
88
|
ask(question: string, overrides?: AskOverrides): Promise<AskPipelineResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Rebind a stored `preparedQuery` with new values, without calling the model. Checks the
|
|
91
|
+
* template under the client's schema (the one `ask()` resolves, unless `options.schema`
|
|
92
|
+
* is set), the given tenant scope and modes, expands a `subtree` scope with
|
|
93
|
+
* `options.resolveTenantDescendants`, and forwards to `@askdb/core`'s `bindPreparedQuery()`.
|
|
94
|
+
*/
|
|
95
|
+
bind(prepared: PreparedQuery, values: Record<string, QueryParameterValue | readonly QueryParameterValue[]>, options?: BindOptions): Promise<BoundQuery>;
|
|
69
96
|
/** Drop cached schema + model so the next ask() re-resolves them. */
|
|
70
97
|
reload(): void;
|
|
71
98
|
};
|
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,EAIL,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,
|
|
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,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAQpD,6EAA6E;AAC7E,MAAM,MAAM,YAAY,GACpB;IAAE,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;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAC;IAC/C,gGAAgG;IAChG,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,iBAAiB,CAAC;QAAC,WAAW,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC1G;;;;;OAKG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,CAAC,QAAQ,EAAE,MAAM,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,CAgNpE"}
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAiRegistry, resolveReasoningEffort, } from "@askdb/ai";
|
|
2
|
-
import { ask, isBuiltInDialectId, loadSchema, loadSchemaFromJson, SUPPORTED_DIALECT_IDS, } from "@askdb/core";
|
|
2
|
+
import { ask, bindPreparedQuery, expandTenantScope, isBuiltInDialectId, loadSchema, loadSchemaFromJson, parseAskDbModeV1, SUPPORTED_DIALECT_IDS, } from "@askdb/core";
|
|
3
3
|
import { DialectNotSupportedError, ModelNotConfiguredError, SchemaLoadError, SchemaNotConfiguredError, } from "./errors.js";
|
|
4
4
|
function resolveRegistry(options) {
|
|
5
5
|
if (options.registry && options.providers) {
|
|
@@ -7,10 +7,9 @@ function resolveRegistry(options) {
|
|
|
7
7
|
}
|
|
8
8
|
if (options.registry)
|
|
9
9
|
return options.registry;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
'(e.g. `providers: [openaiProvider]` from "@askdb/ai-openai"), or a prebuilt `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);
|
|
14
13
|
}
|
|
15
14
|
export function createAskDb(options) {
|
|
16
15
|
const { config } = options;
|
|
@@ -28,7 +27,8 @@ export function createAskDb(options) {
|
|
|
28
27
|
return `path (${src.path})`;
|
|
29
28
|
}
|
|
30
29
|
function loadFromSource(src, label) {
|
|
31
|
-
|
|
30
|
+
// A normalized schema, v1 or v2, passed as is: every one has `tables`, no SchemaSource does.
|
|
31
|
+
if ("tables" in src)
|
|
32
32
|
return src;
|
|
33
33
|
if ("schema" in src)
|
|
34
34
|
return src.schema;
|
|
@@ -133,8 +133,18 @@ export function createAskDb(options) {
|
|
|
133
133
|
cachedModel = undefined;
|
|
134
134
|
cachedAiConfig = undefined;
|
|
135
135
|
},
|
|
136
|
+
async bind(prepared, values, options = {}) {
|
|
137
|
+
const { schema: schemaOverride, resolveTenantDescendants, tenantScope, ...guardrails } = options;
|
|
138
|
+
const schema = schemaOverride ? loadFromSource(schemaOverride, "request") : resolveDefaultSchema();
|
|
139
|
+
const tenantPolicy = "schemaId" in schema ? schema.tenantPolicy : undefined;
|
|
140
|
+
// The same subtree expansion ask() runs, so a host never builds it by hand (ADR 0014).
|
|
141
|
+
const scope = tenantPolicy && tenantScope
|
|
142
|
+
? await expandTenantScope(tenantPolicy, tenantScope, resolveTenantDescendants)
|
|
143
|
+
: tenantScope;
|
|
144
|
+
return bindPreparedQuery(prepared, values, { ...guardrails, schema, ...(scope ? { tenantScope: scope } : {}) });
|
|
145
|
+
},
|
|
136
146
|
async ask(question, overrides = {}) {
|
|
137
|
-
const { schema: schemaOverride, model: modelOverride, dialect: dialectOverride, deps, reasoningEffort, ...rest } = overrides;
|
|
147
|
+
const { schema: schemaOverride, model: modelOverride, dialect: dialectOverride, deps, reasoningEffort, omitSensitiveIdentifiersFromNlToSqlPrompt, mode: callMode, ...rest } = overrides;
|
|
138
148
|
const schema = schemaOverride ? loadFromSource(schemaOverride, "request") : resolveDefaultSchema();
|
|
139
149
|
const dialect = resolveDialect(schema, dialectOverride);
|
|
140
150
|
const resolvedModel = await resolveModel(modelOverride, deps, reasoningEffort);
|
|
@@ -147,8 +157,20 @@ export function createAskDb(options) {
|
|
|
147
157
|
: resolvedModel.providerOptions !== undefined
|
|
148
158
|
? { ...deps, providerOptions: resolvedModel.providerOptions }
|
|
149
159
|
: deps);
|
|
160
|
+
// Config `modes.omitSensitiveFromPrompt` is a floor: a per-call override can
|
|
161
|
+
// tighten it (true) but never loosen it (false) when the operator enabled it.
|
|
162
|
+
const omitSensitive = omitSensitiveIdentifiersFromNlToSqlPrompt === true ||
|
|
163
|
+
config.modes?.omitSensitiveFromPrompt === true;
|
|
164
|
+
// Config `modes.askdbMode` (unset: `schema_only`) is the loosest mode a call gets:
|
|
165
|
+
// a per-call `mode` can tighten it to `schema_only`, never loosen it (ADR 0025). Both go
|
|
166
|
+
// through the same parser, so any accepted spelling tightens and an unknown mode throws.
|
|
167
|
+
const configMode = parseAskDbModeV1(config.modes?.askdbMode);
|
|
168
|
+
const requested = callMode == null ? undefined : parseAskDbModeV1(callMode);
|
|
169
|
+
const mode = requested === "schema_only" ? requested : configMode;
|
|
150
170
|
return ask({
|
|
151
171
|
...rest,
|
|
172
|
+
mode,
|
|
173
|
+
...(omitSensitive ? { omitSensitiveIdentifiersFromNlToSqlPrompt: true } : {}),
|
|
152
174
|
question,
|
|
153
175
|
schema,
|
|
154
176
|
model: resolvedModel.model,
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":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AAS;oBAClC,CAAC,CAAC,IAAI;oBACN,CAAC,CAAC,aAAa,CAAC,eAAe,KAAK,SAAS;wBAC3C,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,eAAe,EAAE,aAAa,CAAC,eAAe,EAAE;wBAC7D,CAAC,CAAC,IAAI,CAAC,CAAC;YAEd,6EAA6E;YAC7E,8EAA8E;YAC9E,MAAM,aAAa,GACjB,yCAAyC,KAAK,IAAI;gBAClD,MAAM,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,CAAC;YAEjD,mFAAmF;YACnF,yFAAyF;YACzF,yFAAyF;YACzF,MAAM,UAAU,GAAG,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YAC7D,MAAM,SAAS,GAAG,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YAC5E,MAAM,IAAI,GAAG,SAAS,KAAK,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;YAElE,OAAO,GAAG,CAAC;gBACT,GAAG,IAAI;gBACP,IAAI;gBACJ,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,yCAAyC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7E,QAAQ;gBACR,MAAM;gBACN,KAAK,EAAE,aAAa,CAAC,KAAK;gBAC1B,OAAO,EAAE,OAAO,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": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.8",
|
|
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",
|
|
@@ -37,22 +37,40 @@
|
|
|
37
37
|
"NOTICE"
|
|
38
38
|
],
|
|
39
39
|
"engines": {
|
|
40
|
-
"node": ">=22.
|
|
40
|
+
"node": ">=22.23.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"ai": "^
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
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.14",
|
|
48
|
+
"@askdb/core": "^1.0.0-beta.45",
|
|
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
|
+
}
|
|
46
64
|
},
|
|
47
65
|
"devDependencies": {
|
|
48
|
-
"
|
|
66
|
+
"@askdb/config": "1.0.0-beta.14",
|
|
67
|
+
"@askdb/core": "1.0.0-beta.45",
|
|
68
|
+
"ai": "^7.0.127",
|
|
49
69
|
"typescript": "^6.0.3",
|
|
50
|
-
"vitest": "^5.0.
|
|
51
|
-
"@askdb/config": "1.0.0-beta.12",
|
|
52
|
-
"@askdb/core": "1.0.0-beta.43"
|
|
70
|
+
"vitest": "^5.0.5"
|
|
53
71
|
},
|
|
54
72
|
"dependencies": {
|
|
55
|
-
"@askdb/ai": "^0.1.0-beta.
|
|
73
|
+
"@askdb/ai": "^0.1.0-beta.9"
|
|
56
74
|
},
|
|
57
75
|
"scripts": {
|
|
58
76
|
"build": "tsc -p tsconfig.build.json",
|