@sales-planner/http-client 0.17.3 → 0.19.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 +93 -4
- package/dist/clients/computed-entities-client.d.ts +44 -0
- package/dist/clients/computed-entities-client.d.ts.map +1 -0
- package/dist/clients/computed-entities-client.js +40 -0
- package/dist/clients/index.d.ts +2 -0
- package/dist/clients/index.d.ts.map +1 -1
- package/dist/clients/index.js +2 -0
- package/dist/clients/sales-planner-client.d.ts +7 -3
- package/dist/clients/sales-planner-client.d.ts.map +1 -1
- package/dist/clients/sales-planner-client.js +6 -0
- package/dist/clients/sku-metrics-client.d.ts +29 -0
- package/dist/clients/sku-metrics-client.d.ts.map +1 -0
- package/dist/clients/sku-metrics-client.js +63 -0
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -49,8 +49,17 @@ interface PaginatedResponse<T> {
|
|
|
49
49
|
Query parameters:
|
|
50
50
|
- `limit` - Number of items per page (1-1000, default: 100)
|
|
51
51
|
- `offset` - Number of items to skip (default: 0)
|
|
52
|
+
- `ids` - Filter by specific IDs (array of numbers)
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
**ID Filtering** - All entities support filtering by IDs:
|
|
55
|
+
```typescript
|
|
56
|
+
// Filter any entity by specific IDs
|
|
57
|
+
const { items: brands } = await client.brands.getAll(ctx, { ids: [1, 2, 3] });
|
|
58
|
+
const { items: skus } = await client.skus.getAll(ctx, { ids: [10, 20, 30] });
|
|
59
|
+
const { items: salesHistory } = await client.salesHistory.getAll(ctx, { ids: [100, 101] });
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Period Filtering** - Sales history, leftovers, and competitor sales also support period filtering:
|
|
54
63
|
```typescript
|
|
55
64
|
const { items, total } = await client.salesHistory.getAll(ctx, {
|
|
56
65
|
period_from: '2024-01',
|
|
@@ -66,10 +75,14 @@ const { items: leftovers } = await client.leftovers.getAll(ctx, {
|
|
|
66
75
|
});
|
|
67
76
|
```
|
|
68
77
|
|
|
69
|
-
|
|
78
|
+
**Combined Filtering** - Combine IDs with pagination and period filters:
|
|
70
79
|
```typescript
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
// Get specific sales history records with period filter
|
|
81
|
+
const { items } = await client.salesHistory.getAll(ctx, {
|
|
82
|
+
ids: [1, 2, 3],
|
|
83
|
+
period_from: '2024-01',
|
|
84
|
+
period_to: '2024-06',
|
|
85
|
+
limit: 50,
|
|
73
86
|
});
|
|
74
87
|
```
|
|
75
88
|
|
|
@@ -115,6 +128,33 @@ const metadata = await client.metadata.getEntitiesMetadata();
|
|
|
115
128
|
console.log(metadata); // { entities: [...], version: "..." }
|
|
116
129
|
```
|
|
117
130
|
|
|
131
|
+
## Computed Entities (Read-Only)
|
|
132
|
+
|
|
133
|
+
SKU metrics and materialized view management:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const ctx = { shop_id: 1, tenant_id: 1 };
|
|
137
|
+
|
|
138
|
+
// SKU Metrics - aggregated metrics from materialized views
|
|
139
|
+
const { items, total } = await client.skuMetrics.list(ctx.shop_id, ctx.tenant_id);
|
|
140
|
+
const metric = await client.skuMetrics.get(id, ctx.shop_id, ctx.tenant_id);
|
|
141
|
+
const topProducts = await client.skuMetrics.getByAbcClass('A', ctx.shop_id, ctx.tenant_id);
|
|
142
|
+
|
|
143
|
+
// Export
|
|
144
|
+
const csv = await client.skuMetrics.exportCsv(ctx.shop_id, ctx.tenant_id);
|
|
145
|
+
const json = await client.skuMetrics.exportJson(ctx.shop_id, ctx.tenant_id);
|
|
146
|
+
|
|
147
|
+
// View Management
|
|
148
|
+
const views = await client.computed.getViews(ctx.shop_id, ctx.tenant_id);
|
|
149
|
+
// [{ name: 'mv_sku_metrics', description: 'SKU metrics with ABC classification' }]
|
|
150
|
+
|
|
151
|
+
const result = await client.computed.refreshAll(ctx.shop_id, ctx.tenant_id);
|
|
152
|
+
// { results: [...], totalDuration: 1234, success: true }
|
|
153
|
+
|
|
154
|
+
const viewResult = await client.computed.refreshView('mv_sku_metrics', ctx.shop_id, ctx.tenant_id);
|
|
155
|
+
// { view: 'mv_sku_metrics', duration: 500, success: true }
|
|
156
|
+
```
|
|
157
|
+
|
|
118
158
|
## Error Handling
|
|
119
159
|
|
|
120
160
|
```typescript
|
|
@@ -140,6 +180,7 @@ interface ShopContextParams {
|
|
|
140
180
|
|
|
141
181
|
// Pagination (all getAll methods support this)
|
|
142
182
|
interface PaginationQuery {
|
|
183
|
+
ids?: number[]; // Filter by specific IDs
|
|
143
184
|
limit?: number; // 1-1000, default: 100
|
|
144
185
|
offset?: number; // default: 0
|
|
145
186
|
}
|
|
@@ -326,6 +367,51 @@ Available entity types summary:
|
|
|
326
367
|
- `Sku`, `Brand`, `Category`, `Group`, `Status`, `Supplier`, `Warehouse`, `Marketplace` - shop data
|
|
327
368
|
- `SalesHistory`, `Leftover`, `SeasonalCoefficient` - time-series data
|
|
328
369
|
- `CompetitorProduct`, `CompetitorSale`, `SkuCompetitorMapping` - competitor data
|
|
370
|
+
- `SkuMetrics` - computed entity (read-only, from materialized view)
|
|
371
|
+
|
|
372
|
+
#### Computed Entities
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
interface SkuMetrics {
|
|
376
|
+
id: number;
|
|
377
|
+
sku_id: number;
|
|
378
|
+
shop_id: number;
|
|
379
|
+
tenant_id: number;
|
|
380
|
+
sku_code: string;
|
|
381
|
+
sku_title: string;
|
|
382
|
+
group_code: string | null;
|
|
383
|
+
category_code: string | null;
|
|
384
|
+
brand_code: string | null;
|
|
385
|
+
status_code: string | null;
|
|
386
|
+
supplier_code: string | null;
|
|
387
|
+
last_period: string; // YYYY-MM format
|
|
388
|
+
last_period_sales: number; // Total sales for last period
|
|
389
|
+
current_stock: number; // Current inventory
|
|
390
|
+
days_of_stock: number | null;
|
|
391
|
+
abc_class: 'A' | 'B' | 'C'; // A=top 20%, B=next 30%, C=bottom 50%
|
|
392
|
+
sales_rank: number; // 1 = highest sales
|
|
393
|
+
computed_at: Date;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// View management types
|
|
397
|
+
interface ViewInfo {
|
|
398
|
+
name: string;
|
|
399
|
+
description: string;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
interface RefreshResult {
|
|
403
|
+
view: string;
|
|
404
|
+
duration: number;
|
|
405
|
+
success: boolean;
|
|
406
|
+
error?: string;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
interface RefreshAllResult {
|
|
410
|
+
results: RefreshResult[];
|
|
411
|
+
totalDuration: number;
|
|
412
|
+
success: boolean;
|
|
413
|
+
}
|
|
414
|
+
```
|
|
329
415
|
|
|
330
416
|
### Import/Export Types
|
|
331
417
|
|
|
@@ -374,6 +460,9 @@ import type {
|
|
|
374
460
|
// Competitor Entities
|
|
375
461
|
CompetitorProduct, CompetitorSale, SkuCompetitorMapping,
|
|
376
462
|
|
|
463
|
+
// Computed Entities (read-only)
|
|
464
|
+
SkuMetrics,
|
|
465
|
+
|
|
377
466
|
// User/Me Response Types
|
|
378
467
|
UserWithRolesAndTenants, UserRole, TenantInfo, ShopInfo,
|
|
379
468
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BaseClient } from './base-client.js';
|
|
2
|
+
/**
|
|
3
|
+
* View metadata returned by getViews
|
|
4
|
+
*/
|
|
5
|
+
export interface ViewInfo {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Result of refreshing a single view
|
|
11
|
+
*/
|
|
12
|
+
export interface RefreshResult {
|
|
13
|
+
view: string;
|
|
14
|
+
duration: number;
|
|
15
|
+
success: boolean;
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Result of refreshing all views
|
|
20
|
+
*/
|
|
21
|
+
export interface RefreshAllResult {
|
|
22
|
+
results: RefreshResult[];
|
|
23
|
+
totalDuration: number;
|
|
24
|
+
success: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Client for managing computed entities (materialized views).
|
|
28
|
+
* Provides view listing and refresh operations.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ComputedEntitiesClient extends BaseClient {
|
|
31
|
+
/**
|
|
32
|
+
* Get list of all available materialized views
|
|
33
|
+
*/
|
|
34
|
+
getViews(shopId: number, tenantId: number): Promise<ViewInfo[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Refresh all materialized views in dependency order
|
|
37
|
+
*/
|
|
38
|
+
refreshAll(shopId: number, tenantId: number): Promise<RefreshAllResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Refresh a single materialized view by name
|
|
41
|
+
*/
|
|
42
|
+
refreshView(viewName: string, shopId: number, tenantId: number): Promise<RefreshResult>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=computed-entities-client.d.ts.map
|
|
@@ -0,0 +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,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IASrE;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAS7E;;OAEG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ9F"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BaseClient } from './base-client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Client for managing computed entities (materialized views).
|
|
4
|
+
* Provides view listing and refresh operations.
|
|
5
|
+
*/
|
|
6
|
+
export class ComputedEntitiesClient extends BaseClient {
|
|
7
|
+
/**
|
|
8
|
+
* Get list of all available materialized views
|
|
9
|
+
*/
|
|
10
|
+
async getViews(shopId, tenantId) {
|
|
11
|
+
return this.request('GET', '/computed/views', {
|
|
12
|
+
params: {
|
|
13
|
+
shop_id: shopId,
|
|
14
|
+
tenant_id: tenantId,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Refresh all materialized views in dependency order
|
|
20
|
+
*/
|
|
21
|
+
async refreshAll(shopId, tenantId) {
|
|
22
|
+
return this.request('POST', '/computed/refresh', {
|
|
23
|
+
params: {
|
|
24
|
+
shop_id: shopId,
|
|
25
|
+
tenant_id: tenantId,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Refresh a single materialized view by name
|
|
31
|
+
*/
|
|
32
|
+
async refreshView(viewName, shopId, tenantId) {
|
|
33
|
+
return this.request('POST', `/computed/refresh/${viewName}`, {
|
|
34
|
+
params: {
|
|
35
|
+
shop_id: shopId,
|
|
36
|
+
tenant_id: tenantId,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
package/dist/clients/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { SalesPlannerClient } from './sales-planner-client.js';
|
|
2
2
|
export { ApiError, type ClientConfig } from './base-client.js';
|
|
3
|
+
export { SkuMetricsClient } from './sku-metrics-client.js';
|
|
4
|
+
export { ComputedEntitiesClient, type ViewInfo, type RefreshResult, type RefreshAllResult, } from './computed-entities-client.js';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/clients/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/clients/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EACL,sBAAsB,EACtB,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,gBAAgB,GACtB,MAAM,+BAA+B,CAAC"}
|
package/dist/clients/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Brand, CreateBrandRequest, UpdateBrandRequest, ImportBrandItem, BrandExportItem, Category, CreateCategoryRequest, UpdateCategoryRequest, ImportCategoryItem, CategoryExportItem, CompetitorProduct, CreateCompetitorProductRequest, UpdateCompetitorProductRequest, ImportCompetitorProductItem, CompetitorProductExportItem, CompetitorProductQuery, CompetitorSale, CreateCompetitorSaleRequest, UpdateCompetitorSaleRequest, ImportCompetitorSaleItem, CompetitorSaleExportItem, CompetitorSaleQuery, Group, CreateGroupRequest, UpdateGroupRequest, ImportGroupItem, GroupExportItem, Leftover, CreateLeftoverRequest, UpdateLeftoverRequest, ImportLeftoverItem, LeftoverExportItem, LeftoverQuery, Status, CreateStatusRequest, UpdateStatusRequest, ImportStatusItem, StatusExportItem, Supplier, CreateSupplierRequest, UpdateSupplierRequest, ImportSupplierItem, SupplierExportItem, SeasonalCoefficient, CreateSeasonalCoefficientRequest, UpdateSeasonalCoefficientRequest, ImportSeasonalCoefficientItem, SeasonalCoefficientExportItem, SkuCompetitorMapping, CreateSkuCompetitorMappingRequest, UpdateSkuCompetitorMappingRequest, ImportSkuCompetitorMappingItem, SkuCompetitorMappingExportItem, Warehouse, CreateWarehouseRequest, UpdateWarehouseRequest, ImportWarehouseItem, WarehouseExportItem, Marketplace, CreateMarketplaceRequest, UpdateMarketplaceRequest, ImportMarketplaceItem, MarketplaceExportItem, Role, CreateRoleRequest, UpdateRoleRequest, SalesHistory, CreateSalesHistoryRequest, UpdateSalesHistoryRequest, ImportSalesHistoryItem, SalesHistoryExportItem, SalesHistoryImportResult, SalesHistoryQuery, ImportResult } from '@sales-planner/shared';
|
|
1
|
+
import type { Brand, CreateBrandRequest, UpdateBrandRequest, ImportBrandItem, BrandExportItem, Category, CreateCategoryRequest, UpdateCategoryRequest, ImportCategoryItem, CategoryExportItem, CompetitorProduct, CreateCompetitorProductRequest, UpdateCompetitorProductRequest, ImportCompetitorProductItem, CompetitorProductExportItem, CompetitorProductQuery, CompetitorSale, CreateCompetitorSaleRequest, UpdateCompetitorSaleRequest, ImportCompetitorSaleItem, CompetitorSaleExportItem, CompetitorSaleQuery, Group, CreateGroupRequest, UpdateGroupRequest, ImportGroupItem, GroupExportItem, Leftover, CreateLeftoverRequest, UpdateLeftoverRequest, ImportLeftoverItem, LeftoverExportItem, LeftoverQuery, PaginationQuery, Status, CreateStatusRequest, UpdateStatusRequest, ImportStatusItem, StatusExportItem, Supplier, CreateSupplierRequest, UpdateSupplierRequest, ImportSupplierItem, SupplierExportItem, SeasonalCoefficient, CreateSeasonalCoefficientRequest, UpdateSeasonalCoefficientRequest, ImportSeasonalCoefficientItem, SeasonalCoefficientExportItem, SkuCompetitorMapping, CreateSkuCompetitorMappingRequest, UpdateSkuCompetitorMappingRequest, ImportSkuCompetitorMappingItem, SkuCompetitorMappingExportItem, Warehouse, CreateWarehouseRequest, UpdateWarehouseRequest, ImportWarehouseItem, WarehouseExportItem, Marketplace, CreateMarketplaceRequest, UpdateMarketplaceRequest, ImportMarketplaceItem, MarketplaceExportItem, Role, CreateRoleRequest, UpdateRoleRequest, SalesHistory, CreateSalesHistoryRequest, UpdateSalesHistoryRequest, ImportSalesHistoryItem, SalesHistoryExportItem, SalesHistoryImportResult, SalesHistoryQuery, ImportResult } from '@sales-planner/shared';
|
|
2
2
|
import type { ClientConfig } from './base-client.js';
|
|
3
3
|
import { CodedEntityClient } from './coded-entity-client.js';
|
|
4
4
|
import { CrudClient } from './crud-client.js';
|
|
@@ -11,6 +11,8 @@ import { ShopsClient } from './shops-client.js';
|
|
|
11
11
|
import { SkusClient } from './skus-client.js';
|
|
12
12
|
import { UserRolesClient } from './user-roles-client.js';
|
|
13
13
|
import { ApiKeysClient } from './api-keys-client.js';
|
|
14
|
+
import { SkuMetricsClient } from './sku-metrics-client.js';
|
|
15
|
+
import { ComputedEntitiesClient } from './computed-entities-client.js';
|
|
14
16
|
export declare class SalesPlannerClient {
|
|
15
17
|
private baseUrl;
|
|
16
18
|
readonly me: MeClient;
|
|
@@ -28,13 +30,15 @@ export declare class SalesPlannerClient {
|
|
|
28
30
|
readonly marketplaces: CodedEntityClient<Marketplace, CreateMarketplaceRequest, UpdateMarketplaceRequest, ImportMarketplaceItem, MarketplaceExportItem>;
|
|
29
31
|
readonly salesHistory: ShopScopedClient<SalesHistory, CreateSalesHistoryRequest, UpdateSalesHistoryRequest, ImportSalesHistoryItem, SalesHistoryExportItem, SalesHistoryImportResult, SalesHistoryQuery>;
|
|
30
32
|
readonly leftovers: ShopScopedClient<Leftover, CreateLeftoverRequest, UpdateLeftoverRequest, ImportLeftoverItem, LeftoverExportItem, ImportResult, LeftoverQuery>;
|
|
31
|
-
readonly seasonalCoefficients: ShopScopedClient<SeasonalCoefficient, CreateSeasonalCoefficientRequest, UpdateSeasonalCoefficientRequest, ImportSeasonalCoefficientItem, SeasonalCoefficientExportItem, ImportResult,
|
|
32
|
-
readonly skuCompetitorMappings: ShopScopedClient<SkuCompetitorMapping, CreateSkuCompetitorMappingRequest, UpdateSkuCompetitorMappingRequest, ImportSkuCompetitorMappingItem, SkuCompetitorMappingExportItem, ImportResult,
|
|
33
|
+
readonly seasonalCoefficients: ShopScopedClient<SeasonalCoefficient, CreateSeasonalCoefficientRequest, UpdateSeasonalCoefficientRequest, ImportSeasonalCoefficientItem, SeasonalCoefficientExportItem, ImportResult, PaginationQuery>;
|
|
34
|
+
readonly skuCompetitorMappings: ShopScopedClient<SkuCompetitorMapping, CreateSkuCompetitorMappingRequest, UpdateSkuCompetitorMappingRequest, ImportSkuCompetitorMappingItem, SkuCompetitorMappingExportItem, ImportResult, PaginationQuery>;
|
|
33
35
|
readonly competitorProducts: ShopScopedClient<CompetitorProduct, CreateCompetitorProductRequest, UpdateCompetitorProductRequest, ImportCompetitorProductItem, CompetitorProductExportItem, ImportResult, CompetitorProductQuery>;
|
|
34
36
|
readonly competitorSales: ShopScopedClient<CompetitorSale, CreateCompetitorSaleRequest, UpdateCompetitorSaleRequest, ImportCompetitorSaleItem, CompetitorSaleExportItem, ImportResult, CompetitorSaleQuery>;
|
|
35
37
|
readonly roles: CrudClient<Role, CreateRoleRequest, UpdateRoleRequest>;
|
|
36
38
|
readonly userRoles: UserRolesClient;
|
|
37
39
|
readonly apiKeys: ApiKeysClient;
|
|
40
|
+
readonly skuMetrics: SkuMetricsClient;
|
|
41
|
+
readonly computed: ComputedEntitiesClient;
|
|
38
42
|
constructor(config: ClientConfig);
|
|
39
43
|
getRoot(): Promise<string>;
|
|
40
44
|
getHealth(): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sales-planner-client.d.ts","sourceRoot":"","sources":["../../src/clients/sales-planner-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,8BAA8B,EAC9B,8BAA8B,EAC9B,2BAA2B,EAC3B,2BAA2B,EAC3B,sBAAsB,EACtB,cAAc,EACd,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,KAAK,EACL,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,gCAAgC,EAChC,gCAAgC,EAChC,6BAA6B,EAC7B,6BAA6B,EAC7B,oBAAoB,EACpB,iCAAiC,EACjC,iCAAiC,EACjC,8BAA8B,EAC9B,8BAA8B,EAC9B,SAAS,EACT,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,IAAI,EACJ,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"sales-planner-client.d.ts","sourceRoot":"","sources":["../../src/clients/sales-planner-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,8BAA8B,EAC9B,8BAA8B,EAC9B,2BAA2B,EAC3B,2BAA2B,EAC3B,sBAAsB,EACtB,cAAc,EACd,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,KAAK,EACL,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,QA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E,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAOhE"}
|
|
@@ -10,6 +10,8 @@ import { ShopsClient } from './shops-client.js';
|
|
|
10
10
|
import { SkusClient } from './skus-client.js';
|
|
11
11
|
import { UserRolesClient } from './user-roles-client.js';
|
|
12
12
|
import { ApiKeysClient } from './api-keys-client.js';
|
|
13
|
+
import { SkuMetricsClient } from './sku-metrics-client.js';
|
|
14
|
+
import { ComputedEntitiesClient } from './computed-entities-client.js';
|
|
13
15
|
export class SalesPlannerClient {
|
|
14
16
|
baseUrl;
|
|
15
17
|
// Sub-clients
|
|
@@ -35,6 +37,8 @@ export class SalesPlannerClient {
|
|
|
35
37
|
roles;
|
|
36
38
|
userRoles;
|
|
37
39
|
apiKeys;
|
|
40
|
+
skuMetrics;
|
|
41
|
+
computed;
|
|
38
42
|
constructor(config) {
|
|
39
43
|
this.baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
40
44
|
this.me = new MeClient(config);
|
|
@@ -59,6 +63,8 @@ export class SalesPlannerClient {
|
|
|
59
63
|
this.roles = new CrudClient(config, 'roles');
|
|
60
64
|
this.userRoles = new UserRolesClient(config);
|
|
61
65
|
this.apiKeys = new ApiKeysClient(config);
|
|
66
|
+
this.skuMetrics = new SkuMetricsClient(config);
|
|
67
|
+
this.computed = new ComputedEntitiesClient(config);
|
|
62
68
|
}
|
|
63
69
|
// Health & Info (unauthenticated)
|
|
64
70
|
async getRoot() {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PaginatedResponse, PaginationQuery, SkuMetrics } from '@sales-planner/shared';
|
|
2
|
+
import { BaseClient } from './base-client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Client for read-only SKU metrics computed from materialized views.
|
|
5
|
+
* SKU metrics include ABC classification, sales rank, and days of stock.
|
|
6
|
+
*/
|
|
7
|
+
export declare class SkuMetricsClient extends BaseClient {
|
|
8
|
+
/**
|
|
9
|
+
* List SKU metrics for a shop with pagination
|
|
10
|
+
*/
|
|
11
|
+
list(shopId: number, tenantId: number, query?: PaginationQuery): Promise<PaginatedResponse<SkuMetrics>>;
|
|
12
|
+
/**
|
|
13
|
+
* Get a single SKU metric by ID
|
|
14
|
+
*/
|
|
15
|
+
get(id: number, shopId: number, tenantId: number): Promise<SkuMetrics>;
|
|
16
|
+
/**
|
|
17
|
+
* Get SKU metrics filtered by ABC classification
|
|
18
|
+
*/
|
|
19
|
+
getByAbcClass(abcClass: 'A' | 'B' | 'C', shopId: number, tenantId: number): Promise<SkuMetrics[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Export SKU metrics as CSV
|
|
22
|
+
*/
|
|
23
|
+
exportCsv(shopId: number, tenantId: number): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Export SKU metrics as JSON
|
|
26
|
+
*/
|
|
27
|
+
exportJson(shopId: number, tenantId: number): Promise<SkuMetrics[]>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=sku-metrics-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sku-metrics-client.d.ts","sourceRoot":"","sources":["../../src/clients/sku-metrics-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;IAC9C;;OAEG;IACG,IAAI,CACR,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,eAAe,GACtB,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAUzC;;OAEG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAS5E;;OAEG;IACG,aAAa,CACjB,QAAQ,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EACzB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,UAAU,EAAE,CAAC;IASxB;;OAEG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IASlE;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAQ1E"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { BaseClient } from './base-client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Client for read-only SKU metrics computed from materialized views.
|
|
4
|
+
* SKU metrics include ABC classification, sales rank, and days of stock.
|
|
5
|
+
*/
|
|
6
|
+
export class SkuMetricsClient extends BaseClient {
|
|
7
|
+
/**
|
|
8
|
+
* List SKU metrics for a shop with pagination
|
|
9
|
+
*/
|
|
10
|
+
async list(shopId, tenantId, query) {
|
|
11
|
+
return this.request('GET', '/sku-metrics', {
|
|
12
|
+
params: {
|
|
13
|
+
shop_id: shopId,
|
|
14
|
+
tenant_id: tenantId,
|
|
15
|
+
...query,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get a single SKU metric by ID
|
|
21
|
+
*/
|
|
22
|
+
async get(id, shopId, tenantId) {
|
|
23
|
+
return this.request('GET', `/sku-metrics/${id}`, {
|
|
24
|
+
params: {
|
|
25
|
+
shop_id: shopId,
|
|
26
|
+
tenant_id: tenantId,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get SKU metrics filtered by ABC classification
|
|
32
|
+
*/
|
|
33
|
+
async getByAbcClass(abcClass, shopId, tenantId) {
|
|
34
|
+
return this.request('GET', `/sku-metrics/abc/${abcClass}`, {
|
|
35
|
+
params: {
|
|
36
|
+
shop_id: shopId,
|
|
37
|
+
tenant_id: tenantId,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Export SKU metrics as CSV
|
|
43
|
+
*/
|
|
44
|
+
async exportCsv(shopId, tenantId) {
|
|
45
|
+
return this.requestText('GET', '/sku-metrics/export/csv', {
|
|
46
|
+
params: {
|
|
47
|
+
shop_id: shopId,
|
|
48
|
+
tenant_id: tenantId,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Export SKU metrics as JSON
|
|
54
|
+
*/
|
|
55
|
+
async exportJson(shopId, tenantId) {
|
|
56
|
+
return this.request('GET', '/sku-metrics/export/json', {
|
|
57
|
+
params: {
|
|
58
|
+
shop_id: shopId,
|
|
59
|
+
tenant_id: tenantId,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sales-planner/http-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
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.17.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"typescript": "^5.7.3"
|
|
31
|
+
},
|
|
26
32
|
"scripts": {
|
|
27
33
|
"build": "tsc",
|
|
28
34
|
"typecheck": "tsc --noEmit",
|
|
29
35
|
"lint": "biome lint --error-on-warnings src",
|
|
30
36
|
"format": "biome format --write src",
|
|
31
37
|
"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
|
+
}
|