@typed-sql/compiler 1.0.0 → 2.0.0-rc.1
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 +44 -0
- package/README.md +28 -5
- package/dist/packages/compiler/src/compatibility.d.ts +66 -0
- package/dist/packages/compiler/src/compatibility.d.ts.map +1 -0
- package/dist/packages/compiler/src/compatibility.js +786 -0
- package/dist/packages/compiler/src/compatibility.js.map +1 -0
- package/dist/packages/compiler/src/compiler.d.ts +16 -1
- package/dist/packages/compiler/src/compiler.d.ts.map +1 -1
- package/dist/packages/compiler/src/compiler.js +67 -4
- package/dist/packages/compiler/src/compiler.js.map +1 -1
- package/dist/packages/compiler/src/index.d.ts +13 -3
- package/dist/packages/compiler/src/index.d.ts.map +1 -1
- package/dist/packages/compiler/src/index.js +6 -1
- package/dist/packages/compiler/src/index.js.map +1 -1
- package/dist/packages/compiler/src/manifest.d.ts +505 -0
- package/dist/packages/compiler/src/manifest.d.ts.map +1 -0
- package/dist/packages/compiler/src/manifest.js +628 -0
- package/dist/packages/compiler/src/manifest.js.map +1 -0
- package/dist/packages/compiler/src/plans.d.ts +88 -0
- package/dist/packages/compiler/src/plans.d.ts.map +1 -0
- package/dist/packages/compiler/src/plans.js +459 -0
- package/dist/packages/compiler/src/plans.js.map +1 -0
- package/dist/packages/compiler/src/project.d.ts +8 -0
- package/dist/packages/compiler/src/project.d.ts.map +1 -0
- package/dist/packages/compiler/src/project.js +62 -0
- package/dist/packages/compiler/src/project.js.map +1 -0
- package/dist/packages/compiler/src/scanner.d.ts +6 -0
- package/dist/packages/compiler/src/scanner.d.ts.map +1 -1
- package/dist/packages/compiler/src/scanner.js +46 -0
- package/dist/packages/compiler/src/scanner.js.map +1 -1
- package/dist/packages/compiler/src/verification.d.ts +106 -0
- package/dist/packages/compiler/src/verification.d.ts.map +1 -0
- package/dist/packages/compiler/src/verification.js +516 -0
- package/dist/packages/compiler/src/verification.js.map +1 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @typed-sql/compiler
|
|
2
2
|
|
|
3
|
+
## 2.0.0-rc.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9c72dab: Use live MySQL catalog origins to preserve enum result evidence, and compare parameter metadata in
|
|
8
|
+
the safe input direction so compiler-enforced literal subsets do not become false mismatches.
|
|
9
|
+
|
|
10
|
+
## 2.0.0-rc.0
|
|
11
|
+
|
|
12
|
+
### Major Changes
|
|
13
|
+
|
|
14
|
+
- 3f063f6: Add deterministic, secret-free query manifests with bounded structural variants, inferred result
|
|
15
|
+
and parameter descriptions, semantic evidence, runtime-correlatable fingerprints, unresolved
|
|
16
|
+
entries, compatible parsing, canonical serialization, incremental per-file reuse, tsconfig project
|
|
17
|
+
discovery, and a dedicated CLI command.
|
|
18
|
+
- 6a7ae58: Add opt-in live query verification through grammar-owned PostgreSQL PREPARE and MySQL
|
|
19
|
+
COM_STMT_PREPARE adapters, bounded neutral comparison, deterministic secret-free proof artifacts,
|
|
20
|
+
offline cache validation, explicit unsupported classifications, CLI workflows, real database E2E,
|
|
21
|
+
and performance budgets.
|
|
22
|
+
- 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.
|
|
23
|
+
- b4f1b6e: Add deterministic migration compatibility analysis across before/after schema snapshots and query
|
|
24
|
+
manifests. Reports classify both rolling-deployment directions, retain exact source and dependency
|
|
25
|
+
evidence, fail closed for unknown semantics, redact defaults and paths, and support configurable CI
|
|
26
|
+
severity through `typed-sql compat`.
|
|
27
|
+
- b2ec119: Add opt-in, grammar-neutral query-plan governance with PostgreSQL and MySQL structured EXPLAIN
|
|
28
|
+
adapters, transient application-owned samples, redacted fingerprint-keyed artifacts, absolute and
|
|
29
|
+
comparable regression budgets, explicit uncertainty, CLI capture and review, documentation, and
|
|
30
|
+
performance coverage.
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [29afc3d]
|
|
35
|
+
- Updated dependencies [3f063f6]
|
|
36
|
+
- Updated dependencies [6a7ae58]
|
|
37
|
+
- Updated dependencies [b06fd0a]
|
|
38
|
+
- Updated dependencies [3050209]
|
|
39
|
+
- Updated dependencies [1b054b6]
|
|
40
|
+
- Updated dependencies [b4f1b6e]
|
|
41
|
+
- Updated dependencies [87189c3]
|
|
42
|
+
- Updated dependencies [e654fae]
|
|
43
|
+
- Updated dependencies [b2ec119]
|
|
44
|
+
- @typed-sql/core@2.0.0-rc.0
|
|
45
|
+
- @typed-sql/schema@2.0.0-rc.0
|
|
46
|
+
|
|
3
47
|
## 1.0.0
|
|
4
48
|
|
|
5
49
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
The stable, grammar-neutral TypeScript source compiler behind
|
|
4
4
|
[typed-sql](https://github.com/Lojhan/typed-sql). It finds static SQL templates, asks the configured
|
|
5
|
-
grammar for row and parameter shapes, creates an in-memory TypeScript overlay,
|
|
6
|
-
mappings
|
|
5
|
+
grammar for row and parameter shapes, creates an in-memory TypeScript overlay, preserves source
|
|
6
|
+
mappings, emits deterministic query manifests, and compares them with grammar-owned native database
|
|
7
|
+
evidence for CI and production correlation. It also compares before/after snapshots and manifests to
|
|
8
|
+
find query-level migration breaks in both rolling-deployment directions, and captures fingerprint-keyed
|
|
9
|
+
structured plans for explicit regression review.
|
|
7
10
|
|
|
8
11
|
```sh
|
|
9
12
|
pnpm add @typed-sql/compiler
|
|
@@ -21,11 +24,31 @@ const result = compileSource({
|
|
|
21
24
|
```
|
|
22
25
|
|
|
23
26
|
`compileSource` consumes only `DialectPlugin`; it does not branch on a database, grammar package,
|
|
24
|
-
or driver.
|
|
25
|
-
|
|
27
|
+
or driver. Compiled queries expose path-independent SHA-256 fingerprints, variant fingerprints,
|
|
28
|
+
variant descriptions, and source-mapped semantics merged conservatively across conditional
|
|
29
|
+
structure. `buildQueryManifest` turns the same evidence into canonical, secret-free JSON without
|
|
30
|
+
generating an application API. Its public options include the structural-variant bound used for
|
|
31
|
+
conditional fragments. Application projects normally use the compiler through `typed-sql check`
|
|
32
|
+
or the language server.
|
|
33
|
+
|
|
34
|
+
Live verification APIs collect transient SQL only after sources still match the manifest, schedule
|
|
35
|
+
grammar-owned adapters with bounded concurrency, compare native field evidence, and emit canonical
|
|
36
|
+
proofs that contain no SQL, values, URLs, absolute paths, or driver errors.
|
|
37
|
+
|
|
38
|
+
Plan-governance APIs schedule grammar-owned inspectors, normalize redacted plan evidence, and apply
|
|
39
|
+
absolute or environment-comparable relative budgets. Version, schema, settings, statistics, and sample
|
|
40
|
+
changes remain explicit uncertainty instead of being treated as a pass.
|
|
41
|
+
|
|
42
|
+
Migration compatibility APIs consume deterministic artifacts only. They classify source, runtime,
|
|
43
|
+
deployment-order, compatible, and unknown outcomes; link affected variants to source and dependency
|
|
44
|
+
ranges; and emit canonical reports without SQL, default expressions, credentials, or absolute paths.
|
|
26
45
|
|
|
27
46
|
Read [Architecture](https://github.com/Lojhan/typed-sql/blob/main/docs/concepts/architecture.md),
|
|
28
|
-
[Compose conditional SQL](https://github.com/Lojhan/typed-sql/blob/main/docs/guides/composition.md),
|
|
47
|
+
[Compose conditional SQL](https://github.com/Lojhan/typed-sql/blob/main/docs/guides/composition.md),
|
|
48
|
+
[Query manifests](https://github.com/Lojhan/typed-sql/blob/main/docs/guides/query-manifests.md), and
|
|
49
|
+
[Live verification](https://github.com/Lojhan/typed-sql/blob/main/docs/guides/live-verification.md),
|
|
50
|
+
[Query plan governance](https://github.com/Lojhan/typed-sql/blob/main/docs/guides/query-plan-governance.md),
|
|
51
|
+
[Migration compatibility](https://github.com/Lojhan/typed-sql/blob/main/docs/guides/migration-compatibility.md), and
|
|
29
52
|
[Inference and safety](https://github.com/Lojhan/typed-sql/blob/main/docs/concepts/type-safety.md).
|
|
30
53
|
|
|
31
54
|
MIT © typed-sql contributors
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { SchemaSnapshot, SourceRange } from "@typed-sql/core";
|
|
2
|
+
import type { QueryManifest, QueryManifestLocation } from "./manifest.js";
|
|
3
|
+
export declare const SCHEMA_COMPATIBILITY_FORMAT_VERSION: 1;
|
|
4
|
+
export declare const SCHEMA_COMPATIBILITY_ANALYZER_VERSION: "typed-sql-v1";
|
|
5
|
+
export type DeploymentDirection = "before-app-after-database" | "after-app-before-database";
|
|
6
|
+
export type CompatibilityClassification = "compatible" | "deployment-order-sensitive" | "source-breaking" | "runtime-breaking" | "unknown";
|
|
7
|
+
export type CompatibilitySeverity = "info" | "warning" | "error";
|
|
8
|
+
export type SchemaCompatibilityChangeKind = "relation-added" | "relation-removed" | "column-added" | "column-removed" | "column-database-type" | "column-typescript-type" | "column-nullability" | "column-array" | "column-default" | "enum-added" | "enum-removed" | "enum-values" | "domain-added" | "domain-removed" | "domain-database-type" | "domain-typescript-type" | "domain-nullability" | "function-added" | "function-removed" | "function-return-type" | "function-nullability" | "function-set-returning" | "function-volatility" | "dialect-version" | "server-version" | "query-contract";
|
|
9
|
+
export interface SchemaCompatibilityTarget {
|
|
10
|
+
readonly kind: "schema" | "relation" | "column" | "enum" | "domain" | "function" | "query";
|
|
11
|
+
readonly key: string;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly schema?: string;
|
|
14
|
+
readonly parent?: string;
|
|
15
|
+
}
|
|
16
|
+
export type CompatibilityEvidenceValue = string | boolean | null | readonly string[];
|
|
17
|
+
export type CompatibilityEvidence = Readonly<Record<string, CompatibilityEvidenceValue>>;
|
|
18
|
+
export interface SchemaCompatibilityChange {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly kind: SchemaCompatibilityChangeKind;
|
|
21
|
+
readonly target: SchemaCompatibilityTarget;
|
|
22
|
+
readonly before?: CompatibilityEvidence;
|
|
23
|
+
readonly after?: CompatibilityEvidence;
|
|
24
|
+
}
|
|
25
|
+
export interface CompatibilityQueryReference {
|
|
26
|
+
readonly queryId: string;
|
|
27
|
+
readonly variantFingerprint: string;
|
|
28
|
+
readonly source: QueryManifestLocation;
|
|
29
|
+
readonly dependencyRange?: SourceRange;
|
|
30
|
+
}
|
|
31
|
+
export interface SchemaCompatibilityAssessment {
|
|
32
|
+
readonly direction: DeploymentDirection;
|
|
33
|
+
readonly changeId?: string;
|
|
34
|
+
readonly classification: CompatibilityClassification;
|
|
35
|
+
readonly severity: CompatibilitySeverity;
|
|
36
|
+
readonly reason: string;
|
|
37
|
+
readonly queries: readonly CompatibilityQueryReference[];
|
|
38
|
+
}
|
|
39
|
+
export interface SchemaCompatibilityReport {
|
|
40
|
+
readonly formatVersion: typeof SCHEMA_COMPATIBILITY_FORMAT_VERSION;
|
|
41
|
+
readonly analyzerVersion: typeof SCHEMA_COMPATIBILITY_ANALYZER_VERSION;
|
|
42
|
+
readonly dialect: string;
|
|
43
|
+
readonly before: {
|
|
44
|
+
readonly schemaHash: string;
|
|
45
|
+
readonly manifestHash: string;
|
|
46
|
+
readonly version?: string;
|
|
47
|
+
};
|
|
48
|
+
readonly after: {
|
|
49
|
+
readonly schemaHash: string;
|
|
50
|
+
readonly manifestHash: string;
|
|
51
|
+
readonly version?: string;
|
|
52
|
+
};
|
|
53
|
+
readonly changes: readonly SchemaCompatibilityChange[];
|
|
54
|
+
readonly assessments: readonly SchemaCompatibilityAssessment[];
|
|
55
|
+
readonly summary: Readonly<Record<CompatibilitySeverity, number>>;
|
|
56
|
+
}
|
|
57
|
+
export interface AnalyzeSchemaCompatibilityOptions {
|
|
58
|
+
readonly before: SchemaSnapshot;
|
|
59
|
+
readonly after: SchemaSnapshot;
|
|
60
|
+
readonly beforeManifest: QueryManifest;
|
|
61
|
+
readonly afterManifest: QueryManifest;
|
|
62
|
+
}
|
|
63
|
+
export declare function analyzeSchemaCompatibility(options: AnalyzeSchemaCompatibilityOptions): SchemaCompatibilityReport;
|
|
64
|
+
export declare function serializeSchemaCompatibilityReport(report: SchemaCompatibilityReport): string;
|
|
65
|
+
export declare function parseSchemaCompatibilityReport(value: unknown): SchemaCompatibilityReport;
|
|
66
|
+
//# sourceMappingURL=compatibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility.d.ts","sourceRoot":"","sources":["../../../../src/compatibility.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEpF,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAwB,MAAM,eAAe,CAAC;AAGhG,eAAO,MAAM,mCAAmC,EAAG,CAAU,CAAC;AAC9D,eAAO,MAAM,qCAAqC,EAAG,cAAuB,CAAC;AAE7E,MAAM,MAAM,mBAAmB,GAAG,2BAA2B,GAAG,2BAA2B,CAAC;AAC5F,MAAM,MAAM,2BAA2B,GACnC,YAAY,GACZ,4BAA4B,GAC5B,iBAAiB,GACjB,kBAAkB,GAClB,SAAS,CAAC;AACd,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AACjE,MAAM,MAAM,6BAA6B,GACrC,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,gBAAgB,GAChB,sBAAsB,GACtB,wBAAwB,GACxB,oBAAoB,GACpB,cAAc,GACd,gBAAgB,GAChB,YAAY,GACZ,cAAc,GACd,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,sBAAsB,GACtB,wBAAwB,GACxB,oBAAoB,GACpB,gBAAgB,GAChB,kBAAkB,GAClB,sBAAsB,GACtB,sBAAsB,GACtB,wBAAwB,GACxB,qBAAqB,GACrB,iBAAiB,GACjB,gBAAgB,GAChB,gBAAgB,CAAC;AAErB,MAAM,WAAW,yBAAyB;IACxC,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