@postxl/schema 1.8.1 → 1.9.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/field/field.d.ts +3 -0
- package/dist/field/scalar.d.ts +8 -0
- package/dist/field/scalar.js +51 -1
- package/dist/field/shared/decoders.d.ts +1 -0
- package/dist/field/shared/decoders.js +5 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/project-schema/project-schema.defaults.d.ts +4 -0
- package/dist/project-schema/project-schema.defaults.js +5 -1
- package/dist/project-schema/project-schema.json-decoder.d.ts +1 -0
- package/dist/project-schema/project-schema.json-decoder.js +6 -0
- package/dist/project-schema/project-schema.transformer.d.ts +2 -0
- package/dist/project-schema/project-schema.transformer.js +1 -0
- package/dist/project-schema/project-schema.types.d.ts +5 -0
- package/dist/samples/paxl.schema.json +897 -0
- package/dist/samples/sample-schemas.d.ts +902 -0
- package/dist/samples/sample-schemas.js +2 -0
- package/package.json +1 -1
package/dist/field/field.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export declare const createFieldJSONDecoder: (params: {
|
|
|
66
66
|
faker: z.ZodOptional<z.ZodString>;
|
|
67
67
|
seed: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>>]>>;
|
|
68
68
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
69
|
+
defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
69
70
|
}, z.core.$strict>, z.ZodTransform<FieldScalarEnriched, {
|
|
70
71
|
name: string;
|
|
71
72
|
type: "BigInt" | "String" | "Boolean" | "DateTime" | "Decimal" | "Float" | "Int" | "Bytes" | "String?" | "Boolean?" | "DateTime?" | "Decimal?" | "Float?" | "Int?" | "Bytes?" | "BigInt?";
|
|
@@ -82,6 +83,7 @@ export declare const createFieldJSONDecoder: (params: {
|
|
|
82
83
|
faker?: string | undefined;
|
|
83
84
|
seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
|
|
84
85
|
placeholder?: string | undefined;
|
|
86
|
+
defaultValue?: string | number | boolean | undefined;
|
|
85
87
|
}>>, z.ZodPipe<z.ZodObject<{
|
|
86
88
|
name: z.ZodString;
|
|
87
89
|
type: z.ZodUnion<readonly [z.ZodLiteral<"Json">, z.ZodLiteral<"JSON">, z.ZodLiteral<"Json?">, z.ZodLiteral<"JSON?">]>;
|
|
@@ -248,6 +250,7 @@ export declare const zFieldJSONInput: (params: {
|
|
|
248
250
|
faker: z.ZodOptional<z.ZodString>;
|
|
249
251
|
seed: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>>]>>;
|
|
250
252
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
253
|
+
defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
251
254
|
}, z.core.$strict>, z.ZodObject<{
|
|
252
255
|
name: z.ZodString;
|
|
253
256
|
type: z.ZodUnion<readonly [z.ZodLiteral<"Json">, z.ZodLiteral<"JSON">, z.ZodLiteral<"Json?">, z.ZodLiteral<"JSON?">]>;
|
package/dist/field/scalar.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ type FieldCommonScalar = {
|
|
|
33
33
|
type FieldScalarStringWithValidations = {
|
|
34
34
|
type: 'string';
|
|
35
35
|
validations: ValidationString;
|
|
36
|
+
defaultValue: string | undefined;
|
|
36
37
|
};
|
|
37
38
|
type ValidationString = {
|
|
38
39
|
maxLength: number | undefined;
|
|
@@ -40,6 +41,7 @@ type ValidationString = {
|
|
|
40
41
|
type FieldScalarNumberWithValidations = {
|
|
41
42
|
type: 'number';
|
|
42
43
|
validations: ValidationNumber;
|
|
44
|
+
defaultValue: number | undefined;
|
|
43
45
|
};
|
|
44
46
|
type ValidationNumber = {
|
|
45
47
|
type: 'int' | 'float';
|
|
@@ -48,9 +50,11 @@ type ValidationNumber = {
|
|
|
48
50
|
};
|
|
49
51
|
type FieldScalarBooleanNoValidation = {
|
|
50
52
|
type: 'boolean';
|
|
53
|
+
defaultValue: boolean | undefined;
|
|
51
54
|
};
|
|
52
55
|
type FieldScalarDateNoValidation = {
|
|
53
56
|
type: 'Date';
|
|
57
|
+
defaultValue: string | undefined;
|
|
54
58
|
};
|
|
55
59
|
/**
|
|
56
60
|
* JSON Schema for an scalar field
|
|
@@ -71,12 +75,14 @@ export declare const zFieldScalarJSON: z.ZodObject<{
|
|
|
71
75
|
faker: z.ZodOptional<z.ZodString>;
|
|
72
76
|
seed: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>>]>>;
|
|
73
77
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
78
|
+
defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
74
79
|
}, z.core.$strict>;
|
|
75
80
|
export type FieldScalarJSON = z.infer<typeof zFieldScalarJSON>;
|
|
76
81
|
export declare function fieldScalarJSONTransformer(fieldInput: FieldScalarJSON, ctx: z.RefinementCtx): FieldScalarEnriched;
|
|
77
82
|
export type FieldScalarEnriched = Omit<FieldCommon<FieldKindScalar>, 'modelName'> & FieldCommonScalar & {
|
|
78
83
|
type: Branded.ScalarType;
|
|
79
84
|
validations: Partial<ValidationString & ValidationNumber>;
|
|
85
|
+
defaultValue: string | number | boolean | undefined;
|
|
80
86
|
};
|
|
81
87
|
export declare const zFieldScalar: z.ZodPipe<z.ZodObject<{
|
|
82
88
|
name: z.ZodString;
|
|
@@ -94,6 +100,7 @@ export declare const zFieldScalar: z.ZodPipe<z.ZodObject<{
|
|
|
94
100
|
faker: z.ZodOptional<z.ZodString>;
|
|
95
101
|
seed: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>>]>>;
|
|
96
102
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
103
|
+
defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
97
104
|
}, z.core.$strict>, z.ZodTransform<FieldScalarEnriched, {
|
|
98
105
|
name: string;
|
|
99
106
|
type: "BigInt" | "String" | "Boolean" | "DateTime" | "Decimal" | "Float" | "Int" | "Bytes" | "String?" | "Boolean?" | "DateTime?" | "Decimal?" | "Float?" | "Int?" | "Bytes?" | "BigInt?";
|
|
@@ -110,6 +117,7 @@ export declare const zFieldScalar: z.ZodPipe<z.ZodObject<{
|
|
|
110
117
|
faker?: string | undefined;
|
|
111
118
|
seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
|
|
112
119
|
placeholder?: string | undefined;
|
|
120
|
+
defaultValue?: string | number | boolean | undefined;
|
|
113
121
|
}>>;
|
|
114
122
|
export declare const fieldScalarTransformer: FieldTransformer<FieldKindScalar, FieldScalarEnriched, FieldScalar>;
|
|
115
123
|
export {};
|
package/dist/field/scalar.js
CHANGED
|
@@ -105,6 +105,7 @@ exports.zFieldScalarJSON = zod_1.z
|
|
|
105
105
|
faker: Decoders.zFieldFaker,
|
|
106
106
|
seed: Decoders.zFieldSeed,
|
|
107
107
|
placeholder: Decoders.zFieldPropertyPlaceholder,
|
|
108
|
+
defaultValue: Decoders.zFieldPropertyDefaultValue,
|
|
108
109
|
})
|
|
109
110
|
.strict();
|
|
110
111
|
const defaultPlaceholders = {
|
|
@@ -128,6 +129,50 @@ function fieldScalarJSONTransformer(fieldInput, ctx) {
|
|
|
128
129
|
const label = fieldInput.label ?? (0, utils_1.toHumanReadable)(fieldInput.name);
|
|
129
130
|
const placeholderFactory = defaultPlaceholders[scalarDatabaseType];
|
|
130
131
|
const placeholder = fieldInput.placeholder ?? placeholderFactory?.(label) ?? `${label} here...`;
|
|
132
|
+
// Validate defaultValue type matches the field type
|
|
133
|
+
const defaultValue = fieldInput.defaultValue;
|
|
134
|
+
if (defaultValue !== undefined) {
|
|
135
|
+
switch (type) {
|
|
136
|
+
case 'string':
|
|
137
|
+
if (typeof defaultValue !== 'string') {
|
|
138
|
+
ctx.addIssue({
|
|
139
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
140
|
+
message: `Default value for String field "${fieldInput.name}" must be a string, but got ${typeof defaultValue}.`,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
case 'number':
|
|
145
|
+
if (typeof defaultValue !== 'number') {
|
|
146
|
+
ctx.addIssue({
|
|
147
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
148
|
+
message: `Default value for numeric field "${fieldInput.name}" must be a number, but got ${typeof defaultValue}.`,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
case 'boolean':
|
|
153
|
+
if (typeof defaultValue !== 'boolean') {
|
|
154
|
+
ctx.addIssue({
|
|
155
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
156
|
+
message: `Default value for Boolean field "${fieldInput.name}" must be a boolean, but got ${typeof defaultValue}.`,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
case 'Date':
|
|
161
|
+
if (typeof defaultValue !== 'string') {
|
|
162
|
+
ctx.addIssue({
|
|
163
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
164
|
+
message: `Default value for DateTime field "${fieldInput.name}" must be an ISO date string, but got ${typeof defaultValue}.`,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
else if (isNaN(Date.parse(defaultValue))) {
|
|
168
|
+
ctx.addIssue({
|
|
169
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
170
|
+
message: `Default value for DateTime field "${fieldInput.name}" must be a valid ISO 8601 date string, but got "${defaultValue}".`,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
131
176
|
return {
|
|
132
177
|
type,
|
|
133
178
|
kind: exports.fieldKindScalar,
|
|
@@ -149,12 +194,13 @@ function fieldScalarJSONTransformer(fieldInput, ctx) {
|
|
|
149
194
|
min: undefined,
|
|
150
195
|
max: undefined,
|
|
151
196
|
},
|
|
197
|
+
defaultValue,
|
|
152
198
|
seed: (0, seed_1.seedTransformer)(fieldInput, ctx),
|
|
153
199
|
placeholder,
|
|
154
200
|
};
|
|
155
201
|
}
|
|
156
202
|
exports.zFieldScalar = exports.zFieldScalarJSON.transform(fieldScalarJSONTransformer);
|
|
157
|
-
const fieldScalarTransformer = ({ fieldInput: { type, validations, ...shared }, model: { name: modelName }, }) => {
|
|
203
|
+
const fieldScalarTransformer = ({ fieldInput: { type, validations, defaultValue, ...shared }, model: { name: modelName }, }) => {
|
|
158
204
|
switch (type) {
|
|
159
205
|
case 'string':
|
|
160
206
|
return {
|
|
@@ -162,6 +208,7 @@ const fieldScalarTransformer = ({ fieldInput: { type, validations, ...shared },
|
|
|
162
208
|
validations: {
|
|
163
209
|
maxLength: validations.maxLength,
|
|
164
210
|
},
|
|
211
|
+
defaultValue: defaultValue,
|
|
165
212
|
...shared,
|
|
166
213
|
modelName,
|
|
167
214
|
};
|
|
@@ -173,18 +220,21 @@ const fieldScalarTransformer = ({ fieldInput: { type, validations, ...shared },
|
|
|
173
220
|
min: validations.min,
|
|
174
221
|
max: validations.max,
|
|
175
222
|
},
|
|
223
|
+
defaultValue: defaultValue,
|
|
176
224
|
...shared,
|
|
177
225
|
modelName,
|
|
178
226
|
};
|
|
179
227
|
case 'boolean':
|
|
180
228
|
return {
|
|
181
229
|
type,
|
|
230
|
+
defaultValue: defaultValue,
|
|
182
231
|
...shared,
|
|
183
232
|
modelName,
|
|
184
233
|
};
|
|
185
234
|
case 'Date':
|
|
186
235
|
return {
|
|
187
236
|
type,
|
|
237
|
+
defaultValue: defaultValue,
|
|
188
238
|
...shared,
|
|
189
239
|
modelName,
|
|
190
240
|
};
|
|
@@ -15,3 +15,4 @@ export declare const zFieldFaker: z.ZodOptional<z.ZodString>;
|
|
|
15
15
|
export declare const zScalarValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>;
|
|
16
16
|
export declare const zFieldSeed: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>>]>>;
|
|
17
17
|
export declare const zFieldPropertyPlaceholder: z.ZodOptional<z.ZodString>;
|
|
18
|
+
export declare const zFieldPropertyDefaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.zFieldPropertyPlaceholder = exports.zFieldSeed = exports.zScalarValue = exports.zFieldFaker = 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.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;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const utils_1 = require("@postxl/utils");
|
|
6
6
|
exports.zFieldPropertyName = zod_1.z
|
|
@@ -88,3 +88,7 @@ exports.zFieldPropertyPlaceholder = zod_1.z
|
|
|
88
88
|
.string()
|
|
89
89
|
.optional()
|
|
90
90
|
.describe('A generic placeholder that is used to pre-populate empty fields.');
|
|
91
|
+
exports.zFieldPropertyDefaultValue = zod_1.z
|
|
92
|
+
.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean()])
|
|
93
|
+
.optional()
|
|
94
|
+
.describe('An optional default value for the field. Must match the field type: string for String fields, number for numeric fields, boolean for Boolean fields, ISO date string for DateTime fields.');
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { zProjectSchema } from './project-schema/project-schema.transformer';
|
|
|
2
2
|
export * from './project-schema/project-schema.auth';
|
|
3
3
|
export * from './project-schema/project-schema.brands';
|
|
4
4
|
export * from './project-schema/project-schema.types';
|
|
5
|
+
export { defaultProjectRoles } from './project-schema/project-schema.defaults';
|
|
5
6
|
export type { ProjectSchemaJSON } from './project-schema/project-schema.json-decoder';
|
|
6
7
|
export type * from './enum/enum.brands';
|
|
7
8
|
export * from './enum/enum.defaults';
|
package/dist/index.js
CHANGED
|
@@ -14,12 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.zProjectSchema = void 0;
|
|
17
|
+
exports.defaultProjectRoles = exports.zProjectSchema = void 0;
|
|
18
18
|
var project_schema_transformer_1 = require("./project-schema/project-schema.transformer");
|
|
19
19
|
Object.defineProperty(exports, "zProjectSchema", { enumerable: true, get: function () { return project_schema_transformer_1.zProjectSchema; } });
|
|
20
20
|
__exportStar(require("./project-schema/project-schema.auth"), exports);
|
|
21
21
|
__exportStar(require("./project-schema/project-schema.brands"), exports);
|
|
22
22
|
__exportStar(require("./project-schema/project-schema.types"), exports);
|
|
23
|
+
var project_schema_defaults_1 = require("./project-schema/project-schema.defaults");
|
|
24
|
+
Object.defineProperty(exports, "defaultProjectRoles", { enumerable: true, get: function () { return project_schema_defaults_1.defaultProjectRoles; } });
|
|
23
25
|
__exportStar(require("./enum/enum.defaults"), exports);
|
|
24
26
|
__exportStar(require("./field"), exports);
|
|
25
27
|
__exportStar(require("./model/model.defaults"), exports);
|
|
@@ -7,6 +7,10 @@ export declare const databaseSchemaNameData: string & import("zod").$brand<"PXL.
|
|
|
7
7
|
* The name of the schema that contains the configuration of the project.
|
|
8
8
|
*/
|
|
9
9
|
export declare const databaseSchemaNameConfig: string & import("zod").$brand<"PXL.DatabaseSchemaName">;
|
|
10
|
+
/**
|
|
11
|
+
* The default project roles. Can be overridden via `defaultRoles` in the project schema.
|
|
12
|
+
*/
|
|
13
|
+
export declare const defaultProjectRoles: readonly ["superadmin", "admin", "editor", "viewer"];
|
|
10
14
|
export declare const defaultSystemUser: {
|
|
11
15
|
id: string;
|
|
12
16
|
sub: null;
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.defaultSystemUser = exports.databaseSchemaNameConfig = exports.databaseSchemaNameData = void 0;
|
|
36
|
+
exports.defaultSystemUser = exports.defaultProjectRoles = exports.databaseSchemaNameConfig = exports.databaseSchemaNameData = void 0;
|
|
37
37
|
const Branded = __importStar(require("./project-schema.brands"));
|
|
38
38
|
/**
|
|
39
39
|
* The name of the default data schema of the project.
|
|
@@ -44,6 +44,10 @@ exports.databaseSchemaNameData = Branded.toDatabaseSchemaName('Data');
|
|
|
44
44
|
* The name of the schema that contains the configuration of the project.
|
|
45
45
|
*/
|
|
46
46
|
exports.databaseSchemaNameConfig = Branded.toDatabaseSchemaName('PXL');
|
|
47
|
+
/**
|
|
48
|
+
* The default project roles. Can be overridden via `defaultRoles` in the project schema.
|
|
49
|
+
*/
|
|
50
|
+
exports.defaultProjectRoles = ['superadmin', 'admin', 'editor', 'viewer'];
|
|
47
51
|
exports.defaultSystemUser = {
|
|
48
52
|
id: 'root',
|
|
49
53
|
sub: null,
|
|
@@ -70,6 +70,7 @@ export declare const zProjectSchemaJSON: z.ZodPipe<z.ZodTransform<unknown, unkno
|
|
|
70
70
|
}, z.core.$strip>>>;
|
|
71
71
|
}, z.core.$strip>>;
|
|
72
72
|
systemUser: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
73
|
+
defaultRoles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
73
74
|
standardModels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
74
75
|
models: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
75
76
|
name: z.ZodString;
|
|
@@ -124,6 +124,12 @@ exports.zProjectSchemaJSON = zod_1.z
|
|
|
124
124
|
.record(zod_1.z.string(), zod_1.z.any())
|
|
125
125
|
.optional()
|
|
126
126
|
.describe('The system user that is used for root/system tasks, e.g. data seeding.'),
|
|
127
|
+
defaultRoles: zod_1.z
|
|
128
|
+
//
|
|
129
|
+
.array(zod_1.z.string().min(1, { error: 'Role must not be empty.' }))
|
|
130
|
+
.min(1, { error: 'defaultRoles must contain at least one role.' })
|
|
131
|
+
.optional()
|
|
132
|
+
.describe(`Override the default project roles. If not provided, the default roles ["superadmin", "admin", "editor", "viewer"] are used. Roles from auth rules are added on top of these defaults.`),
|
|
127
133
|
standardModels: zod_1.z
|
|
128
134
|
//
|
|
129
135
|
.array(Model.zModelNameJSON)
|
|
@@ -49,6 +49,7 @@ export declare const zProjectSchema: z.ZodPipe<z.ZodPipe<z.ZodTransform<unknown,
|
|
|
49
49
|
}, z.core.$strip>>>;
|
|
50
50
|
}, z.core.$strip>>;
|
|
51
51
|
systemUser: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
52
|
+
defaultRoles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
52
53
|
standardModels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
53
54
|
models: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
54
55
|
name: z.ZodString;
|
|
@@ -153,6 +154,7 @@ export declare const zProjectSchema: z.ZodPipe<z.ZodPipe<z.ZodTransform<unknown,
|
|
|
153
154
|
}> | undefined;
|
|
154
155
|
} | undefined;
|
|
155
156
|
systemUser?: Record<string, any> | undefined;
|
|
157
|
+
defaultRoles?: string[] | undefined;
|
|
156
158
|
standardModels?: string[] | undefined;
|
|
157
159
|
models?: {
|
|
158
160
|
name: string;
|
|
@@ -100,6 +100,7 @@ function addDefaults(input) {
|
|
|
100
100
|
...project_schema_defaults_1.defaultSystemUser,
|
|
101
101
|
...input.systemUser,
|
|
102
102
|
},
|
|
103
|
+
defaultRoles: input.defaultRoles ?? [...project_schema_defaults_1.defaultProjectRoles],
|
|
103
104
|
standardModels: input.standardModels ?? Array.from(Object.values(Model.defaultModelNames)),
|
|
104
105
|
models: input.models ?? new Map(),
|
|
105
106
|
standardEnums: input.standardEnums ?? Array.from(Object.values(Enum.defaultEnumNames)),
|
|
@@ -40,6 +40,11 @@ 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 roles for this project. Roles from auth rules are added on top of these.
|
|
45
|
+
* If not provided in the schema, defaults to ['superadmin', 'admin', 'editor', 'viewer'].
|
|
46
|
+
*/
|
|
47
|
+
defaultRoles: string[];
|
|
43
48
|
/**
|
|
44
49
|
* Global authorization configuration for this project.
|
|
45
50
|
*/
|