@go-mondo/identity-sdk 0.0.2-beta.65 → 0.0.2-beta.67

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.
@@ -4,75 +4,273 @@ const vitest_1 = require("vitest");
4
4
  const schema_js_1 = require("../schema.js");
5
5
  const schema_js_2 = require("./schema.js");
6
6
  (0, vitest_1.describe)('Customer - User', () => {
7
+ (0, vitest_1.describe)('VerifiableAttribute', () => {
8
+ (0, vitest_1.test)('should have correct constants', () => {
9
+ (0, vitest_1.expect)(schema_js_2.VerifiableAttribute.EMAIL).toBe('email');
10
+ (0, vitest_1.expect)(schema_js_2.VerifiableAttribute.PHONE_NUMBER).toBe('phoneNumber');
11
+ });
12
+ });
13
+ (0, vitest_1.describe)('UserStatus', () => {
14
+ (0, vitest_1.test)('should have correct constants', () => {
15
+ (0, vitest_1.expect)(schema_js_2.UserStatus.ACTIVE).toBe('active');
16
+ (0, vitest_1.expect)(schema_js_2.UserStatus.SUSPENDED).toBe('suspended');
17
+ (0, vitest_1.expect)(schema_js_2.UserStatus.UNVERIFIED).toBe('unverified');
18
+ });
19
+ (0, vitest_1.test)('should parse valid status values', () => {
20
+ (0, vitest_1.expect)(schema_js_2.UserStatusSchema.safeParse('active').success).toBe(true);
21
+ (0, vitest_1.expect)(schema_js_2.UserStatusSchema.safeParse('suspended').success).toBe(true);
22
+ (0, vitest_1.expect)(schema_js_2.UserStatusSchema.safeParse('unverified').success).toBe(true);
23
+ });
24
+ (0, vitest_1.test)('should reject invalid status values', () => {
25
+ (0, vitest_1.expect)(schema_js_2.UserStatusSchema.safeParse('invalid').success).toBe(false);
26
+ (0, vitest_1.expect)(schema_js_2.UserStatusSchema.safeParse('').success).toBe(false);
27
+ });
28
+ });
29
+ (0, vitest_1.describe)('UserNamePropertiesSchema', () => {
30
+ (0, vitest_1.test)('should parse valid name properties', () => {
31
+ const result = schema_js_2.UserNamePropertiesSchema.safeParse({
32
+ givenName: 'John',
33
+ middleName: 'Robert',
34
+ familyName: 'Doe',
35
+ honorificPrefix: 'Dr.',
36
+ honorificSuffix: 'Jr.',
37
+ });
38
+ (0, vitest_1.expect)(result.success).toBe(true);
39
+ if (result.success) {
40
+ (0, vitest_1.expect)(result.data.givenName).toBe('John');
41
+ (0, vitest_1.expect)(result.data.familyName).toBe('Doe');
42
+ }
43
+ });
44
+ (0, vitest_1.test)('should transform null values to undefined', () => {
45
+ const result = schema_js_2.UserNamePropertiesSchema.safeParse({
46
+ givenName: null,
47
+ familyName: null,
48
+ });
49
+ (0, vitest_1.expect)(result.success).toBe(true);
50
+ if (result.success) {
51
+ (0, vitest_1.expect)(result.data.givenName).toBeUndefined();
52
+ (0, vitest_1.expect)(result.data.familyName).toBeUndefined();
53
+ }
54
+ });
55
+ (0, vitest_1.test)('should allow empty object', () => {
56
+ const result = schema_js_2.UserNamePropertiesSchema.safeParse({});
57
+ (0, vitest_1.expect)(result.success).toBe(true);
58
+ });
59
+ });
60
+ (0, vitest_1.describe)('UpdateUserNamePropertiesSchema', () => {
61
+ (0, vitest_1.test)('should parse valid name properties', () => {
62
+ const result = schema_js_2.UpdateUserNamePropertiesSchema.safeParse({
63
+ givenName: 'Jane',
64
+ familyName: 'Smith',
65
+ });
66
+ (0, vitest_1.expect)(result.success).toBe(true);
67
+ });
68
+ (0, vitest_1.test)('should allow null values without transforming', () => {
69
+ const result = schema_js_2.UpdateUserNamePropertiesSchema.safeParse({
70
+ givenName: null,
71
+ familyName: 'Smith',
72
+ });
73
+ (0, vitest_1.expect)(result.success).toBe(true);
74
+ if (result.success) {
75
+ (0, vitest_1.expect)(result.data.givenName).toBeNull();
76
+ }
77
+ });
78
+ });
79
+ (0, vitest_1.describe)('VerifiedEmailOrPhonePropertiesSchema', () => {
80
+ (0, vitest_1.test)('should parse valid verified email', () => {
81
+ const result = schema_js_2.VerifiedEmailOrPhonePropertiesSchema.safeParse({
82
+ verifiedEmail: 'test@example.com',
83
+ });
84
+ (0, vitest_1.expect)(result.success).toBe(true);
85
+ if (result.success) {
86
+ (0, vitest_1.expect)(result.data.verifiedEmail).toBe('test@example.com');
87
+ }
88
+ });
89
+ (0, vitest_1.test)('should parse valid verified phone number', () => {
90
+ const result = schema_js_2.VerifiedEmailOrPhonePropertiesSchema.safeParse({
91
+ verifiedPhoneNumber: '+1234567890',
92
+ });
93
+ (0, vitest_1.expect)(result.success).toBe(true);
94
+ if (result.success) {
95
+ (0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBe('+1234567890');
96
+ }
97
+ });
98
+ (0, vitest_1.test)('should parse both fields together', () => {
99
+ const result = schema_js_2.VerifiedEmailOrPhonePropertiesSchema.safeParse({
100
+ verifiedEmail: 'verified@example.com',
101
+ verifiedPhoneNumber: '+1111111111',
102
+ });
103
+ (0, vitest_1.expect)(result.success).toBe(true);
104
+ if (result.success) {
105
+ (0, vitest_1.expect)(result.data.verifiedEmail).toBe('verified@example.com');
106
+ (0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBe('+1111111111');
107
+ }
108
+ });
109
+ (0, vitest_1.test)('should transform null values to undefined', () => {
110
+ const result = schema_js_2.VerifiedEmailOrPhonePropertiesSchema.safeParse({
111
+ verifiedEmail: null,
112
+ verifiedPhoneNumber: null,
113
+ });
114
+ (0, vitest_1.expect)(result.success).toBe(true);
115
+ if (result.success) {
116
+ (0, vitest_1.expect)(result.data.verifiedEmail).toBeUndefined();
117
+ (0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBeUndefined();
118
+ }
119
+ });
120
+ (0, vitest_1.test)('should reject invalid email format', () => {
121
+ const result = schema_js_2.VerifiedEmailOrPhonePropertiesSchema.safeParse({
122
+ verifiedEmail: 'not-an-email',
123
+ });
124
+ (0, vitest_1.expect)(result.success).toBe(false);
125
+ });
126
+ (0, vitest_1.test)('should allow empty object', () => {
127
+ const result = schema_js_2.VerifiedEmailOrPhonePropertiesSchema.safeParse({});
128
+ (0, vitest_1.expect)(result.success).toBe(true);
129
+ });
130
+ });
131
+ (0, vitest_1.describe)('UnverifiedEmailOrPhonePropertiesSchema', () => {
132
+ (0, vitest_1.test)('should parse valid unverified email', () => {
133
+ const result = schema_js_2.UnverifiedEmailOrPhonePropertiesSchema.safeParse({
134
+ unverifiedEmail: 'pending@example.com',
135
+ });
136
+ (0, vitest_1.expect)(result.success).toBe(true);
137
+ if (result.success) {
138
+ (0, vitest_1.expect)(result.data.unverifiedEmail).toBe('pending@example.com');
139
+ }
140
+ });
141
+ (0, vitest_1.test)('should parse valid unverified phone number', () => {
142
+ const result = schema_js_2.UnverifiedEmailOrPhonePropertiesSchema.safeParse({
143
+ unverifiedPhoneNumber: '+0987654321',
144
+ });
145
+ (0, vitest_1.expect)(result.success).toBe(true);
146
+ if (result.success) {
147
+ (0, vitest_1.expect)(result.data.unverifiedPhoneNumber).toBe('+0987654321');
148
+ }
149
+ });
150
+ (0, vitest_1.test)('should parse both fields together', () => {
151
+ const result = schema_js_2.UnverifiedEmailOrPhonePropertiesSchema.safeParse({
152
+ unverifiedEmail: 'pending@example.com',
153
+ unverifiedPhoneNumber: '+2222222222',
154
+ });
155
+ (0, vitest_1.expect)(result.success).toBe(true);
156
+ if (result.success) {
157
+ (0, vitest_1.expect)(result.data.unverifiedEmail).toBe('pending@example.com');
158
+ (0, vitest_1.expect)(result.data.unverifiedPhoneNumber).toBe('+2222222222');
159
+ }
160
+ });
161
+ (0, vitest_1.test)('should transform null values to undefined', () => {
162
+ const result = schema_js_2.UnverifiedEmailOrPhonePropertiesSchema.safeParse({
163
+ unverifiedEmail: null,
164
+ unverifiedPhoneNumber: null,
165
+ });
166
+ (0, vitest_1.expect)(result.success).toBe(true);
167
+ if (result.success) {
168
+ (0, vitest_1.expect)(result.data.unverifiedEmail).toBeUndefined();
169
+ (0, vitest_1.expect)(result.data.unverifiedPhoneNumber).toBeUndefined();
170
+ }
171
+ });
172
+ (0, vitest_1.test)('should reject invalid unverified email format', () => {
173
+ const result = schema_js_2.UnverifiedEmailOrPhonePropertiesSchema.safeParse({
174
+ unverifiedEmail: 'also-not-an-email',
175
+ });
176
+ (0, vitest_1.expect)(result.success).toBe(false);
177
+ });
178
+ (0, vitest_1.test)('should allow empty object', () => {
179
+ const result = schema_js_2.UnverifiedEmailOrPhonePropertiesSchema.safeParse({});
180
+ (0, vitest_1.expect)(result.success).toBe(true);
181
+ });
182
+ });
183
+ (0, vitest_1.describe)('EmailOrPhonePropertiesSchema', () => {
184
+ (0, vitest_1.test)('should parse email and phone number', () => {
185
+ const result = schema_js_2.EmailOrPhonePropertiesSchema.safeParse({
186
+ email: 'test@example.com',
187
+ phoneNumber: '+1234567890',
188
+ });
189
+ (0, vitest_1.expect)(result.success).toBe(true);
190
+ if (result.success) {
191
+ (0, vitest_1.expect)(result.data.email).toBe('test@example.com');
192
+ (0, vitest_1.expect)(result.data.phoneNumber).toBe('+1234567890');
193
+ }
194
+ });
195
+ (0, vitest_1.test)('should transform null values to undefined', () => {
196
+ const result = schema_js_2.EmailOrPhonePropertiesSchema.safeParse({
197
+ email: null,
198
+ phoneNumber: null,
199
+ });
200
+ (0, vitest_1.expect)(result.success).toBe(true);
201
+ if (result.success) {
202
+ (0, vitest_1.expect)(result.data.email).toBeUndefined();
203
+ (0, vitest_1.expect)(result.data.phoneNumber).toBeUndefined();
204
+ }
205
+ });
206
+ });
7
207
  (0, vitest_1.describe)('User Payload', () => {
8
208
  (0, vitest_1.test)('should parse attributes successfully', async () => {
9
209
  const item = {
10
210
  foo: 'bar',
11
211
  id: (0, schema_js_1.generateUserId)(),
12
- phoneNumber: '123',
212
+ verifiedPhoneNumber: '123',
13
213
  status: schema_js_2.UserStatus.ACTIVE,
14
214
  createdAt: new Date(),
15
215
  updatedAt: new Date(),
16
216
  };
17
217
  const result = schema_js_2.UserPayloadSchema.safeParse(item);
18
- // Parse succeeds for valid data
19
218
  (0, vitest_1.expect)(result.success).toBe(true);
20
219
  if (result.success) {
21
220
  (0, vitest_1.expect)(result.data.metadata).toBeUndefined();
22
221
  }
23
222
  });
24
- });
25
- (0, vitest_1.describe)('Insert User Payload', () => {
26
- (0, vitest_1.test)('should parse attributes successfully', async () => {
223
+ (0, vitest_1.test)('should parse with all verified and unverified email/phone properties', async () => {
27
224
  const item = {
28
- foo: 'bar',
29
225
  id: (0, schema_js_1.generateUserId)(),
30
- familyName: 'Foo',
31
- phoneNumber: '123',
226
+ verifiedEmail: 'verified@example.com',
227
+ unverifiedEmail: 'pending@example.com',
228
+ verifiedPhoneNumber: '+1234567890',
229
+ unverifiedPhoneNumber: '+0987654321',
230
+ status: schema_js_2.UserStatus.ACTIVE,
231
+ createdAt: new Date(),
232
+ updatedAt: new Date(),
32
233
  };
33
- const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
34
- // Parse succeeds for valid data
234
+ const result = schema_js_2.UserPayloadSchema.safeParse(item);
35
235
  (0, vitest_1.expect)(result.success).toBe(true);
36
236
  if (result.success) {
37
- (0, vitest_1.expect)(result.data.metadata).toBeUndefined();
38
- (0, vitest_1.expect)(result.data.familyName).toBe(item.familyName);
237
+ (0, vitest_1.expect)(result.data.verifiedEmail).toBe('verified@example.com');
238
+ (0, vitest_1.expect)(result.data.unverifiedEmail).toBe('pending@example.com');
239
+ (0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBe('+1234567890');
240
+ (0, vitest_1.expect)(result.data.unverifiedPhoneNumber).toBe('+0987654321');
39
241
  }
40
242
  });
41
- (0, vitest_1.test)('should serialize successfully', async () => {
243
+ (0, vitest_1.test)('should provide email alias for verifiedEmail', async () => {
42
244
  const item = {
43
- foo: 'bar',
44
245
  id: (0, schema_js_1.generateUserId)(),
45
- phoneNumber: '123',
46
- metadata: new Map(),
246
+ verifiedEmail: 'verified@example.com',
247
+ status: schema_js_2.UserStatus.ACTIVE,
248
+ createdAt: new Date(),
249
+ updatedAt: new Date(),
47
250
  };
48
- const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
49
- // Parse succeeds for valid data
251
+ const result = schema_js_2.UserPayloadSchema.safeParse(item);
50
252
  (0, vitest_1.expect)(result.success).toBe(true);
51
253
  if (result.success) {
52
- (0, vitest_1.expect)(result.data.metadata).toBeNull();
254
+ (0, vitest_1.expect)(result.data.email).toBe('verified@example.com');
255
+ (0, vitest_1.expect)(result.data.verifiedEmail).toBe('verified@example.com');
53
256
  }
54
257
  });
55
- (0, vitest_1.test)('should serialize nulls successfully', async () => {
56
- const payload = {
258
+ (0, vitest_1.test)('should provide phoneNumber alias for verifiedPhoneNumber', async () => {
259
+ const item = {
57
260
  id: (0, schema_js_1.generateUserId)(),
58
- status: 'unverified',
59
- givenName: null,
60
- middleName: null,
61
- familyName: null,
62
- honorificPrefix: null,
63
- honorificSuffix: null,
64
- email: null,
65
- verifiedEmail: null,
66
- phoneNumber: null,
67
- verifiedPhoneNumber: null,
68
- createdAt: '2025-04-02T03:50:40.812Z',
69
- updatedAt: '2025-04-02T03:50:40.812Z',
261
+ verifiedPhoneNumber: '+1234567890',
262
+ status: schema_js_2.UserStatus.ACTIVE,
263
+ createdAt: new Date(),
264
+ updatedAt: new Date(),
70
265
  };
71
- const result = schema_js_2.UserPayloadSchema.safeParse(payload);
72
- // Parse succeeds for valid data
266
+ const result = schema_js_2.UserPayloadSchema.safeParse(item);
73
267
  (0, vitest_1.expect)(result.success).toBe(true);
268
+ if (result.success) {
269
+ (0, vitest_1.expect)(result.data.phoneNumber).toBe('+1234567890');
270
+ (0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBe('+1234567890');
271
+ }
74
272
  });
75
- (0, vitest_1.test)('should serialize nulls successfully', async () => {
273
+ (0, vitest_1.test)('should serialize nulls to undefined', async () => {
76
274
  const payload = {
77
275
  id: (0, schema_js_1.generateUserId)(),
78
276
  status: 'unverified',
@@ -81,16 +279,299 @@ const schema_js_2 = require("./schema.js");
81
279
  familyName: null,
82
280
  honorificPrefix: null,
83
281
  honorificSuffix: null,
84
- email: null,
85
282
  verifiedEmail: null,
86
- phoneNumber: null,
283
+ unverifiedEmail: null,
87
284
  verifiedPhoneNumber: null,
285
+ unverifiedPhoneNumber: null,
88
286
  createdAt: '2025-04-02T03:50:40.812Z',
89
287
  updatedAt: '2025-04-02T03:50:40.812Z',
90
288
  };
91
289
  const result = schema_js_2.UserPayloadSchema.safeParse(payload);
92
- // Parse succeeds for valid data
93
290
  (0, vitest_1.expect)(result.success).toBe(true);
291
+ if (result.success) {
292
+ (0, vitest_1.expect)(result.data.verifiedEmail).toBeUndefined();
293
+ (0, vitest_1.expect)(result.data.unverifiedEmail).toBeUndefined();
294
+ (0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBeUndefined();
295
+ (0, vitest_1.expect)(result.data.unverifiedPhoneNumber).toBeUndefined();
296
+ (0, vitest_1.expect)(result.data.email).toBeUndefined();
297
+ (0, vitest_1.expect)(result.data.phoneNumber).toBeUndefined();
298
+ }
299
+ });
300
+ });
301
+ (0, vitest_1.describe)('User Schema', () => {
302
+ (0, vitest_1.test)('should parse complete user object', async () => {
303
+ const user = {
304
+ id: (0, schema_js_1.generateUserId)(),
305
+ givenName: 'John',
306
+ familyName: 'Doe',
307
+ verifiedEmail: 'john@example.com',
308
+ verifiedPhoneNumber: '+1234567890',
309
+ status: schema_js_2.UserStatus.ACTIVE,
310
+ lastLogin: new Date(),
311
+ createdAt: new Date(),
312
+ updatedAt: new Date(),
313
+ };
314
+ const result = schema_js_2.UserSchema.safeParse(user);
315
+ (0, vitest_1.expect)(result.success).toBe(true);
316
+ if (result.success) {
317
+ (0, vitest_1.expect)(result.data.givenName).toBe('John');
318
+ (0, vitest_1.expect)(result.data.verifiedEmail).toBe('john@example.com');
319
+ (0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBe('+1234567890');
320
+ }
321
+ });
322
+ (0, vitest_1.test)('should provide email alias for verifiedEmail', async () => {
323
+ const user = {
324
+ id: (0, schema_js_1.generateUserId)(),
325
+ verifiedEmail: 'john@example.com',
326
+ status: schema_js_2.UserStatus.ACTIVE,
327
+ createdAt: new Date(),
328
+ updatedAt: new Date(),
329
+ };
330
+ const result = schema_js_2.UserSchema.safeParse(user);
331
+ (0, vitest_1.expect)(result.success).toBe(true);
332
+ if (result.success) {
333
+ (0, vitest_1.expect)(result.data.email).toBe('john@example.com');
334
+ (0, vitest_1.expect)(result.data.verifiedEmail).toBe('john@example.com');
335
+ }
336
+ });
337
+ (0, vitest_1.test)('should provide phoneNumber alias for verifiedPhoneNumber', async () => {
338
+ const user = {
339
+ id: (0, schema_js_1.generateUserId)(),
340
+ verifiedPhoneNumber: '+1234567890',
341
+ status: schema_js_2.UserStatus.ACTIVE,
342
+ createdAt: new Date(),
343
+ updatedAt: new Date(),
344
+ };
345
+ const result = schema_js_2.UserSchema.safeParse(user);
346
+ (0, vitest_1.expect)(result.success).toBe(true);
347
+ if (result.success) {
348
+ (0, vitest_1.expect)(result.data.phoneNumber).toBe('+1234567890');
349
+ (0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBe('+1234567890');
350
+ }
351
+ });
352
+ (0, vitest_1.test)('should have undefined aliases when verified fields are undefined', async () => {
353
+ const user = {
354
+ id: (0, schema_js_1.generateUserId)(),
355
+ status: schema_js_2.UserStatus.ACTIVE,
356
+ createdAt: new Date(),
357
+ updatedAt: new Date(),
358
+ };
359
+ const result = schema_js_2.UserSchema.safeParse(user);
360
+ (0, vitest_1.expect)(result.success).toBe(true);
361
+ if (result.success) {
362
+ (0, vitest_1.expect)(result.data.email).toBeUndefined();
363
+ (0, vitest_1.expect)(result.data.phoneNumber).toBeUndefined();
364
+ (0, vitest_1.expect)(result.data.verifiedEmail).toBeUndefined();
365
+ (0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBeUndefined();
366
+ }
367
+ });
368
+ (0, vitest_1.test)('should parse user with deletedAt and deactivatedAt', async () => {
369
+ const user = {
370
+ id: (0, schema_js_1.generateUserId)(),
371
+ status: schema_js_2.UserStatus.SUSPENDED,
372
+ createdAt: new Date(),
373
+ updatedAt: new Date(),
374
+ deletedAt: new Date(),
375
+ deactivatedAt: new Date(),
376
+ };
377
+ const result = schema_js_2.UserSchema.safeParse(user);
378
+ (0, vitest_1.expect)(result.success).toBe(true);
379
+ if (result.success) {
380
+ (0, vitest_1.expect)(result.data.deletedAt).toBeInstanceOf(Date);
381
+ (0, vitest_1.expect)(result.data.deactivatedAt).toBeInstanceOf(Date);
382
+ }
383
+ });
384
+ (0, vitest_1.test)('should include unverified fields alongside aliases', async () => {
385
+ const user = {
386
+ id: (0, schema_js_1.generateUserId)(),
387
+ verifiedEmail: 'verified@example.com',
388
+ unverifiedEmail: 'pending@example.com',
389
+ verifiedPhoneNumber: '+1111111111',
390
+ unverifiedPhoneNumber: '+2222222222',
391
+ status: schema_js_2.UserStatus.ACTIVE,
392
+ createdAt: new Date(),
393
+ updatedAt: new Date(),
394
+ };
395
+ const result = schema_js_2.UserSchema.safeParse(user);
396
+ (0, vitest_1.expect)(result.success).toBe(true);
397
+ if (result.success) {
398
+ (0, vitest_1.expect)(result.data.email).toBe('verified@example.com');
399
+ (0, vitest_1.expect)(result.data.verifiedEmail).toBe('verified@example.com');
400
+ (0, vitest_1.expect)(result.data.unverifiedEmail).toBe('pending@example.com');
401
+ (0, vitest_1.expect)(result.data.phoneNumber).toBe('+1111111111');
402
+ (0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBe('+1111111111');
403
+ (0, vitest_1.expect)(result.data.unverifiedPhoneNumber).toBe('+2222222222');
404
+ }
405
+ });
406
+ });
407
+ (0, vitest_1.describe)('Insert User Payload', () => {
408
+ (0, vitest_1.test)('should parse attributes successfully', async () => {
409
+ const item = {
410
+ foo: 'bar',
411
+ id: (0, schema_js_1.generateUserId)(),
412
+ familyName: 'Foo',
413
+ verifiedPhoneNumber: '123',
414
+ };
415
+ const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
416
+ (0, vitest_1.expect)(result.success).toBe(true);
417
+ if (result.success) {
418
+ (0, vitest_1.expect)(result.data.metadata).toBeUndefined();
419
+ (0, vitest_1.expect)(result.data.familyName).toBe(item.familyName);
420
+ }
421
+ });
422
+ (0, vitest_1.test)('should parse with all verified and unverified email/phone properties', async () => {
423
+ const item = {
424
+ id: (0, schema_js_1.generateUserId)(),
425
+ verifiedEmail: 'verified@example.com',
426
+ unverifiedEmail: 'pending@example.com',
427
+ verifiedPhoneNumber: '+1234567890',
428
+ unverifiedPhoneNumber: '+0987654321',
429
+ };
430
+ const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
431
+ (0, vitest_1.expect)(result.success).toBe(true);
432
+ if (result.success) {
433
+ (0, vitest_1.expect)(result.data.verifiedEmail).toBe('verified@example.com');
434
+ (0, vitest_1.expect)(result.data.unverifiedEmail).toBe('pending@example.com');
435
+ (0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBe('+1234567890');
436
+ (0, vitest_1.expect)(result.data.unverifiedPhoneNumber).toBe('+0987654321');
437
+ }
438
+ });
439
+ (0, vitest_1.test)('should serialize empty Map to null', async () => {
440
+ const item = {
441
+ foo: 'bar',
442
+ id: (0, schema_js_1.generateUserId)(),
443
+ verifiedPhoneNumber: '123',
444
+ metadata: new Map(),
445
+ };
446
+ const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
447
+ (0, vitest_1.expect)(result.success).toBe(true);
448
+ if (result.success) {
449
+ (0, vitest_1.expect)(result.data.metadata).toBeNull();
450
+ }
451
+ });
452
+ (0, vitest_1.test)('should allow optional id and status', async () => {
453
+ const item = {
454
+ verifiedEmail: 'test@example.com',
455
+ };
456
+ const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
457
+ (0, vitest_1.expect)(result.success).toBe(true);
458
+ if (result.success) {
459
+ (0, vitest_1.expect)(result.data.id).toBeUndefined();
460
+ (0, vitest_1.expect)(result.data.status).toBeUndefined();
461
+ }
462
+ });
463
+ (0, vitest_1.test)('should parse with roles association', async () => {
464
+ const item = {
465
+ id: (0, schema_js_1.generateUserId)(),
466
+ verifiedEmail: 'test@example.com',
467
+ roles: [
468
+ 'rol_2NfYOTzVqhCHgWFzUL0WPfRRuhH',
469
+ 'rol_2NfYOTzVqhCHgWFzUL0WPfRRuhI',
470
+ ],
471
+ };
472
+ const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
473
+ (0, vitest_1.expect)(result.success).toBe(true);
474
+ if (result.success) {
475
+ (0, vitest_1.expect)(result.data.roles).toEqual([
476
+ 'rol_2NfYOTzVqhCHgWFzUL0WPfRRuhH',
477
+ 'rol_2NfYOTzVqhCHgWFzUL0WPfRRuhI',
478
+ ]);
479
+ }
480
+ });
481
+ });
482
+ (0, vitest_1.describe)('Update User Payload', () => {
483
+ (0, vitest_1.test)('should parse suspended flag', async () => {
484
+ const result = schema_js_2.UpdateUserPayloadSchema.safeParse({
485
+ suspended: true,
486
+ });
487
+ (0, vitest_1.expect)(result.success).toBe(true);
488
+ if (result.success) {
489
+ (0, vitest_1.expect)(result.data.suspended).toBe(true);
490
+ }
491
+ });
492
+ (0, vitest_1.test)('should parse name updates', async () => {
493
+ const result = schema_js_2.UpdateUserPayloadSchema.safeParse({
494
+ givenName: 'Jane',
495
+ familyName: null,
496
+ });
497
+ (0, vitest_1.expect)(result.success).toBe(true);
498
+ if (result.success) {
499
+ (0, vitest_1.expect)(result.data.givenName).toBe('Jane');
500
+ (0, vitest_1.expect)(result.data.familyName).toBeNull();
501
+ }
502
+ });
503
+ (0, vitest_1.test)('should parse verified and unverified email/phone updates', async () => {
504
+ const result = schema_js_2.UpdateUserPayloadSchema.safeParse({
505
+ verifiedEmail: 'newemail@example.com',
506
+ unverifiedEmail: 'pending@example.com',
507
+ verifiedPhoneNumber: '+9999999999',
508
+ unverifiedPhoneNumber: '+8888888888',
509
+ });
510
+ (0, vitest_1.expect)(result.success).toBe(true);
511
+ if (result.success) {
512
+ (0, vitest_1.expect)(result.data.verifiedEmail).toBe('newemail@example.com');
513
+ (0, vitest_1.expect)(result.data.unverifiedEmail).toBe('pending@example.com');
514
+ (0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBe('+9999999999');
515
+ (0, vitest_1.expect)(result.data.unverifiedPhoneNumber).toBe('+8888888888');
516
+ }
517
+ });
518
+ (0, vitest_1.test)('should parse metadata updates', async () => {
519
+ const result = schema_js_2.UpdateUserPayloadSchema.safeParse({
520
+ metadata: { key: 'value' },
521
+ });
522
+ (0, vitest_1.expect)(result.success).toBe(true);
523
+ if (result.success) {
524
+ (0, vitest_1.expect)(result.data.metadata).toEqual({ key: 'value' });
525
+ }
526
+ });
527
+ (0, vitest_1.test)('should allow empty object', async () => {
528
+ const result = schema_js_2.UpdateUserPayloadSchema.safeParse({});
529
+ (0, vitest_1.expect)(result.success).toBe(true);
530
+ });
531
+ });
532
+ (0, vitest_1.describe)('UserAssociationReferenceSchema', () => {
533
+ (0, vitest_1.test)('should parse valid association reference', () => {
534
+ const result = schema_js_2.UserAssociationReferenceSchema.safeParse({
535
+ id: (0, schema_js_1.generateUserId)(),
536
+ givenName: 'John',
537
+ familyName: 'Doe',
538
+ email: 'john@example.com',
539
+ phoneNumber: '+1234567890',
540
+ model: 'User',
541
+ });
542
+ (0, vitest_1.expect)(result.success).toBe(true);
543
+ if (result.success) {
544
+ (0, vitest_1.expect)(result.data.model).toBe('User');
545
+ (0, vitest_1.expect)(result.data.status).toBe('unverified');
546
+ }
547
+ });
548
+ (0, vitest_1.test)('should default status to unverified', () => {
549
+ const result = schema_js_2.UserAssociationReferenceSchema.safeParse({
550
+ id: (0, schema_js_1.generateUserId)(),
551
+ model: 'User',
552
+ });
553
+ (0, vitest_1.expect)(result.success).toBe(true);
554
+ if (result.success) {
555
+ (0, vitest_1.expect)(result.data.status).toBe('unverified');
556
+ }
557
+ });
558
+ (0, vitest_1.test)('should allow custom status', () => {
559
+ const result = schema_js_2.UserAssociationReferenceSchema.safeParse({
560
+ id: (0, schema_js_1.generateUserId)(),
561
+ status: 'active',
562
+ model: 'User',
563
+ });
564
+ (0, vitest_1.expect)(result.success).toBe(true);
565
+ if (result.success) {
566
+ (0, vitest_1.expect)(result.data.status).toBe('active');
567
+ }
568
+ });
569
+ (0, vitest_1.test)('should reject invalid model literal', () => {
570
+ const result = schema_js_2.UserAssociationReferenceSchema.safeParse({
571
+ id: (0, schema_js_1.generateUserId)(),
572
+ model: 'Organization',
573
+ });
574
+ (0, vitest_1.expect)(result.success).toBe(false);
94
575
  });
95
576
  });
96
577
  });
@@ -20,7 +20,7 @@ export declare const SignUpActionPayloadSchema: z.ZodObject<{
20
20
  export type SignUpActionPayload = z.output<typeof SignUpActionPayloadSchema>;
21
21
  export declare const SignUpActionRequestSchema: z.ZodUnion<readonly [z.ZodObject<{
22
22
  email: z.ZodEmail;
23
- phoneNumber: z.ZodOptional<z.ZodString>;
23
+ phoneNumber: z.ZodOptional<z.ZodE164>;
24
24
  id: z.ZodOptional<z.ZodString>;
25
25
  givenName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
26
26
  middleName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
@@ -28,7 +28,7 @@ export declare const SignUpActionRequestSchema: z.ZodUnion<readonly [z.ZodObject
28
28
  honorificPrefix: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
29
29
  honorificSuffix: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
30
30
  }, z.core.$strip>, z.ZodObject<{
31
- phoneNumber: z.ZodString;
31
+ phoneNumber: z.ZodE164;
32
32
  email: z.ZodOptional<z.ZodEmail>;
33
33
  id: z.ZodOptional<z.ZodString>;
34
34
  givenName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
@@ -16,7 +16,7 @@ export declare const AssociationObjectSchema: z.ZodUnion<readonly [z.ZodObject<{
16
16
  }>>;
17
17
  model: z.ZodLiteral<"User">;
18
18
  email: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
19
- phoneNumber: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
19
+ phoneNumber: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
20
20
  givenName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
21
21
  middleName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
22
22
  familyName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
@@ -75,7 +75,7 @@ export declare const ObjectPropertySchema: z.ZodObject<{
75
75
  }>>;
76
76
  model: z.ZodLiteral<"User">;
77
77
  email: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
78
- phoneNumber: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
78
+ phoneNumber: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
79
79
  givenName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
80
80
  middleName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
81
81
  familyName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
@@ -139,7 +139,7 @@ export declare const AssociationSchema: z.ZodObject<{
139
139
  }>>;
140
140
  model: z.ZodLiteral<"User">;
141
141
  email: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
142
- phoneNumber: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
142
+ phoneNumber: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
143
143
  givenName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
144
144
  middleName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
145
145
  familyName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
@@ -225,7 +225,7 @@ export declare const AssociationPayloadSchema: z.ZodObject<{
225
225
  }>>;
226
226
  model: z.ZodLiteral<"User">;
227
227
  email: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
228
- phoneNumber: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
228
+ phoneNumber: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
229
229
  givenName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
230
230
  middleName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
231
231
  familyName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;