@pelygo/janus 0.5.0 → 0.6.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 +50 -63
- package/USAGE.md +40 -35
- package/dist/index.d.ts +106 -29
- package/dist/index.js +85 -70
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,7 +83,8 @@ await janus.auth.logout();
|
|
|
83
83
|
|----------|----------|------|-------------|
|
|
84
84
|
| Clients | `janus.clients` | Yes | Client account CRUD, courier services per client |
|
|
85
85
|
| Returns | `janus.returns` | Yes | Full returns management: CRUD, items, comments, statuses, reasons, categories, sources |
|
|
86
|
-
| Orders | `janus.orders` | Yes |
|
|
86
|
+
| Orders | `janus.orders` | Yes | General-purpose orders (`/legacy/orders`): paginated list, getById, query. Returns `LegacyOrder` with ISO dates |
|
|
87
|
+
| Orders (Microtrack) | `janus.ordersMt` | Yes | Microtrack orders (`/orders`): stats, returns, filter options, create/update. Returns formatted objects with DD/MM/YYYY dates |
|
|
87
88
|
| Products | `janus.products` | Yes | Product CRUD (preferred over `legacy.queryProducts`) |
|
|
88
89
|
| Product Categories | `janus.productCategories` | Yes | Product category CRUD |
|
|
89
90
|
| Stocks | `janus.stocks` | Yes | Stock record CRUD |
|
|
@@ -148,42 +149,26 @@ await janus.auth.logout();
|
|
|
148
149
|
| `created_ts` | `string?` | ISO timestamp |
|
|
149
150
|
| `updated_ts` | `string?` | ISO timestamp |
|
|
150
151
|
|
|
151
|
-
### LegacyOrder
|
|
152
|
+
### LegacyOrder (from `janus.orders.getAll` / `getById`)
|
|
152
153
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
|
156
|
-
|
|
157
|
-
| `
|
|
158
|
-
| `
|
|
159
|
-
| `
|
|
160
|
-
| `
|
|
161
|
-
| `
|
|
162
|
-
| `
|
|
163
|
-
| `
|
|
164
|
-
| `
|
|
165
|
-
| `
|
|
166
|
-
| `
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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 |
|
|
154
|
+
`janus.orders` is the **general-purpose orders resource**. It hits `/legacy/orders` and returns `LegacyOrder` entities with ISO dates.
|
|
155
|
+
|
|
156
|
+
| Field | Type | Format | Description |
|
|
157
|
+
|-------|------|--------|-------------|
|
|
158
|
+
| `id` | `number` | — | Order ID |
|
|
159
|
+
| `reference` | `string` | — | Order reference number |
|
|
160
|
+
| `channel` | `string` | — | Sales channel name |
|
|
161
|
+
| `transaction_type` | `string` | — | Transaction type |
|
|
162
|
+
| `orderDate` | `string` | ISO 8601 | Date order was received |
|
|
163
|
+
| `orderStatus` | `string` | — | Current order status |
|
|
164
|
+
| `created` | `string` | ISO 8601 | Record creation timestamp |
|
|
165
|
+
| `modified` | `string` | ISO 8601 | Record last modified timestamp |
|
|
166
|
+
| `orderItems` | `array` | — | Order line items |
|
|
167
|
+
| `dispatches` | `array` | — | Associated dispatches |
|
|
168
|
+
|
|
169
|
+
**Date fields are ISO 8601** — no custom parsing required. Use `new Date(order.orderDate)` directly.
|
|
170
|
+
|
|
171
|
+
> **Microtrack orders (`janus.ordersMt`):** If you are building a Microtrack integration, use `janus.ordersMt` instead. It hits `/orders` and returns formatted objects with `DD/MM/YYYY HH:mm` dates and different field names (`orderRef`, `dispatchRef`, `orderCreated`, etc.). See the [Orders Endpoint Guide](docs/AI-usage/endpoints/orders/README.md) for details.
|
|
187
172
|
|
|
188
173
|
### LegacyDispatch
|
|
189
174
|
|
|
@@ -431,24 +416,18 @@ Extends `BaseEntity`.
|
|
|
431
416
|
| `csv` | `boolean` | No | Export as CSV instead of JSON |
|
|
432
417
|
| `group_by` | `string` | No | Group results by field |
|
|
433
418
|
|
|
434
|
-
###
|
|
419
|
+
### ClientScopedPaginatedQueryFilters (janus.orders.getAll)
|
|
420
|
+
|
|
421
|
+
`janus.orders.getAll` now uses the same `ClientScopedPaginatedQueryFilters` as other v2 endpoints:
|
|
435
422
|
|
|
436
423
|
| Param | Type | Required | Description |
|
|
437
424
|
|-------|------|----------|-------------|
|
|
438
|
-
| `clientId` | `number` | **Yes** | Client ID |
|
|
439
|
-
| `
|
|
440
|
-
| `
|
|
441
|
-
| `
|
|
442
|
-
| `
|
|
443
|
-
| `
|
|
444
|
-
| `created_to` | `string` | No | End date (ISO) |
|
|
445
|
-
| `channel` | `string` | No | Filter by sales channel |
|
|
446
|
-
| `destination` | `string` | No | Filter by destination |
|
|
447
|
-
| `courier` | `string` | No | Filter by courier name |
|
|
448
|
-
| `service` | `string` | No | Filter by courier service |
|
|
449
|
-
| `status` | `string` | No | Filter by order status |
|
|
450
|
-
| `query` | `string` | No | Free-text search |
|
|
451
|
-
| `include_all_stages` | `boolean` | No | Include all order stages |
|
|
425
|
+
| `clientId` | `number` | **Yes** | Client ID from `useClient()` |
|
|
426
|
+
| `pageSize` | `number` | No | Results per page (default: 25) |
|
|
427
|
+
| `pageNumber` | `number` | No | Page number, 1-based (default: 1) |
|
|
428
|
+
| `orderColumn` | `string` | No | Column to sort by (e.g. `'id'`, `'created'`) |
|
|
429
|
+
| `orderDirection` | `'ASC' \| 'DESC'` | No | Sort direction (default: DESC) |
|
|
430
|
+
| `query` | `string` | No | Free-text search across key fields |
|
|
452
431
|
|
|
453
432
|
### ReturnsSummaryFilters (janus.reports.returnsSummary / returnsSummaryCsv)
|
|
454
433
|
|
|
@@ -473,7 +452,7 @@ Extends `BaseEntity`.
|
|
|
473
452
|
| `createdFrom` | `string` | No | Start date (ISO) |
|
|
474
453
|
| `createdTo` | `string` | No | End date (ISO) |
|
|
475
454
|
|
|
476
|
-
### OrdersStatsFilters (janus.
|
|
455
|
+
### OrdersStatsFilters (janus.ordersMt.getStats — Microtrack only)
|
|
477
456
|
|
|
478
457
|
| Param | Type | Required | Description |
|
|
479
458
|
|-------|------|----------|-------------|
|
|
@@ -515,7 +494,22 @@ const { data, meta } = await janus.products.getAll({
|
|
|
515
494
|
// meta = { total_items, total_pages, current_page, page_size }
|
|
516
495
|
```
|
|
517
496
|
|
|
518
|
-
**
|
|
497
|
+
**Orders** use `ClientScopedPaginatedQueryFilters` (same as v2 endpoints):
|
|
498
|
+
|
|
499
|
+
```typescript
|
|
500
|
+
const { data: orders, meta } = await janus.orders.getAll({
|
|
501
|
+
clientId: 5,
|
|
502
|
+
pageSize: 25,
|
|
503
|
+
pageNumber: 1,
|
|
504
|
+
orderColumn: 'created',
|
|
505
|
+
orderDirection: 'DESC',
|
|
506
|
+
query: 'ORD-123',
|
|
507
|
+
});
|
|
508
|
+
// orders = LegacyOrder[] with ISO dates
|
|
509
|
+
// meta = { total_items, total_pages, current_page, page_size }
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
**Returns** use their own filter shape:
|
|
519
513
|
|
|
520
514
|
```typescript
|
|
521
515
|
const returns = await janus.returns.query({
|
|
@@ -526,15 +520,6 @@ const returns = await janus.returns.query({
|
|
|
526
520
|
pageSize: 100,
|
|
527
521
|
csv: false,
|
|
528
522
|
});
|
|
529
|
-
|
|
530
|
-
const orders = await janus.orders.getAll({
|
|
531
|
-
clientId: 5,
|
|
532
|
-
created_at: '2024-01-01',
|
|
533
|
-
created_to: '2024-12-31',
|
|
534
|
-
status: 'dispatched',
|
|
535
|
-
order_column: 'created',
|
|
536
|
-
order_direction: 'DESC',
|
|
537
|
-
});
|
|
538
523
|
```
|
|
539
524
|
|
|
540
525
|
### CSV Export
|
|
@@ -636,7 +621,9 @@ Common codes: 400 (bad request/validation), 401 (unauthorized), 404 (not found).
|
|
|
636
621
|
|
|
637
622
|
### Date formats
|
|
638
623
|
- **Query params:** ISO 8601 format (`'2025-01-01'` or `'2025-01-01 12:00:00'`)
|
|
639
|
-
- **
|
|
624
|
+
- **v2 response fields** (returns, stocks, etc.): ISO 8601 timestamps (`created_ts`, `updated_ts`)
|
|
625
|
+
- **Orders response fields** (`janus.orders`): ISO 8601 timestamps (`orderDate`, `created`, `modified`) — no parsing needed
|
|
626
|
+
- **Microtrack orders response fields** (`janus.ordersMt`): `DD/MM/YYYY HH:mm` format — **NOT ISO**. Fields: `orderCreated`, `releaseDate`, `dispatchCompletedDate`. Must be parsed before use.
|
|
640
627
|
- **CSV exports:** formatted as `DD-MM-YYYY HH:mm`
|
|
641
628
|
|
|
642
629
|
### Pagination defaults
|
package/USAGE.md
CHANGED
|
@@ -100,27 +100,25 @@ const returns = await janus.returns.query({
|
|
|
100
100
|
});
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
-
###
|
|
103
|
+
### ClientScopedPaginatedQueryFilters (janus.orders.getAll)
|
|
104
|
+
|
|
105
|
+
`janus.orders.getAll` now uses `ClientScopedPaginatedQueryFilters` (same as other v2 endpoints):
|
|
104
106
|
|
|
105
107
|
| Param | Type | Description |
|
|
106
108
|
|-------|------|-------------|
|
|
107
|
-
| `clientId` | `number` | Client ID |
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
111
|
-
| `
|
|
112
|
-
| `
|
|
113
|
-
| `created_to` | `string` | End date (ISO) |
|
|
114
|
-
| `channel` | `string` | Filter by sales channel |
|
|
115
|
-
| `courier` | `string` | Filter by courier name |
|
|
116
|
-
| `status` | `string` | Filter by order status |
|
|
117
|
-
| `query` | `string` | Free-text search |
|
|
109
|
+
| `clientId` | `number` | **Required.** Client ID from `useClient()` |
|
|
110
|
+
| `pageSize` | `number` | Results per page (default: 25) |
|
|
111
|
+
| `pageNumber` | `number` | Page number, 1-based (default: 1) |
|
|
112
|
+
| `orderColumn` | `string` | Column to sort by (e.g. `'id'`, `'created'`) |
|
|
113
|
+
| `orderDirection` | `'ASC' \| 'DESC'` | Sort direction (default: DESC) |
|
|
114
|
+
| `query` | `string` | Free-text search across key fields |
|
|
118
115
|
|
|
119
116
|
```js
|
|
120
|
-
const orders = await janus.orders.getAll({
|
|
121
|
-
clientId,
|
|
122
|
-
created_at: '2025-01-01', created_to: '2025-12-31', query: 'ORD-123',
|
|
117
|
+
const { data: orders, meta } = await janus.orders.getAll({
|
|
118
|
+
clientId, pageSize: 25, pageNumber: 1, orderDirection: 'DESC', query: 'ORD-123',
|
|
123
119
|
});
|
|
120
|
+
// orders = LegacyOrder[] with ISO dates
|
|
121
|
+
// meta = { total_items, total_pages, current_page, page_size }
|
|
124
122
|
```
|
|
125
123
|
|
|
126
124
|
### ReturnsSummaryFilters (janus.reports.returnsSummary)
|
|
@@ -162,7 +160,8 @@ const summary = await janus.reports.returnsSummary({
|
|
|
162
160
|
|----------|--------|-------------|
|
|
163
161
|
| `janus.clients` | Auth | Client CRUD, courier services, return reasons, integrations, files |
|
|
164
162
|
| `janus.returns` | Auth | Returns CRUD, items, comments, statuses, reasons, categories, sources |
|
|
165
|
-
| `janus.orders` | Auth |
|
|
163
|
+
| `janus.orders` | Auth | General-purpose orders (`/legacy/orders`): paginated list, getById, query. Returns `LegacyOrder` with ISO dates |
|
|
164
|
+
| `janus.ordersMt` | Auth | Microtrack orders (`/orders`): stats, returns, filter options, create/update (Microtrack only) |
|
|
166
165
|
| `janus.reports` | Auth | Returns summary/reasons/overview/stats + CSV exports |
|
|
167
166
|
| `janus.products` | Auth | Product CRUD (preferred over legacy.queryProducts) |
|
|
168
167
|
| `janus.productCategories` | Auth | Product category CRUD |
|
|
@@ -202,23 +201,26 @@ const summary = await janus.reports.returnsSummary({
|
|
|
202
201
|
| `created_ts` | `string` | ISO timestamp |
|
|
203
202
|
| `updated_ts` | `string` | ISO timestamp |
|
|
204
203
|
|
|
205
|
-
##
|
|
204
|
+
## LegacyOrder Fields (from `janus.orders.getAll` / `getById`)
|
|
206
205
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
|
210
|
-
|
|
211
|
-
| `
|
|
212
|
-
| `
|
|
213
|
-
| `
|
|
214
|
-
| `
|
|
215
|
-
| `
|
|
216
|
-
| `
|
|
217
|
-
| `
|
|
218
|
-
| `
|
|
219
|
-
| `
|
|
220
|
-
| `
|
|
221
|
-
|
|
206
|
+
`janus.orders` is the **general-purpose orders resource**. It hits `/legacy/orders` and returns `LegacyOrder` entities with ISO dates:
|
|
207
|
+
|
|
208
|
+
| Field | Type | Format | Description |
|
|
209
|
+
|-------|------|--------|-------------|
|
|
210
|
+
| `id` | `number` | — | Order ID |
|
|
211
|
+
| `reference` | `string` | — | Order reference number |
|
|
212
|
+
| `channel` | `string` | — | Sales channel name |
|
|
213
|
+
| `transaction_type` | `string` | — | Transaction type |
|
|
214
|
+
| `orderDate` | `string` | ISO 8601 | Date order was received |
|
|
215
|
+
| `orderStatus` | `string` | — | Current order status |
|
|
216
|
+
| `created` | `string` | ISO 8601 | Record creation timestamp |
|
|
217
|
+
| `modified` | `string` | ISO 8601 | Record last modified timestamp |
|
|
218
|
+
| `orderItems` | `array` | — | Order line items |
|
|
219
|
+
| `dispatches` | `array` | — | Associated dispatches |
|
|
220
|
+
|
|
221
|
+
**Dates are ISO 8601** — no custom parsing needed. Use `new Date(order.orderDate)` directly.
|
|
222
|
+
|
|
223
|
+
> **Microtrack orders (`janus.ordersMt`):** For Microtrack integrations only. Hits `/orders`, returns formatted objects with `DD/MM/YYYY HH:mm` dates and different field names (`orderRef`, `dispatchRef`, `orderCreated`, etc.). Methods: `getAll`, `getStats`, `getReturns`, `getByRef`, `getReturnFilterOptions`, `getFilterTypes`, `create`, `updateOrder`.
|
|
222
224
|
|
|
223
225
|
## Product Entity Fields (from /products endpoint)
|
|
224
226
|
|
|
@@ -287,10 +289,11 @@ const stats = await janus.reports.returnsStats(clientId);
|
|
|
287
289
|
// }
|
|
288
290
|
```
|
|
289
291
|
|
|
290
|
-
## OrdersStatsResponse Fields
|
|
292
|
+
## OrdersStatsResponse Fields (Microtrack only)
|
|
291
293
|
|
|
292
294
|
```js
|
|
293
|
-
|
|
295
|
+
// Microtrack only — use janus.ordersMt for stats
|
|
296
|
+
const stats = await janus.ordersMt.getStats({ clientId, dashboard: true });
|
|
294
297
|
// Returns a flat object with numeric counts — keys vary by data.
|
|
295
298
|
// Use Object.entries(stats) to iterate. Do NOT hardcode field names.
|
|
296
299
|
// Example: { total_orders: 150, dispatched: 120, processing: 15, ... }
|
|
@@ -307,7 +310,9 @@ Common codes: 400 (bad request/validation), 401 (unauthorized), 404 (not found).
|
|
|
307
310
|
|
|
308
311
|
### Date formats
|
|
309
312
|
- **Query params:** ISO 8601 (`'2025-01-01'` or `'2025-01-01 12:00:00'`)
|
|
310
|
-
- **
|
|
313
|
+
- **v2 response fields** (returns, stocks, etc.): ISO 8601 timestamps (`created_ts`, `updated_ts`)
|
|
314
|
+
- **Orders response fields** (`janus.orders`): ISO 8601 timestamps (`orderDate`, `created`, `modified`) — no parsing needed
|
|
315
|
+
- **Microtrack orders response fields** (`janus.ordersMt`): `DD/MM/YYYY HH:mm` format — **NOT ISO**. Fields: `orderCreated`, `releaseDate`, `dispatchCompletedDate`. Must be parsed.
|
|
311
316
|
- **CSV exports:** formatted as `DD-MM-YYYY HH:mm`
|
|
312
317
|
|
|
313
318
|
### 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 -
|
|
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
|
|
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
|
|
2492
|
-
* //
|
|
2493
|
-
* //
|
|
2494
|
-
* //
|
|
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
|
|
2576
|
+
getAll(filters: ClientScopedPaginatedQueryFilters): Promise<PaginatedListResponse<LegacyOrder>>;
|
|
2497
2577
|
/**
|
|
2498
|
-
* Get
|
|
2578
|
+
* Get a single order by ID with full details (items, dispatches, addresses).
|
|
2499
2579
|
*
|
|
2500
2580
|
* @example
|
|
2501
|
-
* const
|
|
2502
|
-
* // Returns
|
|
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
|
-
|
|
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
|
-
*
|
|
2517
|
-
*
|
|
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
|
-
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
98
|
+
function D(t) {
|
|
99
99
|
return t.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function F(t) {
|
|
102
102
|
const e = {};
|
|
103
103
|
for (const [r, n] of Object.entries(t))
|
|
104
|
-
e[
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
825
|
-
return
|
|
838
|
+
function ie(t) {
|
|
839
|
+
return ae.some((e) => t.includes(e));
|
|
826
840
|
}
|
|
827
|
-
function
|
|
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) =>
|
|
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
|
|
844
|
-
const e = t.baseUrl ||
|
|
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 =
|
|
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
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
920
|
+
function he(t) {
|
|
906
921
|
return t instanceof i;
|
|
907
922
|
}
|
|
908
|
-
function
|
|
909
|
-
return t instanceof
|
|
923
|
+
function ve(t) {
|
|
924
|
+
return t instanceof le;
|
|
910
925
|
}
|
|
911
926
|
export {
|
|
912
|
-
|
|
913
|
-
|
|
927
|
+
oe as DEFAULT_JANUS_URL,
|
|
928
|
+
$e as ForbiddenError,
|
|
914
929
|
i as JanusApiError,
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
930
|
+
me as NotFoundError,
|
|
931
|
+
le as UnauthorizedError,
|
|
932
|
+
pe as ValidationError,
|
|
918
933
|
o as buildClientScopedPaginatedUrl,
|
|
919
934
|
l as buildPaginatedUrl,
|
|
920
|
-
|
|
935
|
+
b as buildQueryString,
|
|
921
936
|
u as buildUrl,
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
937
|
+
de as createJanusApi,
|
|
938
|
+
he as isJanusApiError,
|
|
939
|
+
ve as isUnauthorizedError
|
|
925
940
|
};
|