@rytass/wms-module-core 0.4.0 → 0.5.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/README.md +26 -6
- package/docs/api-reference.md +26 -9
- package/docs/custom-entities.md +105 -68
- package/index.cjs.js +301 -147
- package/index.js +3 -0
- package/lib/core.module.js +82 -29
- package/lib/models/extensions/allocate-inventory-order/allocate-inventory-order-item.entity.js +1 -0
- package/lib/models/extensions/hold-inventory-order/hold-inventory-order-item.entity.js +1 -0
- package/lib/models/extensions/merge-batch-order/merge-batch-order-item.entity.js +1 -0
- package/lib/models/extensions/quality-inspection-order/quality-inspection-order-item.entity.js +1 -0
- package/lib/models/extensions/reclassify-inventory-order/reclassify-inventory-order-item.entity.js +1 -0
- package/lib/models/extensions/scrape-order/scrape-order-item.entity.js +1 -0
- package/lib/models/extensions/split-batch-order/split-batch-order-item.entity.js +1 -0
- package/lib/models/extensions/transfer-customer-order/transfer-customer-order-item.entity.js +1 -0
- package/lib/models/extensions/transfer-order/transfer-order-item.entity.js +1 -0
- package/lib/models/extensions/transfer-vendor-order/transfer-vendor-order-item.entity.js +1 -0
- package/lib/models/index.d.ts +1 -0
- package/lib/models/metadata/index.d.ts +1 -0
- package/lib/models/metadata/order.entity.d.ts +9 -0
- package/lib/models/metadata/order.entity.js +5 -0
- package/lib/models/models.module.js +15 -8
- package/lib/models/wms-entities.d.ts +45 -0
- package/lib/models/wms-entities.js +82 -0
- package/lib/services/allocate-inventory-order.service.d.ts +3 -1
- package/lib/services/allocate-inventory-order.service.js +10 -6
- package/lib/services/batch.service.js +5 -3
- package/lib/services/hold-inventory-order.service.d.ts +3 -1
- package/lib/services/hold-inventory-order.service.js +10 -6
- package/lib/services/loader.service.js +2 -0
- package/lib/services/location.service.js +2 -0
- package/lib/services/material.service.d.ts +1 -15
- package/lib/services/material.service.js +2 -20
- package/lib/services/merge-batch-order.service.d.ts +3 -1
- package/lib/services/merge-batch-order.service.js +13 -9
- package/lib/services/quality-inspection-order.service.d.ts +3 -1
- package/lib/services/quality-inspection-order.service.js +12 -8
- package/lib/services/receive-inventory-order.service.d.ts +3 -1
- package/lib/services/receive-inventory-order.service.js +15 -11
- package/lib/services/reclassify-inventory-order.service.d.ts +3 -1
- package/lib/services/reclassify-inventory-order.service.js +13 -9
- package/lib/services/scrape.service.d.ts +3 -1
- package/lib/services/scrape.service.js +9 -5
- package/lib/services/ship-inventory-order.service.d.ts +3 -1
- package/lib/services/ship-inventory-order.service.js +18 -14
- package/lib/services/split-batch-order.service.d.ts +3 -1
- package/lib/services/split-batch-order.service.js +13 -9
- package/lib/services/stock.service.d.ts +3 -1
- package/lib/services/stock.service.js +14 -10
- package/lib/services/transfer-customer-order.service.d.ts +3 -1
- package/lib/services/transfer-customer-order.service.js +12 -8
- package/lib/services/transfer-order.service.d.ts +3 -1
- package/lib/services/transfer-order.service.js +11 -7
- package/lib/services/transfer-vendor-order.service.d.ts +3 -1
- package/lib/services/transfer-vendor-order.service.js +12 -8
- package/lib/services/unit.service.js +2 -0
- package/lib/services/warehouse-map.service.d.ts +3 -1
- package/lib/services/warehouse-map.service.js +9 -6
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -7,9 +7,11 @@ export { LoaderUnitEntity, LoaderUnitEntityClass } from './lib/models/metadata/l
|
|
|
7
7
|
export { LocationEntity, LocationEntityClass, WarehouseMapEntity } from './lib/models/metadata/location.entity.js';
|
|
8
8
|
export { MaterialEntity, MaterialEntityClass } from './lib/models/metadata/material.entity.js';
|
|
9
9
|
export { MaterialUnitEntity, MaterialUnitEntityClass } from './lib/models/metadata/material-unit.entity.js';
|
|
10
|
+
export { OrderEntity } from './lib/models/metadata/order.entity.js';
|
|
10
11
|
export { SaleOrderEntity, SaleOrderEntityClass } from './lib/models/metadata/sale-order.entity.js';
|
|
11
12
|
export { StockEntity, StockEntityClass } from './lib/models/metadata/stock.entity.js';
|
|
12
13
|
export { UnitEntity, UnitEntityClass } from './lib/models/metadata/unit.entity.js';
|
|
14
|
+
export { WmsEntities } from './lib/models/wms-entities.js';
|
|
13
15
|
export { ReceiveInventoryOrderItemEntity, ReceiveInventoryOrderItemEntityClass } from './lib/models/extensions/receive-inventory-order/receive-inventory-order-item.entity.js';
|
|
14
16
|
export { ReceiveInventoryOrderEntity, ReceiveInventoryOrderEntityClass } from './lib/models/extensions/receive-inventory-order/receive-inventory-order.entity.js';
|
|
15
17
|
export { ReceiveInventoryOrderChangeEntity, ReceiveInventoryOrderChangeEntityClass } from './lib/models/extensions/receive-inventory-order/receive-inventory-order-change.entity.js';
|
|
@@ -76,3 +78,4 @@ export { WMS_ACTOR_EXTRACTOR, WMS_EVENT_EMITTER_BRIDGE, WMS_EVENT_OPTIONS, WMS_S
|
|
|
76
78
|
export { WmsEventCollector } from './lib/events/wms-event.collector.js';
|
|
77
79
|
export { WmsEventDispatcher } from './lib/events/wms-event.dispatcher.js';
|
|
78
80
|
export { collectToScope, runInDispatchScope } from './lib/events/dispatch-scope.js';
|
|
81
|
+
export { OrderEntity as OrderEntityClass } from '@rytass/wms-base-nestjs-module';
|
package/lib/core.module.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
2
|
import { Module } from '@nestjs/common';
|
|
3
|
-
import {
|
|
3
|
+
import { PROVIDE_MATERIAL_ENTITY, PROVIDE_BATCH_ENTITY, PROVIDE_LOCATION_ENTITY, PROVIDE_STOCK_ENTITY, OrderEntity, PROVIDE_ORDER_ENTITY, PROVIDE_WAREHOUSE_MAP_ENTITY, WMSBaseModule } from '@rytass/wms-base-nestjs-module';
|
|
4
|
+
import { WarehouseMapEntity } from '@rytass/wms-base-nestjs-module/models/warehouse-map.entity';
|
|
4
5
|
import { ModelsModule } from './models/models.module.js';
|
|
5
|
-
import {
|
|
6
|
+
import { WmsEntities } from './models/wms-entities.js';
|
|
7
|
+
import { BatchEntityClass, BatchEntity } from './models/metadata/batch.entity.js';
|
|
8
|
+
import { LocationEntityClass, LocationEntity, WarehouseMapEntity as WarehouseMapEntity$1 } from './models/metadata/location.entity.js';
|
|
9
|
+
import { MaterialEntityClass, MaterialEntity } from './models/metadata/material.entity.js';
|
|
10
|
+
import { OrderEntity as OrderEntity$1 } from './models/metadata/order.entity.js';
|
|
11
|
+
import { StockEntityClass, StockEntity } from './models/metadata/stock.entity.js';
|
|
6
12
|
import { StockService } from './services/stock.service.js';
|
|
7
13
|
import { LoaderService } from './services/loader.service.js';
|
|
8
14
|
import { MaterialService } from './services/material.service.js';
|
|
@@ -30,34 +36,81 @@ import { WMS_CORE_MODULE_OPTIONS } from './typings/core-module-options.js';
|
|
|
30
36
|
|
|
31
37
|
var WmsModuleCoreModule_1;
|
|
32
38
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* `MaterialEntityClass`.
|
|
39
|
+
* The entity Symbols a consumer can rebind, each paired with the base module's
|
|
40
|
+
* token carrying their replacement and the class it falls back to.
|
|
36
41
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* base module resolved: both are derived from the same option.
|
|
42
|
+
* These Symbols are how the whole package reaches an entity — no service,
|
|
43
|
+
* DataLoader or query imports the class directly — so rebinding one here swaps
|
|
44
|
+
* that entity everywhere at once. Resolution happens at injection time, from
|
|
45
|
+
* tokens `WMSBaseModule` derives from its own options, which means an override
|
|
46
|
+
* may arrive from `forRoot` or from an async options factory alike and cannot
|
|
47
|
+
* drift from the repository the base module resolved: both come from one option.
|
|
44
48
|
*/
|
|
45
|
-
const
|
|
46
|
-
|
|
49
|
+
const OVERRIDABLE_ENTITIES = [
|
|
50
|
+
{
|
|
51
|
+
option: 'materialEntity',
|
|
52
|
+
token: MaterialEntity,
|
|
53
|
+
provide: PROVIDE_MATERIAL_ENTITY,
|
|
54
|
+
fallback: MaterialEntityClass,
|
|
55
|
+
requires: 'description / baseUnit / isActive',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
option: 'batchEntity',
|
|
59
|
+
token: BatchEntity,
|
|
60
|
+
provide: PROVIDE_BATCH_ENTITY,
|
|
61
|
+
fallback: BatchEntityClass,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
option: 'locationEntity',
|
|
65
|
+
token: LocationEntity,
|
|
66
|
+
provide: PROVIDE_LOCATION_ENTITY,
|
|
67
|
+
fallback: LocationEntityClass,
|
|
68
|
+
requires: 'description / isActive',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
option: 'stockEntity',
|
|
72
|
+
token: StockEntity,
|
|
73
|
+
provide: PROVIDE_STOCK_ENTITY,
|
|
74
|
+
fallback: StockEntityClass,
|
|
75
|
+
requires: 'loaderId / rollbackedAt',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
option: 'orderEntity',
|
|
79
|
+
token: OrderEntity$1,
|
|
80
|
+
provide: PROVIDE_ORDER_ENTITY,
|
|
81
|
+
fallback: OrderEntity,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
option: 'warehouseMapEntity',
|
|
85
|
+
token: WarehouseMapEntity$1,
|
|
86
|
+
provide: PROVIDE_WAREHOUSE_MAP_ENTITY,
|
|
87
|
+
fallback: WarehouseMapEntity,
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
const entityProviders = OVERRIDABLE_ENTITIES.map(({ option, token, provide, fallback, requires }) => ({
|
|
91
|
+
provide: token,
|
|
47
92
|
useFactory: (configured) => {
|
|
48
|
-
if (!configured)
|
|
49
|
-
return
|
|
50
|
-
// `WMSBaseModuleOptions` only asks for a child of the base
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
if (!(configured.prototype instanceof
|
|
56
|
-
throw new Error(`WmsModuleCoreModule:
|
|
93
|
+
if (!configured || configured === fallback)
|
|
94
|
+
return fallback;
|
|
95
|
+
// `WMSBaseModuleOptions` only asks for a child of the *base* entity, but
|
|
96
|
+
// this package reads the columns its own subclass adds. TypeScript's
|
|
97
|
+
// structural typing happily accepts a sibling that never declares them,
|
|
98
|
+
// which then surfaces as a missing column mid-query — a much worse error
|
|
99
|
+
// to work backwards from than this one.
|
|
100
|
+
if (!(configured.prototype instanceof fallback))
|
|
101
|
+
throw new Error(`WmsModuleCoreModule: ${option} "${configured.name}" must extend ${fallback.name} (a @ChildEntity() of it)${requires
|
|
102
|
+
? `. @rytass/wms-module-core reads ${requires} from it, which the base entity does not declare`
|
|
103
|
+
: ''}.`);
|
|
57
104
|
return configured;
|
|
58
105
|
},
|
|
59
|
-
inject: [
|
|
60
|
-
};
|
|
106
|
+
inject: [provide],
|
|
107
|
+
}));
|
|
108
|
+
/** Bound after {@link entityProviders}, since it reads every one of them. */
|
|
109
|
+
const resolvedEntityProviders = [...entityProviders, WmsEntities];
|
|
110
|
+
const exportedEntityTokens = [
|
|
111
|
+
...OVERRIDABLE_ENTITIES.map(({ token }) => token),
|
|
112
|
+
WmsEntities,
|
|
113
|
+
];
|
|
61
114
|
const exportDependencies = [
|
|
62
115
|
LoaderService,
|
|
63
116
|
MaterialService,
|
|
@@ -90,7 +143,7 @@ let WmsModuleCoreModule = WmsModuleCoreModule_1 = class WmsModuleCoreModule {
|
|
|
90
143
|
providers: [
|
|
91
144
|
...exportDependencies,
|
|
92
145
|
StockChangeSubscriber,
|
|
93
|
-
|
|
146
|
+
...resolvedEntityProviders,
|
|
94
147
|
{ provide: WMS_CORE_MODULE_OPTIONS, useValue: coreOptions },
|
|
95
148
|
{ provide: WMS_STOCK_ENRICH, useValue: !!coreOptions.enrichStockEvents },
|
|
96
149
|
],
|
|
@@ -98,7 +151,7 @@ let WmsModuleCoreModule = WmsModuleCoreModule_1 = class WmsModuleCoreModule {
|
|
|
98
151
|
...exportDependencies,
|
|
99
152
|
coreModule,
|
|
100
153
|
ModelsModule,
|
|
101
|
-
|
|
154
|
+
...exportedEntityTokens,
|
|
102
155
|
WMS_CORE_MODULE_OPTIONS,
|
|
103
156
|
],
|
|
104
157
|
};
|
|
@@ -112,7 +165,7 @@ let WmsModuleCoreModule = WmsModuleCoreModule_1 = class WmsModuleCoreModule {
|
|
|
112
165
|
providers: [
|
|
113
166
|
...exportDependencies,
|
|
114
167
|
StockChangeSubscriber,
|
|
115
|
-
|
|
168
|
+
...resolvedEntityProviders,
|
|
116
169
|
{
|
|
117
170
|
provide: WMS_CORE_MODULE_OPTIONS,
|
|
118
171
|
useValue: {
|
|
@@ -127,7 +180,7 @@ let WmsModuleCoreModule = WmsModuleCoreModule_1 = class WmsModuleCoreModule {
|
|
|
127
180
|
...exportDependencies,
|
|
128
181
|
coreModule,
|
|
129
182
|
ModelsModule,
|
|
130
|
-
|
|
183
|
+
...exportedEntityTokens,
|
|
131
184
|
WMS_CORE_MODULE_OPTIONS,
|
|
132
185
|
],
|
|
133
186
|
};
|
package/lib/models/extensions/allocate-inventory-order/allocate-inventory-order-item.entity.js
CHANGED
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
package/lib/models/extensions/quality-inspection-order/quality-inspection-order-item.entity.js
CHANGED
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
package/lib/models/extensions/reclassify-inventory-order/reclassify-inventory-order-item.entity.js
CHANGED
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
package/lib/models/extensions/transfer-customer-order/transfer-customer-order-item.entity.js
CHANGED
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
package/lib/models/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './loader-unit.entity';
|
|
|
6
6
|
export * from './location.entity';
|
|
7
7
|
export * from './material.entity';
|
|
8
8
|
export * from './material-unit.entity';
|
|
9
|
+
export * from './order.entity';
|
|
9
10
|
export * from './sale-order.entity';
|
|
10
11
|
export * from './stock.entity';
|
|
11
12
|
export * from './unit.entity';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OrderEntity as BaseOrderEntity } from '@rytass/wms-base-nestjs-module';
|
|
2
|
+
export declare const OrderEntity: unique symbol;
|
|
3
|
+
/**
|
|
4
|
+
* Orders are the one domain this package adds no columns to, so the entity the
|
|
5
|
+
* `OrderEntity` Symbol falls back to is the base class itself. The alias exists
|
|
6
|
+
* for symmetry with every other entity in this folder — services and DTOs can
|
|
7
|
+
* keep referring to `OrderEntityClass` without caring where it is declared.
|
|
8
|
+
*/
|
|
9
|
+
export { BaseOrderEntity as OrderEntityClass };
|
|
@@ -11,6 +11,7 @@ import { LoaderUnitEntity, LoaderUnitEntityClass } from './metadata/loader-unit.
|
|
|
11
11
|
import { LocationEntity, LocationEntityClass, WarehouseMapEntity } from './metadata/location.entity.js';
|
|
12
12
|
import { MaterialEntity, MaterialEntityClass } from './metadata/material.entity.js';
|
|
13
13
|
import { MaterialUnitEntity, MaterialUnitEntityClass } from './metadata/material-unit.entity.js';
|
|
14
|
+
import '@rytass/wms-base-nestjs-module';
|
|
14
15
|
import { SaleOrderEntity, SaleOrderEntityClass } from './metadata/sale-order.entity.js';
|
|
15
16
|
import { StockEntity, StockEntityClass } from './metadata/stock.entity.js';
|
|
16
17
|
import { UnitEntity, UnitEntityClass } from './metadata/unit.entity.js';
|
|
@@ -107,16 +108,22 @@ const entities = [
|
|
|
107
108
|
[ScrapeOrderChangeEntity, ScrapeOrderChangeEntityClass],
|
|
108
109
|
];
|
|
109
110
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* importing `WMSBaseModule` can read. Binding
|
|
113
|
-
* live bindings for one token, and the loser would be
|
|
114
|
-
* injector happened to reach first.
|
|
111
|
+
* The overridable entities are deliberately absent: `WmsModuleCoreModule` binds
|
|
112
|
+
* each of them to whatever the matching `WMSBaseModuleOptions` entity resolved
|
|
113
|
+
* to, which only a module importing `WMSBaseModule` can read. Binding them here
|
|
114
|
+
* as well would leave two live bindings for one token, and the loser would be
|
|
115
|
+
* whichever module the injector happened to reach first.
|
|
115
116
|
*
|
|
116
|
-
*
|
|
117
|
-
* root of the single-table hierarchy a consumer's override extends.
|
|
117
|
+
* Their classes stay in `entities` above so TypeORM still registers them — each
|
|
118
|
+
* is the root of the single-table hierarchy a consumer's override extends.
|
|
118
119
|
*/
|
|
119
|
-
const EXTERNALLY_BOUND_ENTITIES = new Set([
|
|
120
|
+
const EXTERNALLY_BOUND_ENTITIES = new Set([
|
|
121
|
+
MaterialEntity,
|
|
122
|
+
BatchEntity,
|
|
123
|
+
LocationEntity,
|
|
124
|
+
StockEntity,
|
|
125
|
+
WarehouseMapEntity,
|
|
126
|
+
]);
|
|
120
127
|
const ResolvedEntitiesProviders = entities
|
|
121
128
|
.filter(([token]) => !EXTERNALLY_BOUND_ENTITIES.has(token))
|
|
122
129
|
.map(([token, entity]) => ({
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Type } from '@nestjs/common';
|
|
2
|
+
import { DataSource } from 'typeorm';
|
|
3
|
+
import { WarehouseMapEntity as WarehouseMapEntityClass } from '@rytass/wms-base-nestjs-module/models/warehouse-map.entity';
|
|
4
|
+
import { BatchEntityClass } from './metadata/batch.entity';
|
|
5
|
+
import { LocationEntityClass } from './metadata/location.entity';
|
|
6
|
+
import { MaterialEntityClass } from './metadata/material.entity';
|
|
7
|
+
import { OrderEntityClass } from './metadata/order.entity';
|
|
8
|
+
import { StockEntityClass } from './metadata/stock.entity';
|
|
9
|
+
/**
|
|
10
|
+
* The entity classes this package actually reads and writes, after applying the
|
|
11
|
+
* consumer's `WMSBaseModuleOptions` entity overrides.
|
|
12
|
+
*
|
|
13
|
+
* Every overridable entity is bound to a `Symbol` that `WmsModuleCoreModule`
|
|
14
|
+
* resolves from the base module's `PROVIDE_*_ENTITY` tokens. Injecting them one
|
|
15
|
+
* by one works, but most services and resolvers need three or four at once, so
|
|
16
|
+
* this collects them behind a single dependency.
|
|
17
|
+
*
|
|
18
|
+
* Only entities the base module lets a consumer replace are here. Entities this
|
|
19
|
+
* package owns outright — batch groups, loaders, units, every order extension —
|
|
20
|
+
* have no override to follow and are referenced by class directly.
|
|
21
|
+
*/
|
|
22
|
+
export declare class WmsEntities {
|
|
23
|
+
readonly material: Type<MaterialEntityClass>;
|
|
24
|
+
readonly batch: Type<BatchEntityClass>;
|
|
25
|
+
readonly location: Type<LocationEntityClass>;
|
|
26
|
+
readonly stock: Type<StockEntityClass>;
|
|
27
|
+
readonly order: Type<OrderEntityClass>;
|
|
28
|
+
readonly warehouseMap: Type<WarehouseMapEntityClass>;
|
|
29
|
+
constructor(dataSource: DataSource, material: Type<MaterialEntityClass>, batch: Type<BatchEntityClass>, location: Type<LocationEntityClass>, stock: Type<StockEntityClass>, order: Type<OrderEntityClass>, warehouseMap: Type<WarehouseMapEntityClass>);
|
|
30
|
+
/**
|
|
31
|
+
* Fail during instantiation if an override was never registered with TypeORM.
|
|
32
|
+
*
|
|
33
|
+
* The module cannot register it: `TypeOrmModule.forFeature()` runs while the
|
|
34
|
+
* module graph is assembled, and an override is only known once the options
|
|
35
|
+
* resolve. Registering the built-in class does bring the override's *columns*
|
|
36
|
+
* into the table (TypeORM copies a single-table child's columns into its
|
|
37
|
+
* parent), which makes the omission easy to miss — everything looks right
|
|
38
|
+
* until the first query fails with a bare `EntityMetadataNotFoundError` from
|
|
39
|
+
* somewhere deep in a resolver.
|
|
40
|
+
*
|
|
41
|
+
* This runs in the constructor rather than `onModuleInit` so it lands before
|
|
42
|
+
* any service's own startup work touches the database.
|
|
43
|
+
*/
|
|
44
|
+
private assertRegistered;
|
|
45
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { __decorate, __param, __metadata } from 'tslib';
|
|
2
|
+
import { Injectable, Inject } from '@nestjs/common';
|
|
3
|
+
import { DataSource } from 'typeorm';
|
|
4
|
+
import { BatchEntity } from './metadata/batch.entity.js';
|
|
5
|
+
import { LocationEntity, WarehouseMapEntity } from './metadata/location.entity.js';
|
|
6
|
+
import { MaterialEntity } from './metadata/material.entity.js';
|
|
7
|
+
import { OrderEntity } from './metadata/order.entity.js';
|
|
8
|
+
import { StockEntity } from './metadata/stock.entity.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The entity classes this package actually reads and writes, after applying the
|
|
12
|
+
* consumer's `WMSBaseModuleOptions` entity overrides.
|
|
13
|
+
*
|
|
14
|
+
* Every overridable entity is bound to a `Symbol` that `WmsModuleCoreModule`
|
|
15
|
+
* resolves from the base module's `PROVIDE_*_ENTITY` tokens. Injecting them one
|
|
16
|
+
* by one works, but most services and resolvers need three or four at once, so
|
|
17
|
+
* this collects them behind a single dependency.
|
|
18
|
+
*
|
|
19
|
+
* Only entities the base module lets a consumer replace are here. Entities this
|
|
20
|
+
* package owns outright — batch groups, loaders, units, every order extension —
|
|
21
|
+
* have no override to follow and are referenced by class directly.
|
|
22
|
+
*/
|
|
23
|
+
let WmsEntities = class WmsEntities {
|
|
24
|
+
material;
|
|
25
|
+
batch;
|
|
26
|
+
location;
|
|
27
|
+
stock;
|
|
28
|
+
order;
|
|
29
|
+
warehouseMap;
|
|
30
|
+
constructor(dataSource, material, batch, location, stock, order, warehouseMap) {
|
|
31
|
+
this.material = material;
|
|
32
|
+
this.batch = batch;
|
|
33
|
+
this.location = location;
|
|
34
|
+
this.stock = stock;
|
|
35
|
+
this.order = order;
|
|
36
|
+
this.warehouseMap = warehouseMap;
|
|
37
|
+
this.assertRegistered(dataSource);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Fail during instantiation if an override was never registered with TypeORM.
|
|
41
|
+
*
|
|
42
|
+
* The module cannot register it: `TypeOrmModule.forFeature()` runs while the
|
|
43
|
+
* module graph is assembled, and an override is only known once the options
|
|
44
|
+
* resolve. Registering the built-in class does bring the override's *columns*
|
|
45
|
+
* into the table (TypeORM copies a single-table child's columns into its
|
|
46
|
+
* parent), which makes the omission easy to miss — everything looks right
|
|
47
|
+
* until the first query fails with a bare `EntityMetadataNotFoundError` from
|
|
48
|
+
* somewhere deep in a resolver.
|
|
49
|
+
*
|
|
50
|
+
* This runs in the constructor rather than `onModuleInit` so it lands before
|
|
51
|
+
* any service's own startup work touches the database.
|
|
52
|
+
*/
|
|
53
|
+
assertRegistered(dataSource) {
|
|
54
|
+
const missing = [
|
|
55
|
+
['materialEntity', this.material],
|
|
56
|
+
['batchEntity', this.batch],
|
|
57
|
+
['locationEntity', this.location],
|
|
58
|
+
['stockEntity', this.stock],
|
|
59
|
+
['orderEntity', this.order],
|
|
60
|
+
['warehouseMapEntity', this.warehouseMap],
|
|
61
|
+
].filter(([, entity]) => !dataSource.hasMetadata(entity));
|
|
62
|
+
if (!missing.length)
|
|
63
|
+
return;
|
|
64
|
+
const details = missing
|
|
65
|
+
.map(([option, entity]) => `${option}: ${entity.name}`)
|
|
66
|
+
.join(', ');
|
|
67
|
+
const names = missing.map(([, entity]) => entity.name).join(', ');
|
|
68
|
+
throw new Error(`WmsModuleCoreModule: configured entities are not registered with TypeORM (${details}). Add them to your DataSource "entities", or import TypeOrmModule.forFeature([${names}]) somewhere in your app when using autoLoadEntities.`);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
WmsEntities = __decorate([
|
|
72
|
+
Injectable(),
|
|
73
|
+
__param(1, Inject(MaterialEntity)),
|
|
74
|
+
__param(2, Inject(BatchEntity)),
|
|
75
|
+
__param(3, Inject(LocationEntity)),
|
|
76
|
+
__param(4, Inject(StockEntity)),
|
|
77
|
+
__param(5, Inject(OrderEntity)),
|
|
78
|
+
__param(6, Inject(WarehouseMapEntity)),
|
|
79
|
+
__metadata("design:paramtypes", [DataSource, Object, Object, Object, Object, Object, Object])
|
|
80
|
+
], WmsEntities);
|
|
81
|
+
|
|
82
|
+
export { WmsEntities };
|
|
@@ -7,8 +7,10 @@ import { MaterialService } from './material.service';
|
|
|
7
7
|
import { FindAllocateInventoryOrderInput } from '../typings/find-allocate-inventory-order.input';
|
|
8
8
|
import { BatchService } from './batch.service';
|
|
9
9
|
import { StockService } from './stock.service';
|
|
10
|
+
import { WmsEntities } from '../models/wms-entities';
|
|
10
11
|
export declare class AllocateInventoryOrderService<T extends AllocateInventoryOrderEntityClass = AllocateInventoryOrderEntityClass, K extends AllocateInventoryOrderItemEntityClass = AllocateInventoryOrderItemEntityClass> {
|
|
11
12
|
private readonly dataSource;
|
|
13
|
+
private readonly entities;
|
|
12
14
|
private readonly helperService;
|
|
13
15
|
private readonly materialService;
|
|
14
16
|
private readonly batchService;
|
|
@@ -17,7 +19,7 @@ export declare class AllocateInventoryOrderService<T extends AllocateInventoryOr
|
|
|
17
19
|
readonly allocateInventoryOrderItemEntity: EntityTarget<K>;
|
|
18
20
|
readonly stockEntity: EntityTarget<StockEntityClass>;
|
|
19
21
|
private readonly seqPrefix;
|
|
20
|
-
constructor(dataSource: DataSource, helperService: HelperService, materialService: MaterialService, batchService: BatchService, stockService: StockService, allocateInventoryOrderEntity: EntityTarget<T>, allocateInventoryOrderItemEntity: EntityTarget<K>, stockEntity: EntityTarget<StockEntityClass>);
|
|
22
|
+
constructor(dataSource: DataSource, entities: WmsEntities, helperService: HelperService, materialService: MaterialService, batchService: BatchService, stockService: StockService, allocateInventoryOrderEntity: EntityTarget<T>, allocateInventoryOrderItemEntity: EntityTarget<K>, stockEntity: EntityTarget<StockEntityClass>);
|
|
21
23
|
private getRepositories;
|
|
22
24
|
private processAllocateInventoryOrderItems;
|
|
23
25
|
createAllocateInventoryOrder(options: CreateAllocateInventoryOrderInput, manager?: EntityManager): Promise<T>;
|
|
@@ -8,9 +8,11 @@ import '../models/metadata/loader-unit.entity.js';
|
|
|
8
8
|
import '../models/metadata/location.entity.js';
|
|
9
9
|
import '../models/metadata/material.entity.js';
|
|
10
10
|
import '../models/metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../models/metadata/sale-order.entity.js';
|
|
12
13
|
import { StockEntity } from '../models/metadata/stock.entity.js';
|
|
13
14
|
import '../models/metadata/unit.entity.js';
|
|
15
|
+
import { WmsEntities } from '../models/wms-entities.js';
|
|
14
16
|
import '../models/extensions/receive-inventory-order/receive-inventory-order-item.entity.js';
|
|
15
17
|
import '../models/extensions/receive-inventory-order/receive-inventory-order.entity.js';
|
|
16
18
|
import '../models/extensions/receive-inventory-order/receive-inventory-order-change.entity.js';
|
|
@@ -49,7 +51,6 @@ import '../models/extensions/scrape-order/scrape-order.entity.js';
|
|
|
49
51
|
import '../models/extensions/scrape-order/scrape-order-item.entity.js';
|
|
50
52
|
import '../models/extensions/scrape-order/scrape-order-change.entity.js';
|
|
51
53
|
import { DataSource, Not, IsNull } from 'typeorm';
|
|
52
|
-
import { OrderEntity } from '@rytass/wms-base-nestjs-module';
|
|
53
54
|
import { HelperService } from './helper.service.js';
|
|
54
55
|
import { MaterialService } from './material.service.js';
|
|
55
56
|
import { BatchService } from './batch.service.js';
|
|
@@ -57,6 +58,7 @@ import { StockService } from './stock.service.js';
|
|
|
57
58
|
|
|
58
59
|
let AllocateInventoryOrderService = class AllocateInventoryOrderService {
|
|
59
60
|
dataSource;
|
|
61
|
+
entities;
|
|
60
62
|
helperService;
|
|
61
63
|
materialService;
|
|
62
64
|
batchService;
|
|
@@ -65,8 +67,9 @@ let AllocateInventoryOrderService = class AllocateInventoryOrderService {
|
|
|
65
67
|
allocateInventoryOrderItemEntity;
|
|
66
68
|
stockEntity;
|
|
67
69
|
seqPrefix = 'AIO';
|
|
68
|
-
constructor(dataSource, helperService, materialService, batchService, stockService, allocateInventoryOrderEntity, allocateInventoryOrderItemEntity, stockEntity) {
|
|
70
|
+
constructor(dataSource, entities, helperService, materialService, batchService, stockService, allocateInventoryOrderEntity, allocateInventoryOrderItemEntity, stockEntity) {
|
|
69
71
|
this.dataSource = dataSource;
|
|
72
|
+
this.entities = entities;
|
|
70
73
|
this.helperService = helperService;
|
|
71
74
|
this.materialService = materialService;
|
|
72
75
|
this.batchService = batchService;
|
|
@@ -80,7 +83,7 @@ let AllocateInventoryOrderService = class AllocateInventoryOrderService {
|
|
|
80
83
|
allocateInventoryOrder: manager.getRepository(this.allocateInventoryOrderEntity),
|
|
81
84
|
allocateInventoryOrderItem: manager.getRepository(this.allocateInventoryOrderItemEntity),
|
|
82
85
|
allocateInventoryOrderChange: manager.getRepository(AllocateInventoryOrderChangeEntityClass),
|
|
83
|
-
order: manager.getRepository(
|
|
86
|
+
order: manager.getRepository(this.entities.order),
|
|
84
87
|
stock: manager.getRepository(this.stockEntity),
|
|
85
88
|
};
|
|
86
89
|
}
|
|
@@ -286,10 +289,11 @@ let AllocateInventoryOrderService = class AllocateInventoryOrderService {
|
|
|
286
289
|
};
|
|
287
290
|
AllocateInventoryOrderService = __decorate([
|
|
288
291
|
Injectable(),
|
|
289
|
-
__param(
|
|
290
|
-
__param(
|
|
291
|
-
__param(
|
|
292
|
+
__param(6, Inject(AllocateInventoryOrderEntity)),
|
|
293
|
+
__param(7, Inject(AllocateInventoryOrderItemEntity)),
|
|
294
|
+
__param(8, Inject(StockEntity)),
|
|
292
295
|
__metadata("design:paramtypes", [DataSource,
|
|
296
|
+
WmsEntities,
|
|
293
297
|
HelperService,
|
|
294
298
|
MaterialService,
|
|
295
299
|
BatchService,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate, __param, __metadata } from 'tslib';
|
|
2
2
|
import { Injectable, Inject } from '@nestjs/common';
|
|
3
3
|
import { DataSource, IsNull } from 'typeorm';
|
|
4
|
-
import { BatchEntity
|
|
4
|
+
import { BatchEntity } from '../models/metadata/batch.entity.js';
|
|
5
5
|
import { BatchGroupEntity } from '../models/metadata/batch-group.entity.js';
|
|
6
6
|
import '../models/metadata/loader.entity.js';
|
|
7
7
|
import '../models/metadata/loader-type.entity.js';
|
|
@@ -9,9 +9,11 @@ import '../models/metadata/loader-unit.entity.js';
|
|
|
9
9
|
import '../models/metadata/location.entity.js';
|
|
10
10
|
import '../models/metadata/material.entity.js';
|
|
11
11
|
import '../models/metadata/material-unit.entity.js';
|
|
12
|
+
import '@rytass/wms-base-nestjs-module';
|
|
12
13
|
import '../models/metadata/sale-order.entity.js';
|
|
13
14
|
import '../models/metadata/stock.entity.js';
|
|
14
15
|
import '../models/metadata/unit.entity.js';
|
|
16
|
+
import '../models/wms-entities.js';
|
|
15
17
|
import '../models/extensions/receive-inventory-order/receive-inventory-order-item.entity.js';
|
|
16
18
|
import '../models/extensions/receive-inventory-order/receive-inventory-order.entity.js';
|
|
17
19
|
import '../models/extensions/receive-inventory-order/receive-inventory-order-change.entity.js';
|
|
@@ -120,7 +122,7 @@ let BatchService = class BatchService {
|
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
async getBatch({ manager = this.dataSource.manager, ...options }) {
|
|
123
|
-
const batchRepository = manager.getRepository(
|
|
125
|
+
const batchRepository = manager.getRepository(this.batchEntity);
|
|
124
126
|
const batchGroupRepository = manager.getRepository(this.batchGroupEntity);
|
|
125
127
|
const unsplittedCondition = {
|
|
126
128
|
saleId: IsNull(),
|
|
@@ -150,7 +152,7 @@ let BatchService = class BatchService {
|
|
|
150
152
|
return batch;
|
|
151
153
|
}
|
|
152
154
|
async splitBatch({ manager = this.dataSource.manager, ...options }) {
|
|
153
|
-
const batchRepository = manager.getRepository(
|
|
155
|
+
const batchRepository = manager.getRepository(this.batchEntity);
|
|
154
156
|
const batch = await batchRepository.findOneOrFail({
|
|
155
157
|
where: { id: options.id },
|
|
156
158
|
relations: ['batchGroup'],
|
|
@@ -7,8 +7,10 @@ import { ReleaseInventoryOrderItemInput } from '../typings/release-inventory-ord
|
|
|
7
7
|
import { MaterialService } from './material.service';
|
|
8
8
|
import { BatchService } from './batch.service';
|
|
9
9
|
import { StockService } from './stock.service';
|
|
10
|
+
import { WmsEntities } from '../models/wms-entities';
|
|
10
11
|
export declare class HoldInventoryOrderService<T extends HoldInventoryOrderEntityClass = HoldInventoryOrderEntityClass, K extends HoldInventoryOrderItemEntityClass = HoldInventoryOrderItemEntityClass> {
|
|
11
12
|
private readonly dataSource;
|
|
13
|
+
private readonly entities;
|
|
12
14
|
private readonly helperService;
|
|
13
15
|
private readonly materialService;
|
|
14
16
|
private readonly batchService;
|
|
@@ -17,7 +19,7 @@ export declare class HoldInventoryOrderService<T extends HoldInventoryOrderEntit
|
|
|
17
19
|
readonly holdInventoryOrderItemEntity: EntityTarget<K>;
|
|
18
20
|
readonly stockEntity: EntityTarget<StockEntityClass>;
|
|
19
21
|
private readonly seqPrefix;
|
|
20
|
-
constructor(dataSource: DataSource, helperService: HelperService, materialService: MaterialService, batchService: BatchService, stockService: StockService, holdInventoryOrderEntity: EntityTarget<T>, holdInventoryOrderItemEntity: EntityTarget<K>, stockEntity: EntityTarget<StockEntityClass>);
|
|
22
|
+
constructor(dataSource: DataSource, entities: WmsEntities, helperService: HelperService, materialService: MaterialService, batchService: BatchService, stockService: StockService, holdInventoryOrderEntity: EntityTarget<T>, holdInventoryOrderItemEntity: EntityTarget<K>, stockEntity: EntityTarget<StockEntityClass>);
|
|
21
23
|
private getRepositories;
|
|
22
24
|
private processHoldInventoryOrderItems;
|
|
23
25
|
createHoldInventoryOrder(options: CreateHoldInventoryOrderInput, manager?: EntityManager): Promise<T>;
|