@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,62 @@
1
+ /**
2
+ * Assembly — the product that is made, the counterpart to `Material` (the
3
+ * product that is consumed).
4
+ *
5
+ * A single-table-inheritance subtype of `@happyvertical/smrt-products`
6
+ * `Product`: assembly rows live in the shared `products` table with
7
+ * `productType: 'assembly'` and `_meta_type:
8
+ * '@happyvertical/smrt-manufacturing:Assembly'`. Its own fields are
9
+ * ordinary columns that this package adds to that table.
10
+ *
11
+ * Everything else comes from a neighbour and is deliberately not repeated
12
+ * here:
13
+ *
14
+ * - name, description, price, category and tags from `Product`;
15
+ * - part number, barcode and stock from its `Sku` (`smrt-products`) and the
16
+ * stock levels in `smrt-inventory`;
17
+ * - what it is made of from its {@link BillOfMaterials} and {@link BomLine}s;
18
+ * - specs, plans and drawings from `ProductAsset` links.
19
+ *
20
+ * **Nesting lives in the bill, not on the assembly.** A sub-assembly is a
21
+ * bill line whose component SKU belongs to another `Assembly`; there is no
22
+ * children list to keep in sync. Use {@link AssemblyService.resolveComponent}
23
+ * to tell a sub-assembly from a material or a bought item.
24
+ *
25
+ * @packageDocumentation
26
+ */
27
+ import { Product, type ProductOptions, ProductType } from '@happyvertical/smrt-products/models';
28
+ /**
29
+ * Options accepted by the {@link Assembly} constructor.
30
+ */
31
+ export interface AssemblyOptions extends ProductOptions {
32
+ estimatedLabourMinutes?: number;
33
+ defaultOperationId?: string | null;
34
+ partReference?: string;
35
+ }
36
+ export declare class Assembly extends Product {
37
+ productType: ProductType;
38
+ /**
39
+ * Labour to build one unit, in whole minutes. A planning estimate until
40
+ * routing steps (smrt#3445) provide labour per operation; `0` means not
41
+ * estimated.
42
+ */
43
+ estimatedLabourMinutes: number;
44
+ /**
45
+ * The {@link Operation} that work on this assembly is booked to by
46
+ * default, or `null` for none. `RESTRICT`, like `RoutingStep.operationId`:
47
+ * operations are retired, never deleted.
48
+ */
49
+ defaultOperationId: string | null;
50
+ /**
51
+ * The organization's own drawing or part number for this assembly,
52
+ * alongside (not instead of) the SKU code.
53
+ */
54
+ partReference: string;
55
+ constructor(options?: AssemblyOptions);
56
+ /**
57
+ * Refuses a labour estimate that is not a whole number of minutes of zero
58
+ * or more, on every save (generated REST and collection writes included).
59
+ */
60
+ protected validateBeforeSave(): Promise<void>;
61
+ }
62
+ //# sourceMappingURL=Assembly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Assembly.d.ts","sourceRoot":"","sources":["../../src/models/Assembly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAQH,OAAO,EACL,OAAO,EACP,KAAK,cAAc,EACnB,WAAW,EACZ,MAAM,qCAAqC,CAAC;AAI7C;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACrD,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAOD,qBAUa,QAAS,SAAQ,OAAO;IAC1B,WAAW,EAAE,WAAW,CAAwB;IAEzD;;;;OAIG;IAEH,sBAAsB,EAAE,MAAM,CAAK;IAEnC;;;;OAIG;IAEH,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEzC;;;OAGG;IAEH,aAAa,EAAE,MAAM,CAAM;gBAEf,OAAO,GAAE,eAAoB;IAUzC;;;OAGG;cACsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CAW7D"}
@@ -12,8 +12,8 @@
12
12
  * other vertical that builds finished goods from components.
13
13
  *
14
14
  * Cross-package references (`productId`) are plain string ids — never
15
- * `@foreignKey()` — so this package can be consumed without pulling in the
16
- * upstream catalog package.
15
+ * `@foreignKey()` — so the schema does not couple to the catalog package's
16
+ * table layout. The product is usually an `Assembly`.
17
17
  *
18
18
  * @packageDocumentation
19
19
  */
@@ -37,8 +37,8 @@ export declare class BillOfMaterials extends SmrtObject {
37
37
  /**
38
38
  * Plain string reference to the upstream product this BOM produces.
39
39
  * Typically a `Product.id` (or any STI subtype thereof) from
40
- * `@happyvertical/smrt-products`. Cross-package id, intentionally not
41
- * a `@foreignKey()`, so this package does not pull in `smrt-products`.
40
+ * `@happyvertical/smrt-products`, usually an `Assembly`. Cross-package
41
+ * id, intentionally not a `@foreignKey()`.
42
42
  */
43
43
  productId: string;
44
44
  /**
@@ -74,5 +74,13 @@ export declare class BillOfMaterials extends SmrtObject {
74
74
  */
75
75
  currency: string;
76
76
  constructor(options?: BillOfMaterialsOptions);
77
+ /**
78
+ * Refuses saving the bill as `active` when one of its lines would make
79
+ * its product contain itself, directly or through sub-assemblies' active
80
+ * bills, with a `BomCycleError` naming the path. Draft and superseded
81
+ * bills are not part of the structure and are not checked here (their
82
+ * lines are checked as they are saved).
83
+ */
84
+ protected validateBeforeSave(): Promise<void>;
77
85
  }
78
86
  //# sourceMappingURL=BillOfMaterials.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BillOfMaterials.d.ts","sourceRoot":"","sources":["../../src/models/BillOfMaterials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAEL,UAAU,EACV,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IACrC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAUa,eAAgB,SAAQ,UAAU;IAC7C,6DAA6D;IAE7D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;;;;OAKG;IAE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EAAE,MAAM,CAAM;IAEnB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAS;gBAEb,OAAO,GAAE,sBAA2B;IAkBhD;;;;;;OAMG;cACsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ7D"}
@@ -9,11 +9,10 @@
9
9
  * material consumed but not incorporated into a finished unit.
10
10
  *
11
11
  * Cross-package references (`componentSkuId`) are plain string ids — never
12
- * `@foreignKey()` — so this package can ship without a hard runtime
13
- * dependency on `@happyvertical/smrt-products` (the `Sku` model lives
14
- * there) or `@happyvertical/smrt-inventory` (which holds the stock
15
- * levels / movements addressed by the id) even though all three almost
16
- * always travel together.
12
+ * `@foreignKey()`. The `Sku` model lives in `@happyvertical/smrt-products`
13
+ * and `@happyvertical/smrt-inventory` holds the stock levels and movements
14
+ * addressed by the id. When the SKU belongs to an `Assembly`, the line is a
15
+ * sub-assembly: `AssemblyService.resolveComponent` says which.
17
16
  *
18
17
  * @packageDocumentation
19
18
  */
@@ -84,5 +83,12 @@ export declare class BomLine extends SmrtObject {
84
83
  * `effectiveQty = qtyPerUnit * (1 + wastePercent / 100)`
85
84
  */
86
85
  effectiveQtyPerUnit(): number;
86
+ /**
87
+ * Refuses a line that would make its bill's product contain itself,
88
+ * directly or through sub-assemblies' active bills, with a
89
+ * `BomCycleError` naming the path. Runs on every save, so the generated
90
+ * REST `create`/`update` routes refuse it too.
91
+ */
92
+ protected validateBeforeSave(): Promise<void>;
87
93
  }
88
94
  //# sourceMappingURL=BomLine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BomLine.d.ts","sourceRoot":"","sources":["../../src/models/BomLine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAEL,UAAU,EACV,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAGlC;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,iBAAiB;IACvD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAA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8D;IAE9D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;;;;;OAMG;IAEH,KAAK,EAAE,MAAM,CAAM;IAEnB;;;;;;OAMG;IAEH,cAAc,EAAE,MAAM,CAAM;IAE5B;;;;OAIG;IAEH,UAAU,EAAE,MAAM,CAAO;IAEzB;;;;;;OAMG;IACH,GAAG,EAAE,MAAM,CAAU;IAErB;;;;;;OAMG;IAEH,YAAY,EAAE,MAAM,CAAO;IAE3B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAM;gBAEP,OAAO,GAAE,cAAmB;IAaxC;;;;;OAKG;IACH,mBAAmB,IAAI,MAAM;IAM7B;;;;;OAKG;cACsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7D"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Operation — one kind of work done to build something: cut, weld, assemble,
3
+ * inspect, bake, pack. A managed list per tenant that routing steps point at.
4
+ *
5
+ * Retiring an operation (`isActive = false`) keeps it on every routing and
6
+ * history that already names it and takes it out of pickers; an operation is
7
+ * never deleted. Time recorded against an operation is not modelled here — it
8
+ * stays in `@happyvertical/smrt-timesheets` or the application.
9
+ *
10
+ * Strictly industry-neutral.
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ import { SmrtObject, type SmrtObjectOptions } from '@happyvertical/smrt-core';
15
+ /**
16
+ * Options accepted by the {@link Operation} constructor.
17
+ */
18
+ export interface OperationOptions extends SmrtObjectOptions {
19
+ tenantId?: string | null;
20
+ code?: string;
21
+ name?: string;
22
+ category?: string;
23
+ isActive?: boolean;
24
+ requiredQualificationId?: string | null;
25
+ }
26
+ export declare class Operation extends SmrtObject {
27
+ /** Tenant scope. `null` means the operation is a global record. */
28
+ tenantId: string | null;
29
+ /**
30
+ * Short stable code, unique per tenant (`CUT`, `WELD`). Treated as the
31
+ * operation's identity by {@link OperationService}: it is set when the
32
+ * operation is defined and is not changed afterwards; rename the `name`.
33
+ */
34
+ code: string;
35
+ /** Human-readable name shown in lists and pickers. */
36
+ name: string;
37
+ /**
38
+ * Free-text grouping for lists (`fabrication`, `finishing`, `quality`).
39
+ * Empty when the operation is not grouped.
40
+ */
41
+ category: string;
42
+ /**
43
+ * `false` once the operation is retired. A retired operation stays on the
44
+ * routings and history that name it and is left out of pickers.
45
+ */
46
+ isActive: boolean;
47
+ /**
48
+ * Optional id of the qualification definition a worker needs to start this
49
+ * operation: a `Qualification` from `@happyvertical/smrt-human-resources`.
50
+ * Declared as a cross-package reference (metadata only: this package takes no
51
+ * dependency on it and does not validate the id); an application reads it to
52
+ * decide who may start the operation. `null` when none is required.
53
+ */
54
+ requiredQualificationId: string | null;
55
+ constructor(options?: OperationOptions);
56
+ /** Operations are retired, never deleted, so history keeps resolving. */
57
+ delete(): Promise<void>;
58
+ }
59
+ //# sourceMappingURL=Operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Operation.d.ts","sourceRoot":"","sources":["../../src/models/Operation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAGL,UAAU,EACV,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAGlC;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC;AAED,qBAWa,SAAU,SAAQ,UAAU;IACvC,mEAAmE;IAEnE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;;;OAIG;IAEH,IAAI,EAAE,MAAM,CAAM;IAElB,sDAAsD;IAEtD,IAAI,EAAE,MAAM,CAAM;IAElB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAM;IAEtB;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAQ;IAEzB;;;;;;OAMG;IAIH,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAQ;gBAElC,OAAO,GAAE,gBAAqB;IAW1C,yEAAyE;IAC1D,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAKvC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * ProductionRun — a build of some quantity of a product against one
3
+ * {@link BillOfMaterials}, reported as it happens: "25 to build, 12 done".
4
+ *
5
+ * The run pins the bill it was started against, carries the target and the
6
+ * completed quantity, and moves through `planned` → `in_progress` → `done`,
7
+ * or to `cancelled`. Each report of finished units is a dated
8
+ * {@link ProductionRunCompletion}; `completedQty` is their sum.
9
+ *
10
+ * Writes go through `ProductionRunService`, which keeps `completedQty` equal
11
+ * to the completions under concurrent reporting and enforces the status
12
+ * transitions. The generated REST/MCP/CLI surfaces are read-only for that
13
+ * reason.
14
+ *
15
+ * This is the shop-floor record of building. It is not the commercial
16
+ * instruction to make goods (`ProductionOrder` in `@happyvertical/smrt-commerce`,
17
+ * which carries terms and money); several runs may serve one order, or none
18
+ * (make to stock). An application that has both links them itself.
19
+ *
20
+ * @packageDocumentation
21
+ */
22
+ import { SmrtObject, type SmrtObjectOptions } from '@happyvertical/smrt-core';
23
+ /**
24
+ * Where a {@link ProductionRun} is:
25
+ *
26
+ * - `planned` — created, nothing reported yet.
27
+ * - `in_progress` — started, or at least one completion reported.
28
+ * - `done` — the target was reached, or the run was finished short.
29
+ * - `cancelled` — stopped; completions already reported stay.
30
+ */
31
+ export type ProductionRunStatus = 'planned' | 'in_progress' | 'done' | 'cancelled';
32
+ /** Every {@link ProductionRunStatus}, in lifecycle order. */
33
+ export declare const PRODUCTION_RUN_STATUSES: readonly ProductionRunStatus[];
34
+ /**
35
+ * Options accepted by the {@link ProductionRun} constructor.
36
+ */
37
+ export interface ProductionRunOptions extends SmrtObjectOptions {
38
+ tenantId?: string | null;
39
+ bomId?: string;
40
+ targetQty?: number;
41
+ completedQty?: number;
42
+ status?: ProductionRunStatus;
43
+ }
44
+ export declare class ProductionRun extends SmrtObject {
45
+ /** Tenant scope. `null` means the run is a global record. */
46
+ tenantId: string | null;
47
+ /**
48
+ * The bill the run builds against, pinned when the run is created.
49
+ * Restrict: a bill with runs is history and is not deleted.
50
+ */
51
+ bomId: string;
52
+ /** Units of the bill's product to build. Decimal; greater than zero. */
53
+ targetQty: number;
54
+ /** Units reported done so far: the sum of the run's completions. */
55
+ completedQty: number;
56
+ /** Lifecycle status; see {@link ProductionRunStatus}. */
57
+ status: ProductionRunStatus;
58
+ constructor(options?: ProductionRunOptions);
59
+ /**
60
+ * Units still to build, at the six-decimal quantity precision; `0` once
61
+ * the target is reached.
62
+ */
63
+ remainingQty(): number;
64
+ /** Refuses a status outside the lifecycle and impossible quantities. */
65
+ protected validateBeforeSave(): Promise<void>;
66
+ }
67
+ //# sourceMappingURL=ProductionRun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductionRun.d.ts","sourceRoot":"","sources":["../../src/models/ProductionRun.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAGL,UAAU,EACV,KAAK,iBAAiB,EAGvB,MAAM,0BAA0B,CAAC;AAKlC;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,aAAa,GACb,MAAM,GACN,WAAW,CAAC;AAEhB,6DAA6D;AAC7D,eAAO,MAAM,uBAAuB,EAAE,SAAS,mBAAmB,EAKjE,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B;AAED,qBASa,aAAc,SAAQ,UAAU;IAC3C,6DAA6D;IAE7D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;;OAGG;IAEH,KAAK,EAAE,MAAM,CAAM;IAEnB,wEAAwE;IAExE,SAAS,EAAE,MAAM,CAAO;IAExB,oEAAoE;IAEpE,YAAY,EAAE,MAAM,CAAO;IAE3B,yDAAyD;IAEzD,MAAM,EAAE,mBAAmB,CAAa;gBAE5B,OAAO,GAAE,oBAAyB;IAU9C;;;OAGG;IACH,YAAY,IAAI,MAAM;IAOtB,wEAAwE;cAC/C,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CAuB7D"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * ProductionRunCompletion — one dated report of finished units on a
3
+ * {@link ProductionRun} ("12 done on Tuesday").
4
+ *
5
+ * Written only by `ProductionRunService.recordCompletion`, in the same
6
+ * transaction that adds `qty` to the run's `completedQty` and, when the
7
+ * caller asks, posts the stock movements; those movements carry
8
+ * `sourceType: 'ProductionRunCompletion'` and this row's id. Read-only over
9
+ * the generated surfaces.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import { SmrtObject, type SmrtObjectOptions } from '@happyvertical/smrt-core';
14
+ /**
15
+ * Options accepted by the {@link ProductionRunCompletion} constructor.
16
+ */
17
+ export interface ProductionRunCompletionOptions extends SmrtObjectOptions {
18
+ tenantId?: string | null;
19
+ runId?: string;
20
+ qty?: number;
21
+ completedAt?: Date | string;
22
+ }
23
+ export declare class ProductionRunCompletion extends SmrtObject {
24
+ /** Tenant scope. `null` means a global record. */
25
+ tenantId: string | null;
26
+ /** The run the units were built on. Cascade: completions belong to their run. */
27
+ runId: string;
28
+ /** Units finished in this report. Decimal; greater than zero. */
29
+ qty: number;
30
+ /** When the units were finished (defaults to when the report was made). */
31
+ completedAt: Date;
32
+ constructor(options?: ProductionRunCompletionOptions);
33
+ /** Refuses a report of zero, negative or non-finite units. */
34
+ protected validateBeforeSave(): Promise<void>;
35
+ }
36
+ //# sourceMappingURL=ProductionRunCompletion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductionRunCompletion.d.ts","sourceRoot":"","sources":["../../src/models/ProductionRunCompletion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAGL,UAAU,EACV,KAAK,iBAAiB,EAGvB,MAAM,0BAA0B,CAAC;AAIlC;;GAEG;AACH,MAAM,WAAW,8BAA+B,SAAQ,iBAAiB;IACvE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;CAC7B;AAED,qBAQa,uBAAwB,SAAQ,UAAU;IACrD,kDAAkD;IAElD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B,iFAAiF;IAEjF,KAAK,EAAE,MAAM,CAAM;IAEnB,iEAAiE;IAEjE,GAAG,EAAE,MAAM,CAAO;IAElB,2EAA2E;IAC3E,WAAW,EAAE,IAAI,CAAc;gBAEnB,OAAO,GAAE,8BAAmC;IAYxD,8DAA8D;cACrC,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CAU7D"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * RoutingStep — one operation in the routing of a {@link BillOfMaterials}.
3
+ *
4
+ * A routing is the ordered list of steps for building one unit of the bill's
5
+ * product. It is optional: a bill with no routing steps behaves exactly as a
6
+ * bill always has. Steps are ordered by `sequence`, unique within the bill.
7
+ *
8
+ * Cross-package-style references (`bomId`, `operationId`) are plain string ids,
9
+ * as elsewhere in this package.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import { SmrtObject, type SmrtObjectOptions } from '@happyvertical/smrt-core';
14
+ /**
15
+ * Options accepted by the {@link RoutingStep} constructor.
16
+ */
17
+ export interface RoutingStepOptions extends SmrtObjectOptions {
18
+ tenantId?: string | null;
19
+ bomId?: string;
20
+ operationId?: string;
21
+ sequence?: number;
22
+ estimatedMinutes?: number;
23
+ notes?: string;
24
+ }
25
+ export declare class RoutingStep extends SmrtObject {
26
+ /** Tenant scope. `null` means the step is a global record. */
27
+ tenantId: string | null;
28
+ /**
29
+ * The owning {@link BillOfMaterials}. Cascade: a routing belongs to its bill.
30
+ * (`BomLine.bomId` is still a plain string; see AGENTS.md.)
31
+ */
32
+ bomId: string;
33
+ /** The {@link Operation} performed here. Restrict: operations are retired, never deleted. */
34
+ operationId: string;
35
+ /** Position in the routing, starting at 1 and without gaps. */
36
+ sequence: number;
37
+ /**
38
+ * Estimated working minutes at this step to build one unit of the bill's
39
+ * product. Decimal so `7.5` round-trips.
40
+ */
41
+ estimatedMinutes: number;
42
+ /** Optional free-form note for this step. */
43
+ notes: string;
44
+ constructor(options?: RoutingStepOptions);
45
+ }
46
+ //# sourceMappingURL=RoutingStep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoutingStep.d.ts","sourceRoot":"","sources":["../../src/models/RoutingStep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAGL,UAAU,EACV,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAKlC;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBASa,WAAY,SAAQ,UAAU;IACzC,8DAA8D;IAE9D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;;OAGG;IAEH,KAAK,EAAE,MAAM,CAAM;IAEnB,6FAA6F;IAE7F,WAAW,EAAE,MAAM,CAAM;IAEzB,+DAA+D;IAE/D,QAAQ,EAAE,MAAM,CAAK;IAErB;;;OAGG;IAEH,gBAAgB,EAAE,MAAM,CAAO;IAE/B,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAM;gBAEP,OAAO,GAAE,kBAAuB;CAW7C"}
@@ -9,6 +9,11 @@
9
9
  * @packageDocumentation
10
10
  */
11
11
  import '../__smrt-register__.js';
12
+ export { Assembly, type AssemblyOptions } from './Assembly.js';
12
13
  export { BillOfMaterials, type BillOfMaterialsOptions, } from './BillOfMaterials.js';
13
14
  export { BomLine, type BomLineOptions } from './BomLine.js';
15
+ export { Operation, type OperationOptions } from './Operation.js';
16
+ export { PRODUCTION_RUN_STATUSES, ProductionRun, type ProductionRunOptions, type ProductionRunStatus, } from './ProductionRun.js';
17
+ export { ProductionRunCompletion, type ProductionRunCompletionOptions, } from './ProductionRunCompletion.js';
18
+ export { RoutingStep, type RoutingStepOptions } from './RoutingStep.js';
14
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,GAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,GAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,uBAAuB,EACvB,KAAK,8BAA8B,GACpC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Types and error classes for operations, routing and the labour estimate.
3
+ *
4
+ * Strictly industry-neutral.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import type { Operation } from './models/Operation.js';
9
+ import type { SubAssemblyLabour } from './types.js';
10
+ /**
11
+ * Callback that returns the hourly labour rate for an operation, in the bill's
12
+ * currency, or `null` / `undefined` when no rate is known. The package holds no
13
+ * rates: the caller decides where they come from (a price list, a rate class
14
+ * the application keeps against the operation code, a timesheet rate). Mirrors
15
+ * `ComponentCostResolver` for materials.
16
+ */
17
+ export type OperationRateResolver = (operation: Operation) => Promise<number | null | undefined> | number | null | undefined;
18
+ /** One step of {@link LabourEstimate}. */
19
+ export interface RoutingStepEstimate {
20
+ /** The routing step id. */
21
+ stepId: string;
22
+ /** Position in the routing, starting at 1. */
23
+ sequence: number;
24
+ /** Plain string id of the operation. */
25
+ operationId: string;
26
+ /** Operation code, or `''` if the operation row is missing. */
27
+ operationCode: string;
28
+ /** Operation name, or `''` if the operation row is missing. */
29
+ operationName: string;
30
+ /** Estimated working minutes per produced unit. */
31
+ estimatedMinutes: number;
32
+ /** Hourly rate from the resolver, or `0` when unavailable. */
33
+ hourlyRate: number;
34
+ /** `estimatedMinutes / 60 * hourlyRate`; `0` when the rate is unavailable. */
35
+ stepCost: number;
36
+ /** `true` when no resolver was supplied or it returned no rate. */
37
+ rateUnavailable: boolean;
38
+ }
39
+ /**
40
+ * Estimated labour per produced unit, returned by
41
+ * `BomService.computeLabourEstimate`. A bill with no routing returns an empty
42
+ * `steps` array and zero totals.
43
+ */
44
+ export interface LabourEstimate {
45
+ /** The bill that was rolled up. */
46
+ bomId: string;
47
+ /** `true` when the bill has at least one routing step. */
48
+ hasRouting: boolean;
49
+ /** Total estimated working minutes per produced unit. */
50
+ totalMinutes: number;
51
+ /** Total estimated labour cost per unit; counts only steps with a rate. */
52
+ totalCost: number;
53
+ /** ISO 4217 currency code of the bill. */
54
+ currency: string;
55
+ /** Steps in routing order. */
56
+ steps: RoutingStepEstimate[];
57
+ /** `true` when a step's rate was unavailable, so `totalCost` is a lower bound. */
58
+ hasMissingRates: boolean;
59
+ /**
60
+ * Multi-level only (`{ levels }` above 1): every sub-assembly the walk
61
+ * opened, at any depth, with its own routing estimate and how many units of
62
+ * it one unit of this bill's product needs. `totalMinutes`, `totalCost`,
63
+ * `hasRouting` and `hasMissingRates` then cover them too; `steps` stays this
64
+ * bill's own routing.
65
+ */
66
+ subAssemblies?: SubAssemblyLabour[];
67
+ }
68
+ /** One step handed to `RoutingService.replaceRouting`. */
69
+ export interface RoutingStepInput {
70
+ /** Plain string id of the operation to perform. */
71
+ operationId: string;
72
+ /** Estimated working minutes per produced unit; zero or more. */
73
+ estimatedMinutes: number;
74
+ /** Optional free-form note. */
75
+ notes?: string;
76
+ }
77
+ /** Input for `OperationService.define`. */
78
+ export interface DefineOperationInput {
79
+ /** Unique per tenant; not changed afterwards. */
80
+ code: string;
81
+ name: string;
82
+ category?: string;
83
+ /** Plain string id of a `smrt-human-resources` qualification definition. */
84
+ requiredQualificationId?: string;
85
+ }
86
+ /** Thrown when an operation id does not exist. */
87
+ export declare class OperationNotFoundError extends Error {
88
+ readonly operationId: string;
89
+ name: string;
90
+ constructor(operationId: string);
91
+ }
92
+ /** Thrown when defining an operation whose code is already in use. */
93
+ export declare class DuplicateOperationCodeError extends Error {
94
+ readonly code: string;
95
+ name: string;
96
+ constructor(code: string);
97
+ }
98
+ /** Thrown when a routing would newly add a retired operation. */
99
+ export declare class OperationRetiredError extends Error {
100
+ readonly operationId: string;
101
+ name: string;
102
+ constructor(operationId: string);
103
+ }
104
+ /** Thrown for invalid operation or routing input. */
105
+ export declare class InvalidOperationInputError extends Error {
106
+ name: string;
107
+ }
108
+ //# sourceMappingURL=operation-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-types.d.ts","sourceRoot":"","sources":["../src/operation-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,SAAS,EAAE,SAAS,KACjB,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAEpE,0CAA0C;AAC1C,MAAM,WAAW,mBAAmB;IAClC,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,UAAU,EAAE,OAAO,CAAC;IACpB,yDAAyD;IACzD,YA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6
+ import type { ProductionRun } from './models/ProductionRun.js';
7
+ import type { ProductionRunCompletion } from './models/ProductionRunCompletion.js';
8
+ import type { ConsumeResult, ProduceResult } from './services/ProductionService.js';
9
+ /** Input for `ProductionRunService.createRun`. Give `bomId`, or `productId` for its active bill. */
10
+ export interface CreateProductionRunInput {
11
+ /** The bill to build against. Wins over `productId`. */
12
+ bomId?: string;
13
+ /** A product (usually an `Assembly`) whose active bill the run pins. */
14
+ productId?: string;
15
+ /** Units to build; greater than zero. */
16
+ targetQty: number;
17
+ }
18
+ /** Stock to consume when a completion is recorded: the run's bill, for the completed units. */
19
+ export interface CompletionConsumeOptions {
20
+ /** Location the components are taken from. */
21
+ locationId: string;
22
+ /** Optional free-form note on each movement. */
23
+ note?: string;
24
+ }
25
+ /** Finished goods to receive when a completion is recorded. */
26
+ export interface CompletionProduceOptions {
27
+ /** Location the finished units are received into. */
28
+ locationId: string;
29
+ /** The SKU of the bill's product that was built. */
30
+ finishedSkuId: string;
31
+ /** Optional free-form note on the movement. */
32
+ note?: string;
33
+ }
34
+ /** Input for `ProductionRunService.recordCompletion`. */
35
+ export interface RecordCompletionInput {
36
+ /** Units finished; greater than zero and no more than the run has left. */
37
+ qty: number;
38
+ /** When they were finished. Defaults to now. */
39
+ completedAt?: Date | string;
40
+ /**
41
+ * Consume the run's bill for `qty` units, in the same transaction. Omit
42
+ * (the default) to record progress without touching stock.
43
+ */
44
+ consume?: CompletionConsumeOptions;
45
+ /**
46
+ * Receive `qty` finished units, in the same transaction. Omit (the
47
+ * default) to record progress without touching stock.
48
+ */
49
+ produce?: CompletionProduceOptions;
50
+ }
51
+ /** Result of `ProductionRunService.recordCompletion`. */
52
+ export interface RecordCompletionResult {
53
+ /** The run after the completion. */
54
+ run: ProductionRun;
55
+ /** The completion that was recorded. */
56
+ completion: ProductionRunCompletion;
57
+ /** Components consumed; empty unless `consume` was given. */
58
+ consumed: ConsumeResult[];
59
+ /** Finished goods received; `null` unless `produce` was given. */
60
+ produced: ProduceResult | null;
61
+ }
62
+ /** Thrown when a production run id does not exist. */
63
+ export declare class ProductionRunNotFoundError extends Error {
64
+ readonly runId: string;
65
+ name: string;
66
+ constructor(runId: string);
67
+ }
68
+ /** Thrown when an action is not allowed in the run's current status. */
69
+ export declare class ProductionRunStateError extends Error {
70
+ readonly runId: string;
71
+ /** The run's status when the action was refused. */
72
+ readonly status: string;
73
+ /** What was attempted: `start`, `complete`, `finish`, `cancel`, `retarget`. */
74
+ readonly action: string;
75
+ name: string;
76
+ constructor(runId: string,
77
+ /** The run's status when the action was refused. */
78
+ status: string,
79
+ /** What was attempted: `start`, `complete`, `finish`, `cancel`, `retarget`. */
80
+ action: string);
81
+ }
82
+ /** Thrown when a completion would take the run past its target. */
83
+ export declare class ProductionRunOverCompletionError extends Error {
84
+ readonly runId: string;
85
+ /** The quantity reported. */
86
+ readonly qty: number;
87
+ /** What the run had left to build. */
88
+ readonly remaining: number;
89
+ name: string;
90
+ constructor(runId: string,
91
+ /** The quantity reported. */
92
+ qty: number,
93
+ /** What the run had left to build. */
94
+ remaining: number);
95
+ }
96
+ /** Thrown for invalid production run input (quantities, dates, bill). */
97
+ export declare class InvalidProductionRunInputError extends Error {
98
+ name: string;
99
+ }
100
+ //# sourceMappingURL=production-run-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"production-run-types.d.ts","sourceRoot":"","sources":["../src/production-run-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACd,MAAM,iCAAiC,CAAC;AAEzC,oGAAoG;AACpG,MAAM,WAAW,wBAAwB;IACvC,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yCAA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EAAE,MAAM;IAC9B,+EAA+E;IAC/D,MAAM,EAAE,MAAM;CAIjC;AAED,mEAAmE;AACnE,qBAAa,gCAAiC,SAAQ,KAAK;aAIvC,KAAK,EAAE,MAAM;IAC7B,6BAA6B;aACb,GAAG,EAAE,MAAM;IAC3B,sCAAsC;aACtB,SAAS,EAAE,MAAM;IAP1B,IAAI,SAAsC;gBAGjC,KAAK,EAAE,MAAM;IAC7B,6BAA6B;IACb,GAAG,EAAE,MAAM;IAC3B,sCAAsC;IACtB,SAAS,EAAE,MAAM;CAMpC;AAED,yEAAyE;AACzE,qBAAa,8BAA+B,SAAQ,KAAK;IAC9C,IAAI,SAAoC;CAClD"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Quantity precision for planning and production runs.
3
+ *
4
+ * Quantities are decimals held in binary floating point, so sums such as
5
+ * `0.1 + 0.2` and products such as `2.2 * 100` carry rounding noise. Rather
6
+ * than compare with a tolerance (which must grow with the value and so
7
+ * eventually hides a whole unit), quantities are kept to
8
+ * {@link QUANTITY_DECIMALS} decimal places: rounded through their decimal
9
+ * representation, and summed and compared exactly as whole millionths.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ /** Decimal places a quantity is kept to: a millionth of a unit. */
14
+ export declare const QUANTITY_DECIMALS = 6;
15
+ /**
16
+ * The largest quantity a production run accepts (target or report): every
17
+ * value up to it with {@link QUANTITY_DECIMALS} places has at most 15
18
+ * significant digits, so it survives a round trip through a double exactly
19
+ * and sums of them stay exact.
20
+ */
21
+ export declare const MAX_QUANTITY = 999999999;
22
+ /**
23
+ * `value` rounded to {@link QUANTITY_DECIMALS} decimal places (correctly
24
+ * rounded through its decimal representation, so `0.1 + 0.2` becomes
25
+ * exactly `0.3`).
26
+ */
27
+ export declare function roundQuantity(value: number): number;
28
+ /**
29
+ * `value` as a whole number of millionths, exactly (read from its decimal
30
+ * representation, not multiplied). Exact for any value up to
31
+ * {@link MAX_QUANTITY}.
32
+ */
33
+ export declare function toMillionths(value: number): number;
34
+ /** A whole number of millionths back as a quantity. */
35
+ export declare function fromMillionths(millionths: number): number;
36
+ //# sourceMappingURL=quantity.d.ts.map