@mikemajesty/zod-mock-schema 1.0.13 → 1.0.15
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/README.md +162 -57
- package/dist/__tests__/advanced-schemas.spec.d.ts +1 -0
- package/dist/__tests__/advanced-schemas.spec.js +149 -0
- package/dist/__tests__/advanced-schemas.spec.js.map +1 -0
- package/dist/__tests__/brazilian-formats.spec.d.ts +1 -0
- package/dist/__tests__/brazilian-formats.spec.js +205 -0
- package/dist/__tests__/brazilian-formats.spec.js.map +1 -0
- package/dist/__tests__/complex-intersections.spec.d.ts +1 -0
- package/dist/__tests__/complex-intersections.spec.js +176 -0
- package/dist/__tests__/complex-intersections.spec.js.map +1 -0
- package/dist/__tests__/edge-cases.spec.d.ts +1 -0
- package/dist/__tests__/edge-cases.spec.js +206 -0
- package/dist/__tests__/edge-cases.spec.js.map +1 -0
- package/dist/__tests__/faker-injection.spec.d.ts +1 -0
- package/dist/__tests__/faker-injection.spec.js +110 -0
- package/dist/__tests__/faker-injection.spec.js.map +1 -0
- package/dist/__tests__/overrides-all-types.spec.d.ts +1 -0
- package/dist/__tests__/overrides-all-types.spec.js +283 -0
- package/dist/__tests__/overrides-all-types.spec.js.map +1 -0
- package/dist/__tests__/overrides.spec.d.ts +1 -0
- package/dist/__tests__/overrides.spec.js +345 -0
- package/dist/__tests__/overrides.spec.js.map +1 -0
- package/dist/__tests__/unsupported-types.spec.d.ts +1 -0
- package/dist/__tests__/unsupported-types.spec.js +27 -0
- package/dist/__tests__/unsupported-types.spec.js.map +1 -0
- package/dist/__tests__/{zod-mock-schema.spec.d.ts → zod-types.spec.d.ts} +8 -8
- package/dist/__tests__/zod-types.spec.js +526 -0
- package/dist/__tests__/zod-types.spec.js.map +1 -0
- package/dist/constants.d.ts +46 -0
- package/dist/constants.js +83 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +29 -15
- package/dist/types.js +1 -2
- package/dist/zod-mock-schema.d.ts +17 -20
- package/dist/zod-mock-schema.js +324 -236
- package/dist/zod-mock-schema.js.map +1 -1
- package/package.json +14 -4
- package/dist/__tests__/zod-mock-schema.spec.js +0 -357
- package/dist/__tests__/zod-mock-schema.spec.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overrides.spec.js","sourceRoot":"","sources":["../../src/__tests__/overrides.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;YACvC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;gBACtB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;gBAChB,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE;aACjB,CAAC,CAAC;YAEH,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;YACvC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;gBAC3B,SAAS,EAAE;oBACT,IAAI,EAAE,aAAa;oBACnB,KAAK,EAAE,oBAAoB;iBAC5B;aACF,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACxC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;YACvC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;gBACtB,GAAG,EAAE,CAAC,CAAC,MAAM,EAA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M,IAAI,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;YACvC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;YAEhD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;YAClC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;YACjD,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;gBACtB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;gBAChB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;aAChB,CAAC,CAAC;YAEH,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;YACvC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAE/B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;YAClC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ZodMockSchema } from '../zod-mock-schema.js';
|
|
2
|
+
describe('Unsupported Schema Types', () => {
|
|
3
|
+
it('should throw informative error for unsupported types', () => {
|
|
4
|
+
const mockSchema = {};
|
|
5
|
+
mockSchema._def = { typeName: 'ZodCustomUnsupportedType' };
|
|
6
|
+
const mock = new ZodMockSchema(mockSchema);
|
|
7
|
+
expect(() => mock.generate()).toThrow('Unsupported Zod type: ZodCustomUnsupportedType');
|
|
8
|
+
expect(() => mock.generate()).toThrow('This schema type is not currently supported');
|
|
9
|
+
expect(() => mock.generate()).toThrow('please open an issue');
|
|
10
|
+
expect(() => mock.generate()).toThrow('https://github.com/mikemajesty/zod-mock-schema/issues');
|
|
11
|
+
});
|
|
12
|
+
it('should provide helpful error message format', () => {
|
|
13
|
+
const unsupportedSchema = {};
|
|
14
|
+
unsupportedSchema._def = { typeName: 'ZodFutureType' };
|
|
15
|
+
const mock = new ZodMockSchema(unsupportedSchema);
|
|
16
|
+
try {
|
|
17
|
+
mock.generate();
|
|
18
|
+
fail('Should have thrown an error');
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
expect(error.message).toContain('ZodFutureType');
|
|
22
|
+
expect(error.message).toContain('not currently supported');
|
|
23
|
+
expect(error.message).toContain('github.com');
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=unsupported-types.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsupported-types.spec.js","sourceRoot":"","sources":["../../src/__tests__/unsupported-types.spec.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAG9D,MAAM,UAAU,GAAG,EAAS,CAAC;QAC7B,UAAU,CAAC,IAAI,GAAG,EAAE,QAAQ,EAAE,0BAA0B,EAAE,CAAC;QAE3D,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;QAE3C,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,gDAAgD,CAAC,CAAC;QACxF,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,6CAA6C,CAAC,CAAC;QACrF,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;QAC9D,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,uDAAuD,CAAC,CAAC;IACjG,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,iBAAiB,GAAG,EAAS,CAAC;QACpC,iBAAiB,CAAC,IAAI,GAAG,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;QAEvD,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAAC;QAElD,IAAI,CAAC;YACH,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,6BAA6B,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;YACjD,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;YAC3D,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAChD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -204,21 +204,21 @@ export declare const PersonEntitySchema: z.ZodIntersection<z.ZodIntersection<z.Z
|
|
|
204
204
|
level: z.ZodNumber;
|
|
205
205
|
permissions: z.ZodArray<z.ZodObject<{
|
|
206
206
|
resource: z.ZodEnum<{
|
|
207
|
-
|
|
207
|
+
notifications: "notifications";
|
|
208
208
|
users: "users";
|
|
209
|
+
settings: "settings";
|
|
210
|
+
courses: "courses";
|
|
209
211
|
enrollments: "enrollments";
|
|
210
212
|
grades: "grades";
|
|
211
213
|
payments: "payments";
|
|
212
214
|
reports: "reports";
|
|
213
|
-
settings: "settings";
|
|
214
215
|
audit_logs: "audit_logs";
|
|
215
|
-
notifications: "notifications";
|
|
216
216
|
}>;
|
|
217
217
|
actions: z.ZodArray<z.ZodEnum<{
|
|
218
218
|
read: "read";
|
|
219
|
+
delete: "delete";
|
|
219
220
|
create: "create";
|
|
220
221
|
update: "update";
|
|
221
|
-
delete: "delete";
|
|
222
222
|
approve: "approve";
|
|
223
223
|
export: "export";
|
|
224
224
|
}>>;
|
|
@@ -228,7 +228,7 @@ export declare const PersonEntitySchema: z.ZodIntersection<z.ZodIntersection<z.Z
|
|
|
228
228
|
personal: "personal";
|
|
229
229
|
}>;
|
|
230
230
|
}, z.core.$strip>>;
|
|
231
|
-
reportsTo: z.ZodOptional<z.
|
|
231
|
+
reportsTo: z.ZodOptional<z.ZodUUID>;
|
|
232
232
|
managedDepartments: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
233
233
|
}, z.core.$strip>, z.ZodObject<{
|
|
234
234
|
type: z.ZodLiteral<"staff">;
|
|
@@ -281,7 +281,7 @@ export declare const PersonEntitySchema: z.ZodIntersection<z.ZodIntersection<z.Z
|
|
|
281
281
|
}>;
|
|
282
282
|
effectiveDate: z.ZodDate;
|
|
283
283
|
reason: z.ZodOptional<z.ZodString>;
|
|
284
|
-
changedBy: z.ZodOptional<z.
|
|
284
|
+
changedBy: z.ZodOptional<z.ZodUUID>;
|
|
285
285
|
}, z.core.$strip>>;
|
|
286
286
|
emergencyContacts: z.ZodArray<z.ZodObject<{
|
|
287
287
|
name: z.ZodString;
|
|
@@ -303,7 +303,7 @@ export declare const PersonEntitySchema: z.ZodIntersection<z.ZodIntersection<z.Z
|
|
|
303
303
|
issuingAuthority: z.ZodString;
|
|
304
304
|
issueDate: z.ZodDate;
|
|
305
305
|
expiryDate: z.ZodOptional<z.ZodDate>;
|
|
306
|
-
photoUrl: z.ZodOptional<z.
|
|
306
|
+
photoUrl: z.ZodOptional<z.ZodURL>;
|
|
307
307
|
verified: z.ZodDefault<z.ZodBoolean>;
|
|
308
308
|
}, z.core.$strip>, z.ZodObject<{
|
|
309
309
|
type: z.ZodLiteral<"passport">;
|
|
@@ -462,7 +462,7 @@ export declare const PersonEntitySchema: z.ZodIntersection<z.ZodIntersection<z.Z
|
|
|
462
462
|
}>>;
|
|
463
463
|
}, z.core.$strip>;
|
|
464
464
|
roleSpecificMetadata: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
465
|
-
advisorId: z.ZodOptional<z.
|
|
465
|
+
advisorId: z.ZodOptional<z.ZodUUID>;
|
|
466
466
|
thesisTitle: z.ZodOptional<z.ZodString>;
|
|
467
467
|
researchArea: z.ZodOptional<z.ZodString>;
|
|
468
468
|
publications: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
import { ZodMockSchema } from '../zod-mock-schema.js';
|
|
2
|
+
import z from 'zod';
|
|
3
|
+
const Identifiable = z.object({
|
|
4
|
+
id: z.uuid(),
|
|
5
|
+
createdAt: z.date(),
|
|
6
|
+
updatedAt: z.date().optional(),
|
|
7
|
+
deletedAt: z.date().optional().nullable(),
|
|
8
|
+
version: z.number().int().positive().default(1),
|
|
9
|
+
});
|
|
10
|
+
const Auditable = z.object({
|
|
11
|
+
createdBy: z.uuid(),
|
|
12
|
+
updatedBy: z.uuid().optional(),
|
|
13
|
+
deletedBy: z.uuid().optional().nullable(),
|
|
14
|
+
auditLog: z.array(z.object({
|
|
15
|
+
timestamp: z.date(),
|
|
16
|
+
action: z.enum(['CREATE', 'UPDATE', 'DELETE', 'RESTORE']),
|
|
17
|
+
userId: z.uuid(),
|
|
18
|
+
changes: z.record(z.string(), z.any()).optional(),
|
|
19
|
+
})).max(100).optional(),
|
|
20
|
+
});
|
|
21
|
+
const ContactInfo = z.object({
|
|
22
|
+
email: z.email(),
|
|
23
|
+
phone: z.string().regex(/^\d{10,11}$/),
|
|
24
|
+
alternativePhone: z.string().regex(/^\d{10,11}$/).optional(),
|
|
25
|
+
emergencyContact: z.object({
|
|
26
|
+
name: z.string(),
|
|
27
|
+
relationship: z.enum(['parent', 'spouse', 'child', 'sibling', 'friend', 'other']),
|
|
28
|
+
phone: z.string().regex(/^\d{10,11}$/),
|
|
29
|
+
priority: z.number().min(1).max(3),
|
|
30
|
+
}).optional(),
|
|
31
|
+
});
|
|
32
|
+
const Address = z.object({
|
|
33
|
+
street: z.string().min(3),
|
|
34
|
+
number: z.string(),
|
|
35
|
+
complement: z.string().optional(),
|
|
36
|
+
neighborhood: z.string(),
|
|
37
|
+
city: z.string(),
|
|
38
|
+
state: z.string().length(2).regex(/^[A-Z]{2}$/),
|
|
39
|
+
cep: z.string().regex(/^\d{8}$/),
|
|
40
|
+
country: z.string().default('BR'),
|
|
41
|
+
isPrimary: z.boolean().default(true),
|
|
42
|
+
type: z.enum(['home', 'work', 'billing', 'shipping']),
|
|
43
|
+
coordinates: z.object({
|
|
44
|
+
lat: z.number().min(-90).max(90),
|
|
45
|
+
lng: z.number().min(-180).max(180),
|
|
46
|
+
}).optional(),
|
|
47
|
+
});
|
|
48
|
+
const Geolocatable = z.object({
|
|
49
|
+
addresses: z.array(Address).min(1).max(5),
|
|
50
|
+
timezone: z.string().optional(),
|
|
51
|
+
locale: z.string().default('pt-BR'),
|
|
52
|
+
});
|
|
53
|
+
const BankAccount = z.object({
|
|
54
|
+
bankCode: z.string().regex(/^\d{3}$/),
|
|
55
|
+
agency: z.string().regex(/^\d{4,5}$/),
|
|
56
|
+
account: z.string().regex(/^\d{6,12}$/),
|
|
57
|
+
digit: z.string().regex(/^[0-9X]$/),
|
|
58
|
+
type: z.enum(['checking', 'savings', 'salary', 'payment']),
|
|
59
|
+
isPrimary: z.boolean(),
|
|
60
|
+
verifiedAt: z.date().optional(),
|
|
61
|
+
});
|
|
62
|
+
const FinancialInfo = z.object({
|
|
63
|
+
bankAccounts: z.array(BankAccount).max(3),
|
|
64
|
+
creditScore: z.number().min(0).max(1000).optional(),
|
|
65
|
+
incomeRange: z.enum(['A', 'B', 'C', 'D', 'E']).optional(),
|
|
66
|
+
taxId: z.string().regex(/^\d{11}$|^\d{14}$/).optional(),
|
|
67
|
+
paymentMethods: z.array(z.enum(['credit_card', 'debit_card', 'pix', 'boleto', 'bank_transfer'])).min(1),
|
|
68
|
+
});
|
|
69
|
+
const Course = z.object({
|
|
70
|
+
id: z.string().regex(/^CRS\d{8}$/),
|
|
71
|
+
name: z.string(),
|
|
72
|
+
code: z.string().regex(/^[A-Z]{3}\d{3}$/),
|
|
73
|
+
credits: z.number().int().min(1).max(12),
|
|
74
|
+
professorId: z.uuid().optional(),
|
|
75
|
+
schedule: z.object({
|
|
76
|
+
days: z.array(z.enum(['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'])).min(1).max(6),
|
|
77
|
+
startTime: z.string().regex(/^\d{2}:\d{2}$/),
|
|
78
|
+
endTime: z.string().regex(/^\d{2}:\d{2}$/),
|
|
79
|
+
room: z.string().optional(),
|
|
80
|
+
}),
|
|
81
|
+
status: z.enum(['active', 'inactive', 'completed', 'cancelled']),
|
|
82
|
+
});
|
|
83
|
+
const AcademicRecord = z.object({
|
|
84
|
+
enrollmentId: z.string().regex(/^ENR\d{10}$/),
|
|
85
|
+
semester: z.string().regex(/^\d{4}\.[12]$/),
|
|
86
|
+
gpa: z.number().min(0).max(10).optional(),
|
|
87
|
+
totalCredits: z.number().int().min(0),
|
|
88
|
+
courses: z.array(z.object({
|
|
89
|
+
course: Course,
|
|
90
|
+
grade: z.number().min(0).max(10).optional(),
|
|
91
|
+
status: z.enum(['enrolled', 'approved', 'failed', 'dropped']),
|
|
92
|
+
attendance: z.number().min(0).max(100).optional(),
|
|
93
|
+
})).max(10),
|
|
94
|
+
});
|
|
95
|
+
const StudentRole = z.object({
|
|
96
|
+
type: z.literal('student'),
|
|
97
|
+
studentId: z.string().regex(/^STU\d{8}$/),
|
|
98
|
+
enrollmentDate: z.date(),
|
|
99
|
+
graduationDate: z.date().optional(),
|
|
100
|
+
academicRecord: AcademicRecord,
|
|
101
|
+
scholarships: z.array(z.object({
|
|
102
|
+
id: z.string().regex(/^SCH\d{6}$/),
|
|
103
|
+
type: z.enum(['merit', 'need', 'athletic', 'research']),
|
|
104
|
+
amount: z.number().positive(),
|
|
105
|
+
startDate: z.date(),
|
|
106
|
+
endDate: z.date(),
|
|
107
|
+
renewable: z.boolean(),
|
|
108
|
+
})).max(3).optional(),
|
|
109
|
+
campus: z.enum(['main', 'north', 'south', 'online']),
|
|
110
|
+
});
|
|
111
|
+
const TeacherRole = z.object({
|
|
112
|
+
type: z.literal('teacher'),
|
|
113
|
+
employeeId: z.string().regex(/^TCH\d{8}$/),
|
|
114
|
+
hireDate: z.date(),
|
|
115
|
+
department: z.enum([
|
|
116
|
+
'computer_science', 'mathematics', 'physics', 'chemistry',
|
|
117
|
+
'biology', 'engineering', 'business', 'arts', 'law', 'medicine'
|
|
118
|
+
]),
|
|
119
|
+
title: z.enum(['assistant', 'associate', 'full', 'adjunct', 'visiting']),
|
|
120
|
+
salary: z.object({
|
|
121
|
+
base: z.number().positive(),
|
|
122
|
+
currency: z.string().default('BRL'),
|
|
123
|
+
paymentSchedule: z.enum(['monthly', 'biweekly', 'weekly']),
|
|
124
|
+
benefits: z.array(z.enum(['health', 'dental', 'vision', 'retirement', 'tuition'])).optional(),
|
|
125
|
+
}),
|
|
126
|
+
officeHours: z.array(z.object({
|
|
127
|
+
day: z.enum(['monday', 'tuesday', 'wednesday', 'thursday', 'friday']),
|
|
128
|
+
start: z.string().regex(/^\d{2}:\d{2}$/),
|
|
129
|
+
end: z.string().regex(/^\d{2}:\d{2}$/),
|
|
130
|
+
location: z.string(),
|
|
131
|
+
mode: z.enum(['in_person', 'virtual', 'hybrid']),
|
|
132
|
+
})).max(5).optional(),
|
|
133
|
+
coursesTeaching: z.array(z.object({
|
|
134
|
+
course: Course,
|
|
135
|
+
semester: z.string().regex(/^\d{4}\.[12]$/),
|
|
136
|
+
section: z.string().regex(/^[A-Z]$/),
|
|
137
|
+
})).max(4),
|
|
138
|
+
});
|
|
139
|
+
const AdminRole = z.object({
|
|
140
|
+
type: z.literal('admin'),
|
|
141
|
+
employeeId: z.string().regex(/^ADM\d{8}$/),
|
|
142
|
+
hireDate: z.date(),
|
|
143
|
+
department: z.enum([
|
|
144
|
+
'human_resources', 'information_technology', 'finance',
|
|
145
|
+
'operations', 'admissions', 'student_affairs', 'facilities'
|
|
146
|
+
]),
|
|
147
|
+
level: z.number().min(1).max(10),
|
|
148
|
+
permissions: z.array(z.object({
|
|
149
|
+
resource: z.enum([
|
|
150
|
+
'users', 'courses', 'enrollments', 'grades', 'payments',
|
|
151
|
+
'reports', 'settings', 'audit_logs', 'notifications'
|
|
152
|
+
]),
|
|
153
|
+
actions: z.array(z.enum(['read', 'create', 'update', 'delete', 'approve', 'export'])).min(1),
|
|
154
|
+
scope: z.enum(['global', 'department', 'personal']),
|
|
155
|
+
})).min(1),
|
|
156
|
+
reportsTo: z.uuid().optional(),
|
|
157
|
+
managedDepartments: z.array(z.string()).optional(),
|
|
158
|
+
});
|
|
159
|
+
const StaffRole = z.object({
|
|
160
|
+
type: z.literal('staff'),
|
|
161
|
+
employeeId: z.string().regex(/^STF\d{8}$/),
|
|
162
|
+
hireDate: z.date(),
|
|
163
|
+
position: z.enum([
|
|
164
|
+
'librarian', 'technician', 'counselor', 'coordinator',
|
|
165
|
+
'assistant', 'specialist', 'analyst', 'supervisor'
|
|
166
|
+
]),
|
|
167
|
+
department: z.string(),
|
|
168
|
+
schedule: z.object({
|
|
169
|
+
workHours: z.number().min(20).max(60),
|
|
170
|
+
shift: z.enum(['morning', 'afternoon', 'night', 'flexible']),
|
|
171
|
+
remoteDays: z.array(z.enum(['monday', 'tuesday', 'wednesday', 'thursday', 'friday'])).max(3).optional(),
|
|
172
|
+
}),
|
|
173
|
+
});
|
|
174
|
+
const PersonRole = z.discriminatedUnion('type', [
|
|
175
|
+
StudentRole,
|
|
176
|
+
TeacherRole,
|
|
177
|
+
AdminRole,
|
|
178
|
+
StaffRole,
|
|
179
|
+
]);
|
|
180
|
+
const IdentityDocument = z.object({
|
|
181
|
+
type: z.literal('id_card'),
|
|
182
|
+
number: z.string().regex(/^[A-Z0-9]{5,20}$/),
|
|
183
|
+
issuingAuthority: z.string(),
|
|
184
|
+
issueDate: z.date(),
|
|
185
|
+
expiryDate: z.date().optional(),
|
|
186
|
+
photoUrl: z.url().optional(),
|
|
187
|
+
verified: z.boolean().default(false),
|
|
188
|
+
});
|
|
189
|
+
const PassportDocument = z.object({
|
|
190
|
+
type: z.literal('passport'),
|
|
191
|
+
number: z.string().regex(/^[A-Z0-9]{8,12}$/),
|
|
192
|
+
country: z.string().length(3),
|
|
193
|
+
nationality: z.string(),
|
|
194
|
+
issueDate: z.date(),
|
|
195
|
+
expiryDate: z.date(),
|
|
196
|
+
visaInfo: z.array(z.object({
|
|
197
|
+
country: z.string().length(3),
|
|
198
|
+
type: z.string(),
|
|
199
|
+
issueDate: z.date(),
|
|
200
|
+
expiryDate: z.date(),
|
|
201
|
+
})).max(5).optional(),
|
|
202
|
+
});
|
|
203
|
+
const ProfessionalDocument = z.object({
|
|
204
|
+
type: z.literal('professional'),
|
|
205
|
+
number: z.string().regex(/^[A-Z0-9]{5,15}$/),
|
|
206
|
+
category: z.string(),
|
|
207
|
+
council: z.string(),
|
|
208
|
+
state: z.string().length(2),
|
|
209
|
+
validity: z.date(),
|
|
210
|
+
});
|
|
211
|
+
const Documents = z.array(z.union([IdentityDocument, PassportDocument, ProfessionalDocument])).max(5).optional();
|
|
212
|
+
const HealthInfo = z.object({
|
|
213
|
+
bloodType: z.enum(['A+', 'A-', 'B+', 'B-', 'AB+', 'AB-', 'O+', 'O-']).optional(),
|
|
214
|
+
allergies: z.array(z.string()).max(20).optional(),
|
|
215
|
+
medications: z.array(z.object({
|
|
216
|
+
name: z.string(),
|
|
217
|
+
dosage: z.string(),
|
|
218
|
+
frequency: z.string(),
|
|
219
|
+
prescribedBy: z.string().optional(),
|
|
220
|
+
})).max(10).optional(),
|
|
221
|
+
disabilities: z.array(z.object({
|
|
222
|
+
type: z.string(),
|
|
223
|
+
description: z.string(),
|
|
224
|
+
accommodations: z.array(z.string()).optional(),
|
|
225
|
+
})).max(5).optional(),
|
|
226
|
+
emergencyMedicalContacts: z.array(z.object({
|
|
227
|
+
name: z.string(),
|
|
228
|
+
relationship: z.string(),
|
|
229
|
+
phone: z.string().regex(/^\d{10,11}$/),
|
|
230
|
+
priority: z.number().min(1).max(3),
|
|
231
|
+
})).max(3).optional(),
|
|
232
|
+
});
|
|
233
|
+
const Preferences = z.object({
|
|
234
|
+
notification: z.object({
|
|
235
|
+
email: z.boolean().default(true),
|
|
236
|
+
sms: z.boolean().default(false),
|
|
237
|
+
push: z.boolean().default(true),
|
|
238
|
+
digest: z.enum(['daily', 'weekly', 'monthly', 'never']).default('weekly'),
|
|
239
|
+
}),
|
|
240
|
+
privacy: z.object({
|
|
241
|
+
profileVisible: z.boolean().default(true),
|
|
242
|
+
searchable: z.boolean().default(true),
|
|
243
|
+
showEmail: z.boolean().default(false),
|
|
244
|
+
showPhone: z.boolean().default(false),
|
|
245
|
+
dataSharing: z.enum(['none', 'essential', 'all']).default('essential'),
|
|
246
|
+
}),
|
|
247
|
+
language: z.string().default('pt-BR'),
|
|
248
|
+
timeFormat: z.enum(['12h', '24h']).default('24h'),
|
|
249
|
+
dateFormat: z.enum(['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY-MM-DD']).default('DD/MM/YYYY'),
|
|
250
|
+
});
|
|
251
|
+
const StatusHistory = z.array(z.object({
|
|
252
|
+
status: z.enum(['active', 'inactive', 'pending', 'suspended', 'graduated', 'terminated']),
|
|
253
|
+
effectiveDate: z.date(),
|
|
254
|
+
reason: z.string().optional(),
|
|
255
|
+
changedBy: z.uuid().optional(),
|
|
256
|
+
})).min(1);
|
|
257
|
+
const StudentMetadata = z.object({
|
|
258
|
+
advisorId: z.uuid().optional(),
|
|
259
|
+
thesisTitle: z.string().optional(),
|
|
260
|
+
researchArea: z.string().optional(),
|
|
261
|
+
publications: z.array(z.object({
|
|
262
|
+
title: z.string(),
|
|
263
|
+
year: z.number().int().min(2000).max(2030),
|
|
264
|
+
venue: z.string().optional(),
|
|
265
|
+
})).max(20).optional(),
|
|
266
|
+
});
|
|
267
|
+
const TeacherMetadata = z.object({
|
|
268
|
+
researchInterests: z.array(z.string()).max(10).optional(),
|
|
269
|
+
publicationsCount: z.number().int().min(0),
|
|
270
|
+
grants: z.array(z.object({
|
|
271
|
+
id: z.string(),
|
|
272
|
+
title: z.string(),
|
|
273
|
+
fundingAgency: z.string(),
|
|
274
|
+
amount: z.number().positive(),
|
|
275
|
+
period: z.string(),
|
|
276
|
+
})).max(10).optional(),
|
|
277
|
+
officeLocation: z.string(),
|
|
278
|
+
});
|
|
279
|
+
const AdminMetadata = z.object({
|
|
280
|
+
budgetResponsibility: z.number().positive().optional(),
|
|
281
|
+
teamSize: z.number().int().min(0),
|
|
282
|
+
projects: z.array(z.object({
|
|
283
|
+
name: z.string(),
|
|
284
|
+
status: z.enum(['planning', 'active', 'completed', 'cancelled']),
|
|
285
|
+
deadline: z.date().optional(),
|
|
286
|
+
})).max(10).optional(),
|
|
287
|
+
});
|
|
288
|
+
const Metadata = z.union([
|
|
289
|
+
StudentMetadata,
|
|
290
|
+
TeacherMetadata,
|
|
291
|
+
AdminMetadata,
|
|
292
|
+
]);
|
|
293
|
+
export const PersonEntitySchema = z.object({
|
|
294
|
+
name: z.object({
|
|
295
|
+
firstName: z.string().min(2).max(50),
|
|
296
|
+
lastName: z.string().min(2).max(50),
|
|
297
|
+
middleName: z.string().optional(),
|
|
298
|
+
preferredName: z.string().optional(),
|
|
299
|
+
title: z.enum(['Mr.', 'Mrs.', 'Ms.', 'Dr.', 'Prof.']).optional(),
|
|
300
|
+
}),
|
|
301
|
+
demographic: z.object({
|
|
302
|
+
birthDate: z.date(),
|
|
303
|
+
age: z.number().int().min(0).max(120),
|
|
304
|
+
gender: z.enum(['male', 'female', 'non_binary', 'prefer_not_to_say']),
|
|
305
|
+
nationality: z.string(),
|
|
306
|
+
maritalStatus: z.enum(['single', 'married', 'divorced', 'widowed']).optional(),
|
|
307
|
+
}),
|
|
308
|
+
officialDocuments: z.object({
|
|
309
|
+
cpf: z.string().regex(/^\d{11}$/),
|
|
310
|
+
rg: z.string().regex(/^\d{7,9}$/),
|
|
311
|
+
pis: z.string().regex(/^\d{11}$/).optional(),
|
|
312
|
+
voterId: z.string().regex(/^\d{12}$/).optional(),
|
|
313
|
+
}),
|
|
314
|
+
role: PersonRole,
|
|
315
|
+
status: z.enum(['active', 'inactive', 'pending', 'suspended', 'graduated', 'terminated']),
|
|
316
|
+
statusHistory: StatusHistory,
|
|
317
|
+
emergencyContacts: z.array(z.object({
|
|
318
|
+
name: z.string(),
|
|
319
|
+
phone: z.string().regex(/^\d{10,11}$/),
|
|
320
|
+
relationship: z.enum(['parent', 'spouse', 'child', 'sibling', 'friend', 'other']),
|
|
321
|
+
priority: z.number().min(1).max(3),
|
|
322
|
+
availableHours: z.string().optional(),
|
|
323
|
+
})).min(1).max(5),
|
|
324
|
+
documents: Documents,
|
|
325
|
+
contactInfo: ContactInfo,
|
|
326
|
+
addresses: z.array(Address).min(1).max(3),
|
|
327
|
+
financialInfo: FinancialInfo.optional(),
|
|
328
|
+
healthInfo: HealthInfo.optional(),
|
|
329
|
+
preferences: Preferences,
|
|
330
|
+
roleSpecificMetadata: Metadata.optional(),
|
|
331
|
+
academicHistory: z.array(AcademicRecord).max(10).optional(),
|
|
332
|
+
system: z.object({
|
|
333
|
+
isVerified: z.boolean().default(false),
|
|
334
|
+
verificationLevel: z.number().min(0).max(3).default(0),
|
|
335
|
+
lastLogin: z.date().optional(),
|
|
336
|
+
loginCount: z.number().int().min(0).default(0),
|
|
337
|
+
tags: z.array(z.string()).max(20).optional(),
|
|
338
|
+
flags: z.array(z.enum(['high_value', 'at_risk', 'vip', 'fraud_risk', 'legacy'])).optional(),
|
|
339
|
+
}),
|
|
340
|
+
}).and(Identifiable).and(Auditable);
|
|
341
|
+
describe('PersonEntity with Complex Schema', () => {
|
|
342
|
+
const entityMock = new ZodMockSchema(PersonEntitySchema);
|
|
343
|
+
test('should generate complex mock data', () => {
|
|
344
|
+
const mock = entityMock.generate();
|
|
345
|
+
expect(mock).toBeDefined();
|
|
346
|
+
expect(mock.role).toBeDefined();
|
|
347
|
+
expect(mock.statusHistory).toBeDefined();
|
|
348
|
+
expect(mock.addresses.length).toBeGreaterThan(0);
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
describe('New Zod Types Support', () => {
|
|
352
|
+
describe('ZodSet', () => {
|
|
353
|
+
test('should generate a Set with elements', () => {
|
|
354
|
+
const schema = z.set(z.string());
|
|
355
|
+
const mock = new ZodMockSchema(schema);
|
|
356
|
+
const result = mock.generate();
|
|
357
|
+
expect(result).toBeInstanceOf(Set);
|
|
358
|
+
expect(result.size).toBeGreaterThan(0);
|
|
359
|
+
});
|
|
360
|
+
test('should respect min/max size constraints', () => {
|
|
361
|
+
const schema = z.set(z.number()).min(2).max(5);
|
|
362
|
+
const mock = new ZodMockSchema(schema);
|
|
363
|
+
const result = mock.generate();
|
|
364
|
+
expect(result).toBeInstanceOf(Set);
|
|
365
|
+
expect(result.size).toBeGreaterThanOrEqual(2);
|
|
366
|
+
expect(result.size).toBeLessThanOrEqual(5);
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
describe('ZodMap', () => {
|
|
370
|
+
test('should generate a Map with entries', () => {
|
|
371
|
+
const schema = z.map(z.string(), z.number());
|
|
372
|
+
const mock = new ZodMockSchema(schema);
|
|
373
|
+
const result = mock.generate();
|
|
374
|
+
expect(result).toBeInstanceOf(Map);
|
|
375
|
+
expect(result.size).toBeGreaterThan(0);
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
describe('ZodTuple', () => {
|
|
379
|
+
test('should generate a tuple with correct types', () => {
|
|
380
|
+
const schema = z.tuple([z.string(), z.number(), z.boolean()]);
|
|
381
|
+
const mock = new ZodMockSchema(schema);
|
|
382
|
+
const result = mock.generate();
|
|
383
|
+
expect(Array.isArray(result)).toBe(true);
|
|
384
|
+
expect(result).toHaveLength(3);
|
|
385
|
+
expect(typeof result[0]).toBe('string');
|
|
386
|
+
expect(typeof result[1]).toBe('number');
|
|
387
|
+
expect(typeof result[2]).toBe('boolean');
|
|
388
|
+
});
|
|
389
|
+
test('should generate tuple with rest elements', () => {
|
|
390
|
+
const schema = z.tuple([z.string()]).rest(z.number());
|
|
391
|
+
const mock = new ZodMockSchema(schema);
|
|
392
|
+
const result = mock.generate();
|
|
393
|
+
expect(Array.isArray(result)).toBe(true);
|
|
394
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
395
|
+
expect(typeof result[0]).toBe('string');
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
describe('ZodFunction', () => {
|
|
399
|
+
test('should generate a function that returns mocked value', () => {
|
|
400
|
+
const schema = z.function();
|
|
401
|
+
const mock = new ZodMockSchema(schema);
|
|
402
|
+
const result = mock.generate();
|
|
403
|
+
expect(typeof result).toBe('function');
|
|
404
|
+
expect(result).toBeDefined();
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
describe('ZodDiscriminatedUnion', () => {
|
|
408
|
+
test('should generate one of the union options', () => {
|
|
409
|
+
const schema = z.discriminatedUnion('type', [
|
|
410
|
+
z.object({ type: z.literal('a'), value: z.string() }),
|
|
411
|
+
z.object({ type: z.literal('b'), value: z.number() }),
|
|
412
|
+
]);
|
|
413
|
+
const mock = new ZodMockSchema(schema);
|
|
414
|
+
const result = mock.generate();
|
|
415
|
+
expect(result).toBeDefined();
|
|
416
|
+
expect(['a', 'b']).toContain(result.type);
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
describe('ZodBigInt', () => {
|
|
420
|
+
test('should generate a BigInt', () => {
|
|
421
|
+
const schema = z.bigint();
|
|
422
|
+
const mock = new ZodMockSchema(schema);
|
|
423
|
+
const result = mock.generate();
|
|
424
|
+
expect(typeof result).toBe('bigint');
|
|
425
|
+
expect(result).toBeGreaterThan(BigInt(0));
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
describe('ZodNaN', () => {
|
|
429
|
+
test('should generate NaN', () => {
|
|
430
|
+
const schema = z.nan();
|
|
431
|
+
const mock = new ZodMockSchema(schema);
|
|
432
|
+
const result = mock.generate();
|
|
433
|
+
expect(Number.isNaN(result)).toBe(true);
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
describe('ZodReadonly', () => {
|
|
437
|
+
test('should generate readonly object', () => {
|
|
438
|
+
const schema = z.object({ name: z.string() }).readonly();
|
|
439
|
+
const mock = new ZodMockSchema(schema);
|
|
440
|
+
const result = mock.generate();
|
|
441
|
+
expect(result).toBeDefined();
|
|
442
|
+
expect(typeof result.name).toBe('string');
|
|
443
|
+
});
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
describe('Improved Constraints', () => {
|
|
447
|
+
describe('String min/max', () => {
|
|
448
|
+
test('should respect min length', () => {
|
|
449
|
+
const schema = z.string().min(10);
|
|
450
|
+
const mock = new ZodMockSchema(schema);
|
|
451
|
+
const result = mock.generate();
|
|
452
|
+
expect(result.length).toBeGreaterThanOrEqual(10);
|
|
453
|
+
});
|
|
454
|
+
test('should respect max length', () => {
|
|
455
|
+
const schema = z.string().max(5);
|
|
456
|
+
const mock = new ZodMockSchema(schema);
|
|
457
|
+
const result = mock.generate();
|
|
458
|
+
expect(result.length).toBeLessThanOrEqual(5);
|
|
459
|
+
});
|
|
460
|
+
test('should respect both min and max', () => {
|
|
461
|
+
const schema = z.string().min(5).max(10);
|
|
462
|
+
const mock = new ZodMockSchema(schema);
|
|
463
|
+
const result = mock.generate();
|
|
464
|
+
expect(result.length).toBeGreaterThanOrEqual(5);
|
|
465
|
+
expect(result.length).toBeLessThanOrEqual(10);
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
describe('Date min/max', () => {
|
|
469
|
+
test('should respect date range', () => {
|
|
470
|
+
const minDate = new Date('2025-01-01');
|
|
471
|
+
const maxDate = new Date('2025-12-31');
|
|
472
|
+
const schema = z.date().min(minDate).max(maxDate);
|
|
473
|
+
const mock = new ZodMockSchema(schema);
|
|
474
|
+
const result = mock.generate();
|
|
475
|
+
expect(result).toBeInstanceOf(Date);
|
|
476
|
+
expect(result.getTime()).toBeGreaterThanOrEqual(minDate.getTime());
|
|
477
|
+
expect(result.getTime()).toBeLessThanOrEqual(maxDate.getTime());
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
describe('ZodDefault always uses default value', () => {
|
|
481
|
+
test('should always return the default value', () => {
|
|
482
|
+
const schema = z.string().default('DEFAULT_VALUE');
|
|
483
|
+
const mock = new ZodMockSchema(schema);
|
|
484
|
+
const results = Array.from({ length: 10 }, () => mock.generate());
|
|
485
|
+
expect(results.every(r => r === 'DEFAULT_VALUE')).toBe(true);
|
|
486
|
+
});
|
|
487
|
+
test('should work with default numbers', () => {
|
|
488
|
+
const schema = z.number().default(42);
|
|
489
|
+
const mock = new ZodMockSchema(schema);
|
|
490
|
+
const result = mock.generate();
|
|
491
|
+
expect(result).toBe(42);
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
describe('Seed Support', () => {
|
|
496
|
+
test('should generate same data with same seed', () => {
|
|
497
|
+
const schema = z.object({
|
|
498
|
+
name: z.string(),
|
|
499
|
+
age: z.number(),
|
|
500
|
+
email: z.email(),
|
|
501
|
+
});
|
|
502
|
+
const mock1 = new ZodMockSchema(schema).seed(12345);
|
|
503
|
+
const result1 = mock1.generate();
|
|
504
|
+
const mock2 = new ZodMockSchema(schema).seed(12345);
|
|
505
|
+
const result2 = mock2.generate();
|
|
506
|
+
expect(result1).toEqual(result2);
|
|
507
|
+
});
|
|
508
|
+
test('should generate different data with different seeds', () => {
|
|
509
|
+
const schema = z.object({
|
|
510
|
+
name: z.string(),
|
|
511
|
+
age: z.number(),
|
|
512
|
+
});
|
|
513
|
+
const mock1 = new ZodMockSchema(schema).seed(111);
|
|
514
|
+
const result1 = mock1.generate();
|
|
515
|
+
const mock2 = new ZodMockSchema(schema).seed(222);
|
|
516
|
+
const result2 = mock2.generate();
|
|
517
|
+
expect(result1).not.toEqual(result2);
|
|
518
|
+
});
|
|
519
|
+
test('should support array seed', () => {
|
|
520
|
+
const schema = z.string();
|
|
521
|
+
const mock = new ZodMockSchema(schema).seed([1, 2, 3]);
|
|
522
|
+
const result = mock.generate();
|
|
523
|
+
expect(typeof result).toBe('string');
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
//# sourceMappingURL=zod-types.spec.js.map
|