@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/README.md
CHANGED
|
@@ -71,11 +71,15 @@ Exported services include `LoaderService`, `MaterialService`, `BatchService`, `S
|
|
|
71
71
|
|
|
72
72
|
Each entity is exported in two forms — `MaterialEntity` (a `Symbol` DI token) and `MaterialEntityClass` (the entity class the token is bound to). Everything inside the module resolves entities through the token, so rebinding the token swaps the entity everywhere at once.
|
|
73
73
|
|
|
74
|
-
`materialEntity`
|
|
74
|
+
All six entity options `WMSBaseModuleOptions` exposes — `materialEntity`, `batchEntity`, `locationEntity`, `stockEntity`, `orderEntity`, `warehouseMapEntity` — are wired all the way through. Give one a `@ChildEntity()` of the class it replaces and your own table *is* the WMS table — no second table, no double writes:
|
|
75
75
|
|
|
76
76
|
```ts
|
|
77
77
|
import { ChildEntity, Column } from 'typeorm';
|
|
78
|
-
import {
|
|
78
|
+
import {
|
|
79
|
+
BatchEntityClass,
|
|
80
|
+
MaterialEntityClass,
|
|
81
|
+
WmsModuleCoreModule,
|
|
82
|
+
} from '@rytass/wms-module-core';
|
|
79
83
|
|
|
80
84
|
@ChildEntity()
|
|
81
85
|
export class ItemMasterEntity extends MaterialEntityClass {
|
|
@@ -83,19 +87,35 @@ export class ItemMasterEntity extends MaterialEntityClass {
|
|
|
83
87
|
erpCode!: string | null;
|
|
84
88
|
}
|
|
85
89
|
|
|
90
|
+
@ChildEntity()
|
|
91
|
+
export class LotEntity extends BatchEntityClass {
|
|
92
|
+
@Column({ type: 'date', nullable: true })
|
|
93
|
+
expiresOn!: Date | null;
|
|
94
|
+
}
|
|
95
|
+
|
|
86
96
|
WmsModuleCoreModule.forRootAsync({
|
|
87
|
-
useFactory: async () => ({
|
|
97
|
+
useFactory: async () => ({
|
|
98
|
+
materialEntity: ItemMasterEntity,
|
|
99
|
+
batchEntity: LotEntity,
|
|
100
|
+
}),
|
|
88
101
|
defaultLoaderSerialId: 'DEFAULT',
|
|
89
102
|
defaultLoaderTypeKey: 'DEFAULT',
|
|
90
103
|
defaultLocationKey: 'DEFAULT',
|
|
91
104
|
});
|
|
92
105
|
```
|
|
93
106
|
|
|
94
|
-
|
|
107
|
+
They are ordinary `WMSBaseModuleOptions` fields, so `forRoot` and the async factory both work, and you can override as few or as many as you like. The base module resolves its repositories from them and this package binds its entity Symbols from the same `PROVIDE_*_ENTITY` tokens at injection time — one option, two consumers, no way for them to drift. Needs `@rytass/wms-base-nestjs-module` >= 0.4.0.
|
|
108
|
+
|
|
109
|
+
`WmsEntities` is exported for consumers who need the resolved classes themselves:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
constructor(private readonly entities: WmsEntities) {}
|
|
113
|
+
// this.entities.material / .batch / .location / .stock / .order / .warehouseMap
|
|
114
|
+
```
|
|
95
115
|
|
|
96
|
-
**You register the
|
|
116
|
+
**You register the entities with TypeORM yourself** (`TypeOrmModule.forFeature([...])`, or the DataSource's `entities`). The module cannot: `forFeature()` runs while Nest assembles the module graph, before the options resolve. Forgetting almost works — TypeORM still creates your columns in the parent table — so the module checks at startup and refuses to boot with a message naming what to add.
|
|
97
117
|
|
|
98
|
-
|
|
118
|
+
[`docs/custom-entities.md`](./docs/custom-entities.md) has the full picture, including what single-table inheritance means for rows written before the override existed.
|
|
99
119
|
|
|
100
120
|
## Module options token
|
|
101
121
|
|
package/docs/api-reference.md
CHANGED
|
@@ -38,28 +38,44 @@ static forRootAsync(
|
|
|
38
38
|
): DynamicModule
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
**Entity override(since 0.
|
|
41
|
+
**Entity override(since 0.5.0,需 `@rytass/wms-base-nestjs-module` >= 0.4.0)**
|
|
42
42
|
|
|
43
|
-
`WMSBaseModuleOptions
|
|
43
|
+
`WMSBaseModuleOptions` 的六個 entity 選項現在會一路作用到 core 與 graphql。每個都必須是它所取代的 class 的 `@ChildEntity()`:
|
|
44
|
+
|
|
45
|
+
| 選項 | 資料表 | 取代 |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `materialEntity` | `materials` | `MaterialEntityClass` |
|
|
48
|
+
| `batchEntity` | `batches` | `BatchEntityClass` |
|
|
49
|
+
| `locationEntity` | `locations` | `LocationEntityClass` |
|
|
50
|
+
| `stockEntity` | `stocks` | `StockEntityClass` |
|
|
51
|
+
| `orderEntity` | `orders` | `OrderEntityClass` |
|
|
52
|
+
| `warehouseMapEntity` | `warehouse_maps` | `WarehouseMapEntity`(基座) |
|
|
44
53
|
|
|
45
54
|
```ts
|
|
46
55
|
WmsModuleCoreModule.forRootAsync({
|
|
47
|
-
useFactory: async () => ({
|
|
56
|
+
useFactory: async () => ({
|
|
57
|
+
materialEntity: ItemMasterEntity,
|
|
58
|
+
batchEntity: LotEntity,
|
|
59
|
+
}),
|
|
48
60
|
defaultLoaderSerialId: 'DEFAULT',
|
|
49
61
|
defaultLoaderTypeKey: 'DEFAULT',
|
|
50
62
|
defaultLocationKey: 'DEFAULT',
|
|
51
63
|
});
|
|
52
64
|
```
|
|
53
65
|
|
|
54
|
-
- `forRoot` 與 async factory
|
|
55
|
-
- 基座的 `
|
|
56
|
-
- **entity 需自行註冊給 TypeORM**(`TypeOrmModule.forFeature([
|
|
57
|
-
-
|
|
58
|
-
-
|
|
66
|
+
- `forRoot` 與 async factory 皆可,因為各 Symbol 是在 **DI 時**由基座 export 的 `PROVIDE_*_ENTITY` 綁定,不是在 module graph 組裝時。
|
|
67
|
+
- 基座的 `RESOLVED_*_REPO` 與 core 的 Symbol 由**同一個 option** 推導,結構上不可能不一致。
|
|
68
|
+
- **entity 需自行註冊給 TypeORM**(`TypeOrmModule.forFeature([...])` 或 DataSource `entities`);模組無法代勞,漏掉時會在啟動階段列出缺哪幾個。
|
|
69
|
+
- 未繼承正確 class 者會在啟動時被拒絕(TypeScript 結構型別擋不住兄弟類別)。
|
|
70
|
+
- 可只覆寫其中幾個,其餘沿用內建 class。詳見 [`custom-entities.md`](./custom-entities.md)。
|
|
71
|
+
|
|
72
|
+
### `WmsEntities`
|
|
73
|
+
- 用途: 套用覆寫後**實際**被讀寫的 entity class 集合。`material` / `batch` / `location` / `stock` / `order` / `warehouseMap` 六個唯讀屬性。消費端需要同一份答案時可直接注入。建構時會驗證每個 entity 都已註冊給 TypeORM。
|
|
74
|
+
- 來源: `lib/models/wms-entities.ts`
|
|
59
75
|
|
|
60
76
|
### `ModelsModule`
|
|
61
77
|
- 用途: 內部模組,向 TypeORM 註冊所有 WMS 實體(via DI token 形式),並透過 `ResolvedEntitiesProviders` 提供 DI。**消費端不直接 import**;它由 `WmsModuleCoreModule.forRoot` 自動引入並 re-export。
|
|
62
|
-
-
|
|
78
|
+
- 六個可覆寫的 Symbol **不由此模組綁定**:它們在 `WmsModuleCoreModule` 內由對應的 `PROVIDE_*_ENTITY` 推導,避免同一個 token 出現兩個繫結。內建 class 仍註冊進 `forFeature()`(它們是各自單表繼承的根)。
|
|
63
79
|
- 來源: `lib/models/models.module.ts`
|
|
64
80
|
|
|
65
81
|
---
|
|
@@ -72,6 +88,7 @@ WmsModuleCoreModule.forRootAsync({
|
|
|
72
88
|
|---|---|---|---|
|
|
73
89
|
| `UnitEntity` | `UnitEntityClass` | 單位主檔(kg / pcs 等) | `lib/models/metadata/unit.entity.ts` |
|
|
74
90
|
| `MaterialEntity` | `MaterialEntityClass` | 料號主檔,繼承 `BaseMaterialEntity` | `lib/models/metadata/material.entity.ts` |
|
|
91
|
+
| `OrderEntity` | `OrderEntityClass` | 訂單基底(本套件未加欄位,`OrderEntityClass` 即基座 class) | `lib/models/metadata/order.entity.ts` |
|
|
75
92
|
| `MaterialUnitEntity` | `MaterialUnitEntityClass` | 料號換算單位(含換算係數) | `lib/models/metadata/material-unit.entity.ts` |
|
|
76
93
|
| `BatchEntity` | `BatchEntityClass` | 批號主檔,繼承 `BaseBatchEntity` | `lib/models/metadata/batch.entity.ts` |
|
|
77
94
|
| `BatchGroupEntity` | `BatchGroupEntityClass` | 批號群組,支援多批合併情境 | `lib/models/metadata/batch-group.entity.ts` |
|
package/docs/custom-entities.md
CHANGED
|
@@ -4,11 +4,8 @@ How to make a downstream project's own table the WMS's table, instead of keeping
|
|
|
4
4
|
a second one in sync.
|
|
5
5
|
|
|
6
6
|
> Applies to `@rytass/wms-module-core` and `@rytass/wms-module-graphql`.
|
|
7
|
-
>
|
|
8
|
-
>
|
|
9
|
-
>
|
|
10
|
-
> Requires `@rytass/wms-base-nestjs-module` >= 0.3.0, which is the release that
|
|
11
|
-
> exports the resolved entity tokens this depends on.
|
|
7
|
+
> All six entities `WMSBaseModuleOptions` exposes are supported. Requires
|
|
8
|
+
> `@rytass/wms-base-nestjs-module` >= 0.4.0.
|
|
12
9
|
|
|
13
10
|
## Table of Contents
|
|
14
11
|
|
|
@@ -17,67 +14,103 @@ a second one in sync.
|
|
|
17
14
|
3. [Passing it to the module](#3-passing-it-to-the-module)
|
|
18
15
|
4. [Registering the entity with TypeORM](#4-registering-the-entity-with-typeorm)
|
|
19
16
|
5. [What single-table inheritance means for your data](#5-what-single-table-inheritance-means-for-your-data)
|
|
20
|
-
6. [
|
|
17
|
+
6. [Overriding more than one](#6-overriding-more-than-one)
|
|
21
18
|
|
|
22
19
|
---
|
|
23
20
|
|
|
24
21
|
## 1. What the option does
|
|
25
22
|
|
|
26
|
-
`@rytass/wms-base-nestjs-module` has always accepted
|
|
27
|
-
`WMSBaseModuleOptions`, but it kept the resolved
|
|
28
|
-
never exported, so `@rytass/wms-module-core` could not read
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
`wms-base` 0.3.0 exports `
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
materials
|
|
39
|
-
|
|
40
|
-
|
|
|
41
|
-
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
23
|
+
`@rytass/wms-base-nestjs-module` has always accepted entity overrides in
|
|
24
|
+
`WMSBaseModuleOptions`, but it kept the resolved entities to itself: the tokens
|
|
25
|
+
were never exported, so `@rytass/wms-module-core` could not read them and bound
|
|
26
|
+
its own entity Symbols to the built-in classes unconditionally. The options
|
|
27
|
+
therefore changed nothing above the base layer.
|
|
28
|
+
|
|
29
|
+
`wms-base` 0.3.0 exports `PROVIDE_*_ENTITY` and `RESOLVED_*_REPO` (the same
|
|
30
|
+
shape `@rytass/member-base-nestjs-module` has always used for `memberEntity`),
|
|
31
|
+
and the core module binds its Symbols from those tokens at injection time.
|
|
32
|
+
|
|
33
|
+
| Option | Table | Replaces | Also reached by |
|
|
34
|
+
|----------------------|------------------|------------------------|------------------------------------------------------------|
|
|
35
|
+
| `materialEntity` | `materials` | `MaterialEntityClass` | `MaterialService`, receive / ship / reclassify, stock filters |
|
|
36
|
+
| `batchEntity` | `batches` | `BatchEntityClass` | `BatchService`, split / merge / reclassify |
|
|
37
|
+
| `locationEntity` | `locations` | `LocationEntityClass` | `LocationService`, receive, transfers, startup seeding |
|
|
38
|
+
| `stockEntity` | `stocks` | `StockEntityClass` | `StockService` and every path that moves stock |
|
|
39
|
+
| `orderEntity` | `orders` | `OrderEntityClass` | every order service — one row per stock movement |
|
|
40
|
+
| `warehouseMapEntity` | `warehouse_maps` | `WarehouseMapEntity` | `WarehouseMapDataService` and the map mutation |
|
|
41
|
+
|
|
42
|
+
Nothing in either package imports these classes as values any more. Every
|
|
43
|
+
service, DataLoader and query reaches them through a `Symbol`, so rebinding one
|
|
44
|
+
swaps that entity everywhere at once — including the GraphQL DataLoaders, which
|
|
45
|
+
would otherwise resolve `null` for an override and fail their non-nullable
|
|
46
|
+
fields.
|
|
47
|
+
|
|
48
|
+
`WmsEntities` is the injectable holding the resolved classes, exported for
|
|
49
|
+
consumers who need the same answer:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { WmsEntities } from '@rytass/wms-module-core';
|
|
53
|
+
|
|
54
|
+
@Injectable()
|
|
55
|
+
export class MyService {
|
|
56
|
+
constructor(private readonly entities: WmsEntities) {}
|
|
57
|
+
|
|
58
|
+
find(): Promise<unknown[]> {
|
|
59
|
+
return this.dataSource.getRepository(this.entities.material).find();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
50
63
|
|
|
51
64
|
## 2. Writing the entity
|
|
52
65
|
|
|
53
|
-
|
|
54
|
-
It joins the existing
|
|
55
|
-
|
|
66
|
+
Each override must be a TypeORM `@ChildEntity()` extending the class it replaces.
|
|
67
|
+
It joins the existing table through single-table inheritance; it does not move
|
|
68
|
+
the data anywhere.
|
|
56
69
|
|
|
57
70
|
```ts
|
|
58
71
|
import { ChildEntity, Column, Index } from 'typeorm';
|
|
59
|
-
import {
|
|
72
|
+
import {
|
|
73
|
+
BatchEntityClass,
|
|
74
|
+
LocationEntityClass,
|
|
75
|
+
MaterialEntityClass,
|
|
76
|
+
} from '@rytass/wms-module-core';
|
|
60
77
|
|
|
61
78
|
@ChildEntity()
|
|
62
79
|
export class ItemMasterEntity extends MaterialEntityClass {
|
|
63
80
|
@Column({ type: 'varchar', nullable: true })
|
|
64
81
|
@Index()
|
|
65
82
|
erpCode!: string | null;
|
|
83
|
+
}
|
|
66
84
|
|
|
85
|
+
@ChildEntity()
|
|
86
|
+
export class LotEntity extends BatchEntityClass {
|
|
87
|
+
@Column({ type: 'date', nullable: true })
|
|
88
|
+
expiresOn!: Date | null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@ChildEntity()
|
|
92
|
+
export class BinEntity extends LocationEntityClass {
|
|
67
93
|
@Column({ type: 'varchar', nullable: true })
|
|
68
|
-
|
|
94
|
+
zone!: string | null;
|
|
69
95
|
}
|
|
70
96
|
```
|
|
71
97
|
|
|
72
98
|
Rules:
|
|
73
99
|
|
|
74
|
-
- **Extend
|
|
75
|
-
|
|
76
|
-
|
|
100
|
+
- **Extend the class this package exports, not the base one.** `MaterialEntityClass`,
|
|
101
|
+
`BatchEntityClass`, `LocationEntityClass` and `StockEntityClass` add the columns
|
|
102
|
+
the services and DTOs read; the base classes do not declare them. `OrderEntityClass`
|
|
103
|
+
and the warehouse map entity are the base classes — this package adds nothing to
|
|
104
|
+
those two — and are re-exported so every override reads the same way.
|
|
77
105
|
- **New columns must be nullable or have a default.** Rows written before the
|
|
78
106
|
override existed carry the old discriminator and have no value for them.
|
|
79
107
|
- **Do not re-declare `@Entity()` or `@TableInheritance()`.** Both belong to the
|
|
80
|
-
|
|
108
|
+
class you are extending; `@ChildEntity()` is the whole decoration you need. The
|
|
109
|
+
same goes for `@Tree()` on a location override — inherit it, do not repeat it.
|
|
110
|
+
- The module refuses to boot if an override does not extend the right class.
|
|
111
|
+
`WMSBaseModuleOptions` only asks for a child of the *base* entity, and
|
|
112
|
+
TypeScript's structural typing will happily accept a sibling that never
|
|
113
|
+
declares the columns this package reads.
|
|
81
114
|
|
|
82
115
|
## 3. Passing it to the module
|
|
83
116
|
|
|
@@ -93,6 +126,8 @@ WmsModuleGraphqlModule.forRootAsync({
|
|
|
93
126
|
useFactory: async (vault: VaultService) => ({
|
|
94
127
|
allowNegativeStock: await vault.get<boolean>('ALLOW_NEGATIVE_STOCK'),
|
|
95
128
|
materialEntity: ItemMasterEntity,
|
|
129
|
+
batchEntity: LotEntity,
|
|
130
|
+
locationEntity: BinEntity,
|
|
96
131
|
}),
|
|
97
132
|
|
|
98
133
|
defaultLoaderSerialId: 'DEFAULT',
|
|
@@ -101,11 +136,14 @@ WmsModuleGraphqlModule.forRootAsync({
|
|
|
101
136
|
});
|
|
102
137
|
```
|
|
103
138
|
|
|
139
|
+
Override as few or as many as you like; anything left out keeps its built-in
|
|
140
|
+
class.
|
|
141
|
+
|
|
104
142
|
### `forRoot`
|
|
105
143
|
|
|
106
144
|
```ts
|
|
107
145
|
WmsModuleCoreModule.forRoot(
|
|
108
|
-
{ materialEntity: ItemMasterEntity },
|
|
146
|
+
{ materialEntity: ItemMasterEntity, batchEntity: LotEntity },
|
|
109
147
|
{
|
|
110
148
|
defaultLoaderSerialId: 'DEFAULT',
|
|
111
149
|
defaultLoaderTypeKey: 'DEFAULT',
|
|
@@ -118,8 +156,8 @@ You pass it once. The base module resolves its repository from it and the core
|
|
|
118
156
|
module binds its `MaterialEntity` Symbol from it; both read the same option, so
|
|
119
157
|
there is no forwarding step that could get them out of step.
|
|
120
158
|
|
|
121
|
-
If
|
|
122
|
-
`WMSBaseModuleOptions` only asks for a child of the *base*
|
|
159
|
+
If a class does not extend the one it replaces, the module refuses to boot —
|
|
160
|
+
`WMSBaseModuleOptions` only asks for a child of the *base* entity, and
|
|
123
161
|
TypeScript's structural typing will not catch a sibling that happens to look
|
|
124
162
|
right.
|
|
125
163
|
|
|
@@ -133,7 +171,7 @@ options resolve.
|
|
|
133
171
|
@Module({
|
|
134
172
|
imports: [
|
|
135
173
|
TypeOrmModule.forRoot({ /* ... */ autoLoadEntities: true }),
|
|
136
|
-
TypeOrmModule.forFeature([ItemMasterEntity]),
|
|
174
|
+
TypeOrmModule.forFeature([ItemMasterEntity, LotEntity, BinEntity]),
|
|
137
175
|
WmsModuleGraphqlModule.forRootAsync({ /* ... */ }),
|
|
138
176
|
],
|
|
139
177
|
})
|
|
@@ -149,10 +187,10 @@ module checks for it at startup and refuses to boot rather than letting an
|
|
|
149
187
|
`EntityMetadataNotFoundError` surface later from inside a resolver:
|
|
150
188
|
|
|
151
189
|
```
|
|
152
|
-
WmsModuleCoreModule:
|
|
153
|
-
|
|
154
|
-
TypeOrmModule.forFeature([ItemMasterEntity
|
|
155
|
-
autoLoadEntities.
|
|
190
|
+
WmsModuleCoreModule: configured entities are not registered with TypeORM
|
|
191
|
+
(materialEntity: ItemMasterEntity, batchEntity: LotEntity). Add them to your
|
|
192
|
+
DataSource "entities", or import TypeOrmModule.forFeature([ItemMasterEntity,
|
|
193
|
+
LotEntity]) somewhere in your app when using autoLoadEntities.
|
|
156
194
|
```
|
|
157
195
|
|
|
158
196
|
## 5. What single-table inheritance means for your data
|
|
@@ -169,24 +207,23 @@ class wrote each one.
|
|
|
169
207
|
- Reading through `MaterialEntityClass` still returns your rows, because your
|
|
170
208
|
class is a descendant of it. The asymmetry only bites in the other direction.
|
|
171
209
|
|
|
172
|
-
## 6.
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
only one with no core Symbol at all.
|
|
210
|
+
## 6. Overriding more than one
|
|
211
|
+
|
|
212
|
+
The overrides are independent — take one, take all six, mix and match. They are
|
|
213
|
+
resolved from the same options object and validated together at startup, so a
|
|
214
|
+
partial configuration is a normal state rather than a special case.
|
|
215
|
+
|
|
216
|
+
One caveat worth knowing when overriding `warehouseMapEntity`: its table gained
|
|
217
|
+
its `entityName` discriminator column in `wms-base` 0.4.0, and it is **nullable**
|
|
218
|
+
precisely so existing rows survive the upgrade. A single-table root is queried
|
|
219
|
+
without a discriminator filter, so rows written before the upgrade stay readable
|
|
220
|
+
through the built-in class. They are *not* visible to an override, for the same
|
|
221
|
+
reason described in section 5 — backfill them if you need them:
|
|
222
|
+
|
|
223
|
+
```sql
|
|
224
|
+
UPDATE warehouse_maps SET "entityName" = 'YourMapEntity' WHERE "entityName" IS NULL;
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
The other five tables have carried a discriminator since long before this
|
|
228
|
+
feature, so only `warehouse_maps` needs the column added. If you run migrations
|
|
229
|
+
rather than `synchronize`, generate one for it.
|