@rytass/wms-module-graphql 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.
@@ -1,5 +1,4 @@
1
1
  import { __decorate, __param, __metadata } from 'tslib';
2
- import { Inject } from '@nestjs/common';
3
2
  import { ResolveField, Parent, Context, Resolver } from '@nestjs/graphql';
4
3
  import '../dto/loader-type.dto.js';
5
4
  import '../dto/loader.dto.js';
@@ -25,37 +24,37 @@ import '../dto/scrape-order.dto.js';
25
24
  import '../dto/scrape-order-item.dto.js';
26
25
  import '../dto/quality-inspection-order.dto.js';
27
26
  import '../dto/quality-inspection-order-item.dto.js';
28
- import { StockEntityClass, MaterialEntity, LocationEntityClass, BatchEntityClass, BatchGroupEntityClass } from '@rytass/wms-module-core';
27
+ import { StockEntityClass, WmsEntities, BatchGroupEntityClass } from '@rytass/wms-module-core';
29
28
  import { LocationDto } from '../dto/location.dto.js';
30
29
  import { BatchDto } from '../dto/batch.dto.js';
31
30
 
32
31
  let StockResolver = class StockResolver {
33
- materialEntity;
32
+ entities;
34
33
  /**
35
- * Bound to the `MaterialEntity` Symbol, so the DataLoader queries whichever
36
- * material entity the consumer configured — the built-in `MaterialEntityClass`
37
- * unless `materialEntity` was passed to `forRoot`/`forRootAsync`. Loading the
38
- * built-in class outright would filter on its single-table-inheritance
39
- * discriminator and resolve nothing for a custom entity.
34
+ * The configured entities, not the built-in classes: `__entity` decides which
35
+ * repository the DataLoader opens, so it has to follow whatever the consumer
36
+ * passed to `WMSBaseModuleOptions`. Loading a built-in class outright filters
37
+ * on its single-table-inheritance discriminator and resolves nothing for an
38
+ * override.
40
39
  */
41
- constructor(materialEntity) {
42
- this.materialEntity = materialEntity;
40
+ constructor(entities) {
41
+ this.entities = entities;
43
42
  }
44
43
  material({ materialId }, { loaders }) {
45
44
  return loaders.batchSingle.load({
46
- __entity: this.materialEntity,
45
+ __entity: this.entities.material,
47
46
  __from: { id: materialId },
48
47
  });
49
48
  }
50
49
  location({ locationId }, { loaders }) {
51
50
  return loaders.batchSingle.load({
52
- __entity: LocationEntityClass,
51
+ __entity: this.entities.location,
53
52
  __from: { id: locationId },
54
53
  });
55
54
  }
56
55
  async batch({ batchId }, { loaders }) {
57
56
  const { groupId } = await loaders.batchSingle.load({
58
- __entity: BatchEntityClass,
57
+ __entity: this.entities.batch,
59
58
  __from: { id: batchId },
60
59
  });
61
60
  return loaders.batchSingle.load({
@@ -90,8 +89,7 @@ __decorate([
90
89
  ], StockResolver.prototype, "batch", null);
91
90
  StockResolver = __decorate([
92
91
  Resolver(() => StockDto),
93
- __param(0, Inject(MaterialEntity)),
94
- __metadata("design:paramtypes", [Function])
92
+ __metadata("design:paramtypes", [WmsEntities])
95
93
  ], StockResolver);
96
94
 
97
95
  export { StockResolver };
@@ -1,25 +1,34 @@
1
1
  import { TransferOrderDto } from '../dto/transfer-order.dto';
2
2
  import { TransferOrderItemDto } from '../dto/transfer-order-item.dto';
3
3
  import { type LoaderType } from '../helpers';
4
- import { BatchEntityClass, LoadersEntityClass, LocationEntityClass, MaterialEntityClass, TransferOrderChangeEntityClass, TransferOrderItemEntityClass } from '@rytass/wms-module-core';
4
+ import { BatchEntityClass, LoadersEntityClass, LocationEntityClass, MaterialEntityClass, TransferOrderChangeEntityClass, TransferOrderItemEntityClass, WmsEntities } from '@rytass/wms-module-core';
5
5
  import { LoaderDto, MaterialDto } from '../dto';
6
6
  import { BatchDto } from '../dto/batch.dto';
7
7
  import { LocationDto } from '../dto/location.dto';
8
8
  export declare class TransferOrderResolver {
9
+ private readonly entities;
10
+ /**
11
+ * The configured entities, not the built-in classes: `__entity` decides which
12
+ * repository the DataLoader opens, so it has to follow whatever the consumer
13
+ * passed to `WMSBaseModuleOptions`. Loading a built-in class outright filters
14
+ * on its single-table-inheritance discriminator and resolves nothing for an
15
+ * override.
16
+ */
17
+ constructor(entities: WmsEntities);
9
18
  items({ id }: TransferOrderDto, { loaders }: LoaderType<TransferOrderItemEntityClass>): Promise<TransferOrderItemDto[]>;
10
19
  targetLocation({ id }: TransferOrderDto, { loaders }: LoaderType<TransferOrderItemEntityClass>, locationLoader: LoaderType<LocationEntityClass>): Promise<LocationDto | null>;
11
20
  targetLoader({ id }: TransferOrderDto, { loaders }: LoaderType<TransferOrderItemEntityClass>, loaderLoader: LoaderType<LoadersEntityClass>): Promise<LoaderDto | null>;
12
21
  }
13
22
  export declare class TransferOrderItemResolver {
14
- private readonly materialEntity;
23
+ private readonly entities;
15
24
  /**
16
- * Bound to the `MaterialEntity` Symbol, so the DataLoader queries whichever
17
- * material entity the consumer configured — the built-in `MaterialEntityClass`
18
- * unless `materialEntity` was passed to `forRoot`/`forRootAsync`. Loading the
19
- * built-in class outright would filter on its single-table-inheritance
20
- * discriminator and resolve nothing for a custom entity.
25
+ * The configured entities, not the built-in classes: `__entity` decides which
26
+ * repository the DataLoader opens, so it has to follow whatever the consumer
27
+ * passed to `WMSBaseModuleOptions`. Loading a built-in class outright filters
28
+ * on its single-table-inheritance discriminator and resolves nothing for an
29
+ * override.
21
30
  */
22
- constructor(materialEntity: new () => MaterialEntityClass);
31
+ constructor(entities: WmsEntities);
23
32
  material({ materialId }: TransferOrderItemEntityClass, { loaders }: LoaderType<MaterialEntityClass>): Promise<MaterialDto>;
24
33
  batch({ batchId }: TransferOrderItemEntityClass, { loaders }: LoaderType<BatchEntityClass>): Promise<BatchDto | null>;
25
34
  location({ locationId }: TransferOrderItemEntityClass, { loaders }: LoaderType<LocationEntityClass>): Promise<LocationDto | null>;
@@ -1,9 +1,8 @@
1
1
  import { __decorate, __param, __metadata } from 'tslib';
2
- import { Inject } from '@nestjs/common';
3
2
  import { ResolveField, Parent, Context, Resolver, ID, Int } from '@nestjs/graphql';
4
3
  import { TransferOrderDto } from '../dto/transfer-order.dto.js';
5
4
  import { TransferOrderItemDto } from '../dto/transfer-order-item.dto.js';
6
- import { TransferOrderItemEntityClass, MaterialEntity, LocationEntityClass, LoadersEntityClass, BatchEntityClass, BatchGroupEntityClass, TransferOrderChangeEntityClass } from '@rytass/wms-module-core';
5
+ import { WmsEntities, TransferOrderItemEntityClass, LoadersEntityClass, BatchGroupEntityClass, TransferOrderChangeEntityClass } from '@rytass/wms-module-core';
7
6
  import '../dto/loader-type.dto.js';
8
7
  import { LoaderDto } from '../dto/loader.dto.js';
9
8
  import { MaterialDto } from '../dto/material.dto.js';
@@ -30,6 +29,17 @@ import { BatchDto } from '../dto/batch.dto.js';
30
29
  import { LocationDto } from '../dto/location.dto.js';
31
30
 
32
31
  let TransferOrderResolver = class TransferOrderResolver {
32
+ entities;
33
+ /**
34
+ * The configured entities, not the built-in classes: `__entity` decides which
35
+ * repository the DataLoader opens, so it has to follow whatever the consumer
36
+ * passed to `WMSBaseModuleOptions`. Loading a built-in class outright filters
37
+ * on its single-table-inheritance discriminator and resolves nothing for an
38
+ * override.
39
+ */
40
+ constructor(entities) {
41
+ this.entities = entities;
42
+ }
33
43
  items({ id }, { loaders }) {
34
44
  return loaders.batchMany.load({
35
45
  __entity: TransferOrderItemEntityClass,
@@ -44,7 +54,7 @@ let TransferOrderResolver = class TransferOrderResolver {
44
54
  if (!item?.targetLocationId)
45
55
  return null;
46
56
  return locationLoader.loaders.batchSingle.load({
47
- __entity: LocationEntityClass,
57
+ __entity: this.entities.location,
48
58
  __from: { id: item.targetLocationId },
49
59
  });
50
60
  }
@@ -88,23 +98,24 @@ __decorate([
88
98
  __metadata("design:returntype", Promise)
89
99
  ], TransferOrderResolver.prototype, "targetLoader", null);
90
100
  TransferOrderResolver = __decorate([
91
- Resolver(() => TransferOrderDto)
101
+ Resolver(() => TransferOrderDto),
102
+ __metadata("design:paramtypes", [WmsEntities])
92
103
  ], TransferOrderResolver);
93
104
  let TransferOrderItemResolver = class TransferOrderItemResolver {
94
- materialEntity;
105
+ entities;
95
106
  /**
96
- * Bound to the `MaterialEntity` Symbol, so the DataLoader queries whichever
97
- * material entity the consumer configured — the built-in `MaterialEntityClass`
98
- * unless `materialEntity` was passed to `forRoot`/`forRootAsync`. Loading the
99
- * built-in class outright would filter on its single-table-inheritance
100
- * discriminator and resolve nothing for a custom entity.
107
+ * The configured entities, not the built-in classes: `__entity` decides which
108
+ * repository the DataLoader opens, so it has to follow whatever the consumer
109
+ * passed to `WMSBaseModuleOptions`. Loading a built-in class outright filters
110
+ * on its single-table-inheritance discriminator and resolves nothing for an
111
+ * override.
101
112
  */
102
- constructor(materialEntity) {
103
- this.materialEntity = materialEntity;
113
+ constructor(entities) {
114
+ this.entities = entities;
104
115
  }
105
116
  material({ materialId }, { loaders }) {
106
117
  return loaders.batchSingle.load({
107
- __entity: this.materialEntity,
118
+ __entity: this.entities.material,
108
119
  __from: { id: materialId },
109
120
  });
110
121
  }
@@ -112,7 +123,7 @@ let TransferOrderItemResolver = class TransferOrderItemResolver {
112
123
  if (!batchId)
113
124
  return null;
114
125
  const { groupId } = await loaders.batchSingle.load({
115
- __entity: BatchEntityClass,
126
+ __entity: this.entities.batch,
116
127
  __from: { id: batchId },
117
128
  });
118
129
  return loaders.batchSingle.load({
@@ -124,7 +135,7 @@ let TransferOrderItemResolver = class TransferOrderItemResolver {
124
135
  if (!locationId)
125
136
  return null;
126
137
  return loaders.batchSingle.load({
127
- __entity: LocationEntityClass,
138
+ __entity: this.entities.location,
128
139
  __from: { id: locationId },
129
140
  });
130
141
  }
@@ -141,7 +152,7 @@ let TransferOrderItemResolver = class TransferOrderItemResolver {
141
152
  return null;
142
153
  return loaders.batchSingle
143
154
  .load({
144
- __entity: BatchEntityClass,
155
+ __entity: this.entities.batch,
145
156
  __from: { id: batchId },
146
157
  })
147
158
  .then((batch) => batch.saleId);
@@ -151,7 +162,7 @@ let TransferOrderItemResolver = class TransferOrderItemResolver {
151
162
  return null;
152
163
  return loaders.batchSingle
153
164
  .load({
154
- __entity: BatchEntityClass,
165
+ __entity: this.entities.batch,
155
166
  __from: { id: batchId },
156
167
  })
157
168
  .then((batch) => batch.saleSerialId);
@@ -225,8 +236,7 @@ __decorate([
225
236
  ], TransferOrderItemResolver.prototype, "transferredQuantity", null);
226
237
  TransferOrderItemResolver = __decorate([
227
238
  Resolver(() => TransferOrderItemDto),
228
- __param(0, Inject(MaterialEntity)),
229
- __metadata("design:paramtypes", [Function])
239
+ __metadata("design:paramtypes", [WmsEntities])
230
240
  ], TransferOrderItemResolver);
231
241
 
232
242
  export { TransferOrderItemResolver, TransferOrderResolver };
@@ -1,6 +1,15 @@
1
1
  import { type LoaderType } from '../helpers';
2
- import { LocationEntityClass } from '@rytass/wms-module-core';
2
+ import { LocationEntityClass, WmsEntities } from '@rytass/wms-module-core';
3
3
  import { MapRangeDto } from '../dto/warehouse-map.dto';
4
4
  export declare class MapRangeUnionResolver {
5
+ private readonly entities;
6
+ /**
7
+ * The configured entities, not the built-in classes: `__entity` decides which
8
+ * repository the DataLoader opens, so it has to follow whatever the consumer
9
+ * passed to `WMSBaseModuleOptions`. Loading a built-in class outright filters
10
+ * on its single-table-inheritance discriminator and resolves nothing for an
11
+ * override.
12
+ */
13
+ constructor(entities: WmsEntities);
5
14
  location({ id }: MapRangeDto, { loaders }: LoaderType<LocationEntityClass>): Promise<LocationEntityClass> | null;
6
15
  }
@@ -1,15 +1,26 @@
1
1
  import { __decorate, __param, __metadata } from 'tslib';
2
2
  import { ResolveField, Parent, Context, Resolver } from '@nestjs/graphql';
3
3
  import { LocationDto } from '../dto/location.dto.js';
4
- import { LocationEntityClass } from '@rytass/wms-module-core';
4
+ import { WmsEntities } from '@rytass/wms-module-core';
5
5
  import { MapRangeDto } from '../dto/warehouse-map.dto.js';
6
6
 
7
7
  let MapRangeUnionResolver = class MapRangeUnionResolver {
8
+ entities;
9
+ /**
10
+ * The configured entities, not the built-in classes: `__entity` decides which
11
+ * repository the DataLoader opens, so it has to follow whatever the consumer
12
+ * passed to `WMSBaseModuleOptions`. Loading a built-in class outright filters
13
+ * on its single-table-inheritance discriminator and resolves nothing for an
14
+ * override.
15
+ */
16
+ constructor(entities) {
17
+ this.entities = entities;
18
+ }
8
19
  location({ id }, { loaders }) {
9
20
  if (!id)
10
21
  return null;
11
22
  return loaders.batchSingle.load({
12
- __entity: LocationEntityClass,
23
+ __entity: this.entities.location,
13
24
  __from: { key: id },
14
25
  });
15
26
  }
@@ -23,7 +34,8 @@ __decorate([
23
34
  __metadata("design:returntype", void 0)
24
35
  ], MapRangeUnionResolver.prototype, "location", null);
25
36
  MapRangeUnionResolver = __decorate([
26
- Resolver(() => MapRangeDto)
37
+ Resolver(() => MapRangeDto),
38
+ __metadata("design:paramtypes", [WmsEntities])
27
39
  ], MapRangeUnionResolver);
28
40
 
29
41
  export { MapRangeUnionResolver };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rytass/wms-module-graphql",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Rytass WMS Module — GraphQL schema, resolvers and DTOs for warehouse management",
5
5
  "keywords": [
6
6
  "rytass",
@@ -57,7 +57,7 @@
57
57
  "@nestjs/apollo": ">=13.0.0 <13.2.0",
58
58
  "@nestjs/common": "^11.0.0",
59
59
  "@nestjs/graphql": "^13.0.0",
60
- "@rytass/wms-module-core": "^0.4.0",
60
+ "@rytass/wms-module-core": "^0.5.0",
61
61
  "graphql": "^16.0.0",
62
62
  "reflect-metadata": "^0.1.13 || ^0.2.0",
63
63
  "rxjs": "^7.8.0",