@askdb/core 1.0.0-beta.43 → 1.0.0-beta.45
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 -12
- package/dist/ask.d.ts +39 -38
- package/dist/ask.d.ts.map +1 -1
- package/dist/ask.js +135 -309
- package/dist/ask.js.map +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/enrichment/index.d.ts.map +1 -1
- package/dist/enrichment/prompt.d.ts +3 -3
- package/dist/enrichment/prompt.d.ts.map +1 -1
- package/dist/enrichment/prompt.js +41 -17
- package/dist/enrichment/prompt.js.map +1 -1
- package/dist/enrichment/suggest.d.ts +2 -2
- package/dist/enrichment/suggest.d.ts.map +1 -1
- package/dist/enrichment/suggest.js +6 -2
- package/dist/enrichment/suggest.js.map +1 -1
- package/dist/enrichment/types.d.ts +20 -1
- package/dist/enrichment/types.d.ts.map +1 -1
- package/dist/errors.d.ts +68 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +21 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/retrieval/synthesize-ddl.d.ts +11 -1
- package/dist/retrieval/synthesize-ddl.d.ts.map +1 -1
- package/dist/retrieval/synthesize-ddl.js +39 -34
- package/dist/retrieval/synthesize-ddl.js.map +1 -1
- package/dist/schema/normalize.d.ts +16 -0
- package/dist/schema/normalize.d.ts.map +1 -1
- package/dist/schema/normalize.js +1 -0
- package/dist/schema/normalize.js.map +1 -1
- package/dist/schema/v2/format.d.ts +35 -1
- package/dist/schema/v2/format.d.ts.map +1 -1
- package/dist/schema/v2/format.js +69 -22
- package/dist/schema/v2/format.js.map +1 -1
- package/dist/schema/v2/index.d.ts +2 -0
- package/dist/schema/v2/index.d.ts.map +1 -1
- package/dist/schema/v2/index.js +1 -0
- package/dist/schema/v2/index.js.map +1 -1
- package/dist/schema/v2/loader.d.ts +30 -4
- package/dist/schema/v2/loader.d.ts.map +1 -1
- package/dist/schema/v2/loader.js +90 -28
- package/dist/schema/v2/loader.js.map +1 -1
- package/dist/schema/v2/mentions.d.ts +43 -0
- package/dist/schema/v2/mentions.d.ts.map +1 -0
- package/dist/schema/v2/mentions.js +101 -0
- package/dist/schema/v2/mentions.js.map +1 -0
- package/dist/schema/v2/normalized.d.ts +5 -0
- package/dist/schema/v2/normalized.d.ts.map +1 -1
- package/dist/schema/v2/tenant-policy.d.ts +2 -2
- package/dist/sql/bind.d.ts +18 -5
- package/dist/sql/bind.d.ts.map +1 -1
- package/dist/sql/bind.js +36 -15
- package/dist/sql/bind.js.map +1 -1
- package/dist/sql/dialect-spec.d.ts +27 -1
- package/dist/sql/dialect-spec.d.ts.map +1 -1
- package/dist/sql/dialect-spec.js +20 -1
- package/dist/sql/dialect-spec.js.map +1 -1
- package/dist/sql/generate.d.ts +19 -11
- package/dist/sql/generate.d.ts.map +1 -1
- package/dist/sql/generate.js +72 -34
- package/dist/sql/generate.js.map +1 -1
- package/dist/sql/guardrail-decide.d.ts +56 -0
- package/dist/sql/guardrail-decide.d.ts.map +1 -0
- package/dist/sql/guardrail-decide.js +161 -0
- package/dist/sql/guardrail-decide.js.map +1 -0
- package/dist/sql/guardrails.d.ts +52 -0
- package/dist/sql/guardrails.d.ts.map +1 -0
- package/dist/sql/guardrails.js +100 -0
- package/dist/sql/guardrails.js.map +1 -0
- package/dist/sql/index.d.ts +4 -2
- package/dist/sql/index.d.ts.map +1 -1
- package/dist/sql/index.js +4 -2
- package/dist/sql/index.js.map +1 -1
- package/dist/sql/lexer.d.ts +13 -0
- package/dist/sql/lexer.d.ts.map +1 -1
- package/dist/sql/lexer.js +42 -7
- package/dist/sql/lexer.js.map +1 -1
- package/dist/sql/prompt-identifiers.d.ts +20 -0
- package/dist/sql/prompt-identifiers.d.ts.map +1 -0
- package/dist/sql/prompt-identifiers.js +64 -0
- package/dist/sql/prompt-identifiers.js.map +1 -0
- package/dist/sql/prompt.d.ts +7 -1
- package/dist/sql/prompt.d.ts.map +1 -1
- package/dist/sql/prompt.js +24 -3
- package/dist/sql/prompt.js.map +1 -1
- package/dist/sql/rebind.d.ts +89 -0
- package/dist/sql/rebind.d.ts.map +1 -0
- package/dist/sql/rebind.js +175 -0
- package/dist/sql/rebind.js.map +1 -0
- package/dist/sql/reserved-words.d.ts +15 -0
- package/dist/sql/reserved-words.d.ts.map +1 -0
- package/dist/sql/reserved-words.js +102 -0
- package/dist/sql/reserved-words.js.map +1 -0
- package/dist/sql/sensitive-guardrail.d.ts +7 -2
- package/dist/sql/sensitive-guardrail.d.ts.map +1 -1
- package/dist/sql/sensitive-guardrail.js +20 -37
- package/dist/sql/sensitive-guardrail.js.map +1 -1
- package/dist/sql/tenant-guardrail.d.ts +3 -14
- package/dist/sql/tenant-guardrail.d.ts.map +1 -1
- package/dist/sql/tenant-guardrail.js +16 -65
- package/dist/sql/tenant-guardrail.js.map +1 -1
- package/dist/sql/tenant-placeholders.d.ts +12 -23
- package/dist/sql/tenant-placeholders.d.ts.map +1 -1
- package/dist/sql/tenant-placeholders.js +46 -27
- package/dist/sql/tenant-placeholders.js.map +1 -1
- package/dist/sql/tenant-scope-expand.d.ts +46 -0
- package/dist/sql/tenant-scope-expand.d.ts.map +1 -0
- package/dist/sql/tenant-scope-expand.js +101 -0
- package/dist/sql/tenant-scope-expand.js.map +1 -0
- package/dist/sql/tsql-batch.d.ts +56 -0
- package/dist/sql/tsql-batch.d.ts.map +1 -0
- package/dist/sql/tsql-batch.js +246 -0
- package/dist/sql/tsql-batch.js.map +1 -0
- package/dist/sql/validate.d.ts +16 -3
- package/dist/sql/validate.d.ts.map +1 -1
- package/dist/sql/validate.js +43 -8
- package/dist/sql/validate.js.map +1 -1
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -2,26 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
Dialect-agnostic NL→SQL pipeline for AskDB. Provides `ask()` orchestration, schema/IR types, modes, logging, and retrieval input. Bring your own dialect adapter (e.g. `@askdb/postgres`) and your own model.
|
|
4
4
|
|
|
5
|
-
> **Status:** pre-1.0. `0.3.0` moved the Postgres dialect and `@askdb/core/postgres` to `@askdb/postgres`. Runtime AI provider construction lives in `@askdb/ai`; core remains BYO-model and does not read `process.env`. See [`docs/adrs/0002-integration-package-layout.md`](https://github.com/Ygilany/AskDB/blob/main/docs/adrs/0002-integration-package-layout.md), [`docs/adrs/0005-askdb-config-and-env-bootstrap.md`](https://github.com/Ygilany/AskDB/blob/main/docs/adrs/0005-askdb-config-and-env-bootstrap.md), and [`docs/adrs/0006-ai-provider-integration-strategy.md`](https://github.com/Ygilany/AskDB/blob/main/docs/adrs/0006-ai-provider-integration-strategy.md).
|
|
5
|
+
> **Status:** pre-release beta (`1.0.0-beta.x`); public APIs may still change before 1.0. `0.3.0` moved the Postgres dialect and `@askdb/core/postgres` to `@askdb/postgres`. Runtime AI provider construction lives in `@askdb/ai`; core remains BYO-model and does not read `process.env`. See [`docs/adrs/0002-integration-package-layout.md`](https://github.com/Ygilany/AskDB/blob/main/docs/adrs/0002-integration-package-layout.md), [`docs/adrs/0005-askdb-config-and-env-bootstrap.md`](https://github.com/Ygilany/AskDB/blob/main/docs/adrs/0005-askdb-config-and-env-bootstrap.md), and [`docs/adrs/0006-ai-provider-integration-strategy.md`](https://github.com/Ygilany/AskDB/blob/main/docs/adrs/0006-ai-provider-integration-strategy.md).
|
|
6
6
|
|
|
7
7
|
> **Security model:** `ask()` returns SQL and never executes it. Its SQL checks (single `SELECT`/`WITH` statement (with a SQL Server caveat), no comments, no write/DDL keywords, no known side-effecting functions, and the tenant and sensitive-column checks) are heuristic defense in depth that catch common model mistakes. The read-only and sensitive-column checks use a dialect-aware lexer; the tenant check uses a simpler scanner of its own ([#342](https://github.com/Ygilany/AskDB/issues/342)). They are not a SQL parser and not a security boundary. Run generated SQL under a read-only, least-privilege database role and enforce tenant isolation in the database. See [Safety boundaries](https://askdb.tools/concepts/safety-boundaries/).
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
|
|
12
|
+
# `ai` (Vercel AI SDK) is a required peer dependency — your app owns its version
|
|
13
|
+
pnpm add @askdb/core ai
|
|
13
14
|
# Plus a dialect adapter for the engine you target:
|
|
14
15
|
pnpm add @askdb/postgres
|
|
15
|
-
# Plus a model
|
|
16
|
+
# Plus a model — either construct one directly with an AI SDK provider:
|
|
16
17
|
pnpm add @ai-sdk/openai
|
|
17
|
-
# Optional AskDB config/env model factory:
|
|
18
|
+
# Optional AskDB config/env model factory (uses the @ai-sdk/* package above):
|
|
18
19
|
pnpm add @askdb/ai
|
|
19
|
-
pnpm add @askdb/ai-openai
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
`ai` is a **peer dependency** (`^6.0.0 || ^7.0.51`: AI SDK 6, or 7.0.51 and later), not a bundled dependency: `ask()` receives a `LanguageModel` your app constructs, so core must use the same `ai` instance your app does. Hosts on AI SDK 6 (e.g. `@ai-sdk/openai@3`) and AI SDK 7 (`@ai-sdk/openai@4`) are both supported. The config-driven path (`@askdb/ai` and `@askdb/client`) currently requires AI SDK 7.
|
|
23
|
+
|
|
24
|
+
`ai` is a required peer, not an optional one, and core loads it at import time. So any package that depends on `@askdb/core` needs `ai` installed, even for introspection only. That covers `@askdb/client`, `@askdb/introspect`, the engine packages, `@askdb/prisma`, `@askdb/enrich` and `@askdb/rag`. npm 7+ and pnpm install the missing peer for you. Yarn doesn't, so add `ai` yourself. ADR 0006 records why (2026-09 amendment).
|
|
25
|
+
|
|
22
26
|
`@askdb/core` itself does not depend on `pg`. The optional `pg` peer lives on `@askdb/postgres` for live Postgres introspection.
|
|
23
27
|
|
|
24
|
-
Runtime AI configuration helpers live in `@askdb/ai
|
|
28
|
+
Runtime AI configuration helpers live in `@askdb/ai`, which has built-in providers for OpenAI, Azure/Foundry, Google, Anthropic, and the Vercel AI Gateway (install the matching `@ai-sdk/*` package). If you use [`@askdb/config`](https://github.com/Ygilany/AskDB/blob/main/packages/config/README.md), call `bootstrapAskDbEnv()`, create an AI registry, then pass **`getAskDbRuntimeConfig().ai.aiEnv`** to `registry.createLanguageModelFromEnv(...)`.
|
|
25
29
|
|
|
26
30
|
## Schema format
|
|
27
31
|
|
|
@@ -83,10 +87,8 @@ await pool.query(result.sql); // ready to run
|
|
|
83
87
|
await pool.query(result.unboundSql!, result.params); // driver binding
|
|
84
88
|
|
|
85
89
|
// Render a form from result.parameters, then rebind locally — no model call.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
":tenant_agency_ids": authorizedAgencyIds,
|
|
89
|
-
});
|
|
90
|
+
// The guardrails run again on the template under this schema and scope.
|
|
91
|
+
const rebound = bindPreparedQuery(result.preparedQuery!, { state_name: "Utah" }, { schema, tenantScope });
|
|
90
92
|
await pool.query(rebound.sql);
|
|
91
93
|
```
|
|
92
94
|
|
|
@@ -95,7 +97,7 @@ Key rules:
|
|
|
95
97
|
- `parameterize` defaults to **true**. Set `parameterize: false` when the extra output tokens are not worth it.
|
|
96
98
|
- If the model's extra blocks are missing or inconsistent, the extras are omitted and `result.sql` is unaffected. No new error reaches a caller who does not call `bindPreparedQuery()`.
|
|
97
99
|
- The model decides what to parameterize, so a mistake changes the *form*, not the query. Constrain form inputs using returned `type` and `description`.
|
|
98
|
-
- `bindPreparedQuery()`
|
|
100
|
+
- `bindPreparedQuery(prepared, values, { schema, tenantScope?, sensitiveGuardrailMode?, acceptWarnings? })` re-runs the read-only, tenant and sensitive checks on the stored template under the schema, scope and modes you pass, then binds. Tenant IDs come from `tenantScope`, never from `values`. Under a policy with `enforcement: warn`, a template that fails the tenant check is refused unless `acceptWarnings` includes `"tenant"`. Authorizing `tenantScope` is the host's job, exactly as for `ask()`. Expand a `subtree` scope with `expandTenantScope()` first.
|
|
99
101
|
- Callers using the new fields must execute with `params`, not `tenantParams`.
|
|
100
102
|
- List parameters are arity-stable in `unboundSql` only on PostgreSQL/CockroachDB (`= ANY($n)`); elsewhere a changed list length changes the marker count — rebind through `bindPreparedQuery()` rather than swapping the array.
|
|
101
103
|
- Markers: `$N` (Postgres/CockroachDB), `?` (MySQL/MariaDB/SQLite), `@pN` (SQL Server, 0-based). Map values via `parameters[].markers` for SQL Server.
|
|
@@ -103,7 +105,8 @@ Key rules:
|
|
|
103
105
|
## What you get
|
|
104
106
|
|
|
105
107
|
- `ask({ question, schema, model, dialect })` — generate checked SQL (plus optional `unboundSql` / `params` / `parameters` / `preparedQuery`).
|
|
106
|
-
- `bindPreparedQuery(prepared, values)` —
|
|
108
|
+
- `bindPreparedQuery(prepared, values, guardrails)` — local rebind of a `PreparedQuery` (no model call), re-checked under the given schema and tenant scope.
|
|
109
|
+
- `expandTenantScope(policy, scope, resolveTenantDescendants)` — the `subtree` expansion `ask()` runs, for a rebind.
|
|
107
110
|
- `AskDbLanguageModel` — AskDB's public name for the AI SDK language model contract.
|
|
108
111
|
- `AskDialect` — the dialect adapter contract. `@askdb/postgres` exports a ready-made one.
|
|
109
112
|
- `loadSchema(path)` — load a Schema v2 directory, bundled JSON, or `schema.json` path.
|
package/dist/ask.d.ts
CHANGED
|
@@ -7,8 +7,11 @@ import type { Retriever } from "./retrieval/types.js";
|
|
|
7
7
|
import type { TenantScope } from "./schema/v2/tenant-policy.js";
|
|
8
8
|
import { type BuiltInDialectId, type DialectSpec } from "./sql/dialect-spec.js";
|
|
9
9
|
import { type TenantSqlOutputMode, type TenantBinding } from "./sql/tenant-placeholders.js";
|
|
10
|
+
import { type ResolveTenantDescendants, type TenantIdsByRoot } from "./sql/tenant-scope-expand.js";
|
|
10
11
|
import { type SensitiveGuardrailMode, type SensitiveGuardrailResult } from "./sql/sensitive-guardrail.js";
|
|
12
|
+
import { type GuardrailVerdict } from "./errors.js";
|
|
11
13
|
import { type PreparedQuery, type QueryParameterBinding, type QueryParamSlot } from "./sql/bind.js";
|
|
14
|
+
export type { ResolveTenantDescendants, TenantIdsByRoot };
|
|
12
15
|
/** Options forwarded to a dialect's generator. Stable across dialects. */
|
|
13
16
|
export type AskDialectGenerateOptions = {
|
|
14
17
|
logger?: AskDbLogger;
|
|
@@ -16,6 +19,8 @@ export type AskDialectGenerateOptions = {
|
|
|
16
19
|
omitSensitiveIdentifiersFromNlToSqlPrompt?: boolean;
|
|
17
20
|
generateText?: typeof defaultGenerateText;
|
|
18
21
|
providerOptions?: Record<string, unknown>;
|
|
22
|
+
/** The caller's {@link AskPipelineOptions.abortSignal}. A custom dialect passes it to its model call. */
|
|
23
|
+
abortSignal?: AbortSignal;
|
|
19
24
|
prebuiltDdl?: string;
|
|
20
25
|
tenantPolicy?: import("./schema/v2/tenant-policy.js").NormalizedTenantPolicy;
|
|
21
26
|
tenantScope?: TenantScope;
|
|
@@ -37,9 +42,11 @@ export type AskDialectGenerateResult = {
|
|
|
37
42
|
explain?: unknown;
|
|
38
43
|
/**
|
|
39
44
|
* Optional tenant guardrail result from a custom generator. When the schema has a
|
|
40
|
-
* tenant policy,
|
|
41
|
-
* `
|
|
42
|
-
*
|
|
45
|
+
* tenant policy, its warnings become tenant findings (`form: "generator"`) next to
|
|
46
|
+
* `ask()`'s own check of `sql` and `unboundNamedSql`, decided under the policy's
|
|
47
|
+
* `enforcement`; `passed: false` with no warnings becomes one `UNPROVABLE_SCOPE`
|
|
48
|
+
* finding. It can add findings but never replace or relax that check. Without a tenant
|
|
49
|
+
* policy it is passed through to `result.tenantGuardrail` unchanged.
|
|
43
50
|
*/
|
|
44
51
|
tenantGuardrail?: import("./sql/tenant-guardrail.js").TenantGuardrailResult;
|
|
45
52
|
usage?: AskUsage;
|
|
@@ -65,8 +72,10 @@ export type AskDialectGenerateResult = {
|
|
|
65
72
|
* policy, `ask()` runs the tenant guardrail on the returned `sql` (and
|
|
66
73
|
* `unboundNamedSql`), with its `:tenant_<root>_ids` placeholders still in place,
|
|
67
74
|
* then substitutes them, regardless of dialect; `strict` policies throw
|
|
68
|
-
* `TenantGuardrailError`. A `tenantGuardrail` your
|
|
69
|
-
*
|
|
75
|
+
* `TenantGuardrailError`. A `tenantGuardrail` your generator returns adds
|
|
76
|
+
* findings to that check (`form: "generator"`), never replaces it.
|
|
77
|
+
* - The sensitive-identifier check runs on your SQL too, unless
|
|
78
|
+
* `sensitiveGuardrailMode` is `"off"`.
|
|
70
79
|
*/
|
|
71
80
|
export type AskDialect = {
|
|
72
81
|
generate(question: string, schema: AnyNormalizedSchema, model: AskDbLanguageModel, options?: AskDialectGenerateOptions): Promise<AskDialectGenerateResult>;
|
|
@@ -90,28 +99,6 @@ export type AskGenerateDeps = {
|
|
|
90
99
|
*/
|
|
91
100
|
providerOptions?: Record<string, unknown>;
|
|
92
101
|
};
|
|
93
|
-
/**
|
|
94
|
-
* A subtree's IDs grouped by tenant root: each key is a root table id from the
|
|
95
|
-
* tenant policy (`"table:public.clients"`), and its value holds IDs of that root's
|
|
96
|
-
* own `tenantIdColumn`, never IDs of another root.
|
|
97
|
-
*
|
|
98
|
-
* Root tables have separate ID spaces, so client `5` and agency `5` are different
|
|
99
|
-
* tenants. Keying the IDs by root lets `ask()` bind each root's IDs to that root's
|
|
100
|
-
* own `:tenant_<label>_ids` placeholder.
|
|
101
|
-
*/
|
|
102
|
-
export type TenantIdsByRoot = Readonly<Record<string, readonly string[]>>;
|
|
103
|
-
/**
|
|
104
|
-
* Host callback that expands a `subtree` tenant scope. Given the tenant root id and
|
|
105
|
-
* the seed IDs, return the subtree's IDs grouped by root ({@link TenantIdsByRoot}):
|
|
106
|
-
*
|
|
107
|
-
* - under `tenantRoot`: the seeds and any same-table descendants (e.g. child
|
|
108
|
-
* agencies through `agencies.parent_agency_id`);
|
|
109
|
-
* - under each descendant root the policy declares (`roots[].parent` or
|
|
110
|
-
* `hierarchy[]`): that root's IDs in the subtree.
|
|
111
|
-
*
|
|
112
|
-
* Pass it to `ask()` as {@link AskPipelineOptions.resolveTenantDescendants}.
|
|
113
|
-
*/
|
|
114
|
-
export type ResolveTenantDescendants = (tenantRoot: string, seedIds: readonly string[]) => Promise<TenantIdsByRoot> | TenantIdsByRoot;
|
|
115
102
|
export type AskPipelineOptions = {
|
|
116
103
|
question: string;
|
|
117
104
|
schema: AnyNormalizedSchema;
|
|
@@ -129,6 +116,13 @@ export type AskPipelineOptions = {
|
|
|
129
116
|
*/
|
|
130
117
|
omitSensitiveIdentifiersFromNlToSqlPrompt?: boolean;
|
|
131
118
|
deps?: AskGenerateDeps;
|
|
119
|
+
/**
|
|
120
|
+
* Cancels the NL→SQL model call (`generateText({ abortSignal })`), e.g.
|
|
121
|
+
* `AbortSignal.timeout(60_000)` for a per-request timeout. With a built-in dialect an
|
|
122
|
+
* aborted call rejects with `SqlGenerationError` (the abort reason is its `cause`). A
|
|
123
|
+
* custom {@link AskDialect} receives it in its `generate()` options and maps its own errors.
|
|
124
|
+
*/
|
|
125
|
+
abortSignal?: AbortSignal;
|
|
132
126
|
/** Optional structured logger (host-provided — e.g. `createAskDbLogger` wraps Pino). */
|
|
133
127
|
logger?: AskDbLogger;
|
|
134
128
|
/**
|
|
@@ -208,8 +202,9 @@ export type AskPipelineOptions = {
|
|
|
208
202
|
* `askdb.pipeline.sensitive_sql_warning` is logged, but `ask()` still resolves.
|
|
209
203
|
* `"strict"` throws {@link SensitiveReferenceError} instead. `"off"` skips the check.
|
|
210
204
|
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
205
|
+
* Covers SQL produced by *this* call. A rebind with `bindPreparedQuery()` runs the
|
|
206
|
+
* check again on the stored template; hosts that store and replay `sql` itself should
|
|
207
|
+
* call `validateSensitiveReferences` on that path.
|
|
213
208
|
*/
|
|
214
209
|
sensitiveGuardrailMode?: SensitiveGuardrailMode | "off";
|
|
215
210
|
};
|
|
@@ -238,18 +233,24 @@ export type AskPipelineResult = {
|
|
|
238
233
|
preparedQuery?: PreparedQuery;
|
|
239
234
|
explain?: unknown;
|
|
240
235
|
/**
|
|
241
|
-
*
|
|
242
|
-
*
|
|
236
|
+
* Every guardrail finding for the model's SQL, checked before AskDB renders it (its
|
|
237
|
+
* bound `sql` and `sql-unbound` block, with the `:tenant_<root>_ids` placeholders still
|
|
238
|
+
* in place), and the outcome: `allow`, or `warn` when a `warn`-mode check found
|
|
239
|
+
* something. A `deny` throws the check's typed error instead, with this verdict on it.
|
|
240
|
+
*/
|
|
241
|
+
verdict: GuardrailVerdict;
|
|
242
|
+
/**
|
|
243
|
+
* Sensitive-identifier guardrail result, derived from {@link verdict}. Present when the
|
|
244
|
+
* schema declares at least one `sensitive` table/column and `sensitiveGuardrailMode` is
|
|
245
|
+
* not `"off"`.
|
|
243
246
|
*/
|
|
244
247
|
sensitiveGuardrail?: SensitiveGuardrailResult;
|
|
245
248
|
/**
|
|
246
|
-
* Tenant guardrail result
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
* throws `TenantGuardrailError` instead, so a returned result is always `passed`
|
|
252
|
-
* under `strict`.
|
|
249
|
+
* Tenant guardrail result, derived from {@link verdict}: its tenant findings, once each.
|
|
250
|
+
* `sql` and `unboundSql` differ from the checked forms only by the substituted tenant IDs
|
|
251
|
+
* or markers. Present whenever the schema has a tenant policy, for every dialect form.
|
|
252
|
+
* In `strict` mode a failure throws `TenantGuardrailError` instead, so a returned result
|
|
253
|
+
* is always `passed` under `strict`.
|
|
253
254
|
*/
|
|
254
255
|
tenantGuardrail?: import("./sql/tenant-guardrail.js").TenantGuardrailResult;
|
|
255
256
|
/**
|
package/dist/ask.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask.d.ts","sourceRoot":"","sources":["../src/ask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,IAAI,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,KAAK,EAAE,mB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