@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,220 @@
1
+ //#region src/domain/errors/base.d.ts
2
+ declare abstract class FlowError extends Error {
3
+ abstract readonly code: string;
4
+ abstract readonly httpStatus: number;
5
+ constructor(message: string);
6
+ toJSON(): {
7
+ code: string;
8
+ message: string;
9
+ name: string;
10
+ };
11
+ }
12
+ //#endregion
13
+ //#region src/domain/errors/domain-errors.d.ts
14
+ declare class DuplicateReservationError extends FlowError {
15
+ readonly ownerType: string;
16
+ readonly ownerId: string;
17
+ readonly skuRef: string;
18
+ readonly code: "DUPLICATE_RESERVATION";
19
+ readonly httpStatus = 409;
20
+ constructor(ownerType: string, ownerId: string, skuRef: string);
21
+ }
22
+ declare class LocationNotStockableError extends FlowError {
23
+ readonly locationId: string;
24
+ readonly locationType: string;
25
+ readonly code: "LOCATION_NOT_STOCKABLE";
26
+ readonly httpStatus = 422;
27
+ constructor(locationId: string, locationType: string);
28
+ }
29
+ declare class NegativeStockError extends FlowError {
30
+ readonly skuRef: string;
31
+ readonly locationId: string;
32
+ readonly currentQty: number;
33
+ readonly requestedQty: number;
34
+ readonly code: "NEGATIVE_STOCK";
35
+ readonly httpStatus = 422;
36
+ constructor(skuRef: string, locationId: string, currentQty: number, requestedQty: number);
37
+ }
38
+ declare class MoveAlreadyPostedError extends FlowError {
39
+ readonly moveId: string;
40
+ readonly code: "MOVE_ALREADY_POSTED";
41
+ readonly httpStatus = 409;
42
+ constructor(moveId: string);
43
+ }
44
+ declare class ConcurrencyConflictError extends FlowError {
45
+ readonly code: "CONCURRENCY_CONFLICT";
46
+ readonly httpStatus = 409;
47
+ constructor(message?: string);
48
+ }
49
+ declare class QuantMismatchError extends FlowError {
50
+ readonly skuRef: string;
51
+ readonly locationId: string;
52
+ readonly expected: number;
53
+ readonly actual: number;
54
+ readonly code: "QUANT_MISMATCH";
55
+ readonly httpStatus = 500;
56
+ constructor(skuRef: string, locationId: string, expected: number, actual: number);
57
+ }
58
+ declare class LotRequiredError extends FlowError {
59
+ readonly skuRef: string;
60
+ readonly code: "LOT_REQUIRED";
61
+ readonly httpStatus = 422;
62
+ constructor(skuRef: string);
63
+ }
64
+ declare class SerialQuantityError extends FlowError {
65
+ readonly serialCode: string;
66
+ readonly code: "SERIAL_QUANTITY";
67
+ readonly httpStatus = 422;
68
+ constructor(serialCode: string);
69
+ }
70
+ declare class StockFrozenError extends FlowError {
71
+ readonly locationId: string;
72
+ readonly reason: string;
73
+ readonly code: "STOCK_FROZEN";
74
+ readonly httpStatus = 423;
75
+ constructor(locationId: string, reason: string);
76
+ }
77
+ declare class ProcurementNotApprovedError extends FlowError {
78
+ readonly orderId: string;
79
+ readonly code: "PROCUREMENT_NOT_APPROVED";
80
+ readonly httpStatus = 422;
81
+ constructor(orderId: string);
82
+ }
83
+ declare class NodeNotFoundError extends FlowError {
84
+ readonly nodeId: string;
85
+ readonly code: "NODE_NOT_FOUND";
86
+ readonly httpStatus = 404;
87
+ constructor(nodeId: string);
88
+ }
89
+ declare class LocationNotFoundError extends FlowError {
90
+ readonly locationId: string;
91
+ readonly code: "LOCATION_NOT_FOUND";
92
+ readonly httpStatus = 404;
93
+ constructor(locationId: string);
94
+ }
95
+ declare class MoveGroupNotFoundError extends FlowError {
96
+ readonly groupId: string;
97
+ readonly code: "MOVE_GROUP_NOT_FOUND";
98
+ readonly httpStatus = 404;
99
+ constructor(groupId: string);
100
+ }
101
+ declare class ReservationNotFoundError extends FlowError {
102
+ readonly reservationId: string;
103
+ readonly code: "RESERVATION_NOT_FOUND";
104
+ readonly httpStatus = 404;
105
+ constructor(reservationId: string);
106
+ }
107
+ declare class ValidationError extends FlowError {
108
+ readonly fields?: Record<string, string> | undefined;
109
+ readonly code: "VALIDATION_ERROR";
110
+ readonly httpStatus = 400;
111
+ constructor(message: string, fields?: Record<string, string> | undefined);
112
+ }
113
+ //#endregion
114
+ //#region src/domain/errors/insufficient-stock.error.d.ts
115
+ declare class InsufficientStockError extends FlowError {
116
+ readonly skuRef: string;
117
+ readonly requested: number;
118
+ readonly available: number;
119
+ readonly locationId?: string | undefined;
120
+ readonly code: "INSUFFICIENT_STOCK";
121
+ readonly httpStatus = 409;
122
+ constructor(skuRef: string, requested: number, available: number, locationId?: string | undefined);
123
+ }
124
+ //#endregion
125
+ //#region src/domain/errors/invalid-transition.error.d.ts
126
+ declare class InvalidTransitionError extends FlowError {
127
+ readonly entityType: string;
128
+ readonly entityId: string;
129
+ readonly from: string;
130
+ readonly to: string;
131
+ readonly code: "INVALID_TRANSITION";
132
+ readonly httpStatus = 422;
133
+ constructor(entityType: string, entityId: string, from: string, to: string);
134
+ }
135
+ //#endregion
136
+ //#region src/domain/errors/location-capacity-exceeded.error.d.ts
137
+ declare class LocationCapacityExceededError extends FlowError {
138
+ readonly locationId: string;
139
+ readonly capacity: number;
140
+ readonly requested: number;
141
+ readonly code: "LOCATION_CAPACITY_EXCEEDED";
142
+ readonly httpStatus = 422;
143
+ constructor(locationId: string, capacity: number, requested: number);
144
+ }
145
+ //#endregion
146
+ //#region src/domain/errors/reservation-expired.error.d.ts
147
+ declare class ReservationExpiredError extends FlowError {
148
+ readonly reservationId: string;
149
+ readonly code: "RESERVATION_EXPIRED";
150
+ readonly httpStatus = 410;
151
+ constructor(reservationId: string);
152
+ }
153
+ //#endregion
154
+ //#region src/domain/errors/tenant-isolation.error.d.ts
155
+ declare class TenantIsolationError extends FlowError {
156
+ readonly code: "TENANT_ISOLATION";
157
+ readonly httpStatus = 403;
158
+ constructor(message?: string);
159
+ }
160
+ //#endregion
161
+ //#region src/domain/value-objects/quantity.d.ts
162
+ /**
163
+ * Non-negative quantity value object.
164
+ * Used for planned/done quantities on moves and availability.
165
+ */
166
+ declare class Quantity {
167
+ readonly value: number;
168
+ private constructor();
169
+ static create(value: number): Quantity;
170
+ static zero(): Quantity;
171
+ add(other: Quantity): Quantity;
172
+ subtract(other: Quantity): Quantity;
173
+ isZero(): boolean;
174
+ isGreaterThan(other: Quantity): boolean;
175
+ isGreaterThanOrEqual(other: Quantity): boolean;
176
+ equals(other: Quantity): boolean;
177
+ toString(): string;
178
+ }
179
+ //#endregion
180
+ //#region src/domain/value-objects/sku-ref.d.ts
181
+ /**
182
+ * Product/variant reference — opaque string identifier linking to the external catalog.
183
+ * Flow never owns the product definition; it references via skuRef.
184
+ */
185
+ declare class SkuRef {
186
+ readonly value: string;
187
+ private constructor();
188
+ static create(value: string): SkuRef;
189
+ equals(other: SkuRef): boolean;
190
+ toString(): string;
191
+ }
192
+ //#endregion
193
+ //#region src/domain/value-objects/uom-quantity.d.ts
194
+ /**
195
+ * Quantity with unit of measure.
196
+ * Stock is stored in base UoM per SKU. Moves can specify alternate UoM; conversion applied at posting.
197
+ */
198
+ interface UoMQuantity {
199
+ quantity: number;
200
+ uom: string;
201
+ }
202
+ /**
203
+ * UoM conversion definition.
204
+ */
205
+ interface UoMConversion {
206
+ fromUom: string;
207
+ toUom: string;
208
+ factor: number;
209
+ skuRef?: string;
210
+ }
211
+ /**
212
+ * Convert quantity from one UoM to base UoM.
213
+ */
214
+ declare function convertToBase(quantity: number, conversion: UoMConversion): number;
215
+ /**
216
+ * Convert quantity from base UoM to target UoM.
217
+ */
218
+ declare function convertFromBase(quantity: number, conversion: UoMConversion): number;
219
+ //#endregion
220
+ export { ReservationNotFoundError as C, FlowError as D, ValidationError as E, QuantMismatchError as S, StockFrozenError as T, MoveAlreadyPostedError as _, SkuRef as a, NodeNotFoundError as b, ReservationExpiredError as c, InsufficientStockError as d, ConcurrencyConflictError as f, LotRequiredError as g, LocationNotStockableError as h, convertToBase as i, LocationCapacityExceededError as l, LocationNotFoundError as m, UoMQuantity as n, Quantity as o, DuplicateReservationError as p, convertFromBase as r, TenantIsolationError as s, UoMConversion as t, InvalidTransitionError as u, MoveGroupNotFoundError as v, SerialQuantityError as w, ProcurementNotApprovedError as x, NegativeStockError as y };
@@ -0,0 +1,107 @@
1
+ //#region src/domain/enums/move-status.d.ts
2
+ declare const MoveStatus: {
3
+ readonly draft: "draft";
4
+ readonly planned: "planned";
5
+ readonly waiting: "waiting";
6
+ readonly ready: "ready";
7
+ readonly partially_done: "partially_done";
8
+ readonly done: "done";
9
+ readonly cancelled: "cancelled";
10
+ };
11
+ type MoveStatus = (typeof MoveStatus)[keyof typeof MoveStatus];
12
+ /** Valid status transitions for stock moves. */
13
+ declare const MOVE_STATUS_TRANSITIONS: Record<MoveStatus, readonly MoveStatus[]>;
14
+ declare function isValidMoveTransition(from: MoveStatus, to: MoveStatus): boolean;
15
+ //#endregion
16
+ //#region src/domain/enums/operation-type.d.ts
17
+ declare const OperationType: {
18
+ readonly receipt: "receipt";
19
+ readonly transfer: "transfer";
20
+ readonly shipment: "shipment";
21
+ readonly return: "return";
22
+ readonly adjustment: "adjustment";
23
+ readonly count: "count";
24
+ };
25
+ type OperationType = (typeof OperationType)[keyof typeof OperationType];
26
+ //#endregion
27
+ //#region src/domain/enums/group-type.d.ts
28
+ declare const GroupType: {
29
+ readonly receipt: "receipt";
30
+ readonly transfer: "transfer";
31
+ readonly shipment: "shipment";
32
+ readonly return: "return";
33
+ readonly adjustment: "adjustment";
34
+ readonly pick_wave: "pick_wave";
35
+ readonly count_reconciliation: "count_reconciliation";
36
+ };
37
+ type GroupType = (typeof GroupType)[keyof typeof GroupType];
38
+ //#endregion
39
+ //#region src/domain/enums/location-type.d.ts
40
+ declare const LocationType: {
41
+ readonly view: "view";
42
+ readonly internal: "internal";
43
+ readonly receiving: "receiving";
44
+ readonly storage: "storage";
45
+ readonly picking: "picking";
46
+ readonly packing: "packing";
47
+ readonly shipping: "shipping";
48
+ readonly transit: "transit";
49
+ readonly vendor: "vendor";
50
+ readonly customer: "customer";
51
+ readonly returns: "returns";
52
+ readonly quality_hold: "quality_hold";
53
+ readonly damaged: "damaged";
54
+ readonly scrap: "scrap";
55
+ readonly inventory_loss: "inventory_loss";
56
+ readonly production: "production";
57
+ };
58
+ type LocationType = (typeof LocationType)[keyof typeof LocationType];
59
+ /** Location types that hold physical stock (non-virtual). */
60
+ declare const STOCKABLE_LOCATION_TYPES: readonly LocationType[];
61
+ /** Virtual location types — no physical stock, used for accounting/routing. */
62
+ declare const VIRTUAL_LOCATION_TYPES: readonly LocationType[];
63
+ //#endregion
64
+ //#region src/domain/enums/reservation-status.d.ts
65
+ declare const ReservationStatus: {
66
+ readonly active: "active";
67
+ readonly partially_consumed: "partially_consumed";
68
+ readonly consumed: "consumed";
69
+ readonly released: "released";
70
+ readonly expired: "expired";
71
+ readonly cancelled: "cancelled";
72
+ };
73
+ type ReservationStatus = (typeof ReservationStatus)[keyof typeof ReservationStatus];
74
+ //#endregion
75
+ //#region src/domain/enums/stock-status.d.ts
76
+ declare const StockStatus: {
77
+ readonly sellable: "sellable";
78
+ readonly damaged: "damaged";
79
+ readonly quarantine: "quarantine";
80
+ readonly hold: "hold";
81
+ readonly returns: "returns";
82
+ readonly expired: "expired";
83
+ readonly in_transit: "in_transit";
84
+ };
85
+ type StockStatus = (typeof StockStatus)[keyof typeof StockStatus];
86
+ /** Only sellable stock is counted as available for sale. */
87
+ declare const SELLABLE_STATUSES: readonly StockStatus[];
88
+ //#endregion
89
+ //#region src/domain/enums/tracking-mode.d.ts
90
+ declare const TrackingMode: {
91
+ readonly none: "none";
92
+ readonly lot: "lot";
93
+ readonly serial: "serial";
94
+ };
95
+ type TrackingMode = (typeof TrackingMode)[keyof typeof TrackingMode];
96
+ //#endregion
97
+ //#region src/domain/enums/valuation-method.d.ts
98
+ declare const ValuationMethod: {
99
+ readonly wac: "wac";
100
+ readonly fifo: "fifo";
101
+ readonly fefo: "fefo";
102
+ readonly specific: "specific";
103
+ readonly standard: "standard";
104
+ };
105
+ type ValuationMethod = (typeof ValuationMethod)[keyof typeof ValuationMethod];
106
+ //#endregion
107
+ export { ReservationStatus as a, VIRTUAL_LOCATION_TYPES as c, MOVE_STATUS_TRANSITIONS as d, MoveStatus as f, StockStatus as i, GroupType as l, TrackingMode as n, LocationType as o, isValidMoveTransition as p, SELLABLE_STATUSES as r, STOCKABLE_LOCATION_TYPES as s, ValuationMethod as t, OperationType as u };
@@ -0,0 +1,36 @@
1
+ //#region src/types/index.d.ts
2
+ /**
3
+ * Shared context passed to every service method.
4
+ * organizationId and actorId live here, never in domain input objects.
5
+ */
6
+ interface FlowContext {
7
+ organizationId: string;
8
+ actorId: string;
9
+ roles?: string[];
10
+ nodeScope?: string;
11
+ idempotencyKey?: string;
12
+ }
13
+ /** Paginated list result. */
14
+ interface PaginatedResult<T> {
15
+ data: T[];
16
+ total: number;
17
+ page: number;
18
+ pageSize: number;
19
+ hasMore: boolean;
20
+ }
21
+ /** Standard list query with filters and pagination. */
22
+ interface ListQuery {
23
+ filter?: Record<string, unknown>;
24
+ sort?: Record<string, 1 | -1>;
25
+ page?: number;
26
+ pageSize?: number;
27
+ }
28
+ /** Query options for findMany — passed through to MongoKit's findAll. */
29
+ interface QueryOptions {
30
+ sort?: Record<string, 1 | -1> | string;
31
+ select?: string;
32
+ }
33
+ /** Flow engine deployment mode. */
34
+ type FlowMode = 'simple' | 'standard' | 'enterprise';
35
+ //#endregion
36
+ export { QueryOptions as a, PaginatedResult as i, FlowMode as n, ListQuery as r, FlowContext as t };
@@ -0,0 +1,11 @@
1
+ //#region src/domain/contracts/auth-context.d.ts
2
+ /**
3
+ * AuthContext — optional contract for consumer to provide auth context.
4
+ */
5
+ interface AuthContext {
6
+ organizationId: string;
7
+ actorId: string;
8
+ roles?: string[];
9
+ }
10
+ //#endregion
11
+ export { AuthContext as t };
@@ -0,0 +1 @@
1
+ export { };