@prisma-next/sql-contract-ts 0.3.0-dev.45 → 0.3.0-dev.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dist/config-types.d.mts +8 -0
- package/dist/config-types.d.mts.map +1 -0
- package/dist/config-types.mjs +14 -0
- package/dist/config-types.mjs.map +1 -0
- package/package.json +10 -5
- package/src/config-types.ts +11 -0
- package/src/exports/config-types.ts +2 -0
package/README.md
CHANGED
|
@@ -36,6 +36,14 @@ This package was created in Phase 1 and refactored in Phase 2. It now composes t
|
|
|
36
36
|
- **SQL-specific types**: Provides SQL-specific contract types (`SqlContract`, `SqlStorage`, `SqlMappings`) from `@prisma-next/sql-contract/types`
|
|
37
37
|
- **SQL-specific build()**: Implements SQL-specific `build()` method in `SqlContractBuilder` that constructs `SqlContract` instances with SQL-specific structure (uniques, indexes, foreignKeys arrays)
|
|
38
38
|
|
|
39
|
+
```mermaid
|
|
40
|
+
flowchart LR
|
|
41
|
+
builderInput[TS builder calls] --> sqlContractTs[@prisma-next/sql-contract-ts]
|
|
42
|
+
sqlContractTs --> authoringCore[@prisma-next/contract-authoring]
|
|
43
|
+
sqlContractTs --> sqlTypes[@prisma-next/sql-contract/types]
|
|
44
|
+
sqlContractTs --> contractIR[SQL ContractIR]
|
|
45
|
+
```
|
|
46
|
+
|
|
39
47
|
This package is part of the package layering architecture:
|
|
40
48
|
- **Location**: `packages/2-sql/2-authoring/contract-ts` (SQL family namespace)
|
|
41
49
|
- **Ring**: SQL family namespace (can import from core, authoring, targets, and other SQL family packages)
|
|
@@ -43,6 +51,7 @@ This package is part of the package layering architecture:
|
|
|
43
51
|
## Exports
|
|
44
52
|
|
|
45
53
|
- `./contract-builder` - Contract builder API (`defineContract`, `ColumnBuilder`)
|
|
54
|
+
- `./config-types` - TypeScript contract config helper (`typescriptContract`)
|
|
46
55
|
- `./schema-sql` - SQL contract JSON schema (`data-contract-sql-v1.json`)
|
|
47
56
|
|
|
48
57
|
## Usage
|
|
@@ -124,10 +133,26 @@ import type { Contract } from './contract.d';
|
|
|
124
133
|
const contract = validateContract<Contract>(contractJson);
|
|
125
134
|
```
|
|
126
135
|
|
|
136
|
+
### Config Helper
|
|
137
|
+
|
|
138
|
+
Use `typescriptContract` from this package when wiring TS-authored contracts in `prisma-next.config.ts`.
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { defineConfig } from '@prisma-next/cli/config-types';
|
|
142
|
+
import { typescriptContract } from '@prisma-next/sql-contract-ts/config-types';
|
|
143
|
+
import { contract } from './src/prisma/contract';
|
|
144
|
+
|
|
145
|
+
export default defineConfig({
|
|
146
|
+
// ...
|
|
147
|
+
contract: typescriptContract(contract, 'src/prisma/contract.json'),
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
127
151
|
## Dependencies
|
|
128
152
|
|
|
129
153
|
- **`@prisma-next/contract-authoring`** - Target-agnostic builder core (builder state types, builder classes, type helpers)
|
|
130
154
|
- **`@prisma-next/contract`** - Core contract types (`ContractBase`)
|
|
155
|
+
- **`@prisma-next/core-control-plane`** - Contract config types used by `typescriptContract`
|
|
131
156
|
- **`@prisma-next/sql-contract`** - SQL contract types (`SqlContract`, `SqlStorage`, `SqlMappings`)
|
|
132
157
|
- **`arktype`** - Runtime validation
|
|
133
158
|
- **`ts-toolbelt`** - Type utilities
|
|
@@ -145,4 +170,6 @@ Integration tests that depend on both `sql-contract-ts` and `sql-query` are loca
|
|
|
145
170
|
## See Also
|
|
146
171
|
|
|
147
172
|
- `@prisma-next/contract-authoring` - Target-agnostic builder core that this package composes
|
|
173
|
+
- `@prisma-next/sql-contract-psl` - PSL parser-output to SQL `ContractIR` interpreter for provider-based flows
|
|
174
|
+
- `@prisma-next/sql-contract-psl/provider` - SQL PSL-first `prismaContract()` helper (read -> parse -> interpret)
|
|
148
175
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ContractConfig, ContractConfig as ContractConfig$1 } from "@prisma-next/core-control-plane/config-types";
|
|
2
|
+
import { ContractIR } from "@prisma-next/contract/ir";
|
|
3
|
+
|
|
4
|
+
//#region src/config-types.d.ts
|
|
5
|
+
declare function typescriptContract(contractIR: ContractIR, output?: string): ContractConfig$1;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { type ContractConfig, typescriptContract };
|
|
8
|
+
//# sourceMappingURL=config-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"sourcesContent":[],"mappings":";;;;iBAKgB,kBAAA,aAA+B,8BAA8B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ifDefined } from "@prisma-next/utils/defined";
|
|
2
|
+
import { ok } from "@prisma-next/utils/result";
|
|
3
|
+
|
|
4
|
+
//#region src/config-types.ts
|
|
5
|
+
function typescriptContract(contractIR, output) {
|
|
6
|
+
return {
|
|
7
|
+
source: async () => ok(contractIR),
|
|
8
|
+
...ifDefined("output", output)
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { typescriptContract };
|
|
14
|
+
//# sourceMappingURL=config-types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-types.mjs","names":[],"sources":["../src/config-types.ts"],"sourcesContent":["import type { ContractIR } from '@prisma-next/contract/ir';\nimport type { ContractConfig } from '@prisma-next/core-control-plane/config-types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { ok } from '@prisma-next/utils/result';\n\nexport function typescriptContract(contractIR: ContractIR, output?: string): ContractConfig {\n return {\n source: async () => ok(contractIR),\n ...ifDefined('output', output),\n };\n}\n"],"mappings":";;;;AAKA,SAAgB,mBAAmB,YAAwB,QAAiC;AAC1F,QAAO;EACL,QAAQ,YAAY,GAAG,WAAW;EAClC,GAAG,UAAU,UAAU,OAAO;EAC/B"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/sql-contract-ts",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.47",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "SQL-specific TypeScript contract authoring surface for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"arktype": "^2.1.25",
|
|
9
9
|
"ts-toolbelt": "^9.6.0",
|
|
10
|
-
"@prisma-next/contract": "0.3.0-dev.
|
|
11
|
-
"@prisma-next/
|
|
12
|
-
"@prisma-next/sql-contract": "0.3.0-dev.
|
|
13
|
-
"@prisma-next/utils": "0.3.0-dev.
|
|
10
|
+
"@prisma-next/contract-authoring": "0.3.0-dev.47",
|
|
11
|
+
"@prisma-next/core-control-plane": "0.3.0-dev.47",
|
|
12
|
+
"@prisma-next/sql-contract": "0.3.0-dev.47",
|
|
13
|
+
"@prisma-next/utils": "0.3.0-dev.47",
|
|
14
|
+
"@prisma-next/contract": "0.3.0-dev.47"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@types/pg": "8.16.0",
|
|
@@ -36,6 +37,10 @@
|
|
|
36
37
|
"types": "./dist/contract-builder.d.mts",
|
|
37
38
|
"import": "./dist/contract-builder.mjs"
|
|
38
39
|
},
|
|
40
|
+
"./config-types": {
|
|
41
|
+
"types": "./dist/config-types.d.mts",
|
|
42
|
+
"import": "./dist/config-types.mjs"
|
|
43
|
+
},
|
|
39
44
|
"./schema-sql": "./schemas/data-contract-sql-v1.json",
|
|
40
45
|
"./package.json": "./package.json"
|
|
41
46
|
},
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ContractIR } from '@prisma-next/contract/ir';
|
|
2
|
+
import type { ContractConfig } from '@prisma-next/core-control-plane/config-types';
|
|
3
|
+
import { ifDefined } from '@prisma-next/utils/defined';
|
|
4
|
+
import { ok } from '@prisma-next/utils/result';
|
|
5
|
+
|
|
6
|
+
export function typescriptContract(contractIR: ContractIR, output?: string): ContractConfig {
|
|
7
|
+
return {
|
|
8
|
+
source: async () => ok(contractIR),
|
|
9
|
+
...ifDefined('output', output),
|
|
10
|
+
};
|
|
11
|
+
}
|