@deliverart/sdk-js-customer 0.0.4 → 0.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.
Files changed (25) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.cjs +156 -181
  3. package/dist/index.d.cts +406 -304
  4. package/dist/index.d.ts +406 -304
  5. package/dist/index.js +139 -165
  6. package/package.json +5 -5
  7. package/src/models.ts +41 -12
  8. package/src/requests/customer-addresses/CreateCustomerAddress.ts +6 -10
  9. package/src/requests/customer-addresses/DeleteCustomerAddress.ts +5 -2
  10. package/src/requests/customer-addresses/GetCustomerAddressDetails.ts +7 -4
  11. package/src/requests/customer-addresses/GetCustomerAddresses.ts +5 -4
  12. package/src/requests/customer-addresses/GetCustomerAddressesForCustomer.ts +7 -4
  13. package/src/requests/customer-addresses/UpdateCustomerAddress.ts +5 -9
  14. package/src/requests/customer-business-profiles/CreateCustomerBusinessProfile.ts +6 -5
  15. package/src/requests/customer-business-profiles/DeleteCustomerBusinessProfile.ts +5 -2
  16. package/src/requests/customer-business-profiles/GetCustomerBusinessProfileDetails.ts +10 -5
  17. package/src/requests/customer-business-profiles/GetCustomerBusinessProfiles.ts +7 -4
  18. package/src/requests/customer-business-profiles/GetCustomerBusinessProfilesForCustomer.ts +7 -4
  19. package/src/requests/customer-business-profiles/UpdateCustomerBusinessProfile.ts +6 -5
  20. package/src/requests/customers/CreateCustomer.ts +5 -5
  21. package/src/requests/customers/DeleteCustomer.ts +5 -2
  22. package/src/requests/customers/GetCustomerDetails.ts +8 -4
  23. package/src/requests/customers/GetCustomers.ts +7 -32
  24. package/src/requests/customers/UpdateCustomer.ts +5 -5
  25. package/src/types.ts +16 -58
package/dist/index.js CHANGED
@@ -3,70 +3,44 @@ import {
3
3
  addressSchema,
4
4
  billingDataSchema,
5
5
  datetimeSchema,
6
- locationSchema
6
+ locationSchema,
7
+ sortDirSchema,
8
+ timestampsFilterSchema
7
9
  } from "@deliverart/sdk-js-global-types";
8
- import { pointOfSaleNullablePathSchema } from "@deliverart/sdk-js-point-of-sale";
9
- import { userNullablePathSchema } from "@deliverart/sdk-js-user";
10
- import { z as z2 } from "zod";
10
+ import { pointOfSaleNullableIriSchema } from "@deliverart/sdk-js-point-of-sale";
11
+ import { userNullableIriSchema } from "@deliverart/sdk-js-user";
12
+ import { z } from "zod";
11
13
 
12
14
  // src/types.ts
13
- import { z } from "zod";
14
- var customerPathSchema = z.string().refine((val) => /^\/customers\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val), {
15
- message: "Invalid customer path format"
16
- });
17
- var customerNullablePathSchema = z.string().nullable().refine(
18
- (val) => {
19
- if (!val) return true;
20
- return /^\/customers\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val);
21
- },
22
- {
23
- message: "Invalid customer path format"
24
- }
25
- );
26
- var customerAddressPathSchema = z.string().refine((val) => /^\/customers\/addresses\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val), {
27
- message: "Invalid customerAddress path format"
28
- });
29
- var customerAddressNullablePathSchema = z.string().nullable().refine(
30
- (val) => {
31
- if (!val) return true;
32
- return /^\/customers\/addresses\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val);
33
- },
34
- {
35
- message: "Invalid customerAddress path format"
36
- }
37
- );
38
- var customerBusinessProfilePathSchema = z.string().refine((val) => /^\/customers\/business_profiles\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val), {
39
- message: "Invalid customerBusinessProfile path format"
40
- });
41
- var customerBusinessProfileNullablePathSchema = z.string().nullable().refine(
42
- (val) => {
43
- if (!val) return true;
44
- return /^\/customers\/business_profiles\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val);
45
- },
46
- {
47
- message: "Invalid customerBusinessProfile path format"
48
- }
15
+ import { iriNullableSchema, iriSchema } from "@deliverart/sdk-js-global-types";
16
+ var customerIriSchema = iriSchema("/customers/:id");
17
+ var customerNullableIriSchema = iriNullableSchema("/customers/:id");
18
+ var customerAddressIriSchema = iriSchema("/customers/address/:id");
19
+ var customerAddressNullableIriSchema = iriNullableSchema("/customers/address/:id");
20
+ var customerBusinessProfileIriSchema = iriSchema("/customers/business_profiles/:id");
21
+ var customerBusinessProfileNullableIriSchema = iriNullableSchema(
22
+ "/customers/business_profiles/:id"
49
23
  );
50
24
 
51
25
  // src/models.ts
52
- var customerSchema = z2.object({
53
- id: z2.string(),
54
- firstName: z2.string().nullable(),
55
- lastName: z2.string().nullable(),
56
- email: z2.string().email().nullable(),
57
- phoneNumber: z2.string().nullable(),
58
- hasBusinessProfiles: z2.boolean(),
59
- hasAddresses: z2.boolean(),
60
- ordersPlaced: z2.number(),
61
- totalSpent: z2.number(),
26
+ var customerSchema = z.object({
27
+ id: z.string(),
28
+ firstName: z.string().nullable(),
29
+ lastName: z.string().nullable(),
30
+ email: z.string().email().nullable(),
31
+ phoneNumber: z.string().nullable(),
32
+ hasBusinessProfiles: z.boolean(),
33
+ hasAddresses: z.boolean(),
34
+ ordersPlaced: z.number(),
35
+ totalSpent: z.string(),
62
36
  createdAt: datetimeSchema,
63
37
  updatedAt: datetimeSchema
64
38
  });
65
39
  var customerDetailsSchema = customerSchema.extend({
66
- pointOfSale: pointOfSaleNullablePathSchema,
67
- owner: userNullablePathSchema,
68
- addresses: z2.array(customerAddressPathSchema),
69
- businessProfiles: z2.array(customerBusinessProfilePathSchema)
40
+ pointOfSale: pointOfSaleNullableIriSchema,
41
+ owner: userNullableIriSchema,
42
+ addresses: z.array(customerAddressIriSchema),
43
+ businessProfiles: z.array(customerBusinessProfileIriSchema)
70
44
  });
71
45
  var writableCreateCustomerSchema = customerDetailsSchema.pick({
72
46
  pointOfSale: true,
@@ -78,15 +52,15 @@ var writableCreateCustomerSchema = customerDetailsSchema.pick({
78
52
  var writableCustomerSchema = writableCreateCustomerSchema.omit({
79
53
  pointOfSale: true
80
54
  });
81
- var customerAddressSchema = z2.object({
82
- id: z2.string(),
55
+ var customerAddressSchema = z.object({
56
+ id: z.string(),
83
57
  address: addressSchema,
84
58
  location: locationSchema,
85
59
  createdAt: datetimeSchema,
86
60
  updatedAt: datetimeSchema
87
61
  });
88
62
  var customerAddressDetailsSchema = customerAddressSchema.extend({
89
- customer: customerPathSchema
63
+ customer: customerIriSchema
90
64
  });
91
65
  var writableCreateCustomerAddressSchema = customerAddressDetailsSchema.pick({
92
66
  customer: true,
@@ -95,18 +69,18 @@ var writableCreateCustomerAddressSchema = customerAddressDetailsSchema.pick({
95
69
  var writableCustomerAddressSchema = writableCreateCustomerAddressSchema.omit({
96
70
  customer: true
97
71
  });
98
- var customerBusinessProfileSchema = z2.object({
99
- id: z2.string(),
100
- businessName: z2.string(),
101
- vat: z2.string(),
102
- taxCode: z2.string(),
72
+ var customerBusinessProfileSchema = z.object({
73
+ id: z.string(),
74
+ businessName: z.string(),
75
+ vat: z.string(),
76
+ taxCode: z.string(),
103
77
  billingAddress: addressSchema,
104
78
  billingData: billingDataSchema,
105
79
  createdAt: datetimeSchema,
106
80
  updatedAt: datetimeSchema
107
81
  });
108
82
  var customerBusinessProfileDetailsSchema = customerBusinessProfileSchema.extend({
109
- customer: customerPathSchema
83
+ customer: customerIriSchema
110
84
  });
111
85
  var writableCreateCustomerBusinessProfileSchema = customerBusinessProfileDetailsSchema.pick({
112
86
  customer: true,
@@ -119,6 +93,29 @@ var writableCreateCustomerBusinessProfileSchema = customerBusinessProfileDetails
119
93
  var writableCustomerBusinessProfileSchema = writableCreateCustomerBusinessProfileSchema.omit({
120
94
  customer: true
121
95
  });
96
+ var customersQuerySchema = z.object({
97
+ firstName: z.string().optional(),
98
+ lastName: z.string().optional(),
99
+ email: z.string().optional(),
100
+ phoneNumber: z.string().optional(),
101
+ hasBusinessProfiles: z.coerce.boolean().optional(),
102
+ hasAddresses: z.coerce.boolean().optional(),
103
+ "ordersPlaced[between]": z.coerce.number().optional(),
104
+ "ordersPlaced[gt]": z.coerce.number().optional(),
105
+ "ordersPlaced[gte]": z.coerce.number().optional(),
106
+ "ordersPlaced[lt]": z.coerce.number().optional(),
107
+ "ordersPlaced[lte]": z.coerce.number().optional(),
108
+ "totalSpent[between]": z.coerce.number().optional(),
109
+ "totalSpent[gt]": z.coerce.string().optional(),
110
+ "totalSpent[gte]": z.coerce.string().optional(),
111
+ "totalSpent[lt]": z.coerce.string().optional(),
112
+ "totalSpent[lte]": z.coerce.string().optional(),
113
+ "order[firstName]": sortDirSchema.optional(),
114
+ "order[lastName]": sortDirSchema.optional(),
115
+ "order[createdAt]": sortDirSchema.optional(),
116
+ "order[updatedAt]": sortDirSchema.optional(),
117
+ page: z.coerce.number().optional()
118
+ }).merge(timestampsFilterSchema);
122
119
 
123
120
  // src/requests/customer-addresses/CreateCustomerAddress.ts
124
121
  import { AbstractApiRequest } from "@deliverart/sdk-js-core";
@@ -142,9 +139,9 @@ var CreateCustomerAddress = class extends AbstractApiRequest {
142
139
 
143
140
  // src/requests/customer-addresses/DeleteCustomerAddress.ts
144
141
  import { AbstractApiRequest as AbstractApiRequest2 } from "@deliverart/sdk-js-core";
145
- import { z as z3 } from "zod";
146
- var deleteCustomerAddressInputSchema = z3.undefined();
147
- var deleteCustomerAddressResponseSchema = z3.undefined();
142
+ import { z as z2 } from "zod";
143
+ var deleteCustomerAddressInputSchema = z2.undefined();
144
+ var deleteCustomerAddressResponseSchema = z2.undefined();
148
145
  var DeleteCustomerAddress = class extends AbstractApiRequest2 {
149
146
  method = "DELETE";
150
147
  contentType = "application/json";
@@ -155,7 +152,7 @@ var DeleteCustomerAddress = class extends AbstractApiRequest2 {
155
152
  headersSchema = void 0;
156
153
  customerAddressId;
157
154
  constructor(customerAddressId) {
158
- super();
155
+ super(void 0);
159
156
  this.customerAddressId = customerAddressId;
160
157
  }
161
158
  getPath() {
@@ -165,8 +162,8 @@ var DeleteCustomerAddress = class extends AbstractApiRequest2 {
165
162
 
166
163
  // src/requests/customer-addresses/GetCustomerAddressDetails.ts
167
164
  import { AbstractApiRequest as AbstractApiRequest3 } from "@deliverart/sdk-js-core";
168
- import { z as z4 } from "zod";
169
- var getCustomerAddressDetailsInputSchema = z4.undefined();
165
+ import { z as z3 } from "zod";
166
+ var getCustomerAddressDetailsInputSchema = z3.undefined();
170
167
  var getCustomerAddressDetailsResponseSchema = customerAddressDetailsSchema;
171
168
  var GetCustomerAddressDetails = class extends AbstractApiRequest3 {
172
169
  method = "GET";
@@ -178,7 +175,7 @@ var GetCustomerAddressDetails = class extends AbstractApiRequest3 {
178
175
  headersSchema = void 0;
179
176
  customerAddressId;
180
177
  constructor(customerAddressId) {
181
- super();
178
+ super(void 0);
182
179
  this.customerAddressId = customerAddressId;
183
180
  }
184
181
  getPath() {
@@ -191,17 +188,17 @@ import { AbstractApiRequest as AbstractApiRequest4 } from "@deliverart/sdk-js-co
191
188
  import {
192
189
  createPaginatedSchema,
193
190
  responseToPagination,
194
- sortDirSchema,
195
- timestampsFilterSchema
191
+ sortDirSchema as sortDirSchema2,
192
+ timestampsFilterSchema as timestampsFilterSchema2
196
193
  } from "@deliverart/sdk-js-global-types";
197
- import { z as z5 } from "zod";
198
- var getCustomerAddressesQuerySchema = z5.object({
199
- "order[createdAt]": sortDirSchema.optional(),
200
- "order[updatedAt]": sortDirSchema.optional(),
201
- page: z5.coerce.number().optional()
202
- }).merge(timestampsFilterSchema);
194
+ import { z as z4 } from "zod";
195
+ var getCustomerAddressesQuerySchema = z4.object({
196
+ "order[createdAt]": sortDirSchema2.optional(),
197
+ "order[updatedAt]": sortDirSchema2.optional(),
198
+ page: z4.coerce.number().optional()
199
+ }).merge(timestampsFilterSchema2);
200
+ var getCustomerAddressesInputSchema = z4.undefined();
203
201
  var getCustomerAddressesResponseSchema = createPaginatedSchema(customerAddressSchema);
204
- var getCustomerAddressesInputSchema = z5.undefined();
205
202
  var GetCustomerAddresses = class extends AbstractApiRequest4 {
206
203
  method = "GET";
207
204
  contentType = "application/json";
@@ -217,7 +214,7 @@ var GetCustomerAddresses = class extends AbstractApiRequest4 {
217
214
  return "/customers/addresses";
218
215
  }
219
216
  parseResponse(data, rawResponse) {
220
- const customerAddresses = z5.array(customerAddressSchema).parse(data);
217
+ const customerAddresses = z4.array(customerAddressSchema).parse(data);
221
218
  return this.validateOutput({
222
219
  data: customerAddresses,
223
220
  pagination: responseToPagination(rawResponse)
@@ -227,14 +224,14 @@ var GetCustomerAddresses = class extends AbstractApiRequest4 {
227
224
 
228
225
  // src/requests/customer-addresses/GetCustomerAddressesForCustomer.ts
229
226
  import { AbstractApiRequest as AbstractApiRequest5 } from "@deliverart/sdk-js-core";
230
- import { sortDirSchema as sortDirSchema2, timestampsFilterSchema as timestampsFilterSchema2 } from "@deliverart/sdk-js-global-types";
231
- import { z as z6 } from "zod";
232
- var getCustomerAddressesForCustomerQuerySchema = z6.object({
233
- "order[createdAt]": sortDirSchema2.optional(),
234
- "order[updatedAt]": sortDirSchema2.optional()
235
- }).merge(timestampsFilterSchema2);
236
- var getCustomerAddressesForCustomerResponseSchema = z6.array(customerAddressSchema);
237
- var getCustomerAddressesForCustomerInputSchema = z6.undefined();
227
+ import { sortDirSchema as sortDirSchema3, timestampsFilterSchema as timestampsFilterSchema3 } from "@deliverart/sdk-js-global-types";
228
+ import { z as z5 } from "zod";
229
+ var getCustomerAddressesForCustomerQuerySchema = z5.object({
230
+ "order[createdAt]": sortDirSchema3.optional(),
231
+ "order[updatedAt]": sortDirSchema3.optional()
232
+ }).merge(timestampsFilterSchema3);
233
+ var getCustomerAddressesForCustomerInputSchema = z5.undefined();
234
+ var getCustomerAddressesForCustomerResponseSchema = z5.array(customerAddressSchema);
238
235
  var GetCustomerAddressesForCustomer = class extends AbstractApiRequest5 {
239
236
  method = "GET";
240
237
  contentType = "application/json";
@@ -252,7 +249,7 @@ var GetCustomerAddressesForCustomer = class extends AbstractApiRequest5 {
252
249
  return `/customers/${this.customerId}/addresses`;
253
250
  }
254
251
  parseResponse(data) {
255
- return z6.array(customerAddressSchema).parse(data);
252
+ return z5.array(customerAddressSchema).parse(data);
256
253
  }
257
254
  };
258
255
 
@@ -300,9 +297,9 @@ var CreateCustomerBusinessProfile = class extends AbstractApiRequest7 {
300
297
 
301
298
  // src/requests/customer-business-profiles/DeleteCustomerBusinessProfile.ts
302
299
  import { AbstractApiRequest as AbstractApiRequest8 } from "@deliverart/sdk-js-core";
303
- import { z as z7 } from "zod";
304
- var deleteCustomerBusinessProfileInputSchema = z7.undefined();
305
- var deleteCustomerBusinessProfileResponseSchema = z7.undefined();
300
+ import { z as z6 } from "zod";
301
+ var deleteCustomerBusinessProfileInputSchema = z6.undefined();
302
+ var deleteCustomerBusinessProfileResponseSchema = z6.undefined();
306
303
  var DeleteCustomerBusinessProfile = class extends AbstractApiRequest8 {
307
304
  method = "DELETE";
308
305
  contentType = "application/json";
@@ -313,7 +310,7 @@ var DeleteCustomerBusinessProfile = class extends AbstractApiRequest8 {
313
310
  headersSchema = void 0;
314
311
  customerBusinessProfileId;
315
312
  constructor(customerBusinessProfileId) {
316
- super();
313
+ super(void 0);
317
314
  this.customerBusinessProfileId = customerBusinessProfileId;
318
315
  }
319
316
  getPath() {
@@ -323,8 +320,8 @@ var DeleteCustomerBusinessProfile = class extends AbstractApiRequest8 {
323
320
 
324
321
  // src/requests/customer-business-profiles/GetCustomerBusinessProfileDetails.ts
325
322
  import { AbstractApiRequest as AbstractApiRequest9 } from "@deliverart/sdk-js-core";
326
- import { z as z8 } from "zod";
327
- var getCustomerBusinessProfileDetailsInputSchema = z8.undefined();
323
+ import { z as z7 } from "zod";
324
+ var getCustomerBusinessProfileDetailsInputSchema = z7.undefined();
328
325
  var getCustomerBusinessProfileDetailsResponseSchema = customerBusinessProfileDetailsSchema;
329
326
  var GetCustomerBusinessProfileDetails = class extends AbstractApiRequest9 {
330
327
  method = "GET";
@@ -336,7 +333,7 @@ var GetCustomerBusinessProfileDetails = class extends AbstractApiRequest9 {
336
333
  headersSchema = void 0;
337
334
  customerBusinessProfileId;
338
335
  constructor(customerBusinessProfileId) {
339
- super();
336
+ super(void 0);
340
337
  this.customerBusinessProfileId = customerBusinessProfileId;
341
338
  }
342
339
  getPath() {
@@ -349,23 +346,23 @@ import { AbstractApiRequest as AbstractApiRequest10 } from "@deliverart/sdk-js-c
349
346
  import {
350
347
  createPaginatedSchema as createPaginatedSchema2,
351
348
  responseToPagination as responseToPagination2,
352
- sortDirSchema as sortDirSchema3,
353
- timestampsFilterSchema as timestampsFilterSchema3
349
+ sortDirSchema as sortDirSchema4,
350
+ timestampsFilterSchema as timestampsFilterSchema4
354
351
  } from "@deliverart/sdk-js-global-types";
355
- import { z as z9 } from "zod";
356
- var getCustomerBusinessProfilesQuerySchema = z9.object({
357
- "order[businessName]": sortDirSchema3.optional(),
358
- "order[createdAt]": sortDirSchema3.optional(),
359
- "order[updatedAt]": sortDirSchema3.optional(),
360
- businessName: z9.string().optional(),
361
- vat: z9.string().optional(),
362
- taxCode: z9.string().optional(),
363
- page: z9.coerce.number().optional()
364
- }).merge(timestampsFilterSchema3);
352
+ import { z as z8 } from "zod";
353
+ var getCustomerBusinessProfilesQuerySchema = z8.object({
354
+ "order[businessName]": sortDirSchema4.optional(),
355
+ "order[createdAt]": sortDirSchema4.optional(),
356
+ "order[updatedAt]": sortDirSchema4.optional(),
357
+ businessName: z8.string().optional(),
358
+ vat: z8.string().optional(),
359
+ taxCode: z8.string().optional(),
360
+ page: z8.coerce.number().optional()
361
+ }).merge(timestampsFilterSchema4);
362
+ var getCustomerBusinessProfilesInputSchema = z8.undefined();
365
363
  var getCustomerBusinessProfilesResponseSchema = createPaginatedSchema2(
366
364
  customerBusinessProfileSchema
367
365
  );
368
- var getCustomerBusinessProfilesInputSchema = z9.undefined();
369
366
  var GetCustomerBusinessProfiles = class extends AbstractApiRequest10 {
370
367
  method = "GET";
371
368
  contentType = "application/json";
@@ -381,7 +378,7 @@ var GetCustomerBusinessProfiles = class extends AbstractApiRequest10 {
381
378
  return "/customers/business_profiles";
382
379
  }
383
380
  parseResponse(data, rawResponse) {
384
- const customerBusinessProfiles = z9.array(customerBusinessProfileSchema).parse(data);
381
+ const customerBusinessProfiles = z8.array(customerBusinessProfileSchema).parse(data);
385
382
  return this.validateOutput({
386
383
  data: customerBusinessProfiles,
387
384
  pagination: responseToPagination2(rawResponse)
@@ -391,20 +388,20 @@ var GetCustomerBusinessProfiles = class extends AbstractApiRequest10 {
391
388
 
392
389
  // src/requests/customer-business-profiles/GetCustomerBusinessProfilesForCustomer.ts
393
390
  import { AbstractApiRequest as AbstractApiRequest11 } from "@deliverart/sdk-js-core";
394
- import { sortDirSchema as sortDirSchema4, timestampsFilterSchema as timestampsFilterSchema4 } from "@deliverart/sdk-js-global-types";
395
- import { z as z10 } from "zod";
396
- var getCustomerBusinessProfilesForCustomerQuerySchema = z10.object({
397
- "order[businessName]": sortDirSchema4.optional(),
398
- "order[createdAt]": sortDirSchema4.optional(),
399
- "order[updatedAt]": sortDirSchema4.optional(),
400
- businessName: z10.string().optional(),
401
- vat: z10.string().optional(),
402
- taxCode: z10.string().optional()
403
- }).merge(timestampsFilterSchema4);
404
- var getCustomerBusinessProfilesForCustomerResponseSchema = z10.array(
391
+ import { sortDirSchema as sortDirSchema5, timestampsFilterSchema as timestampsFilterSchema5 } from "@deliverart/sdk-js-global-types";
392
+ import { z as z9 } from "zod";
393
+ var getCustomerBusinessProfilesForCustomerQuerySchema = z9.object({
394
+ "order[businessName]": sortDirSchema5.optional(),
395
+ "order[createdAt]": sortDirSchema5.optional(),
396
+ "order[updatedAt]": sortDirSchema5.optional(),
397
+ businessName: z9.string().optional(),
398
+ vat: z9.string().optional(),
399
+ taxCode: z9.string().optional()
400
+ }).merge(timestampsFilterSchema5);
401
+ var getCustomerBusinessProfilesForCustomerInputSchema = z9.undefined();
402
+ var getCustomerBusinessProfilesForCustomerResponseSchema = z9.array(
405
403
  customerBusinessProfileSchema
406
404
  );
407
- var getCustomerBusinessProfilesForCustomerInputSchema = z10.undefined();
408
405
  var GetCustomerBusinessProfilesForCustomer = class extends AbstractApiRequest11 {
409
406
  method = "GET";
410
407
  contentType = "application/json";
@@ -422,7 +419,7 @@ var GetCustomerBusinessProfilesForCustomer = class extends AbstractApiRequest11
422
419
  return `/customers/${this.customerId}/business_profiles`;
423
420
  }
424
421
  parseResponse(data) {
425
- return z10.array(customerBusinessProfileSchema).parse(data);
422
+ return z9.array(customerBusinessProfileSchema).parse(data);
426
423
  }
427
424
  };
428
425
 
@@ -470,9 +467,9 @@ var CreateCustomer = class extends AbstractApiRequest13 {
470
467
 
471
468
  // src/requests/customers/DeleteCustomer.ts
472
469
  import { AbstractApiRequest as AbstractApiRequest14 } from "@deliverart/sdk-js-core";
473
- import { z as z11 } from "zod";
474
- var deleteCustomerInputSchema = z11.undefined();
475
- var deleteCustomerResponseSchema = z11.undefined();
470
+ import { z as z10 } from "zod";
471
+ var deleteCustomerInputSchema = z10.undefined();
472
+ var deleteCustomerResponseSchema = z10.undefined();
476
473
  var DeleteCustomer = class extends AbstractApiRequest14 {
477
474
  method = "DELETE";
478
475
  contentType = "application/json";
@@ -483,7 +480,7 @@ var DeleteCustomer = class extends AbstractApiRequest14 {
483
480
  headersSchema = void 0;
484
481
  customerId;
485
482
  constructor(customerId) {
486
- super();
483
+ super(void 0);
487
484
  this.customerId = customerId;
488
485
  }
489
486
  getPath() {
@@ -493,8 +490,8 @@ var DeleteCustomer = class extends AbstractApiRequest14 {
493
490
 
494
491
  // src/requests/customers/GetCustomerDetails.ts
495
492
  import { AbstractApiRequest as AbstractApiRequest15 } from "@deliverart/sdk-js-core";
496
- import { z as z12 } from "zod";
497
- var getCustomerDetailsInputSchema = z12.undefined();
493
+ import { z as z11 } from "zod";
494
+ var getCustomerDetailsInputSchema = z11.undefined();
498
495
  var getCustomerDetailsResponseSchema = customerDetailsSchema;
499
496
  var GetCustomerDetails = class extends AbstractApiRequest15 {
500
497
  method = "GET";
@@ -506,7 +503,7 @@ var GetCustomerDetails = class extends AbstractApiRequest15 {
506
503
  headersSchema = void 0;
507
504
  customerId;
508
505
  constructor(customerId) {
509
- super();
506
+ super(void 0);
510
507
  this.customerId = customerId;
511
508
  }
512
509
  getPath() {
@@ -518,36 +515,12 @@ var GetCustomerDetails = class extends AbstractApiRequest15 {
518
515
  import { AbstractApiRequest as AbstractApiRequest16 } from "@deliverart/sdk-js-core";
519
516
  import {
520
517
  createPaginatedSchema as createPaginatedSchema3,
521
- responseToPagination as responseToPagination3,
522
- sortDirSchema as sortDirSchema5,
523
- timestampsFilterSchema as timestampsFilterSchema5
518
+ responseToPagination as responseToPagination3
524
519
  } from "@deliverart/sdk-js-global-types";
525
- import { z as z13 } from "zod";
526
- var getCustomersQuerySchema = z13.object({
527
- firstName: z13.string().optional(),
528
- lastName: z13.string().optional(),
529
- email: z13.string().optional(),
530
- phoneNumber: z13.string().optional(),
531
- hasBusinessProfiles: z13.coerce.boolean().optional(),
532
- hasAddresses: z13.coerce.boolean().optional(),
533
- "ordersPlaced[between]": z13.coerce.number().optional(),
534
- "ordersPlaced[gt]": z13.coerce.number().optional(),
535
- "ordersPlaced[gte]": z13.coerce.number().optional(),
536
- "ordersPlaced[lt]": z13.coerce.number().optional(),
537
- "ordersPlaced[lte]": z13.coerce.number().optional(),
538
- "totalSpent[between]": z13.coerce.number().optional(),
539
- "totalSpent[gt]": z13.coerce.number().optional(),
540
- "totalSpent[gte]": z13.coerce.number().optional(),
541
- "totalSpent[lt]": z13.coerce.number().optional(),
542
- "totalSpent[lte]": z13.coerce.number().optional(),
543
- "order[firstName]": sortDirSchema5.optional(),
544
- "order[lastName]": sortDirSchema5.optional(),
545
- "order[createdAt]": sortDirSchema5.optional(),
546
- "order[updatedAt]": sortDirSchema5.optional(),
547
- page: z13.coerce.number().optional()
548
- }).merge(timestampsFilterSchema5);
520
+ import { z as z12 } from "zod";
521
+ var getCustomersQuerySchema = customersQuerySchema;
522
+ var getCustomersInputSchema = z12.undefined();
549
523
  var getCustomersResponseSchema = createPaginatedSchema3(customerSchema);
550
- var getCustomersInputSchema = z13.undefined();
551
524
  var GetCustomers = class extends AbstractApiRequest16 {
552
525
  method = "GET";
553
526
  contentType = "application/json";
@@ -563,7 +536,7 @@ var GetCustomers = class extends AbstractApiRequest16 {
563
536
  return "/customers";
564
537
  }
565
538
  parseResponse(data, rawResponse) {
566
- const customers = z13.array(customerSchema).parse(data);
539
+ const customers = z12.array(customerSchema).parse(data);
567
540
  return this.validateOutput({ data: customers, pagination: responseToPagination3(rawResponse) });
568
541
  }
569
542
  };
@@ -614,17 +587,18 @@ export {
614
587
  createCustomerInputSchema,
615
588
  createCustomerResponseSchema,
616
589
  customerAddressDetailsSchema,
617
- customerAddressNullablePathSchema,
618
- customerAddressPathSchema,
590
+ customerAddressIriSchema,
591
+ customerAddressNullableIriSchema,
619
592
  customerAddressSchema,
620
593
  customerBusinessProfileDetailsSchema,
621
- customerBusinessProfileNullablePathSchema,
622
- customerBusinessProfilePathSchema,
594
+ customerBusinessProfileIriSchema,
595
+ customerBusinessProfileNullableIriSchema,
623
596
  customerBusinessProfileSchema,
624
597
  customerDetailsSchema,
625
- customerNullablePathSchema,
626
- customerPathSchema,
598
+ customerIriSchema,
599
+ customerNullableIriSchema,
627
600
  customerSchema,
601
+ customersQuerySchema,
628
602
  deleteCustomerAddressInputSchema,
629
603
  deleteCustomerAddressResponseSchema,
630
604
  deleteCustomerBusinessProfileInputSchema,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deliverart/sdk-js-customer",
3
3
  "description": "Deliverart JavaScript SDK for Customer and CustomerAddress Management",
4
- "version": "0.0.4",
4
+ "version": "0.1.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -12,10 +12,10 @@
12
12
  }
13
13
  },
14
14
  "dependencies": {
15
- "@deliverart/sdk-js-core": "0.1.3",
16
- "@deliverart/sdk-js-global-types": "0.0.16",
17
- "@deliverart/sdk-js-point-of-sale": "0.0.6",
18
- "@deliverart/sdk-js-user": "0.2.5",
15
+ "@deliverart/sdk-js-core": "0.2.0",
16
+ "@deliverart/sdk-js-global-types": "0.0.18",
17
+ "@deliverart/sdk-js-point-of-sale": "0.1.1",
18
+ "@deliverart/sdk-js-user": "0.3.2",
19
19
  "axios": "1.9.0",
20
20
  "zod": "3.25.67"
21
21
  },
package/src/models.ts CHANGED
@@ -3,15 +3,17 @@ import {
3
3
  billingDataSchema,
4
4
  datetimeSchema,
5
5
  locationSchema,
6
+ sortDirSchema,
7
+ timestampsFilterSchema,
6
8
  } from '@deliverart/sdk-js-global-types'
7
- import { pointOfSaleNullablePathSchema } from '@deliverart/sdk-js-point-of-sale'
8
- import { userNullablePathSchema } from '@deliverart/sdk-js-user'
9
+ import { pointOfSaleNullableIriSchema } from '@deliverart/sdk-js-point-of-sale'
10
+ import { userNullableIriSchema } from '@deliverart/sdk-js-user'
9
11
  import { z } from 'zod'
10
12
 
11
13
  import {
12
- customerAddressPathSchema,
13
- customerBusinessProfilePathSchema,
14
- customerPathSchema,
14
+ customerAddressIriSchema,
15
+ customerBusinessProfileIriSchema,
16
+ customerIriSchema,
15
17
  } from './types'
16
18
 
17
19
  export const customerSchema = z.object({
@@ -23,17 +25,17 @@ export const customerSchema = z.object({
23
25
  hasBusinessProfiles: z.boolean(),
24
26
  hasAddresses: z.boolean(),
25
27
  ordersPlaced: z.number(),
26
- totalSpent: z.number(),
28
+ totalSpent: z.string(),
27
29
  createdAt: datetimeSchema,
28
30
  updatedAt: datetimeSchema,
29
31
  })
30
32
  export type Customer = z.infer<typeof customerSchema>
31
33
 
32
34
  export const customerDetailsSchema = customerSchema.extend({
33
- pointOfSale: pointOfSaleNullablePathSchema,
34
- owner: userNullablePathSchema,
35
- addresses: z.array(customerAddressPathSchema),
36
- businessProfiles: z.array(customerBusinessProfilePathSchema),
35
+ pointOfSale: pointOfSaleNullableIriSchema,
36
+ owner: userNullableIriSchema,
37
+ addresses: z.array(customerAddressIriSchema),
38
+ businessProfiles: z.array(customerBusinessProfileIriSchema),
37
39
  })
38
40
  export type CustomerDetails = z.infer<typeof customerDetailsSchema>
39
41
 
@@ -58,7 +60,7 @@ export const customerAddressSchema = z.object({
58
60
  export type CustomerAddress = z.infer<typeof customerAddressSchema>
59
61
 
60
62
  export const customerAddressDetailsSchema = customerAddressSchema.extend({
61
- customer: customerPathSchema,
63
+ customer: customerIriSchema,
62
64
  })
63
65
  export type CustomerAddressDetails = z.infer<typeof customerAddressDetailsSchema>
64
66
 
@@ -83,7 +85,7 @@ export const customerBusinessProfileSchema = z.object({
83
85
  export type CustomerBusinessProfile = z.infer<typeof customerBusinessProfileSchema>
84
86
 
85
87
  export const customerBusinessProfileDetailsSchema = customerBusinessProfileSchema.extend({
86
- customer: customerPathSchema,
88
+ customer: customerIriSchema,
87
89
  })
88
90
  export type CustomerBusinessProfileDetails = z.infer<typeof customerBusinessProfileDetailsSchema>
89
91
 
@@ -100,3 +102,30 @@ export const writableCustomerBusinessProfileSchema =
100
102
  writableCreateCustomerBusinessProfileSchema.omit({
101
103
  customer: true,
102
104
  })
105
+
106
+ export const customersQuerySchema = z
107
+ .object({
108
+ firstName: z.string().optional(),
109
+ lastName: z.string().optional(),
110
+ email: z.string().optional(),
111
+ phoneNumber: z.string().optional(),
112
+ hasBusinessProfiles: z.coerce.boolean().optional(),
113
+ hasAddresses: z.coerce.boolean().optional(),
114
+ 'ordersPlaced[between]': z.coerce.number().optional(),
115
+ 'ordersPlaced[gt]': z.coerce.number().optional(),
116
+ 'ordersPlaced[gte]': z.coerce.number().optional(),
117
+ 'ordersPlaced[lt]': z.coerce.number().optional(),
118
+ 'ordersPlaced[lte]': z.coerce.number().optional(),
119
+ 'totalSpent[between]': z.coerce.number().optional(),
120
+ 'totalSpent[gt]': z.coerce.string().optional(),
121
+ 'totalSpent[gte]': z.coerce.string().optional(),
122
+ 'totalSpent[lt]': z.coerce.string().optional(),
123
+ 'totalSpent[lte]': z.coerce.string().optional(),
124
+ 'order[firstName]': sortDirSchema.optional(),
125
+ 'order[lastName]': sortDirSchema.optional(),
126
+ 'order[createdAt]': sortDirSchema.optional(),
127
+ 'order[updatedAt]': sortDirSchema.optional(),
128
+ page: z.coerce.number().optional(),
129
+ })
130
+ .merge(timestampsFilterSchema)
131
+ export type CustomersQueryParams = z.infer<typeof customersQuerySchema>