@prisma-next/sql-contract 0.3.0-dev.13 → 0.3.0-dev.130
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 +84 -10
- package/dist/factories.d.mts +48 -0
- package/dist/factories.d.mts.map +1 -0
- package/dist/factories.mjs +84 -0
- package/dist/factories.mjs.map +1 -0
- package/dist/pack-types.d.mts +13 -0
- package/dist/pack-types.d.mts.map +1 -0
- package/dist/pack-types.mjs +1 -0
- package/dist/types-CB821Pqa.d.mts +197 -0
- package/dist/types-CB821Pqa.d.mts.map +1 -0
- package/dist/types-DRR5stkj.mjs +13 -0
- package/dist/types-DRR5stkj.mjs.map +1 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +3 -0
- package/dist/validate.d.mts +11 -0
- package/dist/validate.d.mts.map +1 -0
- package/dist/validate.mjs +437 -0
- package/dist/validate.mjs.map +1 -0
- package/dist/validators-CNxeypbZ.mjs +234 -0
- package/dist/validators-CNxeypbZ.mjs.map +1 -0
- package/dist/validators.d.mts +71 -0
- package/dist/validators.d.mts.map +1 -0
- package/dist/validators.mjs +3 -0
- package/package.json +21 -25
- package/src/construct.ts +181 -0
- package/src/exports/types.ts +21 -0
- package/src/exports/validate.ts +6 -0
- package/src/exports/validators.ts +1 -1
- package/src/factories.ts +41 -8
- package/src/index.ts +1 -0
- package/src/types.ts +176 -9
- package/src/validate.ts +560 -0
- package/src/validators.ts +184 -18
- package/dist/exports/factories.d.ts +0 -2
- package/dist/exports/factories.d.ts.map +0 -1
- package/dist/exports/factories.js +0 -83
- package/dist/exports/factories.js.map +0 -1
- package/dist/exports/pack-types.d.ts +0 -2
- package/dist/exports/pack-types.d.ts.map +0 -1
- package/dist/exports/pack-types.js +0 -1
- package/dist/exports/pack-types.js.map +0 -1
- package/dist/exports/types.d.ts +0 -2
- package/dist/exports/types.d.ts.map +0 -1
- package/dist/exports/types.js +0 -1
- package/dist/exports/types.js.map +0 -1
- package/dist/exports/validators.d.ts +0 -2
- package/dist/exports/validators.d.ts.map +0 -1
- package/dist/exports/validators.js +0 -96
- package/dist/exports/validators.js.map +0 -1
- package/dist/factories.d.ts +0 -38
- package/dist/factories.d.ts.map +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/pack-types.d.ts +0 -10
- package/dist/pack-types.d.ts.map +0 -1
- package/dist/types.d.ts +0 -68
- package/dist/types.d.ts.map +0 -1
- package/dist/validators.d.ts +0 -35
- package/dist/validators.d.ts.map +0 -1
package/dist/types.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { ContractBase } from '@prisma-next/contract/types';
|
|
2
|
-
export type StorageColumn = {
|
|
3
|
-
readonly nativeType: string;
|
|
4
|
-
readonly codecId: string;
|
|
5
|
-
readonly nullable: boolean;
|
|
6
|
-
};
|
|
7
|
-
export type PrimaryKey = {
|
|
8
|
-
readonly columns: readonly string[];
|
|
9
|
-
readonly name?: string;
|
|
10
|
-
};
|
|
11
|
-
export type UniqueConstraint = {
|
|
12
|
-
readonly columns: readonly string[];
|
|
13
|
-
readonly name?: string;
|
|
14
|
-
};
|
|
15
|
-
export type Index = {
|
|
16
|
-
readonly columns: readonly string[];
|
|
17
|
-
readonly name?: string;
|
|
18
|
-
};
|
|
19
|
-
export type ForeignKeyReferences = {
|
|
20
|
-
readonly table: string;
|
|
21
|
-
readonly columns: readonly string[];
|
|
22
|
-
};
|
|
23
|
-
export type ForeignKey = {
|
|
24
|
-
readonly columns: readonly string[];
|
|
25
|
-
readonly references: ForeignKeyReferences;
|
|
26
|
-
readonly name?: string;
|
|
27
|
-
};
|
|
28
|
-
export type StorageTable = {
|
|
29
|
-
readonly columns: Record<string, StorageColumn>;
|
|
30
|
-
readonly primaryKey?: PrimaryKey;
|
|
31
|
-
readonly uniques: ReadonlyArray<UniqueConstraint>;
|
|
32
|
-
readonly indexes: ReadonlyArray<Index>;
|
|
33
|
-
readonly foreignKeys: ReadonlyArray<ForeignKey>;
|
|
34
|
-
};
|
|
35
|
-
export type SqlStorage = {
|
|
36
|
-
readonly tables: Record<string, StorageTable>;
|
|
37
|
-
};
|
|
38
|
-
export type ModelField = {
|
|
39
|
-
readonly column: string;
|
|
40
|
-
};
|
|
41
|
-
export type ModelStorage = {
|
|
42
|
-
readonly table: string;
|
|
43
|
-
};
|
|
44
|
-
export type ModelDefinition = {
|
|
45
|
-
readonly storage: ModelStorage;
|
|
46
|
-
readonly fields: Record<string, ModelField>;
|
|
47
|
-
readonly relations: Record<string, unknown>;
|
|
48
|
-
};
|
|
49
|
-
export type SqlMappings = {
|
|
50
|
-
readonly modelToTable?: Record<string, string>;
|
|
51
|
-
readonly tableToModel?: Record<string, string>;
|
|
52
|
-
readonly fieldToColumn?: Record<string, Record<string, string>>;
|
|
53
|
-
readonly columnToField?: Record<string, Record<string, string>>;
|
|
54
|
-
readonly codecTypes: Record<string, {
|
|
55
|
-
readonly output: unknown;
|
|
56
|
-
}>;
|
|
57
|
-
readonly operationTypes: Record<string, Record<string, unknown>>;
|
|
58
|
-
};
|
|
59
|
-
export type SqlContract<S extends SqlStorage = SqlStorage, M extends Record<string, unknown> = Record<string, unknown>, R extends Record<string, unknown> = Record<string, unknown>, Map extends SqlMappings = SqlMappings> = ContractBase & {
|
|
60
|
-
readonly targetFamily: string;
|
|
61
|
-
readonly storage: S;
|
|
62
|
-
readonly models: M;
|
|
63
|
-
readonly relations: R;
|
|
64
|
-
readonly mappings: Map;
|
|
65
|
-
};
|
|
66
|
-
export type ExtractCodecTypes<TContract extends SqlContract<SqlStorage>> = TContract['mappings']['codecTypes'];
|
|
67
|
-
export type ExtractOperationTypes<TContract extends SqlContract<SqlStorage>> = TContract['mappings']['operationTypes'];
|
|
68
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.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E,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAClE,CAAC;AAEF,MAAM,MAAM,WAAW,CACrB,CAAC,SAAS,UAAU,GAAG,UAAU,EACjC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,GAAG,SAAS,WAAW,GAAG,WAAW,IACnC,YAAY,GAAG;IACjB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,SAAS,SAAS,WAAW,CAAC,UAAU,CAAC,IACrE,SAAS,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC;AAEtC,MAAM,MAAM,qBAAqB,CAAC,SAAS,SAAS,WAAW,CAAC,UAAU,CAAC,IACzE,SAAS,CAAC,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAAC"}
|
package/dist/validators.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { ModelDefinition, SqlContract, SqlStorage } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Validates the structural shape of SqlStorage using Arktype.
|
|
4
|
-
*
|
|
5
|
-
* @param value - The storage value to validate
|
|
6
|
-
* @returns The validated storage if structure is valid
|
|
7
|
-
* @throws Error if the storage structure is invalid
|
|
8
|
-
*/
|
|
9
|
-
export declare function validateStorage(value: unknown): SqlStorage;
|
|
10
|
-
/**
|
|
11
|
-
* Validates the structural shape of ModelDefinition using Arktype.
|
|
12
|
-
*
|
|
13
|
-
* @param value - The model value to validate
|
|
14
|
-
* @returns The validated model if structure is valid
|
|
15
|
-
* @throws Error if the model structure is invalid
|
|
16
|
-
*/
|
|
17
|
-
export declare function validateModel(value: unknown): ModelDefinition;
|
|
18
|
-
/**
|
|
19
|
-
* Validates the structural shape of a SqlContract using Arktype.
|
|
20
|
-
*
|
|
21
|
-
* **Responsibility: Validation Only**
|
|
22
|
-
* This function validates that the contract has the correct structure and types.
|
|
23
|
-
* It does NOT normalize the contract - normalization must happen in the contract builder.
|
|
24
|
-
*
|
|
25
|
-
* The contract passed to this function must already be normalized (all required fields present).
|
|
26
|
-
* If normalization is needed, it should be done by the contract builder before calling this function.
|
|
27
|
-
*
|
|
28
|
-
* This ensures all required fields are present and have the correct types.
|
|
29
|
-
*
|
|
30
|
-
* @param value - The contract value to validate (typically from a JSON import)
|
|
31
|
-
* @returns The validated contract if structure is valid
|
|
32
|
-
* @throws Error if the contract structure is invalid
|
|
33
|
-
*/
|
|
34
|
-
export declare function validateSqlContract<T extends SqlContract<SqlStorage>>(value: unknown): T;
|
|
35
|
-
//# sourceMappingURL=validators.d.ts.map
|
package/dist/validators.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,eAAe,EAIf,WAAW,EACX,UAAU,EAIX,MAAM,SAAS,CAAC;AA0EjB;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAO1D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAO7D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,WAAW,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAkBxF"}
|