@deliverart/sdk-js-core 2.48.1 → 3.0.0-dev.1

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/README.md CHANGED
@@ -423,6 +423,14 @@ formData.append('name', 'My Image');
423
423
  const image = await client.call(new UploadImage(formData));
424
424
  ```
425
425
 
426
+ ## Shared runtime types
427
+
428
+ `@deliverart/sdk-js-global-types` is a runtime dependency. Core serialization
429
+ returns the same `IriObject` class exported by that package; bundling a private
430
+ copy breaks instance checks and the nominal declaration type used by consumers.
431
+ After building both packages, run `pnpm --filter @deliverart/sdk-js-core test:artifacts`
432
+ to verify the ESM and CommonJS package boundaries.
433
+
426
434
  ## License
427
435
 
428
436
  MIT
package/dist/index.cjs CHANGED
@@ -40,350 +40,10 @@ __export(index_exports, {
40
40
  });
41
41
  module.exports = __toCommonJS(index_exports);
42
42
 
43
- // ../global-types/dist/index.js
44
- var import_zod = require("zod");
45
- var import_zod2 = require("zod");
46
- var import_zod3 = require("zod");
47
- var import_zod4 = require("zod");
48
- var import_zod5 = require("zod");
49
- var daysOfWeek = [
50
- "monday",
51
- "tuesday",
52
- "wednesday",
53
- "thursday",
54
- "friday",
55
- "saturday",
56
- "sunday"
57
- ];
58
- var sortDirections = ["asc", "desc"];
59
- var queryParamsDateCompare = [
60
- "before",
61
- "strictly_before",
62
- "after",
63
- "strictly_after"
64
- ];
65
- var queryParamsNumberCompare = ["gt", "gte", "lt", "lte"];
66
- var arrayContainsMatchOptions = ["all", "any"];
67
- var emailTemplateKeys = [
68
- "delivery_started",
69
- "delivery_taken_over",
70
- "order_created",
71
- "order_amended",
72
- "order_delivered",
73
- "order_in_preparation",
74
- "order_preparation_done",
75
- "subscription_expiring",
76
- "subscription_low_credits",
77
- "subscription_pending_renewal",
78
- "subscription_payment_pending_verification"
79
- ];
80
- var emailTemplateKeySchema = import_zod.z.enum(emailTemplateKeys);
81
- var apiTokenTypes = ["full_access", "point_of_sale"];
82
- var apiTokenTypeSchema = import_zod.z.enum(apiTokenTypes);
83
- var apiTokenModes = ["READ_ONLY", "READ_AND_WRITE"];
84
- var apiTokenModeSchema = import_zod.z.enum(apiTokenModes);
85
- var deliveryFeeTypes = ["amount", "distance", "postal_code"];
86
- var deliveryFeeTypeSchema = import_zod.z.enum(deliveryFeeTypes);
87
- var menuChannels = [
88
- "application",
89
- "ecommerce",
90
- "deliveroo",
91
- "justeat",
92
- "glovo",
93
- "tilby",
94
- "cassa_in_cloud",
95
- "elephant"
96
- ];
97
- var menuChannelSchema = import_zod.z.enum(menuChannels);
98
- var orderPartners = [
99
- "cassa_in_cloud",
100
- "deliveroo",
101
- "justeat",
102
- "glovo",
103
- "tilby",
104
- "elephant"
105
- ];
106
- var orderPartnerSchema = import_zod.z.enum(orderPartners);
107
- var menuItemAllergens = [
108
- "peanuts-and-derivatives",
109
- "crustaceans",
110
- "nuts",
111
- "gluten",
112
- "milk-and-derivatives",
113
- "lupins",
114
- "molluscs",
115
- "mustard",
116
- "fish",
117
- "celery",
118
- "sesame",
119
- "sulfur-dioxide",
120
- "soy",
121
- "eggs-and-derivatives",
122
- "mushrooms"
123
- ];
124
- var menuItemAllergenSchema = import_zod.z.enum(menuItemAllergens);
125
- var menuItemDiets = ["vegan", "vegetarian", "gluten-free", "dairy-free"];
126
- var menuItemDietSchema = import_zod.z.enum(menuItemDiets);
127
- var menuItemPriceOverrideTypes = ["ITEM", "MODIFIER"];
128
- var menuItemPriceOverrideTypeSchema = import_zod.z.enum(menuItemPriceOverrideTypes);
129
- var menuItemTypes = ["ITEM", "CHOICE", "BUNDLE"];
130
- var menuItemTypeSchema = import_zod.z.enum(menuItemTypes);
131
- var menuItemModifierTargetItemTypes = ["ITEM", "BUNDLE"];
132
- var menuItemModifierTargetItemTypeSchema = import_zod.z.enum(menuItemModifierTargetItemTypes);
133
- var menuItemModifierScopes = ["global", "category", "item"];
134
- var menuItemModifierScopeSchema = import_zod.z.enum(menuItemModifierScopes);
135
- var orderTypes = ["delivery", "collection", "kitchen"];
136
- var orderTypeSchema = import_zod.z.union([import_zod.z.enum(orderTypes), import_zod.z.literal("take_away")]).transform((value) => value === "take_away" ? "collection" : value);
137
- var orderSources = ["application", "ecommerce", "partner"];
138
- var orderSourceSchema = import_zod.z.enum(orderSources);
139
- var orderStatuses = ["pending", "confirmed", "rejected"];
140
- var orderStatusSchema = import_zod.z.enum(orderStatuses);
141
- var orderPreparationStatuses = ["to_prepare", "in_preparation", "done"];
142
- var orderPreparationStatusSchema = import_zod.z.enum(orderPreparationStatuses);
143
- var orderMenuItemActions = ["add", "remove"];
144
- var orderMenuItemActionSchema = import_zod.z.enum(orderMenuItemActions);
145
- var orderPlanningModes = ["PLANNED", "FORCED"];
146
- var orderPlanningModeSchema = import_zod.z.enum(orderPlanningModes);
147
- var bundleStatuses = ["pending", "busy", "broken", "released"];
148
- var bundleStatusSchema = import_zod.z.enum(bundleStatuses);
149
- var bundleTypes = ["REGULAR", "FORCED"];
150
- var bundleTypeSchema = import_zod.z.enum(bundleTypes);
151
- var bundleBundleBrokenReasons = ["delivery_removed"];
152
- var bundleBundleBrokenReasonSchema = import_zod.z.enum(bundleBundleBrokenReasons);
153
- var slotInvalidReasons = [
154
- "store_closed",
155
- "no_capacity",
156
- "outside_lead_time",
157
- "journey_outside_window"
158
- ];
159
- var slotInvalidReasonSchema = import_zod.z.enum(slotInvalidReasons);
160
- var rescheduleOptionStatuses = [
161
- "keep_current_bundle",
162
- "create_new_bundle",
163
- "move_to_reference_bundle",
164
- "unavailable"
165
- ];
166
- var rescheduleOptionStatusSchema = import_zod.z.enum(rescheduleOptionStatuses);
167
- var deliveryRunStates = [
168
- "not_started",
169
- "awaiting_stop_selection",
170
- "delivering_stop",
171
- "ready_to_finish",
172
- "finished"
173
- ];
174
- var deliveryRunStateSchema = import_zod.z.enum(deliveryRunStates);
175
- var paymentMethods = [
176
- "stripe",
177
- "bank_transfer",
178
- "cash",
179
- "credit_card",
180
- "ticket",
181
- "platform"
182
- ];
183
- var paymentMethodSchema = import_zod.z.enum(paymentMethods);
184
- var paymentStatuses = [
185
- "pending",
186
- "pending_verification",
187
- "paid",
188
- "canceled",
189
- "refunded",
190
- "failed"
191
- ];
192
- var paymentStatusSchema = import_zod.z.enum(paymentStatuses);
193
- var subscriptionStatuses = [
194
- "created",
195
- "active",
196
- "pending_renewal",
197
- "expired",
198
- "suspended",
199
- "cancelled"
200
- ];
201
- var subscriptionStatusSchema = import_zod.z.enum(subscriptionStatuses);
202
- var subscriptionTypes = ["infinite", "time_based", "consumption"];
203
- var subscriptionTypeSchema = import_zod.z.enum(subscriptionTypes);
204
- var renewalStatuses = [
205
- "pending",
206
- "pending_verification",
207
- "completed",
208
- "cancelled",
209
- "failed"
210
- ];
211
- var renewalStatusSchema = import_zod.z.enum(renewalStatuses);
212
- var creditTransactionTypes = [
213
- "consumption",
214
- "renewal",
215
- "gift",
216
- "bonus",
217
- "refund",
218
- "manual_adjustment"
219
- ];
220
- var creditTransactionTypeSchema = import_zod.z.enum(creditTransactionTypes);
221
- var printerProtocols = ["epson_epos", "esc_pos"];
222
- var printerProtocolSchema = import_zod.z.enum(printerProtocols);
223
- var printerDrivers = ["epson_sdk", "epos_print_xml"];
224
- var printerDriverSchema = import_zod.z.enum(printerDrivers);
225
- var printerReceiptProfiles = [
226
- "80mm_42col",
227
- "80mm_48col",
228
- "58mm_32col",
229
- "58mm_35col"
230
- ];
231
- var printerReceiptProfileSchema = import_zod.z.enum(printerReceiptProfiles);
232
- var webhookEvents = ["create", "update", "delete"];
233
- var webhookEventSchema = import_zod.z.enum(webhookEvents);
234
- var webhookLogStatuses = ["pending", "success", "failed", "timeout"];
235
- var webhookLogStatusSchema = import_zod.z.enum(webhookLogStatuses);
236
- var webhookEntities = [
237
- "App\\Entity\\Bundle",
238
- "App\\Entity\\Customer",
239
- "App\\Entity\\CustomerAddress",
240
- "App\\Entity\\CustomerBusinessProfile",
241
- "App\\Entity\\Delivery",
242
- "App\\Entity\\DeliveryPosition",
243
- "App\\Entity\\Integration",
244
- "App\\Entity\\IntegrationActivationRequest",
245
- "App\\Entity\\Order",
246
- "App\\Entity\\PointOfSale"
247
- ];
248
- var webhookEntitySchema = import_zod.z.enum(webhookEntities);
249
- var uuidPattern = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i;
250
- var isUuid = (s) => uuidPattern.test(s);
251
- var uuidLikeSchema = import_zod2.z.string().regex(uuidPattern, { message: "Invalid UUID format" });
252
- var IriObject = class {
253
- constructor(iri, pattern) {
254
- this.iri = iri;
255
- this.params = this.extractParams(iri, pattern);
256
- this.__pattern = pattern;
257
- }
258
- extractParams(iri, pattern) {
259
- const iriParts = iri.split("/").filter(Boolean);
260
- const patternParts = pattern.split("/").filter(Boolean);
261
- const result = {};
262
- for (let i = 0; i < patternParts.length; i++) {
263
- const part = patternParts[i];
264
- if (part.startsWith(":")) {
265
- const key = part.slice(1);
266
- const value = iriParts[i];
267
- if (!isUuid(value)) {
268
- throw new Error(`Invalid UUID for parameter "${key}": "${value}"`);
269
- }
270
- result[key] = value;
271
- }
272
- }
273
- return result;
274
- }
275
- toString() {
276
- return this.iri;
277
- }
278
- toJSON() {
279
- return this.iri;
280
- }
281
- };
282
- var orderSubPartners = [
283
- "getir",
284
- "yemeksepeti",
285
- "trendyol_go_meal",
286
- "fuudy",
287
- "migros_yemek"
288
- ];
289
- var orderSubPartnerSchema = import_zod3.z.enum(orderSubPartners);
290
- var addressSchema = import_zod4.z.object({
291
- line1: import_zod4.z.string().nullable().optional(),
292
- line2: import_zod4.z.string().nullable().optional(),
293
- city: import_zod4.z.string().nullable().optional(),
294
- region: import_zod4.z.string().nullable().optional(),
295
- postalCode: import_zod4.z.string().nullable().optional(),
296
- country: import_zod4.z.string().nullable().optional()
297
- });
298
- var billingDataITSchema = import_zod4.z.object({
299
- sdi: import_zod4.z.string().trim().optional().nullable(),
300
- pec: import_zod4.z.email({ message: "Invalid email format" }).optional().nullable()
301
- }).check((ctx) => {
302
- const { sdi, pec } = ctx.value;
303
- const hasSdi = sdi?.trim();
304
- const hasPec = pec?.trim();
305
- if (!hasSdi && !hasPec) {
306
- ctx.issues.push({
307
- code: "custom",
308
- message: "At least one of SDI or PEC must be provided",
309
- path: ["sdi"],
310
- input: sdi
311
- });
312
- ctx.issues.push({
313
- code: "custom",
314
- message: "At least one of SDI or PEC must be provided",
315
- path: ["pec"],
316
- input: pec
317
- });
318
- }
319
- });
320
- var booleanSchema = import_zod4.z.preprocess((val) => {
321
- if (typeof val === "boolean") {
322
- return val;
323
- }
324
- if (typeof val === "number") {
325
- return val === 1;
326
- }
327
- if (typeof val === "string") {
328
- if (val === "true" || val === "1") return true;
329
- if (val === "false" || val === "0") return false;
330
- }
331
- return val;
332
- }, import_zod4.z.boolean());
333
- var datetimeSchema = import_zod4.z.string().refine(
334
- (value) => {
335
- return !isNaN(Date.parse(value));
336
- },
337
- {
338
- message: "Invalid datetime format"
339
- }
340
- );
341
- var dayOfWeekSchema = import_zod4.z.enum(daysOfWeek);
342
- var locationSchema = import_zod4.z.object({
343
- latitude: import_zod4.z.number(),
344
- longitude: import_zod4.z.number()
345
- });
346
- var paginationSchema = import_zod4.z.object({
347
- from: import_zod4.z.coerce.number(),
348
- to: import_zod4.z.coerce.number(),
349
- itemsPerPage: import_zod4.z.coerce.number(),
350
- totalItems: import_zod4.z.coerce.number(),
351
- currentPage: import_zod4.z.coerce.number(),
352
- lastPage: import_zod4.z.coerce.number()
353
- });
354
- var sortDirSchema = import_zod4.z.enum(sortDirections);
355
- var queryParamDateCompareSchema = import_zod4.z.enum(queryParamsDateCompare);
356
- var queryParamNumberCompareSchema = import_zod4.z.enum(queryParamsNumberCompare);
357
- var timestampsFilterSchema = import_zod4.z.object({
358
- "createdAt[before]": import_zod4.z.string().optional(),
359
- "createdAt[strictly_before]": import_zod4.z.string().optional(),
360
- "createdAt[after]": import_zod4.z.string().optional(),
361
- "createdAt[strictly_after]": import_zod4.z.string().optional(),
362
- "updatedAt[before]": import_zod4.z.string().optional(),
363
- "updatedAt[strictly_before]": import_zod4.z.string().optional(),
364
- "updatedAt[after]": import_zod4.z.string().optional(),
365
- "updatedAt[strictly_after]": import_zod4.z.string().optional()
366
- });
367
- var arrayContainsMatchSchema = import_zod4.z.enum(arrayContainsMatchOptions);
368
- var emptyResponseSchema = import_zod4.z.union([import_zod4.z.void(), import_zod4.z.undefined(), import_zod4.z.null()]);
369
- var responseToPagination = (response) => {
370
- const getHeader = (name) => {
371
- const value = response.headers.get(name);
372
- return value !== null ? parseInt(value, 10) : NaN;
373
- };
374
- return {
375
- from: getHeader("x-pagination-from"),
376
- to: getHeader("x-pagination-to"),
377
- itemsPerPage: getHeader("x-pagination-items-per-page"),
378
- totalItems: getHeader("x-pagination-total-items"),
379
- currentPage: getHeader("x-pagination-current-page"),
380
- lastPage: getHeader("x-pagination-last-page")
381
- };
382
- };
383
-
384
43
  // src/ApiClient.ts
44
+ var import_sdk_js_global_types = require("@deliverart/sdk-js-global-types");
385
45
  var import_qs = __toESM(require("qs"), 1);
386
- var import_zod6 = require("zod");
46
+ var import_zod = require("zod");
387
47
 
388
48
  // src/errors.ts
389
49
  var InputValidationError = class extends Error {
@@ -437,7 +97,7 @@ var AbstractApiRequest = class {
437
97
  * Return `undefined` if pagination cannot be resolved.
438
98
  */
439
99
  getPagination(rawResponse) {
440
- return responseToPagination(rawResponse);
100
+ return (0, import_sdk_js_global_types.responseToPagination)(rawResponse);
441
101
  }
442
102
  validateInput() {
443
103
  const result = this.inputSchema.safeParse(this.input);
@@ -458,7 +118,7 @@ var AbstractApiRequest = class {
458
118
  }
459
119
  validateOutput(data, useArraySchema) {
460
120
  if (useArraySchema && this.listItemSchema) {
461
- const arraySchema = import_zod6.z.array(this.listItemSchema);
121
+ const arraySchema = import_zod.z.array(this.listItemSchema);
462
122
  const result2 = arraySchema.safeParse(data);
463
123
  if (!result2.success) throw new OutputValidationError(result2.error.issues);
464
124
  return result2.data;
@@ -473,7 +133,7 @@ var AbstractApiRequest = class {
473
133
  if (paginationOption === false) {
474
134
  return this.validateOutput(data, true);
475
135
  }
476
- const arraySchema = import_zod6.z.array(this.listItemSchema);
136
+ const arraySchema = import_zod.z.array(this.listItemSchema);
477
137
  const arrayParse = arraySchema.safeParse(data);
478
138
  if (arrayParse.success) {
479
139
  if (paginationToggle) {
@@ -608,20 +268,21 @@ function createApiClient(config) {
608
268
  }
609
269
 
610
270
  // src/serialization.ts
611
- var import_zod7 = require("zod");
612
- var serializedIriObjectSchema = import_zod7.z.object({
613
- iri: import_zod7.z.string().min(1),
614
- params: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.string()),
615
- __pattern: import_zod7.z.string().min(1)
271
+ var import_sdk_js_global_types2 = require("@deliverart/sdk-js-global-types");
272
+ var import_zod2 = require("zod");
273
+ var serializedIriObjectSchema = import_zod2.z.object({
274
+ iri: import_zod2.z.string().min(1),
275
+ params: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.string()),
276
+ __pattern: import_zod2.z.string().min(1)
616
277
  }).strict();
617
278
  function isSerializedIriObject(input2) {
618
279
  return typeof input2 === "object" && input2 !== null && "iri" in input2 && "params" in input2 && "__pattern" in input2 && typeof input2.iri === "string" && typeof input2.__pattern === "string" && typeof input2.params === "object";
619
280
  }
620
281
  function deserializeIri(s) {
621
- return new IriObject(s.iri, s.__pattern);
282
+ return new import_sdk_js_global_types2.IriObject(s.iri, s.__pattern);
622
283
  }
623
284
  function serializeForClient(input2) {
624
- if (input2 instanceof IriObject) {
285
+ if (input2 instanceof import_sdk_js_global_types2.IriObject) {
625
286
  return {
626
287
  iri: input2.iri,
627
288
  params: input2.params,
package/dist/index.js CHANGED
@@ -1,347 +1,7 @@
1
- // ../global-types/dist/index.js
2
- import { z } from "zod";
3
- import { z as z2 } from "zod";
4
- import { z as z3 } from "zod";
5
- import { z as z4 } from "zod";
6
- import { z as z5 } from "zod";
7
- var daysOfWeek = [
8
- "monday",
9
- "tuesday",
10
- "wednesday",
11
- "thursday",
12
- "friday",
13
- "saturday",
14
- "sunday"
15
- ];
16
- var sortDirections = ["asc", "desc"];
17
- var queryParamsDateCompare = [
18
- "before",
19
- "strictly_before",
20
- "after",
21
- "strictly_after"
22
- ];
23
- var queryParamsNumberCompare = ["gt", "gte", "lt", "lte"];
24
- var arrayContainsMatchOptions = ["all", "any"];
25
- var emailTemplateKeys = [
26
- "delivery_started",
27
- "delivery_taken_over",
28
- "order_created",
29
- "order_amended",
30
- "order_delivered",
31
- "order_in_preparation",
32
- "order_preparation_done",
33
- "subscription_expiring",
34
- "subscription_low_credits",
35
- "subscription_pending_renewal",
36
- "subscription_payment_pending_verification"
37
- ];
38
- var emailTemplateKeySchema = z.enum(emailTemplateKeys);
39
- var apiTokenTypes = ["full_access", "point_of_sale"];
40
- var apiTokenTypeSchema = z.enum(apiTokenTypes);
41
- var apiTokenModes = ["READ_ONLY", "READ_AND_WRITE"];
42
- var apiTokenModeSchema = z.enum(apiTokenModes);
43
- var deliveryFeeTypes = ["amount", "distance", "postal_code"];
44
- var deliveryFeeTypeSchema = z.enum(deliveryFeeTypes);
45
- var menuChannels = [
46
- "application",
47
- "ecommerce",
48
- "deliveroo",
49
- "justeat",
50
- "glovo",
51
- "tilby",
52
- "cassa_in_cloud",
53
- "elephant"
54
- ];
55
- var menuChannelSchema = z.enum(menuChannels);
56
- var orderPartners = [
57
- "cassa_in_cloud",
58
- "deliveroo",
59
- "justeat",
60
- "glovo",
61
- "tilby",
62
- "elephant"
63
- ];
64
- var orderPartnerSchema = z.enum(orderPartners);
65
- var menuItemAllergens = [
66
- "peanuts-and-derivatives",
67
- "crustaceans",
68
- "nuts",
69
- "gluten",
70
- "milk-and-derivatives",
71
- "lupins",
72
- "molluscs",
73
- "mustard",
74
- "fish",
75
- "celery",
76
- "sesame",
77
- "sulfur-dioxide",
78
- "soy",
79
- "eggs-and-derivatives",
80
- "mushrooms"
81
- ];
82
- var menuItemAllergenSchema = z.enum(menuItemAllergens);
83
- var menuItemDiets = ["vegan", "vegetarian", "gluten-free", "dairy-free"];
84
- var menuItemDietSchema = z.enum(menuItemDiets);
85
- var menuItemPriceOverrideTypes = ["ITEM", "MODIFIER"];
86
- var menuItemPriceOverrideTypeSchema = z.enum(menuItemPriceOverrideTypes);
87
- var menuItemTypes = ["ITEM", "CHOICE", "BUNDLE"];
88
- var menuItemTypeSchema = z.enum(menuItemTypes);
89
- var menuItemModifierTargetItemTypes = ["ITEM", "BUNDLE"];
90
- var menuItemModifierTargetItemTypeSchema = z.enum(menuItemModifierTargetItemTypes);
91
- var menuItemModifierScopes = ["global", "category", "item"];
92
- var menuItemModifierScopeSchema = z.enum(menuItemModifierScopes);
93
- var orderTypes = ["delivery", "collection", "kitchen"];
94
- var orderTypeSchema = z.union([z.enum(orderTypes), z.literal("take_away")]).transform((value) => value === "take_away" ? "collection" : value);
95
- var orderSources = ["application", "ecommerce", "partner"];
96
- var orderSourceSchema = z.enum(orderSources);
97
- var orderStatuses = ["pending", "confirmed", "rejected"];
98
- var orderStatusSchema = z.enum(orderStatuses);
99
- var orderPreparationStatuses = ["to_prepare", "in_preparation", "done"];
100
- var orderPreparationStatusSchema = z.enum(orderPreparationStatuses);
101
- var orderMenuItemActions = ["add", "remove"];
102
- var orderMenuItemActionSchema = z.enum(orderMenuItemActions);
103
- var orderPlanningModes = ["PLANNED", "FORCED"];
104
- var orderPlanningModeSchema = z.enum(orderPlanningModes);
105
- var bundleStatuses = ["pending", "busy", "broken", "released"];
106
- var bundleStatusSchema = z.enum(bundleStatuses);
107
- var bundleTypes = ["REGULAR", "FORCED"];
108
- var bundleTypeSchema = z.enum(bundleTypes);
109
- var bundleBundleBrokenReasons = ["delivery_removed"];
110
- var bundleBundleBrokenReasonSchema = z.enum(bundleBundleBrokenReasons);
111
- var slotInvalidReasons = [
112
- "store_closed",
113
- "no_capacity",
114
- "outside_lead_time",
115
- "journey_outside_window"
116
- ];
117
- var slotInvalidReasonSchema = z.enum(slotInvalidReasons);
118
- var rescheduleOptionStatuses = [
119
- "keep_current_bundle",
120
- "create_new_bundle",
121
- "move_to_reference_bundle",
122
- "unavailable"
123
- ];
124
- var rescheduleOptionStatusSchema = z.enum(rescheduleOptionStatuses);
125
- var deliveryRunStates = [
126
- "not_started",
127
- "awaiting_stop_selection",
128
- "delivering_stop",
129
- "ready_to_finish",
130
- "finished"
131
- ];
132
- var deliveryRunStateSchema = z.enum(deliveryRunStates);
133
- var paymentMethods = [
134
- "stripe",
135
- "bank_transfer",
136
- "cash",
137
- "credit_card",
138
- "ticket",
139
- "platform"
140
- ];
141
- var paymentMethodSchema = z.enum(paymentMethods);
142
- var paymentStatuses = [
143
- "pending",
144
- "pending_verification",
145
- "paid",
146
- "canceled",
147
- "refunded",
148
- "failed"
149
- ];
150
- var paymentStatusSchema = z.enum(paymentStatuses);
151
- var subscriptionStatuses = [
152
- "created",
153
- "active",
154
- "pending_renewal",
155
- "expired",
156
- "suspended",
157
- "cancelled"
158
- ];
159
- var subscriptionStatusSchema = z.enum(subscriptionStatuses);
160
- var subscriptionTypes = ["infinite", "time_based", "consumption"];
161
- var subscriptionTypeSchema = z.enum(subscriptionTypes);
162
- var renewalStatuses = [
163
- "pending",
164
- "pending_verification",
165
- "completed",
166
- "cancelled",
167
- "failed"
168
- ];
169
- var renewalStatusSchema = z.enum(renewalStatuses);
170
- var creditTransactionTypes = [
171
- "consumption",
172
- "renewal",
173
- "gift",
174
- "bonus",
175
- "refund",
176
- "manual_adjustment"
177
- ];
178
- var creditTransactionTypeSchema = z.enum(creditTransactionTypes);
179
- var printerProtocols = ["epson_epos", "esc_pos"];
180
- var printerProtocolSchema = z.enum(printerProtocols);
181
- var printerDrivers = ["epson_sdk", "epos_print_xml"];
182
- var printerDriverSchema = z.enum(printerDrivers);
183
- var printerReceiptProfiles = [
184
- "80mm_42col",
185
- "80mm_48col",
186
- "58mm_32col",
187
- "58mm_35col"
188
- ];
189
- var printerReceiptProfileSchema = z.enum(printerReceiptProfiles);
190
- var webhookEvents = ["create", "update", "delete"];
191
- var webhookEventSchema = z.enum(webhookEvents);
192
- var webhookLogStatuses = ["pending", "success", "failed", "timeout"];
193
- var webhookLogStatusSchema = z.enum(webhookLogStatuses);
194
- var webhookEntities = [
195
- "App\\Entity\\Bundle",
196
- "App\\Entity\\Customer",
197
- "App\\Entity\\CustomerAddress",
198
- "App\\Entity\\CustomerBusinessProfile",
199
- "App\\Entity\\Delivery",
200
- "App\\Entity\\DeliveryPosition",
201
- "App\\Entity\\Integration",
202
- "App\\Entity\\IntegrationActivationRequest",
203
- "App\\Entity\\Order",
204
- "App\\Entity\\PointOfSale"
205
- ];
206
- var webhookEntitySchema = z.enum(webhookEntities);
207
- var uuidPattern = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i;
208
- var isUuid = (s) => uuidPattern.test(s);
209
- var uuidLikeSchema = z2.string().regex(uuidPattern, { message: "Invalid UUID format" });
210
- var IriObject = class {
211
- constructor(iri, pattern) {
212
- this.iri = iri;
213
- this.params = this.extractParams(iri, pattern);
214
- this.__pattern = pattern;
215
- }
216
- extractParams(iri, pattern) {
217
- const iriParts = iri.split("/").filter(Boolean);
218
- const patternParts = pattern.split("/").filter(Boolean);
219
- const result = {};
220
- for (let i = 0; i < patternParts.length; i++) {
221
- const part = patternParts[i];
222
- if (part.startsWith(":")) {
223
- const key = part.slice(1);
224
- const value = iriParts[i];
225
- if (!isUuid(value)) {
226
- throw new Error(`Invalid UUID for parameter "${key}": "${value}"`);
227
- }
228
- result[key] = value;
229
- }
230
- }
231
- return result;
232
- }
233
- toString() {
234
- return this.iri;
235
- }
236
- toJSON() {
237
- return this.iri;
238
- }
239
- };
240
- var orderSubPartners = [
241
- "getir",
242
- "yemeksepeti",
243
- "trendyol_go_meal",
244
- "fuudy",
245
- "migros_yemek"
246
- ];
247
- var orderSubPartnerSchema = z3.enum(orderSubPartners);
248
- var addressSchema = z4.object({
249
- line1: z4.string().nullable().optional(),
250
- line2: z4.string().nullable().optional(),
251
- city: z4.string().nullable().optional(),
252
- region: z4.string().nullable().optional(),
253
- postalCode: z4.string().nullable().optional(),
254
- country: z4.string().nullable().optional()
255
- });
256
- var billingDataITSchema = z4.object({
257
- sdi: z4.string().trim().optional().nullable(),
258
- pec: z4.email({ message: "Invalid email format" }).optional().nullable()
259
- }).check((ctx) => {
260
- const { sdi, pec } = ctx.value;
261
- const hasSdi = sdi?.trim();
262
- const hasPec = pec?.trim();
263
- if (!hasSdi && !hasPec) {
264
- ctx.issues.push({
265
- code: "custom",
266
- message: "At least one of SDI or PEC must be provided",
267
- path: ["sdi"],
268
- input: sdi
269
- });
270
- ctx.issues.push({
271
- code: "custom",
272
- message: "At least one of SDI or PEC must be provided",
273
- path: ["pec"],
274
- input: pec
275
- });
276
- }
277
- });
278
- var booleanSchema = z4.preprocess((val) => {
279
- if (typeof val === "boolean") {
280
- return val;
281
- }
282
- if (typeof val === "number") {
283
- return val === 1;
284
- }
285
- if (typeof val === "string") {
286
- if (val === "true" || val === "1") return true;
287
- if (val === "false" || val === "0") return false;
288
- }
289
- return val;
290
- }, z4.boolean());
291
- var datetimeSchema = z4.string().refine(
292
- (value) => {
293
- return !isNaN(Date.parse(value));
294
- },
295
- {
296
- message: "Invalid datetime format"
297
- }
298
- );
299
- var dayOfWeekSchema = z4.enum(daysOfWeek);
300
- var locationSchema = z4.object({
301
- latitude: z4.number(),
302
- longitude: z4.number()
303
- });
304
- var paginationSchema = z4.object({
305
- from: z4.coerce.number(),
306
- to: z4.coerce.number(),
307
- itemsPerPage: z4.coerce.number(),
308
- totalItems: z4.coerce.number(),
309
- currentPage: z4.coerce.number(),
310
- lastPage: z4.coerce.number()
311
- });
312
- var sortDirSchema = z4.enum(sortDirections);
313
- var queryParamDateCompareSchema = z4.enum(queryParamsDateCompare);
314
- var queryParamNumberCompareSchema = z4.enum(queryParamsNumberCompare);
315
- var timestampsFilterSchema = z4.object({
316
- "createdAt[before]": z4.string().optional(),
317
- "createdAt[strictly_before]": z4.string().optional(),
318
- "createdAt[after]": z4.string().optional(),
319
- "createdAt[strictly_after]": z4.string().optional(),
320
- "updatedAt[before]": z4.string().optional(),
321
- "updatedAt[strictly_before]": z4.string().optional(),
322
- "updatedAt[after]": z4.string().optional(),
323
- "updatedAt[strictly_after]": z4.string().optional()
324
- });
325
- var arrayContainsMatchSchema = z4.enum(arrayContainsMatchOptions);
326
- var emptyResponseSchema = z4.union([z4.void(), z4.undefined(), z4.null()]);
327
- var responseToPagination = (response) => {
328
- const getHeader = (name) => {
329
- const value = response.headers.get(name);
330
- return value !== null ? parseInt(value, 10) : NaN;
331
- };
332
- return {
333
- from: getHeader("x-pagination-from"),
334
- to: getHeader("x-pagination-to"),
335
- itemsPerPage: getHeader("x-pagination-items-per-page"),
336
- totalItems: getHeader("x-pagination-total-items"),
337
- currentPage: getHeader("x-pagination-current-page"),
338
- lastPage: getHeader("x-pagination-last-page")
339
- };
340
- };
341
-
342
1
  // src/ApiClient.ts
2
+ import { responseToPagination } from "@deliverart/sdk-js-global-types";
343
3
  import qs from "qs";
344
- import { z as z6 } from "zod";
4
+ import { z } from "zod";
345
5
 
346
6
  // src/errors.ts
347
7
  var InputValidationError = class extends Error {
@@ -416,7 +76,7 @@ var AbstractApiRequest = class {
416
76
  }
417
77
  validateOutput(data, useArraySchema) {
418
78
  if (useArraySchema && this.listItemSchema) {
419
- const arraySchema = z6.array(this.listItemSchema);
79
+ const arraySchema = z.array(this.listItemSchema);
420
80
  const result2 = arraySchema.safeParse(data);
421
81
  if (!result2.success) throw new OutputValidationError(result2.error.issues);
422
82
  return result2.data;
@@ -431,7 +91,7 @@ var AbstractApiRequest = class {
431
91
  if (paginationOption === false) {
432
92
  return this.validateOutput(data, true);
433
93
  }
434
- const arraySchema = z6.array(this.listItemSchema);
94
+ const arraySchema = z.array(this.listItemSchema);
435
95
  const arrayParse = arraySchema.safeParse(data);
436
96
  if (arrayParse.success) {
437
97
  if (paginationToggle) {
@@ -566,11 +226,12 @@ function createApiClient(config) {
566
226
  }
567
227
 
568
228
  // src/serialization.ts
569
- import { z as z7 } from "zod";
570
- var serializedIriObjectSchema = z7.object({
571
- iri: z7.string().min(1),
572
- params: z7.record(z7.string(), z7.string()),
573
- __pattern: z7.string().min(1)
229
+ import { IriObject } from "@deliverart/sdk-js-global-types";
230
+ import { z as z2 } from "zod";
231
+ var serializedIriObjectSchema = z2.object({
232
+ iri: z2.string().min(1),
233
+ params: z2.record(z2.string(), z2.string()),
234
+ __pattern: z2.string().min(1)
574
235
  }).strict();
575
236
  function isSerializedIriObject(input2) {
576
237
  return typeof input2 === "object" && input2 !== null && "iri" in input2 && "params" in input2 && "__pattern" in input2 && typeof input2.iri === "string" && typeof input2.__pattern === "string" && typeof input2.params === "object";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deliverart/sdk-js-core",
3
3
  "description": "Core SDK for DeliverArt, providing essential functionalities and utilities.",
4
- "version": "2.48.1",
4
+ "version": "3.0.0-dev.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -21,17 +21,18 @@
21
21
  "access": "public"
22
22
  },
23
23
  "dependencies": {
24
- "qs": "6.16.0",
25
- "zod": "4.6.6"
24
+ "qs": "6.16.1",
25
+ "zod": "4.6.6",
26
+ "@deliverart/sdk-js-global-types": "3.0.0-dev.1"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@types/qs": "^6.15.1",
29
- "vitest": "4.1.12",
30
- "@deliverart/sdk-js-global-types": "2.48.1"
30
+ "vitest": "4.1.12"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsup src/index.ts --dts --format esm,cjs",
34
34
  "dev": "tsup src/index.ts --dts --watch",
35
- "test": "vitest run"
35
+ "test": "vitest run",
36
+ "test:artifacts": "node --test tests/serialization-artifact.mjs"
36
37
  }
37
38
  }