@pelygo/janus 0.6.0 → 0.6.2
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 +45 -50
- package/USAGE.md +36 -42
- 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,33 +149,26 @@ await janus.auth.logout();
|
|
|
148
149
|
| `created_ts` | `string?` | ISO timestamp |
|
|
149
150
|
| `updated_ts` | `string?` | ISO timestamp |
|
|
150
151
|
|
|
151
|
-
###
|
|
152
|
+
### LegacyOrder (from `janus.orders.getAll` / `getById`)
|
|
152
153
|
|
|
153
|
-
|
|
154
|
+
`janus.orders` is the **general-purpose orders resource**. It hits `/legacy/orders` and returns `LegacyOrder` entities with ISO dates.
|
|
154
155
|
|
|
155
156
|
| Field | Type | Format | Description |
|
|
156
157
|
|-------|------|--------|-------------|
|
|
157
|
-
| `
|
|
158
|
-
| `
|
|
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 |
|
|
158
|
+
| `id` | `number` | — | Order ID |
|
|
159
|
+
| `reference` | `string` | — | Order reference number |
|
|
164
160
|
| `channel` | `string` | — | Sales channel name |
|
|
165
|
-
| `
|
|
166
|
-
| `
|
|
167
|
-
| `
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
```
|
|
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.
|
|
178
172
|
|
|
179
173
|
### LegacyDispatch
|
|
180
174
|
|
|
@@ -422,24 +416,18 @@ Extends `BaseEntity`.
|
|
|
422
416
|
| `csv` | `boolean` | No | Export as CSV instead of JSON |
|
|
423
417
|
| `group_by` | `string` | No | Group results by field |
|
|
424
418
|
|
|
425
|
-
###
|
|
419
|
+
### ClientScopedPaginatedQueryFilters (janus.orders.getAll)
|
|
420
|
+
|
|
421
|
+
`janus.orders.getAll` now uses the same `ClientScopedPaginatedQueryFilters` as other v2 endpoints:
|
|
426
422
|
|
|
427
423
|
| Param | Type | Required | Description |
|
|
428
424
|
|-------|------|----------|-------------|
|
|
429
|
-
| `clientId` | `number` | **Yes** | Client ID |
|
|
430
|
-
| `
|
|
431
|
-
| `
|
|
432
|
-
| `
|
|
433
|
-
| `
|
|
434
|
-
| `
|
|
435
|
-
| `created_to` | `string` | No | End date (ISO) |
|
|
436
|
-
| `channel` | `string` | No | Filter by sales channel |
|
|
437
|
-
| `destination` | `string` | No | Filter by destination |
|
|
438
|
-
| `courier` | `string` | No | Filter by courier name |
|
|
439
|
-
| `service` | `string` | No | Filter by courier service |
|
|
440
|
-
| `status` | `string` | No | Filter by order status |
|
|
441
|
-
| `query` | `string` | No | Free-text search |
|
|
442
|
-
| `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 |
|
|
443
431
|
|
|
444
432
|
### ReturnsSummaryFilters (janus.reports.returnsSummary / returnsSummaryCsv)
|
|
445
433
|
|
|
@@ -464,7 +452,7 @@ Extends `BaseEntity`.
|
|
|
464
452
|
| `createdFrom` | `string` | No | Start date (ISO) |
|
|
465
453
|
| `createdTo` | `string` | No | End date (ISO) |
|
|
466
454
|
|
|
467
|
-
### OrdersStatsFilters (janus.
|
|
455
|
+
### OrdersStatsFilters (janus.ordersMt.getStats — Microtrack only)
|
|
468
456
|
|
|
469
457
|
| Param | Type | Required | Description |
|
|
470
458
|
|-------|------|----------|-------------|
|
|
@@ -506,7 +494,22 @@ const { data, meta } = await janus.products.getAll({
|
|
|
506
494
|
// meta = { total_items, total_pages, current_page, page_size }
|
|
507
495
|
```
|
|
508
496
|
|
|
509
|
-
**
|
|
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:
|
|
510
513
|
|
|
511
514
|
```typescript
|
|
512
515
|
const returns = await janus.returns.query({
|
|
@@ -517,15 +520,6 @@ const returns = await janus.returns.query({
|
|
|
517
520
|
pageSize: 100,
|
|
518
521
|
csv: false,
|
|
519
522
|
});
|
|
520
|
-
|
|
521
|
-
const orders = await janus.orders.getAll({
|
|
522
|
-
clientId: 5,
|
|
523
|
-
created_at: '2024-01-01',
|
|
524
|
-
created_to: '2024-12-31',
|
|
525
|
-
status: 'dispatched',
|
|
526
|
-
order_column: 'created',
|
|
527
|
-
order_direction: 'DESC',
|
|
528
|
-
});
|
|
529
523
|
```
|
|
530
524
|
|
|
531
525
|
### CSV Export
|
|
@@ -628,7 +622,8 @@ Common codes: 400 (bad request/validation), 401 (unauthorized), 404 (not found).
|
|
|
628
622
|
### Date formats
|
|
629
623
|
- **Query params:** ISO 8601 format (`'2025-01-01'` or `'2025-01-01 12:00:00'`)
|
|
630
624
|
- **v2 response fields** (returns, stocks, etc.): ISO 8601 timestamps (`created_ts`, `updated_ts`)
|
|
631
|
-
- **Orders response fields
|
|
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.
|
|
632
627
|
- **CSV exports:** formatted as `DD-MM-YYYY HH:mm`
|
|
633
628
|
|
|
634
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,33 +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
|
-
|
|
206
|
+
`janus.orders` is the **general-purpose orders resource**. It hits `/legacy/orders` and returns `LegacyOrder` entities with ISO dates:
|
|
208
207
|
|
|
209
208
|
| Field | Type | Format | Description |
|
|
210
209
|
|-------|------|--------|-------------|
|
|
211
|
-
| `
|
|
212
|
-
| `
|
|
213
|
-
| `
|
|
214
|
-
| `
|
|
215
|
-
| `
|
|
216
|
-
| `
|
|
217
|
-
| `
|
|
218
|
-
| `
|
|
219
|
-
| `
|
|
220
|
-
| `
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
```
|
|
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`.
|
|
232
224
|
|
|
233
225
|
## Product Entity Fields (from /products endpoint)
|
|
234
226
|
|
|
@@ -297,10 +289,11 @@ const stats = await janus.reports.returnsStats(clientId);
|
|
|
297
289
|
// }
|
|
298
290
|
```
|
|
299
291
|
|
|
300
|
-
## OrdersStatsResponse Fields
|
|
292
|
+
## OrdersStatsResponse Fields (Microtrack only)
|
|
301
293
|
|
|
302
294
|
```js
|
|
303
|
-
|
|
295
|
+
// Microtrack only — use janus.ordersMt for stats
|
|
296
|
+
const stats = await janus.ordersMt.getStats({ clientId, dashboard: true });
|
|
304
297
|
// Returns a flat object with numeric counts — keys vary by data.
|
|
305
298
|
// Use Object.entries(stats) to iterate. Do NOT hardcode field names.
|
|
306
299
|
// Example: { total_orders: 150, dispatched: 120, processing: 15, ... }
|
|
@@ -318,7 +311,8 @@ Common codes: 400 (bad request/validation), 401 (unauthorized), 404 (not found).
|
|
|
318
311
|
### Date formats
|
|
319
312
|
- **Query params:** ISO 8601 (`'2025-01-01'` or `'2025-01-01 12:00:00'`)
|
|
320
313
|
- **v2 response fields** (returns, stocks, etc.): ISO 8601 timestamps (`created_ts`, `updated_ts`)
|
|
321
|
-
- **Orders response fields
|
|
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.
|
|
322
316
|
- **CSV exports:** formatted as `DD-MM-YYYY HH:mm`
|
|
323
317
|
|
|
324
318
|
### Pagination defaults
|