@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.
@@ -1,11 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  declare const zEnumName: z.core.$ZodBranded<z.ZodString, "PXL.EnumName", "out">;
3
3
  export type EnumName = z.infer<typeof zEnumName>;
4
- export declare const toEnumName: (input: string) => string & z.core.$brand<"PXL.EnumName">;
4
+ export declare const toEnumName: (input: string) => string & z.$brand<"PXL.EnumName">;
5
5
  declare const zEnumValue: z.core.$ZodBranded<z.ZodString, "PXL.EnumValue", "out">;
6
6
  export type EnumValue = z.infer<typeof zEnumValue>;
7
- export declare const toEnumValue: (input: string) => string & z.core.$brand<"PXL.EnumValue">;
7
+ export declare const toEnumValue: (input: string) => string & z.$brand<"PXL.EnumValue">;
8
8
  export declare const zDatabaseEnumName: z.core.$ZodBranded<z.ZodString, "PXL.DatabaseEnumName", "out">;
9
9
  export type DatabaseEnumName = z.infer<typeof zDatabaseEnumName>;
10
- export declare const toDatabaseEnumName: (input: string) => string & z.core.$brand<"PXL.DatabaseEnumName">;
10
+ export declare const toDatabaseEnumName: (input: string) => string & z.$brand<"PXL.DatabaseEnumName">;
11
11
  export {};
@@ -16,10 +16,10 @@ export declare const zEnum: import("zod").ZodPipe<import("zod").ZodPreprocess<im
16
16
  }, {
17
17
  name: string;
18
18
  description: string;
19
+ schema?: string | undefined;
20
+ databaseName?: string | undefined;
19
21
  members: (string | {
20
22
  value: string;
21
23
  description?: string | undefined;
22
24
  })[];
23
- schema?: string | undefined;
24
- databaseName?: string | undefined;
25
25
  }>>;
@@ -13,41 +13,41 @@ export declare const defaultEnumNames: {
13
13
  export declare const defaultEnumJson_ActionStatus: {
14
14
  name: string;
15
15
  description: string;
16
+ schema?: string | undefined;
17
+ databaseName?: string | undefined;
16
18
  members: (string | {
17
19
  value: string;
18
20
  description?: string | undefined;
19
21
  })[];
20
- schema?: string | undefined;
21
- databaseName?: string | undefined;
22
22
  };
23
23
  export declare const defaultEnumJson_MutationStatus: {
24
24
  name: string;
25
25
  description: string;
26
+ schema?: string | undefined;
27
+ databaseName?: string | undefined;
26
28
  members: (string | {
27
29
  value: string;
28
30
  description?: string | undefined;
29
31
  })[];
30
- schema?: string | undefined;
31
- databaseName?: string | undefined;
32
32
  };
33
33
  export declare const defaultEnumJson_MutationKind: {
34
34
  name: string;
35
35
  description: string;
36
+ schema?: string | undefined;
37
+ databaseName?: string | undefined;
36
38
  members: (string | {
37
39
  value: string;
38
40
  description?: string | undefined;
39
41
  })[];
40
- schema?: string | undefined;
41
- databaseName?: string | undefined;
42
42
  };
43
43
  export declare const defaultEnumJson_ActionOperationKind: {
44
44
  name: string;
45
45
  description: string;
46
+ schema?: string | undefined;
47
+ databaseName?: string | undefined;
46
48
  members: (string | {
47
49
  value: string;
48
50
  description?: string | undefined;
49
51
  })[];
50
- schema?: string | undefined;
51
- databaseName?: string | undefined;
52
52
  };
53
53
  export declare const defaultEnumsJson: Record<Branded.EnumName, EnumJSON>;
@@ -4,9 +4,9 @@ import type { EnumMember } from './enum.types';
4
4
  export declare function enumMemberTransformer(input: EnumMemberJSON): EnumMember;
5
5
  export type EnumEnriched = ReturnType<typeof enumTransformer>;
6
6
  export declare function enumTransformer(input: EnumJSON, ctx: z.RefinementCtx): {
7
- name: string & z.core.$brand<"PXL.EnumName">;
7
+ name: string & z.$brand<"PXL.EnumName">;
8
8
  description: string;
9
- members: Map<string & z.core.$brand<"PXL.EnumValue">, EnumMember>;
10
- databaseSchema: (string & z.core.$brand<"PXL.DatabaseSchemaName">) | undefined;
11
- databaseName: string & z.core.$brand<"PXL.DatabaseEnumName">;
9
+ members: Map<string & z.$brand<"PXL.EnumValue">, EnumMember>;
10
+ databaseSchema: (string & z.$brand<"PXL.DatabaseSchemaName">) | undefined;
11
+ databaseName: string & z.$brand<"PXL.DatabaseEnumName">;
12
12
  };
@@ -13,6 +13,11 @@ export type FieldEnum = Omit<FieldCommon<FieldKindEnum>, 'databaseType'> & {
13
13
  * Name of the enum. Should be camelCased.
14
14
  */
15
15
  enumName: Enum.EnumName;
16
+ /**
17
+ * Optional default value of the field. Always one of the referenced enum's members - this is
18
+ * validated when the schema is decoded.
19
+ */
20
+ defaultValue: Enum.EnumValue | undefined;
16
21
  };
17
22
  /**
18
23
  * JSON Schema for an enum field
@@ -27,21 +32,25 @@ export declare const createEnumJSONDecoder: ({ enumNames }: {
27
32
  label: z.ZodOptional<z.ZodString>;
28
33
  description: z.ZodOptional<z.ZodString>;
29
34
  isReadonly: z.ZodOptional<z.ZodBoolean>;
35
+ isSystemManaged: z.ZodOptional<z.ZodBoolean>;
30
36
  isUnique: z.ZodOptional<z.ZodBoolean>;
37
+ defaultValue: z.ZodOptional<z.ZodString>;
31
38
  }, z.core.$strip>;
32
39
  export type FieldEnumJSON = z.infer<ReturnType<typeof createEnumJSONDecoder>>;
33
40
  export declare function fieldEnumJSONTransformer(fieldInput: FieldEnumJSON): {
34
41
  kind: "enum";
35
- type: string & z.core.$brand<"PXL.EnumType"> & z.core.$brand<"PXL.Type">;
36
- name: string & z.core.$brand<"PXL.FieldName">;
37
- referencedEnumName: string & z.core.$brand<"PXL.EnumName">;
42
+ type: string & z.$brand<"PXL.EnumType"> & z.$brand<"PXL.Type">;
43
+ name: string & z.$brand<"PXL.FieldName">;
44
+ referencedEnumName: string & z.$brand<"PXL.EnumName">;
38
45
  label: string;
39
- databaseName: string & z.core.$brand<"PXL.DatabaseFieldName">;
40
- excelName: string & z.core.$brand<"PXL.ExcelColumnName">;
46
+ databaseName: string & z.$brand<"PXL.DatabaseFieldName">;
47
+ excelName: string & z.$brand<"PXL.ExcelColumnName">;
41
48
  description: string | undefined;
42
49
  isRequired: boolean;
43
50
  isReadonly: boolean;
51
+ isSystemManaged: boolean;
44
52
  isUnique: boolean;
53
+ defaultValue: string | undefined;
45
54
  };
46
55
  export type FieldEnumEnriched = ReturnType<typeof fieldEnumJSONTransformer>;
47
56
  export declare const fieldEnumTransformer: FieldTransformer<FieldKindEnum, FieldEnumEnriched, FieldEnum>;
@@ -67,7 +67,12 @@ const createEnumJSONDecoder = ({ enumNames }) => {
67
67
  label: Decoders.zFieldPropertyLabel,
68
68
  description: Decoders.zFieldPropertyDescription,
69
69
  isReadonly: Decoders.zFieldPropertyIsReadonly,
70
+ isSystemManaged: Decoders.zFieldPropertyIsSystemManaged,
70
71
  isUnique: Decoders.zFieldPropertyIsUnique,
72
+ defaultValue: zod_1.z
73
+ .string()
74
+ .optional()
75
+ .describe('An optional default value for the field. Must be one of the members of the referenced enum.'),
71
76
  });
72
77
  };
73
78
  exports.createEnumJSONDecoder = createEnumJSONDecoder;
@@ -86,7 +91,9 @@ function fieldEnumJSONTransformer(fieldInput) {
86
91
  description: fieldInput.description,
87
92
  isRequired,
88
93
  isReadonly: fieldInput.isReadonly ?? false,
94
+ isSystemManaged: fieldInput.isSystemManaged ?? false,
89
95
  isUnique: fieldInput.isUnique ?? false,
96
+ defaultValue: fieldInput.defaultValue,
90
97
  };
91
98
  }
92
99
  const fieldEnumTransformer = ({ fieldInput, model, projectSchema }, ctx) => {
@@ -98,8 +105,24 @@ const fieldEnumTransformer = ({ fieldInput, model, projectSchema }, ctx) => {
98
105
  });
99
106
  return zod_1.z.NEVER;
100
107
  }
108
+ // A default that is not a member of the enum would only surface much later: as an invalid
109
+ // `@default(...)` in the Prisma schema, and as a Zod `.default(...)` that does not type-check.
110
+ // Report it here, where the schema author can still see which field it belongs to.
111
+ let defaultValue = undefined;
112
+ if (fieldInput.defaultValue !== undefined) {
113
+ const member = referencedEnum.members.get(Enum.toEnumValue(fieldInput.defaultValue));
114
+ if (member === undefined) {
115
+ ctx.addIssue({
116
+ code: zod_1.z.ZodIssueCode.custom,
117
+ message: `Default value "${fieldInput.defaultValue}" for field ${model.name}.${fieldInput.name} is not a member of enum ${referencedEnum.name}. Expected one of: ${[...referencedEnum.members.keys()].join(', ')}.`,
118
+ });
119
+ return zod_1.z.NEVER;
120
+ }
121
+ defaultValue = member.value;
122
+ }
101
123
  return {
102
124
  ...fieldInput,
125
+ defaultValue,
103
126
  kind: 'enum',
104
127
  enumName: fieldInput.referencedEnumName,
105
128
  modelName: model.name,
@@ -23,52 +23,56 @@ import { FieldScalar, FieldScalarEnriched } from './scalar';
23
23
  export declare const createFieldJSONDecoder: (params: {
24
24
  modelNames: Model.ModelName[];
25
25
  enumNames: Enum.EnumName[];
26
- }) => z.ZodPipe<z.ZodUnknown, z.ZodTransform<{
26
+ }) => z.ZodPipe<z.ZodUnknown, z.ZodTransform<FieldJsonEnriched | {
27
27
  kind: "id";
28
- name: "id" & z.core.$brand<"PXL.FieldName"> & z.core.$brand<"PXL.FieldName.Id">;
29
- unbrandedTypeName: ("string" & z.core.$brand<"PXL.ScalarIdType"> & z.core.$brand<"PXL.ScalarType"> & z.core.$brand<"PXL.Type">) | ("number" & z.core.$brand<"PXL.ScalarIdType"> & z.core.$brand<"PXL.ScalarType"> & z.core.$brand<"PXL.Type">);
30
- databaseType: ("BigInt" & z.core.$brand<"PXL.DatabaseFieldType">) | ("String" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Boolean" & z.core.$brand<"PXL.DatabaseFieldType">) | ("DateTime" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Decimal" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Float" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Int" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Json" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Bytes" & z.core.$brand<"PXL.DatabaseFieldType">);
31
- databaseName: string & z.core.$brand<"PXL.DatabaseFieldName">;
32
- excelName: string & z.core.$brand<"PXL.ExcelColumnName">;
28
+ name: "id" & z.$brand<"PXL.FieldName"> & z.$brand<"PXL.FieldName.Id">;
29
+ unbrandedTypeName: ("number" & z.$brand<"PXL.ScalarIdType"> & z.$brand<"PXL.ScalarType"> & z.$brand<"PXL.Type">) | ("string" & z.$brand<"PXL.ScalarIdType"> & z.$brand<"PXL.ScalarType"> & z.$brand<"PXL.Type">);
30
+ databaseType: ("BigInt" & z.$brand<"PXL.DatabaseFieldType">) | ("Boolean" & z.$brand<"PXL.DatabaseFieldType">) | ("Bytes" & z.$brand<"PXL.DatabaseFieldType">) | ("DateTime" & z.$brand<"PXL.DatabaseFieldType">) | ("Decimal" & z.$brand<"PXL.DatabaseFieldType">) | ("Float" & z.$brand<"PXL.DatabaseFieldType">) | ("Int" & z.$brand<"PXL.DatabaseFieldType">) | ("Json" & z.$brand<"PXL.DatabaseFieldType">) | ("String" & z.$brand<"PXL.DatabaseFieldType">);
31
+ databaseName: string & z.$brand<"PXL.DatabaseFieldName">;
32
+ excelName: string & z.$brand<"PXL.ExcelColumnName">;
33
33
  description: string;
34
34
  label: string;
35
35
  hasIndex: true;
36
36
  isReadonly: boolean;
37
+ isSystemManaged: false;
37
38
  isRequired: true;
38
39
  isUnique: true;
39
40
  isCreatedAt: false;
40
41
  isUpdatedAt: false;
41
42
  seed: import(".").FieldSeedConfig;
42
- } | FieldScalarEnriched | FieldJsonEnriched | {
43
- kind: "relation";
44
- type: string & z.core.$brand<"PXL.IdType"> & z.core.$brand<"PXL.Type">;
45
- name: string & z.core.$brand<"PXL.FieldName">;
46
- referencedModelName: string & z.core.$brand<"PXL.ModelName">;
43
+ } | {
44
+ kind: "enum";
45
+ type: string & z.$brand<"PXL.EnumType"> & z.$brand<"PXL.Type">;
46
+ name: string & z.$brand<"PXL.FieldName">;
47
+ referencedEnumName: string & z.$brand<"PXL.EnumName">;
47
48
  label: string;
48
- databaseName: string & z.core.$brand<"PXL.DatabaseFieldName">;
49
- prismaRelationFieldName: (string & z.core.$brand<"PXL.DatabaseFieldName">) | undefined;
50
- excelName: string & z.core.$brand<"PXL.ExcelColumnName">;
51
- deepClone: boolean;
52
- onDelete: "cascade" | "setNull" | "restrict";
49
+ databaseName: string & z.$brand<"PXL.DatabaseFieldName">;
50
+ excelName: string & z.$brand<"PXL.ExcelColumnName">;
53
51
  description: string | undefined;
54
- isReadonly: boolean;
55
52
  isRequired: boolean;
53
+ isReadonly: boolean;
54
+ isSystemManaged: boolean;
56
55
  isUnique: boolean;
57
- validations: never[];
58
- generation: string;
56
+ defaultValue: string | undefined;
59
57
  } | {
60
- kind: "enum";
61
- type: string & z.core.$brand<"PXL.EnumType"> & z.core.$brand<"PXL.Type">;
62
- name: string & z.core.$brand<"PXL.FieldName">;
63
- referencedEnumName: string & z.core.$brand<"PXL.EnumName">;
58
+ kind: "relation";
59
+ type: string & z.$brand<"PXL.IdType"> & z.$brand<"PXL.Type">;
60
+ name: string & z.$brand<"PXL.FieldName">;
61
+ referencedModelName: string & z.$brand<"PXL.ModelName">;
64
62
  label: string;
65
- databaseName: string & z.core.$brand<"PXL.DatabaseFieldName">;
66
- excelName: string & z.core.$brand<"PXL.ExcelColumnName">;
63
+ databaseName: string & z.$brand<"PXL.DatabaseFieldName">;
64
+ prismaRelationFieldName: (string & z.$brand<"PXL.DatabaseFieldName">) | undefined;
65
+ excelName: string & z.$brand<"PXL.ExcelColumnName">;
66
+ deepClone: boolean;
67
+ onDelete: "cascade" | "restrict" | "setNull";
67
68
  description: string | undefined;
68
- isRequired: boolean;
69
69
  isReadonly: boolean;
70
+ isSystemManaged: boolean;
71
+ isRequired: boolean;
70
72
  isUnique: boolean;
71
- }, unknown>>;
73
+ validations: never[];
74
+ generation: string;
75
+ } | FieldScalarEnriched, unknown>>;
72
76
  export type FieldEnriched = FieldIdEnriched | FieldScalarEnriched | FieldJsonEnriched | FieldRelationEnriched | FieldEnumEnriched;
73
77
  export type FieldEnrichedNativeDatabase = FieldIdEnriched | FieldScalarEnriched | FieldJsonEnriched | FieldRelationEnriched | FieldEnumEnriched;
74
78
  export declare const zFieldJSONInput: (params: {
@@ -92,6 +96,7 @@ export declare const zFieldJSONInput: (params: {
92
96
  label: z.ZodOptional<z.ZodString>;
93
97
  description: z.ZodOptional<z.ZodString>;
94
98
  isReadonly: z.ZodOptional<z.ZodBoolean>;
99
+ isSystemManaged: z.ZodOptional<z.ZodBoolean>;
95
100
  isUnique: z.ZodOptional<z.ZodBoolean>;
96
101
  hasIndex: z.ZodOptional<z.ZodBoolean>;
97
102
  isCreatedAt: z.ZodOptional<z.ZodBoolean>;
@@ -111,6 +116,7 @@ export declare const zFieldJSONInput: (params: {
111
116
  label: z.ZodOptional<z.ZodString>;
112
117
  description: z.ZodOptional<z.ZodString>;
113
118
  isReadonly: z.ZodOptional<z.ZodBoolean>;
119
+ isSystemManaged: z.ZodOptional<z.ZodBoolean>;
114
120
  isUnique: z.ZodOptional<z.ZodBoolean>;
115
121
  hasIndex: z.ZodOptional<z.ZodBoolean>;
116
122
  placeholder: z.ZodOptional<z.ZodString>;
@@ -123,12 +129,13 @@ export declare const zFieldJSONInput: (params: {
123
129
  deepClone: z.ZodOptional<z.ZodBoolean>;
124
130
  onDelete: z.ZodOptional<z.ZodEnum<{
125
131
  cascade: "cascade";
126
- setNull: "setNull";
127
132
  restrict: "restrict";
133
+ setNull: "setNull";
128
134
  }>>;
129
135
  label: z.ZodOptional<z.ZodString>;
130
136
  description: z.ZodOptional<z.ZodString>;
131
137
  isReadonly: z.ZodOptional<z.ZodBoolean>;
138
+ isSystemManaged: z.ZodOptional<z.ZodBoolean>;
132
139
  isUnique: z.ZodOptional<z.ZodBoolean>;
133
140
  }, z.core.$strip>, z.ZodObject<{
134
141
  name: z.ZodString;
@@ -138,7 +145,9 @@ export declare const zFieldJSONInput: (params: {
138
145
  label: z.ZodOptional<z.ZodString>;
139
146
  description: z.ZodOptional<z.ZodString>;
140
147
  isReadonly: z.ZodOptional<z.ZodBoolean>;
148
+ isSystemManaged: z.ZodOptional<z.ZodBoolean>;
141
149
  isUnique: z.ZodOptional<z.ZodBoolean>;
150
+ defaultValue: z.ZodOptional<z.ZodString>;
142
151
  }, z.core.$strip>]>;
143
152
  export type FieldJSONInput = z.infer<ReturnType<typeof zFieldJSONInput>>;
144
153
  export declare const fieldTransformer: (fieldInput: FieldEnriched, model: {
@@ -150,7 +159,7 @@ export declare const fieldTransformer: (fieldInput: FieldEnriched, model: {
150
159
  name: Model.ModelName;
151
160
  isReadonly?: boolean;
152
161
  }>;
153
- }, ctx: z.RefinementCtx) => FieldRelation | FieldId | FieldScalar | FieldJson | FieldEnum;
162
+ }, ctx: z.RefinementCtx) => FieldScalar | FieldEnum | FieldId | FieldJson | FieldRelation;
154
163
  export type FieldDatabaseNative = FieldId | FieldScalar | FieldJson | FieldRelation | FieldEnum;
155
164
  export type Field = FieldDatabaseNative;
156
165
  export type Fields<FIELD = Field> = Map<Branded.FieldName, FIELD>;
@@ -66,15 +66,16 @@ export declare const zFieldId: z.ZodPipe<z.ZodObject<{
66
66
  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]>>]>>;
67
67
  }, z.core.$strip>, z.ZodTransform<{
68
68
  kind: "id";
69
- name: "id" & z.core.$brand<"PXL.FieldName"> & z.core.$brand<"PXL.FieldName.Id">;
70
- unbrandedTypeName: ("string" & z.core.$brand<"PXL.ScalarIdType"> & z.core.$brand<"PXL.ScalarType"> & z.core.$brand<"PXL.Type">) | ("number" & z.core.$brand<"PXL.ScalarIdType"> & z.core.$brand<"PXL.ScalarType"> & z.core.$brand<"PXL.Type">);
71
- databaseType: ("BigInt" & z.core.$brand<"PXL.DatabaseFieldType">) | ("String" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Boolean" & z.core.$brand<"PXL.DatabaseFieldType">) | ("DateTime" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Decimal" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Float" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Int" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Json" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Bytes" & z.core.$brand<"PXL.DatabaseFieldType">);
72
- databaseName: string & z.core.$brand<"PXL.DatabaseFieldName">;
73
- excelName: string & z.core.$brand<"PXL.ExcelColumnName">;
69
+ name: "id" & z.$brand<"PXL.FieldName"> & z.$brand<"PXL.FieldName.Id">;
70
+ unbrandedTypeName: ("number" & z.$brand<"PXL.ScalarIdType"> & z.$brand<"PXL.ScalarType"> & z.$brand<"PXL.Type">) | ("string" & z.$brand<"PXL.ScalarIdType"> & z.$brand<"PXL.ScalarType"> & z.$brand<"PXL.Type">);
71
+ databaseType: ("BigInt" & z.$brand<"PXL.DatabaseFieldType">) | ("Boolean" & z.$brand<"PXL.DatabaseFieldType">) | ("Bytes" & z.$brand<"PXL.DatabaseFieldType">) | ("DateTime" & z.$brand<"PXL.DatabaseFieldType">) | ("Decimal" & z.$brand<"PXL.DatabaseFieldType">) | ("Float" & z.$brand<"PXL.DatabaseFieldType">) | ("Int" & z.$brand<"PXL.DatabaseFieldType">) | ("Json" & z.$brand<"PXL.DatabaseFieldType">) | ("String" & z.$brand<"PXL.DatabaseFieldType">);
72
+ databaseName: string & z.$brand<"PXL.DatabaseFieldName">;
73
+ excelName: string & z.$brand<"PXL.ExcelColumnName">;
74
74
  description: string;
75
75
  label: string;
76
76
  hasIndex: true;
77
77
  isReadonly: boolean;
78
+ isSystemManaged: false;
78
79
  isRequired: true;
79
80
  isUnique: true;
80
81
  isCreatedAt: false;
@@ -82,26 +83,27 @@ export declare const zFieldId: z.ZodPipe<z.ZodObject<{
82
83
  seed: FieldSeedConfig;
83
84
  }, {
84
85
  name: "id";
85
- type: "String" | "Int";
86
+ type: "Int" | "String";
86
87
  databaseName?: string | undefined;
87
88
  excelName?: string | undefined;
88
89
  label?: string | undefined;
89
90
  description?: string | undefined;
90
91
  isReadonly?: boolean | undefined;
91
92
  faker?: string | undefined;
92
- seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
93
+ seed?: string | number | boolean | (string | number | boolean | Date)[] | Date | undefined;
93
94
  }>>;
94
95
  export declare function fieldIdJSONTransformer(fieldInput: FieldIdJSON, ctx: z.RefinementCtx): {
95
96
  kind: "id";
96
- name: "id" & z.core.$brand<"PXL.FieldName"> & z.core.$brand<"PXL.FieldName.Id">;
97
- unbrandedTypeName: ("string" & z.core.$brand<"PXL.ScalarIdType"> & z.core.$brand<"PXL.ScalarType"> & z.core.$brand<"PXL.Type">) | ("number" & z.core.$brand<"PXL.ScalarIdType"> & z.core.$brand<"PXL.ScalarType"> & z.core.$brand<"PXL.Type">);
98
- databaseType: ("BigInt" & z.core.$brand<"PXL.DatabaseFieldType">) | ("String" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Boolean" & z.core.$brand<"PXL.DatabaseFieldType">) | ("DateTime" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Decimal" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Float" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Int" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Json" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Bytes" & z.core.$brand<"PXL.DatabaseFieldType">);
99
- databaseName: string & z.core.$brand<"PXL.DatabaseFieldName">;
100
- excelName: string & z.core.$brand<"PXL.ExcelColumnName">;
97
+ name: "id" & z.$brand<"PXL.FieldName"> & z.$brand<"PXL.FieldName.Id">;
98
+ unbrandedTypeName: ("number" & z.$brand<"PXL.ScalarIdType"> & z.$brand<"PXL.ScalarType"> & z.$brand<"PXL.Type">) | ("string" & z.$brand<"PXL.ScalarIdType"> & z.$brand<"PXL.ScalarType"> & z.$brand<"PXL.Type">);
99
+ databaseType: ("BigInt" & z.$brand<"PXL.DatabaseFieldType">) | ("Boolean" & z.$brand<"PXL.DatabaseFieldType">) | ("Bytes" & z.$brand<"PXL.DatabaseFieldType">) | ("DateTime" & z.$brand<"PXL.DatabaseFieldType">) | ("Decimal" & z.$brand<"PXL.DatabaseFieldType">) | ("Float" & z.$brand<"PXL.DatabaseFieldType">) | ("Int" & z.$brand<"PXL.DatabaseFieldType">) | ("Json" & z.$brand<"PXL.DatabaseFieldType">) | ("String" & z.$brand<"PXL.DatabaseFieldType">);
100
+ databaseName: string & z.$brand<"PXL.DatabaseFieldName">;
101
+ excelName: string & z.$brand<"PXL.ExcelColumnName">;
101
102
  description: string;
102
103
  label: string;
103
104
  hasIndex: true;
104
105
  isReadonly: boolean;
106
+ isSystemManaged: false;
105
107
  isRequired: true;
106
108
  isUnique: true;
107
109
  isCreatedAt: false;
package/dist/field/id.js CHANGED
@@ -81,6 +81,9 @@ function fieldIdJSONTransformer(fieldInput, ctx) {
81
81
  label: fieldInput.label ?? 'Id',
82
82
  hasIndex: true,
83
83
  isReadonly: fieldInput.isReadonly ?? false,
84
+ // The id is never written by anyone after creation, so the human/runtime split that
85
+ // `isSystemManaged` draws does not apply to it - every write surface already excludes it.
86
+ isSystemManaged: false,
84
87
  isRequired: true,
85
88
  isUnique: true,
86
89
  isCreatedAt: false,
@@ -36,6 +36,7 @@ export declare const zFieldJsonJSON: z.ZodObject<{
36
36
  label: z.ZodOptional<z.ZodString>;
37
37
  description: z.ZodOptional<z.ZodString>;
38
38
  isReadonly: z.ZodOptional<z.ZodBoolean>;
39
+ isSystemManaged: z.ZodOptional<z.ZodBoolean>;
39
40
  isUnique: z.ZodOptional<z.ZodBoolean>;
40
41
  hasIndex: z.ZodOptional<z.ZodBoolean>;
41
42
  placeholder: z.ZodOptional<z.ZodString>;
@@ -51,17 +52,19 @@ export declare const zFieldJson: z.ZodPipe<z.ZodObject<{
51
52
  label: z.ZodOptional<z.ZodString>;
52
53
  description: z.ZodOptional<z.ZodString>;
53
54
  isReadonly: z.ZodOptional<z.ZodBoolean>;
55
+ isSystemManaged: z.ZodOptional<z.ZodBoolean>;
54
56
  isUnique: z.ZodOptional<z.ZodBoolean>;
55
57
  hasIndex: z.ZodOptional<z.ZodBoolean>;
56
58
  placeholder: z.ZodOptional<z.ZodString>;
57
59
  }, z.core.$strict>, z.ZodTransform<FieldJsonEnriched, {
58
60
  name: string;
59
- type: "Json" | "JSON" | "Json?" | "JSON?";
61
+ type: "JSON" | "JSON?" | "Json" | "Json?";
60
62
  databaseName?: string | undefined;
61
63
  excelName?: string | undefined;
62
64
  label?: string | undefined;
63
65
  description?: string | undefined;
64
66
  isReadonly?: boolean | undefined;
67
+ isSystemManaged?: boolean | undefined;
65
68
  isUnique?: boolean | undefined;
66
69
  hasIndex?: boolean | undefined;
67
70
  placeholder?: string | undefined;
@@ -67,6 +67,7 @@ exports.zFieldJsonJSON = zod_1.z
67
67
  label: Decoders.zFieldPropertyLabel,
68
68
  description: Decoders.zFieldPropertyDescription,
69
69
  isReadonly: Decoders.zFieldPropertyIsReadonly,
70
+ isSystemManaged: Decoders.zFieldPropertyIsSystemManaged,
70
71
  isUnique: Decoders.zFieldPropertyIsUnique,
71
72
  hasIndex: Decoders.zFieldPropertyHasIndex,
72
73
  placeholder: Decoders.zFieldPropertyPlaceholder,
@@ -86,6 +87,7 @@ function fieldJsonJSONTransformer(fieldInput) {
86
87
  label,
87
88
  hasIndex: fieldInput.hasIndex ?? false,
88
89
  isReadonly: fieldInput.isReadonly ?? false,
90
+ isSystemManaged: fieldInput.isSystemManaged ?? false,
89
91
  isRequired: required.isRequired,
90
92
  isUnique: fieldInput.isUnique ?? false,
91
93
  generation: '',
@@ -11,7 +11,7 @@ export declare const fieldKindRelation: FieldKindRelation;
11
11
  * keeps internal caches consistent.
12
12
  */
13
13
  export type OnDeleteBehavior = 'cascade' | 'setNull' | 'restrict';
14
- export declare const onDeleteBehaviors: readonly ["cascade", "setNull", "restrict"];
14
+ export declare const onDeleteBehaviors: readonly ['cascade', 'setNull', 'restrict'];
15
15
  export type FieldRelation = FieldCommon<FieldKindRelation> & {
16
16
  type: Branded.IdType;
17
17
  referencedModelName: ModelName;
@@ -57,28 +57,30 @@ export declare const createRelationJSONDecoder: ({ modelNames }: {
57
57
  deepClone: z.ZodOptional<z.ZodBoolean>;
58
58
  onDelete: z.ZodOptional<z.ZodEnum<{
59
59
  cascade: "cascade";
60
- setNull: "setNull";
61
60
  restrict: "restrict";
61
+ setNull: "setNull";
62
62
  }>>;
63
63
  label: z.ZodOptional<z.ZodString>;
64
64
  description: z.ZodOptional<z.ZodString>;
65
65
  isReadonly: z.ZodOptional<z.ZodBoolean>;
66
+ isSystemManaged: z.ZodOptional<z.ZodBoolean>;
66
67
  isUnique: z.ZodOptional<z.ZodBoolean>;
67
68
  }, z.core.$strip>;
68
69
  export type FieldRelationJSON = z.infer<ReturnType<typeof createRelationJSONDecoder>>;
69
70
  export declare function fieldRelationJSONTransformer(fieldInput: FieldRelationJSON): {
70
71
  kind: "relation";
71
- type: string & z.core.$brand<"PXL.IdType"> & z.core.$brand<"PXL.Type">;
72
- name: string & z.core.$brand<"PXL.FieldName">;
73
- referencedModelName: string & z.core.$brand<"PXL.ModelName">;
72
+ type: string & z.$brand<"PXL.IdType"> & z.$brand<"PXL.Type">;
73
+ name: string & z.$brand<"PXL.FieldName">;
74
+ referencedModelName: string & z.$brand<"PXL.ModelName">;
74
75
  label: string;
75
- databaseName: string & z.core.$brand<"PXL.DatabaseFieldName">;
76
- prismaRelationFieldName: (string & z.core.$brand<"PXL.DatabaseFieldName">) | undefined;
77
- excelName: string & z.core.$brand<"PXL.ExcelColumnName">;
76
+ databaseName: string & z.$brand<"PXL.DatabaseFieldName">;
77
+ prismaRelationFieldName: (string & z.$brand<"PXL.DatabaseFieldName">) | undefined;
78
+ excelName: string & z.$brand<"PXL.ExcelColumnName">;
78
79
  deepClone: boolean;
79
- onDelete: "cascade" | "setNull" | "restrict";
80
+ onDelete: "cascade" | "restrict" | "setNull";
80
81
  description: string | undefined;
81
82
  isReadonly: boolean;
83
+ isSystemManaged: boolean;
82
84
  isRequired: boolean;
83
85
  isUnique: boolean;
84
86
  validations: never[];
@@ -80,6 +80,7 @@ const createRelationJSONDecoder = ({ modelNames }) => {
80
80
  label: Decoders.zFieldPropertyLabel,
81
81
  description: Decoders.zFieldPropertyDescription,
82
82
  isReadonly: Decoders.zFieldPropertyIsReadonly,
83
+ isSystemManaged: Decoders.zFieldPropertyIsSystemManaged,
83
84
  isUnique: Decoders.zFieldPropertyIsUnique,
84
85
  });
85
86
  };
@@ -103,6 +104,7 @@ function fieldRelationJSONTransformer(fieldInput) {
103
104
  onDelete: fieldInput.onDelete ?? 'cascade',
104
105
  description: fieldInput.description,
105
106
  isReadonly: fieldInput.isReadonly ?? false,
107
+ isSystemManaged: fieldInput.isSystemManaged ?? false,
106
108
  isRequired,
107
109
  isUnique: fieldInput.isUnique ?? false,
108
110
  validations: [],
@@ -75,6 +75,7 @@ export declare const zFieldScalarJSON: z.ZodObject<{
75
75
  label: z.ZodOptional<z.ZodString>;
76
76
  description: z.ZodOptional<z.ZodString>;
77
77
  isReadonly: z.ZodOptional<z.ZodBoolean>;
78
+ isSystemManaged: z.ZodOptional<z.ZodBoolean>;
78
79
  isUnique: z.ZodOptional<z.ZodBoolean>;
79
80
  hasIndex: z.ZodOptional<z.ZodBoolean>;
80
81
  isCreatedAt: z.ZodOptional<z.ZodBoolean>;
@@ -102,6 +103,7 @@ export declare const zFieldScalar: z.ZodPipe<z.ZodObject<{
102
103
  label: z.ZodOptional<z.ZodString>;
103
104
  description: z.ZodOptional<z.ZodString>;
104
105
  isReadonly: z.ZodOptional<z.ZodBoolean>;
106
+ isSystemManaged: z.ZodOptional<z.ZodBoolean>;
105
107
  isUnique: z.ZodOptional<z.ZodBoolean>;
106
108
  hasIndex: z.ZodOptional<z.ZodBoolean>;
107
109
  isCreatedAt: z.ZodOptional<z.ZodBoolean>;
@@ -115,12 +117,13 @@ export declare const zFieldScalar: z.ZodPipe<z.ZodObject<{
115
117
  defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
116
118
  }, z.core.$strict>, z.ZodTransform<FieldScalarEnriched, {
117
119
  name: string;
118
- type: "BigInt" | "String" | "Boolean" | "DateTime" | "Decimal" | "Float" | "Int" | "Bytes" | "String?" | "Int?" | "Boolean?" | "DateTime?" | "Decimal?" | "Float?" | "Bytes?" | "BigInt?";
120
+ type: "BigInt" | "BigInt?" | "Boolean" | "Boolean?" | "Bytes" | "Bytes?" | "DateTime" | "DateTime?" | "Decimal" | "Decimal?" | "Float" | "Float?" | "Int" | "Int?" | "String" | "String?";
119
121
  databaseName?: string | undefined;
120
122
  excelName?: string | undefined;
121
123
  label?: string | undefined;
122
124
  description?: string | undefined;
123
125
  isReadonly?: boolean | undefined;
126
+ isSystemManaged?: boolean | undefined;
124
127
  isUnique?: boolean | undefined;
125
128
  hasIndex?: boolean | undefined;
126
129
  isCreatedAt?: boolean | undefined;
@@ -129,7 +132,7 @@ export declare const zFieldScalar: z.ZodPipe<z.ZodObject<{
129
132
  min?: number | undefined;
130
133
  max?: number | undefined;
131
134
  faker?: string | undefined;
132
- seed?: string | number | boolean | Date | (string | number | boolean | Date)[] | undefined;
135
+ seed?: string | number | boolean | (string | number | boolean | Date)[] | Date | undefined;
133
136
  placeholder?: string | undefined;
134
137
  defaultValue?: string | number | boolean | undefined;
135
138
  }>>;
@@ -108,6 +108,7 @@ exports.zFieldScalarJSON = zod_1.z
108
108
  label: Decoders.zFieldPropertyLabel,
109
109
  description: Decoders.zFieldPropertyDescription,
110
110
  isReadonly: Decoders.zFieldPropertyIsReadonly,
111
+ isSystemManaged: Decoders.zFieldPropertyIsSystemManaged,
111
112
  isUnique: Decoders.zFieldPropertyIsUnique,
112
113
  hasIndex: Decoders.zFieldPropertyHasIndex,
113
114
  isCreatedAt: Decoders.zFieldPropertyIsCreatedAt,
@@ -255,6 +256,7 @@ function fieldScalarJSONTransformer(fieldInput, ctx) {
255
256
  label,
256
257
  hasIndex: fieldInput.hasIndex ?? false,
257
258
  isReadonly: fieldInput.isReadonly ?? (isCreatedAt || isUpdatedAt),
259
+ isSystemManaged: fieldInput.isSystemManaged ?? false,
258
260
  isRequired,
259
261
  isUnique: fieldInput.isUnique ?? false,
260
262
  isCreatedAt,
@@ -2,34 +2,34 @@ import { z } from 'zod';
2
2
  import { ModelName } from '../../model/model.brands';
3
3
  export declare const zFieldName: z.core.$ZodBranded<z.ZodString, "PXL.FieldName", "out">;
4
4
  export type FieldName = z.infer<typeof zFieldName>;
5
- export declare const toFieldName: (input: string) => string & z.core.$brand<"PXL.FieldName">;
5
+ export declare const toFieldName: (input: string) => string & z.$brand<"PXL.FieldName">;
6
6
  export declare const zFieldIdName: z.core.$ZodBranded<z.core.$ZodBranded<z.ZodLiteral<"id">, "PXL.FieldName", "out">, "PXL.FieldName.Id", "out">;
7
7
  export type FieldIdName = z.infer<typeof zFieldIdName>;
8
- export declare const toFieldIdName: (input: string) => "id" & z.core.$brand<"PXL.FieldName"> & z.core.$brand<"PXL.FieldName.Id">;
8
+ export declare const toFieldIdName: (input: string) => "id" & z.$brand<"PXL.FieldName"> & z.$brand<"PXL.FieldName.Id">;
9
9
  export declare const zDatabaseFieldName: z.core.$ZodBranded<z.ZodString, "PXL.DatabaseFieldName", "out">;
10
10
  export type DatabaseFieldName = z.infer<typeof zDatabaseFieldName>;
11
- export declare const toDatabaseFieldName: (input: string) => string & z.core.$brand<"PXL.DatabaseFieldName">;
11
+ export declare const toDatabaseFieldName: (input: string) => string & z.$brand<"PXL.DatabaseFieldName">;
12
12
  export declare const zExcelColumnName: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "PXL.ExcelColumnName", "out">;
13
13
  export type ExcelColumnName = z.infer<typeof zExcelColumnName>;
14
- export declare const toExcelColumnName: (input: string) => string & z.core.$brand<"PXL.ExcelColumnName">;
14
+ export declare const toExcelColumnName: (input: string) => string & z.$brand<"PXL.ExcelColumnName">;
15
15
  export declare const zFieldLabel: z.core.$ZodBranded<z.ZodString, "PXL.FieldLabel", "out">;
16
16
  export type FieldLabel = z.infer<typeof zFieldLabel>;
17
- export declare const toFieldLabel: (input: string) => string & z.core.$brand<"PXL.FieldLabel">;
17
+ export declare const toFieldLabel: (input: string) => string & z.$brand<"PXL.FieldLabel">;
18
18
  export declare const zType: z.core.$ZodBranded<z.ZodString, "PXL.Type", "out">;
19
19
  export type Type = z.infer<typeof zType>;
20
- export declare const toType: (input: string) => string & z.core.$brand<"PXL.Type">;
20
+ export declare const toType: (input: string) => string & z.$brand<"PXL.Type">;
21
21
  export declare const zIdType: z.core.$ZodBranded<z.core.$ZodBranded<z.ZodString, "PXL.IdType", "out">, "PXL.Type", "out">;
22
22
  export type IdType = z.infer<typeof zIdType>;
23
- export declare const toIdType: (input: ModelName) => string & z.core.$brand<"PXL.IdType"> & z.core.$brand<"PXL.Type">;
23
+ export declare const toIdType: (input: ModelName) => string & z.$brand<"PXL.IdType"> & z.$brand<"PXL.Type">;
24
24
  export declare const zScalarType: z.core.$ZodBranded<z.core.$ZodBranded<z.ZodUnion<readonly [z.ZodLiteral<"string">, z.ZodLiteral<"number">, z.ZodLiteral<"boolean">, z.ZodLiteral<"Date">]>, "PXL.ScalarType", "out">, "PXL.Type", "out">;
25
25
  export type ScalarType = z.infer<typeof zScalarType>;
26
- export declare const toScalarType: (input: string) => ("string" & z.core.$brand<"PXL.ScalarType"> & z.core.$brand<"PXL.Type">) | ("number" & z.core.$brand<"PXL.ScalarType"> & z.core.$brand<"PXL.Type">) | ("boolean" & z.core.$brand<"PXL.ScalarType"> & z.core.$brand<"PXL.Type">) | ("Date" & z.core.$brand<"PXL.ScalarType"> & z.core.$brand<"PXL.Type">);
26
+ export declare const toScalarType: (input: string) => ("Date" & z.$brand<"PXL.ScalarType"> & z.$brand<"PXL.Type">) | ("boolean" & z.$brand<"PXL.ScalarType"> & z.$brand<"PXL.Type">) | ("number" & z.$brand<"PXL.ScalarType"> & z.$brand<"PXL.Type">) | ("string" & z.$brand<"PXL.ScalarType"> & z.$brand<"PXL.Type">);
27
27
  export declare const zScalarIdType: z.core.$ZodBranded<z.core.$ZodBranded<z.core.$ZodBranded<z.ZodUnion<readonly [z.ZodLiteral<"string">, z.ZodLiteral<"number">]>, "PXL.ScalarIdType", "out">, "PXL.ScalarType", "out">, "PXL.Type", "out">;
28
28
  export type ScalarIdType = z.infer<typeof zScalarIdType>;
29
- export declare const toScalarIdType: (input: string) => ("string" & z.core.$brand<"PXL.ScalarIdType"> & z.core.$brand<"PXL.ScalarType"> & z.core.$brand<"PXL.Type">) | ("number" & z.core.$brand<"PXL.ScalarIdType"> & z.core.$brand<"PXL.ScalarType"> & z.core.$brand<"PXL.Type">);
29
+ export declare const toScalarIdType: (input: string) => ("number" & z.$brand<"PXL.ScalarIdType"> & z.$brand<"PXL.ScalarType"> & z.$brand<"PXL.Type">) | ("string" & z.$brand<"PXL.ScalarIdType"> & z.$brand<"PXL.ScalarType"> & z.$brand<"PXL.Type">);
30
30
  export declare const zEnumType: z.core.$ZodBranded<z.core.$ZodBranded<z.ZodString, "PXL.EnumType", "out">, "PXL.Type", "out">;
31
31
  export type EnumType = z.infer<typeof zEnumType>;
32
- export declare const toEnumType: (input: string) => string & z.core.$brand<"PXL.EnumType"> & z.core.$brand<"PXL.Type">;
32
+ export declare const toEnumType: (input: string) => string & z.$brand<"PXL.EnumType"> & z.$brand<"PXL.Type">;
33
33
  export declare const zDatabaseFieldType: z.core.$ZodBranded<z.ZodUnion<readonly [z.ZodLiteral<"BigInt">, z.ZodLiteral<"String">, z.ZodLiteral<"Boolean">, z.ZodLiteral<"DateTime">, z.ZodLiteral<"Decimal">, z.ZodLiteral<"Float">, z.ZodLiteral<"Int">, z.ZodLiteral<"Json">, z.ZodLiteral<"Bytes">]>, "PXL.DatabaseFieldType", "out">;
34
34
  export type DatabaseFieldType = z.infer<typeof zDatabaseFieldType>;
35
- export declare const toDatabaseFieldType: (input: string) => ("BigInt" & z.core.$brand<"PXL.DatabaseFieldType">) | ("String" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Boolean" & z.core.$brand<"PXL.DatabaseFieldType">) | ("DateTime" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Decimal" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Float" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Int" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Json" & z.core.$brand<"PXL.DatabaseFieldType">) | ("Bytes" & z.core.$brand<"PXL.DatabaseFieldType">);
35
+ export declare const toDatabaseFieldType: (input: string) => ("BigInt" & z.$brand<"PXL.DatabaseFieldType">) | ("Boolean" & z.$brand<"PXL.DatabaseFieldType">) | ("Bytes" & z.$brand<"PXL.DatabaseFieldType">) | ("DateTime" & z.$brand<"PXL.DatabaseFieldType">) | ("Decimal" & z.$brand<"PXL.DatabaseFieldType">) | ("Float" & z.$brand<"PXL.DatabaseFieldType">) | ("Int" & z.$brand<"PXL.DatabaseFieldType">) | ("Json" & z.$brand<"PXL.DatabaseFieldType">) | ("String" & z.$brand<"PXL.DatabaseFieldType">);
@@ -6,6 +6,7 @@ export declare const zFieldPropertyExcelName: z.ZodOptional<z.ZodString>;
6
6
  export declare const zFieldPropertyLabel: z.ZodOptional<z.ZodString>;
7
7
  export declare const zFieldPropertyDescription: z.ZodOptional<z.ZodString>;
8
8
  export declare const zFieldPropertyIsReadonly: z.ZodOptional<z.ZodBoolean>;
9
+ export declare const zFieldPropertyIsSystemManaged: z.ZodOptional<z.ZodBoolean>;
9
10
  export declare const zFieldPropertyIsUnique: z.ZodOptional<z.ZodBoolean>;
10
11
  export declare const zFieldPropertyHasIndex: z.ZodOptional<z.ZodBoolean>;
11
12
  export declare const zFieldPropertyIsCreatedAt: z.ZodOptional<z.ZodBoolean>;