@sales-planner/shared 0.16.0 → 0.17.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 +11 -0
- package/dist/entities/index.d.ts +1 -0
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +2 -0
- package/dist/entities/sku-metrics.d.ts +34 -0
- package/dist/entities/sku-metrics.d.ts.map +1 -0
- package/dist/entities/sku-metrics.js +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -140,6 +140,17 @@ The API uses **numeric IDs** internally for referential integrity:
|
|
|
140
140
|
| `UserRole` | User-role assignment |
|
|
141
141
|
| `ApiKey` | API authentication key |
|
|
142
142
|
| `Marketplace` | E-commerce platform (numeric ID, shop-scoped) |
|
|
143
|
+
| `SkuMetrics` | Computed SKU metrics (read-only, from materialized view) |
|
|
144
|
+
|
|
145
|
+
### Computed Entities (Read-Only)
|
|
146
|
+
|
|
147
|
+
| Type | Description |
|
|
148
|
+
|------|-------------|
|
|
149
|
+
| `SkuMetrics` | Aggregated SKU metrics from materialized view |
|
|
150
|
+
| `SkuMetrics.abc_class` | ABC classification: 'A' (top 20%), 'B' (next 30%), 'C' (bottom 50%) |
|
|
151
|
+
| `SkuMetrics.sales_rank` | Sales rank within shop (1 = highest) |
|
|
152
|
+
| `SkuMetrics.days_of_stock` | Estimated days of stock based on sales velocity |
|
|
153
|
+
| `SkuMetrics.last_period_sales` | Total sales quantity for the last period |
|
|
143
154
|
|
|
144
155
|
### Query Types
|
|
145
156
|
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAG3B,cAAc,eAAe,CAAC"}
|
package/dist/entities/index.js
CHANGED
|
@@ -37,3 +37,5 @@ __exportStar(require("./sku-competitor-mappings"), exports);
|
|
|
37
37
|
__exportStar(require("./competitor-sales"), exports);
|
|
38
38
|
__exportStar(require("./roles"), exports);
|
|
39
39
|
__exportStar(require("./api-keys"), exports);
|
|
40
|
+
// Computed entities (materialized views)
|
|
41
|
+
__exportStar(require("./sku-metrics"), exports);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SKU Metrics - Computed entity from materialized view
|
|
3
|
+
*
|
|
4
|
+
* This is a read-only computed entity providing aggregated metrics for SKUs
|
|
5
|
+
* including sales, stock levels, and ABC classification.
|
|
6
|
+
*/
|
|
7
|
+
export interface SkuMetrics {
|
|
8
|
+
id: number;
|
|
9
|
+
sku_id: number;
|
|
10
|
+
shop_id: number;
|
|
11
|
+
tenant_id: number;
|
|
12
|
+
sku_code: string;
|
|
13
|
+
sku_title: string;
|
|
14
|
+
group_code: string | null;
|
|
15
|
+
category_code: string | null;
|
|
16
|
+
brand_code: string | null;
|
|
17
|
+
status_code: string | null;
|
|
18
|
+
supplier_code: string | null;
|
|
19
|
+
/** Period in YYYY-MM format */
|
|
20
|
+
last_period: string;
|
|
21
|
+
/** Total sales quantity for the last period */
|
|
22
|
+
last_period_sales: number;
|
|
23
|
+
/** Current stock across all warehouses */
|
|
24
|
+
current_stock: number;
|
|
25
|
+
/** Estimated days of stock based on sales velocity */
|
|
26
|
+
days_of_stock: number | null;
|
|
27
|
+
/** ABC classification: A (top 20%), B (next 30%), C (bottom 50%) */
|
|
28
|
+
abc_class: 'A' | 'B' | 'C';
|
|
29
|
+
/** Sales rank within the shop (1 = highest sales) */
|
|
30
|
+
sales_rank: number;
|
|
31
|
+
/** When this metric was last computed */
|
|
32
|
+
computed_at: Date;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=sku-metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sku-metrics.d.ts","sourceRoot":"","sources":["../../src/entities/sku-metrics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,0CAA0C;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,oEAAoE;IACpE,SAAS,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAC3B,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,WAAW,EAAE,IAAI,CAAC;CACnB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SKU Metrics - Computed entity from materialized view
|
|
4
|
+
*
|
|
5
|
+
* This is a read-only computed entity providing aggregated metrics for SKUs
|
|
6
|
+
* including sales, stock levels, and ABC classification.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|