@postxl/schema 1.1.1 → 1.2.0
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/enum/enum.brands.d.ts +6 -6
- package/dist/enum/enum.brands.js +6 -3
- package/dist/enum/enum.d.ts +10 -34
- package/dist/enum/enum.defaults.d.ts +9 -9
- package/dist/enum/enum.json-decoder.d.ts +8 -44
- package/dist/enum/enum.json-decoder.js +9 -6
- package/dist/enum/enum.transformer.d.ts +4 -4
- package/dist/field/defaults.d.ts +5 -5
- package/dist/field/discriminated-union.d.ts +13 -49
- package/dist/field/enum.d.ts +9 -27
- package/dist/field/field.d.ts +80 -300
- package/dist/field/id.d.ts +22 -62
- package/dist/field/relation.d.ts +10 -32
- package/dist/field/relation.js +4 -2
- package/dist/field/scalar.d.ts +13 -77
- package/dist/field/shared/brands.d.ts +24 -24
- package/dist/field/shared/brands.js +28 -10
- package/dist/field/shared/decoders.d.ts +4 -4
- package/dist/field/shared/decoders.js +8 -6
- package/dist/field/shared/seed.d.ts +2 -8
- package/dist/model/model.brands.d.ts +4 -4
- package/dist/model/model.defaults.d.ts +10 -10
- package/dist/model/model.json-decoder.d.ts +10 -80
- package/dist/model/model.json-decoder.js +13 -10
- package/dist/model/model.transformer.d.ts +32 -30
- package/dist/project-schema/project-schema.brands.d.ts +6 -6
- package/dist/project-schema/project-schema.brands.js +6 -1
- package/dist/project-schema/project-schema.defaults.d.ts +2 -2
- package/dist/project-schema/project-schema.json-decoder.d.ts +19 -222
- package/dist/project-schema/project-schema.json-decoder.js +10 -8
- package/dist/project-schema/project-schema.transformer.d.ts +30 -189
- package/package.json +2 -2
|
@@ -1,94 +1,24 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const zModelNameJSON: z.
|
|
3
|
-
export declare const zModelJSON: z.
|
|
4
|
-
name: z.
|
|
2
|
+
export declare const zModelNameJSON: z.ZodString;
|
|
3
|
+
export declare const zModelJSON: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
4
|
+
name: z.ZodString;
|
|
5
5
|
description: z.ZodOptional<z.ZodString>;
|
|
6
6
|
isReadonly: z.ZodOptional<z.ZodBoolean>;
|
|
7
7
|
schema: z.ZodOptional<z.ZodString>;
|
|
8
8
|
databaseName: z.ZodOptional<z.ZodString>;
|
|
9
|
-
excelName: z.
|
|
9
|
+
excelName: z.ZodOptional<z.ZodString>;
|
|
10
10
|
fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
11
11
|
name: z.ZodString;
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
15
|
-
name: z.ZodString;
|
|
16
|
-
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
17
|
-
standardFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
12
|
+
}, z.core.$loose>>>;
|
|
13
|
+
standardFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
14
|
defaultField: z.ZodOptional<z.ZodString>;
|
|
19
15
|
labelField: z.ZodOptional<z.ZodString>;
|
|
20
|
-
indexes: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodBranded<z.
|
|
21
|
-
seed: z.ZodOptional<z.ZodArray<z.ZodAny
|
|
16
|
+
indexes: z.ZodOptional<z.ZodArray<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">>>>;
|
|
17
|
+
seed: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
22
18
|
source: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
23
19
|
faker: z.ZodOptional<z.ZodObject<{
|
|
24
20
|
items: z.ZodOptional<z.ZodNumber>;
|
|
25
21
|
seed: z.ZodOptional<z.ZodNumber>;
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
items?: number | undefined;
|
|
29
|
-
}, {
|
|
30
|
-
seed?: number | undefined;
|
|
31
|
-
items?: number | undefined;
|
|
32
|
-
}>>;
|
|
33
|
-
}, "strip", z.ZodTypeAny, {
|
|
34
|
-
name: string;
|
|
35
|
-
description?: string | undefined;
|
|
36
|
-
schema?: string | undefined;
|
|
37
|
-
databaseName?: string | undefined;
|
|
38
|
-
excelName?: string | undefined;
|
|
39
|
-
isReadonly?: boolean | undefined;
|
|
40
|
-
faker?: {
|
|
41
|
-
seed?: number | undefined;
|
|
42
|
-
items?: number | undefined;
|
|
43
|
-
} | undefined;
|
|
44
|
-
seed?: any[] | undefined;
|
|
45
|
-
fields?: z.objectOutputType<{
|
|
46
|
-
name: z.ZodString;
|
|
47
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
48
|
-
standardFields?: string[] | undefined;
|
|
49
|
-
defaultField?: string | undefined;
|
|
50
|
-
labelField?: string | undefined;
|
|
51
|
-
indexes?: (string & z.BRAND<"PXL.FieldName">)[][] | undefined;
|
|
52
|
-
source?: Record<string, unknown> | undefined;
|
|
53
|
-
}, {
|
|
54
|
-
name: string;
|
|
55
|
-
description?: string | undefined;
|
|
56
|
-
schema?: string | undefined;
|
|
57
|
-
databaseName?: string | undefined;
|
|
58
|
-
excelName?: string | undefined;
|
|
59
|
-
isReadonly?: boolean | undefined;
|
|
60
|
-
faker?: {
|
|
61
|
-
seed?: number | undefined;
|
|
62
|
-
items?: number | undefined;
|
|
63
|
-
} | undefined;
|
|
64
|
-
seed?: any[] | undefined;
|
|
65
|
-
fields?: z.objectInputType<{
|
|
66
|
-
name: z.ZodString;
|
|
67
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
68
|
-
standardFields?: string[] | undefined;
|
|
69
|
-
defaultField?: string | undefined;
|
|
70
|
-
labelField?: string | undefined;
|
|
71
|
-
indexes?: string[][] | undefined;
|
|
72
|
-
source?: Record<string, unknown> | undefined;
|
|
73
|
-
}>, {
|
|
74
|
-
name: string;
|
|
75
|
-
description?: string | undefined;
|
|
76
|
-
schema?: string | undefined;
|
|
77
|
-
databaseName?: string | undefined;
|
|
78
|
-
excelName?: string | undefined;
|
|
79
|
-
isReadonly?: boolean | undefined;
|
|
80
|
-
faker?: {
|
|
81
|
-
seed?: number | undefined;
|
|
82
|
-
items?: number | undefined;
|
|
83
|
-
} | undefined;
|
|
84
|
-
seed?: any[] | undefined;
|
|
85
|
-
fields?: z.objectOutputType<{
|
|
86
|
-
name: z.ZodString;
|
|
87
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
88
|
-
standardFields?: string[] | undefined;
|
|
89
|
-
defaultField?: string | undefined;
|
|
90
|
-
labelField?: string | undefined;
|
|
91
|
-
indexes?: (string & z.BRAND<"PXL.FieldName">)[][] | undefined;
|
|
92
|
-
source?: Record<string, unknown> | undefined;
|
|
93
|
-
}, unknown>;
|
|
22
|
+
}, z.core.$strip>>;
|
|
23
|
+
}, z.core.$strip>>;
|
|
94
24
|
export type ModelJSON = z.infer<typeof zModelJSON>;
|
|
@@ -7,10 +7,13 @@ const brands_1 = require("../field/shared/brands");
|
|
|
7
7
|
exports.zModelNameJSON = zod_1.z
|
|
8
8
|
//
|
|
9
9
|
.string()
|
|
10
|
-
.min(1, 'Name of the model must not be empty')
|
|
11
|
-
.refine((name) => name !== (0, utils_1.pluralize)(name),
|
|
12
|
-
|
|
13
|
-
})
|
|
10
|
+
.min(1, { error: 'Name of the model must not be empty' })
|
|
11
|
+
.refine((name) => name !== (0, utils_1.pluralize)(name), {
|
|
12
|
+
error: (issue) => `Model ${issue.input} must not be pluralized!`,
|
|
13
|
+
})
|
|
14
|
+
.refine((name) => name === (0, utils_1.toPascalCase)(name), {
|
|
15
|
+
error: (issue) => `Model name "${(0, utils_1.red)(issue.input)}" must be PascalCase, i.e. ${(0, utils_1.toPascalCase)(issue.input)}!`,
|
|
16
|
+
})
|
|
14
17
|
.describe('Name of the model.');
|
|
15
18
|
exports.zModelJSON = zod_1.z.preprocess((input) => {
|
|
16
19
|
if (typeof input === 'object' && input !== null) {
|
|
@@ -35,8 +38,8 @@ exports.zModelJSON = zod_1.z.preprocess((input) => {
|
|
|
35
38
|
schema: zod_1.z
|
|
36
39
|
//
|
|
37
40
|
.string()
|
|
38
|
-
.min(1, 'Schema of the model must not be empty')
|
|
39
|
-
.optional().describe(`The database schema that the model belongs to.
|
|
41
|
+
.min(1, { error: 'Schema of the model must not be empty' })
|
|
42
|
+
.optional().describe(`The database schema that the model belongs to.
|
|
40
43
|
If not provided, the default data schema is assumed.`),
|
|
41
44
|
databaseName: zod_1.z
|
|
42
45
|
.string()
|
|
@@ -45,9 +48,9 @@ If not provided, the default data schema is assumed.`),
|
|
|
45
48
|
excelName: zod_1.z
|
|
46
49
|
.string()
|
|
47
50
|
.optional()
|
|
48
|
-
.refine((name) => name === undefined || name === (0, utils_1.toExcelTableName)(name),
|
|
49
|
-
|
|
50
|
-
})
|
|
51
|
+
.refine((name) => name === undefined || name === (0, utils_1.toExcelTableName)(name), {
|
|
52
|
+
error: (issue) => `Excel table name "${(0, utils_1.red)(String(issue.input ?? ''))}" is not a valid Excel table name. It must start with a letter or underscore and can only contain letters, numbers, and underscores.`,
|
|
53
|
+
})
|
|
51
54
|
.describe('Mapping of the model to an Excel table name. If not provided, we use the `name` field.'),
|
|
52
55
|
fields: zod_1.z
|
|
53
56
|
//
|
|
@@ -79,7 +82,7 @@ Example use case: default language, root region in region tree.`),
|
|
|
79
82
|
The label field must be a string field. If not provided, the \`name\` field is used as the label.`),
|
|
80
83
|
indexes: zod_1.z
|
|
81
84
|
//
|
|
82
|
-
.array(zod_1.z.array(brands_1.zFieldName).min(2))
|
|
85
|
+
.array(zod_1.z.array(brands_1.zFieldName).min(2, { error: 'Index must have at least 2 fields' }))
|
|
83
86
|
.optional()
|
|
84
87
|
.describe('Each entry is an array of field names that are used to create an index.'),
|
|
85
88
|
seed: zod_1.z
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { ModelJSON } from './model.json-decoder';
|
|
3
3
|
export declare function modelJSONTransformer(input: ModelJSON, ctx: z.RefinementCtx): {
|
|
4
|
-
fields: Record<string & z.
|
|
4
|
+
fields: Record<string & z.core.$brand<"PXL.FieldName">, unknown>;
|
|
5
5
|
/**
|
|
6
6
|
* We also provide a list of field names to keep the original order
|
|
7
7
|
*/
|
|
8
|
-
fieldNames: (string & z.
|
|
9
|
-
name: string & z.
|
|
10
|
-
schema: (string & z.
|
|
11
|
-
databaseName: string & z.
|
|
12
|
-
defaultFieldName: (string & z.
|
|
13
|
-
labelFieldName: (string & z.
|
|
8
|
+
fieldNames: (string & z.core.$brand<"PXL.FieldName">)[];
|
|
9
|
+
name: string & z.core.$brand<"PXL.ModelName">;
|
|
10
|
+
schema: (string & z.core.$brand<"PXL.DatabaseSchemaName">) | undefined;
|
|
11
|
+
databaseName: string & z.core.$brand<"PXL.DatabaseModelName">;
|
|
12
|
+
defaultFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
|
|
13
|
+
labelFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
|
|
14
14
|
isReadonly: boolean;
|
|
15
15
|
excelName: string;
|
|
16
16
|
description: string;
|
|
17
|
-
indexes: (string & z.
|
|
17
|
+
indexes: (string & z.core.$brand<"PXL.FieldName">)[][];
|
|
18
18
|
seed: any[];
|
|
19
19
|
faker: {
|
|
20
20
|
seed: number;
|
|
@@ -28,11 +28,12 @@ declare function addDefaults({ description, fields, standardFields, seed, faker,
|
|
|
28
28
|
databaseName: string;
|
|
29
29
|
excelName: string;
|
|
30
30
|
description: string;
|
|
31
|
-
fields:
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
fields: {
|
|
32
|
+
[x: string]: unknown;
|
|
33
|
+
name: string;
|
|
34
|
+
}[];
|
|
34
35
|
standardFields: string[];
|
|
35
|
-
indexes: (string & z.
|
|
36
|
+
indexes: (string & z.core.$brand<"PXL.FieldName">)[][];
|
|
36
37
|
seed: any[];
|
|
37
38
|
faker: {
|
|
38
39
|
seed: number;
|
|
@@ -46,19 +47,20 @@ declare function addDefaults({ description, fields, standardFields, seed, faker,
|
|
|
46
47
|
};
|
|
47
48
|
type WithDefaults = ReturnType<typeof addDefaults>;
|
|
48
49
|
declare function brandModel({ name, schema, databaseName, standardFields, defaultField, labelField, ...input }: WithDefaults): {
|
|
49
|
-
name: string & z.
|
|
50
|
-
schema: (string & z.
|
|
51
|
-
databaseName: string & z.
|
|
52
|
-
standardFields: (string & z.
|
|
53
|
-
defaultFieldName: (string & z.
|
|
54
|
-
labelFieldName: (string & z.
|
|
50
|
+
name: string & z.core.$brand<"PXL.ModelName">;
|
|
51
|
+
schema: (string & z.core.$brand<"PXL.DatabaseSchemaName">) | undefined;
|
|
52
|
+
databaseName: string & z.core.$brand<"PXL.DatabaseModelName">;
|
|
53
|
+
standardFields: (string & z.core.$brand<"PXL.FieldName">)[];
|
|
54
|
+
defaultFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
|
|
55
|
+
labelFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
|
|
55
56
|
isReadonly: boolean;
|
|
56
57
|
excelName: string;
|
|
57
58
|
description: string;
|
|
58
|
-
fields:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
fields: {
|
|
60
|
+
[x: string]: unknown;
|
|
61
|
+
name: string;
|
|
62
|
+
}[];
|
|
63
|
+
indexes: (string & z.core.$brand<"PXL.FieldName">)[][];
|
|
62
64
|
seed: any[];
|
|
63
65
|
faker: {
|
|
64
66
|
seed: number;
|
|
@@ -68,20 +70,20 @@ declare function brandModel({ name, schema, databaseName, standardFields, defaul
|
|
|
68
70
|
};
|
|
69
71
|
type BrandedModel = ReturnType<typeof brandModel>;
|
|
70
72
|
declare function combineFields({ fields, standardFields, ...model }: BrandedModel, ctx: z.RefinementCtx): {
|
|
71
|
-
fields: Record<string & z.
|
|
73
|
+
fields: Record<string & z.core.$brand<"PXL.FieldName">, unknown>;
|
|
72
74
|
/**
|
|
73
75
|
* We also provide a list of field names to keep the original order
|
|
74
76
|
*/
|
|
75
|
-
fieldNames: (string & z.
|
|
76
|
-
name: string & z.
|
|
77
|
-
schema: (string & z.
|
|
78
|
-
databaseName: string & z.
|
|
79
|
-
defaultFieldName: (string & z.
|
|
80
|
-
labelFieldName: (string & z.
|
|
77
|
+
fieldNames: (string & z.core.$brand<"PXL.FieldName">)[];
|
|
78
|
+
name: string & z.core.$brand<"PXL.ModelName">;
|
|
79
|
+
schema: (string & z.core.$brand<"PXL.DatabaseSchemaName">) | undefined;
|
|
80
|
+
databaseName: string & z.core.$brand<"PXL.DatabaseModelName">;
|
|
81
|
+
defaultFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
|
|
82
|
+
labelFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
|
|
81
83
|
isReadonly: boolean;
|
|
82
84
|
excelName: string;
|
|
83
85
|
description: string;
|
|
84
|
-
indexes: (string & z.
|
|
86
|
+
indexes: (string & z.core.$brand<"PXL.FieldName">)[][];
|
|
85
87
|
seed: any[];
|
|
86
88
|
faker: {
|
|
87
89
|
seed: number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const zProjectSchemaName: z.ZodBranded<z.ZodString, "PXL.ProjectSchemaName">;
|
|
2
|
+
export declare const zProjectSchemaName: z.core.$ZodBranded<z.ZodString, "PXL.ProjectSchemaName", "out">;
|
|
3
3
|
export type ProjectSchemaName = z.infer<typeof zProjectSchemaName>;
|
|
4
|
-
export declare const toProjectSchemaName: (input: string) => string & z.
|
|
5
|
-
export declare const zProjectSlug: z.ZodBranded<z.
|
|
4
|
+
export declare const toProjectSchemaName: (input: string) => string & z.core.$brand<"PXL.ProjectSchemaName">;
|
|
5
|
+
export declare const zProjectSlug: z.core.$ZodBranded<z.ZodString, "PXL.ProjectSlug", "out">;
|
|
6
6
|
export type ProjectSlug = z.infer<typeof zProjectSlug>;
|
|
7
|
-
export declare const toProjectSlug: (input: string) => string & z.
|
|
8
|
-
export declare const zDatabaseSchemaName: z.ZodBranded<z.ZodString, "PXL.DatabaseSchemaName">;
|
|
7
|
+
export declare const toProjectSlug: (input: string) => string & z.core.$brand<"PXL.ProjectSlug">;
|
|
8
|
+
export declare const zDatabaseSchemaName: z.core.$ZodBranded<z.ZodString, "PXL.DatabaseSchemaName", "out">;
|
|
9
9
|
export type DatabaseSchemaName = z.infer<typeof zDatabaseSchemaName>;
|
|
10
|
-
export declare const toDatabaseSchemaName: (input: string) => string & z.
|
|
10
|
+
export declare const toDatabaseSchemaName: (input: string) => string & z.core.$brand<"PXL.DatabaseSchemaName">;
|
|
@@ -8,7 +8,12 @@ const toProjectSchemaName = (input) => exports.zProjectSchemaName.parse(input);
|
|
|
8
8
|
exports.toProjectSchemaName = toProjectSchemaName;
|
|
9
9
|
exports.zProjectSlug = zod_1.z
|
|
10
10
|
.string()
|
|
11
|
-
.refine(utils_1.isSlug,
|
|
11
|
+
.refine(utils_1.isSlug, {
|
|
12
|
+
error: (issue) => {
|
|
13
|
+
const s = String(issue.input);
|
|
14
|
+
return `Project slug must be a valid slug. Expected ${(0, utils_1.slugify)(s)}, received ${s}`;
|
|
15
|
+
},
|
|
16
|
+
})
|
|
12
17
|
.brand('PXL.ProjectSlug');
|
|
13
18
|
const toProjectSlug = (input) => exports.zProjectSlug.parse(input);
|
|
14
19
|
exports.toProjectSlug = toProjectSlug;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* The name of the default data schema of the project.
|
|
3
3
|
* This name is used when a model does not specify a schema.
|
|
4
4
|
*/
|
|
5
|
-
export declare const databaseSchemaNameData: string & import("zod")
|
|
5
|
+
export declare const databaseSchemaNameData: string & import("zod").$brand<"PXL.DatabaseSchemaName">;
|
|
6
6
|
/**
|
|
7
7
|
* The name of the schema that contains the configuration of the project.
|
|
8
8
|
*/
|
|
9
|
-
export declare const databaseSchemaNameConfig: string & import("zod")
|
|
9
|
+
export declare const databaseSchemaNameConfig: string & import("zod").$brand<"PXL.DatabaseSchemaName">;
|
|
10
10
|
export declare const defaultSystemUser: {
|
|
11
11
|
id: string;
|
|
12
12
|
sub: null;
|
|
@@ -1,252 +1,49 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const zSchemaName: z.ZodString;
|
|
3
|
-
export declare const zProjectSchemaJSON: z.
|
|
3
|
+
export declare const zProjectSchemaJSON: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
4
4
|
name: z.ZodString;
|
|
5
5
|
slug: z.ZodString;
|
|
6
6
|
description: z.ZodOptional<z.ZodString>;
|
|
7
|
-
projectType: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"standalone">, z.ZodLiteral<"workspace">]>>>;
|
|
7
|
+
projectType: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"standalone">, z.ZodLiteral<"workspace">]>>>;
|
|
8
8
|
version: z.ZodOptional<z.ZodString>;
|
|
9
|
-
schemas: z.ZodOptional<z.ZodArray<z.ZodString
|
|
9
|
+
schemas: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
10
|
defaultSchema: z.ZodOptional<z.ZodString>;
|
|
11
11
|
systemUser: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
12
|
-
standardModels: z.ZodOptional<z.ZodArray<z.
|
|
13
|
-
models: z.ZodOptional<z.ZodArray<z.
|
|
14
|
-
name: z.
|
|
12
|
+
standardModels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
+
models: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
14
|
+
name: z.ZodString;
|
|
15
15
|
description: z.ZodOptional<z.ZodString>;
|
|
16
16
|
isReadonly: z.ZodOptional<z.ZodBoolean>;
|
|
17
17
|
schema: z.ZodOptional<z.ZodString>;
|
|
18
18
|
databaseName: z.ZodOptional<z.ZodString>;
|
|
19
|
-
excelName: z.
|
|
19
|
+
excelName: z.ZodOptional<z.ZodString>;
|
|
20
20
|
fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
21
21
|
name: z.ZodString;
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
25
|
-
name: z.ZodString;
|
|
26
|
-
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
27
|
-
standardFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
22
|
+
}, z.core.$loose>>>;
|
|
23
|
+
standardFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
24
|
defaultField: z.ZodOptional<z.ZodString>;
|
|
29
25
|
labelField: z.ZodOptional<z.ZodString>;
|
|
30
|
-
indexes: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodBranded<z.
|
|
31
|
-
seed: z.ZodOptional<z.ZodArray<z.ZodAny
|
|
26
|
+
indexes: z.ZodOptional<z.ZodArray<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">>>>;
|
|
27
|
+
seed: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
32
28
|
source: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
33
29
|
faker: z.ZodOptional<z.ZodObject<{
|
|
34
30
|
items: z.ZodOptional<z.ZodNumber>;
|
|
35
31
|
seed: z.ZodOptional<z.ZodNumber>;
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}, {
|
|
40
|
-
seed?: number | undefined;
|
|
41
|
-
items?: number | undefined;
|
|
42
|
-
}>>;
|
|
43
|
-
}, "strip", z.ZodTypeAny, {
|
|
44
|
-
name: string;
|
|
45
|
-
description?: string | undefined;
|
|
46
|
-
schema?: string | undefined;
|
|
47
|
-
databaseName?: string | undefined;
|
|
48
|
-
excelName?: string | undefined;
|
|
49
|
-
isReadonly?: boolean | undefined;
|
|
50
|
-
faker?: {
|
|
51
|
-
seed?: number | undefined;
|
|
52
|
-
items?: number | undefined;
|
|
53
|
-
} | undefined;
|
|
54
|
-
seed?: any[] | undefined;
|
|
55
|
-
fields?: z.objectOutputType<{
|
|
56
|
-
name: z.ZodString;
|
|
57
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
58
|
-
standardFields?: string[] | undefined;
|
|
59
|
-
defaultField?: string | undefined;
|
|
60
|
-
labelField?: string | undefined;
|
|
61
|
-
indexes?: (string & z.BRAND<"PXL.FieldName">)[][] | undefined;
|
|
62
|
-
source?: Record<string, unknown> | undefined;
|
|
63
|
-
}, {
|
|
64
|
-
name: string;
|
|
65
|
-
description?: string | undefined;
|
|
66
|
-
schema?: string | undefined;
|
|
67
|
-
databaseName?: string | undefined;
|
|
68
|
-
excelName?: string | undefined;
|
|
69
|
-
isReadonly?: boolean | undefined;
|
|
70
|
-
faker?: {
|
|
71
|
-
seed?: number | undefined;
|
|
72
|
-
items?: number | undefined;
|
|
73
|
-
} | undefined;
|
|
74
|
-
seed?: any[] | undefined;
|
|
75
|
-
fields?: z.objectInputType<{
|
|
76
|
-
name: z.ZodString;
|
|
77
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
78
|
-
standardFields?: string[] | undefined;
|
|
79
|
-
defaultField?: string | undefined;
|
|
80
|
-
labelField?: string | undefined;
|
|
81
|
-
indexes?: string[][] | undefined;
|
|
82
|
-
source?: Record<string, unknown> | undefined;
|
|
83
|
-
}>, {
|
|
84
|
-
name: string;
|
|
85
|
-
description?: string | undefined;
|
|
86
|
-
schema?: string | undefined;
|
|
87
|
-
databaseName?: string | undefined;
|
|
88
|
-
excelName?: string | undefined;
|
|
89
|
-
isReadonly?: boolean | undefined;
|
|
90
|
-
faker?: {
|
|
91
|
-
seed?: number | undefined;
|
|
92
|
-
items?: number | undefined;
|
|
93
|
-
} | undefined;
|
|
94
|
-
seed?: any[] | undefined;
|
|
95
|
-
fields?: z.objectOutputType<{
|
|
96
|
-
name: z.ZodString;
|
|
97
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
98
|
-
standardFields?: string[] | undefined;
|
|
99
|
-
defaultField?: string | undefined;
|
|
100
|
-
labelField?: string | undefined;
|
|
101
|
-
indexes?: (string & z.BRAND<"PXL.FieldName">)[][] | undefined;
|
|
102
|
-
source?: Record<string, unknown> | undefined;
|
|
103
|
-
}, unknown>, "many">>;
|
|
104
|
-
standardEnums: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
32
|
+
}, z.core.$strip>>;
|
|
33
|
+
}, z.core.$strip>>>>;
|
|
34
|
+
standardEnums: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
105
35
|
enums: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
106
|
-
name: z.
|
|
36
|
+
name: z.ZodString;
|
|
107
37
|
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
108
38
|
schema: z.ZodOptional<z.ZodString>;
|
|
109
39
|
databaseName: z.ZodOptional<z.ZodString>;
|
|
110
|
-
members: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
40
|
+
members: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
111
41
|
value: z.ZodString;
|
|
112
42
|
description: z.ZodOptional<z.ZodString>;
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
description?: string | undefined;
|
|
116
|
-
}, {
|
|
117
|
-
value: string;
|
|
118
|
-
description?: string | undefined;
|
|
119
|
-
}>, z.ZodString]>, "many">;
|
|
120
|
-
}, "strip", z.ZodTypeAny, {
|
|
121
|
-
description: string;
|
|
122
|
-
name: string;
|
|
123
|
-
members: (string | {
|
|
124
|
-
value: string;
|
|
125
|
-
description?: string | undefined;
|
|
126
|
-
})[];
|
|
127
|
-
schema?: string | undefined;
|
|
128
|
-
databaseName?: string | undefined;
|
|
129
|
-
}, {
|
|
130
|
-
name: string;
|
|
131
|
-
members: (string | {
|
|
132
|
-
value: string;
|
|
133
|
-
description?: string | undefined;
|
|
134
|
-
})[];
|
|
135
|
-
description?: string | undefined;
|
|
136
|
-
schema?: string | undefined;
|
|
137
|
-
databaseName?: string | undefined;
|
|
138
|
-
}>, "many">>;
|
|
43
|
+
}, z.core.$strip>, z.ZodString]>>;
|
|
44
|
+
}, z.core.$strip>>>;
|
|
139
45
|
source: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
140
|
-
},
|
|
141
|
-
name: string;
|
|
142
|
-
source: Record<string, unknown>;
|
|
143
|
-
slug: string;
|
|
144
|
-
projectType: "standalone" | "workspace";
|
|
145
|
-
description?: string | undefined;
|
|
146
|
-
version?: string | undefined;
|
|
147
|
-
schemas?: string[] | undefined;
|
|
148
|
-
defaultSchema?: string | undefined;
|
|
149
|
-
systemUser?: Record<string, any> | undefined;
|
|
150
|
-
standardModels?: string[] | undefined;
|
|
151
|
-
models?: {
|
|
152
|
-
name: string;
|
|
153
|
-
description?: string | undefined;
|
|
154
|
-
schema?: string | undefined;
|
|
155
|
-
databaseName?: string | undefined;
|
|
156
|
-
excelName?: string | undefined;
|
|
157
|
-
isReadonly?: boolean | undefined;
|
|
158
|
-
faker?: {
|
|
159
|
-
seed?: number | undefined;
|
|
160
|
-
items?: number | undefined;
|
|
161
|
-
} | undefined;
|
|
162
|
-
seed?: any[] | undefined;
|
|
163
|
-
fields?: z.objectOutputType<{
|
|
164
|
-
name: z.ZodString;
|
|
165
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
166
|
-
standardFields?: string[] | undefined;
|
|
167
|
-
defaultField?: string | undefined;
|
|
168
|
-
labelField?: string | undefined;
|
|
169
|
-
indexes?: (string & z.BRAND<"PXL.FieldName">)[][] | undefined;
|
|
170
|
-
source?: Record<string, unknown> | undefined;
|
|
171
|
-
}[] | undefined;
|
|
172
|
-
standardEnums?: string[] | undefined;
|
|
173
|
-
enums?: {
|
|
174
|
-
description: string;
|
|
175
|
-
name: string;
|
|
176
|
-
members: (string | {
|
|
177
|
-
value: string;
|
|
178
|
-
description?: string | undefined;
|
|
179
|
-
})[];
|
|
180
|
-
schema?: string | undefined;
|
|
181
|
-
databaseName?: string | undefined;
|
|
182
|
-
}[] | undefined;
|
|
183
|
-
}, {
|
|
184
|
-
name: string;
|
|
185
|
-
source: Record<string, unknown>;
|
|
186
|
-
slug: string;
|
|
187
|
-
description?: string | undefined;
|
|
188
|
-
version?: string | undefined;
|
|
189
|
-
projectType?: "standalone" | "workspace" | undefined;
|
|
190
|
-
schemas?: string[] | undefined;
|
|
191
|
-
defaultSchema?: string | undefined;
|
|
192
|
-
systemUser?: Record<string, any> | undefined;
|
|
193
|
-
standardModels?: string[] | undefined;
|
|
194
|
-
models?: unknown[] | undefined;
|
|
195
|
-
standardEnums?: string[] | undefined;
|
|
196
|
-
enums?: {
|
|
197
|
-
name: string;
|
|
198
|
-
members: (string | {
|
|
199
|
-
value: string;
|
|
200
|
-
description?: string | undefined;
|
|
201
|
-
})[];
|
|
202
|
-
description?: string | undefined;
|
|
203
|
-
schema?: string | undefined;
|
|
204
|
-
databaseName?: string | undefined;
|
|
205
|
-
}[] | undefined;
|
|
206
|
-
}>, {
|
|
207
|
-
name: string;
|
|
208
|
-
source: Record<string, unknown>;
|
|
209
|
-
slug: string;
|
|
210
|
-
projectType: "standalone" | "workspace";
|
|
211
|
-
description?: string | undefined;
|
|
212
|
-
version?: string | undefined;
|
|
213
|
-
schemas?: string[] | undefined;
|
|
214
|
-
defaultSchema?: string | undefined;
|
|
215
|
-
systemUser?: Record<string, any> | undefined;
|
|
216
|
-
standardModels?: string[] | undefined;
|
|
217
|
-
models?: {
|
|
218
|
-
name: string;
|
|
219
|
-
description?: string | undefined;
|
|
220
|
-
schema?: string | undefined;
|
|
221
|
-
databaseName?: string | undefined;
|
|
222
|
-
excelName?: string | undefined;
|
|
223
|
-
isReadonly?: boolean | undefined;
|
|
224
|
-
faker?: {
|
|
225
|
-
seed?: number | undefined;
|
|
226
|
-
items?: number | undefined;
|
|
227
|
-
} | undefined;
|
|
228
|
-
seed?: any[] | undefined;
|
|
229
|
-
fields?: z.objectOutputType<{
|
|
230
|
-
name: z.ZodString;
|
|
231
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
232
|
-
standardFields?: string[] | undefined;
|
|
233
|
-
defaultField?: string | undefined;
|
|
234
|
-
labelField?: string | undefined;
|
|
235
|
-
indexes?: (string & z.BRAND<"PXL.FieldName">)[][] | undefined;
|
|
236
|
-
source?: Record<string, unknown> | undefined;
|
|
237
|
-
}[] | undefined;
|
|
238
|
-
standardEnums?: string[] | undefined;
|
|
239
|
-
enums?: {
|
|
240
|
-
description: string;
|
|
241
|
-
name: string;
|
|
242
|
-
members: (string | {
|
|
243
|
-
value: string;
|
|
244
|
-
description?: string | undefined;
|
|
245
|
-
})[];
|
|
246
|
-
schema?: string | undefined;
|
|
247
|
-
databaseName?: string | undefined;
|
|
248
|
-
}[] | undefined;
|
|
249
|
-
}, unknown>;
|
|
46
|
+
}, z.core.$strip>>;
|
|
250
47
|
/**
|
|
251
48
|
* The JSON format of a `ProjectSchema`
|
|
252
49
|
*/
|
|
@@ -41,8 +41,8 @@ const Model = __importStar(require("../model"));
|
|
|
41
41
|
exports.zSchemaName = zod_1.z
|
|
42
42
|
//
|
|
43
43
|
.string()
|
|
44
|
-
.min(1, 'Schema name must not be empty')
|
|
45
|
-
.regex(/^\w+$/, 'Schema name can only contain letters, numbers and underscores.')
|
|
44
|
+
.min(1, { error: 'Schema name must not be empty' })
|
|
45
|
+
.regex(/^\w+$/, { error: 'Schema name can only contain letters, numbers and underscores.' })
|
|
46
46
|
.describe('Name of the database schema.');
|
|
47
47
|
exports.zProjectSchemaJSON = zod_1.z
|
|
48
48
|
// We want to keep any extra fields that are not defined in the schema. However, these fields should
|
|
@@ -65,13 +65,13 @@ exports.zProjectSchemaJSON = zod_1.z
|
|
|
65
65
|
name: zod_1.z
|
|
66
66
|
//
|
|
67
67
|
.string()
|
|
68
|
-
.min(1, 'Name of the project must not be empty.')
|
|
68
|
+
.min(1, { error: 'Name of the project must not be empty.' })
|
|
69
69
|
.describe('Name of the project, e.g. "Client1 CRM System".'),
|
|
70
70
|
slug: zod_1.z
|
|
71
71
|
//
|
|
72
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.')
|
|
73
|
+
.min(1, { error: 'Slug of the project must not be empty' })
|
|
74
|
+
.regex(/^[a-z0-9-]+$/, { error: 'Slug can only contain lowercase letters, numbers and dashes.' })
|
|
75
75
|
.describe('Slug of the project, e.g. "client1-crm". '),
|
|
76
76
|
description: zod_1.z
|
|
77
77
|
//
|
|
@@ -87,13 +87,15 @@ exports.zProjectSchemaJSON = zod_1.z
|
|
|
87
87
|
version: zod_1.z
|
|
88
88
|
//
|
|
89
89
|
.string()
|
|
90
|
-
.min(1, 'Version of the project must not be empty')
|
|
90
|
+
.min(1, { error: 'Version of the project must not be empty' })
|
|
91
91
|
.optional()
|
|
92
92
|
.describe('The version of the project/schema. Should follow semantic versioning, see https://semver.org/.'),
|
|
93
93
|
schemas: zod_1.z
|
|
94
94
|
//
|
|
95
95
|
.array(exports.zSchemaName)
|
|
96
|
-
.min(1,
|
|
96
|
+
.min(1, {
|
|
97
|
+
error: 'Schemas of the project must not be empty! If you want to use the default schemas, omit this field.',
|
|
98
|
+
})
|
|
97
99
|
.optional()
|
|
98
100
|
.describe('The database schemas that are used in the project. If not provided, the default schemas "PXL" and "Data" are used.'),
|
|
99
101
|
defaultSchema: exports.zSchemaName
|
|
@@ -102,7 +104,7 @@ exports.zProjectSchemaJSON = zod_1.z
|
|
|
102
104
|
.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.`),
|
|
103
105
|
systemUser: zod_1.z
|
|
104
106
|
//
|
|
105
|
-
.record(zod_1.z.any())
|
|
107
|
+
.record(zod_1.z.string(), zod_1.z.any())
|
|
106
108
|
.optional()
|
|
107
109
|
.describe('The system user that is used for root/system tasks, e.g. data seeding.'),
|
|
108
110
|
standardModels: zod_1.z
|