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