@deliverart/sdk-js-stats 2.14.10 → 2.14.14
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 +140 -200
- package/dist/index.cjs +1093 -22
- package/dist/index.d.cts +4720 -296
- package/dist/index.d.ts +4720 -296
- package/dist/index.js +1023 -21
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -12,252 +12,192 @@ 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 five daily stats families:
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
19
|
+
- `CustomerDailyStats`
|
|
20
|
+
- `CourierDailyStats`
|
|
21
|
+
- `DeliveryDailyStats`
|
|
22
|
+
- `MenuItemDailyStats`
|
|
23
|
+
- `OrderDailyStats`
|
|
72
24
|
|
|
73
|
-
|
|
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)
|
|
25
|
+
It also exposes a frontend-ready customer analytics endpoint:
|
|
79
26
|
|
|
80
|
-
|
|
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)
|
|
27
|
+
- `CustomerStatsOverviewResponse`
|
|
85
28
|
|
|
86
|
-
|
|
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)
|
|
29
|
+
Each family includes:
|
|
91
30
|
|
|
92
|
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
31
|
+
- a Zod model schema and inferred TypeScript type
|
|
32
|
+
- an IRI schema/type for detail resources
|
|
33
|
+
- request classes for collection and detail endpoints
|
|
34
|
+
- point-of-sale scoped collection requests where available
|
|
95
35
|
|
|
96
|
-
|
|
97
|
-
- `page?: number` - Page number (default: 1)
|
|
36
|
+
All daily buckets use the point of sale local day, exposed as `YYYY-MM-DD`.
|
|
98
37
|
|
|
99
|
-
|
|
38
|
+
## Available requests
|
|
100
39
|
|
|
101
|
-
|
|
102
|
-
```typescript
|
|
103
|
-
type CourierDailyStatsIri = string
|
|
104
|
-
```
|
|
105
|
-
Courier daily statistics IRI type (format: `/courier_daily_stats/:id`)
|
|
40
|
+
### Courier daily stats
|
|
106
41
|
|
|
107
|
-
|
|
42
|
+
- `GetCourierDailyStats`
|
|
43
|
+
- `GetCourierDailyStatsDetails`
|
|
44
|
+
- `GetCourierDailyStatsFromPointOfSale`
|
|
45
|
+
- `GetCourierDailyStatsFromUser`
|
|
108
46
|
|
|
109
|
-
###
|
|
47
|
+
### Customer daily stats
|
|
110
48
|
|
|
111
|
-
|
|
112
|
-
|
|
49
|
+
- `GetCustomerDailyStats`
|
|
50
|
+
- `GetCustomerDailyStatsDetails`
|
|
51
|
+
- `GetCustomerDailyStatsFromPointOfSale`
|
|
52
|
+
- `GetCustomerDailyStatsFromCustomer`
|
|
53
|
+
- `GetCustomerStatsOverview`
|
|
113
54
|
|
|
114
|
-
|
|
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
|
-
```
|
|
55
|
+
### Delivery daily stats
|
|
127
56
|
|
|
128
|
-
|
|
129
|
-
|
|
57
|
+
- `GetDeliveryDailyStats`
|
|
58
|
+
- `GetDeliveryDailyStatsDetails`
|
|
59
|
+
- `GetDeliveryDailyStatsFromPointOfSale`
|
|
130
60
|
|
|
131
|
-
|
|
132
|
-
Returns a paginated list of `CourierDailyStats` objects.
|
|
61
|
+
### Order daily stats
|
|
133
62
|
|
|
134
|
-
|
|
63
|
+
- `GetOrderDailyStats`
|
|
64
|
+
- `GetOrderDailyStatsDetails`
|
|
65
|
+
- `GetOrderDailyStatsFromPointOfSale`
|
|
135
66
|
|
|
136
|
-
|
|
137
|
-
Retrieve detailed information for a specific courier daily statistics entry.
|
|
67
|
+
### Menu item daily stats
|
|
138
68
|
|
|
139
|
-
|
|
140
|
-
|
|
69
|
+
- `GetMenuItemDailyStats`
|
|
70
|
+
- `GetMenuItemDailyStatsDetails`
|
|
71
|
+
- `GetMenuItemDailyStatsFromPointOfSale`
|
|
72
|
+
- `GetMenuItemDailyStatsFromMenuItem`
|
|
141
73
|
|
|
142
|
-
|
|
143
|
-
```
|
|
74
|
+
## Query support
|
|
144
75
|
|
|
145
|
-
|
|
146
|
-
- `courierDailyStatsId: string` (required) - The statistics ID
|
|
76
|
+
The package exposes typed query schemas for the filters currently supported by the API:
|
|
147
77
|
|
|
148
|
-
|
|
149
|
-
|
|
78
|
+
- exact filters on dimensions such as `pointOfSale`, `courierUser`, `menuItem`, `salesMode`, `type`, `orderType`, `source`, `partner`, `paymentMethod`, and `planningMode`
|
|
79
|
+
- exact filters on dimensions such as `customer`, `pointOfSale`, `courierUser`, `menuItem`, `salesMode`, `type`, `orderType`, `source`, `partner`, `paymentMethod`, and `planningMode`
|
|
80
|
+
- date filters such as `day[before]`, `day[strictly_after]`, `calculatedAt[after]`
|
|
81
|
+
- range filters for numeric KPIs such as `ordersCount[gte]`, `deliveryOrdersCount[lte]`, `totalAmount[gt]`
|
|
82
|
+
- sorting via `order[...]`
|
|
83
|
+
- pagination via `page`, `itemsPerPage`, and `pagination`
|
|
150
84
|
|
|
151
|
-
|
|
85
|
+
## Usage examples
|
|
152
86
|
|
|
153
|
-
|
|
154
|
-
Retrieve courier daily statistics for a specific point of sale.
|
|
87
|
+
### List courier daily stats
|
|
155
88
|
|
|
156
89
|
```typescript
|
|
157
|
-
import {
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
90
|
+
import { GetCourierDailyStats } from '@deliverart/sdk-js-stats'
|
|
91
|
+
|
|
92
|
+
const response = await sdk.call(
|
|
93
|
+
new GetCourierDailyStats({
|
|
94
|
+
query: {
|
|
95
|
+
source: 'application',
|
|
96
|
+
'day[after]': '2026-04-01',
|
|
97
|
+
'order[day]': 'desc',
|
|
98
|
+
},
|
|
99
|
+
}),
|
|
100
|
+
)
|
|
166
101
|
```
|
|
167
102
|
|
|
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).
|
|
103
|
+
### List customer daily stats for one customer
|
|
179
104
|
|
|
180
105
|
```typescript
|
|
181
|
-
import {
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
})
|
|
106
|
+
import { GetCustomerDailyStatsFromCustomer } from '@deliverart/sdk-js-stats'
|
|
107
|
+
|
|
108
|
+
const response = await sdk.call(
|
|
109
|
+
new GetCustomerDailyStatsFromCustomer('customer-123', {
|
|
110
|
+
query: {
|
|
111
|
+
source: 'application',
|
|
112
|
+
'day[after]': '2026-04-01',
|
|
113
|
+
'order[totalAmount]': 'desc',
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
)
|
|
191
117
|
```
|
|
192
118
|
|
|
193
|
-
|
|
194
|
-
- `userId: string` (required) - The user (courier) ID
|
|
195
|
-
- `query?: CourierDailyStatsQueryParams` (optional) - Query parameters for filtering
|
|
119
|
+
### List delivery daily stats for one point of sale
|
|
196
120
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
121
|
+
```typescript
|
|
122
|
+
import { GetDeliveryDailyStatsFromPointOfSale } from '@deliverart/sdk-js-stats'
|
|
123
|
+
|
|
124
|
+
const response = await sdk.call(
|
|
125
|
+
new GetDeliveryDailyStatsFromPointOfSale('pos-123', {
|
|
126
|
+
query: {
|
|
127
|
+
planningMode: 'PLANNED',
|
|
128
|
+
'totalDelaySeconds[gt]': 0,
|
|
129
|
+
'day[after]': '2026-04-01',
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
132
|
+
)
|
|
133
|
+
```
|
|
201
134
|
|
|
202
|
-
|
|
135
|
+
### List order daily stats
|
|
203
136
|
|
|
204
|
-
### Get Statistics for a Date Range
|
|
205
137
|
```typescript
|
|
206
|
-
import {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
138
|
+
import { GetOrderDailyStats } from '@deliverart/sdk-js-stats'
|
|
139
|
+
|
|
140
|
+
const response = await sdk.call(
|
|
141
|
+
new GetOrderDailyStats({
|
|
142
|
+
query: {
|
|
143
|
+
type: 'delivery',
|
|
144
|
+
paymentMethod: 'credit_card',
|
|
145
|
+
'totalAmount[gte]': 100,
|
|
146
|
+
'order[totalAmount]': 'desc',
|
|
147
|
+
},
|
|
148
|
+
}),
|
|
149
|
+
)
|
|
216
150
|
```
|
|
217
151
|
|
|
218
|
-
###
|
|
152
|
+
### List menu item daily stats for one point of sale
|
|
153
|
+
|
|
219
154
|
```typescript
|
|
220
|
-
import {
|
|
221
|
-
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
155
|
+
import { GetMenuItemDailyStatsFromPointOfSale } from '@deliverart/sdk-js-stats'
|
|
156
|
+
|
|
157
|
+
const response = await sdk.call(
|
|
158
|
+
new GetMenuItemDailyStatsFromPointOfSale('pos-123', {
|
|
159
|
+
query: {
|
|
160
|
+
orderType: 'delivery',
|
|
161
|
+
'quantitySold[gte]': 10,
|
|
162
|
+
'order[totalAmount]': 'desc',
|
|
163
|
+
},
|
|
164
|
+
}),
|
|
165
|
+
)
|
|
228
166
|
```
|
|
229
167
|
|
|
230
|
-
###
|
|
168
|
+
### Fetch one daily stats bucket
|
|
169
|
+
|
|
231
170
|
```typescript
|
|
232
|
-
import {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
171
|
+
import {
|
|
172
|
+
GetCustomerDailyStatsDetails,
|
|
173
|
+
GetCourierDailyStatsDetails,
|
|
174
|
+
GetDeliveryDailyStatsDetails,
|
|
175
|
+
GetMenuItemDailyStatsDetails,
|
|
176
|
+
GetOrderDailyStatsDetails,
|
|
177
|
+
} from '@deliverart/sdk-js-stats'
|
|
178
|
+
|
|
179
|
+
await sdk.call(new GetCustomerDailyStatsDetails('customer-stats-uuid'))
|
|
180
|
+
await sdk.call(new GetCourierDailyStatsDetails('courier-stats-uuid'))
|
|
181
|
+
await sdk.call(new GetDeliveryDailyStatsDetails('delivery-stats-uuid'))
|
|
182
|
+
await sdk.call(new GetMenuItemDailyStatsDetails('menu-item-stats-uuid'))
|
|
183
|
+
await sdk.call(new GetOrderDailyStatsDetails('order-stats-uuid'))
|
|
245
184
|
```
|
|
246
185
|
|
|
247
|
-
###
|
|
186
|
+
### Fetch customer stats overview
|
|
187
|
+
|
|
248
188
|
```typescript
|
|
249
|
-
import {
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
189
|
+
import { GetCustomerStatsOverview } from '@deliverart/sdk-js-stats'
|
|
190
|
+
|
|
191
|
+
const overview = await sdk.call(
|
|
192
|
+
new GetCustomerStatsOverview('customer-123', {
|
|
193
|
+
query: {
|
|
194
|
+
'day[after]': '2026-04-01',
|
|
195
|
+
source: 'application',
|
|
196
|
+
},
|
|
197
|
+
}),
|
|
198
|
+
)
|
|
257
199
|
```
|
|
258
200
|
|
|
259
|
-
---
|
|
260
|
-
|
|
261
201
|
## License
|
|
262
202
|
|
|
263
203
|
See the main SDK repository for license information.
|