@happyvertical/smrt-manufacturing 0.56.0 → 0.56.2

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.
@@ -3,12 +3,12 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-manufacturing",
6
- "packageVersion": "0.56.0",
6
+ "packageVersion": "0.56.2",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "6b1d0d7aa92a0915ef0a174dcd6fcc19d2c8d2e6cdf97fdb524136fef90e9474",
11
- "packageJson": "3aab7bc95c607df992d28bc990e18594862c873d55d9d29ada2c1c26a4c3ee6a",
10
+ "manifest": "a621b699202148426f5c9be1082537139be6c9e21ab37ef32b68408368ed0f62",
11
+ "packageJson": "b6d0801aa8c8ca080b6d928ccdac0977c01eb6349d6d1cb1534fb606f92475cf",
12
12
  "agents": "53bbb8d8dfd7e1dbd438a4ad1559be8cd1ad8ed46c726d5498d2dda5b3535054",
13
13
  "moduleDoc:agents/multilevel-and-runs.md": "544d519356801f3cb3beb9e6d49a3e0eec93fdddf3f56150cf3141f766f98c9d"
14
14
  },
@@ -63,7 +63,7 @@
63
63
  "smrt"
64
64
  ],
65
65
  "risks": [
66
- "cross-package-refs:1",
66
+ "cross-package-refs:3",
67
67
  "sensitive-fields-excluded",
68
68
  "sti-inheritance"
69
69
  ],
@@ -109,30 +109,6 @@
109
109
  }
110
110
  ],
111
111
  "surfaces": [
112
- {
113
- "kind": "api",
114
- "name": "billofmaterialses.findByProduct",
115
- "operation": "findByProduct",
116
- "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection",
117
- "path": "/billofmaterialses/findByProduct",
118
- "method": "POST"
119
- },
120
- {
121
- "kind": "api",
122
- "name": "billofmaterialses.findActiveForProduct",
123
- "operation": "findActiveForProduct",
124
- "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection",
125
- "path": "/billofmaterialses/findActiveForProduct",
126
- "method": "POST"
127
- },
128
- {
129
- "kind": "api",
130
- "name": "billofmaterialses.findByStatus",
131
- "operation": "findByStatus",
132
- "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection",
133
- "path": "/billofmaterialses/findByStatus",
134
- "method": "POST"
135
- },
136
112
  {
137
113
  "kind": "cli",
138
114
  "name": "billofmaterialscollection_findByProduct",
@@ -150,23 +126,28 @@
150
126
  "name": "billofmaterialscollection_findByStatus",
151
127
  "operation": "findByStatus",
152
128
  "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection"
153
- },
129
+ }
130
+ ],
131
+ "withheldSurfaces": [
154
132
  {
155
- "kind": "mcp",
156
- "name": "billofmaterialscollection_findbyproduct",
157
- "operation": "findByProduct",
133
+ "kind": "api",
134
+ "operation": "findActiveForProduct",
135
+ "code": "not-included",
136
+ "reason": "not listed in api.include",
158
137
  "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection"
159
138
  },
160
139
  {
161
- "kind": "mcp",
162
- "name": "billofmaterialscollection_findactiveforproduct",
163
- "operation": "findActiveForProduct",
140
+ "kind": "api",
141
+ "operation": "findByProduct",
142
+ "code": "not-included",
143
+ "reason": "not listed in api.include",
164
144
  "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection"
165
145
  },
166
146
  {
167
- "kind": "mcp",
168
- "name": "billofmaterialscollection_findbystatus",
147
+ "kind": "api",
169
148
  "operation": "findByStatus",
149
+ "code": "not-included",
150
+ "reason": "not listed in api.include",
170
151
  "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection"
171
152
  }
172
153
  ],
@@ -208,22 +189,6 @@
208
189
  }
209
190
  ],
210
191
  "surfaces": [
211
- {
212
- "kind": "api",
213
- "name": "bomlines.findByBom",
214
- "operation": "findByBom",
215
- "objectName": "@happyvertical/smrt-manufacturing:BomLineCollection",
216
- "path": "/bomlines/findByBom",
217
- "method": "POST"
218
- },
219
- {
220
- "kind": "api",
221
- "name": "bomlines.findByComponent",
222
- "operation": "findByComponent",
223
- "objectName": "@happyvertical/smrt-manufacturing:BomLineCollection",
224
- "path": "/bomlines/findByComponent",
225
- "method": "POST"
226
- },
227
192
  {
228
193
  "kind": "cli",
229
194
  "name": "bomlinecollection_findByBom",
@@ -235,17 +200,21 @@
235
200
  "name": "bomlinecollection_findByComponent",
236
201
  "operation": "findByComponent",
237
202
  "objectName": "@happyvertical/smrt-manufacturing:BomLineCollection"
238
- },
203
+ }
204
+ ],
205
+ "withheldSurfaces": [
239
206
  {
240
- "kind": "mcp",
241
- "name": "bomlinecollection_findbybom",
207
+ "kind": "api",
242
208
  "operation": "findByBom",
209
+ "code": "not-included",
210
+ "reason": "not listed in api.include",
243
211
  "objectName": "@happyvertical/smrt-manufacturing:BomLineCollection"
244
212
  },
245
213
  {
246
- "kind": "mcp",
247
- "name": "bomlinecollection_findbycomponent",
214
+ "kind": "api",
248
215
  "operation": "findByComponent",
216
+ "code": "not-included",
217
+ "reason": "not listed in api.include",
249
218
  "objectName": "@happyvertical/smrt-manufacturing:BomLineCollection"
250
219
  }
251
220
  ],
@@ -286,45 +255,20 @@
286
255
  "returns": "Promise<Operation[]>"
287
256
  }
288
257
  ],
289
- "surfaces": [
290
- {
291
- "kind": "api",
292
- "name": "operations.findByCode",
293
- "operation": "findByCode",
294
- "objectName": "@happyvertical/smrt-manufacturing:OperationCollection",
295
- "path": "/operations/findByCode",
296
- "method": "POST"
297
- },
258
+ "surfaces": [],
259
+ "withheldSurfaces": [
298
260
  {
299
261
  "kind": "api",
300
- "name": "operations.listOperations",
301
- "operation": "listOperations",
302
- "objectName": "@happyvertical/smrt-manufacturing:OperationCollection",
303
- "path": "/operations/listOperations",
304
- "method": "POST"
305
- },
306
- {
307
- "kind": "cli",
308
- "name": "operationcollection_findByCode",
309
- "operation": "findByCode",
310
- "objectName": "@happyvertical/smrt-manufacturing:OperationCollection"
311
- },
312
- {
313
- "kind": "cli",
314
- "name": "operationcollection_listOperations",
315
- "operation": "listOperations",
316
- "objectName": "@happyvertical/smrt-manufacturing:OperationCollection"
317
- },
318
- {
319
- "kind": "mcp",
320
- "name": "operationcollection_findbycode",
321
262
  "operation": "findByCode",
263
+ "code": "not-included",
264
+ "reason": "not listed in api.include",
322
265
  "objectName": "@happyvertical/smrt-manufacturing:OperationCollection"
323
266
  },
324
267
  {
325
- "kind": "mcp",
326
- "name": "operationcollection_listoperations",
268
+ "kind": "api",
327
269
  "operation": "listOperations",
270
+ "code": "not-included",
271
+ "reason": "not listed in api.include",
328
272
  "objectName": "@happyvertical/smrt-manufacturing:OperationCollection"
329
273
  }
330
274
  ],
@@ -365,45 +309,20 @@
365
309
  "returns": "Promise<ProductionRun[]>"
366
310
  }
367
311
  ],
368
- "surfaces": [
312
+ "surfaces": [],
313
+ "withheldSurfaces": [
369
314
  {
370
315
  "kind": "api",
371
- "name": "productionruns.findByBom",
372
- "operation": "findByBom",
373
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCollection",
374
- "path": "/productionruns/findByBom",
375
- "method": "POST"
376
- },
377
- {
378
- "kind": "api",
379
- "name": "productionruns.findByStatus",
380
- "operation": "findByStatus",
381
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCollection",
382
- "path": "/productionruns/findByStatus",
383
- "method": "POST"
384
- },
385
- {
386
- "kind": "cli",
387
- "name": "productionruncollection_findByBom",
388
- "operation": "findByBom",
389
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCollection"
390
- },
391
- {
392
- "kind": "cli",
393
- "name": "productionruncollection_findByStatus",
394
- "operation": "findByStatus",
395
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCollection"
396
- },
397
- {
398
- "kind": "mcp",
399
- "name": "productionruncollection_findbybom",
400
316
  "operation": "findByBom",
317
+ "code": "not-included",
318
+ "reason": "not listed in api.include",
401
319
  "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCollection"
402
320
  },
403
321
  {
404
- "kind": "mcp",
405
- "name": "productionruncollection_findbystatus",
322
+ "kind": "api",
406
323
  "operation": "findByStatus",
324
+ "code": "not-included",
325
+ "reason": "not listed in api.include",
407
326
  "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCollection"
408
327
  }
409
328
  ],
@@ -435,25 +354,13 @@
435
354
  "returns": "Promise<ProductionRunCompletion[]>"
436
355
  }
437
356
  ],
438
- "surfaces": [
357
+ "surfaces": [],
358
+ "withheldSurfaces": [
439
359
  {
440
360
  "kind": "api",
441
- "name": "productionruncompletions.findByRun",
442
- "operation": "findByRun",
443
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCompletionCollection",
444
- "path": "/productionruncompletions/findByRun",
445
- "method": "POST"
446
- },
447
- {
448
- "kind": "cli",
449
- "name": "productionruncompletioncollection_findByRun",
450
- "operation": "findByRun",
451
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCompletionCollection"
452
- },
453
- {
454
- "kind": "mcp",
455
- "name": "productionruncompletioncollection_findbyrun",
456
361
  "operation": "findByRun",
362
+ "code": "not-included",
363
+ "reason": "not listed in api.include",
457
364
  "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCompletionCollection"
458
365
  }
459
366
  ],
@@ -495,22 +402,6 @@
495
402
  }
496
403
  ],
497
404
  "surfaces": [
498
- {
499
- "kind": "api",
500
- "name": "routingsteps.findByBom",
501
- "operation": "findByBom",
502
- "objectName": "@happyvertical/smrt-manufacturing:RoutingStepCollection",
503
- "path": "/routingsteps/findByBom",
504
- "method": "POST"
505
- },
506
- {
507
- "kind": "api",
508
- "name": "routingsteps.findByOperation",
509
- "operation": "findByOperation",
510
- "objectName": "@happyvertical/smrt-manufacturing:RoutingStepCollection",
511
- "path": "/routingsteps/findByOperation",
512
- "method": "POST"
513
- },
514
405
  {
515
406
  "kind": "cli",
516
407
  "name": "routingstepcollection_findByBom",
@@ -522,17 +413,21 @@
522
413
  "name": "routingstepcollection_findByOperation",
523
414
  "operation": "findByOperation",
524
415
  "objectName": "@happyvertical/smrt-manufacturing:RoutingStepCollection"
525
- },
416
+ }
417
+ ],
418
+ "withheldSurfaces": [
526
419
  {
527
- "kind": "mcp",
528
- "name": "routingstepcollection_findbybom",
420
+ "kind": "api",
529
421
  "operation": "findByBom",
422
+ "code": "not-included",
423
+ "reason": "not listed in api.include",
530
424
  "objectName": "@happyvertical/smrt-manufacturing:RoutingStepCollection"
531
425
  },
532
426
  {
533
- "kind": "mcp",
534
- "name": "routingstepcollection_findbyoperation",
427
+ "kind": "api",
535
428
  "operation": "findByOperation",
429
+ "code": "not-included",
430
+ "reason": "not listed in api.include",
536
431
  "objectName": "@happyvertical/smrt-manufacturing:RoutingStepCollection"
537
432
  }
538
433
  ],
@@ -615,6 +510,22 @@
615
510
  "default": 0,
616
511
  "description": "The price in minor units (cents), for example 1999 for 19.99."
617
512
  },
513
+ {
514
+ "name": "defaultSalesTaxCodeId",
515
+ "type": "crossPackageRef",
516
+ "required": false,
517
+ "related": "@happyvertical/smrt-commerce:TaxCode",
518
+ "columnType": "UUID",
519
+ "description": "The tax code normally used when this product is sold."
520
+ },
521
+ {
522
+ "name": "defaultPurchaseTaxCodeId",
523
+ "type": "crossPackageRef",
524
+ "required": false,
525
+ "related": "@happyvertical/smrt-commerce:TaxCode",
526
+ "columnType": "UUID",
527
+ "description": "The tax code normally used when this product is purchased."
528
+ },
618
529
  {
619
530
  "name": "inStock",
620
531
  "type": "boolean",
@@ -659,6 +570,20 @@
659
570
  }
660
571
  ],
661
572
  "relationships": [
573
+ {
574
+ "name": "defaultSalesTaxCodeId",
575
+ "type": "crossPackageRef",
576
+ "required": false,
577
+ "related": "@happyvertical/smrt-commerce:TaxCode",
578
+ "columnType": "UUID"
579
+ },
580
+ {
581
+ "name": "defaultPurchaseTaxCodeId",
582
+ "type": "crossPackageRef",
583
+ "required": false,
584
+ "related": "@happyvertical/smrt-commerce:TaxCode",
585
+ "columnType": "UUID"
586
+ },
662
587
  {
663
588
  "name": "defaultOperationId",
664
589
  "type": "foreignKey",
@@ -870,6 +795,7 @@
870
795
  }
871
796
  ],
872
797
  "relationshipFeatures": [
798
+ "crossPackageRef",
873
799
  "foreignKey",
874
800
  "uuidColumns"
875
801
  ],
@@ -1701,30 +1627,6 @@
1701
1627
  }
1702
1628
  ],
1703
1629
  "surfaces": [
1704
- {
1705
- "kind": "api",
1706
- "name": "billofmaterialses.findByProduct",
1707
- "operation": "findByProduct",
1708
- "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection",
1709
- "path": "/billofmaterialses/findByProduct",
1710
- "method": "POST"
1711
- },
1712
- {
1713
- "kind": "api",
1714
- "name": "billofmaterialses.findActiveForProduct",
1715
- "operation": "findActiveForProduct",
1716
- "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection",
1717
- "path": "/billofmaterialses/findActiveForProduct",
1718
- "method": "POST"
1719
- },
1720
- {
1721
- "kind": "api",
1722
- "name": "billofmaterialses.findByStatus",
1723
- "operation": "findByStatus",
1724
- "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection",
1725
- "path": "/billofmaterialses/findByStatus",
1726
- "method": "POST"
1727
- },
1728
1630
  {
1729
1631
  "kind": "cli",
1730
1632
  "name": "billofmaterialscollection_findByProduct",
@@ -1743,40 +1645,6 @@
1743
1645
  "operation": "findByStatus",
1744
1646
  "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection"
1745
1647
  },
1746
- {
1747
- "kind": "mcp",
1748
- "name": "billofmaterialscollection_findbyproduct",
1749
- "operation": "findByProduct",
1750
- "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection"
1751
- },
1752
- {
1753
- "kind": "mcp",
1754
- "name": "billofmaterialscollection_findactiveforproduct",
1755
- "operation": "findActiveForProduct",
1756
- "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection"
1757
- },
1758
- {
1759
- "kind": "mcp",
1760
- "name": "billofmaterialscollection_findbystatus",
1761
- "operation": "findByStatus",
1762
- "objectName": "@happyvertical/smrt-manufacturing:BillOfMaterialsCollection"
1763
- },
1764
- {
1765
- "kind": "api",
1766
- "name": "bomlines.findByBom",
1767
- "operation": "findByBom",
1768
- "objectName": "@happyvertical/smrt-manufacturing:BomLineCollection",
1769
- "path": "/bomlines/findByBom",
1770
- "method": "POST"
1771
- },
1772
- {
1773
- "kind": "api",
1774
- "name": "bomlines.findByComponent",
1775
- "operation": "findByComponent",
1776
- "objectName": "@happyvertical/smrt-manufacturing:BomLineCollection",
1777
- "path": "/bomlines/findByComponent",
1778
- "method": "POST"
1779
- },
1780
1648
  {
1781
1649
  "kind": "cli",
1782
1650
  "name": "bomlinecollection_findByBom",
@@ -1789,134 +1657,6 @@
1789
1657
  "operation": "findByComponent",
1790
1658
  "objectName": "@happyvertical/smrt-manufacturing:BomLineCollection"
1791
1659
  },
1792
- {
1793
- "kind": "mcp",
1794
- "name": "bomlinecollection_findbybom",
1795
- "operation": "findByBom",
1796
- "objectName": "@happyvertical/smrt-manufacturing:BomLineCollection"
1797
- },
1798
- {
1799
- "kind": "mcp",
1800
- "name": "bomlinecollection_findbycomponent",
1801
- "operation": "findByComponent",
1802
- "objectName": "@happyvertical/smrt-manufacturing:BomLineCollection"
1803
- },
1804
- {
1805
- "kind": "api",
1806
- "name": "operations.findByCode",
1807
- "operation": "findByCode",
1808
- "objectName": "@happyvertical/smrt-manufacturing:OperationCollection",
1809
- "path": "/operations/findByCode",
1810
- "method": "POST"
1811
- },
1812
- {
1813
- "kind": "api",
1814
- "name": "operations.listOperations",
1815
- "operation": "listOperations",
1816
- "objectName": "@happyvertical/smrt-manufacturing:OperationCollection",
1817
- "path": "/operations/listOperations",
1818
- "method": "POST"
1819
- },
1820
- {
1821
- "kind": "cli",
1822
- "name": "operationcollection_findByCode",
1823
- "operation": "findByCode",
1824
- "objectName": "@happyvertical/smrt-manufacturing:OperationCollection"
1825
- },
1826
- {
1827
- "kind": "cli",
1828
- "name": "operationcollection_listOperations",
1829
- "operation": "listOperations",
1830
- "objectName": "@happyvertical/smrt-manufacturing:OperationCollection"
1831
- },
1832
- {
1833
- "kind": "mcp",
1834
- "name": "operationcollection_findbycode",
1835
- "operation": "findByCode",
1836
- "objectName": "@happyvertical/smrt-manufacturing:OperationCollection"
1837
- },
1838
- {
1839
- "kind": "mcp",
1840
- "name": "operationcollection_listoperations",
1841
- "operation": "listOperations",
1842
- "objectName": "@happyvertical/smrt-manufacturing:OperationCollection"
1843
- },
1844
- {
1845
- "kind": "api",
1846
- "name": "productionruns.findByBom",
1847
- "operation": "findByBom",
1848
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCollection",
1849
- "path": "/productionruns/findByBom",
1850
- "method": "POST"
1851
- },
1852
- {
1853
- "kind": "api",
1854
- "name": "productionruns.findByStatus",
1855
- "operation": "findByStatus",
1856
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCollection",
1857
- "path": "/productionruns/findByStatus",
1858
- "method": "POST"
1859
- },
1860
- {
1861
- "kind": "cli",
1862
- "name": "productionruncollection_findByBom",
1863
- "operation": "findByBom",
1864
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCollection"
1865
- },
1866
- {
1867
- "kind": "cli",
1868
- "name": "productionruncollection_findByStatus",
1869
- "operation": "findByStatus",
1870
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCollection"
1871
- },
1872
- {
1873
- "kind": "mcp",
1874
- "name": "productionruncollection_findbybom",
1875
- "operation": "findByBom",
1876
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCollection"
1877
- },
1878
- {
1879
- "kind": "mcp",
1880
- "name": "productionruncollection_findbystatus",
1881
- "operation": "findByStatus",
1882
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCollection"
1883
- },
1884
- {
1885
- "kind": "api",
1886
- "name": "productionruncompletions.findByRun",
1887
- "operation": "findByRun",
1888
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCompletionCollection",
1889
- "path": "/productionruncompletions/findByRun",
1890
- "method": "POST"
1891
- },
1892
- {
1893
- "kind": "cli",
1894
- "name": "productionruncompletioncollection_findByRun",
1895
- "operation": "findByRun",
1896
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCompletionCollection"
1897
- },
1898
- {
1899
- "kind": "mcp",
1900
- "name": "productionruncompletioncollection_findbyrun",
1901
- "operation": "findByRun",
1902
- "objectName": "@happyvertical/smrt-manufacturing:ProductionRunCompletionCollection"
1903
- },
1904
- {
1905
- "kind": "api",
1906
- "name": "routingsteps.findByBom",
1907
- "operation": "findByBom",
1908
- "objectName": "@happyvertical/smrt-manufacturing:RoutingStepCollection",
1909
- "path": "/routingsteps/findByBom",
1910
- "method": "POST"
1911
- },
1912
- {
1913
- "kind": "api",
1914
- "name": "routingsteps.findByOperation",
1915
- "operation": "findByOperation",
1916
- "objectName": "@happyvertical/smrt-manufacturing:RoutingStepCollection",
1917
- "path": "/routingsteps/findByOperation",
1918
- "method": "POST"
1919
- },
1920
1660
  {
1921
1661
  "kind": "cli",
1922
1662
  "name": "routingstepcollection_findByBom",
@@ -1929,18 +1669,6 @@
1929
1669
  "operation": "findByOperation",
1930
1670
  "objectName": "@happyvertical/smrt-manufacturing:RoutingStepCollection"
1931
1671
  },
1932
- {
1933
- "kind": "mcp",
1934
- "name": "routingstepcollection_findbybom",
1935
- "operation": "findByBom",
1936
- "objectName": "@happyvertical/smrt-manufacturing:RoutingStepCollection"
1937
- },
1938
- {
1939
- "kind": "mcp",
1940
- "name": "routingstepcollection_findbyoperation",
1941
- "operation": "findByOperation",
1942
- "objectName": "@happyvertical/smrt-manufacturing:RoutingStepCollection"
1943
- },
1944
1672
  {
1945
1673
  "kind": "api",
1946
1674
  "name": "products.list",
@@ -2381,11 +2109,11 @@
2381
2109
  "prompts": [],
2382
2110
  "relationshipsV2": {
2383
2111
  "foreignKeyFields": 5,
2384
- "crossPackageRefFields": 1,
2112
+ "crossPackageRefFields": 3,
2385
2113
  "junctionCollections": 0,
2386
2114
  "hierarchicalObjects": 0,
2387
2115
  "polymorphicAssociations": 0,
2388
- "uuidColumns": 37
2116
+ "uuidColumns": 39
2389
2117
  },
2390
2118
  "agentDoc": "# @happyvertical/smrt-manufacturing\n\nBills of materials (multi-level through sub-assemblies), operations and routing, cost and labour rollup, production runs, and production-order stock movement. Strictly industry-neutral — the same primitives serve apparel, furniture, automotive, CPG, electronics, food production, custom hardware, and any vertical that builds finished goods from a recipe.\n\nSits on top of `@happyvertical/smrt-inventory` (stock) and `@happyvertical/smrt-products` (catalog: `Product`, `Material`, `Sku`), and works alongside the `ProductionOrder` Contract STI subtype already shipped in `@happyvertical/smrt-commerce`.\n\n## Models\n\n| Model | Purpose |\n|---|---|\n| `Assembly` | The product that is **made**, counterpart to `Material`. Cross-package STI subtype of `smrt-products` `Product` (`productType: 'assembly'`, `_meta_type: '@happyvertical/smrt-manufacturing:Assembly'`) in the shared `products` table. Own columns: `estimatedLabourMinutes` (integer, per unit; a save refuses anything but a whole number of minutes of zero or more), `defaultOperationId` (`@foreignKey(Operation)`, nullable, RESTRICT like `RoutingStep.operationId`: the operation work on it is booked to by default), `partReference` (the organization's drawing/part number). Name, price, tags come from `Product`; part number and stock from its `Sku` and inventory; structure from its bill; documents from `ProductAsset`. Exposure matches `Product` (REST list/get/create/update, MCP list/get), as the issue asks: unlike `Operation`, the assembly row has no service-owned invariant that generated writes could bypass. |\n| `BillOfMaterials` | Recipe for a finished product. `productId` (plain string) references the upstream `Product` or any STI subtype. Multiple revisions per product via `version` + `status` (`draft` / `active` / `superseded`). `conflictColumns: ['product_id', 'version', 'tenant_id']`. |\n| `BomLine` | One component on a BOM. `bomId` (FK), `componentSkuId` (plain string ref — the `Sku` model lives in `@happyvertical/smrt-products`; inventory tracks stock motion against the id), `qtyPerUnit`, `uom` (open-ended — `yards`, `each`, `grams`, `kg`, ...), `wastePercent`, `notes`. `conflictColumns: ['bom_id', 'component_sku_id', 'tenant_id']`. |\n| `Operation` | A kind of work (cut, weld, inspect), a managed list per tenant. `code` (unique per tenant; `conflictColumns: ['code', 'tenant_id']`, fixed once defined), `name`, `category`, `isActive` (retire/reinstate; never deleted, `delete()` throws), `requiredQualificationId` (nullable `@crossPackageRef('@happyvertical/smrt-human-resources:Qualification')`: metadata only, no dependency, unvalidated; an application reads it to gate who may start the operation). |\n| `ProductionRun` | A build against one bill, reported as it happens (\"25 to build, 12 done\"). `bomId` (`@foreignKey(BillOfMaterials)`, RESTRICT: pinned when created), `targetQty` and `completedQty` (decimal; completed is the sum of completions), `status` (`planned` / `in_progress` / `done` / `cancelled`). Generated list/get only; `ProductionRunService` owns writes. |\n| `ProductionRunCompletion` | One dated report on a run: `runId` (`@foreignKey(ProductionRun)`, CASCADE), `qty` (decimal, > 0), `completedAt`. Generated list/get only. |\n| `RoutingStep` | One operation in a BOM's optional routing. `bomId` (`@foreignKey(BillOfMaterials)`, CASCADE: a routing belongs to its bill), `operationId` (`@foreignKey(Operation)`, RESTRICT: operations are retired, never deleted), `sequence` (1..n, unique per bom), `estimatedMinutes` (decimal, per produced unit), `notes`. `conflictColumns: ['bom_id', 'sequence', 'tenant_id']`. |\n\nAll models are `@TenantScoped({ mode: 'optional' })` with a nullable `tenantId` so they can be used either tenant-scoped or globally.\n\n## Operations, routing and labour estimate\n\n- `OperationService` maintains the list (`define` rejects a duplicate code, including a retired one's; `rename`, `update`, `retire`, `reinstate`). `RoutingService.replaceRouting(bomId, steps)` swaps a bill's whole routing in one transaction and numbers it 1..n; a retired operation may stay on a routing that has it but cannot be newly added.\n- `BomService.computeLabourEstimate(bomId)` returns minutes and, only when the caller supplies `rateResolver` (hourly rate per `Operation`, mirroring `costResolver`), cost. No resolver means minutes only with `rateUnavailable` on each step. A bill with no routing returns an empty estimate; `computeMaterialCost` is unchanged.\n- `Operation` and `RoutingStep` expose generated list/get only; writes go through the services (generated create/update would upsert on a duplicate code or rename the code). `replaceRouting` saves the bill row inside its transaction (row lock) and retries on a revision conflict, so concurrent replacements serialize.\n- Deliberately absent: a default labour rate class (nothing here would use it; the resolver receives the whole `Operation` and can key on `code`/`category`), setup time, scheduling and work-centre capacity, and time recorded against an operation (that stays in `smrt-timesheets` or the application).\n- `./svelte` exports `OperationList` and `OperationForm` (props-driven; hosts persist through `OperationService`). Messages live in `src/svelte/i18n.ts`; component tests use the shared jsdom harness with axe assertions.\n- Tests: `operations-suite.ts` runs on SQLite (`operations.test.ts`) and PostgreSQL (`operations.optional.test.ts`, `pnpm test:postgres`; each test runs in its own tenant because PostgreSQL test data persists).\n\n## Assemblies — nesting lives in the bill\n\nA sub-assembly is a `BomLine` whose component SKU belongs to an `Assembly`; there is no children list on the model. `AssemblyService` is the one link from a line to what it names:\n\n| Method | Behavior |\n|---|---|\n| `resolveComponent(skuId, { tenantId? })` | `{ kind, sku, product, assembly, activeBom, buildable }`. `kind` is `assembly`, `material` (`Material`), `bought` (any other `Product`), or `missing` (unknown SKU, SKU with no product, or a non-UUID id; never throws). `activeBom` is the assembly's highest active bill, `null` when it has none; `buildable` is `assembly && activeBom`. Multi-level explosion (#3444) recurses on `activeBom` and stops at every other kind. |\n| `isAssembly(skuId)` | `resolveComponent(skuId).kind === 'assembly'`. |\n| `findActiveBom(productId, { tenantId? })` | Highest active bill. With `tenantId` (including `null`), that tenant's own bill, else a global one, and `resolveComponent` reads the SKU and product as that tenant's or global (through `tenant-scope.ts`, so a shared global component stays visible under a tenant context) and reports another tenant's as `missing`, whatever the tenant context; the cycle walk and `getBillStructure` pass the bill's own tenant, so a shared assembly resolves to the right tenant's bill on writes made without `withTenant()`. |\n| `getBillStructure(bomId)` | One level: the bill plus each line with its resolved component. Throws `BomNotFoundError`. |\n| `findCycle(productId, componentSkuIds)` | The path by which those components would make `productId` contain itself, following sub-assemblies' **active** bills only; `null` when none. |\n| `assertLineAcyclic(line)` / `assertBillAcyclic(bom)` | Throw `BomCycleError` (a `ValidationError`, code `MANUFACTURING_BOM_CYCLE`, `path` from the product back to itself). |\n\n**Cycle refusal runs in the models.** `BomLine.validateBeforeSave` checks every line save (draft bills too, so a loop is refused when written); `BillOfMaterials.validateBeforeSave` checks every save of an `active` bill (activation), including the lines of a stored bill with the same `(productId, version, tenantId)` that the save would upsert onto. The generated REST routes go through `save()`, so they refuse cycles as well. Not covered: re-pointing a `Sku.productId` (owned by `smrt-products`) and two concurrent saves that each close half of a loop.\n\n## Multi-level walks and production runs\n\nDetail: [agents/multilevel-and-runs.md](agents/multilevel-and-runs.md).\n\n- Every `BomService` method takes `{ levels }` (default `1`, unchanged; up to `MAX_EXPLOSION_DEPTH` = 32, or `'all'`). One walk (`services/structure-walk.ts`) serves `explode` (gross lines and totals), `planRequirements` (net of stock: available, short, what building a shortfall takes; facts, no make-or-buy policy), `canProduce`, cost and labour. A loop already in stored data fails with `BomStructureCycleError`; size limits with `BomExplosionLimitError`.\n- `ProductionRunService` writes `ProductionRun` / `ProductionRunCompletion` in one transaction per call, locking the run row through its revision-guarded save and retrying on a revision conflict; no adapter without `transaction()`. Stock moves only when the caller passes `consume` / `produce`.\n- A run is not commerce's `ProductionOrder` (a `Contract` with terms and money, in a package this one does not depend on); an application that has both links them.\n\n## Svelte components (`./svelte`)\n\nProps-driven; the host loads and persists. `AssemblyList` (a structural `policy` drops hidden columns), `AssemblyForm` (smrt-ui controls like `OperationForm`: `assembly`, `onsubmit(values, formData)`, `operations` for the default-operation picker, `showSkuCode` for a required part-number field (`values.skuCode`; host-reported messages through `errors.fields.skuCode`), `extraFields` snippet inside the form, a retired or unlisted current operation stays selected and marked, `hiddenFields`/`readonlyFields` for the reader's field policy; price is major units in the form and integer minor units in `onsubmit`; `validateAssemblyForm` mirrors the model's whole-minutes rule). `smrt-fields` is not a dependency: never add `ObjectForm`, `BomEditor` (add/edit/remove lines through host handlers; a sub-assembly shows whether it has its own bill and expands read-only through `loadBill`), `BomStructureTree` (the read-only nested view). `ProductionRunList` (progress, status, and with `oncomplete` a quantity field per open run; `onsettarget`/`onfinish`/`oncancel` each add their control only when given, finish and cancel behind a `ConfirmDialog`; rows from `toProductionRunView`), `RequirementsTree` (read-only `explode` / `planRequirements` result by level with totals; `toRequirementTree`, `toRequirementTotals`; internal `RequirementsTreeLevel`). Adapters: `toAssemblyView`, `toBomEditorLines`; the BOM and requirement adapters live in `src/views.ts` (no runtime imports, exported as `./views`, re-exported by `./svelte`: keep it component-free). Strings are under `manufacturing.` in `src/svelte/i18n.ts`; the package is strict for raw primitives, hardcoded strings and JSDoc.\n\n\n## BomService — planning helpers\n\n```typescript\nimport { BomService } from '@happyvertical/smrt-manufacturing';\n\nconst bom = await BomService.create({\n db,\n // Optional. Resolve unit cost for a component SKU.\n // Without this, every line rolls up to $0 and `costUnavailable` is set.\n costResolver: async (componentSkuId) => fetchLatestCost(componentSkuId),\n});\n\nconst rollup = await bom.computeMaterialCost(bomId);\n// { totalCost, currency, lineBreakdown, hasMissingCosts }\n\nconst requirements = await bom.explodeRequirements(bomId, 100);\n// [{ componentSkuId, totalQty, uom }, ...]\n\nconst check = await bom.canProduce(bomId, 100);\n// { ok: true } | { ok: false, shortages: [...] }\n```\n\n| Method | Behavior |\n|---|---|\n| `computeMaterialCost(bomId)` | Walks every BomLine, applies waste (`qtyPerUnit * (1 + wastePercent / 100)`), resolves unit costs via the optional `costResolver`, returns per-line breakdown plus rolled-up total. Lines with no cost set `costUnavailable: true` and contribute `0`. |\n| `explodeRequirements(bomId, qty)` | Returns a \"shopping list\" of materials needed for `qty` units. Duplicates across lines are summed. Does NOT mutate stock. |\n| `canProduce(bomId, qty)` | Calls `explodeRequirements`, then sums `available` stock across every location per component, returns `{ ok: true }` if everything's covered, else `{ ok: false, shortages: [...] }`. |\n| `explode` / `planRequirements` | Multi-level walks; see \"Multi-level walks\" above. Each method above also takes `{ levels }`. |\n\n## ProductionService — consume / produce\n\n```typescript\nimport { ProductionService } from '@happyvertical/smrt-manufacturing';\n\nconst production = await ProductionService.create({ db });\n\n// Drain materials at the factory.\nconst consumed = await production.consumeMaterials(\n { id: order.id, productId: order.productId, bomId: order.bomId },\n { locationId: factory.id, qty: runQty },\n);\n\n// Receive finished goods.\nconst produced = await production.produceFinishedGoods(\n { id: order.id, productId: order.productId },\n { locationId: factory.id, qty: runQty, finishedSkuId: variant.id },\n);\n\n// Or run both in one transaction — see \"Joint atomicity\" below.\nconst { consumed, produced } = await production.runProduction(\n { id: order.id, productId: order.productId, bomId: order.bomId },\n {\n consume: { locationId: factory.id, qty: runQty },\n produce: { locationId: factory.id, qty: runQty, finishedSkuId: variant.id },\n },\n);\n```\n\nAll three methods write through `StockService` and stamp every emitted `StockMovement` with `sourceType: 'ProductionOrder'` (override with the `sourceType` option, as `ProductionRunService` does) + the production order id so audit queries can roll them up later.\n\n### Joint atomicity — `runProduction` vs the two-call form\n\n`consumeMaterials` and `produceFinishedGoods` are each individually atomic, but calling them as two separate awaits is NOT jointly atomic — each opens its own `stockService.withTransaction(...)` scope. If something goes wrong between the two calls (process crash, transient adapter failure on the produce leg), you can land in a state where materials are deducted but no finished SKU receipt balances them. The audit ledger stays consistent within each call; what's missing is the cross-call invariant.\n\nWhen you need that invariant — typically make-to-stock flows where the factory step is invisible to the ledger — use `runProduction(order, { consume, produce })`. Both legs run inside one transaction; any failure (BOM shortage, adapter error, interceptor reject) rolls back both legs together.\n\nWhen NOT to use it: workflows where consume and produce represent a real wall-clock gap that downstream observers need to see (WIP dashboards, partial-run reporting, separate \"materials posted\" and \"production completed\" events on the dispatch bus). There, the two-call form is the right shape — each call is its own ledger event.\n\n### Location convention — explicit-arg design\n\nThe location where materials are consumed and finished goods are received is passed explicitly to `consumeMaterials` / `produceFinishedGoods`, not carried on the production order itself. Rationale:\n\n- The commerce `ProductionOrder` is a `Contract` STI subtype owned by `@happyvertical/smrt-commerce`. Adding an `originLocationId` field there would either need a schema change in commerce (cross-cutting) or a meta field that only manufacturing knows about (leaky).\n- Real shops often pick a location at run time (factory A is congested, route the run through factory B), so even if the order carried a default, the explicit-arg signature is the more flexible canonical form.\n- Callers that want a default can stash a `locationId` on their own production-order helper and pass it through.\n\n### Finished-SKU convention\n\nA `ProductionOrder` references a `productId`, but a `Product` typically has multiple SKUs (one per variant). The caller of `produceFinishedGoods` picks the concrete `finishedSkuId` because the multi-SKU mapping is application-specific (size run, finish mix, kit variant).\n\n## Opt-in DispatchBus hooks\n\nOff by default. Wire them up explicitly in the application's `smrt.ts`:\n\n```typescript\nimport { installManufacturingDispatchHandlers } from '@happyvertical/smrt-manufacturing';\n\nconst handlers = await installManufacturingDispatchHandlers({\n dispatchBus: bus,\n db,\n // Default: subscribe to production_order:posted, call consumeMaterials.\n installProductionPosted: true,\n // Default: don't auto-produce. Set to true if your shop emits a\n // separate production_order:completed event.\n installProductionCompleted: false,\n // Default: don't combine consume + produce on `posted`. Set to true\n // for make-to-stock-instantly workflows where the factory step is\n // invisible. Ignored when installProductionCompleted is true.\n producedOnPosted: false,\n});\n```\n\nThis subscribes to:\n\n- `production_order:posted` → `production.consumeMaterials(...)`; when `producedOnPosted: true` the handler instead calls `production.runProduction(...)` so consume + produce share one transaction. Process crashes or adapter errors between the two legs can never leave materials deducted with no finished-goods receipt.\n- `production_order:completed` → `production.produceFinishedGoods(...)` (opt-in)\n\nThe companion handlers for `contract:created` (reserve) and `fulfillment:shipped` (fulfil) live in `@happyvertical/smrt-inventory` — wire both packages' installers from `smrt.ts` to get the full lifecycle.\n\n## Tests\n\n`multilevel-suite.ts` (rolled back on PostgreSQL) and `production-run-suite.ts` (base handle, per-test tenant, for real concurrent transactions) follow the same SQLite / `*.optional.test.ts` pattern. `src/__tests__/assembly-suite.ts` runs on SQLite (`assembly.test.ts`) and on PostgreSQL (`assembly.optional.test.ts`, skipped without `DATABASE_URL`; `pnpm test:postgres` and the PostgreSQL CI lane run it on a transaction-scoped handle). Component tests under `src/svelte/__tests__` use jsdom and assert axe.\n\n## Gotchas\n\n- **`computeMaterialCost` without a resolver returns `$0`.** That is deliberate — manufacturing does not assume any particular cost source. A real wiring will plug in `@happyvertical/smrt-products` `Material.costPerUnit`, or a rolling average from purchase-order history, or a vendor price book. The `costUnavailable` flag tells UIs to surface \"unknown cost\" rather than silently rolling up zeros.\n- **`explodeRequirements` does not call any stock APIs.** It is a planning helper. To check whether the materials are actually on hand, use `canProduce`. To actually deduct them, use `ProductionService.consumeMaterials`.\n- **`canProduce` sums available stock across every location.** The planning question is \"do we have it at all?\". The operational question of \"which warehouse do we pull from?\" is left to the caller of `consumeMaterials`, which targets a single `locationId` per call.\n- **`consumeMaterials` propagates `InsufficientStockError`.** If a line would drive `available` below zero, the underlying `StockService.adjust` throws. Pre-flight with `canProduce` before posting if you want to avoid partial-failure mid-run.\n- **`consumeMaterials` is atomic across BOM lines.** All per-line deductions and their audit rows run inside a single `stockService.withTransaction(...)` scope (powered by `@happyvertical/sql >= 0.74.0`'s native `db.transaction()`). An `InsufficientStockError` on line N+1 rolls back lines 1..N so production-order posting never leaves materials half-consumed. The recommended pre-flight (`BomService.canProduce(orderId, qty)`) is still useful when you'd rather know upfront than discover the shortfall mid-run, but a missed pre-flight no longer corrupts state.\n- **`consumeMaterials` + `produceFinishedGoods` are NOT jointly atomic.** Each opens its own transaction. A failure on the produce leg leaves materials deducted with no finished SKU receipt to balance it. Use `runProduction(order, { consume, produce })` when you need both legs to commit or roll back together.\n- **Cross-package references are plain strings.** `BillOfMaterials.productId`, `BomLine.componentSkuId` and `BomLine.bomId` are plain string ids (changing them to UUID references needs a migration window); the newer models (`RoutingStep`, `ProductionRun`, `ProductionRunCompletion`) reference this package's own models with `@foreignKey`. The package does depend on `smrt-products` (for `Assembly` and the resolve helper), but the bill schema does not couple to the catalog's table layout.\n- **`Assembly` fields are columns, not `Meta<T>`.** Unlike `Material`, its own fields are ordinary columns this package adds to `products` (filterable over REST). The PostgreSQL suite asserts they land there.\n- **`AssemblyCollection` lists exact `Assembly` rows.** An application subtype (e.g. one adding a customer) has its own `_meta_type`; read it through its own collection or `ProductCollection` (`resolveComponent` uses `instanceof Assembly`, so subtypes resolve as assemblies).\n- **`conflictColumns` include `tenant_id`** on both models. NULL-matching semantics are handled by `@happyvertical/sql >= 0.74.0`; two saves with the same `(product_id, version, NULL)` tuple merge in place.\n- **Lazy table creation.** Like everything else in SMRT, the `manufacturing_boms` and `manufacturing_bom_lines` tables are created on first DB op via `syncSchema`. Safe for SSR. A `BomLine` save now reads `product_skus` and `products` for the cycle check.\n- **Cross-industry constraint.** This package's vocabulary stays generic. Apparel-specific concepts (`Style`, `Makeup`, `Colorway`, `tech-pack`, fashion `Season`) and their analogues in furniture / automotive / CPG live in the relevant template package, never here. PRs that introduce industry vocabulary should be rejected.\n\n## Source attribution\n\nEvery emitted `StockMovement` carries `sourceType: 'ProductionOrder'` plus `sourceId: order.id` so downstream queries can reconstruct \"what caused this movement\". Reason codes used:\n\n| reasonCode | Emitter | Note |\n|---|---|---|\n| `production_consume` | `ProductionService.consumeMaterials` | One per BOM line per consume call |\n| `production_produce` | `ProductionService.produceFinishedGoods` | One per produce call |\n| either, with `sourceType: 'ProductionRunCompletion'` | `ProductionRunService.recordCompletion` | Only when the caller passes `consume` / `produce` |\n\nThese join cleanly with the standard inventory reason codes (`receipt`, `reservation`, `release`, `fulfillment`, `transfer_out`, `transfer_in`, `adjustment`) defined in `@happyvertical/smrt-inventory`.\n\n## Dependencies\n\n| Package | Purpose |\n|---|---|\n| `@happyvertical/smrt-core` | SmrtObject / SmrtCollection / DispatchBus |\n| `@happyvertical/smrt-inventory` | StockService, stock levels, movements (the `Sku` model itself lives in `@happyvertical/smrt-products`; inventory tracks stock motion against the id) |\n| `@happyvertical/smrt-products` | `Product` (the `Assembly` STI base), `Material`, `Sku` for the resolve helper and cycle check |\n| `@happyvertical/smrt-ui` / `smrt-types` | Svelte controls, i18n, module UI slots |\n| `@happyvertical/smrt-tenancy` | Optional tenant scoping |\n| `@happyvertical/sql` | Database adapter |\n",
2391
2119
  "moduleDocs": [