@pelygo/janus 0.4.0 → 0.6.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/README.md CHANGED
@@ -148,42 +148,33 @@ await janus.auth.logout();
148
148
  | `created_ts` | `string?` | ISO timestamp |
149
149
  | `updated_ts` | `string?` | ISO timestamp |
150
150
 
151
- ### LegacyOrder
152
-
153
- | Field | Type | Description |
154
- |-------|------|-------------|
155
- | `id` | `number` | Primary key |
156
- | `customerId` | `number?` | FK to customer |
157
- | `reference` | `string?` | Order reference string |
158
- | `source` | `number?` | Source ID |
159
- | `orderDate` | `string?` | ISO date the order was placed |
160
- | `dispatchCompletedDate` | `string?` | ISO date all dispatches completed |
161
- | `orderStatus` | `number?` | Numeric status code |
162
- | `postServiceId` | `number?` | FK to shipping service |
163
- | `courierId` | `number?` | FK to courier |
164
- | `actualWeight` | `number?` | Measured weight |
165
- | `notes` | `string?` | Internal notes |
166
- | `hold` | `unknown?` | Whether order is on hold |
167
- | `releaseDate` | `string?` | ISO date when hold was released |
168
- | `draft` | `unknown?` | Whether order is a draft |
169
- | `giftMessage` | `string?` | Gift message text |
170
- | `deliveryInstructions` | `string?` | Delivery instructions |
171
- | `orderIssue` | `number?` | Issue flag |
172
- | `deliveryTerms` | `string?` | Incoterms code (e.g. `"DAP"`) |
173
- | `transaction_type` | `'b2c' \| 'b2b' \| 'internal_transfer' \| 'damage' \| 'expiry'` | **Required.** Transaction classification |
174
- | `external_order_id` | `string?` | External system order ID |
175
- | `channel_order_id` | `string?` | Sales channel order ID |
176
- | `channel` | `string?` | Sales channel name |
177
- | `created` | `string?` | ISO created timestamp |
178
- | `modified` | `string?` | ISO modified timestamp |
179
- | `status` | `number?` | Record status (0 = inactive, 1 = active) |
180
- | `orderItems` | `LegacyOrderItem[]` | Line items |
181
- | `orderMeta` | `LegacyOrderMeta[]` | Metadata key-value pairs |
182
- | `shopperDeliveryAddress` | `LegacyShopperAddress` | Delivery address |
183
- | `shopperBillingAddress` | `LegacyShopperAddress` | Billing address |
184
- | `dispatches` | `LegacyDispatch[]` | All dispatches for this order |
185
- | `dispatch` | `LegacyDispatch` | Primary dispatch |
186
- | `orderSource` | `Source` | Source reference data |
151
+ ### Order (formatted response from `getAll` / `getByRef`)
152
+
153
+ The orders API returns **formatted** objects — field names differ from the raw database entity. Use these exact names:
154
+
155
+ | Field | Type | Format | Description |
156
+ |-------|------|--------|-------------|
157
+ | `orderId` | `number` | — | Order ID |
158
+ | `orderRef` | `string` | | Order reference number |
159
+ | `dispatchId` | `number` | | Dispatch ID |
160
+ | `dispatchRef` | `string` | | Dispatch reference |
161
+ | `orderCreated` | `string` | `DD/MM/YYYY HH:mm` | Date order was received. **Not ISO** |
162
+ | `releaseDate` | `string` | `DD/MM/YYYY HH:mm` | Scheduled release date |
163
+ | `dispatchCompletedDate` | `string` | `DD/MM/YYYY HH:mm` | Date dispatch completed |
164
+ | `channel` | `string` | | Sales channel name |
165
+ | `itemCount` | `number` | | Number of line items |
166
+ | `products` | `array` | | Line items (when included) |
167
+ | `address` | `object` | | Shipping address: `{ fullName, company, addrLine1, addrLine2, city, postcode, country, destination, email, phoneNumber }` |
168
+
169
+ **Date fields use `DD/MM/YYYY HH:mm` format** (e.g. `"25/03/2026 14:30"`), NOT ISO 8601. To parse:
170
+ ```js
171
+ function parseOrderDate(dateStr) {
172
+ if (!dateStr) return null;
173
+ const [datePart, timePart] = dateStr.split(' ');
174
+ const [day, month, year] = datePart.split('/');
175
+ return new Date(`${year}-${month}-${day}T${timePart || '00:00'}`);
176
+ }
177
+ ```
187
178
 
188
179
  ### LegacyDispatch
189
180
 
@@ -636,7 +627,8 @@ Common codes: 400 (bad request/validation), 401 (unauthorized), 404 (not found).
636
627
 
637
628
  ### Date formats
638
629
  - **Query params:** ISO 8601 format (`'2025-01-01'` or `'2025-01-01 12:00:00'`)
639
- - **Response fields:** ISO 8601 timestamps (e.g. `created_ts`, `orderDate`, `created`)
630
+ - **v2 response fields** (returns, stocks, etc.): ISO 8601 timestamps (`created_ts`, `updated_ts`)
631
+ - **Orders response fields**: `DD/MM/YYYY HH:mm` format (e.g. `"25/03/2026 14:30"`) — **NOT ISO**. Fields: `orderCreated`, `releaseDate`, `dispatchCompletedDate`. Must be parsed before use.
640
632
  - **CSV exports:** formatted as `DD-MM-YYYY HH:mm`
641
633
 
642
634
  ### Pagination defaults
package/USAGE.md CHANGED
@@ -202,23 +202,33 @@ const summary = await janus.reports.returnsSummary({
202
202
  | `created_ts` | `string` | ISO timestamp |
203
203
  | `updated_ts` | `string` | ISO timestamp |
204
204
 
205
- ## Order Entity Fields
206
-
207
- | Field | Type | Description |
208
- |-------|------|-------------|
209
- | `id` | `number` | Order ID |
210
- | `reference` | `string` | Order reference number |
211
- | `channel` | `string` | Sales channel ("shopify", "amazon", etc.) |
212
- | `transaction_type` | `string` | "b2c", "b2b", "internal_transfer", "damage", "expiry" |
213
- | `orderDate` | `string` | ISO date when order was placed |
214
- | `orderStatus` | `number` | Numeric status code |
215
- | `notes` | `string` | Order notes |
216
- | `hold` | `number` | 0 = not on hold, 1 = on hold |
217
- | `draft` | `number` | 0 = confirmed, 1 = draft |
218
- | `created` | `string` | ISO date when created |
219
- | `modified` | `string` | ISO date when last modified |
220
- | `orderItems` | `array` | Order line items |
221
- | `dispatches` | `array` | Dispatch records |
205
+ ## Order Fields (formatted response from getAll / getByRef)
206
+
207
+ The orders API returns **formatted** objects — use these exact field names:
208
+
209
+ | Field | Type | Format | Description |
210
+ |-------|------|--------|-------------|
211
+ | `orderId` | `number` | | Order ID |
212
+ | `orderRef` | `string` | | Order reference number |
213
+ | `dispatchId` | `number` | | Dispatch ID |
214
+ | `dispatchRef` | `string` | | Dispatch reference |
215
+ | `orderCreated` | `string` | `DD/MM/YYYY HH:mm` | Date received (**not ISO**) |
216
+ | `releaseDate` | `string` | `DD/MM/YYYY HH:mm` | Release date |
217
+ | `dispatchCompletedDate` | `string` | `DD/MM/YYYY HH:mm` | Dispatch completed |
218
+ | `channel` | `string` | | Sales channel |
219
+ | `itemCount` | `number` | | Number of line items |
220
+ | `products` | `array` | | Line items (when included) |
221
+ | `address` | `object` | | `{ fullName, company, addrLine1, city, postcode, country, email }` |
222
+
223
+ **Date parsing:** Dates are `DD/MM/YYYY HH:mm`, not ISO. Parse with:
224
+ ```js
225
+ function parseOrderDate(dateStr) {
226
+ if (!dateStr) return null;
227
+ const [datePart, timePart] = dateStr.split(' ');
228
+ const [day, month, year] = datePart.split('/');
229
+ return new Date(`${year}-${month}-${day}T${timePart || '00:00'}`);
230
+ }
231
+ ```
222
232
 
223
233
  ## Product Entity Fields (from /products endpoint)
224
234
 
@@ -307,7 +317,8 @@ Common codes: 400 (bad request/validation), 401 (unauthorized), 404 (not found).
307
317
 
308
318
  ### Date formats
309
319
  - **Query params:** ISO 8601 (`'2025-01-01'` or `'2025-01-01 12:00:00'`)
310
- - **Response fields:** ISO 8601 timestamps (e.g. `created_ts`, `orderDate`, `created`)
320
+ - **v2 response fields** (returns, stocks, etc.): ISO 8601 timestamps (`created_ts`, `updated_ts`)
321
+ - **Orders response fields**: `DD/MM/YYYY HH:mm` format — **NOT ISO**. Fields: `orderCreated`, `releaseDate`, `dispatchCompletedDate`. Parse with date splitter (see Order Fields section below).
311
322
  - **CSV exports:** formatted as `DD-MM-YYYY HH:mm`
312
323
 
313
324
  ### Pagination defaults
package/dist/index.d.ts CHANGED
@@ -1826,8 +1826,10 @@ export declare interface JanusApi {
1826
1826
  helpers: HelpersResource;
1827
1827
  /** Couriers resource - manage couriers and services */
1828
1828
  couriers: CouriersResource;
1829
- /** Orders resource - query orders and stats */
1829
+ /** Orders resource - general-purpose order queries using legacy/orders endpoints (ISO dates, standard fields) */
1830
1830
  orders: OrdersResource;
1831
+ /** Microtrack orders - dispatch tracking service data (DD/MM/YYYY dates, Microtrack-specific fields). Use janus.orders for general use. */
1832
+ ordersMt: OrdersMtResource;
1831
1833
  /** Integrations resource - manage integrations */
1832
1834
  integrations: IntegrationsResource;
1833
1835
  /** Users resource - manage users */
@@ -2442,6 +2444,58 @@ export declare interface OrderReturnsFilters extends BaseFilters {
2442
2444
  group_by?: string;
2443
2445
  }
2444
2446
 
2447
+ /**
2448
+ * Microtrack Orders resource interface.
2449
+ *
2450
+ * These endpoints hit the `/orders` v2 controller which returns data
2451
+ * formatted specifically for the Microtrack dispatch tracking service.
2452
+ *
2453
+ * **Response format differences from `janus.orders`:**
2454
+ * - Field names are Microtrack-specific: `orderRef`, `dispatchRef`, `orderCreated`, `itemCount`
2455
+ * - Date fields use `DD/MM/YYYY HH:mm` format (NOT ISO 8601)
2456
+ * - Responses include formatted address and product objects
2457
+ *
2458
+ * For general-purpose order access with standard field names and ISO dates,
2459
+ * use `janus.orders` instead.
2460
+ */
2461
+ export declare interface OrdersMtResource {
2462
+ /**
2463
+ * Get Microtrack orders with optional query filters.
2464
+ *
2465
+ * Response returns Microtrack-formatted objects:
2466
+ * - `orderId`, `orderRef`, `dispatchId`, `dispatchRef`, `channel`, `itemCount`
2467
+ * - `orderCreated`, `releaseDate`, `dispatchCompletedDate` (DD/MM/YYYY HH:mm, NOT ISO)
2468
+ * - `products` (array), `address` (object) when included
2469
+ *
2470
+ * @example
2471
+ * const orders = await janus.ordersMt.getAll({ clientId, pageSize: 25 });
2472
+ * // Each order: { orderId, orderRef, dispatchRef, orderCreated, channel, itemCount }
2473
+ * // IMPORTANT: date fields are "DD/MM/YYYY HH:mm" format, not ISO
2474
+ */
2475
+ getAll(filters?: OrdersQueryFilters): Promise<unknown[]>;
2476
+ /**
2477
+ * Get aggregated Microtrack order statistics.
2478
+ *
2479
+ * @example
2480
+ * const stats = await janus.ordersMt.getStats({ clientId, dashboard: true });
2481
+ * // Returns a flat object with numeric counts — keys vary by data.
2482
+ * // Use Object.entries(stats) to iterate. Do NOT hardcode field names.
2483
+ */
2484
+ getStats(filters?: OrdersStatsFilters): Promise<OrdersStatsResponse>;
2485
+ /** Get Microtrack orders that have associated returns */
2486
+ getReturns(filters?: OrderReturnsFilters): Promise<unknown[]>;
2487
+ /** Get a Microtrack order by its dispatch reference string */
2488
+ getByRef(dispatchRef: string, clientId?: number): Promise<unknown>;
2489
+ /** Get available filter options for the Microtrack returns order list */
2490
+ getReturnFilterOptions(clientId: number): Promise<FilterOptionsResponse>;
2491
+ /** Get available filter type options for the Microtrack orders list */
2492
+ getFilterTypes(clientId?: number): Promise<FilterOptionsResponse>;
2493
+ /** Create a new order via the Microtrack endpoint */
2494
+ create(data: CreateOrderRequest): Promise<unknown>;
2495
+ /** Update an existing order via the Microtrack endpoint */
2496
+ updateOrder(id: number, data: Partial<CreateOrderRequest>): Promise<unknown>;
2497
+ }
2498
+
2445
2499
  /**
2446
2500
  * Filters for querying orders
2447
2501
  */
@@ -2481,46 +2535,69 @@ export declare interface OrdersQueryFilters extends BaseFilters {
2481
2535
  }
2482
2536
 
2483
2537
  /**
2484
- * Orders resource interface
2538
+ * Orders resource interface.
2539
+ *
2540
+ * Queries the `/legacy/orders` endpoints which return `LegacyOrder` entity objects.
2541
+ *
2542
+ * **Key fields on each order:**
2543
+ * - `id` — order ID
2544
+ * - `reference` — order reference string (e.g. "ORD-12345")
2545
+ * - `channel` — sales channel name (e.g. "shopify", "amazon", "manual")
2546
+ * - `transaction_type` — "b2c", "b2b", "internal_transfer", "damage", "expiry"
2547
+ * - `orderDate` — ISO date string when order was placed
2548
+ * - `orderStatus` — numeric status code
2549
+ * - `created` — ISO date string when record was created
2550
+ * - `modified` — ISO date string when record was last modified
2551
+ * - `status` — record status (0 = inactive, 1 = active)
2552
+ * - `external_order_id` — external system order ID
2553
+ * - `channel_order_id` — sales channel order ID
2554
+ * - `notes` — order notes
2555
+ * - `hold` — 0 = not on hold, 1 = on hold
2556
+ * - `draft` — 0 = confirmed, 1 = draft
2557
+ * - `orderItems` — array of order line items (LegacyOrderItem[])
2558
+ * - `dispatches` — array of dispatches (LegacyDispatch[])
2559
+ *
2560
+ * **Date fields are ISO 8601 format** (e.g. "2025-03-25T14:30:00.000Z").
2561
+ * This differs from the Microtrack endpoint (`janus.ordersMt`) which uses DD/MM/YYYY.
2485
2562
  */
2486
2563
  export declare interface OrdersResource {
2487
2564
  /**
2488
- * Get all orders with optional query filters (client, date range, status, etc.)
2565
+ * Get all orders with pagination and optional filters.
2566
+ *
2567
+ * Requires `clientId`. The server translates the Janus client ID to the
2568
+ * legacy customer ID internally.
2489
2569
  *
2490
2570
  * @example
2491
- * const orders = await janus.orders.getAll({ clientId, pageSize: 25 });
2492
- * // Each order has: id, reference, channel, transaction_type, orderDate,
2493
- * // orderStatus, notes, hold, draft, created, modified,
2494
- * // orderItems (array), dispatches (array)
2571
+ * const { data, meta } = await janus.orders.getAll({ clientId, pageSize: 25 });
2572
+ * // data = LegacyOrder[] — each with: id, reference, channel, transaction_type,
2573
+ * // orderDate (ISO), orderStatus, created (ISO), modified (ISO), orderItems[], dispatches[]
2574
+ * // meta = { total_items, total_pages, current_page, page_size }
2495
2575
  */
2496
- getAll(filters?: OrdersQueryFilters): Promise<unknown[]>;
2576
+ getAll(filters: ClientScopedPaginatedQueryFilters): Promise<PaginatedListResponse<LegacyOrder>>;
2497
2577
  /**
2498
- * Get aggregated order statistics (counts, totals) with optional filters
2578
+ * Get a single order by ID with full details (items, dispatches, addresses).
2499
2579
  *
2500
2580
  * @example
2501
- * const stats = await janus.orders.getStats({ clientId, dashboard: true });
2502
- * // Returns a flat object with numeric counts keys vary by data.
2503
- * // Use Object.entries(stats) to iterate. Do NOT hardcode field names.
2504
- */
2505
- getStats(filters?: OrdersStatsFilters): Promise<OrdersStatsResponse>;
2506
- /** Get orders that have associated returns, with optional return-specific filters */
2507
- getReturns(filters?: OrderReturnsFilters): Promise<unknown[]>;
2508
- /**
2509
- * Get a single order by its dispatch reference string.
2510
- * Optionally scope to a specific client.
2581
+ * const order = await janus.orders.getById(12345);
2582
+ * // Returns LegacyOrder with orderItems[], dispatches[], shopperDeliveryAddress, etc.
2511
2583
  */
2512
- getByRef(dispatchRef: string, clientId?: number): Promise<unknown>;
2513
- /** Get available filter options for the returns order list, scoped to a client */
2514
- getReturnFilterOptions(clientId: number): Promise<FilterOptionsResponse>;
2584
+ getById(id: number): Promise<LegacyOrder>;
2515
2585
  /**
2516
- * Get available filter type options for the main orders list.
2517
- * Optionally scoped to a specific client; omit for all available filter types.
2586
+ * Query orders using a structured query body (legacy HttpQuery format).
2587
+ *
2588
+ * This is the legacy query-style POST endpoint. For most use cases,
2589
+ * prefer `getAll()` which uses standard pagination and filters.
2590
+ *
2591
+ * @example
2592
+ * const orders = await janus.orders.query({
2593
+ * query: [
2594
+ * { query_name: 'order.reference', query_type: 'like', query_value: 'ORD-%' },
2595
+ * ],
2596
+ * limit: 50,
2597
+ * offset: 0,
2598
+ * });
2518
2599
  */
2519
- getFilterTypes(clientId?: number): Promise<FilterOptionsResponse>;
2520
- /** Create a new order. The request body must include all required order fields and line items. */
2521
- create(data: CreateOrderRequest): Promise<unknown>;
2522
- /** Update an existing order by ID. Only the provided fields will be changed (partial update). */
2523
- updateOrder(id: number, data: Partial<CreateOrderRequest>): Promise<unknown>;
2600
+ query(query: HttpQueryRequest): Promise<LegacyOrder[]>;
2524
2601
  }
2525
2602
 
2526
2603
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createAuthApi as L } from "@pelygo/auth/core";
1
+ import { createAuthApi as O } from "@pelygo/auth/core";
2
2
  function P(t) {
3
3
  return {
4
4
  async getAll() {
@@ -78,7 +78,7 @@ function P(t) {
78
78
  }
79
79
  };
80
80
  }
81
- function O(t) {
81
+ function b(t) {
82
82
  if (!t)
83
83
  return "";
84
84
  const e = new URLSearchParams();
@@ -89,35 +89,37 @@ function O(t) {
89
89
  function u(t, e) {
90
90
  if (!e || Object.keys(e).length === 0)
91
91
  return t;
92
- const r = O(e);
92
+ const r = b(e);
93
93
  if (!r)
94
94
  return t;
95
95
  const n = t.includes("?") ? "&" : "?";
96
96
  return `${t}${n}${r}`;
97
97
  }
98
- function b(t) {
98
+ function D(t) {
99
99
  return t.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
100
100
  }
101
101
  function F(t) {
102
102
  const e = {};
103
103
  for (const [r, n] of Object.entries(t))
104
- e[b(r)] = n;
104
+ e[D(r)] = n;
105
105
  return e;
106
106
  }
107
107
  function l(t, e) {
108
- return e ? u(t, F(e)) : t;
108
+ if (!e) return t;
109
+ const r = { pageNumber: 1, ...e };
110
+ return u(t, F(r));
109
111
  }
110
112
  function o(t, e) {
111
113
  if (e.clientId == null)
112
114
  throw new Error("clientId is required for this endpoint");
113
115
  return l(t, e);
114
116
  }
115
- function x(t) {
117
+ function N(t) {
116
118
  return {
117
119
  // ── Core returns ─────────────────────────────────────────────
118
120
  async query(e) {
119
- const r = u("/returns/", e);
120
- return t.get(r);
121
+ const r = e && { page: 1, ...e }, n = u("/returns/", r);
122
+ return t.get(n);
121
123
  },
122
124
  async queryPost(e) {
123
125
  return t.post("/returns/query", e);
@@ -264,30 +266,30 @@ function x(t) {
264
266
  }
265
267
  };
266
268
  }
267
- function N(t) {
269
+ function x(t) {
268
270
  return {
269
271
  async returnsSummary(e) {
270
- const r = u("/reports/returns/summary/", e);
271
- return t.get(r);
272
+ const r = e && { page: 1, ...e }, n = u("/reports/returns/summary/", r);
273
+ return t.get(n);
272
274
  },
273
275
  async returnsSummaryCsv(e) {
274
- const r = { ...e, csv: !0, pageSize: 1e5 }, n = u("/reports/returns/summary/", r);
276
+ const r = { ...e, csv: !0, pageSize: 1e5, page: 1 }, n = u("/reports/returns/summary/", r);
275
277
  return t.get(n);
276
278
  },
277
279
  async returnsReasons(e) {
278
- const r = u("/reports/returns/reasons/", e);
279
- return t.get(r);
280
+ const r = e && { page: 1, ...e }, n = u("/reports/returns/reasons/", r);
281
+ return t.get(n);
280
282
  },
281
283
  async returnsReasonsCsv(e) {
282
- const r = { ...e, csv: !0, pageSize: 1e5 }, n = u("/reports/returns/reasons/", r);
284
+ const r = { ...e, csv: !0, pageSize: 1e5, page: 1 }, n = u("/reports/returns/reasons/", r);
283
285
  return t.get(n);
284
286
  },
285
287
  async returnsOverview(e) {
286
- const r = u("/reports/returns/overview/", e);
287
- return t.get(r);
288
+ const r = e && { page: 1, ...e }, n = u("/reports/returns/overview/", r);
289
+ return t.get(n);
288
290
  },
289
291
  async returnsOverviewCsv(e) {
290
- const r = { ...e, csv: !0, pageSize: 1e5 }, n = u("/reports/returns/overview/", r);
292
+ const r = { ...e, csv: !0, pageSize: 1e5, page: 1 }, n = u("/reports/returns/overview/", r);
291
293
  return t.get(n);
292
294
  },
293
295
  async returnsStats(e) {
@@ -364,16 +366,30 @@ function J(t) {
364
366
  function j(t) {
365
367
  return {
366
368
  async getAll(e) {
367
- const r = u("/orders", e);
369
+ const r = o("/legacy/orders", e);
368
370
  return t.get(r);
369
371
  },
372
+ async getById(e) {
373
+ return t.get(`/legacy/orders/${e}`);
374
+ },
375
+ async query(e) {
376
+ return t.post("/legacy/orders/query", e);
377
+ }
378
+ };
379
+ }
380
+ function z(t) {
381
+ return {
382
+ async getAll(e) {
383
+ const r = e && { pageNumber: 1, ...e }, n = u("/orders", r);
384
+ return t.get(n);
385
+ },
370
386
  async getStats(e) {
371
387
  const r = u("/orders/stats", e);
372
388
  return t.get(r);
373
389
  },
374
390
  async getReturns(e) {
375
- const r = u("/orders/returns", e);
376
- return t.get(r);
391
+ const r = e && { pageNumber: 1, ...e }, n = u("/orders/returns", r);
392
+ return t.get(n);
377
393
  },
378
394
  async getByRef(e, r) {
379
395
  const n = u(`/orders/${encodeURIComponent(e)}`, r != null ? { clientId: r } : void 0);
@@ -394,7 +410,7 @@ function j(t) {
394
410
  }
395
411
  };
396
412
  }
397
- function z(t) {
413
+ function W(t) {
398
414
  return {
399
415
  async getAll() {
400
416
  return t.get("/integrations");
@@ -419,7 +435,7 @@ function z(t) {
419
435
  }
420
436
  };
421
437
  }
422
- function D(t) {
438
+ function H(t) {
423
439
  return {
424
440
  async getAll(e) {
425
441
  const r = l("/users", e);
@@ -448,7 +464,7 @@ function D(t) {
448
464
  }
449
465
  };
450
466
  }
451
- function W(t) {
467
+ function M(t) {
452
468
  return {
453
469
  async createActivity(e) {
454
470
  return t.post("/logs/activity", e);
@@ -461,7 +477,7 @@ function W(t) {
461
477
  }
462
478
  };
463
479
  }
464
- function H(t) {
480
+ function V(t) {
465
481
  return {
466
482
  async getByUuid(e) {
467
483
  return t.get(`/tasks/histories/${encodeURIComponent(e)}`);
@@ -472,7 +488,7 @@ function H(t) {
472
488
  }
473
489
  };
474
490
  }
475
- function V(t) {
491
+ function G(t) {
476
492
  const { baseUrl: e } = t;
477
493
  async function r(s, c) {
478
494
  const a = await fetch(s, {
@@ -516,7 +532,7 @@ function V(t) {
516
532
  }
517
533
  };
518
534
  }
519
- function G(t) {
535
+ function K(t) {
520
536
  return {
521
537
  async getCouriers() {
522
538
  return t.get("/legacy-couriers");
@@ -536,7 +552,7 @@ function G(t) {
536
552
  }
537
553
  };
538
554
  }
539
- function K(t) {
555
+ function Q(t) {
540
556
  return {
541
557
  async getAll(e) {
542
558
  const r = o("/products", e);
@@ -556,7 +572,7 @@ function K(t) {
556
572
  }
557
573
  };
558
574
  }
559
- function M(t) {
575
+ function Z(t) {
560
576
  return {
561
577
  async getAll(e) {
562
578
  const r = o("/product-categories", e);
@@ -576,7 +592,7 @@ function M(t) {
576
592
  }
577
593
  };
578
594
  }
579
- function Q(t) {
595
+ function X(t) {
580
596
  return {
581
597
  async getAll(e) {
582
598
  const r = o("/stocks", e);
@@ -596,7 +612,7 @@ function Q(t) {
596
612
  }
597
613
  };
598
614
  }
599
- function Z(t) {
615
+ function Y(t) {
600
616
  return {
601
617
  async getAll(e) {
602
618
  const r = o("/transactions", e);
@@ -616,7 +632,7 @@ function Z(t) {
616
632
  }
617
633
  };
618
634
  }
619
- function X(t) {
635
+ function ee(t) {
620
636
  return {
621
637
  async getAll(e) {
622
638
  const r = o("/allocations", e);
@@ -633,7 +649,7 @@ function X(t) {
633
649
  }
634
650
  };
635
651
  }
636
- function Y(t) {
652
+ function te(t) {
637
653
  return {
638
654
  async getAll(e) {
639
655
  const r = o("/locations", e);
@@ -653,7 +669,7 @@ function Y(t) {
653
669
  }
654
670
  };
655
671
  }
656
- function ee(t) {
672
+ function re(t) {
657
673
  return {
658
674
  async getAll(e) {
659
675
  const r = o("/audits", e);
@@ -664,7 +680,7 @@ function ee(t) {
664
680
  }
665
681
  };
666
682
  }
667
- function te(t) {
683
+ function ne(t) {
668
684
  return {
669
685
  // ── ASN CRUD ─────────────────────────────────
670
686
  async getAll(e) {
@@ -731,7 +747,7 @@ function te(t) {
731
747
  }
732
748
  };
733
749
  }
734
- function re(t) {
750
+ function se(t) {
735
751
  return {
736
752
  async getAll(e) {
737
753
  const r = o("/dispatches", e);
@@ -751,7 +767,7 @@ function re(t) {
751
767
  }
752
768
  };
753
769
  }
754
- function ne(t) {
770
+ function ce(t) {
755
771
  return {
756
772
  async getByDispatchId(e) {
757
773
  return t.get(`/consignments/${e}`);
@@ -767,7 +783,7 @@ function ne(t) {
767
783
  }
768
784
  };
769
785
  }
770
- function se(t) {
786
+ function ue(t) {
771
787
  return {
772
788
  // ── Invoice CRUD ────────────────────────────────────────────
773
789
  async getAll(e) {
@@ -813,16 +829,16 @@ function se(t) {
813
829
  }
814
830
  };
815
831
  }
816
- const ce = "https://api.janus.pelygo.com", ue = [
832
+ const oe = "https://api.janus.pelygo.com", ae = [
817
833
  "/auth/",
818
834
  "/returns/query",
819
835
  "/legacy/products/query",
820
836
  "/legacy/"
821
837
  ];
822
- function oe(t) {
823
- return ue.some((e) => t.includes(e));
838
+ function ie(t) {
839
+ return ae.some((e) => t.includes(e));
824
840
  }
825
- function ae(t) {
841
+ function ye(t) {
826
842
  const e = (r, n) => {
827
843
  throw new Error(
828
844
  `@pelygo/janus: Write operation blocked (${r.toUpperCase()}${n ? " " + n : ""}). The client is in read-only mode. To enable writes, set allowWrites: true in createJanusApi options:
@@ -832,44 +848,45 @@ function ae(t) {
832
848
  };
833
849
  return {
834
850
  ...t,
835
- post: (r, n, s) => oe(r) ? t.post(r, n, s) : e("POST", r),
851
+ post: (r, n, s) => ie(r) ? t.post(r, n, s) : e("POST", r),
836
852
  put: (r, n, s) => e("PUT", r),
837
853
  patch: (r, n, s) => e("PATCH", r),
838
854
  delete: (r, n) => e("DELETE", r)
839
855
  };
840
856
  }
841
- function le(t = {}) {
842
- const e = t.baseUrl || ce, r = {
857
+ function de(t = {}) {
858
+ const e = t.baseUrl || oe, r = {
843
859
  baseUrl: e,
844
860
  authUrl: t.authUrl,
845
861
  onUnauthorized: t.onUnauthorized,
846
862
  onLoginSuccess: t.onLoginSuccess,
847
863
  onLoginError: t.onLoginError
848
- }, n = L(r), s = t.allowWrites ? n : ae(n), c = P(s), a = x(s), y = N(s), d = q({ baseUrl: e }), g = J(s), $ = j(s), m = z(s), f = D(s), p = W(s), v = H(s), h = V({ baseUrl: e }), R = G(s), S = K(s), I = M(s), C = Q(s), A = Z(s), w = X(s), U = Y(s), B = ee(s), k = te(s), _ = re(s), E = ne(s), T = se(s);
864
+ }, n = O(r), s = t.allowWrites ? n : ye(n), c = P(s), a = N(s), y = x(s), g = q({ baseUrl: e }), d = J(s), $ = j(s), m = z(s), p = W(s), h = H(s), v = M(s), f = V(s), R = G({ baseUrl: e }), S = K(s), I = Q(s), C = Z(s), w = X(s), A = Y(s), U = ee(s), B = te(s), k = re(s), _ = ne(s), E = se(s), T = ce(s), L = ue(s);
849
865
  return {
850
866
  clients: c,
851
867
  returns: a,
852
868
  reports: y,
853
- helpers: d,
854
- couriers: g,
869
+ helpers: g,
870
+ couriers: d,
855
871
  orders: $,
856
- integrations: m,
857
- users: f,
858
- logs: p,
859
- tasks: v,
860
- customer: h,
861
- legacy: R,
862
- products: S,
863
- productCategories: I,
864
- stocks: C,
872
+ ordersMt: m,
873
+ integrations: p,
874
+ users: h,
875
+ logs: v,
876
+ tasks: f,
877
+ customer: R,
878
+ legacy: S,
879
+ products: I,
880
+ productCategories: C,
881
+ stocks: w,
865
882
  stockTransactions: A,
866
- stockAllocations: w,
867
- locations: U,
868
- audits: B,
869
- asns: k,
870
- dispatches: _,
871
- consignments: E,
872
- invoices: T,
883
+ stockAllocations: U,
884
+ locations: B,
885
+ audits: k,
886
+ asns: _,
887
+ dispatches: E,
888
+ consignments: T,
889
+ invoices: L,
873
890
  auth: n
874
891
  };
875
892
  }
@@ -880,44 +897,44 @@ class i extends Error {
880
897
  s.captureStackTrace && s.captureStackTrace(this, i);
881
898
  }
882
899
  }
883
- class ie extends i {
900
+ class le extends i {
884
901
  constructor(e = "Unauthorized", r) {
885
902
  super(e, 401, r), this.name = "UnauthorizedError";
886
903
  }
887
904
  }
888
- class de extends i {
905
+ class $e extends i {
889
906
  constructor(e = "Forbidden", r) {
890
907
  super(e, 403, r), this.name = "ForbiddenError";
891
908
  }
892
909
  }
893
- class ge extends i {
910
+ class me extends i {
894
911
  constructor(e = "Not Found", r) {
895
912
  super(e, 404, r), this.name = "NotFoundError";
896
913
  }
897
914
  }
898
- class $e extends i {
915
+ class pe extends i {
899
916
  constructor(e = "Validation Error", r, n) {
900
917
  super(e, 400, n), this.name = "ValidationError", this.errors = r;
901
918
  }
902
919
  }
903
- function me(t) {
920
+ function he(t) {
904
921
  return t instanceof i;
905
922
  }
906
- function fe(t) {
907
- return t instanceof ie;
923
+ function ve(t) {
924
+ return t instanceof le;
908
925
  }
909
926
  export {
910
- ce as DEFAULT_JANUS_URL,
911
- de as ForbiddenError,
927
+ oe as DEFAULT_JANUS_URL,
928
+ $e as ForbiddenError,
912
929
  i as JanusApiError,
913
- ge as NotFoundError,
914
- ie as UnauthorizedError,
915
- $e as ValidationError,
930
+ me as NotFoundError,
931
+ le as UnauthorizedError,
932
+ pe as ValidationError,
916
933
  o as buildClientScopedPaginatedUrl,
917
934
  l as buildPaginatedUrl,
918
- O as buildQueryString,
935
+ b as buildQueryString,
919
936
  u as buildUrl,
920
- le as createJanusApi,
921
- me as isJanusApiError,
922
- fe as isUnauthorizedError
937
+ de as createJanusApi,
938
+ he as isJanusApiError,
939
+ ve as isUnauthorizedError
923
940
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pelygo/janus",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "TypeScript API client for JANUS endpoints with full type safety",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",