@sales-planner/http-client 0.19.3 → 0.20.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 +101 -101
- package/dist/clients/api-keys-client.d.ts +1 -1
- package/dist/clients/api-keys-client.d.ts.map +1 -1
- package/dist/clients/computed-entities-client.d.ts +4 -3
- package/dist/clients/computed-entities-client.d.ts.map +1 -1
- package/dist/clients/computed-entities-client.js +6 -15
- package/dist/clients/sku-metrics-client.d.ts +6 -6
- package/dist/clients/sku-metrics-client.d.ts.map +1 -1
- package/dist/clients/sku-metrics-client.js +10 -26
- package/dist/clients/tenants-client.d.ts +1 -1
- package/dist/clients/tenants-client.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ const client = new SalesPlannerClient({
|
|
|
18
18
|
apiKey: 'your-api-key',
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
const ctx = {
|
|
21
|
+
const ctx = { tenantId: 1, shopId: 1 };
|
|
22
22
|
|
|
23
23
|
// CRUD (all list endpoints return paginated responses)
|
|
24
24
|
const { items: brands, total } = await client.brands.getAll(ctx);
|
|
@@ -62,16 +62,16 @@ const { items: salesHistory } = await client.salesHistory.getAll(ctx, { ids: [10
|
|
|
62
62
|
**Period Filtering** - Sales history, leftovers, and competitor sales also support period filtering:
|
|
63
63
|
```typescript
|
|
64
64
|
const { items, total } = await client.salesHistory.getAll(ctx, {
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
periodFrom: '2024-01',
|
|
66
|
+
periodTo: '2024-12',
|
|
67
67
|
limit: 50,
|
|
68
68
|
offset: 0,
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
// Same for leftovers and competitor sales
|
|
72
72
|
const { items: leftovers } = await client.leftovers.getAll(ctx, {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
periodFrom: '2024-01',
|
|
74
|
+
periodTo: '2024-12',
|
|
75
75
|
});
|
|
76
76
|
```
|
|
77
77
|
|
|
@@ -80,8 +80,8 @@ const { items: leftovers } = await client.leftovers.getAll(ctx, {
|
|
|
80
80
|
// Get specific sales history records with period filter
|
|
81
81
|
const { items } = await client.salesHistory.getAll(ctx, {
|
|
82
82
|
ids: [1, 2, 3],
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
periodFrom: '2024-01',
|
|
84
|
+
periodTo: '2024-06',
|
|
85
85
|
limit: 50,
|
|
86
86
|
});
|
|
87
87
|
```
|
|
@@ -112,7 +112,7 @@ const role = await client.roles.getById(1);
|
|
|
112
112
|
|
|
113
113
|
// User-shop assignments
|
|
114
114
|
const userShops = await client.userShops.getAll({ shopId: 1 });
|
|
115
|
-
await client.userShops.create({
|
|
115
|
+
await client.userShops.create({ userId: 1, shopId: 1 });
|
|
116
116
|
await client.userShops.delete(assignmentId);
|
|
117
117
|
|
|
118
118
|
// Delete all shop data (SKUs, sales history, brands, categories, etc.)
|
|
@@ -141,25 +141,25 @@ console.log(metadata); // { entities: [...], version: "..." }
|
|
|
141
141
|
SKU metrics and materialized view management:
|
|
142
142
|
|
|
143
143
|
```typescript
|
|
144
|
-
const ctx = {
|
|
144
|
+
const ctx = { shopId: 1, tenantId: 1 };
|
|
145
145
|
|
|
146
146
|
// SKU Metrics - aggregated metrics from materialized views
|
|
147
|
-
const { items, total } = await client.skuMetrics.list(ctx
|
|
148
|
-
const metric = await client.skuMetrics.get(
|
|
149
|
-
const topProducts = await client.skuMetrics.getByAbcClass('A'
|
|
147
|
+
const { items, total } = await client.skuMetrics.list(ctx);
|
|
148
|
+
const metric = await client.skuMetrics.get(ctx, id);
|
|
149
|
+
const topProducts = await client.skuMetrics.getByAbcClass(ctx, 'A');
|
|
150
150
|
|
|
151
151
|
// Export
|
|
152
|
-
const csv = await client.skuMetrics.exportCsv(ctx
|
|
153
|
-
const json = await client.skuMetrics.exportJson(ctx
|
|
152
|
+
const csv = await client.skuMetrics.exportCsv(ctx);
|
|
153
|
+
const json = await client.skuMetrics.exportJson(ctx);
|
|
154
154
|
|
|
155
155
|
// View Management
|
|
156
|
-
const views = await client.computed.getViews(ctx
|
|
156
|
+
const views = await client.computed.getViews(ctx);
|
|
157
157
|
// [{ name: 'mv_sku_metrics', description: 'SKU metrics with ABC classification' }]
|
|
158
158
|
|
|
159
|
-
const result = await client.computed.refreshAll(ctx
|
|
159
|
+
const result = await client.computed.refreshAll(ctx);
|
|
160
160
|
// { results: [...], totalDuration: 1234, success: true }
|
|
161
161
|
|
|
162
|
-
const viewResult = await client.computed.refreshView('mv_sku_metrics'
|
|
162
|
+
const viewResult = await client.computed.refreshView(ctx, 'mv_sku_metrics');
|
|
163
163
|
// { view: 'mv_sku_metrics', duration: 500, success: true }
|
|
164
164
|
```
|
|
165
165
|
|
|
@@ -182,8 +182,8 @@ try {
|
|
|
182
182
|
```typescript
|
|
183
183
|
// Required for all shop-scoped operations
|
|
184
184
|
interface ShopContextParams {
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
shopId: number;
|
|
186
|
+
tenantId: number;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
// Pagination (all getAll methods support this)
|
|
@@ -195,8 +195,8 @@ interface PaginationQuery {
|
|
|
195
195
|
|
|
196
196
|
// Period filtering (sales history, leftovers, competitor sales)
|
|
197
197
|
interface PeriodQuery {
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
periodFrom?: string; // YYYY-MM format
|
|
199
|
+
periodTo?: string; // YYYY-MM format
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
// Paginated response (returned by all getAll methods)
|
|
@@ -216,10 +216,10 @@ All entities extend base interfaces:
|
|
|
216
216
|
// Base for shop-scoped entities without code (e.g., SalesHistory)
|
|
217
217
|
interface ShopScopedBaseEntity {
|
|
218
218
|
id: number;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
shopId: number;
|
|
220
|
+
tenantId: number;
|
|
221
|
+
createdAt: Date;
|
|
222
|
+
updatedAt: Date;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
// Base for coded entities (e.g., SKUs, Brands, Categories)
|
|
@@ -236,45 +236,45 @@ interface User {
|
|
|
236
236
|
id: number;
|
|
237
237
|
email: string;
|
|
238
238
|
name: string;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
defaultShopId: number | null;
|
|
240
|
+
createdAt: Date;
|
|
241
|
+
updatedAt: Date;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
interface Tenant {
|
|
245
245
|
id: number;
|
|
246
246
|
title: string;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
247
|
+
ownerId: number | null;
|
|
248
|
+
createdBy: number;
|
|
249
|
+
createdAt: Date;
|
|
250
|
+
updatedAt: Date;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
interface Shop {
|
|
254
254
|
id: number;
|
|
255
255
|
title: string;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
tenantId: number;
|
|
257
|
+
createdAt: Date;
|
|
258
|
+
updatedAt: Date;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
interface Role {
|
|
262
262
|
id: number;
|
|
263
263
|
name: string;
|
|
264
264
|
description: string | null;
|
|
265
|
-
|
|
266
|
-
|
|
265
|
+
createdAt: Date;
|
|
266
|
+
updatedAt: Date;
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
interface ApiKey {
|
|
270
270
|
id: number;
|
|
271
|
-
|
|
271
|
+
userId: number;
|
|
272
272
|
key: string;
|
|
273
273
|
name: string | null;
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
expiresAt: Date | null;
|
|
275
|
+
lastUsedAt: Date | null;
|
|
276
|
+
createdAt: Date;
|
|
277
|
+
updatedAt: Date;
|
|
278
278
|
}
|
|
279
279
|
```
|
|
280
280
|
|
|
@@ -285,13 +285,13 @@ Coded entities (`Sku`, `Brand`, `Category`, `Group`, `Status`, `Supplier`, `Ware
|
|
|
285
285
|
```typescript
|
|
286
286
|
interface Sku extends CodedShopScopedEntity {
|
|
287
287
|
title2?: string | null;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
288
|
+
categoryId?: number | null;
|
|
289
|
+
groupId?: number | null;
|
|
290
|
+
statusId?: number | null;
|
|
291
|
+
supplierId?: number | null;
|
|
292
292
|
}
|
|
293
293
|
// Brand, Category, Group, Status, Supplier, Warehouse, Marketplace
|
|
294
|
-
// all have just: id, code, title,
|
|
294
|
+
// all have just: id, code, title, shopId, tenantId, createdAt, updatedAt
|
|
295
295
|
```
|
|
296
296
|
|
|
297
297
|
#### Time-Series Entities
|
|
@@ -299,37 +299,37 @@ interface Sku extends CodedShopScopedEntity {
|
|
|
299
299
|
```typescript
|
|
300
300
|
interface SalesHistory {
|
|
301
301
|
id: number;
|
|
302
|
-
|
|
303
|
-
|
|
302
|
+
skuId: number;
|
|
303
|
+
marketplaceId: number;
|
|
304
304
|
period: string; // YYYY-MM format
|
|
305
305
|
quantity: number;
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
306
|
+
shopId: number;
|
|
307
|
+
tenantId: number;
|
|
308
|
+
createdAt: Date;
|
|
309
|
+
updatedAt: Date;
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
interface Leftover {
|
|
313
313
|
id: number;
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
skuId: number;
|
|
315
|
+
warehouseId: number;
|
|
316
316
|
period: string; // YYYY-MM format
|
|
317
317
|
quantity: number;
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
318
|
+
shopId: number;
|
|
319
|
+
tenantId: number;
|
|
320
|
+
createdAt: Date;
|
|
321
|
+
updatedAt: Date;
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
interface SeasonalCoefficient {
|
|
325
325
|
id: number;
|
|
326
|
-
|
|
326
|
+
groupId: number;
|
|
327
327
|
month: number; // 1-12
|
|
328
328
|
coefficient: number;
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
329
|
+
shopId: number;
|
|
330
|
+
tenantId: number;
|
|
331
|
+
createdAt: Date;
|
|
332
|
+
updatedAt: Date;
|
|
333
333
|
}
|
|
334
334
|
```
|
|
335
335
|
|
|
@@ -338,35 +338,35 @@ interface SeasonalCoefficient {
|
|
|
338
338
|
```typescript
|
|
339
339
|
interface CompetitorProduct {
|
|
340
340
|
id: number;
|
|
341
|
-
|
|
342
|
-
|
|
341
|
+
marketplaceId: number;
|
|
342
|
+
marketplaceProductId: string; // BIGINT as string
|
|
343
343
|
title: string | null;
|
|
344
344
|
brand: string | null;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
345
|
+
shopId: number;
|
|
346
|
+
tenantId: number;
|
|
347
|
+
createdAt: Date;
|
|
348
|
+
updatedAt: Date;
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
interface CompetitorSale {
|
|
352
352
|
id: number;
|
|
353
|
-
|
|
353
|
+
competitorProductId: number;
|
|
354
354
|
period: string; // YYYY-MM format
|
|
355
355
|
quantity: number;
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
356
|
+
shopId: number;
|
|
357
|
+
tenantId: number;
|
|
358
|
+
createdAt: Date;
|
|
359
|
+
updatedAt: Date;
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
interface SkuCompetitorMapping {
|
|
363
363
|
id: number;
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
364
|
+
skuId: number;
|
|
365
|
+
competitorProductId: number;
|
|
366
|
+
shopId: number;
|
|
367
|
+
tenantId: number;
|
|
368
|
+
createdAt: Date;
|
|
369
|
+
updatedAt: Date;
|
|
370
370
|
}
|
|
371
371
|
```
|
|
372
372
|
|
|
@@ -382,23 +382,23 @@ Available entity types summary:
|
|
|
382
382
|
```typescript
|
|
383
383
|
interface SkuMetrics {
|
|
384
384
|
id: number;
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
385
|
+
skuId: number;
|
|
386
|
+
shopId: number;
|
|
387
|
+
tenantId: number;
|
|
388
|
+
skuCode: string;
|
|
389
|
+
skuTitle: string;
|
|
390
390
|
// IDs for API responses (like other entities)
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
391
|
+
groupId: number | null;
|
|
392
|
+
categoryId: number | null;
|
|
393
|
+
statusId: number | null;
|
|
394
|
+
supplierId: number | null;
|
|
395
|
+
lastPeriod: string; // YYYY-MM format
|
|
396
|
+
lastPeriodSales: number; // Total sales for last period
|
|
397
|
+
currentStock: number; // Current inventory
|
|
398
|
+
daysOfStock: number | null;
|
|
399
|
+
abcClass: 'A' | 'B' | 'C'; // A=top 20%, B=next 30%, C=bottom 50%
|
|
400
|
+
salesRank: number; // 1 = highest sales
|
|
401
|
+
computedAt: Date;
|
|
402
402
|
}
|
|
403
403
|
|
|
404
404
|
// Export uses simple names (like SKUs export), not camelCase
|
|
@@ -457,10 +457,10 @@ interface SkuImportResult extends ImportResult {
|
|
|
457
457
|
created: number;
|
|
458
458
|
updated: number;
|
|
459
459
|
errors: string[];
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
460
|
+
categoriesCreated: number;
|
|
461
|
+
groupsCreated: number;
|
|
462
|
+
statusesCreated: number;
|
|
463
|
+
suppliersCreated: number;
|
|
464
464
|
}
|
|
465
465
|
```
|
|
466
466
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ApiKey, CreateApiKeyRequest, PaginatedResponse, PaginationQuery } from '@sales-planner/shared';
|
|
2
2
|
import { BaseClient } from './base-client.js';
|
|
3
3
|
export interface GetApiKeysQuery extends PaginationQuery {
|
|
4
|
-
|
|
4
|
+
userId?: number;
|
|
5
5
|
}
|
|
6
6
|
export declare class ApiKeysClient extends BaseClient {
|
|
7
7
|
getAll(query?: GetApiKeysQuery): Promise<PaginatedResponse<ApiKey>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-keys-client.d.ts","sourceRoot":"","sources":["../../src/clients/api-keys-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,
|
|
1
|
+
{"version":3,"file":"api-keys-client.d.ts","sourceRoot":"","sources":["../../src/clients/api-keys-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,aAAc,SAAQ,UAAU;IACrC,MAAM,CAAC,KAAK,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAMnE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpC,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ShopContextParams } from '@sales-planner/shared';
|
|
1
2
|
import { BaseClient } from './base-client.js';
|
|
2
3
|
/**
|
|
3
4
|
* View metadata returned by getViews
|
|
@@ -31,14 +32,14 @@ export declare class ComputedEntitiesClient extends BaseClient {
|
|
|
31
32
|
/**
|
|
32
33
|
* Get list of all available materialized views
|
|
33
34
|
*/
|
|
34
|
-
getViews(
|
|
35
|
+
getViews(ctx: ShopContextParams): Promise<ViewInfo[]>;
|
|
35
36
|
/**
|
|
36
37
|
* Refresh all materialized views in dependency order
|
|
37
38
|
*/
|
|
38
|
-
refreshAll(
|
|
39
|
+
refreshAll(ctx: ShopContextParams): Promise<RefreshAllResult>;
|
|
39
40
|
/**
|
|
40
41
|
* Refresh a single materialized view by name
|
|
41
42
|
*/
|
|
42
|
-
refreshView(
|
|
43
|
+
refreshView(ctx: ShopContextParams, viewName: string): Promise<RefreshResult>;
|
|
43
44
|
}
|
|
44
45
|
//# sourceMappingURL=computed-entities-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed-entities-client.d.ts","sourceRoot":"","sources":["../../src/clients/computed-entities-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,UAAU;IACpD;;OAEG;IACG,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"computed-entities-client.d.ts","sourceRoot":"","sources":["../../src/clients/computed-entities-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,UAAU;IACpD;;OAEG;IACG,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAM3D;;OAEG;IACG,UAAU,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAMnE;;OAEG;IACG,WAAW,CAAC,GAAG,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAKpF"}
|
|
@@ -7,34 +7,25 @@ export class ComputedEntitiesClient extends BaseClient {
|
|
|
7
7
|
/**
|
|
8
8
|
* Get list of all available materialized views
|
|
9
9
|
*/
|
|
10
|
-
async getViews(
|
|
10
|
+
async getViews(ctx) {
|
|
11
11
|
return this.request('GET', '/computed/views', {
|
|
12
|
-
params:
|
|
13
|
-
shop_id: shopId,
|
|
14
|
-
tenant_id: tenantId,
|
|
15
|
-
},
|
|
12
|
+
params: ctx,
|
|
16
13
|
});
|
|
17
14
|
}
|
|
18
15
|
/**
|
|
19
16
|
* Refresh all materialized views in dependency order
|
|
20
17
|
*/
|
|
21
|
-
async refreshAll(
|
|
18
|
+
async refreshAll(ctx) {
|
|
22
19
|
return this.request('POST', '/computed/refresh', {
|
|
23
|
-
params:
|
|
24
|
-
shop_id: shopId,
|
|
25
|
-
tenant_id: tenantId,
|
|
26
|
-
},
|
|
20
|
+
params: ctx,
|
|
27
21
|
});
|
|
28
22
|
}
|
|
29
23
|
/**
|
|
30
24
|
* Refresh a single materialized view by name
|
|
31
25
|
*/
|
|
32
|
-
async refreshView(
|
|
26
|
+
async refreshView(ctx, viewName) {
|
|
33
27
|
return this.request('POST', `/computed/refresh/${viewName}`, {
|
|
34
|
-
params:
|
|
35
|
-
shop_id: shopId,
|
|
36
|
-
tenant_id: tenantId,
|
|
37
|
-
},
|
|
28
|
+
params: ctx,
|
|
38
29
|
});
|
|
39
30
|
}
|
|
40
31
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PaginatedResponse, PaginationQuery, SkuMetrics } from '@sales-planner/shared';
|
|
1
|
+
import type { PaginatedResponse, PaginationQuery, ShopContextParams, SkuMetrics } from '@sales-planner/shared';
|
|
2
2
|
import { BaseClient } from './base-client.js';
|
|
3
3
|
/**
|
|
4
4
|
* Client for read-only SKU metrics computed from materialized views.
|
|
@@ -8,22 +8,22 @@ export declare class SkuMetricsClient extends BaseClient {
|
|
|
8
8
|
/**
|
|
9
9
|
* List SKU metrics for a shop with pagination
|
|
10
10
|
*/
|
|
11
|
-
list(
|
|
11
|
+
list(ctx: ShopContextParams, query?: PaginationQuery): Promise<PaginatedResponse<SkuMetrics>>;
|
|
12
12
|
/**
|
|
13
13
|
* Get a single SKU metric by ID
|
|
14
14
|
*/
|
|
15
|
-
get(
|
|
15
|
+
get(ctx: ShopContextParams, id: number): Promise<SkuMetrics>;
|
|
16
16
|
/**
|
|
17
17
|
* Get SKU metrics filtered by ABC classification
|
|
18
18
|
*/
|
|
19
|
-
getByAbcClass(abcClass: 'A' | 'B' | 'C'
|
|
19
|
+
getByAbcClass(ctx: ShopContextParams, abcClass: 'A' | 'B' | 'C'): Promise<SkuMetrics[]>;
|
|
20
20
|
/**
|
|
21
21
|
* Export SKU metrics as CSV
|
|
22
22
|
*/
|
|
23
|
-
exportCsv(
|
|
23
|
+
exportCsv(ctx: ShopContextParams): Promise<string>;
|
|
24
24
|
/**
|
|
25
25
|
* Export SKU metrics as JSON
|
|
26
26
|
*/
|
|
27
|
-
exportJson(
|
|
27
|
+
exportJson(ctx: ShopContextParams): Promise<SkuMetrics[]>;
|
|
28
28
|
}
|
|
29
29
|
//# sourceMappingURL=sku-metrics-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sku-metrics-client.d.ts","sourceRoot":"","sources":["../../src/clients/sku-metrics-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sku-metrics-client.d.ts","sourceRoot":"","sources":["../../src/clients/sku-metrics-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,UAAU,EACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;IAC9C;;OAEG;IACG,IAAI,CACR,GAAG,EAAE,iBAAiB,EACtB,KAAK,CAAC,EAAE,eAAe,GACtB,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAMzC;;OAEG;IACG,GAAG,CAAC,GAAG,EAAE,iBAAiB,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAMlE;;OAEG;IACG,aAAa,CAAC,GAAG,EAAE,iBAAiB,EAAE,QAAQ,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAM7F;;OAEG;IACG,SAAS,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAMxD;;OAEG;IACG,UAAU,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAKhE"}
|
|
@@ -7,57 +7,41 @@ export class SkuMetricsClient extends BaseClient {
|
|
|
7
7
|
/**
|
|
8
8
|
* List SKU metrics for a shop with pagination
|
|
9
9
|
*/
|
|
10
|
-
async list(
|
|
10
|
+
async list(ctx, query) {
|
|
11
11
|
return this.request('GET', '/sku-metrics', {
|
|
12
|
-
params: {
|
|
13
|
-
shop_id: shopId,
|
|
14
|
-
tenant_id: tenantId,
|
|
15
|
-
...query,
|
|
16
|
-
},
|
|
12
|
+
params: { ...ctx, ...query },
|
|
17
13
|
});
|
|
18
14
|
}
|
|
19
15
|
/**
|
|
20
16
|
* Get a single SKU metric by ID
|
|
21
17
|
*/
|
|
22
|
-
async get(
|
|
18
|
+
async get(ctx, id) {
|
|
23
19
|
return this.request('GET', `/sku-metrics/${id}`, {
|
|
24
|
-
params:
|
|
25
|
-
shop_id: shopId,
|
|
26
|
-
tenant_id: tenantId,
|
|
27
|
-
},
|
|
20
|
+
params: ctx,
|
|
28
21
|
});
|
|
29
22
|
}
|
|
30
23
|
/**
|
|
31
24
|
* Get SKU metrics filtered by ABC classification
|
|
32
25
|
*/
|
|
33
|
-
async getByAbcClass(
|
|
26
|
+
async getByAbcClass(ctx, abcClass) {
|
|
34
27
|
return this.request('GET', `/sku-metrics/abc/${abcClass}`, {
|
|
35
|
-
params:
|
|
36
|
-
shop_id: shopId,
|
|
37
|
-
tenant_id: tenantId,
|
|
38
|
-
},
|
|
28
|
+
params: ctx,
|
|
39
29
|
});
|
|
40
30
|
}
|
|
41
31
|
/**
|
|
42
32
|
* Export SKU metrics as CSV
|
|
43
33
|
*/
|
|
44
|
-
async exportCsv(
|
|
34
|
+
async exportCsv(ctx) {
|
|
45
35
|
return this.requestText('GET', '/sku-metrics/export/csv', {
|
|
46
|
-
params:
|
|
47
|
-
shop_id: shopId,
|
|
48
|
-
tenant_id: tenantId,
|
|
49
|
-
},
|
|
36
|
+
params: ctx,
|
|
50
37
|
});
|
|
51
38
|
}
|
|
52
39
|
/**
|
|
53
40
|
* Export SKU metrics as JSON
|
|
54
41
|
*/
|
|
55
|
-
async exportJson(
|
|
42
|
+
async exportJson(ctx) {
|
|
56
43
|
return this.request('GET', '/sku-metrics/export/json', {
|
|
57
|
-
params:
|
|
58
|
-
shop_id: shopId,
|
|
59
|
-
tenant_id: tenantId,
|
|
60
|
-
},
|
|
44
|
+
params: ctx,
|
|
61
45
|
});
|
|
62
46
|
}
|
|
63
47
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Tenant, CreateTenantRequest, UpdateTenantRequest, CreateTenantWithShopRequest, TenantWithShopAndApiKey, PaginatedResponse, PaginationQuery } from '@sales-planner/shared';
|
|
2
2
|
import { BaseClient } from './base-client.js';
|
|
3
3
|
export interface GetTenantsQuery extends PaginationQuery {
|
|
4
|
-
|
|
4
|
+
ownerId?: number;
|
|
5
5
|
}
|
|
6
6
|
export declare class TenantsClient extends BaseClient {
|
|
7
7
|
getAll(query?: GetTenantsQuery): Promise<PaginatedResponse<Tenant>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenants-client.d.ts","sourceRoot":"","sources":["../../src/clients/tenants-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,
|
|
1
|
+
{"version":3,"file":"tenants-client.d.ts","sourceRoot":"","sources":["../../src/clients/tenants-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,aAAc,SAAQ,UAAU;IACrC,MAAM,CAAC,KAAK,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAMnE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpC,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,qBAAqB,CACzB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,uBAAuB,CAAC;IAI7B,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sales-planner/http-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "HTTP client for Sales Planner API",
|
|
5
5
|
"author": "Damir Manapov",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"README.md"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@sales-planner/shared": "0.
|
|
27
|
+
"@sales-planner/shared": "0.18.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"typescript": "^5.7.3"
|