@happyvertical/smrt-manufacturing 0.53.4 → 0.53.6

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.
Files changed (106) hide show
  1. package/AGENTS.md +58 -7
  2. package/README.md +228 -4
  3. package/agents/multilevel-and-runs.md +28 -0
  4. package/dist/collections/AssemblyCollection.d.ts +15 -0
  5. package/dist/collections/AssemblyCollection.d.ts.map +1 -0
  6. package/dist/collections/OperationCollection.d.ts +20 -0
  7. package/dist/collections/OperationCollection.d.ts.map +1 -0
  8. package/dist/collections/ProductionRunCollection.d.ts +15 -0
  9. package/dist/collections/ProductionRunCollection.d.ts.map +1 -0
  10. package/dist/collections/ProductionRunCompletionCollection.d.ts +14 -0
  11. package/dist/collections/ProductionRunCompletionCollection.d.ts.map +1 -0
  12. package/dist/collections/RoutingStepCollection.d.ts +15 -0
  13. package/dist/collections/RoutingStepCollection.d.ts.map +1 -0
  14. package/dist/collections/index.d.ts +5 -0
  15. package/dist/collections/index.d.ts.map +1 -1
  16. package/dist/index.d.ts +23 -5
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1660 -42
  19. package/dist/index.js.map +1 -1
  20. package/dist/manifest.json +1910 -161
  21. package/dist/models/Assembly.d.ts +62 -0
  22. package/dist/models/Assembly.d.ts.map +1 -0
  23. package/dist/models/BillOfMaterials.d.ts +12 -4
  24. package/dist/models/BillOfMaterials.d.ts.map +1 -1
  25. package/dist/models/BomLine.d.ts +11 -5
  26. package/dist/models/BomLine.d.ts.map +1 -1
  27. package/dist/models/Operation.d.ts +59 -0
  28. package/dist/models/Operation.d.ts.map +1 -0
  29. package/dist/models/ProductionRun.d.ts +67 -0
  30. package/dist/models/ProductionRun.d.ts.map +1 -0
  31. package/dist/models/ProductionRunCompletion.d.ts +36 -0
  32. package/dist/models/ProductionRunCompletion.d.ts.map +1 -0
  33. package/dist/models/RoutingStep.d.ts +46 -0
  34. package/dist/models/RoutingStep.d.ts.map +1 -0
  35. package/dist/models/index.d.ts +5 -0
  36. package/dist/models/index.d.ts.map +1 -1
  37. package/dist/operation-types.d.ts +108 -0
  38. package/dist/operation-types.d.ts.map +1 -0
  39. package/dist/production-run-types.d.ts +100 -0
  40. package/dist/production-run-types.d.ts.map +1 -0
  41. package/dist/quantity.d.ts +36 -0
  42. package/dist/quantity.d.ts.map +1 -0
  43. package/dist/services/AssemblyService.d.ts +222 -0
  44. package/dist/services/AssemblyService.d.ts.map +1 -0
  45. package/dist/services/BomService.d.ts +108 -5
  46. package/dist/services/BomService.d.ts.map +1 -1
  47. package/dist/services/OperationService.d.ts +48 -0
  48. package/dist/services/OperationService.d.ts.map +1 -0
  49. package/dist/services/ProductionRunService.d.ts +123 -0
  50. package/dist/services/ProductionRunService.d.ts.map +1 -0
  51. package/dist/services/ProductionService.d.ts +11 -0
  52. package/dist/services/ProductionService.d.ts.map +1 -1
  53. package/dist/services/RoutingService.d.ts +50 -0
  54. package/dist/services/RoutingService.d.ts.map +1 -0
  55. package/dist/services/index.d.ts +5 -0
  56. package/dist/services/index.d.ts.map +1 -1
  57. package/dist/services/structure-walk.d.ts +77 -0
  58. package/dist/services/structure-walk.d.ts.map +1 -0
  59. package/dist/smrt-knowledge.json +1771 -207
  60. package/dist/svelte/components/AssemblyForm.svelte +69 -0
  61. package/dist/svelte/components/AssemblyForm.svelte.d.ts +38 -0
  62. package/dist/svelte/components/AssemblyForm.svelte.d.ts.map +1 -0
  63. package/dist/svelte/components/AssemblyList.svelte +229 -0
  64. package/dist/svelte/components/AssemblyList.svelte.d.ts +28 -0
  65. package/dist/svelte/components/AssemblyList.svelte.d.ts.map +1 -0
  66. package/dist/svelte/components/BomEditor.svelte +575 -0
  67. package/dist/svelte/components/BomEditor.svelte.d.ts +29 -0
  68. package/dist/svelte/components/BomEditor.svelte.d.ts.map +1 -0
  69. package/dist/svelte/components/BomStructureTree.svelte +164 -0
  70. package/dist/svelte/components/BomStructureTree.svelte.d.ts +16 -0
  71. package/dist/svelte/components/BomStructureTree.svelte.d.ts.map +1 -0
  72. package/dist/svelte/components/OperationForm.svelte +258 -0
  73. package/dist/svelte/components/OperationForm.svelte.d.ts +17 -0
  74. package/dist/svelte/components/OperationForm.svelte.d.ts.map +1 -0
  75. package/dist/svelte/components/OperationList.svelte +170 -0
  76. package/dist/svelte/components/OperationList.svelte.d.ts +17 -0
  77. package/dist/svelte/components/OperationList.svelte.d.ts.map +1 -0
  78. package/dist/svelte/components/ProductionRunList.svelte +213 -0
  79. package/dist/svelte/components/ProductionRunList.svelte.d.ts +18 -0
  80. package/dist/svelte/components/ProductionRunList.svelte.d.ts.map +1 -0
  81. package/dist/svelte/components/RequirementsTree.svelte +125 -0
  82. package/dist/svelte/components/RequirementsTree.svelte.d.ts +13 -0
  83. package/dist/svelte/components/RequirementsTree.svelte.d.ts.map +1 -0
  84. package/dist/svelte/components/RequirementsTreeLevel.svelte +120 -0
  85. package/dist/svelte/components/RequirementsTreeLevel.svelte.d.ts +12 -0
  86. package/dist/svelte/components/RequirementsTreeLevel.svelte.d.ts.map +1 -0
  87. package/dist/svelte/i18n.d.ts +119 -0
  88. package/dist/svelte/i18n.d.ts.map +1 -0
  89. package/dist/svelte/i18n.js +119 -0
  90. package/dist/svelte/index.d.ts +33 -0
  91. package/dist/svelte/index.d.ts.map +1 -0
  92. package/dist/svelte/index.js +34 -0
  93. package/dist/svelte/types.d.ts +257 -0
  94. package/dist/svelte/types.d.ts.map +1 -0
  95. package/dist/svelte/types.js +249 -0
  96. package/dist/tenant-scope.d.ts +25 -0
  97. package/dist/tenant-scope.d.ts.map +1 -0
  98. package/dist/types.d.ts +207 -3
  99. package/dist/types.d.ts.map +1 -1
  100. package/dist/types.js +13 -1
  101. package/dist/types.js.map +1 -1
  102. package/dist/ui.d.ts +17 -0
  103. package/dist/ui.d.ts.map +1 -0
  104. package/dist/ui.js +94 -0
  105. package/dist/ui.js.map +1 -0
  106. package/package.json +41 -11
@@ -0,0 +1,50 @@
1
+ /**
2
+ * RoutingService — read and replace the routing of a bill of materials.
3
+ *
4
+ * A routing is the ordered list of {@link RoutingStep} rows for one bill.
5
+ * It is optional; a bill with none is valid. `replaceRouting` swaps the whole
6
+ * list in one transaction, so reordering, inserting and removing steps are one
7
+ * operation and a bill never shows a half-written routing.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ import { type DatabaseConfig } from '@happyvertical/smrt-core';
12
+ import { BillOfMaterialsCollection } from '../collections/BillOfMaterialsCollection.js';
13
+ import { OperationCollection } from '../collections/OperationCollection.js';
14
+ import { RoutingStepCollection } from '../collections/RoutingStepCollection.js';
15
+ import type { RoutingStep } from '../models/RoutingStep.js';
16
+ import { type RoutingStepInput } from '../operation-types.js';
17
+ /** Options accepted by {@link RoutingService.create}. */
18
+ export interface RoutingServiceOptions {
19
+ db: DatabaseConfig;
20
+ }
21
+ export declare class RoutingService {
22
+ private readonly db;
23
+ readonly boms: BillOfMaterialsCollection;
24
+ readonly operations: OperationCollection;
25
+ readonly steps: RoutingStepCollection;
26
+ private constructor();
27
+ /** Factory — prefer {@link createRoutingService}. */
28
+ static create(options: RoutingServiceOptions): Promise<RoutingService>;
29
+ /** The routing of a bill in step order; empty when it has none. */
30
+ list(bomId: string): Promise<RoutingStep[]>;
31
+ /**
32
+ * Check `inputs` against the routing about to be replaced: durations,
33
+ * operations, and that a retired operation is not added beyond the
34
+ * occurrences `current` already has.
35
+ */
36
+ private validate;
37
+ /**
38
+ * Replace the bill's routing with `inputs`, numbered 1..n in the order given.
39
+ * An empty list removes the routing.
40
+ *
41
+ * Throws {@link BomNotFoundError}, {@link OperationNotFoundError},
42
+ * {@link OperationRetiredError} (a retired operation may stay on a routing
43
+ * that already has it but cannot be newly added), or
44
+ * {@link InvalidOperationInputError} for a negative or non-finite duration.
45
+ */
46
+ replaceRouting(bomId: string, inputs: readonly RoutingStepInput[]): Promise<RoutingStep[]>;
47
+ }
48
+ /** Convenience factory. */
49
+ export declare function createRoutingService(options: RoutingServiceOptions): Promise<RoutingService>;
50
+ //# sourceMappingURL=RoutingService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoutingService.d.ts","sourceRoot":"","sources":["../../src/services/RoutingService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,cAAc,EAAmB,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAC;AAG/B,yDAAyD;AACzD,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,cAAc,CAAC;CACpB;AAMD,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,EAAE;aACH,IAAI,EAAE,yBAAyB;aAC/B,UAAU,EAAE,mBAAmB;aAC/B,KAAK,EAAE,qBAAqB;IAJ9C,OAAO;IAOP,qDAAqD;WACxC,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC;IAU5E,mEAAmE;IAC7D,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAIjD;;;;OAIG;YACW,QAAQ;IAyBtB;;;;;;;;OAQG;IACG,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,SAAS,gBAAgB,EAAE,GAClC,OAAO,CAAC,WAAW,EAAE,CAAC;CAoD1B;AAiBD,2BAA2B;AAC3B,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,cAAc,CAAC,CAEzB"}
@@ -3,7 +3,12 @@
3
3
  *
4
4
  * @packageDocumentation
5
5
  */
6
+ export { AssemblyService, type AssemblyServiceOptions, type BillStructure, type BillStructureLine, BomCycleError, type BomCyclePathEntry, type ComponentKind, createAssemblyService, type ResolveComponentOptions, type ResolvedComponent, } from './AssemblyService.js';
6
7
  export { BomService, type BomServiceOptions, type ComponentCostResolver, createBomService, } from './BomService.js';
7
8
  export { type InstalledManufacturingDispatchHandlers, type InstallManufacturingDispatchHandlersOptions, installManufacturingDispatchHandlers, type ProductionOrderCompletedPayload, type ProductionOrderPostedPayload, } from './dispatch-handlers.js';
9
+ export { createOperationService, OperationService, type OperationServiceOptions, } from './OperationService.js';
10
+ export { createProductionRunService, ProductionRunService, type ProductionRunServiceOptions, } from './ProductionRunService.js';
8
11
  export { type ConsumeMaterialsOptions, type ConsumeResult, createProductionService, type ProduceFinishedGoodsOptions, type ProduceResult, type ProductionOrderRef, ProductionService, type ProductionServiceOptions, } from './ProductionService.js';
12
+ export { createRoutingService, RoutingService, type RoutingServiceOptions, } from './RoutingService.js';
13
+ export { BomStructureCycleError } from './structure-walk.js';
9
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,sCAAsC,EAC3C,KAAK,2CAA2C,EAChD,oCAAoC,EACpC,KAAK,+BAA+B,EACpC,KAAK,4BAA4B,GAClC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,uBAAuB,EACvB,KAAK,2BAA2B,EAChC,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,qBAAqB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,sCAAsC,EAC3C,KAAK,2CAA2C,EAChD,oCAAoC,EACpC,KAAK,+BAA+B,EACpC,KAAK,4BAA4B,GAClC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,KAAK,uBAAuB,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,uBAAuB,EACvB,KAAK,2BAA2B,EAChC,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,KAAK,qBAAqB,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The shared step of every multi-level walk in {@link BomService}: read a
3
+ * bill's lines, resolve each component, and decide whether to open a
4
+ * sub-assembly's active bill. Explosion, planning, cost and labour all walk
5
+ * the same way through this class, so they agree on what is opened.
6
+ *
7
+ * A walk is bounded three ways: by the caller's `levels`, by
8
+ * {@link MAX_EXPLOSION_DEPTH} and {@link MAX_EXPLOSION_LINES}, and by the path
9
+ * of products above the current line, which turns a cycle already present in
10
+ * stored data into a {@link BomStructureCycleError} instead of a loop.
11
+ *
12
+ * @internal
13
+ * @packageDocumentation
14
+ */
15
+ import type { BillOfMaterials } from '../models/BillOfMaterials.js';
16
+ import type { BomLine } from '../models/BomLine.js';
17
+ import { type ExplosionLevels, type ExplosionPathEntry } from '../types.js';
18
+ import { type AssemblyService, BomCycleError, type BomCyclePathEntry, type ResolvedComponent } from './AssemblyService.js';
19
+ /**
20
+ * Thrown when a multi-level walk meets a product that already contains
21
+ * itself in stored data (a loop saved before cycle refusal existed, or
22
+ * written around it). Carries the loop as `path`, like the
23
+ * {@link BomCycleError} it extends.
24
+ */
25
+ export declare class BomStructureCycleError extends BomCycleError {
26
+ name: string;
27
+ constructor(bomId: string, path: BomCyclePathEntry[]);
28
+ }
29
+ /**
30
+ * The deepest level a walk may open for `levels`. Throws for anything that is
31
+ * not a whole number from 1 to {@link MAX_EXPLOSION_DEPTH} or `'all'`.
32
+ */
33
+ export declare function maxLevelFor(levels: ExplosionLevels | undefined): number;
34
+ /** `true` when the caller asked for a walk rather than the single-level form. */
35
+ export declare function isMultiLevel(levels: ExplosionLevels | undefined): boolean;
36
+ /** One walk from one top bill; caches what it reads for the walk's lifetime. */
37
+ export declare class StructureWalk {
38
+ private readonly assemblies;
39
+ /** The bill the walk starts from. */
40
+ readonly top: BillOfMaterials;
41
+ /** The caller's `levels`. */
42
+ readonly levels: ExplosionLevels;
43
+ private readonly components;
44
+ private readonly bills;
45
+ private lineCount;
46
+ /** The deepest level whose lines the walk reads. */
47
+ readonly maxLevel: number;
48
+ constructor(assemblies: AssemblyService,
49
+ /** The bill the walk starts from. */
50
+ top: BillOfMaterials,
51
+ /** The caller's `levels`. */
52
+ levels: ExplosionLevels);
53
+ /**
54
+ * Resolve a component SKU, reading assemblies' active bills in the top
55
+ * bill's tenant so a shared assembly opens that tenant's bill.
56
+ */
57
+ resolve(skuId: string): Promise<ResolvedComponent>;
58
+ /**
59
+ * A bill's lines in the top bill's tenant (and global lines), counted
60
+ * against {@link MAX_EXPLOSION_LINES} every time the walk visits them (a
61
+ * shared sub-assembly counts once per use).
62
+ */
63
+ linesOf(bomId: string): Promise<BomLine[]>;
64
+ /** The path entry for the top bill. */
65
+ root(): Promise<ExplosionPathEntry>;
66
+ /**
67
+ * The bill to open below a line at `level`, or `null` when the component
68
+ * is not a sub-assembly with an active bill or `levels` stops here.
69
+ *
70
+ * @throws {BomStructureCycleError} when the sub-assembly is already on
71
+ * `path` (it would contain itself).
72
+ * @throws {BomExplosionLimitError} when `levels: 'all'` would go deeper
73
+ * than {@link MAX_EXPLOSION_DEPTH}.
74
+ */
75
+ open(component: ResolvedComponent, level: number, path: readonly ExplosionPathEntry[]): ExplosionPathEntry | null;
76
+ }
77
+ //# sourceMappingURL=structure-walk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structure-walk.d.ts","sourceRoot":"","sources":["../../src/services/structure-walk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EAGxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,eAAe,EACpB,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAE9B;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,aAAa;IAC9C,IAAI,SAA4B;gBAE7B,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE;CAMrD;AAKD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,GAAG,MAAM,CAQvE;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,GAAG,OAAO,CAEzE;AAED,gFAAgF;AAChF,qBAAa,aAAa;IAQtB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,qCAAqC;IACrC,QAAQ,CAAC,GAAG,EAAE,eAAe;IAC7B,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,eAAe;IAXlC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiD;IAC5E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAyC;IAC/D,OAAO,CAAC,SAAS,CAAK;IACtB,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAGP,UAAU,EAAE,eAAe;IAC5C,qCAAqC;IAC5B,GAAG,EAAE,eAAe;IAC7B,6BAA6B;IACpB,MAAM,EAAE,eAAe;IAKlC;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAWlD;;;;OAIG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAkBhD,uCAAuC;IACjC,IAAI,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAczC;;;;;;;;OAQG;IACH,IAAI,CACF,SAAS,EAAE,iBAAiB,EAC5B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,SAAS,kBAAkB,EAAE,GAClC,kBAAkB,GAAG,IAAI;CAoB7B"}