@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/brain/signatures.md
CHANGED
|
@@ -28,6 +28,7 @@ interface IAddressDTO {
|
|
|
28
28
|
interface ICustomerAddressDTO {
|
|
29
29
|
id: string;
|
|
30
30
|
label: string;
|
|
31
|
+
labelId: string | null;
|
|
31
32
|
isPrimary: boolean;
|
|
32
33
|
address: IAddressDTO;
|
|
33
34
|
}
|
|
@@ -66,6 +67,7 @@ interface ICustomerEmailDTO {
|
|
|
66
67
|
id: string;
|
|
67
68
|
email: string;
|
|
68
69
|
label: string;
|
|
70
|
+
labelId: string | null;
|
|
69
71
|
isPrimary: boolean;
|
|
70
72
|
createdAt: string;
|
|
71
73
|
}
|
|
@@ -82,12 +84,16 @@ interface ICustomerPhoneDTO {
|
|
|
82
84
|
id: string;
|
|
83
85
|
phone: string;
|
|
84
86
|
label: string;
|
|
87
|
+
labelId: string | null;
|
|
85
88
|
isPrimary: boolean;
|
|
86
89
|
createdAt: string;
|
|
87
90
|
}
|
|
88
91
|
|
|
89
|
-
interface
|
|
90
|
-
|
|
92
|
+
interface ICustomerLabelDTO {
|
|
93
|
+
id: string;
|
|
94
|
+
type: CustomerLabelType;
|
|
95
|
+
value: string;
|
|
96
|
+
createdAt: string;
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
function toAddressDTO(a: IAddress): IAddressDTO
|
|
@@ -104,7 +110,7 @@ function toCustomerNoteDTO(n: ICustomerNote): ICustomerNoteDTO
|
|
|
104
110
|
|
|
105
111
|
function toCustomerPhoneDTO(p: ICustomerPhone): ICustomerPhoneDTO
|
|
106
112
|
|
|
107
|
-
function
|
|
113
|
+
function toCustomerLabelDTO(l: ICustomerLabel): ICustomerLabelDTO
|
|
108
114
|
|
|
109
115
|
new CustomerAddressModel(store: IStoreAdapter): CustomerAddressModel
|
|
110
116
|
.list(customerId: string): Promise<ICustomerAddress[]>
|
|
@@ -235,10 +241,5 @@ interface ICustomerPhone {
|
|
|
235
241
|
createdAt: string;
|
|
236
242
|
}
|
|
237
243
|
|
|
238
|
-
interface ICustomerTag {
|
|
239
|
-
customerId: string;
|
|
240
|
-
tag: string;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
244
|
namespace schemas — exports: addAddressSchema, addEmailSchema, addPhoneSchema, addRelationshipSchema, addTagSchema, blacklistSchema, createCustomerSchema, noteSchema, updateAddressSchema, updateCustomerSchema, updateEmailSchema, updatePhoneSchema
|
|
244
245
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -34,9 +34,9 @@ __export(index_exports, {
|
|
|
34
34
|
toCustomerDTO: () => toCustomerDTO,
|
|
35
35
|
toCustomerDetailDTO: () => toCustomerDetailDTO,
|
|
36
36
|
toCustomerEmailDTO: () => toCustomerEmailDTO,
|
|
37
|
+
toCustomerLabelDTO: () => toCustomerLabelDTO,
|
|
37
38
|
toCustomerNoteDTO: () => toCustomerNoteDTO,
|
|
38
|
-
toCustomerPhoneDTO: () => toCustomerPhoneDTO
|
|
39
|
-
toCustomerTagDTO: () => toCustomerTagDTO
|
|
39
|
+
toCustomerPhoneDTO: () => toCustomerPhoneDTO
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(index_exports);
|
|
42
42
|
|
|
@@ -100,6 +100,7 @@ function toCustomerRelationshipExpandedDTO(r) {
|
|
|
100
100
|
customerId,
|
|
101
101
|
relationship: (0, import_core.stringOrEmpty)(r.relationship),
|
|
102
102
|
isPrimary: (0, import_core.booleanOrFalse)(r.isPrimary),
|
|
103
|
+
relationshipCreatedAt: (0, import_core.dateOrEmpty)(r.createdAt),
|
|
103
104
|
...customerFields2
|
|
104
105
|
};
|
|
105
106
|
}
|
|
@@ -121,6 +122,7 @@ function toCustomerRelationshipExpandedD2DTO(r) {
|
|
|
121
122
|
customerId,
|
|
122
123
|
relationship: (0, import_core.stringOrEmpty)(r.relationship),
|
|
123
124
|
isPrimary: (0, import_core.booleanOrFalse)(r.isPrimary),
|
|
125
|
+
relationshipCreatedAt: (0, import_core.dateOrEmpty)(r.createdAt),
|
|
124
126
|
...customerFields2,
|
|
125
127
|
relationships: (0, import_core.arrayOrEmpty)(r.customer.relationships).map(toCustomerRelationshipExpandedDTO)
|
|
126
128
|
};
|
|
@@ -152,6 +154,7 @@ function toCustomerEmailDTO(e) {
|
|
|
152
154
|
id: (0, import_core.stringOrEmpty)(e.id),
|
|
153
155
|
email: (0, import_core.stringOrEmpty)(e.email),
|
|
154
156
|
label: (0, import_core.stringOrEmpty)(e.label),
|
|
157
|
+
labelId: e.labelId ?? null,
|
|
155
158
|
isPrimary: (0, import_core.booleanOrFalse)(e.isPrimary),
|
|
156
159
|
createdAt: (0, import_core.dateOrEmpty)(e.createdAt)
|
|
157
160
|
};
|
|
@@ -161,6 +164,7 @@ function toCustomerPhoneDTO(p) {
|
|
|
161
164
|
id: (0, import_core.stringOrEmpty)(p.id),
|
|
162
165
|
phone: (0, import_core.stringOrEmpty)(p.phone),
|
|
163
166
|
label: (0, import_core.stringOrEmpty)(p.label),
|
|
167
|
+
labelId: p.labelId ?? null,
|
|
164
168
|
isPrimary: (0, import_core.booleanOrFalse)(p.isPrimary),
|
|
165
169
|
createdAt: (0, import_core.dateOrEmpty)(p.createdAt)
|
|
166
170
|
};
|
|
@@ -169,6 +173,7 @@ function toCustomerAddressDTO(ca) {
|
|
|
169
173
|
return {
|
|
170
174
|
id: (0, import_core.stringOrEmpty)(ca.addrId),
|
|
171
175
|
label: (0, import_core.stringOrEmpty)(ca.label),
|
|
176
|
+
labelId: ca.labelId ?? null,
|
|
172
177
|
isPrimary: (0, import_core.booleanOrFalse)(ca.isPrimary),
|
|
173
178
|
address: toAddressDTO(ca.address)
|
|
174
179
|
};
|
|
@@ -182,9 +187,12 @@ function toCustomerNoteDTO(n) {
|
|
|
182
187
|
updatedAt: (0, import_core.dateOrEmpty)(n.updatedAt)
|
|
183
188
|
};
|
|
184
189
|
}
|
|
185
|
-
function
|
|
190
|
+
function toCustomerLabelDTO(l) {
|
|
186
191
|
return {
|
|
187
|
-
|
|
192
|
+
id: (0, import_core.stringOrEmpty)(l.id),
|
|
193
|
+
type: l.type,
|
|
194
|
+
value: (0, import_core.stringOrEmpty)(l.value),
|
|
195
|
+
createdAt: (0, import_core.dateOrEmpty)(l.createdAt)
|
|
188
196
|
};
|
|
189
197
|
}
|
|
190
198
|
|
|
@@ -1293,17 +1301,23 @@ var customerFields = {
|
|
|
1293
1301
|
companyName: import_zod.z.string().max(200).nullable().optional(),
|
|
1294
1302
|
avatarUrl: import_zod.z.string().trim().pipe(import_zod.z.url()).nullable().optional(),
|
|
1295
1303
|
locale: import_zod.z.string().max(35).nullable().optional(),
|
|
1296
|
-
referenceCode: import_zod.z.string().max(100).nullable().optional()
|
|
1304
|
+
referenceCode: import_zod.z.string().max(100).nullable().optional()
|
|
1305
|
+
};
|
|
1306
|
+
var referralFields = {
|
|
1297
1307
|
referralCode: import_zod.z.string().max(100).nullable().optional(),
|
|
1298
1308
|
referredByCode: import_zod.z.string().max(100).nullable().optional()
|
|
1299
1309
|
};
|
|
1300
|
-
var createCustomerSchema = import_zod.z.object(customerFields);
|
|
1310
|
+
var createCustomerSchema = import_zod.z.object({ ...customerFields, ...referralFields });
|
|
1301
1311
|
var updateCustomerSchema = import_zod.z.object(customerFields).refine((o) => Object.values(o).some((v) => v !== void 0), "Provide at least one field");
|
|
1302
1312
|
var blacklistSchema = import_zod.z.object({ reason: import_zod.z.string().max(1e3).optional() });
|
|
1303
1313
|
var addEmailSchema = import_zod.z.object({ email, label, isPrimary });
|
|
1304
|
-
var updateEmailSchema = import_zod.z.object({
|
|
1314
|
+
var updateEmailSchema = import_zod.z.object({
|
|
1315
|
+
label: import_zod.z.string().trim().min(1, "label is required").max(100)
|
|
1316
|
+
});
|
|
1305
1317
|
var addPhoneSchema = import_zod.z.object({ phone, label, isPrimary });
|
|
1306
|
-
var updatePhoneSchema = import_zod.z.object({
|
|
1318
|
+
var updatePhoneSchema = import_zod.z.object({
|
|
1319
|
+
label: import_zod.z.string().trim().min(1, "label is required").max(100)
|
|
1320
|
+
});
|
|
1307
1321
|
var addressFields = {
|
|
1308
1322
|
label,
|
|
1309
1323
|
isPrimary,
|
|
@@ -1316,12 +1330,16 @@ var addressFields = {
|
|
|
1316
1330
|
subdivision2Iso: import_zod.z.string().max(10).nullable().optional()
|
|
1317
1331
|
};
|
|
1318
1332
|
var addAddressSchema = import_zod.z.object(addressFields);
|
|
1319
|
-
var updateAddressSchema = import_zod.z.object(
|
|
1333
|
+
var updateAddressSchema = import_zod.z.object({
|
|
1334
|
+
label: import_zod.z.string().trim().min(1, "label is required").max(100)
|
|
1335
|
+
});
|
|
1320
1336
|
var noteSchema = import_zod.z.object({ body: import_zod.z.string().trim().min(1, "body is required").max(1e4) });
|
|
1321
1337
|
var addTagSchema = import_zod.z.object({ tag: import_zod.z.string().trim().min(1, "tag is required").max(100) });
|
|
1322
1338
|
var addRelationshipSchema = import_zod.z.object({
|
|
1323
1339
|
relatedId: import_zod.z.string().min(1, "relatedId is required"),
|
|
1324
|
-
|
|
1340
|
+
// The controller has always required this — an optional schema let a
|
|
1341
|
+
// type-correct client walk straight into a guaranteed 422.
|
|
1342
|
+
relationship: import_zod.z.string().trim().min(1, "relationship is required").max(100),
|
|
1325
1343
|
isPrimary
|
|
1326
1344
|
});
|
|
1327
1345
|
|
|
@@ -2161,7 +2179,9 @@ function customerLabelController(store) {
|
|
|
2161
2179
|
return (0, import_core8.setApiResponse)(import_core8.HTTP.UNPROCESSABLE, "INVALID_PARAMETER", "type must be phone, email, or address");
|
|
2162
2180
|
}
|
|
2163
2181
|
const rows = await labels.list(type);
|
|
2164
|
-
return (0, import_core8.setApiResponse)(import_core8.HTTP.OK, "LABELS_FETCHED", "Labels retrieved successfully.", {
|
|
2182
|
+
return (0, import_core8.setApiResponse)(import_core8.HTTP.OK, "LABELS_FETCHED", "Labels retrieved successfully.", {
|
|
2183
|
+
labels: rows.map(toCustomerLabelDTO)
|
|
2184
|
+
});
|
|
2165
2185
|
},
|
|
2166
2186
|
async remove(ctx) {
|
|
2167
2187
|
const params = ctx.meta["params"];
|
|
@@ -2355,8 +2375,8 @@ var CustomersModule = class {
|
|
|
2355
2375
|
toCustomerDTO,
|
|
2356
2376
|
toCustomerDetailDTO,
|
|
2357
2377
|
toCustomerEmailDTO,
|
|
2378
|
+
toCustomerLabelDTO,
|
|
2358
2379
|
toCustomerNoteDTO,
|
|
2359
|
-
toCustomerPhoneDTO
|
|
2360
|
-
toCustomerTagDTO
|
|
2380
|
+
toCustomerPhoneDTO
|
|
2361
2381
|
});
|
|
2362
2382
|
//# sourceMappingURL=index.cjs.map
|