@rytass/wms-module-core 0.7.0 → 0.8.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/docs/integration-guide.md +21 -1
- package/index.cjs.js +28 -19
- package/lib/services/allocate-inventory-order.service.js +1 -1
- package/lib/services/batch.service.js +17 -8
- package/lib/services/receive-inventory-order.service.js +1 -1
- package/lib/services/ship-inventory-order.service.js +3 -3
- package/lib/services/transfer-customer-order.service.js +1 -1
- package/lib/services/transfer-order.service.js +4 -4
- package/lib/services/transfer-vendor-order.service.js +1 -1
- package/package.json +2 -2
|
@@ -348,13 +348,33 @@ combination the integration suite actually runs against.
|
|
|
348
348
|
|--------------------------|------------------------|--------------|-----------------------------------------------------------------------------|
|
|
349
349
|
| `@nestjs/common` | 10.x – 11.x | 11.1.x | **12.x is not accepted**: the whole NestJS 12 line is ESM-only, which this package (dual CJS+ESM) and a webpack-bundled host cannot consume yet |
|
|
350
350
|
| `@nestjs/typeorm` | 10.x – 11.x | 11.0.x | Three import sites (`InjectDataSource`, `forFeature`), stable across both |
|
|
351
|
-
| TypeORM | 0.3.x
|
|
351
|
+
| TypeORM | 0.3.x – 1.x | 1.1.1 | The suite is run against both 0.3.31 and 1.1.1. 0.2.x is not supported (different DataSource API). Note 0.3.x is now tagged `legacy` on npm |
|
|
352
|
+
| `@nestjs/typeorm` | 10.x – 11.x | 11.0.3 | **TypeORM 1.x needs `@nestjs/typeorm` >= 11.0.1** — earlier releases peer `^0.3.0` only |
|
|
352
353
|
| `reflect-metadata` | 0.1.13+ / 0.2.x | 0.1.x | Ambient requirement of the decorators |
|
|
353
354
|
| `rxjs` | not a peer | — | Never imported by this package; `@nestjs/common` peers it for you |
|
|
354
355
|
| `@rytass/wms-base-nestjs-module` | 0.4.x | 0.4.0 | **A peer since 0.7.0**, not a bundled dependency. It was pinned exactly under `dependencies`, which cannot prevent a second copy — it *causes* one as soon as you ask for any other 0.4.x. Two copies means two sets of entity classes and DI Symbols, the split-brain this package's Symbol discipline exists to avoid. Install it yourself so there is one |
|
|
355
356
|
| PostgreSQL | — | 14+ | Native dialect |
|
|
356
357
|
| Node.js | — | 20 LTS / 22 | 18 deprecated, 24 untested |
|
|
357
358
|
|
|
359
|
+
### Upgrading to TypeORM 1.x
|
|
360
|
+
|
|
361
|
+
Both majors are supported and both are exercised by the integration suite, so you can move
|
|
362
|
+
at your own pace. Two things changed upstream that are worth knowing before you do:
|
|
363
|
+
|
|
364
|
+
1. **`relations` no longer accepts an array.** `relations: ['items']` becomes
|
|
365
|
+
`relations: { items: true }`. The object form works in 0.3.x too, so it is safe to convert
|
|
366
|
+
before you upgrade.
|
|
367
|
+
2. **A bare `null` in a `where` is now an error**, not a silently-never-matching condition.
|
|
368
|
+
TypeORM 1.x raises `Null value encountered in property '…' of a where condition` and tells
|
|
369
|
+
you to use `IsNull()`. This is worth welcoming rather than working around: in 0.3.x such a
|
|
370
|
+
condition compiled to `= NULL`, which is never true in SQL, so the query quietly returned
|
|
371
|
+
nothing. Upgrading found exactly one such bug in this package — a batch-reuse lookup that
|
|
372
|
+
had been splitting duplicates instead of matching the batch already there.
|
|
373
|
+
|
|
374
|
+
If you have too many call sites to fix at once, TypeORM offers
|
|
375
|
+
`invalidWhereValuesBehavior.null` in the DataSource options as an escape hatch. Prefer
|
|
376
|
+
fixing them: each one is a query that was returning the wrong answer.
|
|
377
|
+
|
|
358
378
|
The GraphQL-side packages (`@nestjs/graphql`, `@nestjs/apollo`, `@apollo/server`,
|
|
359
379
|
`@as-integrations/express5`) are not peers of this package — see
|
|
360
380
|
[`@rytass/wms-module-graphql`](https://www.npmjs.com/package/@rytass/wms-module-graphql) §4.6.
|
package/index.cjs.js
CHANGED
|
@@ -3777,7 +3777,7 @@ exports.BatchService = class BatchService {
|
|
|
3777
3777
|
const batchRepository = manager.getRepository(this.batchEntity);
|
|
3778
3778
|
const batch = await batchRepository.findOneOrFail({
|
|
3779
3779
|
where: { id: options.id },
|
|
3780
|
-
relations:
|
|
3780
|
+
relations: { batchGroup: true },
|
|
3781
3781
|
});
|
|
3782
3782
|
// Validate state transition before proceeding
|
|
3783
3783
|
this.validateStateTransition(batch, options);
|
|
@@ -3787,15 +3787,24 @@ exports.BatchService = class BatchService {
|
|
|
3787
3787
|
...options,
|
|
3788
3788
|
groupId: batch.batchGroup.id,
|
|
3789
3789
|
};
|
|
3790
|
-
|
|
3790
|
+
/*
|
|
3791
|
+
* Absent attributes have to be matched with `IsNull()`, not with a bare
|
|
3792
|
+
* `null`. A `null` on the right of a find condition compiles to `= NULL`,
|
|
3793
|
+
* which is never true in SQL — so this lookup used to miss every batch whose
|
|
3794
|
+
* attributes were unset and split off a duplicate instead of reusing the one
|
|
3795
|
+
* already there. `getBatch` above has always done it this way; this call
|
|
3796
|
+
* site did not. TypeORM 1.x refuses a bare `null` here outright, which is
|
|
3797
|
+
* how the bug surfaced.
|
|
3798
|
+
*/
|
|
3799
|
+
const orNull = (value) => value === null || value === undefined ? typeorm.IsNull() : value;
|
|
3791
3800
|
const whereCondition = {
|
|
3792
3801
|
groupId: mergedBatch.groupId,
|
|
3793
|
-
saleId: mergedBatch.saleId
|
|
3794
|
-
saleSerialId: mergedBatch.saleSerialId
|
|
3795
|
-
customerId: mergedBatch.customerId
|
|
3796
|
-
vendorId: mergedBatch.vendorId
|
|
3797
|
-
inspectionResult: mergedBatch.inspectionResult
|
|
3798
|
-
transferId: mergedBatch.transferId
|
|
3802
|
+
saleId: orNull(mergedBatch.saleId),
|
|
3803
|
+
saleSerialId: orNull(mergedBatch.saleSerialId),
|
|
3804
|
+
customerId: orNull(mergedBatch.customerId),
|
|
3805
|
+
vendorId: orNull(mergedBatch.vendorId),
|
|
3806
|
+
inspectionResult: orNull(mergedBatch.inspectionResult),
|
|
3807
|
+
transferId: orNull(mergedBatch.transferId),
|
|
3799
3808
|
held: mergedBatch.held ?? false,
|
|
3800
3809
|
inShipment: mergedBatch.inShipment ?? false,
|
|
3801
3810
|
};
|
|
@@ -4115,7 +4124,7 @@ exports.ReceiveInventoryOrderService = class ReceiveInventoryOrderService {
|
|
|
4115
4124
|
const stockRepository = manager.getRepository(this.entities.stock);
|
|
4116
4125
|
const items = await itemRepository.find({
|
|
4117
4126
|
where: { id: typeorm.In(options.map((o) => o.itemId)) },
|
|
4118
|
-
relations:
|
|
4127
|
+
relations: { changes: true },
|
|
4119
4128
|
});
|
|
4120
4129
|
const itemMap = new Map(items.map((i) => [i.id, i]));
|
|
4121
4130
|
await Promise.all(options.map(async (option) => {
|
|
@@ -4478,7 +4487,7 @@ exports.ShipInventoryOrderService = class ShipInventoryOrderService {
|
|
|
4478
4487
|
// Find all items with changes to calculate cancellable quantities
|
|
4479
4488
|
const items = await itemRepository.find({
|
|
4480
4489
|
where: { orderId: id },
|
|
4481
|
-
relations:
|
|
4490
|
+
relations: { changes: true },
|
|
4482
4491
|
});
|
|
4483
4492
|
// Build cancel inputs for items with remaining prepared quantity
|
|
4484
4493
|
const cancelInputs = [];
|
|
@@ -4520,7 +4529,7 @@ exports.ShipInventoryOrderService = class ShipInventoryOrderService {
|
|
|
4520
4529
|
const stockRepository = manager.getRepository(this.entities.stock);
|
|
4521
4530
|
const items = await itemRepository.find({
|
|
4522
4531
|
where: { id: typeorm.In(options.map((o) => o.itemId)) },
|
|
4523
|
-
relations:
|
|
4532
|
+
relations: { changes: true },
|
|
4524
4533
|
});
|
|
4525
4534
|
const itemMap = new Map(items.map((item) => [item.id, item]));
|
|
4526
4535
|
await Promise.all(options.map(async (option) => {
|
|
@@ -4677,7 +4686,7 @@ exports.ShipInventoryOrderService = class ShipInventoryOrderService {
|
|
|
4677
4686
|
const stockRepository = manager.getRepository(this.entities.stock);
|
|
4678
4687
|
const items = await itemRepository.find({
|
|
4679
4688
|
where: { id: typeorm.In(options.map((option) => option.itemId)) },
|
|
4680
|
-
relations:
|
|
4689
|
+
relations: { changes: true },
|
|
4681
4690
|
});
|
|
4682
4691
|
const itemMap = new Map(items.map((item) => [item.id, item]));
|
|
4683
4692
|
await Promise.all(options.map(async (option) => {
|
|
@@ -4949,7 +4958,7 @@ exports.TransferOrderService = class TransferOrderService {
|
|
|
4949
4958
|
const repos = this.getRepositories(manager);
|
|
4950
4959
|
const items = await repos.transferOrderItem.find({
|
|
4951
4960
|
where: { id: typeorm.In(options.map((o) => o.itemId)) },
|
|
4952
|
-
relations:
|
|
4961
|
+
relations: { changes: true },
|
|
4953
4962
|
});
|
|
4954
4963
|
const itemMap = new Map(items.map((item) => [item.id, item]));
|
|
4955
4964
|
// Whole-loader transfer cancel validation (Phase 2d-sync).
|
|
@@ -5048,7 +5057,7 @@ exports.TransferOrderService = class TransferOrderService {
|
|
|
5048
5057
|
// Find all items with changes to calculate cancellable quantities
|
|
5049
5058
|
const items = await repos.transferOrderItem.find({
|
|
5050
5059
|
where: { orderId: id },
|
|
5051
|
-
relations:
|
|
5060
|
+
relations: { changes: true },
|
|
5052
5061
|
});
|
|
5053
5062
|
// Build cancel inputs for items with remaining pending quantity
|
|
5054
5063
|
const cancelInputs = [];
|
|
@@ -5257,7 +5266,7 @@ exports.TransferOrderService = class TransferOrderService {
|
|
|
5257
5266
|
const stockRepository = manager.getRepository(this.stockEntity);
|
|
5258
5267
|
const items = await itemRepository.find({
|
|
5259
5268
|
where: { id: typeorm.In(options.map((o) => o.itemId)) },
|
|
5260
|
-
relations:
|
|
5269
|
+
relations: { changes: true },
|
|
5261
5270
|
});
|
|
5262
5271
|
const itemMap = new Map(items.map((item) => [item.id, item]));
|
|
5263
5272
|
const inputMap = new Map(options.map((o) => [o.itemId, o]));
|
|
@@ -5283,7 +5292,7 @@ exports.TransferOrderService = class TransferOrderService {
|
|
|
5283
5292
|
if (orderId) {
|
|
5284
5293
|
const allOrderItems = await itemRepository.find({
|
|
5285
5294
|
where: { orderId },
|
|
5286
|
-
relations:
|
|
5295
|
+
relations: { changes: true },
|
|
5287
5296
|
});
|
|
5288
5297
|
for (const orderItem of allOrderItems) {
|
|
5289
5298
|
if (orderItem.removedAt)
|
|
@@ -5764,7 +5773,7 @@ exports.AllocateInventoryOrderService = class AllocateInventoryOrderService {
|
|
|
5764
5773
|
if (items?.length) {
|
|
5765
5774
|
const existingItemIds = new Set((await repos.allocateInventoryOrderItem.find({
|
|
5766
5775
|
where: { orderId: id },
|
|
5767
|
-
relations:
|
|
5776
|
+
relations: { changes: true },
|
|
5768
5777
|
})).map((item) => item.id));
|
|
5769
5778
|
const newItems = [];
|
|
5770
5779
|
const existingItems = [];
|
|
@@ -6384,7 +6393,7 @@ exports.TransferVendorOrderService = class TransferVendorOrderService {
|
|
|
6384
6393
|
if (items?.length) {
|
|
6385
6394
|
const existingItemIds = new Set((await repos.transferVendorOrderItem.find({
|
|
6386
6395
|
where: { orderId: id },
|
|
6387
|
-
relations:
|
|
6396
|
+
relations: { changes: true },
|
|
6388
6397
|
})).map((item) => item.id));
|
|
6389
6398
|
const newItems = [];
|
|
6390
6399
|
const existingItems = [];
|
|
@@ -6689,7 +6698,7 @@ exports.TransferCustomerOrderService = class TransferCustomerOrderService {
|
|
|
6689
6698
|
if (items?.length) {
|
|
6690
6699
|
const existingItemIds = new Set((await repos.transferCustomerOrderItem.find({
|
|
6691
6700
|
where: { orderId: id },
|
|
6692
|
-
relations:
|
|
6701
|
+
relations: { changes: true },
|
|
6693
6702
|
})).map((item) => item.id));
|
|
6694
6703
|
const newItems = [];
|
|
6695
6704
|
const existingItems = [];
|
|
@@ -170,7 +170,7 @@ let AllocateInventoryOrderService = class AllocateInventoryOrderService {
|
|
|
170
170
|
if (items?.length) {
|
|
171
171
|
const existingItemIds = new Set((await repos.allocateInventoryOrderItem.find({
|
|
172
172
|
where: { orderId: id },
|
|
173
|
-
relations:
|
|
173
|
+
relations: { changes: true },
|
|
174
174
|
})).map((item) => item.id));
|
|
175
175
|
const newItems = [];
|
|
176
176
|
const existingItems = [];
|
|
@@ -158,7 +158,7 @@ let BatchService = class BatchService {
|
|
|
158
158
|
const batchRepository = manager.getRepository(this.batchEntity);
|
|
159
159
|
const batch = await batchRepository.findOneOrFail({
|
|
160
160
|
where: { id: options.id },
|
|
161
|
-
relations:
|
|
161
|
+
relations: { batchGroup: true },
|
|
162
162
|
});
|
|
163
163
|
// Validate state transition before proceeding
|
|
164
164
|
this.validateStateTransition(batch, options);
|
|
@@ -168,15 +168,24 @@ let BatchService = class BatchService {
|
|
|
168
168
|
...options,
|
|
169
169
|
groupId: batch.batchGroup.id,
|
|
170
170
|
};
|
|
171
|
-
|
|
171
|
+
/*
|
|
172
|
+
* Absent attributes have to be matched with `IsNull()`, not with a bare
|
|
173
|
+
* `null`. A `null` on the right of a find condition compiles to `= NULL`,
|
|
174
|
+
* which is never true in SQL — so this lookup used to miss every batch whose
|
|
175
|
+
* attributes were unset and split off a duplicate instead of reusing the one
|
|
176
|
+
* already there. `getBatch` above has always done it this way; this call
|
|
177
|
+
* site did not. TypeORM 1.x refuses a bare `null` here outright, which is
|
|
178
|
+
* how the bug surfaced.
|
|
179
|
+
*/
|
|
180
|
+
const orNull = (value) => value === null || value === undefined ? IsNull() : value;
|
|
172
181
|
const whereCondition = {
|
|
173
182
|
groupId: mergedBatch.groupId,
|
|
174
|
-
saleId: mergedBatch.saleId
|
|
175
|
-
saleSerialId: mergedBatch.saleSerialId
|
|
176
|
-
customerId: mergedBatch.customerId
|
|
177
|
-
vendorId: mergedBatch.vendorId
|
|
178
|
-
inspectionResult: mergedBatch.inspectionResult
|
|
179
|
-
transferId: mergedBatch.transferId
|
|
183
|
+
saleId: orNull(mergedBatch.saleId),
|
|
184
|
+
saleSerialId: orNull(mergedBatch.saleSerialId),
|
|
185
|
+
customerId: orNull(mergedBatch.customerId),
|
|
186
|
+
vendorId: orNull(mergedBatch.vendorId),
|
|
187
|
+
inspectionResult: orNull(mergedBatch.inspectionResult),
|
|
188
|
+
transferId: orNull(mergedBatch.transferId),
|
|
180
189
|
held: mergedBatch.held ?? false,
|
|
181
190
|
inShipment: mergedBatch.inShipment ?? false,
|
|
182
191
|
};
|
|
@@ -314,7 +314,7 @@ let ReceiveInventoryOrderService = class ReceiveInventoryOrderService {
|
|
|
314
314
|
const stockRepository = manager.getRepository(this.entities.stock);
|
|
315
315
|
const items = await itemRepository.find({
|
|
316
316
|
where: { id: In(options.map((o) => o.itemId)) },
|
|
317
|
-
relations:
|
|
317
|
+
relations: { changes: true },
|
|
318
318
|
});
|
|
319
319
|
const itemMap = new Map(items.map((i) => [i.id, i]));
|
|
320
320
|
await Promise.all(options.map(async (option) => {
|
|
@@ -325,7 +325,7 @@ let ShipInventoryOrderService = class ShipInventoryOrderService {
|
|
|
325
325
|
// Find all items with changes to calculate cancellable quantities
|
|
326
326
|
const items = await itemRepository.find({
|
|
327
327
|
where: { orderId: id },
|
|
328
|
-
relations:
|
|
328
|
+
relations: { changes: true },
|
|
329
329
|
});
|
|
330
330
|
// Build cancel inputs for items with remaining prepared quantity
|
|
331
331
|
const cancelInputs = [];
|
|
@@ -367,7 +367,7 @@ let ShipInventoryOrderService = class ShipInventoryOrderService {
|
|
|
367
367
|
const stockRepository = manager.getRepository(this.entities.stock);
|
|
368
368
|
const items = await itemRepository.find({
|
|
369
369
|
where: { id: In(options.map((o) => o.itemId)) },
|
|
370
|
-
relations:
|
|
370
|
+
relations: { changes: true },
|
|
371
371
|
});
|
|
372
372
|
const itemMap = new Map(items.map((item) => [item.id, item]));
|
|
373
373
|
await Promise.all(options.map(async (option) => {
|
|
@@ -524,7 +524,7 @@ let ShipInventoryOrderService = class ShipInventoryOrderService {
|
|
|
524
524
|
const stockRepository = manager.getRepository(this.entities.stock);
|
|
525
525
|
const items = await itemRepository.find({
|
|
526
526
|
where: { id: In(options.map((option) => option.itemId)) },
|
|
527
|
-
relations:
|
|
527
|
+
relations: { changes: true },
|
|
528
528
|
});
|
|
529
529
|
const itemMap = new Map(items.map((item) => [item.id, item]));
|
|
530
530
|
await Promise.all(options.map(async (option) => {
|
|
@@ -174,7 +174,7 @@ let TransferCustomerOrderService = class TransferCustomerOrderService {
|
|
|
174
174
|
if (items?.length) {
|
|
175
175
|
const existingItemIds = new Set((await repos.transferCustomerOrderItem.find({
|
|
176
176
|
where: { orderId: id },
|
|
177
|
-
relations:
|
|
177
|
+
relations: { changes: true },
|
|
178
178
|
})).map((item) => item.id));
|
|
179
179
|
const newItems = [];
|
|
180
180
|
const existingItems = [];
|
|
@@ -162,7 +162,7 @@ let TransferOrderService = class TransferOrderService {
|
|
|
162
162
|
const repos = this.getRepositories(manager);
|
|
163
163
|
const items = await repos.transferOrderItem.find({
|
|
164
164
|
where: { id: In(options.map((o) => o.itemId)) },
|
|
165
|
-
relations:
|
|
165
|
+
relations: { changes: true },
|
|
166
166
|
});
|
|
167
167
|
const itemMap = new Map(items.map((item) => [item.id, item]));
|
|
168
168
|
// Whole-loader transfer cancel validation (Phase 2d-sync).
|
|
@@ -261,7 +261,7 @@ let TransferOrderService = class TransferOrderService {
|
|
|
261
261
|
// Find all items with changes to calculate cancellable quantities
|
|
262
262
|
const items = await repos.transferOrderItem.find({
|
|
263
263
|
where: { orderId: id },
|
|
264
|
-
relations:
|
|
264
|
+
relations: { changes: true },
|
|
265
265
|
});
|
|
266
266
|
// Build cancel inputs for items with remaining pending quantity
|
|
267
267
|
const cancelInputs = [];
|
|
@@ -470,7 +470,7 @@ let TransferOrderService = class TransferOrderService {
|
|
|
470
470
|
const stockRepository = manager.getRepository(this.stockEntity);
|
|
471
471
|
const items = await itemRepository.find({
|
|
472
472
|
where: { id: In(options.map((o) => o.itemId)) },
|
|
473
|
-
relations:
|
|
473
|
+
relations: { changes: true },
|
|
474
474
|
});
|
|
475
475
|
const itemMap = new Map(items.map((item) => [item.id, item]));
|
|
476
476
|
const inputMap = new Map(options.map((o) => [o.itemId, o]));
|
|
@@ -496,7 +496,7 @@ let TransferOrderService = class TransferOrderService {
|
|
|
496
496
|
if (orderId) {
|
|
497
497
|
const allOrderItems = await itemRepository.find({
|
|
498
498
|
where: { orderId },
|
|
499
|
-
relations:
|
|
499
|
+
relations: { changes: true },
|
|
500
500
|
});
|
|
501
501
|
for (const orderItem of allOrderItems) {
|
|
502
502
|
if (orderItem.removedAt)
|
|
@@ -174,7 +174,7 @@ let TransferVendorOrderService = class TransferVendorOrderService {
|
|
|
174
174
|
if (items?.length) {
|
|
175
175
|
const existingItemIds = new Set((await repos.transferVendorOrderItem.find({
|
|
176
176
|
where: { orderId: id },
|
|
177
|
-
relations:
|
|
177
|
+
relations: { changes: true },
|
|
178
178
|
})).map((item) => item.id));
|
|
179
179
|
const newItems = [];
|
|
180
180
|
const existingItems = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rytass/wms-module-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Rytass WMS Module — NestJS services and TypeORM entities for warehouse management",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rytass",
|
|
@@ -48,6 +48,6 @@
|
|
|
48
48
|
"@nestjs/typeorm": "^10.0.0 || ^11.0.0",
|
|
49
49
|
"@rytass/wms-base-nestjs-module": "^0.4.0",
|
|
50
50
|
"reflect-metadata": "^0.1.13 || ^0.2.0",
|
|
51
|
-
"typeorm": "^0.3.0"
|
|
51
|
+
"typeorm": "^0.3.0 || ^1.0.0"
|
|
52
52
|
}
|
|
53
53
|
}
|