@prisma-next/sql-contract-ts 0.3.0-pr.99.6 → 0.4.0-dev.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/LICENSE +201 -0
- package/README.md +206 -73
- 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/dist/contract-builder.d.mts +769 -0
- package/dist/contract-builder.d.mts.map +1 -0
- package/dist/contract-builder.mjs +1288 -0
- package/dist/contract-builder.mjs.map +1 -0
- package/package.json +19 -16
- package/schemas/data-contract-sql-v1.json +189 -23
- package/src/authoring-helper-runtime.ts +139 -0
- package/src/authoring-type-utils.ts +168 -0
- package/src/build-contract.ts +463 -0
- package/src/composed-authoring-helpers.ts +256 -0
- package/src/config-types.ts +11 -0
- package/src/contract-builder.ts +232 -551
- package/src/contract-definition.ts +103 -0
- package/src/contract-dsl.ts +1492 -0
- package/src/contract-lowering.ts +703 -0
- package/src/contract-types.ts +534 -0
- package/src/contract-warnings.ts +242 -0
- package/src/exports/config-types.ts +2 -0
- package/src/exports/contract-builder.ts +23 -2
- package/dist/chunk-HTNUNGA2.js +0 -346
- package/dist/chunk-HTNUNGA2.js.map +0 -1
- package/dist/contract-builder.d.ts +0 -101
- package/dist/contract-builder.d.ts.map +0 -1
- package/dist/contract.d.ts +0 -50
- package/dist/contract.d.ts.map +0 -1
- package/dist/exports/contract-builder.d.ts +0 -3
- package/dist/exports/contract-builder.d.ts.map +0 -1
- package/dist/exports/contract-builder.js +0 -231
- package/dist/exports/contract-builder.js.map +0 -1
- package/dist/exports/contract.d.ts +0 -2
- package/dist/exports/contract.d.ts.map +0 -1
- package/dist/exports/contract.js +0 -9
- package/dist/exports/contract.js.map +0 -1
- package/src/contract.ts +0 -582
- package/src/exports/contract.ts +0 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ColumnDefault, ExecutionMutationDefaultValue } from '@prisma-next/contract/types';
|
|
2
|
+
import type {
|
|
3
|
+
ColumnTypeDescriptor,
|
|
4
|
+
ForeignKeyDefaultsState,
|
|
5
|
+
} from '@prisma-next/contract-authoring';
|
|
6
|
+
import type { ExtensionPackRef, TargetPackRef } from '@prisma-next/framework-components/components';
|
|
7
|
+
import type { ReferentialAction, StorageTypeInstance } from '@prisma-next/sql-contract/types';
|
|
8
|
+
|
|
9
|
+
export interface FieldNode {
|
|
10
|
+
readonly fieldName: string;
|
|
11
|
+
readonly columnName: string;
|
|
12
|
+
readonly descriptor: ColumnTypeDescriptor;
|
|
13
|
+
readonly nullable: boolean;
|
|
14
|
+
readonly default?: ColumnDefault;
|
|
15
|
+
readonly executionDefault?: ExecutionMutationDefaultValue;
|
|
16
|
+
readonly many?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface PrimaryKeyNode {
|
|
20
|
+
readonly columns: readonly string[];
|
|
21
|
+
readonly name?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface UniqueConstraintNode {
|
|
25
|
+
readonly columns: readonly string[];
|
|
26
|
+
readonly name?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface IndexNode {
|
|
30
|
+
readonly columns: readonly string[];
|
|
31
|
+
readonly name?: string;
|
|
32
|
+
readonly using?: string;
|
|
33
|
+
readonly config?: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ForeignKeyNode {
|
|
37
|
+
readonly columns: readonly string[];
|
|
38
|
+
readonly references: {
|
|
39
|
+
readonly model: string;
|
|
40
|
+
readonly table: string;
|
|
41
|
+
readonly columns: readonly string[];
|
|
42
|
+
};
|
|
43
|
+
readonly name?: string;
|
|
44
|
+
readonly onDelete?: ReferentialAction;
|
|
45
|
+
readonly onUpdate?: ReferentialAction;
|
|
46
|
+
readonly constraint?: boolean;
|
|
47
|
+
readonly index?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface RelationNode {
|
|
51
|
+
readonly fieldName: string;
|
|
52
|
+
readonly toModel: string;
|
|
53
|
+
readonly toTable: string;
|
|
54
|
+
readonly cardinality: '1:1' | '1:N' | 'N:1' | 'N:M';
|
|
55
|
+
readonly on: {
|
|
56
|
+
readonly parentTable: string;
|
|
57
|
+
readonly parentColumns: readonly string[];
|
|
58
|
+
readonly childTable: string;
|
|
59
|
+
readonly childColumns: readonly string[];
|
|
60
|
+
};
|
|
61
|
+
readonly through?: {
|
|
62
|
+
readonly table: string;
|
|
63
|
+
readonly parentColumns: readonly string[];
|
|
64
|
+
readonly childColumns: readonly string[];
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface ValueObjectFieldNode {
|
|
69
|
+
readonly fieldName: string;
|
|
70
|
+
readonly columnName: string;
|
|
71
|
+
readonly valueObjectName: string;
|
|
72
|
+
readonly nullable: boolean;
|
|
73
|
+
readonly default?: ColumnDefault;
|
|
74
|
+
readonly executionDefault?: ExecutionMutationDefaultValue;
|
|
75
|
+
readonly many?: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ValueObjectNode {
|
|
79
|
+
readonly name: string;
|
|
80
|
+
readonly fields: readonly (FieldNode | ValueObjectFieldNode)[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface ModelNode {
|
|
84
|
+
readonly modelName: string;
|
|
85
|
+
readonly tableName: string;
|
|
86
|
+
readonly fields: readonly (FieldNode | ValueObjectFieldNode)[];
|
|
87
|
+
readonly id?: PrimaryKeyNode;
|
|
88
|
+
readonly uniques?: readonly UniqueConstraintNode[];
|
|
89
|
+
readonly indexes?: readonly IndexNode[];
|
|
90
|
+
readonly foreignKeys?: readonly ForeignKeyNode[];
|
|
91
|
+
readonly relations?: readonly RelationNode[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ContractDefinition {
|
|
95
|
+
readonly target: TargetPackRef<'sql', string>;
|
|
96
|
+
readonly extensionPacks?: Record<string, ExtensionPackRef<'sql', string>>;
|
|
97
|
+
readonly capabilities?: Record<string, Record<string, boolean>>;
|
|
98
|
+
readonly storageHash?: string;
|
|
99
|
+
readonly foreignKeyDefaults?: ForeignKeyDefaultsState;
|
|
100
|
+
readonly storageTypes?: Record<string, StorageTypeInstance>;
|
|
101
|
+
readonly models: readonly ModelNode[];
|
|
102
|
+
readonly valueObjects?: readonly ValueObjectNode[];
|
|
103
|
+
}
|