@postxl/schema 0.0.2
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 +50 -0
- package/README.md +320 -0
- package/dist/enum/enum.brands.d.ts +11 -0
- package/dist/enum/enum.brands.js +19 -0
- package/dist/enum/enum.d.ts +49 -0
- package/dist/enum/enum.defaults.d.ts +41 -0
- package/dist/enum/enum.defaults.js +105 -0
- package/dist/enum/enum.js +6 -0
- package/dist/enum/enum.json-decoder.d.ts +61 -0
- package/dist/enum/enum.json-decoder.js +51 -0
- package/dist/enum/enum.transformer.d.ts +12 -0
- package/dist/enum/enum.transformer.js +76 -0
- package/dist/enum/enum.types.d.ts +14 -0
- package/dist/enum/enum.types.js +2 -0
- package/dist/enum/index.d.ts +6 -0
- package/dist/enum/index.js +22 -0
- package/dist/field/defaults.d.ts +12 -0
- package/dist/field/defaults.js +78 -0
- package/dist/field/discriminated-union.d.ts +125 -0
- package/dist/field/discriminated-union.js +207 -0
- package/dist/field/enum.d.ts +65 -0
- package/dist/field/enum.js +111 -0
- package/dist/field/field.d.ts +483 -0
- package/dist/field/field.js +68 -0
- package/dist/field/id.d.ts +152 -0
- package/dist/field/id.js +104 -0
- package/dist/field/index.d.ts +11 -0
- package/dist/field/index.js +27 -0
- package/dist/field/relation.d.ts +88 -0
- package/dist/field/relation.js +138 -0
- package/dist/field/scalar.d.ts +179 -0
- package/dist/field/scalar.js +197 -0
- package/dist/field/shared/brands.d.ts +38 -0
- package/dist/field/shared/brands.js +109 -0
- package/dist/field/shared/decoders.d.ts +17 -0
- package/dist/field/shared/decoders.js +88 -0
- package/dist/field/shared/seed.d.ts +32 -0
- package/dist/field/shared/seed.js +63 -0
- package/dist/field/shared/types.d.ts +73 -0
- package/dist/field/shared/types.js +2 -0
- package/dist/field/shared/utils.d.ts +26 -0
- package/dist/field/shared/utils.js +52 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +25 -0
- package/dist/model/index.d.ts +5 -0
- package/dist/model/index.js +21 -0
- package/dist/model/model.brands.d.ts +7 -0
- package/dist/model/model.brands.js +10 -0
- package/dist/model/model.defaults.d.ts +28 -0
- package/dist/model/model.defaults.js +304 -0
- package/dist/model/model.json-decoder.d.ts +94 -0
- package/dist/model/model.json-decoder.js +107 -0
- package/dist/model/model.transformer.d.ts +93 -0
- package/dist/model/model.transformer.js +183 -0
- package/dist/model/model.types.d.ts +37 -0
- package/dist/model/model.types.js +2 -0
- package/dist/project-schema/project-schema.brands.d.ts +10 -0
- package/dist/project-schema/project-schema.brands.js +17 -0
- package/dist/project-schema/project-schema.defaults.d.ts +16 -0
- package/dist/project-schema/project-schema.defaults.js +53 -0
- package/dist/project-schema/project-schema.json-decoder.d.ts +285 -0
- package/dist/project-schema/project-schema.json-decoder.js +145 -0
- package/dist/project-schema/project-schema.transformer.d.ts +284 -0
- package/dist/project-schema/project-schema.transformer.js +444 -0
- package/dist/project-schema/project-schema.types.d.ts +77 -0
- package/dist/project-schema/project-schema.types.js +2 -0
- package/dist/samples/la.schema.json +2055 -0
- package/dist/samples/mca.schema.json +830 -0
- package/dist/samples/ring.schema.json +879 -0
- package/dist/samples/sample-schemas.d.ts +1896 -0
- package/dist/samples/sample-schemas.js +20 -0
- package/dist/samples/simple.schema.json +250 -0
- package/dist/samples/subex.schema.json +1188 -0
- package/dist/samples/usp-msm.schema.json +2515 -0
- package/package.json +57 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const zSchemaName: z.ZodString;
|
|
3
|
+
export declare const zProjectSchemaJSON: z.ZodEffects<z.ZodObject<{
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
slug: z.ZodString;
|
|
6
|
+
description: z.ZodOptional<z.ZodString>;
|
|
7
|
+
projectType: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
8
|
+
kind: z.ZodLiteral<"standalone">;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
kind: "standalone";
|
|
11
|
+
}, {
|
|
12
|
+
kind: "standalone";
|
|
13
|
+
}>, z.ZodObject<{
|
|
14
|
+
kind: z.ZodLiteral<"workspace">;
|
|
15
|
+
projectDirectory: z.ZodString;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
kind: "workspace";
|
|
18
|
+
projectDirectory: string;
|
|
19
|
+
}, {
|
|
20
|
+
kind: "workspace";
|
|
21
|
+
projectDirectory: string;
|
|
22
|
+
}>]>>;
|
|
23
|
+
version: z.ZodOptional<z.ZodString>;
|
|
24
|
+
schemas: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
25
|
+
defaultSchema: z.ZodOptional<z.ZodString>;
|
|
26
|
+
systemUser: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
27
|
+
standardModels: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
28
|
+
models: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
29
|
+
name: z.ZodEffects<z.ZodString, string, string>;
|
|
30
|
+
description: z.ZodOptional<z.ZodString>;
|
|
31
|
+
isReadonly: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
schema: z.ZodOptional<z.ZodString>;
|
|
33
|
+
databaseName: z.ZodOptional<z.ZodString>;
|
|
34
|
+
excelName: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
35
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
36
|
+
name: z.ZodString;
|
|
37
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
40
|
+
name: z.ZodString;
|
|
41
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
42
|
+
standardFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
43
|
+
defaultField: z.ZodOptional<z.ZodString>;
|
|
44
|
+
labelField: z.ZodOptional<z.ZodString>;
|
|
45
|
+
indexes: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodBranded<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, "PXL.FieldName">, "many">, "many">>;
|
|
46
|
+
seed: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
47
|
+
source: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
48
|
+
faker: z.ZodOptional<z.ZodObject<{
|
|
49
|
+
items: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
seed: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
seed?: number | undefined;
|
|
53
|
+
items?: number | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
seed?: number | undefined;
|
|
56
|
+
items?: number | undefined;
|
|
57
|
+
}>>;
|
|
58
|
+
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
name: string;
|
|
60
|
+
description?: string | undefined;
|
|
61
|
+
schema?: string | undefined;
|
|
62
|
+
databaseName?: string | undefined;
|
|
63
|
+
excelName?: string | undefined;
|
|
64
|
+
isReadonly?: boolean | undefined;
|
|
65
|
+
faker?: {
|
|
66
|
+
seed?: number | undefined;
|
|
67
|
+
items?: number | undefined;
|
|
68
|
+
} | undefined;
|
|
69
|
+
seed?: any[] | undefined;
|
|
70
|
+
fields?: z.objectOutputType<{
|
|
71
|
+
name: z.ZodString;
|
|
72
|
+
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
73
|
+
standardFields?: string[] | undefined;
|
|
74
|
+
defaultField?: string | undefined;
|
|
75
|
+
labelField?: string | undefined;
|
|
76
|
+
indexes?: (string & z.BRAND<"PXL.FieldName">)[][] | undefined;
|
|
77
|
+
source?: Record<string, unknown> | undefined;
|
|
78
|
+
}, {
|
|
79
|
+
name: string;
|
|
80
|
+
description?: string | undefined;
|
|
81
|
+
schema?: string | undefined;
|
|
82
|
+
databaseName?: string | undefined;
|
|
83
|
+
excelName?: string | undefined;
|
|
84
|
+
isReadonly?: boolean | undefined;
|
|
85
|
+
faker?: {
|
|
86
|
+
seed?: number | undefined;
|
|
87
|
+
items?: number | undefined;
|
|
88
|
+
} | undefined;
|
|
89
|
+
seed?: any[] | undefined;
|
|
90
|
+
fields?: z.objectInputType<{
|
|
91
|
+
name: z.ZodString;
|
|
92
|
+
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
93
|
+
standardFields?: string[] | undefined;
|
|
94
|
+
defaultField?: string | undefined;
|
|
95
|
+
labelField?: string | undefined;
|
|
96
|
+
indexes?: string[][] | undefined;
|
|
97
|
+
source?: Record<string, unknown> | undefined;
|
|
98
|
+
}>, {
|
|
99
|
+
name: string;
|
|
100
|
+
description?: string | undefined;
|
|
101
|
+
schema?: string | undefined;
|
|
102
|
+
databaseName?: string | undefined;
|
|
103
|
+
excelName?: string | undefined;
|
|
104
|
+
isReadonly?: boolean | undefined;
|
|
105
|
+
faker?: {
|
|
106
|
+
seed?: number | undefined;
|
|
107
|
+
items?: number | undefined;
|
|
108
|
+
} | undefined;
|
|
109
|
+
seed?: any[] | undefined;
|
|
110
|
+
fields?: z.objectOutputType<{
|
|
111
|
+
name: z.ZodString;
|
|
112
|
+
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
113
|
+
standardFields?: string[] | undefined;
|
|
114
|
+
defaultField?: string | undefined;
|
|
115
|
+
labelField?: string | undefined;
|
|
116
|
+
indexes?: (string & z.BRAND<"PXL.FieldName">)[][] | undefined;
|
|
117
|
+
source?: Record<string, unknown> | undefined;
|
|
118
|
+
}, unknown>, "many">>;
|
|
119
|
+
standardEnums: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
120
|
+
enums: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
121
|
+
name: z.ZodEffects<z.ZodString, string, string>;
|
|
122
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
123
|
+
schema: z.ZodOptional<z.ZodString>;
|
|
124
|
+
databaseName: z.ZodOptional<z.ZodString>;
|
|
125
|
+
members: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
126
|
+
value: z.ZodString;
|
|
127
|
+
description: z.ZodOptional<z.ZodString>;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
value: string;
|
|
130
|
+
description?: string | undefined;
|
|
131
|
+
}, {
|
|
132
|
+
value: string;
|
|
133
|
+
description?: string | undefined;
|
|
134
|
+
}>, z.ZodString]>, "many">;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
description: string;
|
|
137
|
+
name: string;
|
|
138
|
+
members: (string | {
|
|
139
|
+
value: string;
|
|
140
|
+
description?: string | undefined;
|
|
141
|
+
})[];
|
|
142
|
+
schema?: string | undefined;
|
|
143
|
+
databaseName?: string | undefined;
|
|
144
|
+
}, {
|
|
145
|
+
name: string;
|
|
146
|
+
members: (string | {
|
|
147
|
+
value: string;
|
|
148
|
+
description?: string | undefined;
|
|
149
|
+
})[];
|
|
150
|
+
description?: string | undefined;
|
|
151
|
+
schema?: string | undefined;
|
|
152
|
+
databaseName?: string | undefined;
|
|
153
|
+
}>, "many">>;
|
|
154
|
+
source: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
155
|
+
}, "strip", z.ZodTypeAny, {
|
|
156
|
+
name: string;
|
|
157
|
+
source: Record<string, unknown>;
|
|
158
|
+
slug: string;
|
|
159
|
+
description?: string | undefined;
|
|
160
|
+
version?: string | undefined;
|
|
161
|
+
projectType?: {
|
|
162
|
+
kind: "standalone";
|
|
163
|
+
} | {
|
|
164
|
+
kind: "workspace";
|
|
165
|
+
projectDirectory: string;
|
|
166
|
+
} | undefined;
|
|
167
|
+
schemas?: string[] | undefined;
|
|
168
|
+
defaultSchema?: string | undefined;
|
|
169
|
+
systemUser?: Record<string, any> | undefined;
|
|
170
|
+
standardModels?: string[] | undefined;
|
|
171
|
+
models?: {
|
|
172
|
+
name: string;
|
|
173
|
+
description?: string | undefined;
|
|
174
|
+
schema?: string | undefined;
|
|
175
|
+
databaseName?: string | undefined;
|
|
176
|
+
excelName?: string | undefined;
|
|
177
|
+
isReadonly?: boolean | undefined;
|
|
178
|
+
faker?: {
|
|
179
|
+
seed?: number | undefined;
|
|
180
|
+
items?: number | undefined;
|
|
181
|
+
} | undefined;
|
|
182
|
+
seed?: any[] | undefined;
|
|
183
|
+
fields?: z.objectOutputType<{
|
|
184
|
+
name: z.ZodString;
|
|
185
|
+
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
186
|
+
standardFields?: string[] | undefined;
|
|
187
|
+
defaultField?: string | undefined;
|
|
188
|
+
labelField?: string | undefined;
|
|
189
|
+
indexes?: (string & z.BRAND<"PXL.FieldName">)[][] | undefined;
|
|
190
|
+
source?: Record<string, unknown> | undefined;
|
|
191
|
+
}[] | undefined;
|
|
192
|
+
standardEnums?: string[] | undefined;
|
|
193
|
+
enums?: {
|
|
194
|
+
description: string;
|
|
195
|
+
name: string;
|
|
196
|
+
members: (string | {
|
|
197
|
+
value: string;
|
|
198
|
+
description?: string | undefined;
|
|
199
|
+
})[];
|
|
200
|
+
schema?: string | undefined;
|
|
201
|
+
databaseName?: string | undefined;
|
|
202
|
+
}[] | undefined;
|
|
203
|
+
}, {
|
|
204
|
+
name: string;
|
|
205
|
+
source: Record<string, unknown>;
|
|
206
|
+
slug: string;
|
|
207
|
+
description?: string | undefined;
|
|
208
|
+
version?: string | undefined;
|
|
209
|
+
projectType?: {
|
|
210
|
+
kind: "standalone";
|
|
211
|
+
} | {
|
|
212
|
+
kind: "workspace";
|
|
213
|
+
projectDirectory: string;
|
|
214
|
+
} | undefined;
|
|
215
|
+
schemas?: string[] | undefined;
|
|
216
|
+
defaultSchema?: string | undefined;
|
|
217
|
+
systemUser?: Record<string, any> | undefined;
|
|
218
|
+
standardModels?: string[] | undefined;
|
|
219
|
+
models?: unknown[] | undefined;
|
|
220
|
+
standardEnums?: string[] | undefined;
|
|
221
|
+
enums?: {
|
|
222
|
+
name: string;
|
|
223
|
+
members: (string | {
|
|
224
|
+
value: string;
|
|
225
|
+
description?: string | undefined;
|
|
226
|
+
})[];
|
|
227
|
+
description?: string | undefined;
|
|
228
|
+
schema?: string | undefined;
|
|
229
|
+
databaseName?: string | undefined;
|
|
230
|
+
}[] | undefined;
|
|
231
|
+
}>, {
|
|
232
|
+
name: string;
|
|
233
|
+
source: Record<string, unknown>;
|
|
234
|
+
slug: string;
|
|
235
|
+
description?: string | undefined;
|
|
236
|
+
version?: string | undefined;
|
|
237
|
+
projectType?: {
|
|
238
|
+
kind: "standalone";
|
|
239
|
+
} | {
|
|
240
|
+
kind: "workspace";
|
|
241
|
+
projectDirectory: string;
|
|
242
|
+
} | undefined;
|
|
243
|
+
schemas?: string[] | undefined;
|
|
244
|
+
defaultSchema?: string | undefined;
|
|
245
|
+
systemUser?: Record<string, any> | undefined;
|
|
246
|
+
standardModels?: string[] | undefined;
|
|
247
|
+
models?: {
|
|
248
|
+
name: string;
|
|
249
|
+
description?: string | undefined;
|
|
250
|
+
schema?: string | undefined;
|
|
251
|
+
databaseName?: string | undefined;
|
|
252
|
+
excelName?: string | undefined;
|
|
253
|
+
isReadonly?: boolean | undefined;
|
|
254
|
+
faker?: {
|
|
255
|
+
seed?: number | undefined;
|
|
256
|
+
items?: number | undefined;
|
|
257
|
+
} | undefined;
|
|
258
|
+
seed?: any[] | undefined;
|
|
259
|
+
fields?: z.objectOutputType<{
|
|
260
|
+
name: z.ZodString;
|
|
261
|
+
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
262
|
+
standardFields?: string[] | undefined;
|
|
263
|
+
defaultField?: string | undefined;
|
|
264
|
+
labelField?: string | undefined;
|
|
265
|
+
indexes?: (string & z.BRAND<"PXL.FieldName">)[][] | undefined;
|
|
266
|
+
source?: Record<string, unknown> | undefined;
|
|
267
|
+
}[] | undefined;
|
|
268
|
+
standardEnums?: string[] | undefined;
|
|
269
|
+
enums?: {
|
|
270
|
+
description: string;
|
|
271
|
+
name: string;
|
|
272
|
+
members: (string | {
|
|
273
|
+
value: string;
|
|
274
|
+
description?: string | undefined;
|
|
275
|
+
})[];
|
|
276
|
+
schema?: string | undefined;
|
|
277
|
+
databaseName?: string | undefined;
|
|
278
|
+
}[] | undefined;
|
|
279
|
+
}, unknown>;
|
|
280
|
+
/**
|
|
281
|
+
* The JSON format of a `ProjectSchema`
|
|
282
|
+
*/
|
|
283
|
+
export type ProjectSchemaJSON = Omit<z.infer<typeof zProjectSchemaJSON>, 'source'> & {
|
|
284
|
+
source?: Record<string, unknown>;
|
|
285
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.zProjectSchemaJSON = exports.zSchemaName = void 0;
|
|
37
|
+
const zod_1 = require("zod");
|
|
38
|
+
const utils_1 = require("@postxl/utils");
|
|
39
|
+
const Enum = __importStar(require("../enum"));
|
|
40
|
+
const Model = __importStar(require("../model"));
|
|
41
|
+
exports.zSchemaName = zod_1.z
|
|
42
|
+
//
|
|
43
|
+
.string()
|
|
44
|
+
.min(1, 'Schema name must not be empty')
|
|
45
|
+
.regex(/^\w+$/, 'Schema name can only contain letters, numbers and underscores.')
|
|
46
|
+
.describe('Name of the database schema.');
|
|
47
|
+
exports.zProjectSchemaJSON = zod_1.z
|
|
48
|
+
// We want to keep any extra fields that are not defined in the schema. However, these fields should
|
|
49
|
+
// not really be exposed as "main fields" of the parsed schema - instead, they should be nested under
|
|
50
|
+
// the `source` field. Zod does not expose the original input of an object (unless you use `.passthrough()`,
|
|
51
|
+
// but that would also expose the extra fields as main fields). So we need to preprocess the input to
|
|
52
|
+
// extract the `source` field.
|
|
53
|
+
.preprocess((input) => {
|
|
54
|
+
if (typeof input === 'object' && input !== null) {
|
|
55
|
+
const original = input;
|
|
56
|
+
return {
|
|
57
|
+
...original,
|
|
58
|
+
// We omit models from the source fields as we keep the original input in model.source
|
|
59
|
+
// as part of the model schema.
|
|
60
|
+
source: (0, utils_1.omit)(original, 'models'),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return input;
|
|
64
|
+
}, zod_1.z.object({
|
|
65
|
+
name: zod_1.z
|
|
66
|
+
//
|
|
67
|
+
.string()
|
|
68
|
+
.min(1, 'Name of the project must not be empty.')
|
|
69
|
+
.describe('Name of the project, e.g. "Client1 CRM System".'),
|
|
70
|
+
slug: zod_1.z
|
|
71
|
+
//
|
|
72
|
+
.string()
|
|
73
|
+
.min(1, 'Slug of the project must not be empty')
|
|
74
|
+
.regex(/^[a-z0-9-]+$/, 'Slug can only contain lowercase letters, numbers and dashes.')
|
|
75
|
+
.describe('Slug of the project, e.g. "client1-crm". '),
|
|
76
|
+
description: zod_1.z
|
|
77
|
+
//
|
|
78
|
+
.string()
|
|
79
|
+
.optional()
|
|
80
|
+
.describe('A helpful description of the project.'),
|
|
81
|
+
projectType: zod_1.z
|
|
82
|
+
//
|
|
83
|
+
.union([
|
|
84
|
+
zod_1.z.object({
|
|
85
|
+
kind: zod_1.z.literal('standalone'),
|
|
86
|
+
}),
|
|
87
|
+
zod_1.z.object({
|
|
88
|
+
kind: zod_1.z.literal('workspace'),
|
|
89
|
+
projectDirectory: zod_1.z
|
|
90
|
+
.string()
|
|
91
|
+
.min(1, 'Project directory must not be empty')
|
|
92
|
+
.describe('The project directory, without leading or trailing slash.'),
|
|
93
|
+
}),
|
|
94
|
+
], (0, utils_1.unionErrorMessage)((data) => `Project type must be either ${(0, utils_1.yellow)('"standalone"')} or ${(0, utils_1.yellow)('"workspace"')} (with additional fields)! Instead, received ${(0, utils_1.red)(JSON.stringify(data))}.`))
|
|
95
|
+
.optional()
|
|
96
|
+
.describe('The type of the project, either "standalone" or "workspace".'),
|
|
97
|
+
version: zod_1.z
|
|
98
|
+
//
|
|
99
|
+
.string()
|
|
100
|
+
.min(1, 'Version of the project must not be empty')
|
|
101
|
+
.optional()
|
|
102
|
+
.describe('The version of the project/schema. Should follow semantic versioning, see https://semver.org/.'),
|
|
103
|
+
schemas: zod_1.z
|
|
104
|
+
//
|
|
105
|
+
.array(exports.zSchemaName)
|
|
106
|
+
.min(1, 'Schemas of the project must not be empty! If you want to use the default schemas, omit this field.')
|
|
107
|
+
.optional()
|
|
108
|
+
.describe('The database schemas that are used in the project. If not provided, the default schemas "PXL" and "Data" are used.'),
|
|
109
|
+
defaultSchema: exports.zSchemaName
|
|
110
|
+
//
|
|
111
|
+
.optional()
|
|
112
|
+
.describe(`The default database schema that is used if model/enum does not specify a schema. If not provided, the default schema "Data" is used.`),
|
|
113
|
+
systemUser: zod_1.z
|
|
114
|
+
//
|
|
115
|
+
.record(zod_1.z.any())
|
|
116
|
+
.optional()
|
|
117
|
+
.describe('The system user that is used for root/system tasks, e.g. data seeding.'),
|
|
118
|
+
standardModels: zod_1.z
|
|
119
|
+
//
|
|
120
|
+
.array(Model.zModelNameJSON)
|
|
121
|
+
.optional().describe(`Names of standard models that should be included in the project.
|
|
122
|
+
Currently, the following fields are supported: Config, User, Action, ActionOperation, File.
|
|
123
|
+
If not provided, all models are included by default.
|
|
124
|
+
|
|
125
|
+
If any of the standard models are also provided in the \`models\` array, the custom models will take precedence.`),
|
|
126
|
+
models: zod_1.z
|
|
127
|
+
//
|
|
128
|
+
.array(Model.zModelJSON)
|
|
129
|
+
.optional()
|
|
130
|
+
.describe('The models that are used in the project.'),
|
|
131
|
+
standardEnums: zod_1.z
|
|
132
|
+
//
|
|
133
|
+
.array(Enum.zEnumNameJSON)
|
|
134
|
+
.optional().describe(`Names of standard enums that should be included in the project.
|
|
135
|
+
Currently, the following fields are supported: ActionStatus, MutationStatus, MutationKind.
|
|
136
|
+
If not provided, all enums are included by default.
|
|
137
|
+
|
|
138
|
+
If any of the standard enums are also provided in the \`enums\` array, the custom enums will take precedence.`),
|
|
139
|
+
enums: zod_1.z
|
|
140
|
+
//
|
|
141
|
+
.array(Enum.zEnumJSON)
|
|
142
|
+
.optional()
|
|
143
|
+
.describe('The enums that are used in the project.'),
|
|
144
|
+
source: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
|
|
145
|
+
}));
|