@typed-sql/core 1.0.0-rc.0 → 2.0.0-rc.0
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 +94 -0
- package/README.md +41 -137
- package/dist/packages/core/src/adapter-capabilities.d.ts +30 -0
- package/dist/packages/core/src/adapter-capabilities.d.ts.map +1 -0
- package/dist/packages/core/src/adapter-capabilities.js +52 -0
- package/dist/packages/core/src/adapter-capabilities.js.map +1 -0
- package/dist/packages/core/src/diagnostics.d.ts +16 -0
- package/dist/packages/core/src/diagnostics.d.ts.map +1 -1
- package/dist/packages/core/src/diagnostics.js +4 -0
- package/dist/packages/core/src/diagnostics.js.map +1 -1
- package/dist/packages/core/src/execution.d.ts +62 -0
- package/dist/packages/core/src/execution.d.ts.map +1 -0
- package/dist/packages/core/src/execution.js +118 -0
- package/dist/packages/core/src/execution.js.map +1 -0
- package/dist/packages/core/src/index.d.ts +15 -3
- package/dist/packages/core/src/index.d.ts.map +1 -1
- package/dist/packages/core/src/index.js +7 -1
- package/dist/packages/core/src/index.js.map +1 -1
- package/dist/packages/core/src/observation.d.ts +60 -0
- package/dist/packages/core/src/observation.d.ts.map +1 -0
- package/dist/packages/core/src/observation.js +149 -0
- package/dist/packages/core/src/observation.js.map +1 -0
- package/dist/packages/core/src/query.d.ts +46 -2
- package/dist/packages/core/src/query.d.ts.map +1 -1
- package/dist/packages/core/src/query.js +156 -18
- package/dist/packages/core/src/query.js.map +1 -1
- package/dist/packages/core/src/resolver.d.ts +2 -0
- package/dist/packages/core/src/resolver.d.ts.map +1 -1
- package/dist/packages/core/src/resolver.js +10 -0
- package/dist/packages/core/src/resolver.js.map +1 -1
- package/dist/packages/core/src/result-validation.d.ts +87 -0
- package/dist/packages/core/src/result-validation.d.ts.map +1 -0
- package/dist/packages/core/src/result-validation.js +167 -0
- package/dist/packages/core/src/result-validation.js.map +1 -0
- package/dist/packages/core/src/routing.d.ts +71 -0
- package/dist/packages/core/src/routing.d.ts.map +1 -0
- package/dist/packages/core/src/routing.js +258 -0
- package/dist/packages/core/src/routing.js.map +1 -0
- package/dist/packages/core/src/semantics.d.ts +49 -0
- package/dist/packages/core/src/semantics.d.ts.map +1 -0
- package/dist/packages/core/src/semantics.js +134 -0
- package/dist/packages/core/src/semantics.js.map +1 -0
- package/dist/packages/core/src/types.d.ts +136 -1
- package/dist/packages/core/src/types.d.ts.map +1 -1
- package/dist/packages/core/src/types.js +95 -1
- package/dist/packages/core/src/types.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,99 @@
|
|
|
1
1
|
# @typed-sql/core
|
|
2
2
|
|
|
3
|
+
## 2.0.0-rc.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 29afc3d: Add conservative semantic primary/replica routing over application-owned databases, scoped
|
|
8
|
+
read-after-write pinning, explicit role requirements, stable unsafe-route errors, dialect runtime
|
|
9
|
+
semantic resolvers, and bounded abortable transaction retry policies with native PostgreSQL and
|
|
10
|
+
MySQL error classifiers. Parse and classify dialect locking reads so uncertain or affine work
|
|
11
|
+
always fails closed to primary.
|
|
12
|
+
- 3f063f6: Add deterministic, secret-free query manifests with bounded structural variants, inferred result
|
|
13
|
+
and parameter descriptions, semantic evidence, runtime-correlatable fingerprints, unresolved
|
|
14
|
+
entries, compatible parsing, canonical serialization, incremental per-file reuse, tsconfig project
|
|
15
|
+
discovery, and a dedicated CLI command.
|
|
16
|
+
- 6a7ae58: Add opt-in live query verification through grammar-owned PostgreSQL PREPARE and MySQL
|
|
17
|
+
COM_STMT_PREPARE adapters, bounded neutral comparison, deterministic secret-free proof artifacts,
|
|
18
|
+
offline cache validation, explicit unsupported classifications, CLI workflows, real database E2E,
|
|
19
|
+
and performance budgets.
|
|
20
|
+
- b06fd0a: Add grammar-neutral optional adapter capability discovery, typed PostgreSQL COPY import and export
|
|
21
|
+
through application-owned `pg-copy-streams`, and typed MySQL LOAD DATA import through mysql2's
|
|
22
|
+
application-owned infile stream. Bulk transfers preserve ordinary `INSERT` parameter evidence,
|
|
23
|
+
enforce structural row stability, apply bounded backpressure, support cancellation and progress,
|
|
24
|
+
and integrate with transaction ownership and conservative connection cleanup.
|
|
25
|
+
- 3050209: Add the dialect contract v4 semantic query evidence foundation. PostgreSQL and MySQL now report operation, dependencies, cardinality, volatility, locking, connection affinity, and required capabilities; compiler results add deterministic query and structural-variant fingerprints and conservatively merged source-mapped semantics. Schema snapshots can record function volatility, and the AST package exposes a neutral statement walker for grammar implementations.
|
|
26
|
+
- 1b054b6: Add an adapter-neutral, redacted database observation lifecycle for queries, cardinality contracts,
|
|
27
|
+
batches, PostgreSQL pipelines, streams, cancellation, and nested transactions. Runtime fingerprints
|
|
28
|
+
correlate with compiler structural variants while SQL, parameter values, connection configuration,
|
|
29
|
+
and driver causes remain excluded by default. Publish the optional OpenTelemetry bridge with current
|
|
30
|
+
database semantic conventions and explicit high-cardinality or exception-capture opt-ins.
|
|
31
|
+
- b4f1b6e: Add deterministic migration compatibility analysis across before/after schema snapshots and query
|
|
32
|
+
manifests. Reports classify both rolling-deployment directions, retain exact source and dependency
|
|
33
|
+
evidence, fail closed for unknown semantics, redact defaults and paths, and support configurable CI
|
|
34
|
+
severity through `typed-sql compat`.
|
|
35
|
+
- 87189c3: Add grammar-neutral `all`, `one`, and `maybeOne` execution with exact row types, stable cardinality
|
|
36
|
+
and cancellation errors, explicit adapter capabilities, AbortSignal support, and absolute deadlines.
|
|
37
|
+
The pg and mysql2 adapters conservatively discard interrupted connections, including transaction
|
|
38
|
+
leases, while the existing uncontrolled `execute` path remains unchanged.
|
|
39
|
+
- e654fae: Add opt-in Standard Schema V1 result validation with compile-time output compatibility, immutable
|
|
40
|
+
query attachment, sync and async validators, redacted fingerprinted errors, and consistent decoded-row
|
|
41
|
+
handling across buffered cardinality methods, batches, PostgreSQL pipelines, streams, and transactions.
|
|
42
|
+
- b2ec119: Add opt-in, grammar-neutral query-plan governance with PostgreSQL and MySQL structured EXPLAIN
|
|
43
|
+
adapters, transient application-owned samples, redacted fingerprint-keyed artifacts, absolute and
|
|
44
|
+
comparable regression budgets, explicit uncertainty, CLI capture and review, documentation, and
|
|
45
|
+
performance coverage.
|
|
46
|
+
|
|
47
|
+
## 1.0.0
|
|
48
|
+
|
|
49
|
+
### Major Changes
|
|
50
|
+
|
|
51
|
+
- 7ca256b: Release the first public typed-sql beta: exact TypeScript 7 row inference from static PostgreSQL and
|
|
52
|
+
MySQL, versioned schema introspection, application-owned drivers, config-driven grammar plugins,
|
|
53
|
+
CLI verification, editor language-server integration, versioned diagnostics, bounded parsing, and
|
|
54
|
+
real-database plus packed-tarball verification.
|
|
55
|
+
|
|
56
|
+
### Minor Changes
|
|
57
|
+
|
|
58
|
+
- eb16de7: Add grammar-neutral stream and ordered-result type contracts, and add lazy prepared-query factories to the PostgreSQL and MySQL runtime adapters. Prepared factories retain exact query types, validate stable SQL shapes, and remain available inside nested transactions.
|
|
59
|
+
- b6389e4: Cache immutable SQL rendering skeletons for prepared query factories so repeated calls only bind changing values while still rejecting structural drift before driver dispatch.
|
|
60
|
+
- eb16de7: Add a grammar-neutral validated query-batch type and ordered, exactly typed query batches to the
|
|
61
|
+
PostgreSQL and MySQL runtime adapters. Non-empty root batches execute sequentially on one leased
|
|
62
|
+
connection, transaction batches reuse their transaction connection, and empty batches avoid
|
|
63
|
+
connection acquisition. Batch execution preserves prepared metadata and adapter codecs, stops at
|
|
64
|
+
the first failure, and rejects transaction work that escapes its callback.
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- b6389e4: Reuse immutable SQL text segments and whole interpolation-free fragments at template callsites, and avoid spread allocations while composing predicates, joins, and appended queries.
|
|
69
|
+
- eb16de7: Allow adapters to retain enriched capabilities in transaction callbacks and nested transactions
|
|
70
|
+
through a self-typed core database contract. Transaction cleanup now also preserves the original
|
|
71
|
+
operation error when rollback or connection-release cleanup fails.
|
|
72
|
+
- 1563a7a: Declare and enforce the 1.0 package stability boundary. Core SQL, compiler, schema, config, AST,
|
|
73
|
+
PostgreSQL, MySQL, and CLI packages form the stable train; the TypeScript preview bridge and
|
|
74
|
+
language server remain explicitly experimental. Freeze public entrypoints and query type contracts,
|
|
75
|
+
and remove internal compiler/type helpers from stable package-root exports before 1.0.
|
|
76
|
+
- 9dd6bc4: Finalize dialect contract version 3 with explicit identifier quoting and grammar-owned capability
|
|
77
|
+
declarations. Accept third-party snapshot dialects, validate grammar versions, and document the
|
|
78
|
+
public grammar-authoring and conformance workflow.
|
|
79
|
+
- 16e2475: Prove npm trusted publishing and provenance after the initial registry bootstrap.
|
|
80
|
+
- 69c7d87: Report `TSQ004` for bare nested templates used as conditional SQL structure and offer an alias-aware
|
|
81
|
+
language-server quick fix that prefixes the template with `sql.fragment`. Ordinary and nested
|
|
82
|
+
values remain parameterized across the edit.
|
|
83
|
+
- 3e2c75c: Infer ordered query parameter tuples and let TypeScript reject interpolation values that do not
|
|
84
|
+
match their SQL context. Dialect contract version 2 adds explicit parameter analysis; unresolved
|
|
85
|
+
positions remain `unknown`. Add typed nullable predicate composition through `sql.fragment()`,
|
|
86
|
+
`sql.and()`, `sql.or()`, `sql.where()`, and `sql.append()` while preserving row and parameter tuples.
|
|
87
|
+
Direct append fragments are grammar-analyzed cumulatively against their static base, so TypeScript
|
|
88
|
+
rejects fragment interpolation values that disagree with the referenced database columns.
|
|
89
|
+
Add `sql.empty` and SQL-template-native conditional structural fragments. The compiler analyzes
|
|
90
|
+
complete branch variants, preserves literal boolean-dependent result rows, and type-checks nested
|
|
91
|
+
fragment parameters without adding a query-builder DSL. Bound independent structural expansion at
|
|
92
|
+
64 variants by default, correlate repeated conditions, merge diagnostics and fragment expectations
|
|
93
|
+
across variants, and fail closed on incompatible contexts. Share indexed catalog and conservative
|
|
94
|
+
parameter-resolution primitives across grammars, harden cooked-template scanning, and add runtime,
|
|
95
|
+
resolver, scanner, and structural performance gates.
|
|
96
|
+
|
|
3
97
|
## 1.0.0-rc.0
|
|
4
98
|
|
|
5
99
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,157 +1,61 @@
|
|
|
1
1
|
# @typed-sql/core
|
|
2
2
|
|
|
3
|
-
The driver- and
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Most applications install it alongside one dialect:
|
|
3
|
+
The stable, driver- and grammar-neutral foundation of
|
|
4
|
+
[typed-sql](https://github.com/Lojhan/typed-sql). It defines queries, fragments, rendering,
|
|
5
|
+
database adapters, diagnostics, schema contracts, and the interface implemented by every SQL
|
|
6
|
+
grammar.
|
|
8
7
|
|
|
9
8
|
```sh
|
|
10
|
-
pnpm add @typed-sql/core
|
|
9
|
+
pnpm add @typed-sql/core @typed-sql/postgres pg
|
|
11
10
|
```
|
|
12
11
|
|
|
13
|
-
Application queries import `sql` from the
|
|
14
|
-
|
|
12
|
+
Application queries import `sql` from the selected grammar so the compiler can associate each
|
|
13
|
+
template with its dialect:
|
|
15
14
|
|
|
16
15
|
```ts
|
|
17
16
|
import { sql } from "@typed-sql/postgres";
|
|
17
|
+
import type { QueryParameters, QueryRow } from "@typed-sql/core";
|
|
18
18
|
|
|
19
19
|
const query = sql`
|
|
20
20
|
SELECT account.id, account.email
|
|
21
21
|
FROM accounts AS account
|
|
22
22
|
WHERE account.id = ${42n}
|
|
23
23
|
`;
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
The compiler supplies the ordered parameter tuple from SQL context. For example, comparing an
|
|
27
|
-
interpolation with a `bigint` column produces `Query<Row, readonly [bigint]>`, so passing a `string`
|
|
28
|
-
is a normal TypeScript error. Positions that cannot be proven remain `unknown`.
|
|
29
|
-
|
|
30
|
-
For optional runtime filters, infer a static base query and compose predicates without concatenating
|
|
31
|
-
values into SQL:
|
|
32
|
-
|
|
33
|
-
```ts
|
|
34
|
-
import { sql } from "@typed-sql/postgres";
|
|
35
|
-
import type { QueryRow } from "@typed-sql/core";
|
|
36
|
-
|
|
37
|
-
const base = sql`SELECT account.id, account.status FROM accounts AS account`;
|
|
38
|
-
type Account = QueryRow<typeof base>;
|
|
39
|
-
|
|
40
|
-
function filtered(status: Account["status"] | null, minimumId: Account["id"] | null) {
|
|
41
|
-
const predicates = [
|
|
42
|
-
status == null ? undefined : sql.fragment`account.status = ${status}`,
|
|
43
|
-
minimumId == null ? undefined : sql.fragment`account.id >= ${minimumId}`,
|
|
44
|
-
] as const;
|
|
45
|
-
return sql.where(base, sql.and(predicates));
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
`sql.and()` and `sql.or()` accept nullable fragment tuples, preserve parameter order, parenthesize
|
|
50
|
-
each predicate, and render `TRUE` when every predicate is absent. `sql.where()` preserves the base
|
|
51
|
-
row and concatenates its parameter tuple with the fragment tuple. This is a safe parameterization
|
|
52
|
-
and type-composition boundary; arbitrary dynamic SQL strings are intentionally not analyzed.
|
|
53
|
-
|
|
54
|
-
`sql.append()` provides the type-safe equivalent of conditionally appending clauses:
|
|
55
|
-
|
|
56
|
-
```ts
|
|
57
|
-
function filtered2(filters: { status?: Account["status"] | null; minimumId?: Account["id"] | null }) {
|
|
58
|
-
const query = sql`SELECT account.id, account.status FROM accounts AS account`;
|
|
59
|
-
return sql.append(
|
|
60
|
-
query,
|
|
61
|
-
sql.fragment` WHERE 1 = 1`,
|
|
62
|
-
filters.status == null ? undefined : sql.fragment` AND account.status = ${filters.status}`,
|
|
63
|
-
filters.minimumId == null ? undefined : sql.fragment` AND account.id >= ${filters.minimumId}`,
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
JavaScript does not support operator overloading, so `query += fragment` would stringify the values
|
|
69
|
-
and erase their type and parameter segments. `sql.append()` skips `undefined`, `null`, and `false`,
|
|
70
|
-
then concatenates only validated fragments. Variadic arguments retain exact parameter order;
|
|
71
|
-
mutable fragment arrays can be spread and retain their allowed parameter union, but have a
|
|
72
|
-
variable-length parameter array.
|
|
73
|
-
|
|
74
|
-
When direct variadic fragments are visible to the typed-sql compiler, it analyzes them cumulatively
|
|
75
|
-
with the static base. The grammar therefore supplies each interpolation's expected column type;
|
|
76
|
-
the core runtime alone only owns immutable composition and parameterization.
|
|
77
|
-
|
|
78
|
-
`sql.empty` enables SQL-template-native conditional structure:
|
|
79
|
-
|
|
80
|
-
```ts
|
|
81
|
-
const query = sql`
|
|
82
|
-
SELECT account.id, account.email
|
|
83
|
-
${select.status ? sql.fragment`, account.status` : sql.empty}
|
|
84
|
-
FROM accounts AS account
|
|
85
|
-
`;
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
The runtime only flattens fragment segments and values. The compiler analyzes every finite branch as
|
|
89
|
-
a complete statement and supplies the branch-dependent row type; no clause-builder abstraction is
|
|
90
|
-
introduced. Structural compilation defaults to at most 64 correlated variants and fails with
|
|
91
|
-
`TSQ003` before invoking a grammar if independent conditions exceed that bound.
|
|
92
24
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
`sql.empty` or another trusted structural branch. The explicit marker is an injection boundary:
|
|
96
|
-
interpolated values inside `sql.fragment` remain parameters rather than becoming SQL text.
|
|
97
|
-
|
|
98
|
-
`sql.join()` accepts only `SqlFragment` values. Its optional separator is also a trusted fragment,
|
|
99
|
-
so use `sql.raw(" UNION ALL ")` when a non-comma separator is intentional; an arbitrary runtime
|
|
100
|
-
string is never promoted to SQL implicitly.
|
|
101
|
-
|
|
102
|
-
`@typed-sql/core` is directly useful to grammar and adapter authors:
|
|
103
|
-
|
|
104
|
-
```ts
|
|
105
|
-
import {
|
|
106
|
-
DIALECT_CONTRACT_VERSION,
|
|
107
|
-
assertDialectPlugin,
|
|
108
|
-
createDatabase,
|
|
109
|
-
defineConfig,
|
|
110
|
-
closestName,
|
|
111
|
-
ParameterCollector,
|
|
112
|
-
renderQuery,
|
|
113
|
-
parameterTypeLiteral,
|
|
114
|
-
ResolverSchemaIndex,
|
|
115
|
-
rowTypeLiteral,
|
|
116
|
-
sql,
|
|
117
|
-
unionTypeLiterals,
|
|
118
|
-
type DialectPlugin,
|
|
119
|
-
type DialectCapabilities,
|
|
120
|
-
type Query,
|
|
121
|
-
type QueryParameters,
|
|
122
|
-
type QueryRow,
|
|
123
|
-
type SqlFragment,
|
|
124
|
-
type SchemaSnapshot,
|
|
125
|
-
} from "@typed-sql/core";
|
|
25
|
+
type Account = QueryRow<typeof query>;
|
|
26
|
+
type Parameters = QueryParameters<typeof query>;
|
|
126
27
|
```
|
|
127
28
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
29
|
+
Runtime adapters share grammar-neutral result and control contracts: `all`, `one`, and `maybeOne`
|
|
30
|
+
preserve the inferred row, accept optional signals or absolute deadlines, and expose stable
|
|
31
|
+
cardinality and cancellation errors. Adapter capabilities are explicit; unsupported controls are
|
|
32
|
+
never silently ignored.
|
|
33
|
+
|
|
34
|
+
Optional adapter services use namespaced capability tokens rather than widening the common
|
|
35
|
+
`Database` interface. `getAdapterCapability` and `requireAdapterCapability` preserve the service
|
|
36
|
+
type without adding a protocol or driver dependency to core.
|
|
37
|
+
|
|
38
|
+
`DatabaseObserver` provides redacted query, batch, pipeline, stream, cancellation, and nested
|
|
39
|
+
transaction lifecycles. It is disabled by default and does not add a telemetry dependency to core.
|
|
40
|
+
|
|
41
|
+
`sql.validateResult(query, schema)` optionally validates decoded rows through the structural
|
|
42
|
+
Standard Schema V1 interface. Validator output must agree with the inferred row; core does not
|
|
43
|
+
install Zod, Valibot, or another validator package.
|
|
44
|
+
|
|
45
|
+
`createRoutedDatabase` provides conservative, grammar-neutral primary/replica selection and bounded
|
|
46
|
+
explicit-transaction retries from semantic evidence. Dialect packages supply the semantic resolver;
|
|
47
|
+
applications continue owning every database adapter and topology decision.
|
|
48
|
+
|
|
49
|
+
Grammar and adapter authors can use `DialectPlugin`, `DIALECT_CONTRACT_VERSION`,
|
|
50
|
+
`assertDialectPlugin`, `defineQuerySemantics`, `mergeQuerySemantics`, `createDatabase`, `renderQuery`,
|
|
51
|
+
the prepared-query skeleton helpers, and the neutral resolver primitives from the package root. The package has no parser, grammar,
|
|
52
|
+
database driver, TypeScript compiler, or editor dependency.
|
|
53
|
+
|
|
54
|
+
Read the [query API](https://github.com/Lojhan/typed-sql/blob/main/docs/reference/api.md),
|
|
55
|
+
[architecture](https://github.com/Lojhan/typed-sql/blob/main/docs/concepts/architecture.md),
|
|
56
|
+
[routing and retry guide](https://github.com/Lojhan/typed-sql/blob/main/docs/guides/routing-and-retries.md),
|
|
57
|
+
[bulk data guide](https://github.com/Lojhan/typed-sql/blob/main/docs/guides/bulk-data.md),
|
|
58
|
+
[result validation guide](https://github.com/Lojhan/typed-sql/blob/main/docs/guides/result-validation.md), and
|
|
59
|
+
[custom grammar guide](https://github.com/Lojhan/typed-sql/blob/main/docs/extending/custom-grammars.md).
|
|
156
60
|
|
|
157
61
|
MIT © typed-sql contributors
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare const adapterCapabilityBrand: unique symbol;
|
|
2
|
+
/** A namespaced token describing one optional service exposed by a database adapter. */
|
|
3
|
+
export interface AdapterCapability<Service> {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly key: symbol;
|
|
6
|
+
readonly [adapterCapabilityBrand]: () => Service;
|
|
7
|
+
}
|
|
8
|
+
export type AdapterCapabilityService<Capability> = Capability extends AdapterCapability<infer Service> ? Service : never;
|
|
9
|
+
export type AdapterCapabilityResolver = (key: symbol) => unknown;
|
|
10
|
+
export declare const adapterCapabilities: unique symbol;
|
|
11
|
+
/** Structural host contract implemented by adapters that provide optional services. */
|
|
12
|
+
export interface AdapterCapabilityHost {
|
|
13
|
+
readonly [adapterCapabilities]?: AdapterCapabilityResolver;
|
|
14
|
+
}
|
|
15
|
+
export declare class UnsupportedAdapterCapabilityError extends Error {
|
|
16
|
+
readonly code = "TSQL_UNSUPPORTED_ADAPTER_CAPABILITY";
|
|
17
|
+
readonly capability: string;
|
|
18
|
+
constructor(capability: string);
|
|
19
|
+
}
|
|
20
|
+
/** Defines a globally stable, namespaced adapter capability token. */
|
|
21
|
+
export declare function defineAdapterCapability<Service>(id: string): AdapterCapability<Service>;
|
|
22
|
+
/** Creates the immutable resolver installed on one adapter or transaction scope. */
|
|
23
|
+
export declare function createAdapterCapabilityResolver(entries: readonly (readonly [AdapterCapability<unknown>, unknown])[]): AdapterCapabilityResolver;
|
|
24
|
+
/** Returns an optional adapter service without importing its driver or protocol package. */
|
|
25
|
+
export declare function getAdapterCapability<Service>(host: unknown, capability: AdapterCapability<Service>): Service | undefined;
|
|
26
|
+
export declare function hasAdapterCapability<Service>(host: unknown, capability: AdapterCapability<Service>): boolean;
|
|
27
|
+
/** Resolves an adapter service or throws a stable fail-closed error. */
|
|
28
|
+
export declare function requireAdapterCapability<Service>(host: unknown, capability: AdapterCapability<Service>): Service;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=adapter-capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-capabilities.d.ts","sourceRoot":"","sources":["../../../../src/adapter-capabilities.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,sBAAsB,EAAE,OAAO,MAA8D,CAAC;AAEpG,wFAAwF;AACxF,MAAM,WAAW,iBAAiB,CAAC,OAAO;IACxC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,CAAC,sBAAsB,CAAC,EAAE,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0 +1,52 @@
|
|
|
1
|
+
const adapterCapabilityBrand = Symbol("@typed-sql/core.adapter-capability");
|
|
2
|
+
export const adapterCapabilities = Symbol.for("@typed-sql/core.adapter-capabilities");
|
|
3
|
+
export class UnsupportedAdapterCapabilityError extends Error {
|
|
4
|
+
code = "TSQL_UNSUPPORTED_ADAPTER_CAPABILITY";
|
|
5
|
+
capability;
|
|
6
|
+
constructor(capability) {
|
|
7
|
+
super(`This database adapter does not provide the ${capability} capability`);
|
|
8
|
+
this.name = "UnsupportedAdapterCapabilityError";
|
|
9
|
+
this.capability = capability;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** Defines a globally stable, namespaced adapter capability token. */
|
|
13
|
+
export function defineAdapterCapability(id) {
|
|
14
|
+
if (id.length === 0 || !id.includes(".")) {
|
|
15
|
+
throw new TypeError("Adapter capability ids must be non-empty and namespaced, for example vendor.feature");
|
|
16
|
+
}
|
|
17
|
+
return Object.freeze({
|
|
18
|
+
id,
|
|
19
|
+
key: Symbol.for(`@typed-sql/adapter-capability/${id}`),
|
|
20
|
+
[adapterCapabilityBrand]: () => {
|
|
21
|
+
throw new TypeError("Adapter capability type brands are not callable");
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** Creates the immutable resolver installed on one adapter or transaction scope. */
|
|
26
|
+
export function createAdapterCapabilityResolver(entries) {
|
|
27
|
+
const services = new Map();
|
|
28
|
+
for (const [capability, service] of entries) {
|
|
29
|
+
if (services.has(capability.key))
|
|
30
|
+
throw new TypeError(`Duplicate adapter capability: ${capability.id}`);
|
|
31
|
+
services.set(capability.key, service);
|
|
32
|
+
}
|
|
33
|
+
return (key) => services.get(key);
|
|
34
|
+
}
|
|
35
|
+
/** Returns an optional adapter service without importing its driver or protocol package. */
|
|
36
|
+
export function getAdapterCapability(host, capability) {
|
|
37
|
+
if ((typeof host !== "object" && typeof host !== "function") || host === null)
|
|
38
|
+
return undefined;
|
|
39
|
+
const resolver = host[adapterCapabilities];
|
|
40
|
+
return resolver?.(capability.key);
|
|
41
|
+
}
|
|
42
|
+
export function hasAdapterCapability(host, capability) {
|
|
43
|
+
return getAdapterCapability(host, capability) !== undefined;
|
|
44
|
+
}
|
|
45
|
+
/** Resolves an adapter service or throws a stable fail-closed error. */
|
|
46
|
+
export function requireAdapterCapability(host, capability) {
|
|
47
|
+
const service = getAdapterCapability(host, capability);
|
|
48
|
+
if (service === undefined)
|
|
49
|
+
throw new UnsupportedAdapterCapabilityError(capability.id);
|
|
50
|
+
return service;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=adapter-capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-capabilities.js","sourceRoot":"","sources":["../../../../src/adapter-capabilities.ts"],"names":[],"mappings":"AAAA,MAAM,sBAAsB,GAAkB,MAAM,CAAC,oCAAoC,CAAU,CAAC;AAcpG,MAAM,CAAC,MAAM,mBAAmB,GAAkB,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAU,CAAC;AAO9G,MAAM,OAAO,iCAAkC,SAAQ,KAAK;IACjD,IAAI,GAAG,qCAAqC,CAAC;IAC7C,UAAU,CAAS;IAE5B,YAAY,UAAkB;QAC5B,KAAK,CAAC,8CAA8C,UAAU,aAAa,CAAC,CAAC;QAC7E,IAAI,CAAC,IAAI,GAAG,mCAAmC,CAAC;QAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAED,sEAAsE;AACtE,MAAM,UAAU,uBAAuB,CAAU,EAAU;IACzD,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,SAAS,CAAC,qFAAqF,CAAC,CAAC;IAC7G,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,EAAE;QACF,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,iCAAiC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U,CAAC,CAAC;IACvD,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,IAAI,iCAAiC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACtF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -15,6 +15,10 @@ export declare const diagnosticRegistry: Readonly<{
|
|
|
15
15
|
readonly category: "contract";
|
|
16
16
|
readonly summary: "Structural SQL requires an explicitly trusted fragment.";
|
|
17
17
|
};
|
|
18
|
+
readonly TSQ005: {
|
|
19
|
+
readonly category: "support";
|
|
20
|
+
readonly summary: "Runtime SQL cannot be analyzed statically.";
|
|
21
|
+
};
|
|
18
22
|
readonly TSQ007: {
|
|
19
23
|
readonly category: "contract";
|
|
20
24
|
readonly summary: "The schema snapshot and dialect do not match.";
|
|
@@ -111,6 +115,18 @@ export declare const diagnosticRegistry: Readonly<{
|
|
|
111
115
|
readonly category: "support";
|
|
112
116
|
readonly summary: "The dialect surface is intentionally unsupported.";
|
|
113
117
|
};
|
|
118
|
+
readonly TSQ500: {
|
|
119
|
+
readonly category: "verification";
|
|
120
|
+
readonly summary: "Live database metadata differs from compiler evidence.";
|
|
121
|
+
};
|
|
122
|
+
readonly TSQ501: {
|
|
123
|
+
readonly category: "verification";
|
|
124
|
+
readonly summary: "A query could not be verified safely or statically.";
|
|
125
|
+
};
|
|
126
|
+
readonly TSQ502: {
|
|
127
|
+
readonly category: "verification";
|
|
128
|
+
readonly summary: "Native live verification failed without persisting driver details.";
|
|
129
|
+
};
|
|
114
130
|
}>;
|
|
115
131
|
export type TypedSqlDiagnosticCode = keyof typeof diagnosticRegistry;
|
|
116
132
|
export declare function isTypedSqlDiagnosticCode(value: string): value is TypedSqlDiagnosticCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../../src/diagnostics.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;;iBACnB,QAAQ,EAAE,QAAQ;iBAAE,OAAO,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,7 @@ export const diagnosticRegistry = Object.freeze({
|
|
|
3
3
|
TSQ002: { category: "resource", summary: "SQL exceeded a parser resource limit." },
|
|
4
4
|
TSQ003: { category: "resource", summary: "Conditional SQL exceeded the structural variant limit." },
|
|
5
5
|
TSQ004: { category: "contract", summary: "Structural SQL requires an explicitly trusted fragment." },
|
|
6
|
+
TSQ005: { category: "support", summary: "Runtime SQL cannot be analyzed statically." },
|
|
6
7
|
TSQ007: { category: "contract", summary: "The schema snapshot and dialect do not match." },
|
|
7
8
|
TSQ100: { category: "schema", summary: "A referenced table does not exist." },
|
|
8
9
|
TSQ101: { category: "schema", summary: "A referenced column does not exist." },
|
|
@@ -27,6 +28,9 @@ export const diagnosticRegistry = Object.freeze({
|
|
|
27
28
|
TSQ217: { category: "result", summary: "An IN subquery does not return exactly one column." },
|
|
28
29
|
TSQ301: { category: "drift", summary: "The live schema or type policy differs from the generated snapshot." },
|
|
29
30
|
TSQ401: { category: "support", summary: "The dialect surface is intentionally unsupported." },
|
|
31
|
+
TSQ500: { category: "verification", summary: "Live database metadata differs from compiler evidence." },
|
|
32
|
+
TSQ501: { category: "verification", summary: "A query could not be verified safely or statically." },
|
|
33
|
+
TSQ502: { category: "verification", summary: "Native live verification failed without persisting driver details." },
|
|
30
34
|
});
|
|
31
35
|
export function isTypedSqlDiagnosticCode(value) {
|
|
32
36
|
return Object.hasOwn(diagnosticRegistry, value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../../../src/diagnostics.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,iCAAiC,EAAE;IAC1E,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,uCAAuC,EAAE;IAClF,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU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AQ,EAAE,OAAO,EAAE,2BAA2B,EAAE;IACpE,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,6BAA6B,EAAE;IACtE,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,wCAAwC,EAAE;IACjF,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,0CAA0C,EAAE;IACnF,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,kDAAkD,EAAE;IAC3F,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,uDAAuD,EAAE;IAChG,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,oDAAoD,EAAE;IAC7F,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,qEAAqE,EAAE;IAC7G,MAAM,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,mDAAmD,EAAE;IAC7F,MAAM,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,wDAAwD,EAAE;IACvG,MAAM,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,qDAAqD,EAAE;IACpG,MAAM,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,oEAAoE,EAAE;CAC3G,CAAC,CAAC;AAIZ,MAAM,UAAU,wBAAwB,CAAC,KAAa;IACpD,OAAO,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Query } from "./query.js";
|
|
2
|
+
export type QueryCardinalityExpectation = "one" | "maybeOne";
|
|
3
|
+
export type QueryCancellationReason = "signal" | "deadline";
|
|
4
|
+
export type ExecutionCapability = "cancellation" | "deadlines";
|
|
5
|
+
export interface ExecutionOptions {
|
|
6
|
+
readonly signal?: AbortSignal;
|
|
7
|
+
/** Absolute Unix time in milliseconds, or a Date representing that instant. */
|
|
8
|
+
readonly deadline?: number | Date;
|
|
9
|
+
}
|
|
10
|
+
export interface ExecutionCapabilities {
|
|
11
|
+
readonly cancellation: boolean;
|
|
12
|
+
readonly deadlines: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare class QueryCardinalityError extends Error {
|
|
15
|
+
readonly code = "TSQL_CARDINALITY";
|
|
16
|
+
readonly expected: QueryCardinalityExpectation;
|
|
17
|
+
readonly actual: number;
|
|
18
|
+
constructor(expected: QueryCardinalityExpectation, actual: number);
|
|
19
|
+
}
|
|
20
|
+
export declare class QueryCancelledError extends Error {
|
|
21
|
+
readonly code = "TSQL_CANCELLED";
|
|
22
|
+
readonly reason: QueryCancellationReason;
|
|
23
|
+
constructor(reason: QueryCancellationReason, options?: ErrorOptions);
|
|
24
|
+
}
|
|
25
|
+
export declare class UnsupportedExecutionCapabilityError extends Error {
|
|
26
|
+
readonly code = "TSQL_UNSUPPORTED_EXECUTION_CAPABILITY";
|
|
27
|
+
readonly capability: ExecutionCapability;
|
|
28
|
+
constructor(capability: ExecutionCapability);
|
|
29
|
+
}
|
|
30
|
+
export declare function executionDeadline(options: ExecutionOptions): number | undefined;
|
|
31
|
+
export declare function assertExecutionCapabilities(capabilities: ExecutionCapabilities, options: ExecutionOptions): void;
|
|
32
|
+
/** Runs one dispatched operation and invokes adapter cleanup exactly once when its controls fire. */
|
|
33
|
+
export declare function runControlledExecution<Value>(options: ExecutionOptions, operation: () => Promise<Value>, cancel: (error: QueryCancelledError) => void): Promise<Value>;
|
|
34
|
+
/** The buffered rows produced by executing one typed query. */
|
|
35
|
+
export type QueryResult<Value> = Value extends Query<infer Row, infer _Params> ? readonly Row[] : never;
|
|
36
|
+
/**
|
|
37
|
+
* Maps an ordered query tuple or array to its ordered buffered results.
|
|
38
|
+
*
|
|
39
|
+
* A tuple remains a tuple, while a homogeneous query array remains an array.
|
|
40
|
+
*/
|
|
41
|
+
export type QueryResults<Queries extends readonly unknown[]> = {
|
|
42
|
+
readonly [Index in keyof Queries]: QueryResult<Queries[Index]>;
|
|
43
|
+
};
|
|
44
|
+
/** Validates an ordered tuple or array while preserving every query's exact type. */
|
|
45
|
+
export type QueryBatch<Queries extends readonly unknown[]> = Queries & {
|
|
46
|
+
readonly [Index in keyof Queries]: Queries[Index] extends Query<infer Row, infer Params> ? Query<Row, Params> : never;
|
|
47
|
+
};
|
|
48
|
+
/** Common, grammar-neutral stream configuration. */
|
|
49
|
+
export interface StreamOptions {
|
|
50
|
+
/**
|
|
51
|
+
* Preferred number of rows fetched or buffered at a time.
|
|
52
|
+
*
|
|
53
|
+
* Adapters must reject values that are not positive safe integers. This is a row count, not a
|
|
54
|
+
* byte limit or a guarantee of server-side cursor paging.
|
|
55
|
+
*/
|
|
56
|
+
readonly batchSize?: number;
|
|
57
|
+
}
|
|
58
|
+
/** A lazy, explicitly closeable stream of typed query rows. */
|
|
59
|
+
export interface QueryStream<Row> extends AsyncIterableIterator<Row>, AsyncDisposable {
|
|
60
|
+
close(): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../../src/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,MAAM,2BAA2B,GAAG,KAAK,GAAG,UAAU,CAAC;AAC7D,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAC5D,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,WAAW,CAAC;AAE/D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,C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