@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 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
- ## Exported Types
15
+ ## What this package exports
16
16
 
17
- ### Models
17
+ The package now exposes five daily stats families:
18
18
 
19
- #### CourierDailyStats
20
- ```typescript
21
- interface CourierDailyStats {
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.
19
+ - `CustomerDailyStats`
20
+ - `CourierDailyStats`
21
+ - `DeliveryDailyStats`
22
+ - `MenuItemDailyStats`
23
+ - `OrderDailyStats`
72
24
 
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)
25
+ It also exposes a frontend-ready customer analytics endpoint:
79
26
 
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)
27
+ - `CustomerStatsOverviewResponse`
85
28
 
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)
29
+ Each family includes:
91
30
 
92
- **Sort Parameters:**
93
- - `order[day]?: 'asc' | 'desc'` - Sort by day
94
- - `order[calculatedAt]?: 'asc' | 'desc'` - Sort by calculation date
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
- **Pagination:**
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
- ### IRI Types
38
+ ## Available requests
100
39
 
101
- #### CourierDailyStatsIri
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
- ## Available Requests
42
+ - `GetCourierDailyStats`
43
+ - `GetCourierDailyStatsDetails`
44
+ - `GetCourierDailyStatsFromPointOfSale`
45
+ - `GetCourierDailyStatsFromUser`
108
46
 
109
- ### Courier Daily Statistics
47
+ ### Customer daily stats
110
48
 
111
- #### GetCourierDailyStats
112
- Retrieve a list of courier daily statistics with filtering and pagination.
49
+ - `GetCustomerDailyStats`
50
+ - `GetCustomerDailyStatsDetails`
51
+ - `GetCustomerDailyStatsFromPointOfSale`
52
+ - `GetCustomerDailyStatsFromCustomer`
53
+ - `GetCustomerStatsOverview`
113
54
 
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
- ```
55
+ ### Delivery daily stats
127
56
 
128
- **Query Parameters:**
129
- See `CourierDailyStatsQueryParams` above for all available filters.
57
+ - `GetDeliveryDailyStats`
58
+ - `GetDeliveryDailyStatsDetails`
59
+ - `GetDeliveryDailyStatsFromPointOfSale`
130
60
 
131
- **Response:**
132
- Returns a paginated list of `CourierDailyStats` objects.
61
+ ### Order daily stats
133
62
 
134
- ---
63
+ - `GetOrderDailyStats`
64
+ - `GetOrderDailyStatsDetails`
65
+ - `GetOrderDailyStatsFromPointOfSale`
135
66
 
136
- #### GetCourierDailyStatsDetails
137
- Retrieve detailed information for a specific courier daily statistics entry.
67
+ ### Menu item daily stats
138
68
 
139
- ```typescript
140
- import { GetCourierDailyStatsDetails } from '@deliverart/sdk-js-stats';
69
+ - `GetMenuItemDailyStats`
70
+ - `GetMenuItemDailyStatsDetails`
71
+ - `GetMenuItemDailyStatsFromPointOfSale`
72
+ - `GetMenuItemDailyStatsFromMenuItem`
141
73
 
142
- const stats = await sdk.call(new GetCourierDailyStatsDetails('stats-123'));
143
- ```
74
+ ## Query support
144
75
 
145
- **Parameters:**
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
- **Response:**
149
- Returns a single `CourierDailyStats` object.
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
- #### GetCourierDailyStatsFromPointOfSale
154
- Retrieve courier daily statistics for a specific point of sale.
87
+ ### List courier daily stats
155
88
 
156
89
  ```typescript
157
- import { GetCourierDailyStatsFromPointOfSale } from '@deliverart/sdk-js-stats';
158
-
159
- const stats = await sdk.call(new GetCourierDailyStatsFromPointOfSale('pos-123', {
160
- query: {
161
- 'day[after]': '2024-01-01',
162
- source: 'application',
163
- page: 1
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
- **Parameters:**
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 { GetCourierDailyStatsFromUser } from '@deliverart/sdk-js-stats';
182
-
183
- const stats = await sdk.call(new GetCourierDailyStatsFromUser('user-123', {
184
- query: {
185
- 'day[after]': '2024-01-01',
186
- 'day[before]': '2024-01-31',
187
- 'order[day]': 'asc',
188
- page: 1
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
- **Parameters:**
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
- **Response:**
198
- Returns a paginated list of `CourierDailyStats` objects for the specified courier.
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
- ## Usage Examples
135
+ ### List order daily stats
203
136
 
204
- ### Get Statistics for a Date Range
205
137
  ```typescript
206
- import { GetCourierDailyStats } from '@deliverart/sdk-js-stats';
207
-
208
- // Get all stats for January 2024
209
- const januaryStats = await sdk.call(new GetCourierDailyStats({
210
- query: {
211
- 'day[after]': '2024-01-01',
212
- 'day[strictly_before]': '2024-02-01',
213
- 'order[day]': 'asc'
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
- ### Get Statistics by Point of Sale and Source
152
+ ### List menu item daily stats for one point of sale
153
+
219
154
  ```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
- }));
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
- ### Get Courier Performance
168
+ ### Fetch one daily stats bucket
169
+
231
170
  ```typescript
232
- import { GetCourierDailyStatsFromUser } from '@deliverart/sdk-js-stats';
233
-
234
- const courierStats = await sdk.call(new GetCourierDailyStatsFromUser('courier-456', {
235
- query: {
236
- 'day[after]': '2024-01-01',
237
- 'order[day]': 'desc'
238
- }
239
- }));
240
-
241
- // Analyze courier performance
242
- courierStats.member.forEach(stat => {
243
- console.log(`${stat.day}: ${stat.ordersCount} orders, ${stat.totalAmount} revenue`);
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
- ### Filter by Payment Method
186
+ ### Fetch customer stats overview
187
+
248
188
  ```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
- }));
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.