@rytass/wms-module-core 0.1.6 → 0.2.0

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.
package/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './lib/models';
3
3
  export * from './lib/services';
4
4
  export * from './lib/typings';
5
5
  export * from './lib/constants';
6
+ export * from './lib/events';
package/index.js CHANGED
@@ -72,3 +72,7 @@ export { WMS_CORE_MODULE_OPTIONS } from './lib/typings/core-module-options.js';
72
72
  export { ReceiveInventoryOrderStatus } from './lib/typings/find-receive-inventory-order.input.js';
73
73
  export { ShipInventoryOrderStatus } from './lib/typings/find-ship-inventory-order.input.js';
74
74
  export { ChangeType, StockStatus } from './lib/constants/stock-status.js';
75
+ export { WMS_EVENT_EMITTER_BRIDGE, WMS_EVENT_OPTIONS } from './lib/events/wms-event.tokens.js';
76
+ export { WmsEventCollector } from './lib/events/wms-event.collector.js';
77
+ export { WmsEventDispatcher } from './lib/events/wms-event.dispatcher.js';
78
+ export { collectToScope, runInDispatchScope } from './lib/events/dispatch-scope.js';
@@ -0,0 +1,18 @@
1
+ import type { WmsDomainEvent } from './wms-event.types';
2
+ /** Push an event into the active scope. No-op when called outside a scope. */
3
+ export declare function collectToScope(event: WmsDomainEvent): void;
4
+ export interface DispatchScopeResult<T> {
5
+ readonly result: T;
6
+ /**
7
+ * The collected events when this call **owns** the outermost scope (caller
8
+ * must flush them), or `null` when joining an existing outer scope (the outer
9
+ * owner flushes).
10
+ */
11
+ readonly events: readonly WmsDomainEvent[] | null;
12
+ }
13
+ /**
14
+ * Run `fn` inside a dispatch scope. If a scope already exists (nested mutation),
15
+ * joins it and returns `events: null` so only the outermost owner flushes — this
16
+ * guarantees a single post-commit flush after the outermost transaction.
17
+ */
18
+ export declare function runInDispatchScope<T>(fn: () => Promise<T>): Promise<DispatchScopeResult<T>>;
@@ -0,0 +1,29 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+
3
+ /**
4
+ * Process-wide async-context store that buffers domain events for the lifetime
5
+ * of a single mutation. Propagates automatically across `await` boundaries
6
+ * (resolver -> service -> cross-service) via the V8 async context, so services
7
+ * collect into the same buffer without threading any context argument.
8
+ */
9
+ const dispatchAls = new AsyncLocalStorage();
10
+ /** Push an event into the active scope. No-op when called outside a scope. */
11
+ function collectToScope(event) {
12
+ dispatchAls.getStore()?.buffer.push(event);
13
+ }
14
+ /**
15
+ * Run `fn` inside a dispatch scope. If a scope already exists (nested mutation),
16
+ * joins it and returns `events: null` so only the outermost owner flushes — this
17
+ * guarantees a single post-commit flush after the outermost transaction.
18
+ */
19
+ async function runInDispatchScope(fn) {
20
+ if (dispatchAls.getStore()) {
21
+ const result = await fn();
22
+ return { result, events: null };
23
+ }
24
+ const scope = { buffer: [] };
25
+ const result = await dispatchAls.run(scope, fn);
26
+ return { result, events: scope.buffer };
27
+ }
28
+
29
+ export { collectToScope, runInDispatchScope };
@@ -0,0 +1,5 @@
1
+ export { WMS_EVENT_EMITTER_BRIDGE, WMS_EVENT_OPTIONS, } from './wms-event.tokens';
2
+ export { WmsEventCollector } from './wms-event.collector';
3
+ export { WmsEventDispatcher } from './wms-event.dispatcher';
4
+ export { collectToScope, runInDispatchScope, type DispatchScopeResult, } from './dispatch-scope';
5
+ export type { WmsAfterEventContext, WmsAfterListener, WmsAfterListenerMap, WmsBeforeHook, WmsBeforeHookContext, WmsBeforeHookMap, WmsDomainEvent, WmsEventEmitterBridge, WmsEventModuleOptions, WmsEventName, WmsEventPayloadMap, WmsOperationEventName, WmsOperationEventPayload, WmsStockEventName, WmsStockEventPayload, } from './wms-event.types';
@@ -0,0 +1,18 @@
1
+ import { DataSource, type EntitySubscriberInterface, type InsertEvent } from 'typeorm';
2
+ import { WmsEventCollector } from './wms-event.collector';
3
+ /**
4
+ * Centralized collection of stock domain events. Listens to every
5
+ * `*_order_change` insert and, using the change table name plus the sign of
6
+ * `quantityChanged`, derives the `ChangeType` and buffers a `stock.*` event
7
+ * into the active dispatch scope (flushed post-commit by the graphql
8
+ * interceptor). This keeps the 12 domain services untouched and automatically
9
+ * covers any future code path that writes a change row.
10
+ *
11
+ * It self-registers on the data source so no global TypeORM `subscribers`
12
+ * config is required.
13
+ */
14
+ export declare class StockChangeSubscriber implements EntitySubscriberInterface {
15
+ private readonly collector;
16
+ constructor(dataSource: DataSource, collector: WmsEventCollector);
17
+ afterInsert(event: InsertEvent<unknown>): void;
18
+ }
@@ -0,0 +1,118 @@
1
+ import { __decorate, __param, __metadata } from 'tslib';
2
+ import { Injectable } from '@nestjs/common';
3
+ import { InjectDataSource } from '@nestjs/typeorm';
4
+ import { DataSource } from 'typeorm';
5
+ import { ChangeType } from '../constants/stock-status.js';
6
+ import { WmsEventCollector } from './wms-event.collector.js';
7
+
8
+ /**
9
+ * Resolve the `ChangeType` for a change table. Tables whose semantics depend on
10
+ * the sign of `quantityChanged` (ship / transfer / vendor / customer / hold /
11
+ * allocate) branch on it; the rest are fixed.
12
+ */
13
+ const TABLE_TO_CHANGE_TYPE = new Map([
14
+ ['receive_inventory_order_changes', () => ChangeType.RECEIVED],
15
+ [
16
+ 'ship_inventory_order_changes',
17
+ (q) => (q > 0 ? ChangeType.IN_SHIPMENT : ChangeType.SHIPPED),
18
+ ],
19
+ [
20
+ 'transfer_order_changes',
21
+ (q) => (q > 0 ? ChangeType.IN_TRANSFER : ChangeType.TRANSFERRED),
22
+ ],
23
+ [
24
+ 'transfer_vendor_order_changes',
25
+ (q) => q > 0 ? ChangeType.VENDOR_TRANSFERRED : ChangeType.VENDOR_RETURNED,
26
+ ],
27
+ [
28
+ 'transfer_customer_order_changes',
29
+ (q) => q > 0 ? ChangeType.CUSTOMER_HELD : ChangeType.CUSTOMER_RETURNED,
30
+ ],
31
+ [
32
+ 'hold_inventory_order_changes',
33
+ (q) => (q > 0 ? ChangeType.HELD : ChangeType.RELEASED),
34
+ ],
35
+ [
36
+ 'allocate_inventory_order_changes',
37
+ (q) => (q > 0 ? ChangeType.ALLOCATED : ChangeType.DEALLOCATED),
38
+ ],
39
+ ['split_batch_order_changes', () => ChangeType.SPLITTED],
40
+ ['merge_batch_order_changes', () => ChangeType.MERGED],
41
+ ['reclassify_inventory_order_changes', () => ChangeType.RECLASSIFIED],
42
+ ['scrape_order_changes', () => ChangeType.SCRAPED],
43
+ ]);
44
+ const CHANGE_TYPE_TO_EVENT = {
45
+ [ChangeType.RECEIVED]: 'stock.received',
46
+ [ChangeType.IN_SHIPMENT]: 'stock.in-shipment',
47
+ [ChangeType.SHIPPED]: 'stock.shipped',
48
+ [ChangeType.IN_TRANSFER]: 'stock.in-transfer',
49
+ [ChangeType.TRANSFERRED]: 'stock.transferred',
50
+ [ChangeType.VENDOR_TRANSFERRED]: 'stock.vendor-transferred',
51
+ [ChangeType.VENDOR_RETURNED]: 'stock.vendor-returned',
52
+ [ChangeType.HELD]: 'stock.held',
53
+ [ChangeType.RELEASED]: 'stock.released',
54
+ [ChangeType.CUSTOMER_HELD]: 'stock.customer-held',
55
+ [ChangeType.CUSTOMER_RETURNED]: 'stock.customer-returned',
56
+ [ChangeType.SPLITTED]: 'stock.splitted',
57
+ [ChangeType.MERGED]: 'stock.merged',
58
+ [ChangeType.ALLOCATED]: 'stock.allocated',
59
+ [ChangeType.DEALLOCATED]: 'stock.deallocated',
60
+ [ChangeType.RECLASSIFIED]: 'stock.reclassified',
61
+ [ChangeType.SCRAPED]: 'stock.scraped',
62
+ };
63
+ const QUALITY_INSPECTION_TABLE = 'quality_inspection_order_changes';
64
+ /**
65
+ * Centralized collection of stock domain events. Listens to every
66
+ * `*_order_change` insert and, using the change table name plus the sign of
67
+ * `quantityChanged`, derives the `ChangeType` and buffers a `stock.*` event
68
+ * into the active dispatch scope (flushed post-commit by the graphql
69
+ * interceptor). This keeps the 12 domain services untouched and automatically
70
+ * covers any future code path that writes a change row.
71
+ *
72
+ * It self-registers on the data source so no global TypeORM `subscribers`
73
+ * config is required.
74
+ */
75
+ let StockChangeSubscriber = class StockChangeSubscriber {
76
+ collector;
77
+ constructor(dataSource, collector) {
78
+ this.collector = collector;
79
+ dataSource.subscribers.push(this);
80
+ }
81
+ afterInsert(event) {
82
+ const tableName = event.metadata.tableName;
83
+ const entity = event.entity;
84
+ if (!entity || typeof entity.id !== 'string') {
85
+ return;
86
+ }
87
+ const quantityDelta = Number(entity.quantityChanged);
88
+ if (tableName === QUALITY_INSPECTION_TABLE) {
89
+ this.collector.collect('stock.inspection-resolved', {
90
+ orderId: entity.id,
91
+ itemId: entity.itemId,
92
+ quantityDelta,
93
+ changeType: null,
94
+ inspectionResult: entity.result ?? null,
95
+ });
96
+ return;
97
+ }
98
+ const resolveChangeType = TABLE_TO_CHANGE_TYPE.get(tableName);
99
+ if (!resolveChangeType) {
100
+ return;
101
+ }
102
+ const changeType = resolveChangeType(quantityDelta);
103
+ this.collector.collect(CHANGE_TYPE_TO_EVENT[changeType], {
104
+ orderId: entity.id,
105
+ itemId: entity.itemId,
106
+ quantityDelta,
107
+ changeType,
108
+ });
109
+ }
110
+ };
111
+ StockChangeSubscriber = __decorate([
112
+ Injectable(),
113
+ __param(0, InjectDataSource()),
114
+ __metadata("design:paramtypes", [DataSource,
115
+ WmsEventCollector])
116
+ ], StockChangeSubscriber);
117
+
118
+ export { StockChangeSubscriber };
@@ -0,0 +1,11 @@
1
+ import type { WmsEventName, WmsEventPayloadMap } from './wms-event.types';
2
+ /**
3
+ * Injected into core services so they can record stock domain events at the
4
+ * point a `*_order_change` / state transition is written. Events are buffered
5
+ * in the current dispatch scope and flushed post-commit by the graphql
6
+ * interceptor. Outside a scope (the service called directly as a plain library)
7
+ * this is a silent no-op.
8
+ */
9
+ export declare class WmsEventCollector {
10
+ collect<N extends WmsEventName>(name: N, payload: WmsEventPayloadMap[N]): void;
11
+ }
@@ -0,0 +1,22 @@
1
+ import { __decorate } from 'tslib';
2
+ import { Injectable } from '@nestjs/common';
3
+ import { collectToScope } from './dispatch-scope.js';
4
+
5
+ /**
6
+ * Injected into core services so they can record stock domain events at the
7
+ * point a `*_order_change` / state transition is written. Events are buffered
8
+ * in the current dispatch scope and flushed post-commit by the graphql
9
+ * interceptor. Outside a scope (the service called directly as a plain library)
10
+ * this is a silent no-op.
11
+ */
12
+ let WmsEventCollector = class WmsEventCollector {
13
+ collect(name, payload) {
14
+ const event = { name, payload };
15
+ collectToScope(event);
16
+ }
17
+ };
18
+ WmsEventCollector = __decorate([
19
+ Injectable()
20
+ ], WmsEventCollector);
21
+
22
+ export { WmsEventCollector };
@@ -0,0 +1,19 @@
1
+ import type { WmsBeforeHookContext, WmsDomainEvent, WmsEventEmitterBridge, WmsEventModuleOptions } from './wms-event.types';
2
+ /**
3
+ * Central event dispatcher. Runs consumer before-hooks (which may veto) and,
4
+ * post-commit, flushes collected events to consumer after-listeners and the
5
+ * optional emitter bridge. Listener errors are isolated so one failing listener
6
+ * never blocks the others or the already-committed mutation.
7
+ */
8
+ export declare class WmsEventDispatcher {
9
+ private readonly options;
10
+ private readonly bridge;
11
+ private readonly logger;
12
+ constructor(options: WmsEventModuleOptions, bridge?: WmsEventEmitterBridge | null);
13
+ /** Whether any hook, listener or bridge is wired (lets the interceptor skip overhead entirely). */
14
+ isActive(): boolean;
15
+ /** Invoke the before-hook for an event. A thrown error vetoes the mutation. */
16
+ runBeforeHook(context: WmsBeforeHookContext): Promise<void>;
17
+ /** Flush collected events to after-listeners and the emitter bridge (post-commit). */
18
+ flush(events: readonly WmsDomainEvent[]): Promise<void>;
19
+ }
@@ -0,0 +1,63 @@
1
+ import { __decorate, __param, __metadata } from 'tslib';
2
+ import { Injectable, Inject, Optional, Logger } from '@nestjs/common';
3
+ import { WMS_EVENT_OPTIONS, WMS_EVENT_EMITTER_BRIDGE } from './wms-event.tokens.js';
4
+
5
+ var WmsEventDispatcher_1;
6
+ /**
7
+ * Central event dispatcher. Runs consumer before-hooks (which may veto) and,
8
+ * post-commit, flushes collected events to consumer after-listeners and the
9
+ * optional emitter bridge. Listener errors are isolated so one failing listener
10
+ * never blocks the others or the already-committed mutation.
11
+ */
12
+ let WmsEventDispatcher = WmsEventDispatcher_1 = class WmsEventDispatcher {
13
+ options;
14
+ bridge;
15
+ logger = new Logger(WmsEventDispatcher_1.name);
16
+ constructor(options, bridge = null) {
17
+ this.options = options;
18
+ this.bridge = bridge;
19
+ }
20
+ /** Whether any hook, listener or bridge is wired (lets the interceptor skip overhead entirely). */
21
+ isActive() {
22
+ const { beforeHooks, afterListeners } = this.options;
23
+ return (!!this.bridge ||
24
+ (!!beforeHooks && Object.keys(beforeHooks).length > 0) ||
25
+ (!!afterListeners && Object.keys(afterListeners).length > 0));
26
+ }
27
+ /** Invoke the before-hook for an event. A thrown error vetoes the mutation. */
28
+ async runBeforeHook(context) {
29
+ const hook = this.options.beforeHooks?.[context.event];
30
+ if (hook) {
31
+ await hook(context);
32
+ }
33
+ }
34
+ /** Flush collected events to after-listeners and the emitter bridge (post-commit). */
35
+ async flush(events) {
36
+ for (const event of events) {
37
+ const listener = this.options.afterListeners?.[event.name];
38
+ if (listener) {
39
+ try {
40
+ await listener({ event: event.name, payload: event.payload });
41
+ }
42
+ catch (error) {
43
+ this.logger.error(`WMS after-listener for "${event.name}" threw: ${error instanceof Error ? error.message : String(error)}`);
44
+ }
45
+ }
46
+ try {
47
+ this.bridge?.forward(event);
48
+ }
49
+ catch (error) {
50
+ this.logger.error(`WMS emitter bridge for "${event.name}" threw: ${error instanceof Error ? error.message : String(error)}`);
51
+ }
52
+ }
53
+ }
54
+ };
55
+ WmsEventDispatcher = WmsEventDispatcher_1 = __decorate([
56
+ Injectable(),
57
+ __param(0, Inject(WMS_EVENT_OPTIONS)),
58
+ __param(1, Optional()),
59
+ __param(1, Inject(WMS_EVENT_EMITTER_BRIDGE)),
60
+ __metadata("design:paramtypes", [Object, Object])
61
+ ], WmsEventDispatcher);
62
+
63
+ export { WmsEventDispatcher };
@@ -0,0 +1,4 @@
1
+ /** DI token holding the resolved {@link WmsEventModuleOptions}. */
2
+ export declare const WMS_EVENT_OPTIONS: unique symbol;
3
+ /** DI token for an optional external emitter bridge (e.g. @nestjs/event-emitter). */
4
+ export declare const WMS_EVENT_EMITTER_BRIDGE: unique symbol;
@@ -0,0 +1,6 @@
1
+ /** DI token holding the resolved {@link WmsEventModuleOptions}. */
2
+ const WMS_EVENT_OPTIONS = Symbol('WMS_EVENT_OPTIONS');
3
+ /** DI token for an optional external emitter bridge (e.g. @nestjs/event-emitter). */
4
+ const WMS_EVENT_EMITTER_BRIDGE = Symbol('WMS_EVENT_EMITTER_BRIDGE');
5
+
6
+ export { WMS_EVENT_EMITTER_BRIDGE, WMS_EVENT_OPTIONS };
@@ -0,0 +1,98 @@
1
+ import type { ExecutionContext } from '@nestjs/common';
2
+ import type { ChangeType } from '../constants/stock-status';
3
+ /**
4
+ * Host-neutral event/hook contracts for WMS mutations.
5
+ *
6
+ * Two tiers of events:
7
+ * - **Operation events** (`<domain>.<past-tense-action>`): exactly one per root
8
+ * mutation, emitted by the GraphQL interceptor after the handler resolves
9
+ * (post-commit) carrying the operation result.
10
+ * - **Stock domain events** (`stock.<change-type>`): driven by the `ChangeType`
11
+ * state machine, collected inside core services (possibly many per operation)
12
+ * and flushed post-commit.
13
+ *
14
+ * The library never knows what a consumer does with these — it only declares the
15
+ * names and payloads. Wiring is opt-in via `forRootAsync({ beforeHooks,
16
+ * afterListeners })`; when nothing is configured the whole chain is inert.
17
+ */
18
+ export type WmsOperationEventName = 'receive-inventory-order.created' | 'receive-inventory-order.updated' | 'receive-inventory-order.received' | 'ship-inventory-order.created' | 'ship-inventory-order.updated' | 'ship-inventory-order.shipped' | 'ship-inventory-order.ship-cancelled' | 'transfer-order.created' | 'transfer-order.updated' | 'transfer-order.transferred' | 'transfer-order.transfer-cancelled' | 'hold-inventory-order.created' | 'hold-inventory-order.updated' | 'hold-inventory-order.released' | 'allocate-inventory-order.created' | 'allocate-inventory-order.updated' | 'allocate-inventory-order.deallocated' | 'transfer-vendor-order.created' | 'transfer-vendor-order.updated' | 'transfer-vendor-order.returned' | 'transfer-customer-order.created' | 'transfer-customer-order.updated' | 'transfer-customer-order.returned' | 'quality-inspection-order.inspected' | 'scrape-order.scraped' | 'reclassify-inventory-order.reclassified' | 'batch.merged' | 'batch.splitted' | 'material.created' | 'material.updated' | 'loader.created' | 'loader.batch-created' | 'loader.updated' | 'loader.type-created' | 'loader.type-updated' | 'location.created' | 'location.updated' | 'warehouse-map.updated';
19
+ export type WmsStockEventName = 'stock.received' | 'stock.in-shipment' | 'stock.shipped' | 'stock.in-transfer' | 'stock.transferred' | 'stock.vendor-transferred' | 'stock.vendor-returned' | 'stock.held' | 'stock.released' | 'stock.customer-held' | 'stock.customer-returned' | 'stock.splitted' | 'stock.merged' | 'stock.allocated' | 'stock.deallocated' | 'stock.reclassified' | 'stock.scraped' | 'stock.inspection-resolved';
20
+ export type WmsEventName = WmsOperationEventName | WmsStockEventName;
21
+ /**
22
+ * Payload for an operation event. `id` is the primary key of the operation's
23
+ * main entity/order (correlation id shared with the stock events it fans out
24
+ * to); `result` is the mutation's return value (a DTO, or `boolean` for action
25
+ * mutations).
26
+ */
27
+ export interface WmsOperationEventPayload<TResult = unknown> {
28
+ readonly id: string | null;
29
+ readonly result: TResult;
30
+ }
31
+ /**
32
+ * Payload for a stock domain event, built from the inserted `*_order_change`
33
+ * row. These four fields are reliably available the moment the change is
34
+ * written (no extra query). For richer batch/material/location details a
35
+ * listener can look them up by `orderId` / `itemId` after commit.
36
+ */
37
+ export interface WmsStockEventPayload {
38
+ /** Base order id (`change.id`) — correlation id shared with the operation event. */
39
+ readonly orderId: string;
40
+ /** The order item this change applies to (`change.itemId`). */
41
+ readonly itemId: string;
42
+ /** `change.quantityChanged` — sign carries direction (in: +, out: -). */
43
+ readonly quantityDelta: number;
44
+ /** The resolved `ChangeType` for this stock movement (null for inspection). */
45
+ readonly changeType: ChangeType | null;
46
+ /** Quality-inspection result, present only on `stock.inspection-resolved`. */
47
+ readonly inspectionResult?: boolean | null;
48
+ }
49
+ /** Maps every event name to its payload type. */
50
+ export type WmsEventPayloadMap = {
51
+ readonly [N in WmsOperationEventName]: WmsOperationEventPayload;
52
+ } & {
53
+ readonly [N in WmsStockEventName]: WmsStockEventPayload;
54
+ };
55
+ /** A collected domain event: a name plus its typed payload. */
56
+ export interface WmsDomainEvent<N extends WmsEventName = WmsEventName> {
57
+ readonly name: N;
58
+ readonly payload: WmsEventPayloadMap[N];
59
+ }
60
+ /**
61
+ * Context handed to a before-hook. Runs *before* any DB work, so it sees the
62
+ * mutation **intent** (raw GraphQL arguments) rather than a result. Throwing
63
+ * vetoes the whole mutation with zero side effects.
64
+ */
65
+ export interface WmsBeforeHookContext<N extends WmsEventName = WmsEventName> {
66
+ readonly event: N;
67
+ readonly args: Readonly<Record<string, unknown>>;
68
+ readonly executionContext: ExecutionContext;
69
+ }
70
+ /** Context handed to an after-listener. Runs post-commit with the event payload. */
71
+ export interface WmsAfterEventContext<N extends WmsEventName = WmsEventName> {
72
+ readonly event: N;
73
+ readonly payload: WmsEventPayloadMap[N];
74
+ }
75
+ export type WmsBeforeHook<N extends WmsEventName = WmsEventName> = (context: WmsBeforeHookContext<N>) => void | Promise<void>;
76
+ export type WmsAfterListener<N extends WmsEventName = WmsEventName> = (context: WmsAfterEventContext<N>) => void | Promise<void>;
77
+ export type WmsBeforeHookMap = {
78
+ readonly [N in WmsEventName]?: WmsBeforeHook<N>;
79
+ };
80
+ export type WmsAfterListenerMap = {
81
+ readonly [N in WmsEventName]?: WmsAfterListener<N>;
82
+ };
83
+ /**
84
+ * Event options merged into the module options. All optional — omit everything
85
+ * to keep the module inert (pre-event behaviour).
86
+ */
87
+ export interface WmsEventModuleOptions {
88
+ readonly beforeHooks?: WmsBeforeHookMap;
89
+ readonly afterListeners?: WmsAfterListenerMap;
90
+ }
91
+ /**
92
+ * Runtime bridge to an external emitter (e.g. `@nestjs/event-emitter`). The
93
+ * graphql package provides an implementation; when absent, dispatch simply
94
+ * skips it.
95
+ */
96
+ export interface WmsEventEmitterBridge {
97
+ forward(event: WmsDomainEvent): void;
98
+ }
@@ -1,6 +1,8 @@
1
1
  import { __decorate } from 'tslib';
2
2
  import { Module } from '@nestjs/common';
3
3
  import { TypeOrmModule } from '@nestjs/typeorm';
4
+ import { WmsEventCollector } from '../events/wms-event.collector.js';
5
+ import { StockChangeSubscriber } from '../events/stock-change.subscriber.js';
4
6
  import { WarehouseMapEntity as WarehouseMapEntity$1 } from '@rytass/wms-base-nestjs-module/models/warehouse-map.entity';
5
7
  import { BatchEntity, BatchEntityClass } from './metadata/batch.entity.js';
6
8
  import { BatchGroupEntity, BatchGroupEntityClass } from './metadata/batch-group.entity.js';
@@ -114,8 +116,12 @@ let ModelsModule = class ModelsModule {
114
116
  ModelsModule = __decorate([
115
117
  Module({
116
118
  imports: [TypeOrmModule.forFeature(entities.map(([_, entity]) => entity))],
117
- providers: ResolvedEntitiesProviders,
118
- exports: [TypeOrmModule, ...ResolvedEntitiesProviders],
119
+ providers: [
120
+ ...ResolvedEntitiesProviders,
121
+ WmsEventCollector,
122
+ StockChangeSubscriber,
123
+ ],
124
+ exports: [TypeOrmModule, ...ResolvedEntitiesProviders, WmsEventCollector],
119
125
  })
120
126
  ], ModelsModule);
121
127
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rytass/wms-module-core",
3
- "version": "0.1.6",
3
+ "version": "0.2.0",
4
4
  "description": "Rytass WMS Module — NestJS services and TypeORM entities for warehouse management",
5
5
  "keywords": [
6
6
  "rytass",