@prisma-next/family-sql 0.3.0-pr.99.5 → 0.3.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/LICENSE +201 -0
- package/README.md +58 -22
- package/dist/authoring-type-constructors-DgU-RFaP.mjs +203 -0
- package/dist/authoring-type-constructors-DgU-RFaP.mjs.map +1 -0
- package/dist/control-adapter.d.mts +54 -0
- package/dist/control-adapter.d.mts.map +1 -0
- package/dist/control-adapter.mjs +1 -0
- package/dist/control.d.mts +386 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +643 -0
- package/dist/control.mjs.map +1 -0
- package/dist/operation-descriptors.d.mts +380 -0
- package/dist/operation-descriptors.d.mts.map +1 -0
- package/dist/operation-descriptors.mjs +294 -0
- package/dist/operation-descriptors.mjs.map +1 -0
- package/dist/pack.d.mts +248 -0
- package/dist/pack.d.mts.map +1 -0
- package/dist/pack.mjs +18 -0
- package/dist/pack.mjs.map +1 -0
- package/dist/runtime.d.mts +27 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +38 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/schema-verify.d.mts +48 -0
- package/dist/schema-verify.d.mts.map +1 -0
- package/dist/schema-verify.mjs +3 -0
- package/dist/test-utils.d.mts +2 -0
- package/dist/test-utils.mjs +3 -0
- package/dist/types-BaUzKt6Q.d.mts +353 -0
- package/dist/types-BaUzKt6Q.d.mts.map +1 -0
- package/dist/verify-DZHtfcmj.mjs +108 -0
- package/dist/verify-DZHtfcmj.mjs.map +1 -0
- package/dist/verify-sql-schema-BBhkqEDo.d.mts +67 -0
- package/dist/verify-sql-schema-BBhkqEDo.d.mts.map +1 -0
- package/dist/verify-sql-schema-lR-tlboL.mjs +1174 -0
- package/dist/verify-sql-schema-lR-tlboL.mjs.map +1 -0
- package/dist/verify.d.mts +31 -0
- package/dist/verify.d.mts.map +1 -0
- package/dist/verify.mjs +3 -0
- package/package.json +35 -43
- package/src/core/assembly.ts +123 -155
- package/src/core/authoring-field-presets.ts +207 -0
- package/src/core/authoring-type-constructors.ts +17 -0
- package/src/core/control-adapter.ts +18 -10
- package/src/core/control-descriptor.ts +28 -0
- package/src/core/control-instance.ts +700 -0
- package/src/core/migrations/contract-to-schema-ir.ts +269 -0
- package/src/core/migrations/descriptor-schemas.ts +172 -0
- package/src/core/migrations/operation-descriptors.ts +213 -0
- package/src/core/migrations/policies.ts +1 -1
- package/src/core/migrations/types.ts +199 -175
- package/src/core/runtime-descriptor.ts +19 -41
- package/src/core/runtime-instance.ts +11 -133
- package/src/core/schema-verify/verify-helpers.ts +104 -22
- package/src/core/schema-verify/verify-sql-schema.ts +964 -418
- package/src/core/verify.ts +4 -13
- package/src/exports/control.ts +31 -8
- package/src/exports/operation-descriptors.ts +52 -0
- package/src/exports/pack.ts +16 -0
- package/src/exports/runtime.ts +2 -6
- package/src/exports/schema-verify.ts +4 -1
- package/src/exports/test-utils.ts +3 -4
- package/dist/chunk-GYEG3I7U.js +0 -624
- package/dist/chunk-GYEG3I7U.js.map +0 -1
- package/dist/chunk-SU7LN2UH.js +0 -96
- package/dist/chunk-SU7LN2UH.js.map +0 -1
- package/dist/chunk-XH2Y5NTD.js +0 -715
- package/dist/chunk-XH2Y5NTD.js.map +0 -1
- package/dist/core/assembly.d.ts +0 -43
- package/dist/core/assembly.d.ts.map +0 -1
- package/dist/core/control-adapter.d.ts +0 -42
- package/dist/core/control-adapter.d.ts.map +0 -1
- package/dist/core/descriptor.d.ts +0 -28
- package/dist/core/descriptor.d.ts.map +0 -1
- package/dist/core/instance.d.ts +0 -140
- package/dist/core/instance.d.ts.map +0 -1
- package/dist/core/migrations/plan-helpers.d.ts +0 -20
- package/dist/core/migrations/plan-helpers.d.ts.map +0 -1
- package/dist/core/migrations/policies.d.ts +0 -6
- package/dist/core/migrations/policies.d.ts.map +0 -1
- package/dist/core/migrations/types.d.ts +0 -280
- package/dist/core/migrations/types.d.ts.map +0 -1
- package/dist/core/runtime-descriptor.d.ts +0 -19
- package/dist/core/runtime-descriptor.d.ts.map +0 -1
- package/dist/core/runtime-instance.d.ts +0 -54
- package/dist/core/runtime-instance.d.ts.map +0 -1
- package/dist/core/schema-verify/verify-helpers.d.ts +0 -96
- package/dist/core/schema-verify/verify-helpers.d.ts.map +0 -1
- package/dist/core/schema-verify/verify-sql-schema.d.ts +0 -45
- package/dist/core/schema-verify/verify-sql-schema.d.ts.map +0 -1
- package/dist/core/verify.d.ts +0 -39
- package/dist/core/verify.d.ts.map +0 -1
- package/dist/exports/control-adapter.d.ts +0 -2
- package/dist/exports/control-adapter.d.ts.map +0 -1
- package/dist/exports/control-adapter.js +0 -1
- package/dist/exports/control-adapter.js.map +0 -1
- package/dist/exports/control.d.ts +0 -13
- package/dist/exports/control.d.ts.map +0 -1
- package/dist/exports/control.js +0 -149
- package/dist/exports/control.js.map +0 -1
- package/dist/exports/runtime.d.ts +0 -8
- package/dist/exports/runtime.d.ts.map +0 -1
- package/dist/exports/runtime.js +0 -64
- package/dist/exports/runtime.js.map +0 -1
- package/dist/exports/schema-verify.d.ts +0 -11
- package/dist/exports/schema-verify.d.ts.map +0 -1
- package/dist/exports/schema-verify.js +0 -15
- package/dist/exports/schema-verify.js.map +0 -1
- package/dist/exports/test-utils.d.ts +0 -7
- package/dist/exports/test-utils.d.ts.map +0 -1
- package/dist/exports/test-utils.js +0 -17
- package/dist/exports/test-utils.js.map +0 -1
- package/dist/exports/verify.d.ts +0 -2
- package/dist/exports/verify.d.ts.map +0 -1
- package/dist/exports/verify.js +0 -11
- package/dist/exports/verify.js.map +0 -1
- package/src/core/descriptor.ts +0 -33
- package/src/core/instance.ts +0 -909
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2026] [Prisma Data, Inc]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -5,22 +5,35 @@ SQL family descriptor for Prisma Next.
|
|
|
5
5
|
## Purpose
|
|
6
6
|
|
|
7
7
|
Provides the SQL family descriptor (`ControlFamilyDescriptor`) that includes:
|
|
8
|
-
- The SQL target family hook (`
|
|
8
|
+
- The SQL target family hook (`sqlEmission`)
|
|
9
9
|
- Factory method (`create()`) to create family instances
|
|
10
10
|
|
|
11
11
|
## Responsibilities
|
|
12
12
|
|
|
13
13
|
- **Family Descriptor Export**: Exports the SQL `ControlFamilyDescriptor` for use in CLI configuration files
|
|
14
|
-
- **Family Instance Creation**: Creates `SqlFamilyInstance` objects that implement control-plane domain actions (`verify`, `schemaVerify`, `introspect`, `emitContract`, `
|
|
14
|
+
- **Family Instance Creation**: Creates `SqlFamilyInstance` objects that implement control-plane domain actions (`verify`, `schemaVerify`, `introspect`, `emitContract`, `validateContract`)
|
|
15
15
|
- **Planner & Runner SPI**: Owns the `MigrationPlanner` / `MigrationRunner` interfaces plus the `SqlControlTargetDescriptor` helper so targets can expose planners and runners (e.g., Postgres init planner/runner)
|
|
16
|
-
- **Family Hook Integration**: Integrates the SQL target family hook (`
|
|
16
|
+
- **Family Hook Integration**: Integrates the SQL target family hook (`sqlEmission`) from `@prisma-next/sql-contract-emitter`
|
|
17
17
|
- **Control Plane Entry Point**: Serves as the control plane entry point for the SQL family, enabling the CLI to select the family hook and create family instances
|
|
18
18
|
- **Component Database Dependencies**: Consumes database dependencies declared by framework components (target/adapter/extension packs). Callers pass the active `frameworkComponents` list into planning/execution/verification; SQL layers structurally narrow to components that declare `databaseDependencies` and use their pure verification hooks (no fuzzy matching against `contract.extensionPacks`).
|
|
19
|
+
- **Contract-to-SchemaIR Conversion**: Converts `SqlStorage` from a contract into `SqlSchemaIR` for offline migration planning, enabling `migration plan` to work without a database connection
|
|
20
|
+
- **Destructive Change Detection**: Compares two `SqlStorage` values and identifies destructive changes (dropped tables/columns) for migration policy enforcement
|
|
21
|
+
- **Storage Type Control Hooks**: Extracts codec-owned control hooks for planning/verification/introspection of `storage.types` without adding enum-specific fields to shared IR
|
|
22
|
+
- **Codec Ownership**: Enforces a single owner per `codecId` for parameterized renderers and control-plane hooks to prevent ambiguous conflicts during assembly
|
|
23
|
+
- **Mutation Default Registry Assembly**: Assembles control-plane default-function entries and generator descriptors from composed components with hard-error collisions
|
|
24
|
+
- **PSL Interpretation Input Assembly**: Assembles target-bound scalar type descriptors plus mutation-default contributions for PSL provider/interpreter inputs
|
|
25
|
+
- **Parameterized Type Verification**: Expands contract `typeParams` into expected native type strings during schema verification and flags missing parameters as type mismatches
|
|
26
|
+
- **Schema Defaults Policy**: Ignores execution mutation defaults during schema verification since they are applied before DB writes
|
|
27
|
+
- **Foreign Key Config Awareness**: Schema verification respects the contract's `foreignKeys` configuration — when `foreignKeys.constraints` is `false`, FK constraint checks are skipped during verification (see [ADR 161](../../../docs/architecture%20docs/adrs/ADR%20161%20-%20Explicit%20foreign%20key%20constraint%20and%20index%20configuration.md))
|
|
28
|
+
- **Referential Action Verification**: When a contract FK specifies `onDelete` or `onUpdate`, the verifier compares them against the introspected schema and reports `foreign_key_mismatch` on mismatch (see [ADR 166](../../../docs/architecture%20docs/adrs/ADR%20166%20-%20Referential%20actions%20for%20foreign%20keys.md))
|
|
19
29
|
|
|
20
30
|
## Usage
|
|
21
31
|
|
|
22
32
|
```typescript
|
|
23
|
-
import sql
|
|
33
|
+
import sql, {
|
|
34
|
+
assembleAuthoringContributions,
|
|
35
|
+
assemblePslInterpretationContributions,
|
|
36
|
+
} from '@prisma-next/family-sql/control';
|
|
24
37
|
|
|
25
38
|
// sql is a ControlFamilyDescriptor with:
|
|
26
39
|
// - kind: 'family'
|
|
@@ -38,9 +51,9 @@ const familyInstance = sql.create({
|
|
|
38
51
|
});
|
|
39
52
|
|
|
40
53
|
// Use instance methods for domain actions
|
|
41
|
-
const
|
|
42
|
-
const verifyResult = await familyInstance.verify({ driver,
|
|
43
|
-
const emitResult = await familyInstance.emitContract({
|
|
54
|
+
const contract = familyInstance.validateContract(contractJson);
|
|
55
|
+
const verifyResult = await familyInstance.verify({ driver, contract, ... });
|
|
56
|
+
const emitResult = await familyInstance.emitContract({ contract: rawContract }); // Handles stripping mappings and validation internally
|
|
44
57
|
|
|
45
58
|
// Targets that implement SqlControlTargetDescriptor can build planners
|
|
46
59
|
const planner = postgresTargetDescriptor.migrations.createPlanner(familyInstance);
|
|
@@ -62,6 +75,30 @@ const executeResult = await runner.execute({
|
|
|
62
75
|
frameworkComponents: [postgresTargetDescriptor, postgresAdapterDescriptor, pgVectorExtensionDescriptor],
|
|
63
76
|
});
|
|
64
77
|
|
|
78
|
+
// Assemble PSL interpretation inputs for sql-contract-psl/provider
|
|
79
|
+
const authoringContributions = assembleAuthoringContributions([
|
|
80
|
+
sql,
|
|
81
|
+
postgresTargetDescriptor,
|
|
82
|
+
postgresAdapterDescriptor,
|
|
83
|
+
pgVectorExtensionDescriptor,
|
|
84
|
+
]);
|
|
85
|
+
const pslInputs = assemblePslInterpretationContributions([
|
|
86
|
+
sql,
|
|
87
|
+
postgresTargetDescriptor,
|
|
88
|
+
postgresAdapterDescriptor,
|
|
89
|
+
pgVectorExtensionDescriptor,
|
|
90
|
+
]);
|
|
91
|
+
const providerOptions = {
|
|
92
|
+
target: postgresTargetDescriptor,
|
|
93
|
+
authoringContributions,
|
|
94
|
+
scalarTypeDescriptors: pslInputs.scalarTypeDescriptors,
|
|
95
|
+
controlMutationDefaults: {
|
|
96
|
+
defaultFunctionRegistry: pslInputs.defaultFunctionRegistry,
|
|
97
|
+
generatorDescriptors: pslInputs.generatorDescriptors,
|
|
98
|
+
},
|
|
99
|
+
composedExtensionPacks: [pgVectorExtensionDescriptor.id],
|
|
100
|
+
};
|
|
101
|
+
|
|
65
102
|
// executeResult is a Result<MigrationRunnerSuccessValue, MigrationRunnerFailure>
|
|
66
103
|
if (executeResult.ok) {
|
|
67
104
|
console.log(`Executed ${executeResult.value.operationsExecuted} operations`);
|
|
@@ -75,29 +112,30 @@ if (executeResult.ok) {
|
|
|
75
112
|
This package is the control plane entry point for the SQL family. It composes:
|
|
76
113
|
- `@prisma-next/sql-contract-emitter` - Provides the SQL family hook
|
|
77
114
|
- `@prisma-next/sql-operations` - SQL operation signature types
|
|
78
|
-
- `@prisma-next/sql-contract
|
|
115
|
+
- `@prisma-next/sql-contract` - SQL contract types and validation
|
|
79
116
|
|
|
80
117
|
The framework CLI uses this descriptor to:
|
|
81
118
|
1. Create family instances for control-plane operations (via `create()`)
|
|
82
119
|
|
|
83
120
|
Family instances implement domain actions:
|
|
84
|
-
- **`
|
|
85
|
-
- **`verify()`**: Verifies database marker against contract (compares target,
|
|
121
|
+
- **`validateContract(contractJson)`**: Validates and normalizes contract, returns `Contract` without mappings
|
|
122
|
+
- **`verify()`**: Verifies database marker against contract (compares target, storageHash, profileHash)
|
|
86
123
|
- **`schemaVerify()`**: Verifies database schema against contract (compares contract requirements vs live schema)
|
|
87
124
|
- **`introspect()`**: Introspects database schema and returns `SqlSchemaIR`
|
|
88
125
|
- **`toSchemaView(schema)`**: Projects `SqlSchemaIR` into `CoreSchemaView` for human-readable display. Always displays native database types (e.g., `int4`, `text`) rather than mapped codec IDs (e.g., `pg/int4@1`) to reflect actual database state.
|
|
89
|
-
- **`emitContract({
|
|
126
|
+
- **`emitContract({ contract })`**: Emits contract JSON and DTS as strings. Handles stripping mappings and validation internally. Uses preassembled state (operation registry, type imports, extension IDs).
|
|
90
127
|
|
|
91
128
|
The descriptor is "pure data + factory" - it only provides the hook and factory method. All family-specific logic lives on the instance.
|
|
92
129
|
|
|
93
130
|
## Package Structure
|
|
94
131
|
|
|
95
|
-
- **`src/core/descriptor.ts`**: `SqlFamilyDescriptor` class implementing `ControlFamilyDescriptor` interface (pure data + factory)
|
|
96
|
-
- **`src/core/instance.ts`**: `createSqlFamilyInstance` function that creates `SqlFamilyInstance` with domain action methods (`
|
|
97
|
-
- **`src/core/assembly.ts`**: Assembly helpers for
|
|
132
|
+
- **`src/core/control-descriptor.ts`**: `SqlFamilyDescriptor` class implementing `ControlFamilyDescriptor` interface (pure data + factory)
|
|
133
|
+
- **`src/core/control-instance.ts`**: `createSqlFamilyInstance` function that creates `SqlFamilyInstance` with domain action methods (`validateContract`, `verify`, `schemaVerify`, `introspect`, `toSchemaView`, `emitContract`). Contains `convertOperationManifest` function used internally by instance creation and test utilities in the same package.
|
|
134
|
+
- **`src/core/assembly.ts`**: Assembly helpers for extracting type imports, collecting codec-owned storage type control hooks, and composing mutation-default registries with duplicate detection.
|
|
98
135
|
- **`src/core/verify.ts`**: Verification helpers (`readMarker`, `collectSupportedCodecTypeIds`)
|
|
99
136
|
- **`src/core/control-adapter.ts`**: SQL control adapter interface (`SqlControlAdapter`) for control-plane operations
|
|
100
137
|
- **`src/core/migrations/`**: Migration IR helpers plus planner and runner SPI types (`MigrationPlanner`, `MigrationRunner`, `SqlControlTargetDescriptor`). Runners return `MigrationRunnerResult` which is a union of success/failure.
|
|
138
|
+
- **`src/core/migrations/contract-to-schema-ir.ts`**: `contractToSchemaIR(contract, { annotationNamespace, ... })` converts a contract to `SqlSchemaIR` for offline migration planning (used by `migration plan` to synthesize the "from" schema without a database connection). Also exports `detectDestructiveChanges(from, to)` which compares two `SqlStorage` values and returns a list of destructive changes (dropped tables, dropped columns) for migration policy enforcement.
|
|
101
139
|
|
|
102
140
|
### Migration Runner Error Codes
|
|
103
141
|
|
|
@@ -111,22 +149,21 @@ The runner returns structured errors with the following codes:
|
|
|
111
149
|
- **`SCHEMA_VERIFY_FAILED`**: Resulting schema doesn't satisfy the destination contract
|
|
112
150
|
- **`EXECUTION_FAILED`**: SQL execution error during operation execution
|
|
113
151
|
- **`src/exports/control.ts`**: Control plane entry point (exports `SqlFamilyDescriptor` instance)
|
|
114
|
-
- **`src/exports/runtime.ts`**: Runtime entry point
|
|
152
|
+
- **`src/exports/runtime.ts`**: Runtime plane entry point
|
|
115
153
|
|
|
116
154
|
## Entrypoints
|
|
117
155
|
|
|
118
156
|
- **`./control`**: Control plane entry point for CLI/config usage (exports `SqlFamilyDescriptor`)
|
|
119
157
|
- **`./control-adapter`**: SQL control adapter interface (`SqlControlAdapter`, `SqlControlAdapterDescriptor`) for target-specific adapters
|
|
120
|
-
- **`./runtime`**: Runtime
|
|
158
|
+
- **`./runtime`**: Runtime plane identity exports only (family ID, types, descriptor identity). Does **not** export runtime creation helpers—use `instantiateExecutionStack` from `@prisma-next/framework-components/execution` and `createExecutionContext`, `createRuntime`, `createSqlExecutionStack` from `@prisma-next/sql-runtime`. See [ADR 152](../../../docs/architecture%20docs/adrs/ADR%20152%20-%20Execution%20Plane%20Descriptors%20and%20Instances.md).
|
|
121
159
|
- **`./verify`**: Verification utilities (`readMarker`, `readMarkerSql`, `parseContractMarkerRow`) for reading contract markers from databases
|
|
122
160
|
|
|
123
161
|
## Dependencies
|
|
124
162
|
|
|
125
|
-
- **`@prisma-next/
|
|
126
|
-
- **`@prisma-next/sql-contract-emitter`**: SQL target family hook (`
|
|
127
|
-
- **`@prisma-next/sql-contract
|
|
128
|
-
- **`@prisma-next/sql-
|
|
129
|
-
- **`@prisma-next/sql-operations`**: SQL operation signature types (`SqlOperationSignature`)
|
|
163
|
+
- **`@prisma-next/framework-components`**: Control plane types via `./control` (`ControlFamilyDescriptor`, `ControlTargetDescriptor`, `ControlAdapterDescriptor`, `ControlDriverDescriptor`, `ControlExtensionDescriptor`, `ControlDriverInstance`, etc.)
|
|
164
|
+
- **`@prisma-next/sql-contract-emitter`**: SQL target family hook (`sqlEmission`)
|
|
165
|
+
- **`@prisma-next/sql-contract`**: SQL contract types plus validation (`validateContract`)
|
|
166
|
+
- **`@prisma-next/sql-operations`**: SQL operation registry types (`SqlOperationEntry`, `SqlOperationRegistry`)
|
|
130
167
|
|
|
131
168
|
**Dependents:**
|
|
132
169
|
- CLI configuration files import this package to register the SQL family
|
|
@@ -142,4 +179,3 @@ The runner returns structured errors with the following codes:
|
|
|
142
179
|
- **Tests**:
|
|
143
180
|
- CLI integration: `test/integration/test/cli.db-init.e2e.test.ts`
|
|
144
181
|
- Target unit/integration: `packages/3-targets/3-targets/postgres/test/migrations/*`
|
|
145
|
-
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
//#region src/core/authoring-field-presets.ts
|
|
2
|
+
const CHARACTER_CODEC_ID = "sql/char@1";
|
|
3
|
+
const CHARACTER_NATIVE_TYPE = "character";
|
|
4
|
+
const nanoidOptionsArgument = {
|
|
5
|
+
kind: "object",
|
|
6
|
+
optional: true,
|
|
7
|
+
properties: { size: {
|
|
8
|
+
kind: "number",
|
|
9
|
+
optional: true,
|
|
10
|
+
integer: true,
|
|
11
|
+
minimum: 2,
|
|
12
|
+
maximum: 255
|
|
13
|
+
} }
|
|
14
|
+
};
|
|
15
|
+
const sqlFamilyAuthoringFieldPresets = {
|
|
16
|
+
text: {
|
|
17
|
+
kind: "fieldPreset",
|
|
18
|
+
output: {
|
|
19
|
+
codecId: "sql/text@1",
|
|
20
|
+
nativeType: "text"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
timestamp: {
|
|
24
|
+
kind: "fieldPreset",
|
|
25
|
+
output: {
|
|
26
|
+
codecId: "sql/timestamp@1",
|
|
27
|
+
nativeType: "timestamp"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
createdAt: {
|
|
31
|
+
kind: "fieldPreset",
|
|
32
|
+
output: {
|
|
33
|
+
codecId: "sql/timestamp@1",
|
|
34
|
+
nativeType: "timestamp",
|
|
35
|
+
default: {
|
|
36
|
+
kind: "function",
|
|
37
|
+
expression: "CURRENT_TIMESTAMP"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
uuid: {
|
|
42
|
+
kind: "fieldPreset",
|
|
43
|
+
output: {
|
|
44
|
+
codecId: CHARACTER_CODEC_ID,
|
|
45
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
46
|
+
typeParams: { length: 36 }
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
ulid: {
|
|
50
|
+
kind: "fieldPreset",
|
|
51
|
+
output: {
|
|
52
|
+
codecId: CHARACTER_CODEC_ID,
|
|
53
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
54
|
+
typeParams: { length: 26 }
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
nanoid: {
|
|
58
|
+
kind: "fieldPreset",
|
|
59
|
+
args: [nanoidOptionsArgument],
|
|
60
|
+
output: {
|
|
61
|
+
codecId: CHARACTER_CODEC_ID,
|
|
62
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
63
|
+
typeParams: { length: {
|
|
64
|
+
kind: "arg",
|
|
65
|
+
index: 0,
|
|
66
|
+
path: ["size"],
|
|
67
|
+
default: 21
|
|
68
|
+
} }
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
cuid2: {
|
|
72
|
+
kind: "fieldPreset",
|
|
73
|
+
output: {
|
|
74
|
+
codecId: CHARACTER_CODEC_ID,
|
|
75
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
76
|
+
typeParams: { length: 24 }
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
ksuid: {
|
|
80
|
+
kind: "fieldPreset",
|
|
81
|
+
output: {
|
|
82
|
+
codecId: CHARACTER_CODEC_ID,
|
|
83
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
84
|
+
typeParams: { length: 27 }
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
id: {
|
|
88
|
+
uuidv4: {
|
|
89
|
+
kind: "fieldPreset",
|
|
90
|
+
output: {
|
|
91
|
+
codecId: CHARACTER_CODEC_ID,
|
|
92
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
93
|
+
typeParams: { length: 36 },
|
|
94
|
+
executionDefault: {
|
|
95
|
+
kind: "generator",
|
|
96
|
+
id: "uuidv4"
|
|
97
|
+
},
|
|
98
|
+
id: true
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
uuidv7: {
|
|
102
|
+
kind: "fieldPreset",
|
|
103
|
+
output: {
|
|
104
|
+
codecId: CHARACTER_CODEC_ID,
|
|
105
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
106
|
+
typeParams: { length: 36 },
|
|
107
|
+
executionDefault: {
|
|
108
|
+
kind: "generator",
|
|
109
|
+
id: "uuidv7"
|
|
110
|
+
},
|
|
111
|
+
id: true
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
ulid: {
|
|
115
|
+
kind: "fieldPreset",
|
|
116
|
+
output: {
|
|
117
|
+
codecId: CHARACTER_CODEC_ID,
|
|
118
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
119
|
+
typeParams: { length: 26 },
|
|
120
|
+
executionDefault: {
|
|
121
|
+
kind: "generator",
|
|
122
|
+
id: "ulid"
|
|
123
|
+
},
|
|
124
|
+
id: true
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
nanoid: {
|
|
128
|
+
kind: "fieldPreset",
|
|
129
|
+
args: [nanoidOptionsArgument],
|
|
130
|
+
output: {
|
|
131
|
+
codecId: CHARACTER_CODEC_ID,
|
|
132
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
133
|
+
typeParams: { length: {
|
|
134
|
+
kind: "arg",
|
|
135
|
+
index: 0,
|
|
136
|
+
path: ["size"],
|
|
137
|
+
default: 21
|
|
138
|
+
} },
|
|
139
|
+
executionDefault: {
|
|
140
|
+
kind: "generator",
|
|
141
|
+
id: "nanoid",
|
|
142
|
+
params: { size: {
|
|
143
|
+
kind: "arg",
|
|
144
|
+
index: 0,
|
|
145
|
+
path: ["size"]
|
|
146
|
+
} }
|
|
147
|
+
},
|
|
148
|
+
id: true
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
cuid2: {
|
|
152
|
+
kind: "fieldPreset",
|
|
153
|
+
output: {
|
|
154
|
+
codecId: CHARACTER_CODEC_ID,
|
|
155
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
156
|
+
typeParams: { length: 24 },
|
|
157
|
+
executionDefault: {
|
|
158
|
+
kind: "generator",
|
|
159
|
+
id: "cuid2"
|
|
160
|
+
},
|
|
161
|
+
id: true
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
ksuid: {
|
|
165
|
+
kind: "fieldPreset",
|
|
166
|
+
output: {
|
|
167
|
+
codecId: CHARACTER_CODEC_ID,
|
|
168
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
169
|
+
typeParams: { length: 27 },
|
|
170
|
+
executionDefault: {
|
|
171
|
+
kind: "generator",
|
|
172
|
+
id: "ksuid"
|
|
173
|
+
},
|
|
174
|
+
id: true
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/core/authoring-type-constructors.ts
|
|
182
|
+
const sqlFamilyAuthoringTypes = { sql: { String: {
|
|
183
|
+
kind: "typeConstructor",
|
|
184
|
+
args: [{
|
|
185
|
+
kind: "number",
|
|
186
|
+
name: "length",
|
|
187
|
+
integer: true,
|
|
188
|
+
minimum: 1,
|
|
189
|
+
maximum: 10485760
|
|
190
|
+
}],
|
|
191
|
+
output: {
|
|
192
|
+
codecId: "sql/varchar@1",
|
|
193
|
+
nativeType: "character varying",
|
|
194
|
+
typeParams: { length: {
|
|
195
|
+
kind: "arg",
|
|
196
|
+
index: 0
|
|
197
|
+
} }
|
|
198
|
+
}
|
|
199
|
+
} } };
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
export { sqlFamilyAuthoringFieldPresets as n, sqlFamilyAuthoringTypes as t };
|
|
203
|
+
//# sourceMappingURL=authoring-type-constructors-DgU-RFaP.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring-type-constructors-DgU-RFaP.mjs","names":[],"sources":["../src/core/authoring-field-presets.ts","../src/core/authoring-type-constructors.ts"],"sourcesContent":["import type { AuthoringFieldNamespace } from '@prisma-next/framework-components/authoring';\n\nconst CHARACTER_CODEC_ID = 'sql/char@1';\nconst CHARACTER_NATIVE_TYPE = 'character';\n\nconst nanoidOptionsArgument = {\n kind: 'object',\n optional: true,\n properties: {\n size: {\n kind: 'number',\n optional: true,\n integer: true,\n minimum: 2,\n maximum: 255,\n },\n },\n} as const;\n\nexport const sqlFamilyAuthoringFieldPresets = {\n text: {\n kind: 'fieldPreset',\n output: {\n codecId: 'sql/text@1',\n nativeType: 'text',\n },\n },\n timestamp: {\n kind: 'fieldPreset',\n output: {\n codecId: 'sql/timestamp@1',\n nativeType: 'timestamp',\n },\n },\n createdAt: {\n kind: 'fieldPreset',\n output: {\n codecId: 'sql/timestamp@1',\n nativeType: 'timestamp',\n default: {\n kind: 'function',\n expression: 'CURRENT_TIMESTAMP',\n },\n },\n },\n uuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n },\n },\n id: {\n uuidv4: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefault: {\n kind: 'generator',\n id: 'uuidv4',\n },\n id: true,\n },\n },\n uuidv7: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefault: {\n kind: 'generator',\n id: 'uuidv7',\n },\n id: true,\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n executionDefault: {\n kind: 'generator',\n id: 'ulid',\n },\n id: true,\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n executionDefault: {\n kind: 'generator',\n id: 'nanoid',\n params: {\n size: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n },\n },\n },\n id: true,\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n executionDefault: {\n kind: 'generator',\n id: 'cuid2',\n },\n id: true,\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n executionDefault: {\n kind: 'generator',\n id: 'ksuid',\n },\n id: true,\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n","import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\n\nexport const sqlFamilyAuthoringTypes = {\n sql: {\n String: {\n kind: 'typeConstructor',\n args: [{ kind: 'number', name: 'length', integer: true, minimum: 1, maximum: 10485760 }],\n output: {\n codecId: 'sql/varchar@1',\n nativeType: 'character varying',\n typeParams: {\n length: { kind: 'arg', index: 0 },\n },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n"],"mappings":";AAEA,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;AAE9B,MAAM,wBAAwB;CAC5B,MAAM;CACN,UAAU;CACV,YAAY,EACV,MAAM;EACJ,MAAM;EACN,UAAU;EACV,SAAS;EACT,SAAS;EACT,SAAS;EACV,EACF;CACF;AAED,MAAa,iCAAiC;CAC5C,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACb;EACF;CACD,WAAW;EACT,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACb;EACF;CACD,WAAW;EACT,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,SAAS;IACP,MAAM;IACN,YAAY;IACb;GACF;EACF;CACD,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,IACT;GACF;EACF;CACD,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,IACT;GACF;EACF;CACD,QAAQ;EACN,MAAM;EACN,MAAM,CAAC,sBAAsB;EAC7B,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ;IACN,MAAM;IACN,OAAO;IACP,MAAM,CAAC,OAAO;IACd,SAAS;IACV,EACF;GACF;EACF;CACD,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,IACT;GACF;EACF;CACD,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,IACT;GACF;EACF;CACD,IAAI;EACF,QAAQ;GACN,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,YAAY,EACV,QAAQ,IACT;IACD,kBAAkB;KAChB,MAAM;KACN,IAAI;KACL;IACD,IAAI;IACL;GACF;EACD,QAAQ;GACN,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,YAAY,EACV,QAAQ,IACT;IACD,kBAAkB;KAChB,MAAM;KACN,IAAI;KACL;IACD,IAAI;IACL;GACF;EACD,MAAM;GACJ,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,YAAY,EACV,QAAQ,IACT;IACD,kBAAkB;KAChB,MAAM;KACN,IAAI;KACL;IACD,IAAI;IACL;GACF;EACD,QAAQ;GACN,MAAM;GACN,MAAM,CAAC,sBAAsB;GAC7B,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,YAAY,EACV,QAAQ;KACN,MAAM;KACN,OAAO;KACP,MAAM,CAAC,OAAO;KACd,SAAS;KACV,EACF;IACD,kBAAkB;KAChB,MAAM;KACN,IAAI;KACJ,QAAQ,EACN,MAAM;MACJ,MAAM;MACN,OAAO;MACP,MAAM,CAAC,OAAO;MACf,EACF;KACF;IACD,IAAI;IACL;GACF;EACD,OAAO;GACL,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,YAAY,EACV,QAAQ,IACT;IACD,kBAAkB;KAChB,MAAM;KACN,IAAI;KACL;IACD,IAAI;IACL;GACF;EACD,OAAO;GACL,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,YAAY,EACV,QAAQ,IACT;IACD,kBAAkB;KAChB,MAAM;KACN,IAAI;KACL;IACD,IAAI;IACL;GACF;EACF;CACF;;;;AC5MD,MAAa,0BAA0B,EACrC,KAAK,EACH,QAAQ;CACN,MAAM;CACN,MAAM,CAAC;EAAE,MAAM;EAAU,MAAM;EAAU,SAAS;EAAM,SAAS;EAAG,SAAS;EAAU,CAAC;CACxF,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,YAAY,EACV,QAAQ;GAAE,MAAM;GAAO,OAAO;GAAG,EAClC;EACF;CACF,EACF,EACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { n as NativeTypeNormalizer, t as DefaultNormalizer } from "./verify-sql-schema-BBhkqEDo.mjs";
|
|
2
|
+
import { ControlAdapterInstance, ControlDriverInstance } from "@prisma-next/framework-components/control";
|
|
3
|
+
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
4
|
+
|
|
5
|
+
//#region src/core/control-adapter.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* SQL control adapter interface for control-plane operations.
|
|
9
|
+
* Implemented by target-specific adapters (e.g., Postgres, MySQL).
|
|
10
|
+
*
|
|
11
|
+
* @template TTarget - The target ID (e.g., 'postgres', 'mysql')
|
|
12
|
+
*/
|
|
13
|
+
interface SqlControlAdapter<TTarget extends string = string> extends ControlAdapterInstance<'sql', TTarget> {
|
|
14
|
+
/**
|
|
15
|
+
* Introspects a database schema and returns a raw SqlSchemaIR.
|
|
16
|
+
*
|
|
17
|
+
* This is a pure schema discovery operation that queries the database catalog
|
|
18
|
+
* and returns the schema structure without type mapping or contract enrichment.
|
|
19
|
+
* Type mapping and enrichment are handled separately by enrichment helpers.
|
|
20
|
+
*
|
|
21
|
+
* @param driver - ControlDriverInstance instance for executing queries (target-specific)
|
|
22
|
+
* @param contract - Optional contract for contract-guided introspection (filtering, optimization)
|
|
23
|
+
* @param schema - Schema name to introspect (defaults to 'public')
|
|
24
|
+
* @returns Promise resolving to SqlSchemaIR representing the live database schema
|
|
25
|
+
*/
|
|
26
|
+
introspect(driver: ControlDriverInstance<'sql', TTarget>, contract?: unknown, schema?: string): Promise<SqlSchemaIR>;
|
|
27
|
+
/**
|
|
28
|
+
* Optional target-specific normalizer for raw database default expressions.
|
|
29
|
+
* When provided, schema defaults (raw strings) are normalized before comparison
|
|
30
|
+
* with contract defaults (ColumnDefault objects) during schema verification.
|
|
31
|
+
*/
|
|
32
|
+
readonly normalizeDefault?: DefaultNormalizer;
|
|
33
|
+
/**
|
|
34
|
+
* Optional target-specific normalizer for schema native type names.
|
|
35
|
+
* When provided, schema native types (from introspection) are normalized
|
|
36
|
+
* before comparison with contract native types during schema verification.
|
|
37
|
+
*/
|
|
38
|
+
readonly normalizeNativeType?: NativeTypeNormalizer;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* SQL control adapter descriptor interface.
|
|
42
|
+
* Provides a factory method to create control adapter instances.
|
|
43
|
+
*
|
|
44
|
+
* @template TTarget - The target ID (e.g., 'postgres', 'mysql')
|
|
45
|
+
*/
|
|
46
|
+
interface SqlControlAdapterDescriptor<TTarget extends string = string> {
|
|
47
|
+
/**
|
|
48
|
+
* Creates a SQL control adapter instance for control-plane operations.
|
|
49
|
+
*/
|
|
50
|
+
create(): SqlControlAdapter<TTarget>;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { type SqlControlAdapter, type SqlControlAdapterDescriptor };
|
|
54
|
+
//# sourceMappingURL=control-adapter.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-adapter.d.mts","names":[],"sources":["../src/core/control-adapter.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAaA;;;;AAkBa,UAlBI,iBAkBJ,CAAA,gBAAA,MAAA,GAAA,MAAA,CAAA,SAjBH,sBAiBG,CAAA,KAAA,EAjB2B,OAiB3B,CAAA,CAAA;EAAR;;;;;AAuBL;;;;;;;qBA1BY,6BAA6B,gDAGpC,QAAQ;;;;;;8BAOiB;;;;;;iCAOG;;;;;;;;UAShB;;;;YAIL,kBAAkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|