@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,56 @@
1
+ import { l as GroupType } from "./index-CulWO137.mjs";
2
+ import { i as PaginatedResult, r as ListQuery, t as FlowContext } from "./index-DFF0GJ4J.mjs";
3
+ import { t as TransactionSession } from "./unit-of-work.port-CWEkrDKu.mjs";
4
+
5
+ //#region src/domain/entities/stock-move-group.d.ts
6
+ type MoveGroupStatus = 'draft' | 'confirmed' | 'allocated' | 'in_progress' | 'partially_done' | 'done' | 'cancelled';
7
+ declare const MOVE_GROUP_STATUS_TRANSITIONS: Record<MoveGroupStatus, readonly MoveGroupStatus[]>;
8
+ interface StockMoveGroup {
9
+ _id: string;
10
+ organizationId: string;
11
+ groupType: GroupType;
12
+ documentNumber: string;
13
+ sourceNodeId?: string;
14
+ destinationNodeId?: string;
15
+ status: MoveGroupStatus;
16
+ priority?: number;
17
+ routePlanId?: string;
18
+ counterparty?: {
19
+ type: string;
20
+ id: string;
21
+ };
22
+ requestedAt?: Date;
23
+ confirmedAt?: Date;
24
+ completedAt?: Date;
25
+ createdBy?: string;
26
+ modifiedBy?: string;
27
+ notes?: string;
28
+ metadata?: Record<string, unknown>;
29
+ createdAt?: Date;
30
+ updatedAt?: Date;
31
+ }
32
+ //#endregion
33
+ //#region src/domain/ports/move-group.port.d.ts
34
+ interface CreateMoveGroupInput {
35
+ organizationId: string;
36
+ groupType: string;
37
+ documentNumber: string;
38
+ sourceNodeId?: string;
39
+ destinationNodeId?: string;
40
+ priority?: number;
41
+ counterparty?: {
42
+ type: string;
43
+ id: string;
44
+ };
45
+ notes?: string;
46
+ createdBy: string;
47
+ metadata?: Record<string, unknown>;
48
+ }
49
+ interface MoveGroupPort {
50
+ create(input: CreateMoveGroupInput, session?: TransactionSession): Promise<StockMoveGroup>;
51
+ findById(id: string, ctx: FlowContext, session?: TransactionSession): Promise<StockMoveGroup | null>;
52
+ updateStatus(id: string, status: MoveGroupStatus, updates: Partial<StockMoveGroup>, session?: TransactionSession): Promise<StockMoveGroup>;
53
+ list(query: ListQuery, ctx: FlowContext, session?: TransactionSession): Promise<PaginatedResult<StockMoveGroup>>;
54
+ }
55
+ //#endregion
56
+ export { StockMoveGroup as a, MoveGroupStatus as i, MoveGroupPort as n, MOVE_GROUP_STATUS_TRANSITIONS as r, CreateMoveGroupInput as t };
@@ -0,0 +1,38 @@
1
+ //#region src/domain/enums/move-status.ts
2
+ const MoveStatus = {
3
+ draft: "draft",
4
+ planned: "planned",
5
+ waiting: "waiting",
6
+ ready: "ready",
7
+ partially_done: "partially_done",
8
+ done: "done",
9
+ cancelled: "cancelled"
10
+ };
11
+ /** Valid status transitions for stock moves. */
12
+ const MOVE_STATUS_TRANSITIONS = {
13
+ [MoveStatus.draft]: [
14
+ MoveStatus.planned,
15
+ MoveStatus.ready,
16
+ MoveStatus.done,
17
+ MoveStatus.cancelled
18
+ ],
19
+ [MoveStatus.planned]: [
20
+ MoveStatus.waiting,
21
+ MoveStatus.ready,
22
+ MoveStatus.cancelled
23
+ ],
24
+ [MoveStatus.waiting]: [MoveStatus.ready, MoveStatus.cancelled],
25
+ [MoveStatus.ready]: [
26
+ MoveStatus.partially_done,
27
+ MoveStatus.done,
28
+ MoveStatus.cancelled
29
+ ],
30
+ [MoveStatus.partially_done]: [MoveStatus.done, MoveStatus.cancelled],
31
+ [MoveStatus.done]: [],
32
+ [MoveStatus.cancelled]: []
33
+ };
34
+ function isValidMoveTransition(from, to) {
35
+ return MOVE_STATUS_TRANSITIONS[from].includes(to);
36
+ }
37
+ //#endregion
38
+ export { MoveStatus as n, isValidMoveTransition as r, MOVE_STATUS_TRANSITIONS as t };
@@ -0,0 +1,89 @@
1
+ import { f as MoveStatus, u as OperationType } from "./index-CulWO137.mjs";
2
+ import { a as QueryOptions, t as FlowContext } from "./index-DFF0GJ4J.mjs";
3
+ import { t as TransactionSession } from "./unit-of-work.port-CWEkrDKu.mjs";
4
+
5
+ //#region src/domain/value-objects/tracking-assignment.d.ts
6
+ type TrackingAssignment = {
7
+ trackingMode: 'none';
8
+ quantity: number;
9
+ expiresAt?: Date;
10
+ } | {
11
+ trackingMode: 'lot';
12
+ lotId?: string;
13
+ lotCode: string;
14
+ quantity: number;
15
+ expiresAt?: Date;
16
+ } | {
17
+ trackingMode: 'serial';
18
+ serialCode: string;
19
+ quantity: 1;
20
+ expiresAt?: Date;
21
+ };
22
+ //#endregion
23
+ //#region src/domain/entities/stock-move.d.ts
24
+ interface StockMove {
25
+ _id: string;
26
+ organizationId: string;
27
+ moveGroupId: string;
28
+ referenceType?: string;
29
+ referenceId?: string;
30
+ operationType: OperationType;
31
+ skuRef: string;
32
+ sourceLocationId: string;
33
+ destinationLocationId: string;
34
+ trackingAssignments?: TrackingAssignment[];
35
+ uom?: string;
36
+ quantityPlanned: number;
37
+ quantityReserved?: number;
38
+ quantityDone?: number;
39
+ status: MoveStatus;
40
+ scheduledAt?: Date;
41
+ executedAt?: Date;
42
+ cancelledAt?: Date;
43
+ reservationIds?: string[];
44
+ policySnapshot?: Record<string, unknown>;
45
+ createdBy?: string;
46
+ modifiedBy?: string;
47
+ metadata?: Record<string, unknown>;
48
+ createdAt?: Date;
49
+ updatedAt?: Date;
50
+ }
51
+ /**
52
+ * Validate a move status transition. Throws if invalid.
53
+ */
54
+ declare function assertMoveTransition(move: StockMove, targetStatus: MoveStatus): void;
55
+ //#endregion
56
+ //#region src/domain/ports/move.port.d.ts
57
+ interface CreateMoveInput {
58
+ moveGroupId: string;
59
+ operationType: string;
60
+ skuRef: string;
61
+ sourceLocationId: string;
62
+ destinationLocationId: string;
63
+ quantityPlanned: number;
64
+ uom?: string;
65
+ trackingAssignments?: Array<{
66
+ trackingMode: string;
67
+ lotId?: string;
68
+ lotCode?: string;
69
+ serialCode?: string;
70
+ quantity: number;
71
+ expiresAt?: Date;
72
+ }>;
73
+ scheduledAt?: Date;
74
+ referenceType?: string;
75
+ referenceId?: string;
76
+ metadata?: Record<string, unknown>;
77
+ }
78
+ interface MovePort {
79
+ create(input: CreateMoveInput & {
80
+ organizationId: string;
81
+ createdBy: string;
82
+ }, session?: TransactionSession): Promise<StockMove>;
83
+ findById(id: string, ctx: FlowContext, session?: TransactionSession): Promise<StockMove | null>;
84
+ findByGroupId(groupId: string, ctx: FlowContext, session?: TransactionSession): Promise<StockMove[]>;
85
+ updateStatus(id: string, status: MoveStatus, updates: Partial<StockMove>, session?: TransactionSession): Promise<StockMove>;
86
+ findMany(filter: Record<string, unknown>, ctx: FlowContext, session?: TransactionSession, options?: QueryOptions): Promise<StockMove[]>;
87
+ }
88
+ //#endregion
89
+ export { TrackingAssignment as a, assertMoveTransition as i, MovePort as n, StockMove as r, CreateMoveInput as t };
@@ -0,0 +1,95 @@
1
+ import { t as assertTenantContext } from "./tenant-guard-6Ne-BILP.mjs";
2
+ //#region src/services/package.service.ts
3
+ var PackageService = class {
4
+ constructor(packageModel, quantPort) {
5
+ this.packageModel = packageModel;
6
+ this.quantPort = quantPort;
7
+ }
8
+ async create(input, ctx) {
9
+ assertTenantContext(ctx);
10
+ return (await this.packageModel.create([{
11
+ organizationId: ctx.organizationId,
12
+ name: input.name ?? `PKG-${Date.now()}`,
13
+ barcode: input.barcode ?? `PKG-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
14
+ packageTypeId: input.packageTypeId,
15
+ parentPackageId: input.parentPackageId,
16
+ locationId: input.locationId,
17
+ baseWeight: input.baseWeight ?? 0,
18
+ maxWeight: input.maxWeight,
19
+ packageUse: input.packageUse ?? "disposable"
20
+ }]))[0].toObject();
21
+ }
22
+ async nest(childId, parentId, ctx) {
23
+ assertTenantContext(ctx);
24
+ const updated = await this.packageModel.findOneAndUpdate({
25
+ _id: childId,
26
+ organizationId: ctx.organizationId
27
+ }, { $set: { parentPackageId: parentId } }, { returnDocument: "after" }).lean();
28
+ if (!updated) throw new Error(`Package ${childId} not found`);
29
+ return updated;
30
+ }
31
+ async unnest(childId, ctx) {
32
+ assertTenantContext(ctx);
33
+ const updated = await this.packageModel.findOneAndUpdate({
34
+ _id: childId,
35
+ organizationId: ctx.organizationId
36
+ }, { $unset: { parentPackageId: 1 } }, { returnDocument: "after" }).lean();
37
+ if (!updated) throw new Error(`Package ${childId} not found`);
38
+ return updated;
39
+ }
40
+ async getContents(packageId, ctx) {
41
+ assertTenantContext(ctx);
42
+ const pkg = await this.packageModel.findOne({
43
+ _id: packageId,
44
+ organizationId: ctx.organizationId
45
+ }).lean();
46
+ if (!pkg) throw new Error(`Package ${packageId} not found`);
47
+ return {
48
+ package: pkg,
49
+ childPackages: await this.packageModel.find({
50
+ parentPackageId: packageId,
51
+ organizationId: ctx.organizationId
52
+ }).lean(),
53
+ allQuants: (pkg.locationId ? await this.quantPort.findMany({
54
+ organizationId: ctx.organizationId,
55
+ locationId: pkg.locationId
56
+ }, ctx) : []).map((q) => ({
57
+ skuRef: q.skuRef,
58
+ locationId: q.locationId,
59
+ quantity: q.quantityOnHand
60
+ }))
61
+ };
62
+ }
63
+ async getWeight(packageId, ctx) {
64
+ assertTenantContext(ctx);
65
+ const pkg = await this.packageModel.findOne({
66
+ _id: packageId,
67
+ organizationId: ctx.organizationId
68
+ }).lean();
69
+ if (!pkg) throw new Error(`Package ${packageId} not found`);
70
+ const children = await this.packageModel.find({
71
+ parentPackageId: packageId,
72
+ organizationId: ctx.organizationId
73
+ }).lean();
74
+ let contentWeight = 0;
75
+ for (const child of children) {
76
+ const childWeight = await this.getWeight(child._id.toString(), ctx);
77
+ contentWeight += childWeight.totalWeight;
78
+ }
79
+ const baseWeight = pkg.baseWeight ?? 0;
80
+ return {
81
+ baseWeight,
82
+ contentWeight,
83
+ totalWeight: baseWeight + contentWeight
84
+ };
85
+ }
86
+ async findByBarcode(barcode, ctx) {
87
+ assertTenantContext(ctx);
88
+ return await this.packageModel.findOne({
89
+ barcode,
90
+ organizationId: ctx.organizationId
91
+ }).lean();
92
+ }
93
+ };
94
+ //#endregion
95
+ export { PackageService as t };
@@ -0,0 +1,42 @@
1
+ import { t as FlowContext } from "./index-DFF0GJ4J.mjs";
2
+ import { t as StockPackage } from "./stock-package-BIarxbDS.mjs";
3
+ import { r as QuantPort } from "./quant.port-BBa66PBT.mjs";
4
+ import { Model } from "mongoose";
5
+
6
+ //#region src/services/package.service.d.ts
7
+ interface CreatePackageInput {
8
+ name?: string;
9
+ barcode?: string;
10
+ packageTypeId?: string;
11
+ parentPackageId?: string;
12
+ locationId?: string;
13
+ baseWeight?: number;
14
+ maxWeight?: number;
15
+ packageUse?: 'disposable' | 'reusable';
16
+ }
17
+ interface PackageContents {
18
+ package: StockPackage;
19
+ childPackages: StockPackage[];
20
+ allQuants: Array<{
21
+ skuRef: string;
22
+ locationId: string;
23
+ quantity: number;
24
+ }>;
25
+ }
26
+ declare class PackageService {
27
+ private packageModel;
28
+ private quantPort;
29
+ constructor(packageModel: Model<any>, quantPort: QuantPort);
30
+ create(input: CreatePackageInput, ctx: FlowContext): Promise<StockPackage>;
31
+ nest(childId: string, parentId: string, ctx: FlowContext): Promise<StockPackage>;
32
+ unnest(childId: string, ctx: FlowContext): Promise<StockPackage>;
33
+ getContents(packageId: string, ctx: FlowContext): Promise<PackageContents>;
34
+ getWeight(packageId: string, ctx: FlowContext): Promise<{
35
+ baseWeight: number;
36
+ contentWeight: number;
37
+ totalWeight: number;
38
+ }>;
39
+ findByBarcode(barcode: string, ctx: FlowContext): Promise<StockPackage | null>;
40
+ }
41
+ //#endregion
42
+ export { PackageContents as n, PackageService as r, CreatePackageInput as t };
@@ -0,0 +1,2 @@
1
+ import { n as PackageContents, r as PackageService, t as CreatePackageInput } from "../package.service-C605NaBQ.mjs";
2
+ export { type CreatePackageInput, type PackageContents, PackageService };
@@ -0,0 +1,2 @@
1
+ import { t as PackageService } from "../package.service-4tcAwBbr.mjs";
2
+ export { PackageService };
@@ -0,0 +1,2 @@
1
+ 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";
2
+ export { type CreateProcurementInput, ProcurementService, type ReceivePayload, type ReplenishmentEvaluation, type ReplenishmentScope, ReplenishmentService, type ReplenishmentTrigger };
@@ -0,0 +1,2 @@
1
+ import { n as ProcurementService, t as ReplenishmentService } from "../replenishment.service-BT9P-HKM.mjs";
2
+ export { ProcurementService, ReplenishmentService };
@@ -0,0 +1,42 @@
1
+ import { a as QueryOptions, t as FlowContext } from "./index-DFF0GJ4J.mjs";
2
+ import { n as StockQuant, t as QuantIdentity } from "./stock-quant-CZhgvTu7.mjs";
3
+ import { t as TransactionSession } from "./unit-of-work.port-CWEkrDKu.mjs";
4
+
5
+ //#region src/domain/ports/quant.port.d.ts
6
+ interface AvailabilityQuery {
7
+ skuRef?: string;
8
+ locationId?: string;
9
+ nodeId?: string;
10
+ lotId?: string;
11
+ stockStatus?: string;
12
+ }
13
+ interface Availability {
14
+ quantityOnHand: number;
15
+ quantityReserved: number;
16
+ quantityAvailable: number;
17
+ quantityIncoming: number;
18
+ quantityOutgoing: number;
19
+ breakdowns: StockQuant[];
20
+ }
21
+ interface QuantUpdate {
22
+ organizationId: string;
23
+ skuRef: string;
24
+ locationId: string;
25
+ lotId?: string;
26
+ ownerRef?: string;
27
+ stockStatus?: string;
28
+ quantityDelta: number;
29
+ reservedDelta?: number;
30
+ inDate?: Date;
31
+ unitCost?: number;
32
+ }
33
+ interface QuantPort {
34
+ getAvailability(query: AvailabilityQuery, ctx: FlowContext, session?: TransactionSession): Promise<Availability>;
35
+ upsert(update: QuantUpdate, session?: TransactionSession): Promise<StockQuant>;
36
+ batchUpsert?(updates: QuantUpdate[], session?: TransactionSession): Promise<void>;
37
+ findByIdentity(identity: QuantIdentity, session?: TransactionSession): Promise<StockQuant | null>;
38
+ findMany(filter: Record<string, unknown>, ctx: FlowContext, session?: TransactionSession, options?: QueryOptions): Promise<StockQuant[]>;
39
+ deleteAll(ctx: FlowContext, session?: TransactionSession): Promise<void>;
40
+ }
41
+ //#endregion
42
+ export { QuantUpdate as i, AvailabilityQuery as n, QuantPort as r, Availability as t };
@@ -0,0 +1,29 @@
1
+ import { n as StockQuant } from "./stock-quant-CZhgvTu7.mjs";
2
+ import { n as AllocationResult } from "./allocation-policy-my_HfzdV.mjs";
3
+
4
+ //#region src/domain/policies/putaway-policy.d.ts
5
+ /**
6
+ * Putaway policy — decides where to store received goods.
7
+ */
8
+ interface PutawayPolicy {
9
+ name: string;
10
+ resolve(skuRef: string, quantity: number, nodeId: string, context: {
11
+ lotId?: string;
12
+ vendorRef?: string;
13
+ skuCategory?: string;
14
+ }): Promise<{
15
+ locationId: string;
16
+ } | null>;
17
+ }
18
+ //#endregion
19
+ //#region src/domain/policies/removal-policy.d.ts
20
+ /**
21
+ * Removal policy — decides which physical stock to pick.
22
+ * Same shape as AllocationPolicy but used at pick time.
23
+ */
24
+ interface RemovalPolicy {
25
+ name: string;
26
+ resolve(skuRef: string, quantity: number, candidates: StockQuant[]): AllocationResult;
27
+ }
28
+ //#endregion
29
+ export { PutawayPolicy as n, RemovalPolicy as t };
@@ -0,0 +1,78 @@
1
+ import { a as QueryOptions, i as PaginatedResult, r as ListQuery, t as FlowContext } from "./index-DFF0GJ4J.mjs";
2
+ import { t as TransactionSession } from "./unit-of-work.port-CWEkrDKu.mjs";
3
+
4
+ //#region src/domain/entities/procurement-order.d.ts
5
+ type ProcurementStatus = 'draft' | 'approved' | 'ordered' | 'partially_received' | 'received' | 'cancelled';
6
+ interface ProcurementItem {
7
+ skuRef: string;
8
+ quantity: number;
9
+ quantityReceived: number;
10
+ unitCost: number;
11
+ expectedAt?: Date;
12
+ }
13
+ interface ProcurementOrder {
14
+ _id: string;
15
+ organizationId: string;
16
+ orderNumber: string;
17
+ vendorRef: string;
18
+ destinationNodeId: string;
19
+ destinationLocationId?: string;
20
+ status: ProcurementStatus;
21
+ items: ProcurementItem[];
22
+ expectedAt?: Date;
23
+ receivedAt?: Date;
24
+ sourceDemandRefs?: string[];
25
+ createdBy?: string;
26
+ modifiedBy?: string;
27
+ metadata?: Record<string, unknown>;
28
+ createdAt?: Date;
29
+ updatedAt?: Date;
30
+ }
31
+ //#endregion
32
+ //#region src/domain/entities/replenishment-rule.d.ts
33
+ interface ReplenishmentRule {
34
+ _id: string;
35
+ organizationId: string;
36
+ scopeType: 'organization' | 'node' | 'location';
37
+ scopeRef: string;
38
+ skuRef: string;
39
+ locationId?: string;
40
+ triggerType: 'reorder_point' | 'min_max' | 'scheduled';
41
+ reorderPoint: number;
42
+ targetLevel: number;
43
+ preferredSourceType?: 'vendor' | 'internal_transfer';
44
+ preferredSourceRef?: string;
45
+ procurementMode?: 'purchase' | 'transfer' | 'manufacture';
46
+ leadTimeDays?: number;
47
+ minOrderQty?: number;
48
+ maxOrderQty?: number;
49
+ multipleOf?: number;
50
+ safetyStock?: number;
51
+ enabled: boolean;
52
+ metadata?: Record<string, unknown>;
53
+ createdAt?: Date;
54
+ updatedAt?: Date;
55
+ }
56
+ //#endregion
57
+ //#region src/domain/ports/procurement.port.d.ts
58
+ interface ProcurementPort {
59
+ create(input: Omit<ProcurementOrder, '_id' | 'createdAt' | 'updatedAt'>, session?: TransactionSession): Promise<ProcurementOrder>;
60
+ findById(id: string, ctx: FlowContext, session?: TransactionSession): Promise<ProcurementOrder | null>;
61
+ updateStatus(id: string, status: ProcurementStatus, updates: Partial<ProcurementOrder>, session?: TransactionSession): Promise<ProcurementOrder>;
62
+ findMany(filter: Record<string, unknown>, ctx: FlowContext, session?: TransactionSession, options?: QueryOptions): Promise<ProcurementOrder[]>;
63
+ list(query: ListQuery, ctx: FlowContext, session?: TransactionSession): Promise<PaginatedResult<ProcurementOrder>>;
64
+ }
65
+ //#endregion
66
+ //#region src/domain/ports/replenishment-rule.port.d.ts
67
+ interface ReplenishmentRulePort {
68
+ findByNode(nodeId: string, ctx: FlowContext, session?: TransactionSession): Promise<ReplenishmentRule[]>;
69
+ findBySkuRef(skuRef: string, ctx: FlowContext, session?: TransactionSession): Promise<ReplenishmentRule[]>;
70
+ list(ctx: FlowContext, session?: TransactionSession): Promise<ReplenishmentRule[]>;
71
+ findMany(filter: Record<string, unknown>, ctx: FlowContext, session?: TransactionSession, options?: QueryOptions): Promise<ReplenishmentRule[]>;
72
+ create(input: Omit<ReplenishmentRule, '_id' | 'createdAt' | 'updatedAt'>, session?: TransactionSession): Promise<ReplenishmentRule>;
73
+ findById(id: string, ctx: FlowContext, session?: TransactionSession): Promise<ReplenishmentRule | null>;
74
+ delete(id: string, ctx: FlowContext, session?: TransactionSession): Promise<void>;
75
+ update(id: string, updates: Partial<ReplenishmentRule>, ctx: FlowContext, session?: TransactionSession): Promise<ReplenishmentRule>;
76
+ }
77
+ //#endregion
78
+ export { ProcurementOrder as a, ProcurementItem as i, ProcurementPort as n, ProcurementStatus as o, ReplenishmentRule as r, ReplenishmentRulePort as t };