@sales-planner/http-client 0.17.1 → 0.17.2
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 +271 -11
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -122,20 +122,280 @@ try {
|
|
|
122
122
|
|
|
123
123
|
## Types
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
### Query & Context Types
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
// Required for all shop-scoped operations
|
|
129
|
+
interface ShopContextParams {
|
|
130
|
+
shop_id: number;
|
|
131
|
+
tenant_id: number;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Pagination (all getAll methods support this)
|
|
135
|
+
interface PaginationQuery {
|
|
136
|
+
limit?: number; // 1-1000, default: 100
|
|
137
|
+
offset?: number; // default: 0
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Period filtering (sales history, leftovers, competitor sales)
|
|
141
|
+
interface PeriodQuery {
|
|
142
|
+
period_from?: string; // YYYY-MM format
|
|
143
|
+
period_to?: string; // YYYY-MM format
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Paginated response (returned by all getAll methods)
|
|
147
|
+
interface PaginatedResponse<T> {
|
|
148
|
+
items: T[];
|
|
149
|
+
total: number;
|
|
150
|
+
limit: number;
|
|
151
|
+
offset: number;
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Entity Types
|
|
156
|
+
|
|
157
|
+
All entities extend base interfaces:
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
// Base for shop-scoped entities without code (e.g., SalesHistory)
|
|
161
|
+
interface ShopScopedBaseEntity {
|
|
162
|
+
id: number;
|
|
163
|
+
shop_id: number;
|
|
164
|
+
tenant_id: number;
|
|
165
|
+
created_at: Date;
|
|
166
|
+
updated_at: Date;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Base for coded entities (e.g., SKUs, Brands, Categories)
|
|
170
|
+
interface CodedShopScopedEntity extends ShopScopedBaseEntity {
|
|
171
|
+
code: string;
|
|
172
|
+
title: string;
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### System Entities
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
interface User {
|
|
180
|
+
id: number;
|
|
181
|
+
email: string;
|
|
182
|
+
name: string;
|
|
183
|
+
default_shop_id: number | null;
|
|
184
|
+
created_at: Date;
|
|
185
|
+
updated_at: Date;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
interface Tenant {
|
|
189
|
+
id: number;
|
|
190
|
+
title: string;
|
|
191
|
+
owner_id: number | null;
|
|
192
|
+
created_by: number;
|
|
193
|
+
created_at: Date;
|
|
194
|
+
updated_at: Date;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
interface Shop {
|
|
198
|
+
id: number;
|
|
199
|
+
title: string;
|
|
200
|
+
tenant_id: number;
|
|
201
|
+
created_at: Date;
|
|
202
|
+
updated_at: Date;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
interface Role {
|
|
206
|
+
id: number;
|
|
207
|
+
name: string;
|
|
208
|
+
description: string | null;
|
|
209
|
+
created_at: Date;
|
|
210
|
+
updated_at: Date;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
interface ApiKey {
|
|
214
|
+
id: number;
|
|
215
|
+
user_id: number;
|
|
216
|
+
key: string;
|
|
217
|
+
name: string | null;
|
|
218
|
+
expires_at: Date | null;
|
|
219
|
+
last_used_at: Date | null;
|
|
220
|
+
created_at: Date;
|
|
221
|
+
updated_at: Date;
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### Shop Data Entities
|
|
226
|
+
|
|
227
|
+
Coded entities (`Sku`, `Brand`, `Category`, `Group`, `Status`, `Supplier`, `Warehouse`, `Marketplace`) extend `CodedShopScopedEntity`:
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
interface Sku extends CodedShopScopedEntity {
|
|
231
|
+
title2?: string | null;
|
|
232
|
+
category_id?: number | null;
|
|
233
|
+
group_id?: number | null;
|
|
234
|
+
status_id?: number | null;
|
|
235
|
+
supplier_id?: number | null;
|
|
236
|
+
}
|
|
237
|
+
// Brand, Category, Group, Status, Supplier, Warehouse, Marketplace
|
|
238
|
+
// all have just: id, code, title, shop_id, tenant_id, created_at, updated_at
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
#### Time-Series Entities
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
interface SalesHistory {
|
|
245
|
+
id: number;
|
|
246
|
+
sku_id: number;
|
|
247
|
+
marketplace_id: number;
|
|
248
|
+
period: string; // YYYY-MM format
|
|
249
|
+
quantity: number;
|
|
250
|
+
shop_id: number;
|
|
251
|
+
tenant_id: number;
|
|
252
|
+
created_at: Date;
|
|
253
|
+
updated_at: Date;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
interface Leftover {
|
|
257
|
+
id: number;
|
|
258
|
+
sku_id: number;
|
|
259
|
+
warehouse_id: number;
|
|
260
|
+
period: string; // YYYY-MM format
|
|
261
|
+
quantity: number;
|
|
262
|
+
shop_id: number;
|
|
263
|
+
tenant_id: number;
|
|
264
|
+
created_at: Date;
|
|
265
|
+
updated_at: Date;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
interface SeasonalCoefficient {
|
|
269
|
+
id: number;
|
|
270
|
+
group_id: number;
|
|
271
|
+
month: number; // 1-12
|
|
272
|
+
coefficient: number;
|
|
273
|
+
shop_id: number;
|
|
274
|
+
tenant_id: number;
|
|
275
|
+
created_at: Date;
|
|
276
|
+
updated_at: Date;
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
#### Competitor Entities
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
interface CompetitorProduct {
|
|
284
|
+
id: number;
|
|
285
|
+
marketplace_id: number;
|
|
286
|
+
marketplace_product_id: string; // BIGINT as string
|
|
287
|
+
title: string | null;
|
|
288
|
+
brand: string | null;
|
|
289
|
+
shop_id: number;
|
|
290
|
+
tenant_id: number;
|
|
291
|
+
created_at: Date;
|
|
292
|
+
updated_at: Date;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
interface CompetitorSale {
|
|
296
|
+
id: number;
|
|
297
|
+
competitor_product_id: number;
|
|
298
|
+
period: string; // YYYY-MM format
|
|
299
|
+
quantity: number;
|
|
300
|
+
shop_id: number;
|
|
301
|
+
tenant_id: number;
|
|
302
|
+
created_at: Date;
|
|
303
|
+
updated_at: Date;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
interface SkuCompetitorMapping {
|
|
307
|
+
id: number;
|
|
308
|
+
sku_id: number;
|
|
309
|
+
competitor_product_id: number;
|
|
310
|
+
shop_id: number;
|
|
311
|
+
tenant_id: number;
|
|
312
|
+
created_at: Date;
|
|
313
|
+
updated_at: Date;
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Available entity types summary:
|
|
318
|
+
- `User`, `Tenant`, `Shop`, `Role`, `ApiKey` - system entities
|
|
319
|
+
- `Sku`, `Brand`, `Category`, `Group`, `Status`, `Supplier`, `Warehouse`, `Marketplace` - shop data
|
|
320
|
+
- `SalesHistory`, `Leftover`, `SeasonalCoefficient` - time-series data
|
|
321
|
+
- `CompetitorProduct`, `CompetitorSale`, `SkuCompetitorMapping` - competitor data
|
|
322
|
+
|
|
323
|
+
### Import/Export Types
|
|
324
|
+
|
|
325
|
+
Import items use string codes for references (auto-resolved to IDs):
|
|
326
|
+
|
|
327
|
+
```typescript
|
|
328
|
+
interface ImportSkuItem {
|
|
329
|
+
code: string;
|
|
330
|
+
title: string;
|
|
331
|
+
title2?: string;
|
|
332
|
+
category?: string; // category code, auto-resolved
|
|
333
|
+
group?: string; // group code, auto-resolved
|
|
334
|
+
status?: string; // status code, auto-resolved
|
|
335
|
+
supplier?: string; // supplier code, auto-resolved
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Import results include auto-creation counts
|
|
339
|
+
interface SkuImportResult extends ImportResult {
|
|
340
|
+
created: number;
|
|
341
|
+
updated: number;
|
|
342
|
+
errors: string[];
|
|
343
|
+
categories_created: number;
|
|
344
|
+
groups_created: number;
|
|
345
|
+
statuses_created: number;
|
|
346
|
+
suppliers_created: number;
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### All Exported Types
|
|
126
351
|
|
|
127
352
|
```typescript
|
|
128
353
|
import type {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
354
|
+
// Query & Response
|
|
355
|
+
ShopContextParams, PaginationQuery, PaginatedResponse, PeriodQuery,
|
|
356
|
+
SalesHistoryQuery, LeftoverQuery, CompetitorSaleQuery, GetUserRolesQuery,
|
|
357
|
+
|
|
358
|
+
// System Entities
|
|
359
|
+
User, Tenant, Shop, Role, ApiKey, UserRoleResponse,
|
|
360
|
+
|
|
361
|
+
// Shop Data Entities
|
|
362
|
+
Sku, Brand, Category, Group, Status, Supplier, Warehouse, Marketplace,
|
|
363
|
+
|
|
364
|
+
// Time-Series Entities
|
|
365
|
+
SalesHistory, Leftover, SeasonalCoefficient,
|
|
366
|
+
|
|
367
|
+
// Competitor Entities
|
|
368
|
+
CompetitorProduct, CompetitorSale, SkuCompetitorMapping,
|
|
369
|
+
|
|
370
|
+
// User/Me Response Types
|
|
371
|
+
UserWithRolesAndTenants, UserRole, TenantInfo, ShopInfo,
|
|
372
|
+
|
|
373
|
+
// Create/Update Requests
|
|
374
|
+
CreateSkuRequest, UpdateSkuRequest,
|
|
375
|
+
CreateUserRequest, UpdateUserRequest,
|
|
376
|
+
CreateTenantRequest, UpdateTenantRequest,
|
|
377
|
+
CreateShopRequest, UpdateShopRequest,
|
|
378
|
+
CreateApiKeyRequest,
|
|
379
|
+
|
|
380
|
+
// Import Items (use string codes, auto-resolved)
|
|
381
|
+
ImportSkuItem, ImportSalesHistoryItem, ImportLeftoverItem,
|
|
382
|
+
ImportSeasonalCoefficientItem, ImportSkuCompetitorMappingItem,
|
|
383
|
+
ImportCompetitorProductItem, ImportCompetitorSaleItem,
|
|
384
|
+
ImportBrandItem, ImportCategoryItem, ImportGroupItem,
|
|
385
|
+
ImportStatusItem, ImportSupplierItem, ImportWarehouseItem, ImportMarketplaceItem,
|
|
386
|
+
|
|
387
|
+
// Export Items
|
|
388
|
+
SkuExportItem, SalesHistoryExportItem, LeftoverExportItem,
|
|
389
|
+
SeasonalCoefficientExportItem, SkuCompetitorMappingExportItem,
|
|
390
|
+
CompetitorProductExportItem, CompetitorSaleExportItem,
|
|
391
|
+
BrandExportItem, CategoryExportItem, GroupExportItem,
|
|
392
|
+
StatusExportItem, SupplierExportItem, WarehouseExportItem, MarketplaceExportItem,
|
|
393
|
+
|
|
394
|
+
// Results
|
|
395
|
+
ImportResult, SkuImportResult, SalesHistoryImportResult, DeleteDataResult,
|
|
396
|
+
|
|
397
|
+
// Metadata (for UI documentation)
|
|
398
|
+
EntitiesMetadata, EntityMetadata, EntityFieldMetadata, FieldType,
|
|
139
399
|
} from '@sales-planner/http-client';
|
|
140
400
|
```
|
|
141
401
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sales-planner/http-client",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"description": "HTTP client for Sales Planner API",
|
|
5
5
|
"author": "Damir Manapov",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,17 +23,17 @@
|
|
|
23
23
|
"dist",
|
|
24
24
|
"README.md"
|
|
25
25
|
],
|
|
26
|
-
"dependencies": {
|
|
27
|
-
"@sales-planner/shared": "0.15.1"
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"typescript": "^5.7.3"
|
|
31
|
-
},
|
|
32
26
|
"scripts": {
|
|
33
27
|
"build": "tsc",
|
|
34
28
|
"typecheck": "tsc --noEmit",
|
|
35
29
|
"lint": "biome lint --error-on-warnings src",
|
|
36
30
|
"format": "biome format --write src",
|
|
37
31
|
"format:check": "biome format src"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@sales-planner/shared": "workspace:*"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"typescript": "^5.7.3"
|
|
38
38
|
}
|
|
39
|
-
}
|
|
39
|
+
}
|