@deliverart/sdk-js-stats 2.14.9 → 2.14.11
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 +80 -213
- package/dist/index.cjs +378 -22
- package/dist/index.d.cts +1423 -120
- package/dist/index.d.ts +1423 -120
- package/dist/index.js +350 -19
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -12,252 +12,119 @@ pnpm add @deliverart/sdk-js-stats @deliverart/sdk-js-core
|
|
|
12
12
|
yarn add @deliverart/sdk-js-stats @deliverart/sdk-js-core
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## What this package exports
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
The package now exposes three daily stats families:
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
id: string
|
|
23
|
-
day: string
|
|
24
|
-
pointOfSale?: string
|
|
25
|
-
courierUser?: string
|
|
26
|
-
source: OrderSource
|
|
27
|
-
partner: OrderPartner | null
|
|
28
|
-
paymentMethod: PaymentMethod | null
|
|
29
|
-
ordersCount: number
|
|
30
|
-
totalCountableItems: number
|
|
31
|
-
totalAmount: string
|
|
32
|
-
calculatedAt: string
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
Daily statistics for courier deliveries.
|
|
36
|
-
|
|
37
|
-
**Properties:**
|
|
38
|
-
- `id: string` - Unique statistics identifier
|
|
39
|
-
- `day: string` - Date in YYYY-MM-DD format
|
|
40
|
-
- `pointOfSale?: string` - Point of sale IRI (optional)
|
|
41
|
-
- `courierUser?: string` - Courier user IRI (optional)
|
|
42
|
-
- `source: OrderSource` - Order source ('application', 'ecommerce', 'partner')
|
|
43
|
-
- `partner: OrderPartner | null` - Partner identifier (nullable)
|
|
44
|
-
- `paymentMethod: PaymentMethod | null` - Payment method used (nullable)
|
|
45
|
-
- `ordersCount: number` - Total number of orders
|
|
46
|
-
- `totalCountableItems: number` - Total number of countable items
|
|
47
|
-
- `totalAmount: string` - Total amount (monetary value as string)
|
|
48
|
-
- `calculatedAt: string` - Calculation timestamp (ISO 8601)
|
|
49
|
-
|
|
50
|
-
#### CourierDailyStatsQueryParams
|
|
51
|
-
```typescript
|
|
52
|
-
interface CourierDailyStatsQueryParams {
|
|
53
|
-
pointOfSale?: string | string[]
|
|
54
|
-
courierUser?: string | string[]
|
|
55
|
-
partner?: OrderPartner | OrderPartner[]
|
|
56
|
-
source?: OrderSource | OrderSource[]
|
|
57
|
-
paymentMethod?: PaymentMethod | PaymentMethod[]
|
|
58
|
-
'day[before]'?: string
|
|
59
|
-
'day[strictly_before]'?: string
|
|
60
|
-
'day[after]'?: string
|
|
61
|
-
'day[strictly_after]'?: string
|
|
62
|
-
'calculatedAt[before]'?: string
|
|
63
|
-
'calculatedAt[strictly_before]'?: string
|
|
64
|
-
'calculatedAt[after]'?: string
|
|
65
|
-
'calculatedAt[strictly_after]'?: string
|
|
66
|
-
'order[day]'?: 'asc' | 'desc'
|
|
67
|
-
'order[calculatedAt]'?: 'asc' | 'desc'
|
|
68
|
-
page?: number
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
Query parameters for filtering and sorting courier daily statistics.
|
|
72
|
-
|
|
73
|
-
**Filter Parameters:**
|
|
74
|
-
- `pointOfSale?: string | string[]` - Filter by point of sale IRI(s)
|
|
75
|
-
- `courierUser?: string | string[]` - Filter by courier user IRI(s)
|
|
76
|
-
- `partner?: OrderPartner | OrderPartner[]` - Filter by partner(s)
|
|
77
|
-
- `source?: OrderSource | OrderSource[]` - Filter by order source(s)
|
|
78
|
-
- `paymentMethod?: PaymentMethod | PaymentMethod[]` - Filter by payment method(s)
|
|
79
|
-
|
|
80
|
-
**Date Range Filters:**
|
|
81
|
-
- `day[before]?: string` - Days before (inclusive)
|
|
82
|
-
- `day[strictly_before]?: string` - Days strictly before (exclusive)
|
|
83
|
-
- `day[after]?: string` - Days after (inclusive)
|
|
84
|
-
- `day[strictly_after]?: string` - Days strictly after (exclusive)
|
|
85
|
-
|
|
86
|
-
**Calculation Date Range Filters:**
|
|
87
|
-
- `calculatedAt[before]?: string` - Calculated before (inclusive)
|
|
88
|
-
- `calculatedAt[strictly_before]?: string` - Calculated strictly before (exclusive)
|
|
89
|
-
- `calculatedAt[after]?: string` - Calculated after (inclusive)
|
|
90
|
-
- `calculatedAt[strictly_after]?: string` - Calculated strictly after (exclusive)
|
|
19
|
+
- `CourierDailyStats`
|
|
20
|
+
- `DeliveryDailyStats`
|
|
21
|
+
- `OrderDailyStats`
|
|
91
22
|
|
|
92
|
-
|
|
93
|
-
- `order[day]?: 'asc' | 'desc'` - Sort by day
|
|
94
|
-
- `order[calculatedAt]?: 'asc' | 'desc'` - Sort by calculation date
|
|
23
|
+
Each family includes:
|
|
95
24
|
|
|
96
|
-
|
|
97
|
-
-
|
|
25
|
+
- a Zod model schema and inferred TypeScript type
|
|
26
|
+
- an IRI schema/type for detail resources
|
|
27
|
+
- request classes for collection and detail endpoints
|
|
28
|
+
- point-of-sale scoped collection requests where available
|
|
98
29
|
|
|
99
|
-
|
|
30
|
+
All daily buckets use the point of sale local day, exposed as `YYYY-MM-DD`.
|
|
100
31
|
|
|
101
|
-
|
|
102
|
-
```typescript
|
|
103
|
-
type CourierDailyStatsIri = string
|
|
104
|
-
```
|
|
105
|
-
Courier daily statistics IRI type (format: `/courier_daily_stats/:id`)
|
|
106
|
-
|
|
107
|
-
## Available Requests
|
|
108
|
-
|
|
109
|
-
### Courier Daily Statistics
|
|
32
|
+
## Available requests
|
|
110
33
|
|
|
111
|
-
|
|
112
|
-
Retrieve a list of courier daily statistics with filtering and pagination.
|
|
113
|
-
|
|
114
|
-
```typescript
|
|
115
|
-
import { GetCourierDailyStats } from '@deliverart/sdk-js-stats';
|
|
116
|
-
|
|
117
|
-
const stats = await sdk.call(new GetCourierDailyStats({
|
|
118
|
-
query: {
|
|
119
|
-
'day[after]': '2024-01-01',
|
|
120
|
-
'day[before]': '2024-12-31',
|
|
121
|
-
source: 'application',
|
|
122
|
-
'order[day]': 'desc',
|
|
123
|
-
page: 1
|
|
124
|
-
}
|
|
125
|
-
}));
|
|
126
|
-
```
|
|
34
|
+
### Courier daily stats
|
|
127
35
|
|
|
128
|
-
|
|
129
|
-
|
|
36
|
+
- `GetCourierDailyStats`
|
|
37
|
+
- `GetCourierDailyStatsDetails`
|
|
38
|
+
- `GetCourierDailyStatsFromPointOfSale`
|
|
39
|
+
- `GetCourierDailyStatsFromUser`
|
|
130
40
|
|
|
131
|
-
|
|
132
|
-
Returns a paginated list of `CourierDailyStats` objects.
|
|
41
|
+
### Delivery daily stats
|
|
133
42
|
|
|
134
|
-
|
|
43
|
+
- `GetDeliveryDailyStats`
|
|
44
|
+
- `GetDeliveryDailyStatsDetails`
|
|
45
|
+
- `GetDeliveryDailyStatsFromPointOfSale`
|
|
135
46
|
|
|
136
|
-
|
|
137
|
-
Retrieve detailed information for a specific courier daily statistics entry.
|
|
47
|
+
### Order daily stats
|
|
138
48
|
|
|
139
|
-
|
|
140
|
-
|
|
49
|
+
- `GetOrderDailyStats`
|
|
50
|
+
- `GetOrderDailyStatsDetails`
|
|
51
|
+
- `GetOrderDailyStatsFromPointOfSale`
|
|
141
52
|
|
|
142
|
-
|
|
143
|
-
```
|
|
53
|
+
## Query support
|
|
144
54
|
|
|
145
|
-
|
|
146
|
-
- `courierDailyStatsId: string` (required) - The statistics ID
|
|
55
|
+
The package exposes typed query schemas for the filters currently supported by the API:
|
|
147
56
|
|
|
148
|
-
|
|
149
|
-
|
|
57
|
+
- exact filters on dimensions such as `pointOfSale`, `courierUser`, `type`, `source`, `partner`, `paymentMethod`, and `planningMode`
|
|
58
|
+
- date filters such as `day[before]`, `day[strictly_after]`, `calculatedAt[after]`
|
|
59
|
+
- range filters for numeric KPIs such as `ordersCount[gte]`, `deliveryOrdersCount[lte]`, `totalAmount[gt]`
|
|
60
|
+
- sorting via `order[...]`
|
|
61
|
+
- pagination via `page`, `itemsPerPage`, and `pagination`
|
|
150
62
|
|
|
151
|
-
|
|
63
|
+
## Usage examples
|
|
152
64
|
|
|
153
|
-
|
|
154
|
-
Retrieve courier daily statistics for a specific point of sale.
|
|
65
|
+
### List courier daily stats
|
|
155
66
|
|
|
156
67
|
```typescript
|
|
157
|
-
import {
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
68
|
+
import { GetCourierDailyStats } from '@deliverart/sdk-js-stats'
|
|
69
|
+
|
|
70
|
+
const response = await sdk.call(
|
|
71
|
+
new GetCourierDailyStats({
|
|
72
|
+
query: {
|
|
73
|
+
source: 'application',
|
|
74
|
+
'day[after]': '2026-04-01',
|
|
75
|
+
'order[day]': 'desc',
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
)
|
|
166
79
|
```
|
|
167
80
|
|
|
168
|
-
|
|
169
|
-
- `pointOfSaleId: string` (required) - The point of sale ID
|
|
170
|
-
- `query?: CourierDailyStatsQueryParams` (optional) - Query parameters for filtering
|
|
171
|
-
|
|
172
|
-
**Response:**
|
|
173
|
-
Returns a paginated list of `CourierDailyStats` objects for the specified point of sale.
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
#### GetCourierDailyStatsFromUser
|
|
178
|
-
Retrieve courier daily statistics for a specific user (courier).
|
|
81
|
+
### List delivery daily stats for one point of sale
|
|
179
82
|
|
|
180
83
|
```typescript
|
|
181
|
-
import {
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
})
|
|
84
|
+
import { GetDeliveryDailyStatsFromPointOfSale } from '@deliverart/sdk-js-stats'
|
|
85
|
+
|
|
86
|
+
const response = await sdk.call(
|
|
87
|
+
new GetDeliveryDailyStatsFromPointOfSale('pos-123', {
|
|
88
|
+
query: {
|
|
89
|
+
planningMode: 'PLANNED',
|
|
90
|
+
'totalDelaySeconds[gt]': 0,
|
|
91
|
+
'day[after]': '2026-04-01',
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
)
|
|
191
95
|
```
|
|
192
96
|
|
|
193
|
-
|
|
194
|
-
- `userId: string` (required) - The user (courier) ID
|
|
195
|
-
- `query?: CourierDailyStatsQueryParams` (optional) - Query parameters for filtering
|
|
196
|
-
|
|
197
|
-
**Response:**
|
|
198
|
-
Returns a paginated list of `CourierDailyStats` objects for the specified courier.
|
|
199
|
-
|
|
200
|
-
---
|
|
97
|
+
### List order daily stats
|
|
201
98
|
|
|
202
|
-
## Usage Examples
|
|
203
|
-
|
|
204
|
-
### Get Statistics for a Date Range
|
|
205
99
|
```typescript
|
|
206
|
-
import {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
100
|
+
import { GetOrderDailyStats } from '@deliverart/sdk-js-stats'
|
|
101
|
+
|
|
102
|
+
const response = await sdk.call(
|
|
103
|
+
new GetOrderDailyStats({
|
|
104
|
+
query: {
|
|
105
|
+
type: 'delivery',
|
|
106
|
+
paymentMethod: 'credit_card',
|
|
107
|
+
'totalAmount[gte]': 100,
|
|
108
|
+
'order[totalAmount]': 'desc',
|
|
109
|
+
},
|
|
110
|
+
}),
|
|
111
|
+
)
|
|
216
112
|
```
|
|
217
113
|
|
|
218
|
-
###
|
|
219
|
-
```typescript
|
|
220
|
-
import { GetCourierDailyStatsFromPointOfSale } from '@deliverart/sdk-js-stats';
|
|
221
|
-
|
|
222
|
-
const posStats = await sdk.call(new GetCourierDailyStatsFromPointOfSale('pos-123', {
|
|
223
|
-
query: {
|
|
224
|
-
source: ['application', 'ecommerce'],
|
|
225
|
-
'day[after]': '2024-01-01'
|
|
226
|
-
}
|
|
227
|
-
}));
|
|
228
|
-
```
|
|
114
|
+
### Fetch one daily stats bucket
|
|
229
115
|
|
|
230
|
-
### Get Courier Performance
|
|
231
116
|
```typescript
|
|
232
|
-
import {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
// Analyze courier performance
|
|
242
|
-
courierStats.member.forEach(stat => {
|
|
243
|
-
console.log(`${stat.day}: ${stat.ordersCount} orders, ${stat.totalAmount} revenue`);
|
|
244
|
-
});
|
|
117
|
+
import {
|
|
118
|
+
GetCourierDailyStatsDetails,
|
|
119
|
+
GetDeliveryDailyStatsDetails,
|
|
120
|
+
GetOrderDailyStatsDetails,
|
|
121
|
+
} from '@deliverart/sdk-js-stats'
|
|
122
|
+
|
|
123
|
+
await sdk.call(new GetCourierDailyStatsDetails('courier-stats-uuid'))
|
|
124
|
+
await sdk.call(new GetDeliveryDailyStatsDetails('delivery-stats-uuid'))
|
|
125
|
+
await sdk.call(new GetOrderDailyStatsDetails('order-stats-uuid'))
|
|
245
126
|
```
|
|
246
127
|
|
|
247
|
-
### Filter by Payment Method
|
|
248
|
-
```typescript
|
|
249
|
-
import { GetCourierDailyStats } from '@deliverart/sdk-js-stats';
|
|
250
|
-
|
|
251
|
-
const cashStats = await sdk.call(new GetCourierDailyStats({
|
|
252
|
-
query: {
|
|
253
|
-
paymentMethod: 'cash',
|
|
254
|
-
'day[after]': '2024-01-01'
|
|
255
|
-
}
|
|
256
|
-
}));
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
---
|
|
260
|
-
|
|
261
128
|
## License
|
|
262
129
|
|
|
263
130
|
See the main SDK repository for license information.
|