@happyvertical/smrt-manufacturing 0.30.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/dist/types.js ADDED
@@ -0,0 +1,23 @@
1
+ class BomNotFoundError extends Error {
2
+ constructor(bomId) {
3
+ super(`Bill of Materials not found: ${bomId}`);
4
+ this.bomId = bomId;
5
+ }
6
+ bomId;
7
+ name = "BomNotFoundError";
8
+ }
9
+ class NoActiveBomForProductError extends Error {
10
+ constructor(productId) {
11
+ super(
12
+ `No active Bill of Materials found for product: ${productId}. Activate a BOM for this product or pass one explicitly.`
13
+ );
14
+ this.productId = productId;
15
+ }
16
+ productId;
17
+ name = "NoActiveBomForProductError";
18
+ }
19
+ export {
20
+ BomNotFoundError,
21
+ NoActiveBomForProductError
22
+ };
23
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["/**\n * Shared types and error classes for `@happyvertical/smrt-manufacturing`.\n *\n * Strictly industry-neutral. The same vocabulary serves apparel, furniture,\n * automotive, CPG, electronics, food production, custom hardware, and any\n * other vertical that builds finished goods from raw inputs by recipe.\n *\n * @packageDocumentation\n */\n\n/**\n * Lifecycle state of a {@link BillOfMaterials}.\n *\n * - `draft` — under construction; not yet released for production. Cost\n * rollups can still be computed, but the BOM should not yet be referenced\n * by a production order.\n * - `active` — currently in use. New production orders should reference the\n * active BOM for a given product.\n * - `superseded` — an older revision that has been replaced by a newer\n * `active` BOM. Historical production orders may still reference the\n * superseded row for audit, but no new orders should pick it up.\n */\nexport type BomStatus = 'draft' | 'active' | 'superseded';\n\n/**\n * Per-line cost breakdown returned by {@link BomService.computeMaterialCost}.\n * Lets callers surface \"here's where the $42 came from\" UIs without\n * recomputing on the client.\n */\nexport interface BomLineCost {\n /**\n * Plain string reference to a component SKU id. The `Sku` model\n * itself lives in `@happyvertical/smrt-products`; inventory only\n * tracks stock motion against that id.\n */\n componentSkuId: string;\n /** Quantity per produced unit (pre-waste). */\n qtyPerUnit: number;\n /** Waste percent applied to this line (`0` if none). */\n wastePercent: number;\n /** Effective quantity used per produced unit, including waste. */\n effectiveQty: number;\n /** Latest known unit cost, or `0` if unavailable. */\n unitCost: number;\n /** Effective unit-cost contribution to the rolled-up total. */\n lineCost: number;\n /** Unit of measure as declared on the line (`'yards'`, `'each'`, ...). */\n uom: string;\n /**\n * `true` when the unit cost could not be resolved from upstream\n * `smrt-products`. The line still contributes `0` to the total; the\n * flag lets UIs warn the user that the cost rollup is incomplete.\n */\n costUnavailable: boolean;\n}\n\n/**\n * Aggregate cost rollup returned by {@link BomService.computeMaterialCost}.\n */\nexport interface BomCostRollup {\n /** BOM that was rolled up. */\n bomId: string;\n /** Total material cost per produced unit. */\n totalCost: number;\n /** ISO 4217 currency code. Defaults to `'USD'`. */\n currency: string;\n /** Per-line breakdown. Empty array when the BOM has no lines. */\n lineBreakdown: BomLineCost[];\n /**\n * `true` when at least one line's unit cost could not be resolved.\n * Callers should treat `totalCost` as a lower bound in that case.\n */\n hasMissingCosts: boolean;\n}\n\n/**\n * A single entry on a requirements explosion. Multiple BOM lines pointing\n * at the same component SKU are summed.\n */\nexport interface MaterialRequirement {\n /** Plain string reference to the required component {@link Sku}. */\n componentSkuId: string;\n /** Total quantity needed across the full production run (waste included). */\n totalQty: number;\n /** Unit of measure carried over from the originating BOM line(s). */\n uom: string;\n}\n\n/**\n * A single shortage discovered by {@link BomService.canProduce}.\n */\nexport interface MaterialShortage {\n /** Plain string reference to the missing component {@link Sku}. */\n componentSkuId: string;\n /** Total quantity required for the requested production run. */\n requested: number;\n /** Available stock across all locations (`available` state). */\n available: number;\n}\n\n/**\n * Result returned by {@link BomService.canProduce}.\n *\n * `ok: true` means every material requirement is currently covered by\n * available stock; `ok: false` means at least one component is short.\n */\nexport type CanProduceResult =\n | { ok: true; shortages: [] }\n | { ok: false; shortages: MaterialShortage[] };\n\n/**\n * Thrown when a service operation needs to resolve a BOM by id but the row\n * does not exist. Carries the requested id so callers can surface a\n * meaningful message.\n */\nexport class BomNotFoundError extends Error {\n override name = 'BomNotFoundError';\n\n constructor(public readonly bomId: string) {\n super(`Bill of Materials not found: ${bomId}`);\n }\n}\n\n/**\n * Thrown when a production-order operation needs a BOM to plan against but\n * no active BOM is currently registered for the production order's\n * `productId`. The caller should either link a BOM by passing one in\n * explicitly or activate one for the given product.\n */\nexport class NoActiveBomForProductError extends Error {\n override name = 'NoActiveBomForProductError';\n\n constructor(public readonly productId: string) {\n super(\n `No active Bill of Materials found for product: ${productId}. ` +\n `Activate a BOM for this product or pass one explicitly.`,\n );\n }\n}\n"],"names":[],"mappings":"AAmHO,MAAM,yBAAyB,MAAM;AAAA,EAG1C,YAA4B,OAAe;AACzC,UAAM,gCAAgC,KAAK,EAAE;AADnB,SAAA,QAAA;AAAA,EAE5B;AAAA,EAF4B;AAAA,EAFnB,OAAO;AAKlB;AAQO,MAAM,mCAAmC,MAAM;AAAA,EAGpD,YAA4B,WAAmB;AAC7C;AAAA,MACE,kDAAkD,SAAS;AAAA,IAAA;AAFnC,SAAA,YAAA;AAAA,EAK5B;AAAA,EAL4B;AAAA,EAFnB,OAAO;AAQlB;"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@happyvertical/smrt-manufacturing",
3
+ "version": "0.30.0",
4
+ "description": "Bills of materials, cost rollup, and production-order operations for the SMRT framework — strictly industry-neutral",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "CLAUDE.md",
11
+ "AGENTS.md"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ },
18
+ "./manifest": "./dist/manifest.json",
19
+ "./manifest.json": "./dist/manifest.json"
20
+ },
21
+ "dependencies": {
22
+ "@happyvertical/logger": "^0.74.7",
23
+ "@happyvertical/sql": "^0.74.7",
24
+ "@happyvertical/smrt-core": "0.30.0",
25
+ "@happyvertical/smrt-inventory": "0.30.0",
26
+ "@happyvertical/smrt-tenancy": "0.30.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "25.0.9",
30
+ "typescript": "^5.9.3",
31
+ "vite": "^7.3.1",
32
+ "vitest": "^4.0.17",
33
+ "@happyvertical/smrt-vitest": "0.30.0"
34
+ },
35
+ "keywords": [
36
+ "smrt",
37
+ "manufacturing",
38
+ "bom",
39
+ "bill-of-materials",
40
+ "production",
41
+ "cost-rollup"
42
+ ],
43
+ "author": "HappyVertical",
44
+ "license": "MIT",
45
+ "publishConfig": {
46
+ "registry": "https://registry.npmjs.org",
47
+ "access": "public"
48
+ },
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "https://github.com/happyvertical/smrt.git",
52
+ "directory": "packages/manufacturing"
53
+ },
54
+ "scripts": {
55
+ "build": "vite build --mode library",
56
+ "build:watch": "vite build --mode library --watch",
57
+ "clean": "rm -rf dist",
58
+ "dev": "vite dev",
59
+ "test": "vitest run",
60
+ "test:watch": "vitest",
61
+ "typecheck": "tsc --noEmit",
62
+ "verify:pack": "node ../../scripts/verify-package-types-exports.js ."
63
+ }
64
+ }