@happyvertical/smrt-manufacturing 0.37.2 → 0.37.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.
@@ -1,211 +1,9 @@
1
1
  {
2
2
  "version": "1.0.0",
3
- "timestamp": 1782873341370,
3
+ "timestamp": 1782943591119,
4
4
  "packageName": "@happyvertical/smrt-manufacturing",
5
- "packageVersion": "0.37.2",
5
+ "packageVersion": "0.37.4",
6
6
  "objects": {
7
- "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection": {
8
- "name": "billofmaterialscollection",
9
- "className": "BillOfMaterialsCollection",
10
- "qualifiedName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection",
11
- "collection": "billofmaterialses",
12
- "filePath": "/home/runner/_work/smrt/smrt/packages/manufacturing/src/collections/BillOfMaterialsCollection.ts",
13
- "packageName": "@happyvertical/smrt-manufacturing",
14
- "fields": {},
15
- "methods": {
16
- "findByProduct": {
17
- "name": "findByProduct",
18
- "async": true,
19
- "parameters": [
20
- {
21
- "name": "productId",
22
- "type": "string",
23
- "optional": false
24
- }
25
- ],
26
- "returnType": "Promise<BillOfMaterials[]>",
27
- "isStatic": false,
28
- "isPublic": true
29
- },
30
- "findActiveForProduct": {
31
- "name": "findActiveForProduct",
32
- "async": true,
33
- "parameters": [
34
- {
35
- "name": "productId",
36
- "type": "string",
37
- "optional": false
38
- }
39
- ],
40
- "returnType": "Promise<BillOfMaterials | null>",
41
- "isStatic": false,
42
- "isPublic": true
43
- },
44
- "findByStatus": {
45
- "name": "findByStatus",
46
- "async": true,
47
- "parameters": [
48
- {
49
- "name": "status",
50
- "type": "BomStatus",
51
- "optional": false
52
- }
53
- ],
54
- "returnType": "Promise<BillOfMaterials[]>",
55
- "isStatic": false,
56
- "isPublic": true
57
- }
58
- },
59
- "decoratorConfig": {
60
- "tableName": "manufacturing_boms"
61
- },
62
- "extends": "SmrtCollection",
63
- "extendsTypeArg": "BillOfMaterials",
64
- "exportName": "BillOfMaterialsCollection",
65
- "collectionExportName": "BillOfMaterialsCollectionCollection",
66
- "schema": {
67
- "tableName": "manufacturing_boms",
68
- "ddl": "CREATE TABLE IF NOT EXISTS \"manufacturing_boms\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
69
- "columns": {
70
- "id": {
71
- "type": "UUID",
72
- "primaryKey": true,
73
- "referenceKind": "id",
74
- "notNull": true
75
- },
76
- "slug": {
77
- "type": "TEXT",
78
- "notNull": true
79
- },
80
- "context": {
81
- "type": "TEXT",
82
- "notNull": true,
83
- "default": ""
84
- },
85
- "created_at": {
86
- "type": "TIMESTAMP",
87
- "notNull": true,
88
- "default": "current_timestamp"
89
- },
90
- "updated_at": {
91
- "type": "TIMESTAMP",
92
- "notNull": true,
93
- "default": "current_timestamp"
94
- }
95
- },
96
- "indexes": [
97
- {
98
- "name": "manufacturing_boms_id_idx",
99
- "columns": [
100
- "id"
101
- ]
102
- },
103
- {
104
- "name": "manufacturing_boms_slug_context_idx",
105
- "columns": [
106
- "slug",
107
- "context"
108
- ],
109
- "unique": true
110
- }
111
- ],
112
- "version": "ac053b14"
113
- }
114
- },
115
- "@happyvertical/smrt-manufacturing:BomLineCollection": {
116
- "name": "bomlinecollection",
117
- "className": "BomLineCollection",
118
- "qualifiedName": "@happyvertical/smrt-manufacturing:BomLineCollection",
119
- "collection": "bomlines",
120
- "filePath": "/home/runner/_work/smrt/smrt/packages/manufacturing/src/collections/BomLineCollection.ts",
121
- "packageName": "@happyvertical/smrt-manufacturing",
122
- "fields": {},
123
- "methods": {
124
- "findByBom": {
125
- "name": "findByBom",
126
- "async": true,
127
- "parameters": [
128
- {
129
- "name": "bomId",
130
- "type": "string",
131
- "optional": false
132
- }
133
- ],
134
- "returnType": "Promise<BomLine[]>",
135
- "isStatic": false,
136
- "isPublic": true
137
- },
138
- "findByComponent": {
139
- "name": "findByComponent",
140
- "async": true,
141
- "parameters": [
142
- {
143
- "name": "componentSkuId",
144
- "type": "string",
145
- "optional": false
146
- }
147
- ],
148
- "returnType": "Promise<BomLine[]>",
149
- "isStatic": false,
150
- "isPublic": true
151
- }
152
- },
153
- "decoratorConfig": {
154
- "tableName": "manufacturing_bom_lines"
155
- },
156
- "extends": "SmrtCollection",
157
- "extendsTypeArg": "BomLine",
158
- "exportName": "BomLineCollection",
159
- "collectionExportName": "BomLineCollectionCollection",
160
- "schema": {
161
- "tableName": "manufacturing_bom_lines",
162
- "ddl": "CREATE TABLE IF NOT EXISTS \"manufacturing_bom_lines\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
163
- "columns": {
164
- "id": {
165
- "type": "UUID",
166
- "primaryKey": true,
167
- "referenceKind": "id",
168
- "notNull": true
169
- },
170
- "slug": {
171
- "type": "TEXT",
172
- "notNull": true
173
- },
174
- "context": {
175
- "type": "TEXT",
176
- "notNull": true,
177
- "default": ""
178
- },
179
- "created_at": {
180
- "type": "TIMESTAMP",
181
- "notNull": true,
182
- "default": "current_timestamp"
183
- },
184
- "updated_at": {
185
- "type": "TIMESTAMP",
186
- "notNull": true,
187
- "default": "current_timestamp"
188
- }
189
- },
190
- "indexes": [
191
- {
192
- "name": "manufacturing_bom_lines_id_idx",
193
- "columns": [
194
- "id"
195
- ]
196
- },
197
- {
198
- "name": "manufacturing_bom_lines_slug_context_idx",
199
- "columns": [
200
- "slug",
201
- "context"
202
- ],
203
- "unique": true
204
- }
205
- ],
206
- "version": "9b18ab50"
207
- }
208
- },
209
7
  "@happyvertical/smrt-manufacturing:BillOfMaterials": {
210
8
  "name": "billofmaterials",
211
9
  "className": "BillOfMaterials",
@@ -612,6 +410,208 @@
612
410
  ],
613
411
  "version": "cfbae7e8"
614
412
  }
413
+ },
414
+ "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection": {
415
+ "name": "billofmaterialscollection",
416
+ "className": "BillOfMaterialsCollection",
417
+ "qualifiedName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection",
418
+ "collection": "billofmaterialses",
419
+ "filePath": "/home/runner/_work/smrt/smrt/packages/manufacturing/src/collections/BillOfMaterialsCollection.ts",
420
+ "packageName": "@happyvertical/smrt-manufacturing",
421
+ "fields": {},
422
+ "methods": {
423
+ "findByProduct": {
424
+ "name": "findByProduct",
425
+ "async": true,
426
+ "parameters": [
427
+ {
428
+ "name": "productId",
429
+ "type": "string",
430
+ "optional": false
431
+ }
432
+ ],
433
+ "returnType": "Promise<BillOfMaterials[]>",
434
+ "isStatic": false,
435
+ "isPublic": true
436
+ },
437
+ "findActiveForProduct": {
438
+ "name": "findActiveForProduct",
439
+ "async": true,
440
+ "parameters": [
441
+ {
442
+ "name": "productId",
443
+ "type": "string",
444
+ "optional": false
445
+ }
446
+ ],
447
+ "returnType": "Promise<BillOfMaterials | null>",
448
+ "isStatic": false,
449
+ "isPublic": true
450
+ },
451
+ "findByStatus": {
452
+ "name": "findByStatus",
453
+ "async": true,
454
+ "parameters": [
455
+ {
456
+ "name": "status",
457
+ "type": "BomStatus",
458
+ "optional": false
459
+ }
460
+ ],
461
+ "returnType": "Promise<BillOfMaterials[]>",
462
+ "isStatic": false,
463
+ "isPublic": true
464
+ }
465
+ },
466
+ "decoratorConfig": {
467
+ "tableName": "manufacturing_boms"
468
+ },
469
+ "extends": "SmrtCollection",
470
+ "extendsTypeArg": "BillOfMaterials",
471
+ "exportName": "BillOfMaterialsCollection",
472
+ "collectionExportName": "BillOfMaterialsCollectionCollection",
473
+ "schema": {
474
+ "tableName": "manufacturing_boms",
475
+ "ddl": "CREATE TABLE IF NOT EXISTS \"manufacturing_boms\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
476
+ "columns": {
477
+ "id": {
478
+ "type": "UUID",
479
+ "primaryKey": true,
480
+ "referenceKind": "id",
481
+ "notNull": true
482
+ },
483
+ "slug": {
484
+ "type": "TEXT",
485
+ "notNull": true
486
+ },
487
+ "context": {
488
+ "type": "TEXT",
489
+ "notNull": true,
490
+ "default": ""
491
+ },
492
+ "created_at": {
493
+ "type": "TIMESTAMP",
494
+ "notNull": true,
495
+ "default": "current_timestamp"
496
+ },
497
+ "updated_at": {
498
+ "type": "TIMESTAMP",
499
+ "notNull": true,
500
+ "default": "current_timestamp"
501
+ }
502
+ },
503
+ "indexes": [
504
+ {
505
+ "name": "manufacturing_boms_id_idx",
506
+ "columns": [
507
+ "id"
508
+ ]
509
+ },
510
+ {
511
+ "name": "manufacturing_boms_slug_context_idx",
512
+ "columns": [
513
+ "slug",
514
+ "context"
515
+ ],
516
+ "unique": true
517
+ }
518
+ ],
519
+ "version": "ac053b14"
520
+ }
521
+ },
522
+ "@happyvertical/smrt-manufacturing:BomLineCollection": {
523
+ "name": "bomlinecollection",
524
+ "className": "BomLineCollection",
525
+ "qualifiedName": "@happyvertical/smrt-manufacturing:BomLineCollection",
526
+ "collection": "bomlines",
527
+ "filePath": "/home/runner/_work/smrt/smrt/packages/manufacturing/src/collections/BomLineCollection.ts",
528
+ "packageName": "@happyvertical/smrt-manufacturing",
529
+ "fields": {},
530
+ "methods": {
531
+ "findByBom": {
532
+ "name": "findByBom",
533
+ "async": true,
534
+ "parameters": [
535
+ {
536
+ "name": "bomId",
537
+ "type": "string",
538
+ "optional": false
539
+ }
540
+ ],
541
+ "returnType": "Promise<BomLine[]>",
542
+ "isStatic": false,
543
+ "isPublic": true
544
+ },
545
+ "findByComponent": {
546
+ "name": "findByComponent",
547
+ "async": true,
548
+ "parameters": [
549
+ {
550
+ "name": "componentSkuId",
551
+ "type": "string",
552
+ "optional": false
553
+ }
554
+ ],
555
+ "returnType": "Promise<BomLine[]>",
556
+ "isStatic": false,
557
+ "isPublic": true
558
+ }
559
+ },
560
+ "decoratorConfig": {
561
+ "tableName": "manufacturing_bom_lines"
562
+ },
563
+ "extends": "SmrtCollection",
564
+ "extendsTypeArg": "BomLine",
565
+ "exportName": "BomLineCollection",
566
+ "collectionExportName": "BomLineCollectionCollection",
567
+ "schema": {
568
+ "tableName": "manufacturing_bom_lines",
569
+ "ddl": "CREATE TABLE IF NOT EXISTS \"manufacturing_bom_lines\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
570
+ "columns": {
571
+ "id": {
572
+ "type": "UUID",
573
+ "primaryKey": true,
574
+ "referenceKind": "id",
575
+ "notNull": true
576
+ },
577
+ "slug": {
578
+ "type": "TEXT",
579
+ "notNull": true
580
+ },
581
+ "context": {
582
+ "type": "TEXT",
583
+ "notNull": true,
584
+ "default": ""
585
+ },
586
+ "created_at": {
587
+ "type": "TIMESTAMP",
588
+ "notNull": true,
589
+ "default": "current_timestamp"
590
+ },
591
+ "updated_at": {
592
+ "type": "TIMESTAMP",
593
+ "notNull": true,
594
+ "default": "current_timestamp"
595
+ }
596
+ },
597
+ "indexes": [
598
+ {
599
+ "name": "manufacturing_bom_lines_id_idx",
600
+ "columns": [
601
+ "id"
602
+ ]
603
+ },
604
+ {
605
+ "name": "manufacturing_bom_lines_slug_context_idx",
606
+ "columns": [
607
+ "slug",
608
+ "context"
609
+ ],
610
+ "unique": true
611
+ }
612
+ ],
613
+ "version": "9b18ab50"
614
+ }
615
615
  }
616
616
  },
617
617
  "moduleType": "smrt",
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-07-01T02:35:43.421Z",
3
+ "generatedAt": "2026-07-01T22:06:33.287Z",
4
4
  "packageName": "@happyvertical/smrt-manufacturing",
5
- "packageVersion": "0.37.2",
5
+ "packageVersion": "0.37.4",
6
6
  "sourceManifestPath": "dist/manifest.json",
7
7
  "agentDocPath": "AGENTS.md",
8
8
  "sourceHashes": {
9
- "manifest": "73b14e0a3d4ee53a800c18f931dce3a1727ca8c099b96c47ad0c1c1a499f6650",
10
- "packageJson": "c04f28b4b851c0782f5fa04a6cec3e8aae66a706b7e267cab6e2eba9900034a5",
9
+ "manifest": "8b67e9d4ffc6e4421511e81c61fd8bf72cf7656dc724392e1278f91f6ac8ab05",
10
+ "packageJson": "faa6a65a8c15eef05a88b99b7db4348a4cbda4584476a80e33569e43c77c852b",
11
11
  "agents": "94d10408c859743730368f932f77e5602ebefb8fe9a8ac3178fa4b211e95ad29"
12
12
  },
13
13
  "exports": [
@@ -22,10 +22,10 @@
22
22
  "@happyvertical/smrt-tenancy": "workspace:*",
23
23
  "@happyvertical/sql": "catalog:",
24
24
  "@happyvertical/smrt-vitest": "workspace:*",
25
- "@types/node": "25.0.9",
25
+ "@types/node": "24.13.2",
26
26
  "typescript": "^5.9.3",
27
- "vite": "^7.3.6",
28
- "vitest": "^4.0.17"
27
+ "vite": "^8.1.2",
28
+ "vitest": "^4.1.9"
29
29
  },
30
30
  "smrtDependencies": [
31
31
  "@happyvertical/smrt-core",
@@ -40,47 +40,6 @@
40
40
  "tags": [],
41
41
  "risks": [],
42
42
  "objects": [
43
- {
44
- "name": "BillOfMaterialsCollection",
45
- "qualifiedName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection",
46
- "collection": "billofmaterialses",
47
- "tableName": "manufacturing_boms",
48
- "packageName": "@happyvertical/smrt-manufacturing",
49
- "extends": "SmrtCollection",
50
- "fields": [],
51
- "relationships": [],
52
- "methods": [
53
- "findActiveForProduct",
54
- "findByProduct",
55
- "findByStatus"
56
- ],
57
- "surfaces": [],
58
- "relationshipFeatures": [
59
- "uuidColumns"
60
- ],
61
- "tags": [],
62
- "risks": []
63
- },
64
- {
65
- "name": "BomLineCollection",
66
- "qualifiedName": "@happyvertical/smrt-manufacturing:BomLineCollection",
67
- "collection": "bomlines",
68
- "tableName": "manufacturing_bom_lines",
69
- "packageName": "@happyvertical/smrt-manufacturing",
70
- "extends": "SmrtCollection",
71
- "fields": [],
72
- "relationships": [],
73
- "methods": [
74
- "findByBom",
75
- "findByComponent"
76
- ],
77
- "surfaces": [],
78
- "relationshipFeatures": [
79
- "uuidColumns"
80
- ],
81
- "tags": [],
82
- "risks": []
83
- },
84
43
  {
85
44
  "name": "BillOfMaterials",
86
45
  "qualifiedName": "@happyvertical/smrt-manufacturing:BillOfMaterials",
@@ -352,6 +311,47 @@
352
311
  ],
353
312
  "tags": [],
354
313
  "risks": []
314
+ },
315
+ {
316
+ "name": "BillOfMaterialsCollection",
317
+ "qualifiedName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection",
318
+ "collection": "billofmaterialses",
319
+ "tableName": "manufacturing_boms",
320
+ "packageName": "@happyvertical/smrt-manufacturing",
321
+ "extends": "SmrtCollection",
322
+ "fields": [],
323
+ "relationships": [],
324
+ "methods": [
325
+ "findActiveForProduct",
326
+ "findByProduct",
327
+ "findByStatus"
328
+ ],
329
+ "surfaces": [],
330
+ "relationshipFeatures": [
331
+ "uuidColumns"
332
+ ],
333
+ "tags": [],
334
+ "risks": []
335
+ },
336
+ {
337
+ "name": "BomLineCollection",
338
+ "qualifiedName": "@happyvertical/smrt-manufacturing:BomLineCollection",
339
+ "collection": "bomlines",
340
+ "tableName": "manufacturing_bom_lines",
341
+ "packageName": "@happyvertical/smrt-manufacturing",
342
+ "extends": "SmrtCollection",
343
+ "fields": [],
344
+ "relationships": [],
345
+ "methods": [
346
+ "findByBom",
347
+ "findByComponent"
348
+ ],
349
+ "surfaces": [],
350
+ "relationshipFeatures": [
351
+ "uuidColumns"
352
+ ],
353
+ "tags": [],
354
+ "risks": []
355
355
  }
356
356
  ],
357
357
  "surfaces": [
package/dist/types.js CHANGED
@@ -1,23 +1,21 @@
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
1
+ //#region src/types.ts
2
+ var BomNotFoundError = class extends Error {
3
+ constructor(bomId) {
4
+ super(`Bill of Materials not found: ${bomId}`);
5
+ this.bomId = bomId;
6
+ }
7
+ bomId;
8
+ name = "BomNotFoundError";
22
9
  };
23
- //# sourceMappingURL=types.js.map
10
+ var NoActiveBomForProductError = class extends Error {
11
+ constructor(productId) {
12
+ super(`No active Bill of Materials found for product: ${productId}. Activate a BOM for this product or pass one explicitly.`);
13
+ this.productId = productId;
14
+ }
15
+ productId;
16
+ name = "NoActiveBomForProductError";
17
+ };
18
+ //#endregion
19
+ export { BomNotFoundError, NoActiveBomForProductError };
20
+
21
+ //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +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;"}
1
+ {"version":3,"file":"types.js","names":[],"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"],"mappings":";AAmHO,IAAM,mBAAN,cAA+B,MAAM;CAG1C,YAA4B,OAAe;EACzC,MAAM,gCAAgC,OAAO;EADnB,KAAA,QAAA;CAE5B;CAF4B;CAFnB,OAAO;AAKlB;AAQO,IAAM,6BAAN,cAAyC,MAAM;CAGpD,YAA4B,WAAmB;EAC7C,MACE,kDAAkD,UAAS,0DAE7D;EAJ0B,KAAA,YAAA;CAK5B;CAL4B;CAFnB,OAAO;AAQlB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-manufacturing",
3
- "version": "0.37.2",
3
+ "version": "0.37.4",
4
4
  "description": "Bills of materials, cost rollup, and production-order operations for the SMRT framework — strictly industry-neutral",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -19,18 +19,18 @@
19
19
  "./manifest.json": "./dist/manifest.json"
20
20
  },
21
21
  "dependencies": {
22
- "@happyvertical/logger": "^0.74.10",
23
- "@happyvertical/sql": "^0.74.10",
24
- "@happyvertical/smrt-inventory": "0.37.2",
25
- "@happyvertical/smrt-core": "0.37.2",
26
- "@happyvertical/smrt-tenancy": "0.37.2"
22
+ "@happyvertical/logger": "^0.74.11",
23
+ "@happyvertical/sql": "^0.74.11",
24
+ "@happyvertical/smrt-inventory": "0.37.4",
25
+ "@happyvertical/smrt-core": "0.37.4",
26
+ "@happyvertical/smrt-tenancy": "0.37.4"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/node": "25.0.9",
29
+ "@types/node": "24.13.2",
30
30
  "typescript": "^5.9.3",
31
- "vite": "^7.3.6",
32
- "vitest": "^4.0.17",
33
- "@happyvertical/smrt-vitest": "0.37.2"
31
+ "vite": "^8.1.2",
32
+ "vitest": "^4.1.9",
33
+ "@happyvertical/smrt-vitest": "0.37.4"
34
34
  },
35
35
  "keywords": [
36
36
  "smrt",