@fonderie/customers 6.0.0 → 6.1.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.
- package/brain/signatures.md +9 -8
- package/dist/index.cjs +33 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -25
- package/dist/index.d.ts +18 -25
- package/dist/index.js +31 -11
- package/dist/index.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -5
- package/dist/types.d.ts +1 -5
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomerSex, IAddress, ICustomerAddress, ICustomer, ICustomerDetail, ICustomerEmail, ICustomerNote, ICustomerPhone,
|
|
1
|
+
import { CustomerSex, CustomerLabelType, IAddress, ICustomerAddress, ICustomer, ICustomerDetail, ICustomerEmail, ICustomerLabel, ICustomerNote, ICustomerPhone, ICustomerDetailD2 } from './types.cjs';
|
|
2
2
|
export { CustomerType } from './types.cjs';
|
|
3
3
|
import { IStoreAdapter } from '@fonderie/store';
|
|
4
4
|
import { IFonderieModule, IFonderieApp } from '@fonderie/core';
|
|
@@ -50,6 +50,7 @@ type ICustomerRelationshipExpandedDTO = Omit<ICustomerShallowDTO, 'id'> & {
|
|
|
50
50
|
customerId: string;
|
|
51
51
|
relationship: string;
|
|
52
52
|
isPrimary: boolean;
|
|
53
|
+
relationshipCreatedAt: string;
|
|
53
54
|
};
|
|
54
55
|
interface ICustomerDetailDTO extends ICustomerDTO {
|
|
55
56
|
emails: ICustomerEmailDTO[];
|
|
@@ -63,6 +64,7 @@ interface ICustomerEmailDTO {
|
|
|
63
64
|
id: string;
|
|
64
65
|
email: string;
|
|
65
66
|
label: string;
|
|
67
|
+
labelId: string | null;
|
|
66
68
|
isPrimary: boolean;
|
|
67
69
|
createdAt: string;
|
|
68
70
|
}
|
|
@@ -70,6 +72,7 @@ interface ICustomerPhoneDTO {
|
|
|
70
72
|
id: string;
|
|
71
73
|
phone: string;
|
|
72
74
|
label: string;
|
|
75
|
+
labelId: string | null;
|
|
73
76
|
isPrimary: boolean;
|
|
74
77
|
createdAt: string;
|
|
75
78
|
}
|
|
@@ -85,6 +88,7 @@ interface IAddressDTO {
|
|
|
85
88
|
interface ICustomerAddressDTO {
|
|
86
89
|
id: string;
|
|
87
90
|
label: string;
|
|
91
|
+
labelId: string | null;
|
|
88
92
|
isPrimary: boolean;
|
|
89
93
|
address: IAddressDTO;
|
|
90
94
|
}
|
|
@@ -95,8 +99,11 @@ interface ICustomerNoteDTO {
|
|
|
95
99
|
createdAt: string;
|
|
96
100
|
updatedAt: string;
|
|
97
101
|
}
|
|
98
|
-
interface
|
|
99
|
-
|
|
102
|
+
interface ICustomerLabelDTO {
|
|
103
|
+
id: string;
|
|
104
|
+
type: CustomerLabelType;
|
|
105
|
+
value: string;
|
|
106
|
+
createdAt: string;
|
|
100
107
|
}
|
|
101
108
|
declare function toCustomerDTO(c: ICustomer): ICustomerDTO;
|
|
102
109
|
declare function toCustomerDetailDTO(c: ICustomerDetail): ICustomerDetailDTO;
|
|
@@ -105,7 +112,7 @@ declare function toCustomerEmailDTO(e: ICustomerEmail): ICustomerEmailDTO;
|
|
|
105
112
|
declare function toCustomerPhoneDTO(p: ICustomerPhone): ICustomerPhoneDTO;
|
|
106
113
|
declare function toCustomerAddressDTO(ca: ICustomerAddress): ICustomerAddressDTO;
|
|
107
114
|
declare function toCustomerNoteDTO(n: ICustomerNote): ICustomerNoteDTO;
|
|
108
|
-
declare function
|
|
115
|
+
declare function toCustomerLabelDTO(l: ICustomerLabel): ICustomerLabelDTO;
|
|
109
116
|
|
|
110
117
|
interface ListCustomersOpts {
|
|
111
118
|
workspaceId: string;
|
|
@@ -254,6 +261,8 @@ declare class CustomersModule implements IFonderieModule {
|
|
|
254
261
|
}
|
|
255
262
|
|
|
256
263
|
declare const createCustomerSchema: z.ZodObject<{
|
|
264
|
+
referralCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
265
|
+
referredByCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
257
266
|
type: z.ZodOptional<z.ZodEnum<{
|
|
258
267
|
individual: "individual";
|
|
259
268
|
business: "business";
|
|
@@ -269,8 +278,6 @@ declare const createCustomerSchema: z.ZodObject<{
|
|
|
269
278
|
avatarUrl: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodURL>>>;
|
|
270
279
|
locale: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
271
280
|
referenceCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
272
|
-
referralCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
273
|
-
referredByCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
274
281
|
}, z.core.$strip>;
|
|
275
282
|
declare const updateCustomerSchema: z.ZodObject<{
|
|
276
283
|
type: z.ZodOptional<z.ZodEnum<{
|
|
@@ -288,8 +295,6 @@ declare const updateCustomerSchema: z.ZodObject<{
|
|
|
288
295
|
avatarUrl: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodURL>>>;
|
|
289
296
|
locale: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
290
297
|
referenceCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
291
|
-
referralCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
292
|
-
referredByCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
293
298
|
}, z.core.$strip>;
|
|
294
299
|
declare const blacklistSchema: z.ZodObject<{
|
|
295
300
|
reason: z.ZodOptional<z.ZodString>;
|
|
@@ -300,9 +305,7 @@ declare const addEmailSchema: z.ZodObject<{
|
|
|
300
305
|
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
301
306
|
}, z.core.$strip>;
|
|
302
307
|
declare const updateEmailSchema: z.ZodObject<{
|
|
303
|
-
|
|
304
|
-
label: z.ZodOptional<z.ZodString>;
|
|
305
|
-
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
308
|
+
label: z.ZodString;
|
|
306
309
|
}, z.core.$strip>;
|
|
307
310
|
declare const addPhoneSchema: z.ZodObject<{
|
|
308
311
|
phone: z.ZodString;
|
|
@@ -310,9 +313,7 @@ declare const addPhoneSchema: z.ZodObject<{
|
|
|
310
313
|
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
311
314
|
}, z.core.$strip>;
|
|
312
315
|
declare const updatePhoneSchema: z.ZodObject<{
|
|
313
|
-
|
|
314
|
-
label: z.ZodOptional<z.ZodString>;
|
|
315
|
-
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
316
|
+
label: z.ZodString;
|
|
316
317
|
}, z.core.$strip>;
|
|
317
318
|
declare const addAddressSchema: z.ZodObject<{
|
|
318
319
|
label: z.ZodOptional<z.ZodString>;
|
|
@@ -326,15 +327,7 @@ declare const addAddressSchema: z.ZodObject<{
|
|
|
326
327
|
subdivision2Iso: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
327
328
|
}, z.core.$strip>;
|
|
328
329
|
declare const updateAddressSchema: z.ZodObject<{
|
|
329
|
-
label: z.
|
|
330
|
-
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
331
|
-
line1: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
332
|
-
line2: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
333
|
-
unit: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
334
|
-
zipPostalCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
335
|
-
countryIso: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
336
|
-
subdivision1Iso: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
337
|
-
subdivision2Iso: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
330
|
+
label: z.ZodString;
|
|
338
331
|
}, z.core.$strip>;
|
|
339
332
|
declare const noteSchema: z.ZodObject<{
|
|
340
333
|
body: z.ZodString;
|
|
@@ -344,7 +337,7 @@ declare const addTagSchema: z.ZodObject<{
|
|
|
344
337
|
}, z.core.$strip>;
|
|
345
338
|
declare const addRelationshipSchema: z.ZodObject<{
|
|
346
339
|
relatedId: z.ZodString;
|
|
347
|
-
relationship: z.
|
|
340
|
+
relationship: z.ZodString;
|
|
348
341
|
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
349
342
|
}, z.core.$strip>;
|
|
350
343
|
|
|
@@ -364,4 +357,4 @@ declare namespace schemas {
|
|
|
364
357
|
export { schemas_addAddressSchema as addAddressSchema, schemas_addEmailSchema as addEmailSchema, schemas_addPhoneSchema as addPhoneSchema, schemas_addRelationshipSchema as addRelationshipSchema, schemas_addTagSchema as addTagSchema, schemas_blacklistSchema as blacklistSchema, schemas_createCustomerSchema as createCustomerSchema, schemas_noteSchema as noteSchema, schemas_updateAddressSchema as updateAddressSchema, schemas_updateCustomerSchema as updateCustomerSchema, schemas_updateEmailSchema as updateEmailSchema, schemas_updatePhoneSchema as updatePhoneSchema };
|
|
365
358
|
}
|
|
366
359
|
|
|
367
|
-
export { CustomerAddressModel, CustomerEmailModel, CustomerModel, CustomerNoteModel, CustomerPhoneModel, CustomerTagModel, type CustomersEventKey, CustomersModule, EVENT_KEYS, IAddress, type IAddressDTO, ICustomer, ICustomerAddress, type ICustomerAddressDTO, type ICustomerDTO, ICustomerDetail, type ICustomerDetailDTO, ICustomerEmail, type ICustomerEmailDTO, ICustomerNote, type ICustomerNoteDTO, ICustomerPhone, type ICustomerPhoneDTO,
|
|
360
|
+
export { CustomerAddressModel, CustomerEmailModel, CustomerModel, CustomerNoteModel, CustomerPhoneModel, CustomerTagModel, type CustomersEventKey, CustomersModule, EVENT_KEYS, IAddress, type IAddressDTO, ICustomer, ICustomerAddress, type ICustomerAddressDTO, type ICustomerDTO, ICustomerDetail, type ICustomerDetailDTO, ICustomerEmail, type ICustomerEmailDTO, type ICustomerLabelDTO, ICustomerNote, type ICustomerNoteDTO, ICustomerPhone, type ICustomerPhoneDTO, type ICustomersConfig, schemas, toAddressDTO, toCustomerAddressDTO, toCustomerDTO, toCustomerDetailDTO, toCustomerEmailDTO, toCustomerLabelDTO, toCustomerNoteDTO, toCustomerPhoneDTO };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomerSex, IAddress, ICustomerAddress, ICustomer, ICustomerDetail, ICustomerEmail, ICustomerNote, ICustomerPhone,
|
|
1
|
+
import { CustomerSex, CustomerLabelType, IAddress, ICustomerAddress, ICustomer, ICustomerDetail, ICustomerEmail, ICustomerLabel, ICustomerNote, ICustomerPhone, ICustomerDetailD2 } from './types.js';
|
|
2
2
|
export { CustomerType } from './types.js';
|
|
3
3
|
import { IStoreAdapter } from '@fonderie/store';
|
|
4
4
|
import { IFonderieModule, IFonderieApp } from '@fonderie/core';
|
|
@@ -50,6 +50,7 @@ type ICustomerRelationshipExpandedDTO = Omit<ICustomerShallowDTO, 'id'> & {
|
|
|
50
50
|
customerId: string;
|
|
51
51
|
relationship: string;
|
|
52
52
|
isPrimary: boolean;
|
|
53
|
+
relationshipCreatedAt: string;
|
|
53
54
|
};
|
|
54
55
|
interface ICustomerDetailDTO extends ICustomerDTO {
|
|
55
56
|
emails: ICustomerEmailDTO[];
|
|
@@ -63,6 +64,7 @@ interface ICustomerEmailDTO {
|
|
|
63
64
|
id: string;
|
|
64
65
|
email: string;
|
|
65
66
|
label: string;
|
|
67
|
+
labelId: string | null;
|
|
66
68
|
isPrimary: boolean;
|
|
67
69
|
createdAt: string;
|
|
68
70
|
}
|
|
@@ -70,6 +72,7 @@ interface ICustomerPhoneDTO {
|
|
|
70
72
|
id: string;
|
|
71
73
|
phone: string;
|
|
72
74
|
label: string;
|
|
75
|
+
labelId: string | null;
|
|
73
76
|
isPrimary: boolean;
|
|
74
77
|
createdAt: string;
|
|
75
78
|
}
|
|
@@ -85,6 +88,7 @@ interface IAddressDTO {
|
|
|
85
88
|
interface ICustomerAddressDTO {
|
|
86
89
|
id: string;
|
|
87
90
|
label: string;
|
|
91
|
+
labelId: string | null;
|
|
88
92
|
isPrimary: boolean;
|
|
89
93
|
address: IAddressDTO;
|
|
90
94
|
}
|
|
@@ -95,8 +99,11 @@ interface ICustomerNoteDTO {
|
|
|
95
99
|
createdAt: string;
|
|
96
100
|
updatedAt: string;
|
|
97
101
|
}
|
|
98
|
-
interface
|
|
99
|
-
|
|
102
|
+
interface ICustomerLabelDTO {
|
|
103
|
+
id: string;
|
|
104
|
+
type: CustomerLabelType;
|
|
105
|
+
value: string;
|
|
106
|
+
createdAt: string;
|
|
100
107
|
}
|
|
101
108
|
declare function toCustomerDTO(c: ICustomer): ICustomerDTO;
|
|
102
109
|
declare function toCustomerDetailDTO(c: ICustomerDetail): ICustomerDetailDTO;
|
|
@@ -105,7 +112,7 @@ declare function toCustomerEmailDTO(e: ICustomerEmail): ICustomerEmailDTO;
|
|
|
105
112
|
declare function toCustomerPhoneDTO(p: ICustomerPhone): ICustomerPhoneDTO;
|
|
106
113
|
declare function toCustomerAddressDTO(ca: ICustomerAddress): ICustomerAddressDTO;
|
|
107
114
|
declare function toCustomerNoteDTO(n: ICustomerNote): ICustomerNoteDTO;
|
|
108
|
-
declare function
|
|
115
|
+
declare function toCustomerLabelDTO(l: ICustomerLabel): ICustomerLabelDTO;
|
|
109
116
|
|
|
110
117
|
interface ListCustomersOpts {
|
|
111
118
|
workspaceId: string;
|
|
@@ -254,6 +261,8 @@ declare class CustomersModule implements IFonderieModule {
|
|
|
254
261
|
}
|
|
255
262
|
|
|
256
263
|
declare const createCustomerSchema: z.ZodObject<{
|
|
264
|
+
referralCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
265
|
+
referredByCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
257
266
|
type: z.ZodOptional<z.ZodEnum<{
|
|
258
267
|
individual: "individual";
|
|
259
268
|
business: "business";
|
|
@@ -269,8 +278,6 @@ declare const createCustomerSchema: z.ZodObject<{
|
|
|
269
278
|
avatarUrl: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodURL>>>;
|
|
270
279
|
locale: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
271
280
|
referenceCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
272
|
-
referralCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
273
|
-
referredByCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
274
281
|
}, z.core.$strip>;
|
|
275
282
|
declare const updateCustomerSchema: z.ZodObject<{
|
|
276
283
|
type: z.ZodOptional<z.ZodEnum<{
|
|
@@ -288,8 +295,6 @@ declare const updateCustomerSchema: z.ZodObject<{
|
|
|
288
295
|
avatarUrl: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodURL>>>;
|
|
289
296
|
locale: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
290
297
|
referenceCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
291
|
-
referralCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
292
|
-
referredByCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
293
298
|
}, z.core.$strip>;
|
|
294
299
|
declare const blacklistSchema: z.ZodObject<{
|
|
295
300
|
reason: z.ZodOptional<z.ZodString>;
|
|
@@ -300,9 +305,7 @@ declare const addEmailSchema: z.ZodObject<{
|
|
|
300
305
|
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
301
306
|
}, z.core.$strip>;
|
|
302
307
|
declare const updateEmailSchema: z.ZodObject<{
|
|
303
|
-
|
|
304
|
-
label: z.ZodOptional<z.ZodString>;
|
|
305
|
-
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
308
|
+
label: z.ZodString;
|
|
306
309
|
}, z.core.$strip>;
|
|
307
310
|
declare const addPhoneSchema: z.ZodObject<{
|
|
308
311
|
phone: z.ZodString;
|
|
@@ -310,9 +313,7 @@ declare const addPhoneSchema: z.ZodObject<{
|
|
|
310
313
|
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
311
314
|
}, z.core.$strip>;
|
|
312
315
|
declare const updatePhoneSchema: z.ZodObject<{
|
|
313
|
-
|
|
314
|
-
label: z.ZodOptional<z.ZodString>;
|
|
315
|
-
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
316
|
+
label: z.ZodString;
|
|
316
317
|
}, z.core.$strip>;
|
|
317
318
|
declare const addAddressSchema: z.ZodObject<{
|
|
318
319
|
label: z.ZodOptional<z.ZodString>;
|
|
@@ -326,15 +327,7 @@ declare const addAddressSchema: z.ZodObject<{
|
|
|
326
327
|
subdivision2Iso: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
327
328
|
}, z.core.$strip>;
|
|
328
329
|
declare const updateAddressSchema: z.ZodObject<{
|
|
329
|
-
label: z.
|
|
330
|
-
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
331
|
-
line1: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
332
|
-
line2: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
333
|
-
unit: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
334
|
-
zipPostalCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
335
|
-
countryIso: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
336
|
-
subdivision1Iso: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
337
|
-
subdivision2Iso: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
330
|
+
label: z.ZodString;
|
|
338
331
|
}, z.core.$strip>;
|
|
339
332
|
declare const noteSchema: z.ZodObject<{
|
|
340
333
|
body: z.ZodString;
|
|
@@ -344,7 +337,7 @@ declare const addTagSchema: z.ZodObject<{
|
|
|
344
337
|
}, z.core.$strip>;
|
|
345
338
|
declare const addRelationshipSchema: z.ZodObject<{
|
|
346
339
|
relatedId: z.ZodString;
|
|
347
|
-
relationship: z.
|
|
340
|
+
relationship: z.ZodString;
|
|
348
341
|
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
349
342
|
}, z.core.$strip>;
|
|
350
343
|
|
|
@@ -364,4 +357,4 @@ declare namespace schemas {
|
|
|
364
357
|
export { schemas_addAddressSchema as addAddressSchema, schemas_addEmailSchema as addEmailSchema, schemas_addPhoneSchema as addPhoneSchema, schemas_addRelationshipSchema as addRelationshipSchema, schemas_addTagSchema as addTagSchema, schemas_blacklistSchema as blacklistSchema, schemas_createCustomerSchema as createCustomerSchema, schemas_noteSchema as noteSchema, schemas_updateAddressSchema as updateAddressSchema, schemas_updateCustomerSchema as updateCustomerSchema, schemas_updateEmailSchema as updateEmailSchema, schemas_updatePhoneSchema as updatePhoneSchema };
|
|
365
358
|
}
|
|
366
359
|
|
|
367
|
-
export { CustomerAddressModel, CustomerEmailModel, CustomerModel, CustomerNoteModel, CustomerPhoneModel, CustomerTagModel, type CustomersEventKey, CustomersModule, EVENT_KEYS, IAddress, type IAddressDTO, ICustomer, ICustomerAddress, type ICustomerAddressDTO, type ICustomerDTO, ICustomerDetail, type ICustomerDetailDTO, ICustomerEmail, type ICustomerEmailDTO, ICustomerNote, type ICustomerNoteDTO, ICustomerPhone, type ICustomerPhoneDTO,
|
|
360
|
+
export { CustomerAddressModel, CustomerEmailModel, CustomerModel, CustomerNoteModel, CustomerPhoneModel, CustomerTagModel, type CustomersEventKey, CustomersModule, EVENT_KEYS, IAddress, type IAddressDTO, ICustomer, ICustomerAddress, type ICustomerAddressDTO, type ICustomerDTO, ICustomerDetail, type ICustomerDetailDTO, ICustomerEmail, type ICustomerEmailDTO, type ICustomerLabelDTO, ICustomerNote, type ICustomerNoteDTO, ICustomerPhone, type ICustomerPhoneDTO, type ICustomersConfig, schemas, toAddressDTO, toCustomerAddressDTO, toCustomerDTO, toCustomerDetailDTO, toCustomerEmailDTO, toCustomerLabelDTO, toCustomerNoteDTO, toCustomerPhoneDTO };
|
package/dist/index.js
CHANGED
|
@@ -64,6 +64,7 @@ function toCustomerRelationshipExpandedDTO(r) {
|
|
|
64
64
|
customerId,
|
|
65
65
|
relationship: stringOrEmpty(r.relationship),
|
|
66
66
|
isPrimary: booleanOrFalse(r.isPrimary),
|
|
67
|
+
relationshipCreatedAt: dateOrEmpty(r.createdAt),
|
|
67
68
|
...customerFields2
|
|
68
69
|
};
|
|
69
70
|
}
|
|
@@ -85,6 +86,7 @@ function toCustomerRelationshipExpandedD2DTO(r) {
|
|
|
85
86
|
customerId,
|
|
86
87
|
relationship: stringOrEmpty(r.relationship),
|
|
87
88
|
isPrimary: booleanOrFalse(r.isPrimary),
|
|
89
|
+
relationshipCreatedAt: dateOrEmpty(r.createdAt),
|
|
88
90
|
...customerFields2,
|
|
89
91
|
relationships: arrayOrEmpty(r.customer.relationships).map(toCustomerRelationshipExpandedDTO)
|
|
90
92
|
};
|
|
@@ -116,6 +118,7 @@ function toCustomerEmailDTO(e) {
|
|
|
116
118
|
id: stringOrEmpty(e.id),
|
|
117
119
|
email: stringOrEmpty(e.email),
|
|
118
120
|
label: stringOrEmpty(e.label),
|
|
121
|
+
labelId: e.labelId ?? null,
|
|
119
122
|
isPrimary: booleanOrFalse(e.isPrimary),
|
|
120
123
|
createdAt: dateOrEmpty(e.createdAt)
|
|
121
124
|
};
|
|
@@ -125,6 +128,7 @@ function toCustomerPhoneDTO(p) {
|
|
|
125
128
|
id: stringOrEmpty(p.id),
|
|
126
129
|
phone: stringOrEmpty(p.phone),
|
|
127
130
|
label: stringOrEmpty(p.label),
|
|
131
|
+
labelId: p.labelId ?? null,
|
|
128
132
|
isPrimary: booleanOrFalse(p.isPrimary),
|
|
129
133
|
createdAt: dateOrEmpty(p.createdAt)
|
|
130
134
|
};
|
|
@@ -133,6 +137,7 @@ function toCustomerAddressDTO(ca) {
|
|
|
133
137
|
return {
|
|
134
138
|
id: stringOrEmpty(ca.addrId),
|
|
135
139
|
label: stringOrEmpty(ca.label),
|
|
140
|
+
labelId: ca.labelId ?? null,
|
|
136
141
|
isPrimary: booleanOrFalse(ca.isPrimary),
|
|
137
142
|
address: toAddressDTO(ca.address)
|
|
138
143
|
};
|
|
@@ -146,9 +151,12 @@ function toCustomerNoteDTO(n) {
|
|
|
146
151
|
updatedAt: dateOrEmpty(n.updatedAt)
|
|
147
152
|
};
|
|
148
153
|
}
|
|
149
|
-
function
|
|
154
|
+
function toCustomerLabelDTO(l) {
|
|
150
155
|
return {
|
|
151
|
-
|
|
156
|
+
id: stringOrEmpty(l.id),
|
|
157
|
+
type: l.type,
|
|
158
|
+
value: stringOrEmpty(l.value),
|
|
159
|
+
createdAt: dateOrEmpty(l.createdAt)
|
|
152
160
|
};
|
|
153
161
|
}
|
|
154
162
|
|
|
@@ -1257,17 +1265,23 @@ var customerFields = {
|
|
|
1257
1265
|
companyName: z.string().max(200).nullable().optional(),
|
|
1258
1266
|
avatarUrl: z.string().trim().pipe(z.url()).nullable().optional(),
|
|
1259
1267
|
locale: z.string().max(35).nullable().optional(),
|
|
1260
|
-
referenceCode: z.string().max(100).nullable().optional()
|
|
1268
|
+
referenceCode: z.string().max(100).nullable().optional()
|
|
1269
|
+
};
|
|
1270
|
+
var referralFields = {
|
|
1261
1271
|
referralCode: z.string().max(100).nullable().optional(),
|
|
1262
1272
|
referredByCode: z.string().max(100).nullable().optional()
|
|
1263
1273
|
};
|
|
1264
|
-
var createCustomerSchema = z.object(customerFields);
|
|
1274
|
+
var createCustomerSchema = z.object({ ...customerFields, ...referralFields });
|
|
1265
1275
|
var updateCustomerSchema = z.object(customerFields).refine((o) => Object.values(o).some((v) => v !== void 0), "Provide at least one field");
|
|
1266
1276
|
var blacklistSchema = z.object({ reason: z.string().max(1e3).optional() });
|
|
1267
1277
|
var addEmailSchema = z.object({ email, label, isPrimary });
|
|
1268
|
-
var updateEmailSchema = z.object({
|
|
1278
|
+
var updateEmailSchema = z.object({
|
|
1279
|
+
label: z.string().trim().min(1, "label is required").max(100)
|
|
1280
|
+
});
|
|
1269
1281
|
var addPhoneSchema = z.object({ phone, label, isPrimary });
|
|
1270
|
-
var updatePhoneSchema = z.object({
|
|
1282
|
+
var updatePhoneSchema = z.object({
|
|
1283
|
+
label: z.string().trim().min(1, "label is required").max(100)
|
|
1284
|
+
});
|
|
1271
1285
|
var addressFields = {
|
|
1272
1286
|
label,
|
|
1273
1287
|
isPrimary,
|
|
@@ -1280,12 +1294,16 @@ var addressFields = {
|
|
|
1280
1294
|
subdivision2Iso: z.string().max(10).nullable().optional()
|
|
1281
1295
|
};
|
|
1282
1296
|
var addAddressSchema = z.object(addressFields);
|
|
1283
|
-
var updateAddressSchema = z.object(
|
|
1297
|
+
var updateAddressSchema = z.object({
|
|
1298
|
+
label: z.string().trim().min(1, "label is required").max(100)
|
|
1299
|
+
});
|
|
1284
1300
|
var noteSchema = z.object({ body: z.string().trim().min(1, "body is required").max(1e4) });
|
|
1285
1301
|
var addTagSchema = z.object({ tag: z.string().trim().min(1, "tag is required").max(100) });
|
|
1286
1302
|
var addRelationshipSchema = z.object({
|
|
1287
1303
|
relatedId: z.string().min(1, "relatedId is required"),
|
|
1288
|
-
|
|
1304
|
+
// The controller has always required this — an optional schema let a
|
|
1305
|
+
// type-correct client walk straight into a guaranteed 422.
|
|
1306
|
+
relationship: z.string().trim().min(1, "relationship is required").max(100),
|
|
1289
1307
|
isPrimary
|
|
1290
1308
|
});
|
|
1291
1309
|
|
|
@@ -2125,7 +2143,9 @@ function customerLabelController(store) {
|
|
|
2125
2143
|
return setApiResponse7(HTTP7.UNPROCESSABLE, "INVALID_PARAMETER", "type must be phone, email, or address");
|
|
2126
2144
|
}
|
|
2127
2145
|
const rows = await labels.list(type);
|
|
2128
|
-
return setApiResponse7(HTTP7.OK, "LABELS_FETCHED", "Labels retrieved successfully.", {
|
|
2146
|
+
return setApiResponse7(HTTP7.OK, "LABELS_FETCHED", "Labels retrieved successfully.", {
|
|
2147
|
+
labels: rows.map(toCustomerLabelDTO)
|
|
2148
|
+
});
|
|
2129
2149
|
},
|
|
2130
2150
|
async remove(ctx) {
|
|
2131
2151
|
const params = ctx.meta["params"];
|
|
@@ -2318,8 +2338,8 @@ export {
|
|
|
2318
2338
|
toCustomerDTO,
|
|
2319
2339
|
toCustomerDetailDTO,
|
|
2320
2340
|
toCustomerEmailDTO,
|
|
2341
|
+
toCustomerLabelDTO,
|
|
2321
2342
|
toCustomerNoteDTO,
|
|
2322
|
-
toCustomerPhoneDTO
|
|
2323
|
-
toCustomerTagDTO
|
|
2343
|
+
toCustomerPhoneDTO
|
|
2324
2344
|
};
|
|
2325
2345
|
//# sourceMappingURL=index.js.map
|