@deessejs/collections 0.0.15 → 0.0.16
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/dist/dsl/types.d.ts +1 -0
- package/dist/dsl/types.js +2 -0
- package/dist/fields/field.d.ts +5 -0
- package/dist/fields/field.js +72 -2
- package/dist/fields/types.d.ts +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type DataKind = 'integer' | 'smallint';
|
package/dist/fields/field.d.ts
CHANGED
|
@@ -2,3 +2,8 @@ import z from "zod";
|
|
|
2
2
|
import { Field, FieldConfig, FieldTypeConfig, FieldTypeFinal } from "./types";
|
|
3
3
|
export declare const fieldType: <TOutput, TParams extends z.ZodType>(config: FieldTypeConfig<TParams>) => (params: z.infer<TParams>) => FieldTypeFinal<TParams, TOutput>;
|
|
4
4
|
export declare const field: <TType extends FieldTypeFinal>(config: FieldConfig<TType>) => Field<TType>;
|
|
5
|
+
export declare const unique: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
|
|
6
|
+
export declare const required: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
|
|
7
|
+
export declare const optional: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
|
|
8
|
+
export declare const nullable: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
|
|
9
|
+
export declare const notNullable: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
|
package/dist/fields/field.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.field = exports.fieldType = void 0;
|
|
3
|
+
exports.notNullable = exports.nullable = exports.optional = exports.required = exports.unique = exports.field = exports.fieldType = void 0;
|
|
4
4
|
const fieldType = (config) => (params) => {
|
|
5
5
|
const validated = config.schema ? config.schema.parse(params) : params;
|
|
6
6
|
return {
|
|
7
7
|
kind: config.dsl.kind,
|
|
8
8
|
params: validated,
|
|
9
|
-
dsl:
|
|
9
|
+
dsl: {
|
|
10
|
+
kind: config.dsl.kind,
|
|
11
|
+
isPrimary: false,
|
|
12
|
+
isUnique: false,
|
|
13
|
+
canBeNull: true,
|
|
14
|
+
},
|
|
10
15
|
admin: config.admin,
|
|
11
16
|
};
|
|
12
17
|
};
|
|
@@ -27,3 +32,68 @@ const field = (config) => {
|
|
|
27
32
|
};
|
|
28
33
|
};
|
|
29
34
|
exports.field = field;
|
|
35
|
+
const unique = (field) => {
|
|
36
|
+
return {
|
|
37
|
+
...field,
|
|
38
|
+
type: {
|
|
39
|
+
...field.type,
|
|
40
|
+
dsl: {
|
|
41
|
+
...field.type.dsl,
|
|
42
|
+
isUnique: true,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
exports.unique = unique;
|
|
48
|
+
const required = (field) => {
|
|
49
|
+
return {
|
|
50
|
+
...field,
|
|
51
|
+
type: {
|
|
52
|
+
...field.type,
|
|
53
|
+
dsl: {
|
|
54
|
+
...field.type.dsl,
|
|
55
|
+
canBeNull: false,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
exports.required = required;
|
|
61
|
+
const optional = (field) => {
|
|
62
|
+
return {
|
|
63
|
+
...field,
|
|
64
|
+
type: {
|
|
65
|
+
...field.type,
|
|
66
|
+
dsl: {
|
|
67
|
+
...field.type.dsl,
|
|
68
|
+
canBeNull: true,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
exports.optional = optional;
|
|
74
|
+
const nullable = (field) => {
|
|
75
|
+
return {
|
|
76
|
+
...field,
|
|
77
|
+
type: {
|
|
78
|
+
...field.type,
|
|
79
|
+
dsl: {
|
|
80
|
+
...field.type.dsl,
|
|
81
|
+
canBeNull: true,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
exports.nullable = nullable;
|
|
87
|
+
const notNullable = (field) => {
|
|
88
|
+
return {
|
|
89
|
+
...field,
|
|
90
|
+
type: {
|
|
91
|
+
...field.type,
|
|
92
|
+
dsl: {
|
|
93
|
+
...field.type.dsl,
|
|
94
|
+
canBeNull: false,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
exports.notNullable = notNullable;
|
package/dist/fields/types.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export type FieldTypeConfig<TParams extends z.ZodType = z.ZodType> = {
|
|
|
3
3
|
schema?: TParams;
|
|
4
4
|
dsl: {
|
|
5
5
|
kind: string;
|
|
6
|
-
config?: Record<string, any>;
|
|
7
6
|
};
|
|
8
7
|
admin: {
|
|
9
8
|
component: any;
|
|
@@ -14,7 +13,9 @@ export type FieldTypeFinal<TParams extends z.ZodType = z.ZodType, TOutput = any>
|
|
|
14
13
|
params: z.infer<TParams>;
|
|
15
14
|
dsl: {
|
|
16
15
|
kind: string;
|
|
17
|
-
|
|
16
|
+
isPrimary: boolean;
|
|
17
|
+
isUnique: boolean;
|
|
18
|
+
canBeNull: boolean;
|
|
18
19
|
};
|
|
19
20
|
admin: {
|
|
20
21
|
component: any;
|