@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.
Files changed (75) hide show
  1. package/LICENSE +50 -0
  2. package/README.md +320 -0
  3. package/dist/enum/enum.brands.d.ts +11 -0
  4. package/dist/enum/enum.brands.js +19 -0
  5. package/dist/enum/enum.d.ts +49 -0
  6. package/dist/enum/enum.defaults.d.ts +41 -0
  7. package/dist/enum/enum.defaults.js +105 -0
  8. package/dist/enum/enum.js +6 -0
  9. package/dist/enum/enum.json-decoder.d.ts +61 -0
  10. package/dist/enum/enum.json-decoder.js +51 -0
  11. package/dist/enum/enum.transformer.d.ts +12 -0
  12. package/dist/enum/enum.transformer.js +76 -0
  13. package/dist/enum/enum.types.d.ts +14 -0
  14. package/dist/enum/enum.types.js +2 -0
  15. package/dist/enum/index.d.ts +6 -0
  16. package/dist/enum/index.js +22 -0
  17. package/dist/field/defaults.d.ts +12 -0
  18. package/dist/field/defaults.js +78 -0
  19. package/dist/field/discriminated-union.d.ts +125 -0
  20. package/dist/field/discriminated-union.js +207 -0
  21. package/dist/field/enum.d.ts +65 -0
  22. package/dist/field/enum.js +111 -0
  23. package/dist/field/field.d.ts +483 -0
  24. package/dist/field/field.js +68 -0
  25. package/dist/field/id.d.ts +152 -0
  26. package/dist/field/id.js +104 -0
  27. package/dist/field/index.d.ts +11 -0
  28. package/dist/field/index.js +27 -0
  29. package/dist/field/relation.d.ts +88 -0
  30. package/dist/field/relation.js +138 -0
  31. package/dist/field/scalar.d.ts +179 -0
  32. package/dist/field/scalar.js +197 -0
  33. package/dist/field/shared/brands.d.ts +38 -0
  34. package/dist/field/shared/brands.js +109 -0
  35. package/dist/field/shared/decoders.d.ts +17 -0
  36. package/dist/field/shared/decoders.js +88 -0
  37. package/dist/field/shared/seed.d.ts +32 -0
  38. package/dist/field/shared/seed.js +63 -0
  39. package/dist/field/shared/types.d.ts +73 -0
  40. package/dist/field/shared/types.js +2 -0
  41. package/dist/field/shared/utils.d.ts +26 -0
  42. package/dist/field/shared/utils.js +52 -0
  43. package/dist/index.d.ts +12 -0
  44. package/dist/index.js +25 -0
  45. package/dist/model/index.d.ts +5 -0
  46. package/dist/model/index.js +21 -0
  47. package/dist/model/model.brands.d.ts +7 -0
  48. package/dist/model/model.brands.js +10 -0
  49. package/dist/model/model.defaults.d.ts +28 -0
  50. package/dist/model/model.defaults.js +304 -0
  51. package/dist/model/model.json-decoder.d.ts +94 -0
  52. package/dist/model/model.json-decoder.js +107 -0
  53. package/dist/model/model.transformer.d.ts +93 -0
  54. package/dist/model/model.transformer.js +183 -0
  55. package/dist/model/model.types.d.ts +37 -0
  56. package/dist/model/model.types.js +2 -0
  57. package/dist/project-schema/project-schema.brands.d.ts +10 -0
  58. package/dist/project-schema/project-schema.brands.js +17 -0
  59. package/dist/project-schema/project-schema.defaults.d.ts +16 -0
  60. package/dist/project-schema/project-schema.defaults.js +53 -0
  61. package/dist/project-schema/project-schema.json-decoder.d.ts +285 -0
  62. package/dist/project-schema/project-schema.json-decoder.js +145 -0
  63. package/dist/project-schema/project-schema.transformer.d.ts +284 -0
  64. package/dist/project-schema/project-schema.transformer.js +444 -0
  65. package/dist/project-schema/project-schema.types.d.ts +77 -0
  66. package/dist/project-schema/project-schema.types.js +2 -0
  67. package/dist/samples/la.schema.json +2055 -0
  68. package/dist/samples/mca.schema.json +830 -0
  69. package/dist/samples/ring.schema.json +879 -0
  70. package/dist/samples/sample-schemas.d.ts +1896 -0
  71. package/dist/samples/sample-schemas.js +20 -0
  72. package/dist/samples/simple.schema.json +250 -0
  73. package/dist/samples/subex.schema.json +1188 -0
  74. package/dist/samples/usp-msm.schema.json +2515 -0
  75. package/package.json +57 -0
@@ -0,0 +1,65 @@
1
+ import { z } from 'zod';
2
+ import * as Enum from '../enum';
3
+ import * as Branded from './shared/brands';
4
+ import { FieldCommon, FieldTransformer } from './shared/types';
5
+ export type FieldKindEnum = 'enum';
6
+ export declare const fieldKindEnum: FieldKindEnum;
7
+ export type FieldEnum = Omit<FieldCommon<FieldKindEnum>, 'databaseType'> & {
8
+ /**
9
+ * The branded TypeScript type of the enum field, e.g. `ActionStatus`.
10
+ */
11
+ type: Branded.EnumType;
12
+ /**
13
+ * Name of the enum. Should be camelCased.
14
+ */
15
+ enumName: Enum.EnumName;
16
+ };
17
+ /**
18
+ * JSON Schema for an enum field
19
+ */
20
+ export declare const createEnumJSONDecoder: ({ enumNames }: {
21
+ enumNames: Enum.EnumName[];
22
+ }) => z.ZodObject<{
23
+ name: z.ZodEffects<z.ZodString, string, string>;
24
+ type: z.ZodEffects<z.ZodString, string, string>;
25
+ databaseName: z.ZodOptional<z.ZodString>;
26
+ excelName: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
27
+ label: z.ZodOptional<z.ZodString>;
28
+ description: z.ZodOptional<z.ZodString>;
29
+ isReadonly: z.ZodOptional<z.ZodBoolean>;
30
+ isUnique: z.ZodOptional<z.ZodBoolean>;
31
+ }, "strip", z.ZodTypeAny, {
32
+ type: string;
33
+ name: string;
34
+ description?: string | undefined;
35
+ databaseName?: string | undefined;
36
+ excelName?: string | undefined;
37
+ label?: string | undefined;
38
+ isReadonly?: boolean | undefined;
39
+ isUnique?: boolean | undefined;
40
+ }, {
41
+ type: string;
42
+ name: string;
43
+ description?: string | undefined;
44
+ databaseName?: string | undefined;
45
+ excelName?: string | undefined;
46
+ label?: string | undefined;
47
+ isReadonly?: boolean | undefined;
48
+ isUnique?: boolean | undefined;
49
+ }>;
50
+ export type FieldEnumJSON = z.infer<ReturnType<typeof createEnumJSONDecoder>>;
51
+ export declare function fieldEnumJSONTransformer(fieldInput: FieldEnumJSON): {
52
+ kind: "enum";
53
+ type: string & z.BRAND<"PXL.EnumType"> & z.BRAND<"PXL.Type">;
54
+ name: string & z.BRAND<"PXL.FieldName">;
55
+ referencedEnumName: string & z.BRAND<"PXL.EnumName">;
56
+ label: string;
57
+ databaseName: string & z.BRAND<"PXL.DatabaseFieldName">;
58
+ excelName: string & z.BRAND<"PXL.ExcelColumnName">;
59
+ description: string | undefined;
60
+ isRequired: boolean;
61
+ isReadonly: boolean;
62
+ isUnique: boolean;
63
+ };
64
+ export type FieldEnumEnriched = ReturnType<typeof fieldEnumJSONTransformer>;
65
+ export declare const fieldEnumTransformer: FieldTransformer<FieldKindEnum, FieldEnumEnriched, FieldEnum>;
@@ -0,0 +1,111 @@
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.fieldEnumTransformer = exports.createEnumJSONDecoder = exports.fieldKindEnum = void 0;
37
+ exports.fieldEnumJSONTransformer = fieldEnumJSONTransformer;
38
+ const zod_1 = require("zod");
39
+ const utils_1 = require("@postxl/utils");
40
+ const Enum = __importStar(require("../enum"));
41
+ const Branded = __importStar(require("./shared/brands"));
42
+ const Decoders = __importStar(require("./shared/decoders"));
43
+ const utils_2 = require("./shared/utils");
44
+ exports.fieldKindEnum = 'enum';
45
+ /**
46
+ * JSON Schema for an enum field
47
+ */
48
+ const createEnumJSONDecoder = ({ enumNames }) => {
49
+ return zod_1.z.object({
50
+ name: Decoders.zFieldPropertyName,
51
+ type: zod_1.z //
52
+ .string()
53
+ .describe('The name of the referenced enum. If suffixed with "?", the field is optional.')
54
+ .transform((input, ctx) => {
55
+ const enumName = Enum.toEnumName(input.endsWith('?') ? input.slice(0, -1) : input);
56
+ if (!enumNames.includes(enumName)) {
57
+ ctx.addIssue({
58
+ code: zod_1.z.ZodIssueCode.custom,
59
+ message: `Enum ${enumName} is not defined in the project!`,
60
+ });
61
+ return zod_1.z.NEVER;
62
+ }
63
+ return input;
64
+ }),
65
+ databaseName: Decoders.zFieldPropertyDatabaseName,
66
+ excelName: Decoders.zFieldPropertyExcelName,
67
+ label: Decoders.zFieldPropertyLabel,
68
+ description: Decoders.zFieldPropertyDescription,
69
+ isReadonly: Decoders.zFieldPropertyIsReadonly,
70
+ isUnique: Decoders.zFieldPropertyIsUnique,
71
+ });
72
+ };
73
+ exports.createEnumJSONDecoder = createEnumJSONDecoder;
74
+ function fieldEnumJSONTransformer(fieldInput) {
75
+ const { isRequired, type: enumName } = (0, utils_2.isFieldRequired)(fieldInput.type);
76
+ const referencedEnumName = Enum.toEnumName(enumName);
77
+ const type = Branded.toEnumType(referencedEnumName);
78
+ return {
79
+ kind: exports.fieldKindEnum,
80
+ type,
81
+ name: Branded.toFieldName(fieldInput.name),
82
+ referencedEnumName,
83
+ label: (0, utils_1.toHumanReadable)(fieldInput.label ?? fieldInput.name),
84
+ databaseName: Branded.toDatabaseFieldName(fieldInput.databaseName ?? (0, utils_1.toSnakeCase)(fieldInput.name)),
85
+ excelName: Branded.toExcelColumnName(fieldInput.excelName ?? fieldInput.label ?? fieldInput.name),
86
+ description: fieldInput.description,
87
+ isRequired,
88
+ isReadonly: fieldInput.isReadonly ?? false,
89
+ isUnique: fieldInput.isUnique ?? false,
90
+ };
91
+ }
92
+ const fieldEnumTransformer = ({ fieldInput, model, projectSchema }, ctx) => {
93
+ const referencedEnum = projectSchema.enums.get(fieldInput.referencedEnumName);
94
+ if (referencedEnum === undefined) {
95
+ ctx.addIssue({
96
+ code: zod_1.z.ZodIssueCode.custom,
97
+ message: `Cannot find referenced enum for ${model.name}.${fieldInput.name}!`,
98
+ });
99
+ return zod_1.z.NEVER;
100
+ }
101
+ return {
102
+ ...fieldInput,
103
+ kind: 'enum',
104
+ enumName: fieldInput.referencedEnumName,
105
+ modelName: model.name,
106
+ name: Branded.toFieldName(fieldInput.name),
107
+ label: fieldInput.label ?? fieldInput.name,
108
+ databaseName: Branded.toDatabaseFieldName(fieldInput.databaseName ?? fieldInput.name),
109
+ };
110
+ };
111
+ exports.fieldEnumTransformer = fieldEnumTransformer;
@@ -0,0 +1,483 @@
1
+ import { z } from 'zod';
2
+ import * as Enum from '../enum';
3
+ import * as Model from '../model';
4
+ import * as Branded from './shared/brands';
5
+ import { FieldDiscriminatedUnion, FieldDiscriminatedUnionEnriched } from './discriminated-union';
6
+ import { FieldEnum, FieldEnumEnriched } from './enum';
7
+ import { FieldId, FieldIdEnriched } from './id';
8
+ import { FieldRelation, FieldRelationEnriched } from './relation';
9
+ import { FieldScalar, FieldScalarEnriched } from './scalar';
10
+ /**
11
+ * JSON Schema for a field
12
+ */
13
+ export declare const createFieldJSONDecoder: (params: {
14
+ modelNames: Model.ModelName[];
15
+ enumNames: Enum.EnumName[];
16
+ }) => z.ZodUnion<[z.ZodEffects<z.ZodObject<{
17
+ name: z.ZodLiteral<"id">;
18
+ type: z.ZodUnion<[z.ZodLiteral<"String">, z.ZodLiteral<"Int">]>;
19
+ databaseName: z.ZodOptional<z.ZodString>;
20
+ excelName: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
21
+ label: z.ZodOptional<z.ZodString>;
22
+ description: z.ZodOptional<z.ZodString>;
23
+ isReadonly: z.ZodOptional<z.ZodBoolean>;
24
+ faker: z.ZodOptional<z.ZodString>;
25
+ seed: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>, "many">]>>;
26
+ }, "strip", z.ZodTypeAny, {
27
+ type: "String" | "Int";
28
+ name: "id";
29
+ description?: string | undefined;
30
+ databaseName?: string | undefined;
31
+ excelName?: string | undefined;
32
+ label?: string | undefined;
33
+ isReadonly?: boolean | undefined;
34
+ faker?: string | undefined;
35
+ seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
36
+ }, {
37
+ type: "String" | "Int";
38
+ name: "id";
39
+ description?: string | undefined;
40
+ databaseName?: string | undefined;
41
+ excelName?: string | undefined;
42
+ label?: string | undefined;
43
+ isReadonly?: boolean | undefined;
44
+ faker?: string | undefined;
45
+ seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
46
+ }>, {
47
+ kind: "id";
48
+ name: "id" & z.BRAND<"PXL.FieldName"> & z.BRAND<"PXL.FieldName.Id">;
49
+ unbrandedTypeName: ((("string" | "number") & z.BRAND<"PXL.ScalarIdType">) & z.BRAND<"PXL.ScalarType">) & z.BRAND<"PXL.Type">;
50
+ databaseType: ("BigInt" | "String" | "Boolean" | "DateTime" | "Decimal" | "Float" | "Int" | "Json" | "Bytes") & z.BRAND<"PXL.DatabaseFieldType">;
51
+ databaseName: string & z.BRAND<"PXL.DatabaseFieldName">;
52
+ excelName: string & z.BRAND<"PXL.ExcelColumnName">;
53
+ description: string;
54
+ label: string;
55
+ hasIndex: true;
56
+ isReadonly: boolean;
57
+ isRequired: true;
58
+ isUnique: true;
59
+ isCreatedAt: false;
60
+ isUpdatedAt: false;
61
+ seed: import(".").FieldSeedConfig;
62
+ }, {
63
+ type: "String" | "Int";
64
+ name: "id";
65
+ description?: string | undefined;
66
+ databaseName?: string | undefined;
67
+ excelName?: string | undefined;
68
+ label?: string | undefined;
69
+ isReadonly?: boolean | undefined;
70
+ faker?: string | undefined;
71
+ seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
72
+ }>, z.ZodEffects<z.ZodObject<{
73
+ name: z.ZodEffects<z.ZodString, string, string>;
74
+ type: z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"String">, z.ZodLiteral<"String?">]>, z.ZodUnion<[z.ZodLiteral<"Boolean">, z.ZodLiteral<"Boolean?">]>, z.ZodUnion<[z.ZodLiteral<"DateTime">, z.ZodLiteral<"DateTime?">]>, z.ZodUnion<[z.ZodLiteral<"Decimal">, z.ZodLiteral<"Decimal?">]>, z.ZodUnion<[z.ZodLiteral<"Float">, z.ZodLiteral<"Float?">]>, z.ZodUnion<[z.ZodLiteral<"Int">, z.ZodLiteral<"Int?">]>, z.ZodUnion<[z.ZodLiteral<"Json">, z.ZodLiteral<"Json?">]>, z.ZodUnion<[z.ZodLiteral<"Bytes">, z.ZodLiteral<"Bytes?">]>, z.ZodUnion<[z.ZodLiteral<"BigInt">, z.ZodLiteral<"BigInt?">]>]>;
75
+ databaseName: z.ZodOptional<z.ZodString>;
76
+ excelName: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
77
+ label: z.ZodOptional<z.ZodString>;
78
+ description: z.ZodOptional<z.ZodString>;
79
+ isReadonly: z.ZodOptional<z.ZodBoolean>;
80
+ isUnique: z.ZodOptional<z.ZodBoolean>;
81
+ hasIndex: z.ZodOptional<z.ZodBoolean>;
82
+ isCreatedAt: z.ZodOptional<z.ZodBoolean>;
83
+ isUpdatedAt: z.ZodOptional<z.ZodBoolean>;
84
+ maxLength: z.ZodOptional<z.ZodNumber>;
85
+ faker: z.ZodOptional<z.ZodString>;
86
+ seed: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>, "many">]>>;
87
+ placeholder: z.ZodOptional<z.ZodString>;
88
+ }, "strict", z.ZodTypeAny, {
89
+ type: "BigInt" | "String" | "Boolean" | "DateTime" | "Decimal" | "Float" | "Int" | "Json" | "Bytes" | "String?" | "Boolean?" | "DateTime?" | "Decimal?" | "Float?" | "Int?" | "Json?" | "Bytes?" | "BigInt?";
90
+ name: string;
91
+ description?: string | undefined;
92
+ databaseName?: string | undefined;
93
+ excelName?: string | undefined;
94
+ label?: string | undefined;
95
+ isReadonly?: boolean | undefined;
96
+ faker?: string | undefined;
97
+ seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
98
+ isUnique?: boolean | undefined;
99
+ hasIndex?: boolean | undefined;
100
+ isCreatedAt?: boolean | undefined;
101
+ isUpdatedAt?: boolean | undefined;
102
+ maxLength?: number | undefined;
103
+ placeholder?: string | undefined;
104
+ }, {
105
+ type: "BigInt" | "String" | "Boolean" | "DateTime" | "Decimal" | "Float" | "Int" | "Json" | "Bytes" | "String?" | "Boolean?" | "DateTime?" | "Decimal?" | "Float?" | "Int?" | "Json?" | "Bytes?" | "BigInt?";
106
+ name: string;
107
+ description?: string | undefined;
108
+ databaseName?: string | undefined;
109
+ excelName?: string | undefined;
110
+ label?: string | undefined;
111
+ isReadonly?: boolean | undefined;
112
+ faker?: string | undefined;
113
+ seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
114
+ isUnique?: boolean | undefined;
115
+ hasIndex?: boolean | undefined;
116
+ isCreatedAt?: boolean | undefined;
117
+ isUpdatedAt?: boolean | undefined;
118
+ maxLength?: number | undefined;
119
+ placeholder?: string | undefined;
120
+ }>, FieldScalarEnriched, {
121
+ type: "BigInt" | "String" | "Boolean" | "DateTime" | "Decimal" | "Float" | "Int" | "Json" | "Bytes" | "String?" | "Boolean?" | "DateTime?" | "Decimal?" | "Float?" | "Int?" | "Json?" | "Bytes?" | "BigInt?";
122
+ name: string;
123
+ description?: string | undefined;
124
+ databaseName?: string | undefined;
125
+ excelName?: string | undefined;
126
+ label?: string | undefined;
127
+ isReadonly?: boolean | undefined;
128
+ faker?: string | undefined;
129
+ seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
130
+ isUnique?: boolean | undefined;
131
+ hasIndex?: boolean | undefined;
132
+ isCreatedAt?: boolean | undefined;
133
+ isUpdatedAt?: boolean | undefined;
134
+ maxLength?: number | undefined;
135
+ placeholder?: string | undefined;
136
+ }>, z.ZodEffects<z.ZodObject<{
137
+ name: z.ZodEffects<z.ZodString, string, string>;
138
+ type: z.ZodUnion<[z.ZodLiteral<"DiscriminatedUnion">, z.ZodLiteral<"DiscriminatedUnion?">]>;
139
+ label: z.ZodOptional<z.ZodString>;
140
+ description: z.ZodOptional<z.ZodString>;
141
+ databaseName: z.ZodOptional<z.ZodString>;
142
+ excelName: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
143
+ members: z.ZodArray<z.ZodObject<{
144
+ type: z.ZodEffects<z.ZodString, string, string>;
145
+ label: z.ZodOptional<z.ZodString>;
146
+ fields: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>, "many">>;
147
+ }, "strip", z.ZodTypeAny, {
148
+ type: string;
149
+ label?: string | undefined;
150
+ fields?: Record<string, any>[] | undefined;
151
+ }, {
152
+ type: string;
153
+ label?: string | undefined;
154
+ fields?: Record<string, any>[] | undefined;
155
+ }>, "many">;
156
+ commonFields: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>, "many">>;
157
+ isReadonly: z.ZodOptional<z.ZodBoolean>;
158
+ }, "strip", z.ZodTypeAny, {
159
+ type: "DiscriminatedUnion" | "DiscriminatedUnion?";
160
+ name: string;
161
+ members: {
162
+ type: string;
163
+ label?: string | undefined;
164
+ fields?: Record<string, any>[] | undefined;
165
+ }[];
166
+ description?: string | undefined;
167
+ databaseName?: string | undefined;
168
+ excelName?: string | undefined;
169
+ label?: string | undefined;
170
+ isReadonly?: boolean | undefined;
171
+ commonFields?: Record<string, any>[] | undefined;
172
+ }, {
173
+ type: "DiscriminatedUnion" | "DiscriminatedUnion?";
174
+ name: string;
175
+ members: {
176
+ type: string;
177
+ label?: string | undefined;
178
+ fields?: Record<string, any>[] | undefined;
179
+ }[];
180
+ description?: string | undefined;
181
+ databaseName?: string | undefined;
182
+ excelName?: string | undefined;
183
+ label?: string | undefined;
184
+ isReadonly?: boolean | undefined;
185
+ commonFields?: Record<string, any>[] | undefined;
186
+ }>, {
187
+ kind: "discriminatedUnion";
188
+ name: string & z.BRAND<"PXL.FieldName">;
189
+ discriminatorFieldName: string & z.BRAND<"PXL.FieldName">;
190
+ label: string;
191
+ databaseName: string & z.BRAND<"PXL.DatabaseFieldName">;
192
+ excelName: string & z.BRAND<"PXL.ExcelColumnName">;
193
+ description: string | undefined;
194
+ members: {
195
+ type: string;
196
+ label?: string | undefined;
197
+ fields?: Record<string, any>[] | undefined;
198
+ }[];
199
+ commonFields: Record<string, any>[] | undefined;
200
+ isReadonly: boolean;
201
+ isRequired: boolean;
202
+ }, {
203
+ type: "DiscriminatedUnion" | "DiscriminatedUnion?";
204
+ name: string;
205
+ members: {
206
+ type: string;
207
+ label?: string | undefined;
208
+ fields?: Record<string, any>[] | undefined;
209
+ }[];
210
+ description?: string | undefined;
211
+ databaseName?: string | undefined;
212
+ excelName?: string | undefined;
213
+ label?: string | undefined;
214
+ isReadonly?: boolean | undefined;
215
+ commonFields?: Record<string, any>[] | undefined;
216
+ }>, z.ZodEffects<z.ZodObject<{
217
+ name: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
218
+ type: z.ZodEffects<z.ZodString, string, string>;
219
+ databaseName: z.ZodOptional<z.ZodString>;
220
+ excelName: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
221
+ prismaRelationFieldName: z.ZodOptional<z.ZodString>;
222
+ deepClone: z.ZodOptional<z.ZodBoolean>;
223
+ label: z.ZodOptional<z.ZodString>;
224
+ description: z.ZodOptional<z.ZodString>;
225
+ isReadonly: z.ZodOptional<z.ZodBoolean>;
226
+ isUnique: z.ZodOptional<z.ZodBoolean>;
227
+ }, "strip", z.ZodTypeAny, {
228
+ type: string;
229
+ name: string;
230
+ description?: string | undefined;
231
+ databaseName?: string | undefined;
232
+ excelName?: string | undefined;
233
+ label?: string | undefined;
234
+ isReadonly?: boolean | undefined;
235
+ isUnique?: boolean | undefined;
236
+ prismaRelationFieldName?: string | undefined;
237
+ deepClone?: boolean | undefined;
238
+ }, {
239
+ type: string;
240
+ name: string;
241
+ description?: string | undefined;
242
+ databaseName?: string | undefined;
243
+ excelName?: string | undefined;
244
+ label?: string | undefined;
245
+ isReadonly?: boolean | undefined;
246
+ isUnique?: boolean | undefined;
247
+ prismaRelationFieldName?: string | undefined;
248
+ deepClone?: boolean | undefined;
249
+ }>, {
250
+ kind: "relation";
251
+ type: string & z.BRAND<"PXL.IdType"> & z.BRAND<"PXL.Type">;
252
+ name: string & z.BRAND<"PXL.FieldName">;
253
+ referencedModelName: string & z.BRAND<"PXL.ModelName">;
254
+ label: string;
255
+ databaseName: string & z.BRAND<"PXL.DatabaseFieldName">;
256
+ prismaRelationFieldName: (string & z.BRAND<"PXL.DatabaseFieldName">) | undefined;
257
+ excelName: string & z.BRAND<"PXL.ExcelColumnName">;
258
+ deepClone: boolean;
259
+ description: string | undefined;
260
+ isReadonly: boolean;
261
+ isRequired: boolean;
262
+ isUnique: boolean;
263
+ validations: never[];
264
+ generation: string;
265
+ }, {
266
+ type: string;
267
+ name: string;
268
+ description?: string | undefined;
269
+ databaseName?: string | undefined;
270
+ excelName?: string | undefined;
271
+ label?: string | undefined;
272
+ isReadonly?: boolean | undefined;
273
+ isUnique?: boolean | undefined;
274
+ prismaRelationFieldName?: string | undefined;
275
+ deepClone?: boolean | undefined;
276
+ }>, z.ZodEffects<z.ZodObject<{
277
+ name: z.ZodEffects<z.ZodString, string, string>;
278
+ type: z.ZodEffects<z.ZodString, string, string>;
279
+ databaseName: z.ZodOptional<z.ZodString>;
280
+ excelName: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
281
+ label: z.ZodOptional<z.ZodString>;
282
+ description: z.ZodOptional<z.ZodString>;
283
+ isReadonly: z.ZodOptional<z.ZodBoolean>;
284
+ isUnique: z.ZodOptional<z.ZodBoolean>;
285
+ }, "strip", z.ZodTypeAny, {
286
+ type: string;
287
+ name: string;
288
+ description?: string | undefined;
289
+ databaseName?: string | undefined;
290
+ excelName?: string | undefined;
291
+ label?: string | undefined;
292
+ isReadonly?: boolean | undefined;
293
+ isUnique?: boolean | undefined;
294
+ }, {
295
+ type: string;
296
+ name: string;
297
+ description?: string | undefined;
298
+ databaseName?: string | undefined;
299
+ excelName?: string | undefined;
300
+ label?: string | undefined;
301
+ isReadonly?: boolean | undefined;
302
+ isUnique?: boolean | undefined;
303
+ }>, {
304
+ kind: "enum";
305
+ type: string & z.BRAND<"PXL.EnumType"> & z.BRAND<"PXL.Type">;
306
+ name: string & z.BRAND<"PXL.FieldName">;
307
+ referencedEnumName: string & z.BRAND<"PXL.EnumName">;
308
+ label: string;
309
+ databaseName: string & z.BRAND<"PXL.DatabaseFieldName">;
310
+ excelName: string & z.BRAND<"PXL.ExcelColumnName">;
311
+ description: string | undefined;
312
+ isRequired: boolean;
313
+ isReadonly: boolean;
314
+ isUnique: boolean;
315
+ }, {
316
+ type: string;
317
+ name: string;
318
+ description?: string | undefined;
319
+ databaseName?: string | undefined;
320
+ excelName?: string | undefined;
321
+ label?: string | undefined;
322
+ isReadonly?: boolean | undefined;
323
+ isUnique?: boolean | undefined;
324
+ }>]>;
325
+ export type FieldEnriched = FieldIdEnriched | FieldScalarEnriched | FieldRelationEnriched | FieldEnumEnriched | FieldDiscriminatedUnionEnriched;
326
+ export type FieldEnrichedNativeDatabase = FieldIdEnriched | FieldScalarEnriched | FieldRelationEnriched | FieldEnumEnriched;
327
+ export declare const zFieldJSONInput: (params: {
328
+ modelNames: Model.ModelName[];
329
+ enumNames: Enum.EnumName[];
330
+ }) => z.ZodUnion<[z.ZodObject<{
331
+ name: z.ZodLiteral<"id">;
332
+ type: z.ZodUnion<[z.ZodLiteral<"String">, z.ZodLiteral<"Int">]>;
333
+ databaseName: z.ZodOptional<z.ZodString>;
334
+ excelName: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
335
+ label: z.ZodOptional<z.ZodString>;
336
+ description: z.ZodOptional<z.ZodString>;
337
+ isReadonly: z.ZodOptional<z.ZodBoolean>;
338
+ faker: z.ZodOptional<z.ZodString>;
339
+ seed: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>, "many">]>>;
340
+ }, "strip", z.ZodTypeAny, {
341
+ type: "String" | "Int";
342
+ name: "id";
343
+ description?: string | undefined;
344
+ databaseName?: string | undefined;
345
+ excelName?: string | undefined;
346
+ label?: string | undefined;
347
+ isReadonly?: boolean | undefined;
348
+ faker?: string | undefined;
349
+ seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
350
+ }, {
351
+ type: "String" | "Int";
352
+ name: "id";
353
+ description?: string | undefined;
354
+ databaseName?: string | undefined;
355
+ excelName?: string | undefined;
356
+ label?: string | undefined;
357
+ isReadonly?: boolean | undefined;
358
+ faker?: string | undefined;
359
+ seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
360
+ }>, z.ZodObject<{
361
+ name: z.ZodEffects<z.ZodString, string, string>;
362
+ type: z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"String">, z.ZodLiteral<"String?">]>, z.ZodUnion<[z.ZodLiteral<"Boolean">, z.ZodLiteral<"Boolean?">]>, z.ZodUnion<[z.ZodLiteral<"DateTime">, z.ZodLiteral<"DateTime?">]>, z.ZodUnion<[z.ZodLiteral<"Decimal">, z.ZodLiteral<"Decimal?">]>, z.ZodUnion<[z.ZodLiteral<"Float">, z.ZodLiteral<"Float?">]>, z.ZodUnion<[z.ZodLiteral<"Int">, z.ZodLiteral<"Int?">]>, z.ZodUnion<[z.ZodLiteral<"Json">, z.ZodLiteral<"Json?">]>, z.ZodUnion<[z.ZodLiteral<"Bytes">, z.ZodLiteral<"Bytes?">]>, z.ZodUnion<[z.ZodLiteral<"BigInt">, z.ZodLiteral<"BigInt?">]>]>;
363
+ databaseName: z.ZodOptional<z.ZodString>;
364
+ excelName: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
365
+ label: z.ZodOptional<z.ZodString>;
366
+ description: z.ZodOptional<z.ZodString>;
367
+ isReadonly: z.ZodOptional<z.ZodBoolean>;
368
+ isUnique: z.ZodOptional<z.ZodBoolean>;
369
+ hasIndex: z.ZodOptional<z.ZodBoolean>;
370
+ isCreatedAt: z.ZodOptional<z.ZodBoolean>;
371
+ isUpdatedAt: z.ZodOptional<z.ZodBoolean>;
372
+ maxLength: z.ZodOptional<z.ZodNumber>;
373
+ faker: z.ZodOptional<z.ZodString>;
374
+ seed: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodDate]>, "many">]>>;
375
+ placeholder: z.ZodOptional<z.ZodString>;
376
+ }, "strict", z.ZodTypeAny, {
377
+ type: "BigInt" | "String" | "Boolean" | "DateTime" | "Decimal" | "Float" | "Int" | "Json" | "Bytes" | "String?" | "Boolean?" | "DateTime?" | "Decimal?" | "Float?" | "Int?" | "Json?" | "Bytes?" | "BigInt?";
378
+ name: string;
379
+ description?: string | undefined;
380
+ databaseName?: string | undefined;
381
+ excelName?: string | undefined;
382
+ label?: string | undefined;
383
+ isReadonly?: boolean | undefined;
384
+ faker?: string | undefined;
385
+ seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
386
+ isUnique?: boolean | undefined;
387
+ hasIndex?: boolean | undefined;
388
+ isCreatedAt?: boolean | undefined;
389
+ isUpdatedAt?: boolean | undefined;
390
+ maxLength?: number | undefined;
391
+ placeholder?: string | undefined;
392
+ }, {
393
+ type: "BigInt" | "String" | "Boolean" | "DateTime" | "Decimal" | "Float" | "Int" | "Json" | "Bytes" | "String?" | "Boolean?" | "DateTime?" | "Decimal?" | "Float?" | "Int?" | "Json?" | "Bytes?" | "BigInt?";
394
+ name: string;
395
+ description?: string | undefined;
396
+ databaseName?: string | undefined;
397
+ excelName?: string | undefined;
398
+ label?: string | undefined;
399
+ isReadonly?: boolean | undefined;
400
+ faker?: string | undefined;
401
+ seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
402
+ isUnique?: boolean | undefined;
403
+ hasIndex?: boolean | undefined;
404
+ isCreatedAt?: boolean | undefined;
405
+ isUpdatedAt?: boolean | undefined;
406
+ maxLength?: number | undefined;
407
+ placeholder?: string | undefined;
408
+ }>, z.ZodObject<{
409
+ name: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
410
+ type: z.ZodEffects<z.ZodString, string, string>;
411
+ databaseName: z.ZodOptional<z.ZodString>;
412
+ excelName: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
413
+ prismaRelationFieldName: z.ZodOptional<z.ZodString>;
414
+ deepClone: z.ZodOptional<z.ZodBoolean>;
415
+ label: z.ZodOptional<z.ZodString>;
416
+ description: z.ZodOptional<z.ZodString>;
417
+ isReadonly: z.ZodOptional<z.ZodBoolean>;
418
+ isUnique: z.ZodOptional<z.ZodBoolean>;
419
+ }, "strip", z.ZodTypeAny, {
420
+ type: string;
421
+ name: string;
422
+ description?: string | undefined;
423
+ databaseName?: string | undefined;
424
+ excelName?: string | undefined;
425
+ label?: string | undefined;
426
+ isReadonly?: boolean | undefined;
427
+ isUnique?: boolean | undefined;
428
+ prismaRelationFieldName?: string | undefined;
429
+ deepClone?: boolean | undefined;
430
+ }, {
431
+ type: string;
432
+ name: string;
433
+ description?: string | undefined;
434
+ databaseName?: string | undefined;
435
+ excelName?: string | undefined;
436
+ label?: string | undefined;
437
+ isReadonly?: boolean | undefined;
438
+ isUnique?: boolean | undefined;
439
+ prismaRelationFieldName?: string | undefined;
440
+ deepClone?: boolean | undefined;
441
+ }>, z.ZodObject<{
442
+ name: z.ZodEffects<z.ZodString, string, string>;
443
+ type: z.ZodEffects<z.ZodString, string, string>;
444
+ databaseName: z.ZodOptional<z.ZodString>;
445
+ excelName: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
446
+ label: z.ZodOptional<z.ZodString>;
447
+ description: z.ZodOptional<z.ZodString>;
448
+ isReadonly: z.ZodOptional<z.ZodBoolean>;
449
+ isUnique: z.ZodOptional<z.ZodBoolean>;
450
+ }, "strip", z.ZodTypeAny, {
451
+ type: string;
452
+ name: string;
453
+ description?: string | undefined;
454
+ databaseName?: string | undefined;
455
+ excelName?: string | undefined;
456
+ label?: string | undefined;
457
+ isReadonly?: boolean | undefined;
458
+ isUnique?: boolean | undefined;
459
+ }, {
460
+ type: string;
461
+ name: string;
462
+ description?: string | undefined;
463
+ databaseName?: string | undefined;
464
+ excelName?: string | undefined;
465
+ label?: string | undefined;
466
+ isReadonly?: boolean | undefined;
467
+ isUnique?: boolean | undefined;
468
+ }>]>;
469
+ export type FieldJSONInput = z.infer<ReturnType<typeof zFieldJSONInput>>;
470
+ export declare const fieldTransformer: (fieldInput: FieldEnriched, model: {
471
+ name: Model.ModelName;
472
+ fields: Map<Branded.FieldName, FieldEnriched>;
473
+ }, projectSchema: {
474
+ enums: Enum.Enums;
475
+ models: Map<Model.ModelName, {
476
+ name: Model.ModelName;
477
+ isReadonly?: boolean;
478
+ }>;
479
+ }, ctx: z.RefinementCtx) => FieldId | FieldScalar | FieldRelation | FieldEnum | FieldDiscriminatedUnion;
480
+ export type FieldDatabaseNative = FieldId | FieldScalar | FieldRelation | FieldEnum;
481
+ export declare function isFieldDatabaseNative(field: Field): field is FieldDatabaseNative;
482
+ export type Field = FieldDatabaseNative | FieldDiscriminatedUnion;
483
+ export type Fields<FIELD = Field> = Map<Branded.FieldName, FIELD>;