@sales-planner/http-client 0.19.3 → 0.19.4
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 +8 -8
- 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/package.json +2 -2
package/README.md
CHANGED
|
@@ -144,22 +144,22 @@ SKU metrics and materialized view management:
|
|
|
144
144
|
const ctx = { shop_id: 1, tenant_id: 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
|
|
|
@@ -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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sales-planner/http-client",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.4",
|
|
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.17.
|
|
27
|
+
"@sales-planner/shared": "0.17.4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"typescript": "^5.7.3"
|