@pelygo/janus 0.5.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,32 +89,32 @@ 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
- function D(t) {
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
108
  if (!e) return t;
109
109
  const r = { pageNumber: 1, ...e };
110
- return u(t, D(r));
110
+ return u(t, F(r));
111
111
  }
112
112
  function o(t, e) {
113
113
  if (e.clientId == null)
114
114
  throw new Error("clientId is required for this endpoint");
115
115
  return l(t, e);
116
116
  }
117
- function F(t) {
117
+ function N(t) {
118
118
  return {
119
119
  // ── Core returns ─────────────────────────────────────────────
120
120
  async query(e) {
@@ -266,7 +266,7 @@ function F(t) {
266
266
  }
267
267
  };
268
268
  }
269
- function N(t) {
269
+ function x(t) {
270
270
  return {
271
271
  async returnsSummary(e) {
272
272
  const r = e && { page: 1, ...e }, n = u("/reports/returns/summary/", r);
@@ -297,7 +297,7 @@ function N(t) {
297
297
  }
298
298
  };
299
299
  }
300
- function x(t) {
300
+ function q(t) {
301
301
  const { baseUrl: e } = t;
302
302
  async function r(n, s) {
303
303
  const c = await fetch(n, {
@@ -335,7 +335,7 @@ function x(t) {
335
335
  }
336
336
  };
337
337
  }
338
- function q(t) {
338
+ function J(t) {
339
339
  return {
340
340
  async getAll() {
341
341
  return t.get("/couriers");
@@ -363,7 +363,21 @@ function q(t) {
363
363
  }
364
364
  };
365
365
  }
366
- function J(t) {
366
+ function j(t) {
367
+ return {
368
+ async getAll(e) {
369
+ const r = o("/legacy/orders", e);
370
+ return t.get(r);
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) {
367
381
  return {
368
382
  async getAll(e) {
369
383
  const r = e && { pageNumber: 1, ...e }, n = u("/orders", r);
@@ -396,7 +410,7 @@ function J(t) {
396
410
  }
397
411
  };
398
412
  }
399
- function j(t) {
413
+ function W(t) {
400
414
  return {
401
415
  async getAll() {
402
416
  return t.get("/integrations");
@@ -421,7 +435,7 @@ function j(t) {
421
435
  }
422
436
  };
423
437
  }
424
- function z(t) {
438
+ function H(t) {
425
439
  return {
426
440
  async getAll(e) {
427
441
  const r = l("/users", e);
@@ -450,7 +464,7 @@ function z(t) {
450
464
  }
451
465
  };
452
466
  }
453
- function W(t) {
467
+ function M(t) {
454
468
  return {
455
469
  async createActivity(e) {
456
470
  return t.post("/logs/activity", e);
@@ -463,7 +477,7 @@ function W(t) {
463
477
  }
464
478
  };
465
479
  }
466
- function H(t) {
480
+ function V(t) {
467
481
  return {
468
482
  async getByUuid(e) {
469
483
  return t.get(`/tasks/histories/${encodeURIComponent(e)}`);
@@ -474,7 +488,7 @@ function H(t) {
474
488
  }
475
489
  };
476
490
  }
477
- function V(t) {
491
+ function G(t) {
478
492
  const { baseUrl: e } = t;
479
493
  async function r(s, c) {
480
494
  const a = await fetch(s, {
@@ -518,7 +532,7 @@ function V(t) {
518
532
  }
519
533
  };
520
534
  }
521
- function G(t) {
535
+ function K(t) {
522
536
  return {
523
537
  async getCouriers() {
524
538
  return t.get("/legacy-couriers");
@@ -538,7 +552,7 @@ function G(t) {
538
552
  }
539
553
  };
540
554
  }
541
- function K(t) {
555
+ function Q(t) {
542
556
  return {
543
557
  async getAll(e) {
544
558
  const r = o("/products", e);
@@ -558,7 +572,7 @@ function K(t) {
558
572
  }
559
573
  };
560
574
  }
561
- function M(t) {
575
+ function Z(t) {
562
576
  return {
563
577
  async getAll(e) {
564
578
  const r = o("/product-categories", e);
@@ -578,7 +592,7 @@ function M(t) {
578
592
  }
579
593
  };
580
594
  }
581
- function Q(t) {
595
+ function X(t) {
582
596
  return {
583
597
  async getAll(e) {
584
598
  const r = o("/stocks", e);
@@ -598,7 +612,7 @@ function Q(t) {
598
612
  }
599
613
  };
600
614
  }
601
- function Z(t) {
615
+ function Y(t) {
602
616
  return {
603
617
  async getAll(e) {
604
618
  const r = o("/transactions", e);
@@ -618,7 +632,7 @@ function Z(t) {
618
632
  }
619
633
  };
620
634
  }
621
- function X(t) {
635
+ function ee(t) {
622
636
  return {
623
637
  async getAll(e) {
624
638
  const r = o("/allocations", e);
@@ -635,7 +649,7 @@ function X(t) {
635
649
  }
636
650
  };
637
651
  }
638
- function Y(t) {
652
+ function te(t) {
639
653
  return {
640
654
  async getAll(e) {
641
655
  const r = o("/locations", e);
@@ -655,7 +669,7 @@ function Y(t) {
655
669
  }
656
670
  };
657
671
  }
658
- function ee(t) {
672
+ function re(t) {
659
673
  return {
660
674
  async getAll(e) {
661
675
  const r = o("/audits", e);
@@ -666,7 +680,7 @@ function ee(t) {
666
680
  }
667
681
  };
668
682
  }
669
- function te(t) {
683
+ function ne(t) {
670
684
  return {
671
685
  // ── ASN CRUD ─────────────────────────────────
672
686
  async getAll(e) {
@@ -733,7 +747,7 @@ function te(t) {
733
747
  }
734
748
  };
735
749
  }
736
- function re(t) {
750
+ function se(t) {
737
751
  return {
738
752
  async getAll(e) {
739
753
  const r = o("/dispatches", e);
@@ -753,7 +767,7 @@ function re(t) {
753
767
  }
754
768
  };
755
769
  }
756
- function ne(t) {
770
+ function ce(t) {
757
771
  return {
758
772
  async getByDispatchId(e) {
759
773
  return t.get(`/consignments/${e}`);
@@ -769,7 +783,7 @@ function ne(t) {
769
783
  }
770
784
  };
771
785
  }
772
- function se(t) {
786
+ function ue(t) {
773
787
  return {
774
788
  // ── Invoice CRUD ────────────────────────────────────────────
775
789
  async getAll(e) {
@@ -815,16 +829,16 @@ function se(t) {
815
829
  }
816
830
  };
817
831
  }
818
- const ce = "https://api.janus.pelygo.com", ue = [
832
+ const oe = "https://api.janus.pelygo.com", ae = [
819
833
  "/auth/",
820
834
  "/returns/query",
821
835
  "/legacy/products/query",
822
836
  "/legacy/"
823
837
  ];
824
- function oe(t) {
825
- return ue.some((e) => t.includes(e));
838
+ function ie(t) {
839
+ return ae.some((e) => t.includes(e));
826
840
  }
827
- function ae(t) {
841
+ function ye(t) {
828
842
  const e = (r, n) => {
829
843
  throw new Error(
830
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:
@@ -834,20 +848,20 @@ function ae(t) {
834
848
  };
835
849
  return {
836
850
  ...t,
837
- 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),
838
852
  put: (r, n, s) => e("PUT", r),
839
853
  patch: (r, n, s) => e("PATCH", r),
840
854
  delete: (r, n) => e("DELETE", r)
841
855
  };
842
856
  }
843
- function le(t = {}) {
844
- const e = t.baseUrl || ce, r = {
857
+ function de(t = {}) {
858
+ const e = t.baseUrl || oe, r = {
845
859
  baseUrl: e,
846
860
  authUrl: t.authUrl,
847
861
  onUnauthorized: t.onUnauthorized,
848
862
  onLoginSuccess: t.onLoginSuccess,
849
863
  onLoginError: t.onLoginError
850
- }, n = L(r), s = t.allowWrites ? n : ae(n), c = P(s), a = F(s), y = N(s), g = x({ baseUrl: e }), d = q(s), $ = J(s), m = j(s), p = z(s), h = W(s), v = H(s), f = V({ baseUrl: e }), R = G(s), S = K(s), I = M(s), C = Q(s), w = Z(s), A = 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);
851
865
  return {
852
866
  clients: c,
853
867
  returns: a,
@@ -855,23 +869,24 @@ function le(t = {}) {
855
869
  helpers: g,
856
870
  couriers: d,
857
871
  orders: $,
858
- integrations: m,
859
- users: p,
860
- logs: h,
861
- tasks: v,
862
- customer: f,
863
- legacy: R,
864
- products: S,
865
- productCategories: I,
866
- stocks: C,
867
- stockTransactions: w,
868
- stockAllocations: A,
869
- locations: U,
870
- audits: B,
871
- asns: k,
872
- dispatches: _,
873
- consignments: E,
874
- invoices: T,
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,
882
+ stockTransactions: A,
883
+ stockAllocations: U,
884
+ locations: B,
885
+ audits: k,
886
+ asns: _,
887
+ dispatches: E,
888
+ consignments: T,
889
+ invoices: L,
875
890
  auth: n
876
891
  };
877
892
  }
@@ -882,44 +897,44 @@ class i extends Error {
882
897
  s.captureStackTrace && s.captureStackTrace(this, i);
883
898
  }
884
899
  }
885
- class ie extends i {
900
+ class le extends i {
886
901
  constructor(e = "Unauthorized", r) {
887
902
  super(e, 401, r), this.name = "UnauthorizedError";
888
903
  }
889
904
  }
890
- class ge extends i {
905
+ class $e extends i {
891
906
  constructor(e = "Forbidden", r) {
892
907
  super(e, 403, r), this.name = "ForbiddenError";
893
908
  }
894
909
  }
895
- class de extends i {
910
+ class me extends i {
896
911
  constructor(e = "Not Found", r) {
897
912
  super(e, 404, r), this.name = "NotFoundError";
898
913
  }
899
914
  }
900
- class $e extends i {
915
+ class pe extends i {
901
916
  constructor(e = "Validation Error", r, n) {
902
917
  super(e, 400, n), this.name = "ValidationError", this.errors = r;
903
918
  }
904
919
  }
905
- function me(t) {
920
+ function he(t) {
906
921
  return t instanceof i;
907
922
  }
908
- function pe(t) {
909
- return t instanceof ie;
923
+ function ve(t) {
924
+ return t instanceof le;
910
925
  }
911
926
  export {
912
- ce as DEFAULT_JANUS_URL,
913
- ge as ForbiddenError,
927
+ oe as DEFAULT_JANUS_URL,
928
+ $e as ForbiddenError,
914
929
  i as JanusApiError,
915
- de as NotFoundError,
916
- ie as UnauthorizedError,
917
- $e as ValidationError,
930
+ me as NotFoundError,
931
+ le as UnauthorizedError,
932
+ pe as ValidationError,
918
933
  o as buildClientScopedPaginatedUrl,
919
934
  l as buildPaginatedUrl,
920
- O as buildQueryString,
935
+ b as buildQueryString,
921
936
  u as buildUrl,
922
- le as createJanusApi,
923
- me as isJanusApiError,
924
- pe as isUnauthorizedError
937
+ de as createJanusApi,
938
+ he as isJanusApiError,
939
+ ve as isUnauthorizedError
925
940
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pelygo/janus",
3
- "version": "0.5.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",