@postxl/schema 2.4.0 → 2.6.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 +3 -3
- package/dist/enum/enum.d.ts +2 -2
- package/dist/enum/enum.defaults.d.ts +8 -8
- package/dist/enum/enum.transformer.d.ts +4 -4
- package/dist/field/enum.d.ts +14 -5
- package/dist/field/enum.js +23 -0
- package/dist/field/field.d.ts +38 -29
- package/dist/field/id.d.ts +14 -12
- package/dist/field/id.js +3 -0
- package/dist/field/json.d.ts +4 -1
- package/dist/field/json.js +2 -0
- package/dist/field/relation.d.ts +11 -9
- package/dist/field/relation.js +2 -0
- package/dist/field/scalar.d.ts +5 -2
- package/dist/field/scalar.js +2 -0
- package/dist/field/shared/brands.d.ts +11 -11
- package/dist/field/shared/decoders.d.ts +1 -0
- package/dist/field/shared/decoders.js +6 -1
- package/dist/field/shared/types.d.ts +10 -0
- package/dist/model/model.brands.d.ts +2 -2
- package/dist/model/model.defaults.js +5 -0
- package/dist/model/model.json-decoder.d.ts +8 -8
- package/dist/model/model.transformer.d.ts +88 -88
- package/dist/project-schema/project-schema.brands.d.ts +3 -3
- package/dist/project-schema/project-schema.defaults.d.ts +1 -1
- package/dist/project-schema/project-schema.json-decoder.d.ts +12 -4
- package/dist/project-schema/project-schema.json-decoder.js +6 -1
- package/dist/project-schema/project-schema.transformer.d.ts +16 -11
- package/dist/project-schema/project-schema.transformer.js +10 -13
- package/dist/project-schema/project-schema.types.d.ts +7 -0
- package/dist/samples/sample-schemas.d.ts +465 -465
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.zFieldPropertyDefaultValue = exports.zFieldPropertyPlaceholder = exports.zFieldSeed = exports.zScalarValue = exports.zFieldFaker = exports.zFieldPropertyMax = exports.zFieldPropertyMin = exports.zFieldPropertyMaxLength = exports.zFieldPropertyIsUpdatedAt = exports.zFieldPropertyIsCreatedAt = exports.zFieldPropertyHasIndex = exports.zFieldPropertyIsUnique = exports.zFieldPropertyIsReadonly = exports.zFieldPropertyDescription = exports.zFieldPropertyLabel = exports.zFieldPropertyExcelName = exports.zFieldPropertyDatabaseName = exports.zFieldPropertyType = exports.zFieldPropertyName = void 0;
|
|
3
|
+
exports.zFieldPropertyDefaultValue = exports.zFieldPropertyPlaceholder = exports.zFieldSeed = exports.zScalarValue = exports.zFieldFaker = exports.zFieldPropertyMax = exports.zFieldPropertyMin = exports.zFieldPropertyMaxLength = exports.zFieldPropertyIsUpdatedAt = exports.zFieldPropertyIsCreatedAt = exports.zFieldPropertyHasIndex = exports.zFieldPropertyIsUnique = exports.zFieldPropertyIsSystemManaged = exports.zFieldPropertyIsReadonly = exports.zFieldPropertyDescription = exports.zFieldPropertyLabel = exports.zFieldPropertyExcelName = exports.zFieldPropertyDatabaseName = exports.zFieldPropertyType = exports.zFieldPropertyName = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const utils_1 = require("@postxl/utils");
|
|
6
6
|
exports.zFieldPropertyName = zod_1.z
|
|
@@ -46,6 +46,11 @@ exports.zFieldPropertyIsReadonly = zod_1.z
|
|
|
46
46
|
.boolean()
|
|
47
47
|
.optional()
|
|
48
48
|
.describe('If true, the field is readonly, ie. it cannot be changed by the user.');
|
|
49
|
+
exports.zFieldPropertyIsSystemManaged = zod_1.z
|
|
50
|
+
//
|
|
51
|
+
.boolean()
|
|
52
|
+
.optional()
|
|
53
|
+
.describe('If true, the field is owned by the runtime, not the user: it disappears from every human-facing write surface (admin table (bulk) edit, the `updateField`/`updateFieldMany` write unions, the update form, Excel import) but stays in the whole-object `update` decoder so code can still persist it. Use `isReadonly` instead when nothing may write the field after creation.');
|
|
49
54
|
exports.zFieldPropertyIsUnique = zod_1.z
|
|
50
55
|
//
|
|
51
56
|
.boolean()
|
|
@@ -52,6 +52,16 @@ export type FieldCommon<T extends string> = FieldCore<T> & {
|
|
|
52
52
|
* If true, the field is readonly, ie. it cannot be changed by the user.
|
|
53
53
|
*/
|
|
54
54
|
isReadonly: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* If true, the field is owned by the runtime rather than by the user.
|
|
57
|
+
*
|
|
58
|
+
* It is dropped from every human-facing write surface - the admin table is not editable on it,
|
|
59
|
+
* it is not a member of the `updateField` / `updateFieldMany` write unions, the update form does
|
|
60
|
+
* not render it, and an Excel import never produces a delta for it - but, unlike `isReadonly`, it
|
|
61
|
+
* *stays* in the whole-object `update` decoder and in the repository's update statement, so the
|
|
62
|
+
* code that owns it can keep persisting it.
|
|
63
|
+
*/
|
|
64
|
+
isSystemManaged: boolean;
|
|
55
65
|
/**
|
|
56
66
|
* If true, uniqueness is enforced for the field, ie no two items can have the same value for this field.
|
|
57
67
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const zModelName: z.core.$ZodBranded<z.ZodString, "PXL.ModelName", "out">;
|
|
3
3
|
export type ModelName = z.infer<typeof zModelName>;
|
|
4
|
-
export declare const toModelName: (input: string) => string & z
|
|
4
|
+
export declare const toModelName: (input: string) => string & z.$brand<"PXL.ModelName">;
|
|
5
5
|
export declare const zDatabaseModelName: z.core.$ZodBranded<z.ZodString, "PXL.DatabaseModelName", "out">;
|
|
6
6
|
export type DatabaseModelName = z.infer<typeof zDatabaseModelName>;
|
|
7
|
-
export declare const toDatabaseModelName: (input: string) => string & z
|
|
7
|
+
export declare const toDatabaseModelName: (input: string) => string & z.$brand<"PXL.DatabaseModelName">;
|
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.defaultModelsJson = exports.defaultModelJson_Comment = exports.defaultModelJson_TableView = exports.defaultModelJson_File = exports.defaultModelJson_ActionOperation = exports.defaultModelJson_Action = exports.defaultModelJson_User = exports.defaultModel_Config = exports.defaultModelNames = exports.standardModelName_Comment = exports.standardModelName_TableView = exports.standardModelName_File = exports.standardModelName_ActionOperation = exports.standardModelName_Action = exports.standardModelName_User = exports.defaultModelName_Config = void 0;
|
|
37
37
|
const defaults_1 = require("../field/defaults");
|
|
38
|
+
const brands_1 = require("../field/shared/brands");
|
|
38
39
|
const project_schema_defaults_1 = require("../project-schema/project-schema.defaults");
|
|
39
40
|
const Branded = __importStar(require("./model.brands"));
|
|
40
41
|
exports.defaultModelName_Config = Branded.toModelName('Config');
|
|
@@ -249,6 +250,10 @@ Transformation: Depends on the transformation`,
|
|
|
249
250
|
description: 'For mutation operations: the original entity before the mutation was executed. Null in case of a create mutation.',
|
|
250
251
|
},
|
|
251
252
|
],
|
|
253
|
+
indexes: [
|
|
254
|
+
{ fields: [defaults_1.standardFieldName_createdAt], unique: false, map: undefined },
|
|
255
|
+
{ fields: [(0, brands_1.toFieldName)('actionId')], unique: false, map: undefined },
|
|
256
|
+
],
|
|
252
257
|
repository: { type: 'DatabaseDirect' },
|
|
253
258
|
faker: { items: 0 },
|
|
254
259
|
};
|
|
@@ -10,19 +10,19 @@ export declare const zModelNameJSON: z.ZodString;
|
|
|
10
10
|
* `@@index`), with optional `map` to pin the database constraint name.
|
|
11
11
|
*/
|
|
12
12
|
export declare const zModelIndexJSON: z.ZodUnion<readonly [z.ZodPipe<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">>, z.ZodTransform<{
|
|
13
|
-
fields: (string & z
|
|
13
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
14
14
|
unique: boolean;
|
|
15
15
|
map: string | undefined;
|
|
16
|
-
}, (string & z
|
|
16
|
+
}, (string & z.$brand<"PXL.FieldName">)[]>>, z.ZodPipe<z.ZodObject<{
|
|
17
17
|
fields: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">>;
|
|
18
18
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
19
19
|
map: z.ZodOptional<z.ZodString>;
|
|
20
20
|
}, z.core.$strip>, z.ZodTransform<{
|
|
21
|
-
fields: (string & z
|
|
21
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
22
22
|
unique: boolean;
|
|
23
23
|
map: string | undefined;
|
|
24
24
|
}, {
|
|
25
|
-
fields: (string & z
|
|
25
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
26
26
|
unique?: boolean | undefined;
|
|
27
27
|
map?: string | undefined;
|
|
28
28
|
}>>]>;
|
|
@@ -70,19 +70,19 @@ export declare const zModelJSON: z.ZodPreprocess<z.ZodObject<{
|
|
|
70
70
|
keyField: z.ZodOptional<z.ZodString>;
|
|
71
71
|
defaultSort: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">>>;
|
|
72
72
|
indexes: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodPipe<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">>, z.ZodTransform<{
|
|
73
|
-
fields: (string & z
|
|
73
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
74
74
|
unique: boolean;
|
|
75
75
|
map: string | undefined;
|
|
76
|
-
}, (string & z
|
|
76
|
+
}, (string & z.$brand<"PXL.FieldName">)[]>>, z.ZodPipe<z.ZodObject<{
|
|
77
77
|
fields: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">>;
|
|
78
78
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
79
79
|
map: z.ZodOptional<z.ZodString>;
|
|
80
80
|
}, z.core.$strip>, z.ZodTransform<{
|
|
81
|
-
fields: (string & z
|
|
81
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
82
82
|
unique: boolean;
|
|
83
83
|
map: string | undefined;
|
|
84
84
|
}, {
|
|
85
|
-
fields: (string & z
|
|
85
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
86
86
|
unique?: boolean | undefined;
|
|
87
87
|
map?: string | undefined;
|
|
88
88
|
}>>]>>>;
|
|
@@ -1,40 +1,6 @@
|
|
|
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.core.$brand<"PXL.FieldName">, unknown>;
|
|
5
|
-
/**
|
|
6
|
-
* We also provide a list of field names to keep the original order
|
|
7
|
-
*/
|
|
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
|
-
labelQualifier: {
|
|
15
|
-
relationFieldName: string & z.core.$brand<"PXL.FieldName">;
|
|
16
|
-
separator: string | undefined;
|
|
17
|
-
} | undefined;
|
|
18
|
-
keyFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
|
|
19
|
-
defaultSort: (string & z.core.$brand<"PXL.FieldName">)[] | undefined;
|
|
20
|
-
isReadonly: boolean;
|
|
21
|
-
exposeRestApi: boolean;
|
|
22
|
-
excelName: string;
|
|
23
|
-
description: string;
|
|
24
|
-
indexes: ({
|
|
25
|
-
fields: (string & z.core.$brand<"PXL.FieldName">)[];
|
|
26
|
-
unique: boolean;
|
|
27
|
-
map: string | undefined;
|
|
28
|
-
} | {
|
|
29
|
-
fields: (string & z.core.$brand<"PXL.FieldName">)[];
|
|
30
|
-
unique: boolean;
|
|
31
|
-
map: string | undefined;
|
|
32
|
-
})[];
|
|
33
|
-
seed: any[];
|
|
34
|
-
faker: {
|
|
35
|
-
seed: number;
|
|
36
|
-
items: number;
|
|
37
|
-
};
|
|
38
4
|
auth?: {
|
|
39
5
|
read?: {
|
|
40
6
|
anyRole: string[];
|
|
@@ -59,37 +25,43 @@ export declare function modelJSONTransformer(input: ModelJSON, ctx: z.Refinement
|
|
|
59
25
|
} | undefined;
|
|
60
26
|
} | undefined;
|
|
61
27
|
source?: Record<string, unknown> | undefined;
|
|
62
|
-
};
|
|
63
|
-
export type ModelEnriched = ReturnType<typeof modelJSONTransformer>;
|
|
64
|
-
declare function addDefaults({ description, fields, standardFields, seed, faker, ...input }: ModelJSON): {
|
|
65
28
|
isReadonly: boolean;
|
|
66
29
|
exposeRestApi: boolean;
|
|
67
|
-
databaseName: string;
|
|
68
30
|
excelName: string;
|
|
69
31
|
description: string;
|
|
70
|
-
fields: {
|
|
71
|
-
[x: string]: unknown;
|
|
72
|
-
name: string;
|
|
73
|
-
}[];
|
|
74
|
-
standardFields: string[];
|
|
75
32
|
indexes: ({
|
|
76
|
-
fields: (string & z
|
|
33
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
77
34
|
unique: boolean;
|
|
78
35
|
map: string | undefined;
|
|
79
36
|
} | {
|
|
80
|
-
fields: (string & z
|
|
37
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
81
38
|
unique: boolean;
|
|
82
39
|
map: string | undefined;
|
|
83
40
|
})[];
|
|
84
41
|
seed: any[];
|
|
85
|
-
labelQualifier: {
|
|
86
|
-
relation: string;
|
|
87
|
-
separator: string | undefined;
|
|
88
|
-
} | undefined;
|
|
89
42
|
faker: {
|
|
90
43
|
seed: number;
|
|
91
44
|
items: number;
|
|
92
45
|
};
|
|
46
|
+
name: string & z.$brand<"PXL.ModelName">;
|
|
47
|
+
schema: (string & z.$brand<"PXL.DatabaseSchemaName">) | undefined;
|
|
48
|
+
databaseName: string & z.$brand<"PXL.DatabaseModelName">;
|
|
49
|
+
defaultFieldName: (string & z.$brand<"PXL.FieldName">) | undefined;
|
|
50
|
+
labelFieldName: (string & z.$brand<"PXL.FieldName">) | undefined;
|
|
51
|
+
labelQualifier: {
|
|
52
|
+
relationFieldName: string & z.$brand<"PXL.FieldName">;
|
|
53
|
+
separator: string | undefined;
|
|
54
|
+
} | undefined;
|
|
55
|
+
keyFieldName: (string & z.$brand<"PXL.FieldName">) | undefined;
|
|
56
|
+
defaultSort: (string & z.$brand<"PXL.FieldName">)[] | undefined;
|
|
57
|
+
fields: Record<string & z.$brand<"PXL.FieldName">, unknown>;
|
|
58
|
+
/**
|
|
59
|
+
* We also provide a list of field names to keep the original order
|
|
60
|
+
*/
|
|
61
|
+
fieldNames: (string & z.$brand<"PXL.FieldName">)[];
|
|
62
|
+
};
|
|
63
|
+
export type ModelEnriched = ReturnType<typeof modelJSONTransformer>;
|
|
64
|
+
declare function addDefaults({ description, fields, standardFields, seed, faker, ...input }: ModelJSON): {
|
|
93
65
|
name: string;
|
|
94
66
|
auth?: {
|
|
95
67
|
read?: {
|
|
@@ -118,45 +90,39 @@ declare function addDefaults({ description, fields, standardFields, seed, faker,
|
|
|
118
90
|
defaultField?: string | undefined;
|
|
119
91
|
labelField?: string | undefined;
|
|
120
92
|
keyField?: string | undefined;
|
|
121
|
-
defaultSort?: (string & z
|
|
93
|
+
defaultSort?: (string & z.$brand<"PXL.FieldName">)[] | undefined;
|
|
122
94
|
source?: Record<string, unknown> | undefined;
|
|
123
|
-
};
|
|
124
|
-
type WithDefaults = ReturnType<typeof addDefaults>;
|
|
125
|
-
declare function brandModel({ name, schema, databaseName, standardFields, defaultField, labelField, labelQualifier, keyField, defaultSort, ...input }: WithDefaults): {
|
|
126
|
-
name: string & z.core.$brand<"PXL.ModelName">;
|
|
127
|
-
schema: (string & z.core.$brand<"PXL.DatabaseSchemaName">) | undefined;
|
|
128
|
-
databaseName: string & z.core.$brand<"PXL.DatabaseModelName">;
|
|
129
|
-
standardFields: (string & z.core.$brand<"PXL.FieldName">)[];
|
|
130
|
-
defaultFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
|
|
131
|
-
labelFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
|
|
132
|
-
labelQualifier: {
|
|
133
|
-
relationFieldName: string & z.core.$brand<"PXL.FieldName">;
|
|
134
|
-
separator: string | undefined;
|
|
135
|
-
} | undefined;
|
|
136
|
-
keyFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
|
|
137
|
-
defaultSort: (string & z.core.$brand<"PXL.FieldName">)[] | undefined;
|
|
138
95
|
isReadonly: boolean;
|
|
139
96
|
exposeRestApi: boolean;
|
|
97
|
+
databaseName: string;
|
|
140
98
|
excelName: string;
|
|
141
99
|
description: string;
|
|
142
100
|
fields: {
|
|
143
101
|
[x: string]: unknown;
|
|
144
102
|
name: string;
|
|
145
103
|
}[];
|
|
104
|
+
standardFields: string[];
|
|
146
105
|
indexes: ({
|
|
147
|
-
fields: (string & z
|
|
106
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
148
107
|
unique: boolean;
|
|
149
108
|
map: string | undefined;
|
|
150
109
|
} | {
|
|
151
|
-
fields: (string & z
|
|
110
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
152
111
|
unique: boolean;
|
|
153
112
|
map: string | undefined;
|
|
154
113
|
})[];
|
|
155
114
|
seed: any[];
|
|
115
|
+
labelQualifier: {
|
|
116
|
+
relation: string;
|
|
117
|
+
separator: string | undefined;
|
|
118
|
+
} | undefined;
|
|
156
119
|
faker: {
|
|
157
120
|
seed: number;
|
|
158
121
|
items: number;
|
|
159
122
|
};
|
|
123
|
+
};
|
|
124
|
+
type WithDefaults = ReturnType<typeof addDefaults>;
|
|
125
|
+
declare function brandModel({ name, schema, databaseName, standardFields, defaultField, labelField, labelQualifier, keyField, defaultSort, ...input }: WithDefaults): {
|
|
160
126
|
auth?: {
|
|
161
127
|
read?: {
|
|
162
128
|
anyRole: string[];
|
|
@@ -181,35 +147,20 @@ declare function brandModel({ name, schema, databaseName, standardFields, defaul
|
|
|
181
147
|
} | undefined;
|
|
182
148
|
} | undefined;
|
|
183
149
|
source?: Record<string, unknown> | undefined;
|
|
184
|
-
};
|
|
185
|
-
type BrandedModel = ReturnType<typeof brandModel>;
|
|
186
|
-
declare function combineFields({ fields, standardFields, ...model }: BrandedModel, ctx: z.RefinementCtx): {
|
|
187
|
-
fields: Record<string & z.core.$brand<"PXL.FieldName">, unknown>;
|
|
188
|
-
/**
|
|
189
|
-
* We also provide a list of field names to keep the original order
|
|
190
|
-
*/
|
|
191
|
-
fieldNames: (string & z.core.$brand<"PXL.FieldName">)[];
|
|
192
|
-
name: string & z.core.$brand<"PXL.ModelName">;
|
|
193
|
-
schema: (string & z.core.$brand<"PXL.DatabaseSchemaName">) | undefined;
|
|
194
|
-
databaseName: string & z.core.$brand<"PXL.DatabaseModelName">;
|
|
195
|
-
defaultFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
|
|
196
|
-
labelFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
|
|
197
|
-
labelQualifier: {
|
|
198
|
-
relationFieldName: string & z.core.$brand<"PXL.FieldName">;
|
|
199
|
-
separator: string | undefined;
|
|
200
|
-
} | undefined;
|
|
201
|
-
keyFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
|
|
202
|
-
defaultSort: (string & z.core.$brand<"PXL.FieldName">)[] | undefined;
|
|
203
150
|
isReadonly: boolean;
|
|
204
151
|
exposeRestApi: boolean;
|
|
205
152
|
excelName: string;
|
|
206
153
|
description: string;
|
|
154
|
+
fields: {
|
|
155
|
+
[x: string]: unknown;
|
|
156
|
+
name: string;
|
|
157
|
+
}[];
|
|
207
158
|
indexes: ({
|
|
208
|
-
fields: (string & z
|
|
159
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
209
160
|
unique: boolean;
|
|
210
161
|
map: string | undefined;
|
|
211
162
|
} | {
|
|
212
|
-
fields: (string & z
|
|
163
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
213
164
|
unique: boolean;
|
|
214
165
|
map: string | undefined;
|
|
215
166
|
})[];
|
|
@@ -218,6 +169,21 @@ declare function combineFields({ fields, standardFields, ...model }: BrandedMode
|
|
|
218
169
|
seed: number;
|
|
219
170
|
items: number;
|
|
220
171
|
};
|
|
172
|
+
name: string & z.$brand<"PXL.ModelName">;
|
|
173
|
+
schema: (string & z.$brand<"PXL.DatabaseSchemaName">) | undefined;
|
|
174
|
+
databaseName: string & z.$brand<"PXL.DatabaseModelName">;
|
|
175
|
+
standardFields: (string & z.$brand<"PXL.FieldName">)[];
|
|
176
|
+
defaultFieldName: (string & z.$brand<"PXL.FieldName">) | undefined;
|
|
177
|
+
labelFieldName: (string & z.$brand<"PXL.FieldName">) | undefined;
|
|
178
|
+
labelQualifier: {
|
|
179
|
+
relationFieldName: string & z.$brand<"PXL.FieldName">;
|
|
180
|
+
separator: string | undefined;
|
|
181
|
+
} | undefined;
|
|
182
|
+
keyFieldName: (string & z.$brand<"PXL.FieldName">) | undefined;
|
|
183
|
+
defaultSort: (string & z.$brand<"PXL.FieldName">)[] | undefined;
|
|
184
|
+
};
|
|
185
|
+
type BrandedModel = ReturnType<typeof brandModel>;
|
|
186
|
+
declare function combineFields({ fields, standardFields, ...model }: BrandedModel, ctx: z.RefinementCtx): {
|
|
221
187
|
auth?: {
|
|
222
188
|
read?: {
|
|
223
189
|
anyRole: string[];
|
|
@@ -242,6 +208,40 @@ declare function combineFields({ fields, standardFields, ...model }: BrandedMode
|
|
|
242
208
|
} | undefined;
|
|
243
209
|
} | undefined;
|
|
244
210
|
source?: Record<string, unknown> | undefined;
|
|
211
|
+
isReadonly: boolean;
|
|
212
|
+
exposeRestApi: boolean;
|
|
213
|
+
excelName: string;
|
|
214
|
+
description: string;
|
|
215
|
+
indexes: ({
|
|
216
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
217
|
+
unique: boolean;
|
|
218
|
+
map: string | undefined;
|
|
219
|
+
} | {
|
|
220
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
221
|
+
unique: boolean;
|
|
222
|
+
map: string | undefined;
|
|
223
|
+
})[];
|
|
224
|
+
seed: any[];
|
|
225
|
+
faker: {
|
|
226
|
+
seed: number;
|
|
227
|
+
items: number;
|
|
228
|
+
};
|
|
229
|
+
name: string & z.$brand<"PXL.ModelName">;
|
|
230
|
+
schema: (string & z.$brand<"PXL.DatabaseSchemaName">) | undefined;
|
|
231
|
+
databaseName: string & z.$brand<"PXL.DatabaseModelName">;
|
|
232
|
+
defaultFieldName: (string & z.$brand<"PXL.FieldName">) | undefined;
|
|
233
|
+
labelFieldName: (string & z.$brand<"PXL.FieldName">) | undefined;
|
|
234
|
+
labelQualifier: {
|
|
235
|
+
relationFieldName: string & z.$brand<"PXL.FieldName">;
|
|
236
|
+
separator: string | undefined;
|
|
237
|
+
} | undefined;
|
|
238
|
+
keyFieldName: (string & z.$brand<"PXL.FieldName">) | undefined;
|
|
239
|
+
defaultSort: (string & z.$brand<"PXL.FieldName">)[] | undefined;
|
|
240
|
+
fields: Record<string & z.$brand<"PXL.FieldName">, unknown>;
|
|
241
|
+
/**
|
|
242
|
+
* We also provide a list of field names to keep the original order
|
|
243
|
+
*/
|
|
244
|
+
fieldNames: (string & z.$brand<"PXL.FieldName">)[];
|
|
245
245
|
};
|
|
246
246
|
export type CombinedFields = ReturnType<typeof combineFields>;
|
|
247
247
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
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
|
|
4
|
+
export declare const toProjectSchemaName: (input: string) => string & z.$brand<"PXL.ProjectSchemaName">;
|
|
5
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
|
|
7
|
+
export declare const toProjectSlug: (input: string) => string & z.$brand<"PXL.ProjectSlug">;
|
|
8
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.$brand<"PXL.DatabaseSchemaName">;
|
|
@@ -10,7 +10,7 @@ export declare const databaseSchemaNameConfig: string & import("zod").$brand<"PX
|
|
|
10
10
|
/**
|
|
11
11
|
* The default project roles. Can be overridden via `defaultRoles` in the project schema.
|
|
12
12
|
*/
|
|
13
|
-
export declare const defaultProjectRoles: readonly [
|
|
13
|
+
export declare const defaultProjectRoles: readonly ['superadmin', 'admin', 'editor', 'viewer'];
|
|
14
14
|
export declare const defaultSystemUser: {
|
|
15
15
|
id: string;
|
|
16
16
|
sub: null;
|
|
@@ -26,6 +26,10 @@ export declare const zSchemaJSON: z.ZodObject<{
|
|
|
26
26
|
}, z.core.$strip>>;
|
|
27
27
|
}, z.core.$strip>>;
|
|
28
28
|
}, z.core.$strip>;
|
|
29
|
+
export declare const zDefaultRepositoryType: z.ZodEnum<{
|
|
30
|
+
DatabaseCached: "DatabaseCached";
|
|
31
|
+
DatabaseDirect: "DatabaseDirect";
|
|
32
|
+
}>;
|
|
29
33
|
export declare const zProjectSchemaJSON: z.ZodPreprocess<z.ZodObject<{
|
|
30
34
|
name: z.ZodString;
|
|
31
35
|
slug: z.ZodString;
|
|
@@ -59,6 +63,10 @@ export declare const zProjectSchemaJSON: z.ZodPreprocess<z.ZodObject<{
|
|
|
59
63
|
}, z.core.$strip>>;
|
|
60
64
|
}, z.core.$strip>]>>>;
|
|
61
65
|
defaultSchema: z.ZodOptional<z.ZodString>;
|
|
66
|
+
defaultRepositoryType: z.ZodOptional<z.ZodEnum<{
|
|
67
|
+
DatabaseCached: "DatabaseCached";
|
|
68
|
+
DatabaseDirect: "DatabaseDirect";
|
|
69
|
+
}>>;
|
|
62
70
|
defaultLabelSeparator: z.ZodOptional<z.ZodString>;
|
|
63
71
|
auth: z.ZodOptional<z.ZodObject<{
|
|
64
72
|
provider: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"keycloak">>>;
|
|
@@ -117,19 +125,19 @@ export declare const zProjectSchemaJSON: z.ZodPreprocess<z.ZodObject<{
|
|
|
117
125
|
keyField: z.ZodOptional<z.ZodString>;
|
|
118
126
|
defaultSort: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">>>;
|
|
119
127
|
indexes: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodPipe<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">>, z.ZodTransform<{
|
|
120
|
-
fields: (string & z
|
|
128
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
121
129
|
unique: boolean;
|
|
122
130
|
map: string | undefined;
|
|
123
|
-
}, (string & z
|
|
131
|
+
}, (string & z.$brand<"PXL.FieldName">)[]>>, z.ZodPipe<z.ZodObject<{
|
|
124
132
|
fields: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">>;
|
|
125
133
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
126
134
|
map: z.ZodOptional<z.ZodString>;
|
|
127
135
|
}, z.core.$strip>, z.ZodTransform<{
|
|
128
|
-
fields: (string & z
|
|
136
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
129
137
|
unique: boolean;
|
|
130
138
|
map: string | undefined;
|
|
131
139
|
}, {
|
|
132
|
-
fields: (string & z
|
|
140
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
133
141
|
unique?: boolean | undefined;
|
|
134
142
|
map?: string | undefined;
|
|
135
143
|
}>>]>>>;
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.zProjectSchemaJSON = exports.zSchemaJSON = exports.zSchemaName = void 0;
|
|
36
|
+
exports.zProjectSchemaJSON = exports.zDefaultRepositoryType = exports.zSchemaJSON = exports.zSchemaName = void 0;
|
|
37
37
|
const zod_1 = require("zod");
|
|
38
38
|
const utils_1 = require("@postxl/utils");
|
|
39
39
|
const Enum = __importStar(require("../enum"));
|
|
@@ -51,6 +51,7 @@ exports.zSchemaJSON = zod_1.z.object({
|
|
|
51
51
|
name: exports.zSchemaName,
|
|
52
52
|
auth: project_schema_auth_1.zAuthRuleSetJSON.optional(),
|
|
53
53
|
});
|
|
54
|
+
exports.zDefaultRepositoryType = zod_1.z.enum(['DatabaseDirect', 'DatabaseCached']);
|
|
54
55
|
exports.zProjectSchemaJSON = zod_1.z
|
|
55
56
|
// We want to keep any extra fields that are not defined in the schema. However, these fields should
|
|
56
57
|
// not really be exposed as "main fields" of the parsed schema - instead, they should be nested under
|
|
@@ -116,6 +117,10 @@ exports.zProjectSchemaJSON = zod_1.z
|
|
|
116
117
|
//
|
|
117
118
|
.optional()
|
|
118
119
|
.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.`),
|
|
120
|
+
defaultRepositoryType: exports.zDefaultRepositoryType
|
|
121
|
+
//
|
|
122
|
+
.optional()
|
|
123
|
+
.describe(`The default repository type used for models that omit \`repository.type\` ("DatabaseDirect" or "DatabaseCached"). Defaults to "DatabaseCached" when omitted.`),
|
|
119
124
|
defaultLabelSeparator: zod_1.z
|
|
120
125
|
//
|
|
121
126
|
.string()
|
|
@@ -38,6 +38,10 @@ export declare const zProjectSchema: z.ZodPipe<z.ZodPreprocess<z.ZodObject<{
|
|
|
38
38
|
}, z.core.$strip>>;
|
|
39
39
|
}, z.core.$strip>]>>>;
|
|
40
40
|
defaultSchema: z.ZodOptional<z.ZodString>;
|
|
41
|
+
defaultRepositoryType: z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
DatabaseCached: "DatabaseCached";
|
|
43
|
+
DatabaseDirect: "DatabaseDirect";
|
|
44
|
+
}>>;
|
|
41
45
|
defaultLabelSeparator: z.ZodOptional<z.ZodString>;
|
|
42
46
|
auth: z.ZodOptional<z.ZodObject<{
|
|
43
47
|
provider: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"keycloak">>>;
|
|
@@ -96,19 +100,19 @@ export declare const zProjectSchema: z.ZodPipe<z.ZodPreprocess<z.ZodObject<{
|
|
|
96
100
|
keyField: z.ZodOptional<z.ZodString>;
|
|
97
101
|
defaultSort: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">>>;
|
|
98
102
|
indexes: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodPipe<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">>, z.ZodTransform<{
|
|
99
|
-
fields: (string & z
|
|
103
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
100
104
|
unique: boolean;
|
|
101
105
|
map: string | undefined;
|
|
102
|
-
}, (string & z
|
|
106
|
+
}, (string & z.$brand<"PXL.FieldName">)[]>>, z.ZodPipe<z.ZodObject<{
|
|
103
107
|
fields: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">>;
|
|
104
108
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
105
109
|
map: z.ZodOptional<z.ZodString>;
|
|
106
110
|
}, z.core.$strip>, z.ZodTransform<{
|
|
107
|
-
fields: (string & z
|
|
111
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
108
112
|
unique: boolean;
|
|
109
113
|
map: string | undefined;
|
|
110
114
|
}, {
|
|
111
|
-
fields: (string & z
|
|
115
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
112
116
|
unique?: boolean | undefined;
|
|
113
117
|
map?: string | undefined;
|
|
114
118
|
}>>]>>>;
|
|
@@ -136,9 +140,8 @@ export declare const zProjectSchema: z.ZodPipe<z.ZodPreprocess<z.ZodObject<{
|
|
|
136
140
|
}, z.core.$strip>>, z.ZodTransform<ProjectSchema, {
|
|
137
141
|
name: string;
|
|
138
142
|
slug: string;
|
|
139
|
-
projectType: "standalone" | "workspace";
|
|
140
|
-
source: Record<string, unknown>;
|
|
141
143
|
description?: string | undefined;
|
|
144
|
+
projectType: "standalone" | "workspace";
|
|
142
145
|
version?: string | undefined;
|
|
143
146
|
schemas?: (string | {
|
|
144
147
|
name: string;
|
|
@@ -167,6 +170,7 @@ export declare const zProjectSchema: z.ZodPipe<z.ZodPreprocess<z.ZodObject<{
|
|
|
167
170
|
} | undefined;
|
|
168
171
|
})[] | undefined;
|
|
169
172
|
defaultSchema?: string | undefined;
|
|
173
|
+
defaultRepositoryType?: "DatabaseCached" | "DatabaseDirect" | undefined;
|
|
170
174
|
defaultLabelSeparator?: string | undefined;
|
|
171
175
|
auth?: {
|
|
172
176
|
provider: "keycloak";
|
|
@@ -224,13 +228,13 @@ export declare const zProjectSchema: z.ZodPipe<z.ZodPreprocess<z.ZodObject<{
|
|
|
224
228
|
separator?: string | undefined;
|
|
225
229
|
} | undefined;
|
|
226
230
|
keyField?: string | undefined;
|
|
227
|
-
defaultSort?: (string & z
|
|
231
|
+
defaultSort?: (string & z.$brand<"PXL.FieldName">)[] | undefined;
|
|
228
232
|
indexes?: ({
|
|
229
|
-
fields: (string & z
|
|
233
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
230
234
|
unique: boolean;
|
|
231
235
|
map: string | undefined;
|
|
232
236
|
} | {
|
|
233
|
-
fields: (string & z
|
|
237
|
+
fields: (string & z.$brand<"PXL.FieldName">)[];
|
|
234
238
|
unique: boolean;
|
|
235
239
|
map: string | undefined;
|
|
236
240
|
})[] | undefined;
|
|
@@ -245,13 +249,14 @@ export declare const zProjectSchema: z.ZodPipe<z.ZodPreprocess<z.ZodObject<{
|
|
|
245
249
|
enums?: {
|
|
246
250
|
name: string;
|
|
247
251
|
description: string;
|
|
252
|
+
schema?: string | undefined;
|
|
253
|
+
databaseName?: string | undefined;
|
|
248
254
|
members: (string | {
|
|
249
255
|
value: string;
|
|
250
256
|
description?: string | undefined;
|
|
251
257
|
})[];
|
|
252
|
-
schema?: string | undefined;
|
|
253
|
-
databaseName?: string | undefined;
|
|
254
258
|
}[] | undefined;
|
|
255
259
|
modelFiles?: string[] | undefined;
|
|
256
260
|
enumFiles?: string[] | undefined;
|
|
261
|
+
source: Record<string, unknown>;
|
|
257
262
|
}>>;
|
|
@@ -95,6 +95,7 @@ function addDefaults(input) {
|
|
|
95
95
|
schemas,
|
|
96
96
|
schemaAuth,
|
|
97
97
|
defaultSchema,
|
|
98
|
+
...(input.defaultRepositoryType ? { defaultRepositoryType: input.defaultRepositoryType } : {}),
|
|
98
99
|
defaultLabelSeparator: input.defaultLabelSeparator,
|
|
99
100
|
...(input.auth ? { auth: input.auth } : {}),
|
|
100
101
|
systemUser: {
|
|
@@ -292,19 +293,15 @@ function transformModels(projectSchema, ctx) {
|
|
|
292
293
|
// `defaultLabelSeparator` is only a fallback consulted while resolving each model's
|
|
293
294
|
// `labelQualifier.separator` above; it is fully resolved by this point and must not leak
|
|
294
295
|
// into the output (consumers never re-resolve it against project defaults).
|
|
295
|
-
const { auth, defaultLabelSeparator: _defaultLabelSeparatorInput, ...remainingProjectSchema } = projectSchema;
|
|
296
|
-
// Keep optional field shape clean: only include
|
|
297
|
-
// instead of returning `
|
|
298
|
-
return
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
: {
|
|
305
|
-
...remainingProjectSchema,
|
|
306
|
-
models,
|
|
307
|
-
};
|
|
296
|
+
const { auth, defaultRepositoryType, defaultLabelSeparator: _defaultLabelSeparatorInput, ...remainingProjectSchema } = projectSchema;
|
|
297
|
+
// Keep optional field shape clean: only include optional fields when actually set,
|
|
298
|
+
// instead of returning `field: undefined`.
|
|
299
|
+
return {
|
|
300
|
+
...remainingProjectSchema,
|
|
301
|
+
...(auth ? { auth } : {}),
|
|
302
|
+
...(defaultRepositoryType ? { defaultRepositoryType } : {}),
|
|
303
|
+
models,
|
|
304
|
+
};
|
|
308
305
|
}
|
|
309
306
|
/**
|
|
310
307
|
* Rejects circular label-qualifier chains (e.g. Session qualified by Project qualified by
|
|
@@ -40,6 +40,12 @@ export type ProjectSchema = {
|
|
|
40
40
|
* If not provided, the default schema "Data" is used.
|
|
41
41
|
*/
|
|
42
42
|
defaultDatabaseSchema: Branded.DatabaseSchemaName;
|
|
43
|
+
/**
|
|
44
|
+
* The default repository type used for models that do not specify `repository.type`.
|
|
45
|
+
*
|
|
46
|
+
* If not provided, models default to `'DatabaseCached'` for backwards compatibility.
|
|
47
|
+
*/
|
|
48
|
+
defaultRepositoryType?: DefaultRepositoryType;
|
|
43
49
|
/**
|
|
44
50
|
* The default roles for this project. Roles from auth rules are added on top of these.
|
|
45
51
|
* If not provided in the schema, defaults to ['superadmin', 'admin', 'editor', 'viewer'].
|
|
@@ -81,6 +87,7 @@ export type ProjectSchema = {
|
|
|
81
87
|
source: Record<string, unknown>;
|
|
82
88
|
};
|
|
83
89
|
export type ProjectType = 'standalone' | 'workspace';
|
|
90
|
+
export type DefaultRepositoryType = 'DatabaseDirect' | 'DatabaseCached';
|
|
84
91
|
export type SystemUser = Record<string, unknown> & {
|
|
85
92
|
id: string;
|
|
86
93
|
};
|