@deliverart/sdk-js-stats 2.9.0
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 +263 -0
- package/dist/index.cjs +13968 -0
- package/dist/index.d.cts +827 -0
- package/dist/index.d.ts +827 -0
- package/dist/index.js +13936 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
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
|
+
## Exported Types
|
|
16
|
+
|
|
17
|
+
### Models
|
|
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.
|
|
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)
|
|
91
|
+
|
|
92
|
+
**Sort Parameters:**
|
|
93
|
+
- `order[day]?: 'asc' | 'desc'` - Sort by day
|
|
94
|
+
- `order[calculatedAt]?: 'asc' | 'desc'` - Sort by calculation date
|
|
95
|
+
|
|
96
|
+
**Pagination:**
|
|
97
|
+
- `page?: number` - Page number (default: 1)
|
|
98
|
+
|
|
99
|
+
### IRI Types
|
|
100
|
+
|
|
101
|
+
#### CourierDailyStatsIri
|
|
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
|
|
110
|
+
|
|
111
|
+
#### GetCourierDailyStats
|
|
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
|
+
```
|
|
127
|
+
|
|
128
|
+
**Query Parameters:**
|
|
129
|
+
See `CourierDailyStatsQueryParams` above for all available filters.
|
|
130
|
+
|
|
131
|
+
**Response:**
|
|
132
|
+
Returns a paginated list of `CourierDailyStats` objects.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
#### GetCourierDailyStatsDetails
|
|
137
|
+
Retrieve detailed information for a specific courier daily statistics entry.
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import { GetCourierDailyStatsDetails } from '@deliverart/sdk-js-stats';
|
|
141
|
+
|
|
142
|
+
const stats = await sdk.call(new GetCourierDailyStatsDetails('stats-123'));
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Parameters:**
|
|
146
|
+
- `courierDailyStatsId: string` (required) - The statistics ID
|
|
147
|
+
|
|
148
|
+
**Response:**
|
|
149
|
+
Returns a single `CourierDailyStats` object.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
#### GetCourierDailyStatsFromPointOfSale
|
|
154
|
+
Retrieve courier daily statistics for a specific point of sale.
|
|
155
|
+
|
|
156
|
+
```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
|
+
}));
|
|
166
|
+
```
|
|
167
|
+
|
|
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).
|
|
179
|
+
|
|
180
|
+
```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
|
+
}));
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Parameters:**
|
|
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
|
+
---
|
|
201
|
+
|
|
202
|
+
## Usage Examples
|
|
203
|
+
|
|
204
|
+
### Get Statistics for a Date Range
|
|
205
|
+
```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
|
+
}));
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Get Statistics by Point of Sale and Source
|
|
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
|
+
```
|
|
229
|
+
|
|
230
|
+
### Get Courier Performance
|
|
231
|
+
```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
|
+
});
|
|
245
|
+
```
|
|
246
|
+
|
|
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
|
+
## License
|
|
262
|
+
|
|
263
|
+
See the main SDK repository for license information.
|