@classytic/flow 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/LICENSE +21 -0
  3. package/README.md +258 -0
  4. package/dist/allocation-policy-my_HfzdV.d.mts +23 -0
  5. package/dist/base-MWBqRFM2.mjs +16 -0
  6. package/dist/catalog-bridge-K8bdkncJ.d.mts +29 -0
  7. package/dist/cost-layer.port-iH9pvZqB.d.mts +30 -0
  8. package/dist/cost-layer.service-BQ1bs-XN.mjs +86 -0
  9. package/dist/cost-layer.service-DWmo9dQz.d.mts +53 -0
  10. package/dist/count.port-BRqwGbi3.d.mts +57 -0
  11. package/dist/counting/index.d.mts +2 -0
  12. package/dist/counting/index.mjs +2 -0
  13. package/dist/counting.service-BiQXqorv.mjs +232 -0
  14. package/dist/counting.service-CpAxU2G0.d.mts +74 -0
  15. package/dist/domain/contracts/index.d.mts +3 -0
  16. package/dist/domain/contracts/index.mjs +1 -0
  17. package/dist/domain/enums/index.d.mts +2 -0
  18. package/dist/domain/enums/index.mjs +4 -0
  19. package/dist/domain/index.d.mts +24 -0
  20. package/dist/domain/index.mjs +10 -0
  21. package/dist/domain/policies/index.d.mts +4 -0
  22. package/dist/domain/policies/index.mjs +1 -0
  23. package/dist/domain-D5cpMpR0.mjs +96 -0
  24. package/dist/domain-errors-D7S9ydNF.mjs +133 -0
  25. package/dist/enums-C3_z6aHC.mjs +82 -0
  26. package/dist/event-bus-BNmyoJb4.mjs +37 -0
  27. package/dist/event-bus-Um_xrcMY.d.mts +21 -0
  28. package/dist/event-emitter.port-BFh2pasY.d.mts +183 -0
  29. package/dist/event-types-BSqQOvXv.mjs +29 -0
  30. package/dist/events/index.d.mts +3 -0
  31. package/dist/events/index.mjs +3 -0
  32. package/dist/idempotency.port-CTC70JON.d.mts +55 -0
  33. package/dist/index-Bia4m8d2.d.mts +67 -0
  34. package/dist/index-BmNm3oNU2.d.mts +107 -0
  35. package/dist/index-C5PciI9P.d.mts +203 -0
  36. package/dist/index-CMTUKEK_.d.mts +308 -0
  37. package/dist/index-C_aEnozN.d.mts +220 -0
  38. package/dist/index-CulWO137.d.mts +107 -0
  39. package/dist/index-DFF0GJ4J.d.mts +36 -0
  40. package/dist/index-DsE7lZdO.d.mts +11 -0
  41. package/dist/index-DwO9IdNa.d.mts +1 -0
  42. package/dist/index-dtWUZr2a2.d.mts +350 -0
  43. package/dist/index.d.mts +128 -0
  44. package/dist/index.mjs +102 -0
  45. package/dist/insufficient-stock.error-Dyr4BYaV.mjs +15 -0
  46. package/dist/location.port-CValXIpb.d.mts +52 -0
  47. package/dist/lot.port-ChsmvZqs.d.mts +32 -0
  48. package/dist/models/index.d.mts +2 -0
  49. package/dist/models/index.mjs +2 -0
  50. package/dist/models-CHTMbp-G.mjs +1020 -0
  51. package/dist/move-group.port-DHGoQA3d.d.mts +56 -0
  52. package/dist/move-status-DkaFp2GD.mjs +38 -0
  53. package/dist/move.port-Qg1CYp7h.d.mts +89 -0
  54. package/dist/package.service-4tcAwBbr.mjs +95 -0
  55. package/dist/package.service-C605NaBQ.d.mts +42 -0
  56. package/dist/packaging/index.d.mts +2 -0
  57. package/dist/packaging/index.mjs +2 -0
  58. package/dist/procurement/index.d.mts +2 -0
  59. package/dist/procurement/index.mjs +2 -0
  60. package/dist/quant.port-BBa66PBT.d.mts +42 -0
  61. package/dist/removal-policy-BItBB8FD.d.mts +29 -0
  62. package/dist/replenishment-rule.port-DnEYtbyD.d.mts +78 -0
  63. package/dist/replenishment.service-BT9P-HKM.mjs +284 -0
  64. package/dist/replenishment.service-HO0sDhB_.d.mts +89 -0
  65. package/dist/reporting/index.d.mts +2 -0
  66. package/dist/reporting/index.mjs +2 -0
  67. package/dist/reporting-CL5ffrKM.mjs +243 -0
  68. package/dist/repositories/index.d.mts +2 -0
  69. package/dist/repositories/index.mjs +2 -0
  70. package/dist/repositories-nZXJKvLW.mjs +842 -0
  71. package/dist/reservation-status-ZfuTaWG0.mjs +22 -0
  72. package/dist/reservation.port-l9NFQ0si.d.mts +85 -0
  73. package/dist/reservations/index.d.mts +2 -0
  74. package/dist/reservations/index.mjs +2 -0
  75. package/dist/reservations-Cg4wN0QB.mjs +112 -0
  76. package/dist/routing/index.d.mts +362 -0
  77. package/dist/routing/index.mjs +582 -0
  78. package/dist/runtime-config-C0ggPkiK.mjs +40 -0
  79. package/dist/runtime-config-CQLtPPqY.d.mts +38 -0
  80. package/dist/scan-token-CNM9QVLY.d.mts +26 -0
  81. package/dist/scanning/index.d.mts +45 -0
  82. package/dist/scanning/index.mjs +228 -0
  83. package/dist/services/index.d.mts +8 -0
  84. package/dist/services/index.mjs +8 -0
  85. package/dist/services-_lLO4Xbl.mjs +1009 -0
  86. package/dist/stock-move-group-C0DqUfPY.mjs +88 -0
  87. package/dist/stock-package-BIarxbDS.d.mts +19 -0
  88. package/dist/stock-quant-CZhgvTu7.d.mts +41 -0
  89. package/dist/tenant-guard-6Ne-BILP.mjs +12 -0
  90. package/dist/tenant-isolation.error-D3OcKUdx.mjs +11 -0
  91. package/dist/trace.service-B9vAh-l-.d.mts +55 -0
  92. package/dist/trace.service-DE6Eh8_8.mjs +71 -0
  93. package/dist/traceability/index.d.mts +2 -0
  94. package/dist/traceability/index.mjs +2 -0
  95. package/dist/types/index.d.mts +2 -0
  96. package/dist/types/index.mjs +1 -0
  97. package/dist/unit-of-work.port-CWEkrDKu.d.mts +17 -0
  98. package/dist/valuation/index.d.mts +78 -0
  99. package/dist/valuation/index.mjs +103 -0
  100. package/dist/valuation-policy-Dco8c9Vw.d.mts +14 -0
  101. package/dist/virtual-locations-B9zXqPdi.d.mts +38 -0
  102. package/package.json +155 -0
@@ -0,0 +1,45 @@
1
+ import { t as FlowContext } from "../index-DFF0GJ4J.mjs";
2
+ import { t as LocationPort } from "../location.port-CValXIpb.mjs";
3
+ import { t as LotPort } from "../lot.port-ChsmvZqs.mjs";
4
+ import { n as CatalogBridge } from "../catalog-bridge-K8bdkncJ.mjs";
5
+ import { n as ScanResolution, t as GS1Resolution } from "../scan-token-CNM9QVLY.mjs";
6
+
7
+ //#region src/scanning/chain-resolver.d.ts
8
+ /**
9
+ * ChainResolver — resolves a raw scan token through a prioritised chain:
10
+ * GS1-128 → Location → Lot → Serial → SKU → Unknown
11
+ */
12
+ declare class ChainResolver {
13
+ private locationPort;
14
+ private lotPort;
15
+ private catalogBridge;
16
+ constructor(locationPort: LocationPort, lotPort: LotPort, catalogBridge: CatalogBridge);
17
+ resolve(token: string, ctx: FlowContext): Promise<ScanResolution>;
18
+ }
19
+ //#endregion
20
+ //#region src/scanning/gs1-parser.d.ts
21
+ /**
22
+ * Parse a GS1-128 barcode string into its constituent Application Identifiers.
23
+ */
24
+ declare function parseGS1(barcode: string): GS1Resolution;
25
+ //#endregion
26
+ //#region src/scanning/scan.service.d.ts
27
+ /**
28
+ * EnhancedScanService — thin wrapper around ChainResolver that also
29
+ * exposes a synchronous GS1 decomposition method.
30
+ */
31
+ declare class EnhancedScanService {
32
+ private resolver;
33
+ constructor(resolver: ChainResolver);
34
+ /**
35
+ * Resolve a raw scan token through the full chain (GS1, location, lot, serial, SKU).
36
+ */
37
+ resolve(token: string, ctx: FlowContext): Promise<ScanResolution>;
38
+ /**
39
+ * Synchronously decompose a GS1-128 barcode into its AI components.
40
+ * Does not perform any backend lookups.
41
+ */
42
+ resolveGS1(barcode: string): GS1Resolution;
43
+ }
44
+ //#endregion
45
+ export { ChainResolver, EnhancedScanService, parseGS1 };
@@ -0,0 +1,228 @@
1
+ //#region src/scanning/gs1-parser.ts
2
+ const AI_DEFINITIONS = {
3
+ "01": {
4
+ type: "product",
5
+ length: 14
6
+ },
7
+ "10": {
8
+ type: "lot",
9
+ variableLength: true
10
+ },
11
+ "17": {
12
+ type: "expiry",
13
+ length: 6
14
+ },
15
+ "21": {
16
+ type: "serial",
17
+ variableLength: true
18
+ },
19
+ "37": {
20
+ type: "quantity",
21
+ variableLength: true
22
+ }
23
+ };
24
+ const WEIGHT_AI_PREFIX = "310";
25
+ const GS = String.fromCharCode(29);
26
+ /**
27
+ * Parse a GS1-128 barcode string into its constituent Application Identifiers.
28
+ */
29
+ function parseGS1(barcode) {
30
+ let raw = barcode;
31
+ if (raw.startsWith("]C1")) raw = raw.slice(3);
32
+ raw = raw.replace(/\((\d{2,4})\)/g, "$1");
33
+ const components = [];
34
+ let pos = 0;
35
+ while (pos < raw.length) {
36
+ const parsed = parseNextAI(raw, pos);
37
+ if (!parsed) break;
38
+ components.push(parsed.component);
39
+ pos = parsed.nextPos;
40
+ }
41
+ return {
42
+ token: barcode,
43
+ components,
44
+ resolvedSku: null,
45
+ resolvedLot: null
46
+ };
47
+ }
48
+ function parseNextAI(raw, pos) {
49
+ if (raw.length >= pos + 4) {
50
+ const fourChar = raw.substring(pos, pos + 4);
51
+ if (fourChar.startsWith(WEIGHT_AI_PREFIX)) {
52
+ const decimalPlaces = parseInt(fourChar[3], 10);
53
+ if (!Number.isNaN(decimalPlaces)) {
54
+ const valueStr = raw.substring(pos + 4, pos + 4 + 6);
55
+ if (valueStr.length === 6 && /^\d+$/.test(valueStr)) return {
56
+ component: {
57
+ ai: fourChar,
58
+ type: "weight",
59
+ value: parseInt(valueStr, 10) / 10 ** decimalPlaces
60
+ },
61
+ nextPos: pos + 4 + 6
62
+ };
63
+ }
64
+ }
65
+ }
66
+ if (raw.length >= pos + 2) {
67
+ const twoChar = raw.substring(pos, pos + 2);
68
+ const def = AI_DEFINITIONS[twoChar];
69
+ if (def) {
70
+ const aiLen = 2;
71
+ if (def.variableLength) return parseVariable(raw, pos, aiLen, twoChar, def.type);
72
+ return parseFixed(raw, pos, aiLen, twoChar, def.type, def.length);
73
+ }
74
+ }
75
+ return null;
76
+ }
77
+ function parseFixed(raw, pos, aiLen, ai, type, length) {
78
+ const start = pos + aiLen;
79
+ const valueStr = raw.substring(start, start + length);
80
+ if (valueStr.length < length) return null;
81
+ return {
82
+ component: {
83
+ ai,
84
+ type,
85
+ value: convertValue(ai, type, valueStr)
86
+ },
87
+ nextPos: start + length
88
+ };
89
+ }
90
+ function parseVariable(raw, pos, aiLen, ai, type) {
91
+ const start = pos + aiLen;
92
+ let end = raw.indexOf(GS, start);
93
+ if (end === -1) end = raw.length;
94
+ const valueStr = raw.substring(start, end);
95
+ if (valueStr.length === 0) return null;
96
+ const value = convertValue(ai, type, valueStr);
97
+ const nextPos = end < raw.length ? end + 1 : end;
98
+ return {
99
+ component: {
100
+ ai,
101
+ type,
102
+ value
103
+ },
104
+ nextPos
105
+ };
106
+ }
107
+ function convertValue(ai, _type, valueStr) {
108
+ if (ai === "17") return parseExpiryDate(valueStr);
109
+ if (ai === "37") {
110
+ const n = parseInt(valueStr, 10);
111
+ return Number.isNaN(n) ? valueStr : n;
112
+ }
113
+ return valueStr;
114
+ }
115
+ /**
116
+ * Parse YYMMDD expiry date. DD=00 means last day of month.
117
+ */
118
+ function parseExpiryDate(yymmdd) {
119
+ const yy = parseInt(yymmdd.substring(0, 2), 10);
120
+ const mm = parseInt(yymmdd.substring(2, 4), 10);
121
+ const dd = parseInt(yymmdd.substring(4, 6), 10);
122
+ const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
123
+ const currentCentury = Math.floor(currentYear / 100) * 100;
124
+ const year = yy <= (currentYear + 49) % 100 ? currentCentury + yy : currentCentury - 100 + yy;
125
+ if (dd === 0) return new Date(year, mm, 0);
126
+ return new Date(year, mm - 1, dd);
127
+ }
128
+ //#endregion
129
+ //#region src/scanning/chain-resolver.ts
130
+ /**
131
+ * ChainResolver — resolves a raw scan token through a prioritised chain:
132
+ * GS1-128 → Location → Lot → Serial → SKU → Unknown
133
+ */
134
+ var ChainResolver = class {
135
+ constructor(locationPort, lotPort, catalogBridge) {
136
+ this.locationPort = locationPort;
137
+ this.lotPort = lotPort;
138
+ this.catalogBridge = catalogBridge;
139
+ }
140
+ async resolve(token, ctx) {
141
+ const trimmed = token.trim();
142
+ if (isGS1(trimmed)) {
143
+ const gs1 = parseGS1(trimmed);
144
+ const gtinComponent = gs1.components.find((c) => c.type === "product");
145
+ if (gtinComponent) {
146
+ const sku = await this.catalogBridge.resolveSku(String(gtinComponent.value));
147
+ if (sku) return {
148
+ token: trimmed,
149
+ resolvedType: "sku",
150
+ resolvedId: sku.skuRef,
151
+ resolvedEntity: {
152
+ ...sku,
153
+ gs1: gs1.components
154
+ }
155
+ };
156
+ }
157
+ }
158
+ const location = await this.locationPort.findByBarcode(trimmed, ctx);
159
+ if (location) return {
160
+ token: trimmed,
161
+ resolvedType: "location",
162
+ resolvedId: location._id,
163
+ resolvedEntity: location
164
+ };
165
+ const lot = await this.lotPort.findByCode(trimmed, "", ctx);
166
+ if (lot) return {
167
+ token: trimmed,
168
+ resolvedType: "lot",
169
+ resolvedId: lot._id,
170
+ resolvedEntity: lot
171
+ };
172
+ const serial = await this.lotPort.findBySerial(trimmed, "", ctx);
173
+ if (serial) return {
174
+ token: trimmed,
175
+ resolvedType: "serial",
176
+ resolvedId: serial._id,
177
+ resolvedEntity: serial
178
+ };
179
+ const skuDetails = await this.catalogBridge.resolveSku(trimmed);
180
+ if (skuDetails) return {
181
+ token: trimmed,
182
+ resolvedType: "sku",
183
+ resolvedId: skuDetails.skuRef,
184
+ resolvedEntity: skuDetails
185
+ };
186
+ return {
187
+ token: trimmed,
188
+ resolvedType: "unknown",
189
+ resolvedId: null,
190
+ resolvedEntity: null
191
+ };
192
+ }
193
+ };
194
+ /**
195
+ * Heuristic: does the token look like a GS1-128 barcode?
196
+ */
197
+ function isGS1(token) {
198
+ if (token.startsWith("]C1")) return true;
199
+ if (token.startsWith("(01)")) return true;
200
+ if (/^\d{14,}$/.test(token)) return true;
201
+ return false;
202
+ }
203
+ //#endregion
204
+ //#region src/scanning/scan.service.ts
205
+ /**
206
+ * EnhancedScanService — thin wrapper around ChainResolver that also
207
+ * exposes a synchronous GS1 decomposition method.
208
+ */
209
+ var EnhancedScanService = class {
210
+ constructor(resolver) {
211
+ this.resolver = resolver;
212
+ }
213
+ /**
214
+ * Resolve a raw scan token through the full chain (GS1, location, lot, serial, SKU).
215
+ */
216
+ async resolve(token, ctx) {
217
+ return this.resolver.resolve(token, ctx);
218
+ }
219
+ /**
220
+ * Synchronously decompose a GS1-128 barcode into its AI components.
221
+ * Does not perform any backend lookups.
222
+ */
223
+ resolveGS1(barcode) {
224
+ return parseGS1(barcode);
225
+ }
226
+ };
227
+ //#endregion
228
+ export { ChainResolver, EnhancedScanService, parseGS1 };
@@ -0,0 +1,8 @@
1
+ import { a as requireStandardMode, i as requireEnterpriseMode, n as createRuntimeConfig, r as isRoutingEnabled, t as RuntimeConfig } from "../runtime-config-CQLtPPqY.mjs";
2
+ import { a as ReconcileResult, i as ReconcileOptions, n as CountingService, o as VarianceReport, r as CreateCountInput, t as CountLineInput } from "../counting.service-CpAxU2G0.mjs";
3
+ import { n as TraceResult, r as TraceService, t as RecallResult } from "../trace.service-B9vAh-l-.mjs";
4
+ import { n as CreateCostLayerInput, r as InventoryValuation, t as CostLayerService } from "../cost-layer.service-DWmo9dQz.mjs";
5
+ import { _ as PostingService, a as ScanService, b as AvailabilityCheckItem, c as ProjectedAvailability, d as RebuildScope, f as CreateMoveGroupServiceInput, g as PostResult, h as MoveService, i as createServices, l as QuantService, m as MoveGroupService, n as FlowServices, o as ReservationService, p as GroupAction, r as ReportingServices, s as ReserveInput, t as CreateServicesInput, u as RebuildResult, v as AllocateInput, x as AvailabilityCheckResult, y as AllocationService } from "../index-CMTUKEK_.mjs";
6
+ import { n as PackageContents, r as PackageService, t as CreatePackageInput } from "../package.service-C605NaBQ.mjs";
7
+ import { a as CreateProcurementInput, i as ReplenishmentTrigger, n as ReplenishmentScope, o as ProcurementService, r as ReplenishmentService, s as ReceivePayload, t as ReplenishmentEvaluation } from "../replenishment.service-HO0sDhB_.mjs";
8
+ export { AllocateInput, AllocationService, AvailabilityCheckItem, AvailabilityCheckResult, CostLayerService, CountLineInput, CountingService, CreateCostLayerInput, CreateCountInput, CreateMoveGroupServiceInput, CreatePackageInput, CreateProcurementInput, CreateServicesInput, FlowServices, GroupAction, InventoryValuation, MoveGroupService, MoveService, PackageContents, PackageService, PostResult, PostingService, ProcurementService, ProjectedAvailability, QuantService, RebuildResult, RebuildScope, RecallResult, ReceivePayload, ReconcileOptions, ReconcileResult, ReplenishmentEvaluation, ReplenishmentScope, ReplenishmentService, ReplenishmentTrigger, ReportingServices, ReservationService, ReserveInput, RuntimeConfig, ScanService, TraceResult, TraceService, VarianceReport, createRuntimeConfig, createServices, isRoutingEnabled, requireEnterpriseMode, requireStandardMode };
@@ -0,0 +1,8 @@
1
+ import { t as TraceService } from "../trace.service-DE6Eh8_8.mjs";
2
+ import { t as CostLayerService } from "../cost-layer.service-BQ1bs-XN.mjs";
3
+ import { a as PostingService, c as AllocationService, i as QuantService, n as ScanService, o as MoveGroupService, r as ReservationService, s as MoveService, t as createServices } from "../services-_lLO4Xbl.mjs";
4
+ import { i as requireStandardMode, n as isRoutingEnabled, r as requireEnterpriseMode, t as createRuntimeConfig } from "../runtime-config-C0ggPkiK.mjs";
5
+ import { t as CountingService } from "../counting.service-BiQXqorv.mjs";
6
+ import { t as PackageService } from "../package.service-4tcAwBbr.mjs";
7
+ import { n as ProcurementService, t as ReplenishmentService } from "../replenishment.service-BT9P-HKM.mjs";
8
+ export { AllocationService, CostLayerService, CountingService, MoveGroupService, MoveService, PackageService, PostingService, ProcurementService, QuantService, ReplenishmentService, ReservationService, ScanService, TraceService, createRuntimeConfig, createServices, isRoutingEnabled, requireEnterpriseMode, requireStandardMode };