@go-mondo/identity-sdk 0.0.2-beta.76 → 0.0.2-beta.78
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/.release-please-manifest.json +1 -1
- package/.tsbuildinfo/cjs.json +1 -1
- package/.tsbuildinfo/esm.json +1 -1
- package/CHANGELOG.md +14 -0
- package/dist/cjs/app/authorization/schema.d.ts +10 -10
- package/dist/cjs/app/authorization/schema.d.ts.map +1 -1
- package/dist/cjs/app/authorization/schema.js +10 -10
- package/dist/cjs/app/authorization/schema.test.js +34 -4
- package/dist/cjs/customer/users/schema.d.ts +4 -4
- package/dist/cjs/customer/users/schema.d.ts.map +1 -1
- package/dist/cjs/customer/users/schema.js +7 -7
- package/dist/cjs/customer/users/schema.test.js +14 -16
- package/dist/esm/app/authorization/schema.d.ts +10 -10
- package/dist/esm/app/authorization/schema.d.ts.map +1 -1
- package/dist/esm/app/authorization/schema.js +6 -6
- package/dist/esm/app/authorization/schema.test.js +34 -4
- package/dist/esm/customer/users/schema.d.ts +4 -4
- package/dist/esm/customer/users/schema.d.ts.map +1 -1
- package/dist/esm/customer/users/schema.js +7 -7
- package/dist/esm/customer/users/schema.test.js +14 -16
- package/package.json +1 -1
|
@@ -203,10 +203,10 @@ export type UserPayload = z.output<typeof UserPayloadSchema>;
|
|
|
203
203
|
export declare const InsertUserPayloadSchema: z.ZodObject<{
|
|
204
204
|
metadata: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodNull, z.ZodCustom<Map<string, string | number | boolean>, Map<string, string | number | boolean>>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>, z.ZodTransform<Record<string, string | number | boolean> | null | undefined, Record<string, string | number | boolean> | Map<string, string | number | boolean> | null | undefined>>>;
|
|
205
205
|
roles: z.ZodOptional<z.ZodUnion<readonly [z.ZodUndefined, z.ZodArray<z.ZodString>]>>;
|
|
206
|
+
verifiedEmail: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>>;
|
|
207
|
+
verifiedPhoneNumber: z.ZodOptional<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>>;
|
|
206
208
|
unverifiedEmail: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>>;
|
|
207
209
|
unverifiedPhoneNumber: z.ZodOptional<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>>;
|
|
208
|
-
verifiedEmail: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodBoolean, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<boolean | undefined, boolean | null | undefined>>>;
|
|
209
|
-
verifiedPhoneNumber: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodBoolean, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<boolean | undefined, boolean | null | undefined>>>;
|
|
210
210
|
givenName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
211
211
|
middleName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
212
212
|
familyName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
@@ -223,10 +223,10 @@ export type InsertUserInput = z.input<typeof InsertUserPayloadSchema>;
|
|
|
223
223
|
export type InsertUserPayload = z.output<typeof InsertUserPayloadSchema>;
|
|
224
224
|
export declare const UpdateUserPayloadSchema: z.ZodObject<{
|
|
225
225
|
metadata: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodNull, z.ZodCustom<Map<string, string | number | boolean>, Map<string, string | number | boolean>>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>, z.ZodTransform<Record<string, string | number | boolean> | null | undefined, Record<string, string | number | boolean> | Map<string, string | number | boolean> | null | undefined>>>;
|
|
226
|
+
verifiedEmail: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>>;
|
|
227
|
+
verifiedPhoneNumber: z.ZodOptional<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>>;
|
|
226
228
|
unverifiedEmail: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>>;
|
|
227
229
|
unverifiedPhoneNumber: z.ZodOptional<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>>;
|
|
228
|
-
verifiedEmail: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
229
|
-
verifiedPhoneNumber: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
230
230
|
givenName: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>>;
|
|
231
231
|
middleName: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>>;
|
|
232
232
|
familyName: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/customer/users/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AA2B5B,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAEX,MAAM,MAAM,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B,CAAC,CAAC;AACtE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;iBAMzC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAC7C,OAAO,8BAA8B,CACtC,CAAC"}
|
|
@@ -44,7 +44,9 @@ export const UnverifiedEmailOrPhonePropertiesSchema = z.object({
|
|
|
44
44
|
unverifiedEmail: optionallyNullishToUndefined(RequiredEmailSchema),
|
|
45
45
|
unverifiedPhoneNumber: optionallyNullishToUndefined(RequiredPhoneNumberSchema),
|
|
46
46
|
});
|
|
47
|
-
const
|
|
47
|
+
const UpsertEmailOrPhonePropertiesSchema = z.object({
|
|
48
|
+
verifiedEmail: optionallyNullish(RequiredEmailSchema),
|
|
49
|
+
verifiedPhoneNumber: optionallyNullish(RequiredPhoneNumberSchema),
|
|
48
50
|
unverifiedEmail: optionallyNullish(RequiredEmailSchema),
|
|
49
51
|
unverifiedPhoneNumber: optionallyNullish(RequiredPhoneNumberSchema),
|
|
50
52
|
});
|
|
@@ -92,8 +94,8 @@ export const UserPayloadSchema = UserPayloadSchemaBase.transform((user) => ({
|
|
|
92
94
|
phoneNumber: user.verifiedPhoneNumber,
|
|
93
95
|
}));
|
|
94
96
|
const requiredEmailOrPhoneMessage = 'At least one of verifiedEmail, verifiedPhoneNumber, unverifiedEmail, or unverifiedPhoneNumber is required';
|
|
95
|
-
const hasEmailOrPhone = (data) => data.verifiedEmail
|
|
96
|
-
data.verifiedPhoneNumber
|
|
97
|
+
const hasEmailOrPhone = (data) => data.verifiedEmail != null ||
|
|
98
|
+
data.verifiedPhoneNumber != null ||
|
|
97
99
|
data.unverifiedEmail != null ||
|
|
98
100
|
data.unverifiedPhoneNumber != null;
|
|
99
101
|
export const InsertUserPayloadSchema = z
|
|
@@ -101,9 +103,7 @@ export const InsertUserPayloadSchema = z
|
|
|
101
103
|
id: UserIdSchema.optional(),
|
|
102
104
|
status: UserStatusSchema.optional(),
|
|
103
105
|
...UserNamePropertiesSchema.shape,
|
|
104
|
-
|
|
105
|
-
verifiedPhoneNumber: optionallyNullishToUndefined(z.boolean()),
|
|
106
|
-
...UpsertUnverifiedEmailOrPhonePropertiesSchema.shape,
|
|
106
|
+
...UpsertEmailOrPhonePropertiesSchema.shape,
|
|
107
107
|
...UserAssociationsSchema.shape,
|
|
108
108
|
...UpsertMetadataPropertyPayloadSchema.shape,
|
|
109
109
|
})
|
|
@@ -127,7 +127,7 @@ export const UpdateUserPayloadSchema = z.object({
|
|
|
127
127
|
suspended: z.boolean().optional(),
|
|
128
128
|
...UpdateUserNamePropertiesSchema.shape,
|
|
129
129
|
...VerifiedEmailOrPhonePropertiesSchema.shape,
|
|
130
|
-
...
|
|
130
|
+
...UpsertEmailOrPhonePropertiesSchema.shape,
|
|
131
131
|
...UpsertMetadataPropertyPayloadSchema.shape,
|
|
132
132
|
});
|
|
133
133
|
/**
|
|
@@ -408,7 +408,7 @@ describe('Customer - User', () => {
|
|
|
408
408
|
foo: 'bar',
|
|
409
409
|
id: generateUserId(),
|
|
410
410
|
familyName: 'Foo',
|
|
411
|
-
verifiedPhoneNumber:
|
|
411
|
+
verifiedPhoneNumber: '+12025551234',
|
|
412
412
|
};
|
|
413
413
|
const result = InsertUserPayloadSchema.safeParse(item);
|
|
414
414
|
expect(result.success).toBe(true);
|
|
@@ -420,17 +420,17 @@ describe('Customer - User', () => {
|
|
|
420
420
|
test('should parse with all verified and unverified email/phone properties', async () => {
|
|
421
421
|
const item = {
|
|
422
422
|
id: generateUserId(),
|
|
423
|
-
verifiedEmail:
|
|
423
|
+
verifiedEmail: 'verified@example.com',
|
|
424
424
|
unverifiedEmail: 'pending@example.com',
|
|
425
|
-
verifiedPhoneNumber:
|
|
425
|
+
verifiedPhoneNumber: '+1234567890',
|
|
426
426
|
unverifiedPhoneNumber: '+0987654321',
|
|
427
427
|
};
|
|
428
428
|
const result = InsertUserPayloadSchema.safeParse(item);
|
|
429
429
|
expect(result.success).toBe(true);
|
|
430
430
|
if (result.success) {
|
|
431
|
-
expect(result.data.verifiedEmail).toBe(
|
|
431
|
+
expect(result.data.verifiedEmail).toBe('verified@example.com');
|
|
432
432
|
expect(result.data.unverifiedEmail).toBe('pending@example.com');
|
|
433
|
-
expect(result.data.verifiedPhoneNumber).toBe(
|
|
433
|
+
expect(result.data.verifiedPhoneNumber).toBe('+1234567890');
|
|
434
434
|
expect(result.data.unverifiedPhoneNumber).toBe('+0987654321');
|
|
435
435
|
}
|
|
436
436
|
});
|
|
@@ -438,7 +438,7 @@ describe('Customer - User', () => {
|
|
|
438
438
|
const item = {
|
|
439
439
|
foo: 'bar',
|
|
440
440
|
id: generateUserId(),
|
|
441
|
-
verifiedPhoneNumber:
|
|
441
|
+
verifiedPhoneNumber: '+12025551234',
|
|
442
442
|
metadata: new Map(),
|
|
443
443
|
};
|
|
444
444
|
const result = InsertUserPayloadSchema.safeParse(item);
|
|
@@ -449,7 +449,7 @@ describe('Customer - User', () => {
|
|
|
449
449
|
});
|
|
450
450
|
test('should allow optional id and status', async () => {
|
|
451
451
|
const item = {
|
|
452
|
-
verifiedEmail:
|
|
452
|
+
verifiedEmail: 'test@example.com',
|
|
453
453
|
};
|
|
454
454
|
const result = InsertUserPayloadSchema.safeParse(item);
|
|
455
455
|
expect(result.success).toBe(true);
|
|
@@ -461,7 +461,7 @@ describe('Customer - User', () => {
|
|
|
461
461
|
test('should parse with roles association', async () => {
|
|
462
462
|
const item = {
|
|
463
463
|
id: generateUserId(),
|
|
464
|
-
verifiedEmail:
|
|
464
|
+
verifiedEmail: 'test@example.com',
|
|
465
465
|
roles: [
|
|
466
466
|
'rol_2NfYOTzVqhCHgWFzUL0WPfRRuhH',
|
|
467
467
|
'rol_2NfYOTzVqhCHgWFzUL0WPfRRuhI',
|
|
@@ -493,28 +493,27 @@ describe('Customer - User', () => {
|
|
|
493
493
|
});
|
|
494
494
|
test('should accept with only verifiedEmail', async () => {
|
|
495
495
|
const item = {
|
|
496
|
-
verifiedEmail:
|
|
496
|
+
verifiedEmail: 'test@example.com',
|
|
497
497
|
};
|
|
498
498
|
const result = InsertUserPayloadSchema.safeParse(item);
|
|
499
499
|
expect(result.success).toBe(true);
|
|
500
500
|
if (result.success) {
|
|
501
|
-
expect(result.data.verifiedEmail).toBe(
|
|
501
|
+
expect(result.data.verifiedEmail).toBe('test@example.com');
|
|
502
502
|
}
|
|
503
503
|
});
|
|
504
504
|
test('should accept with only verifiedPhoneNumber', async () => {
|
|
505
505
|
const item = {
|
|
506
|
-
verifiedPhoneNumber:
|
|
506
|
+
verifiedPhoneNumber: '+12025551234',
|
|
507
507
|
};
|
|
508
508
|
const result = InsertUserPayloadSchema.safeParse(item);
|
|
509
509
|
expect(result.success).toBe(true);
|
|
510
510
|
if (result.success) {
|
|
511
|
-
expect(result.data.verifiedPhoneNumber).toBe(
|
|
511
|
+
expect(result.data.verifiedPhoneNumber).toBe('+12025551234');
|
|
512
512
|
}
|
|
513
513
|
});
|
|
514
514
|
test('should succeed with only unverifiedEmail', async () => {
|
|
515
515
|
const item = {
|
|
516
516
|
unverifiedEmail: 'test@example.com',
|
|
517
|
-
verifiedEmail: true,
|
|
518
517
|
unverifiedPhoneNumber: null,
|
|
519
518
|
};
|
|
520
519
|
const result = InsertUserPayloadSchema.safeParse(item);
|
|
@@ -522,7 +521,7 @@ describe('Customer - User', () => {
|
|
|
522
521
|
if (result.success) {
|
|
523
522
|
expect(result.data.unverifiedEmail).toBe('test@example.com');
|
|
524
523
|
expect(result.data.unverifiedPhoneNumber).toBeNull();
|
|
525
|
-
expect(result.data.verifiedEmail).
|
|
524
|
+
expect(result.data.verifiedEmail).toBeUndefined();
|
|
526
525
|
expect(result.data.verifiedPhoneNumber).toBeUndefined();
|
|
527
526
|
}
|
|
528
527
|
});
|
|
@@ -530,7 +529,6 @@ describe('Customer - User', () => {
|
|
|
530
529
|
const item = {
|
|
531
530
|
unverifiedEmail: null,
|
|
532
531
|
unverifiedPhoneNumber: '+12025551234',
|
|
533
|
-
verifiedPhoneNumber: true,
|
|
534
532
|
};
|
|
535
533
|
const result = InsertUserPayloadSchema.safeParse(item);
|
|
536
534
|
expect(result.success).toBe(true);
|
|
@@ -538,7 +536,7 @@ describe('Customer - User', () => {
|
|
|
538
536
|
expect(result.data.unverifiedPhoneNumber).toBe('+12025551234');
|
|
539
537
|
expect(result.data.unverifiedEmail).toBeNull();
|
|
540
538
|
expect(result.data.verifiedEmail).toBeUndefined();
|
|
541
|
-
expect(result.data.verifiedPhoneNumber).
|
|
539
|
+
expect(result.data.verifiedPhoneNumber).toBeUndefined();
|
|
542
540
|
}
|
|
543
541
|
});
|
|
544
542
|
});
|