@rytass/wms-module-graphql 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +1009 -98
- package/lib/dto/consumption-order-item.dto.d.ts +17 -0
- package/lib/dto/consumption-order-item.dto.js +43 -0
- package/lib/dto/consumption-order.dto.d.ts +14 -0
- package/lib/dto/consumption-order.dto.js +52 -0
- package/lib/dto/index.d.ts +3 -0
- package/lib/dto/inventory-count-order.dto.d.ts +7 -1
- package/lib/dto/inventory-count-order.dto.js +11 -1
- package/lib/dto/order-reference.dto.d.ts +22 -0
- package/lib/dto/order-reference.dto.js +73 -0
- package/lib/dto/stock.dto.d.ts +15 -0
- package/lib/dto/stock.dto.js +28 -0
- package/lib/events/operation-result-map.d.ts +13 -0
- package/lib/events/typed-maps.d.ts +17 -7
- package/lib/events/wms-mutation.interceptor.d.ts +11 -9
- package/lib/events/wms-mutation.interceptor.js +19 -45
- package/lib/graphql.module.d.ts +1 -1
- package/lib/graphql.module.js +30 -13
- package/lib/inputs/consumption-order.args.d.ts +47 -0
- package/lib/inputs/consumption-order.args.js +182 -0
- package/lib/inputs/find-stock.args.d.ts +6 -0
- package/lib/inputs/find-stock.args.js +10 -0
- package/lib/inputs/order-reference.args.d.ts +32 -0
- package/lib/inputs/order-reference.args.js +103 -0
- package/lib/inputs/split-batch.args.d.ts +6 -0
- package/lib/inputs/split-batch.args.js +11 -0
- package/lib/mutations/consumption-order.mutation.d.ts +18 -0
- package/lib/mutations/consumption-order.mutation.js +90 -0
- package/lib/mutations/loader.mutation.js +3 -0
- package/lib/mutations/material.mutation.js +3 -0
- package/lib/mutations/order-reference.mutation.d.ts +13 -0
- package/lib/mutations/order-reference.mutation.js +57 -0
- package/lib/mutations/receive-inventory-order.mutation.js +3 -0
- package/lib/mutations/ship-inventory-order.mutation.js +3 -0
- package/lib/queries/consumption-order.query.d.ts +9 -0
- package/lib/queries/consumption-order.query.js +45 -0
- package/lib/queries/loader.query.js +3 -0
- package/lib/queries/material.query.js +3 -0
- package/lib/queries/order-reference.query.d.ts +8 -0
- package/lib/queries/order-reference.query.js +34 -0
- package/lib/queries/recieve-inventory-order.query.js +3 -0
- package/lib/queries/ship-inventory-order.query.js +3 -0
- package/lib/queries/stock.query.js +3 -0
- package/lib/resolvers/aggregated-stock.resolver.js +3 -0
- package/lib/resolvers/change-log.resolver.js +3 -0
- package/lib/resolvers/consumption-order.resolver.d.ts +40 -0
- package/lib/resolvers/consumption-order.resolver.js +238 -0
- package/lib/resolvers/loader-type.resolver.js +3 -0
- package/lib/resolvers/loader.resolver.js +3 -0
- package/lib/resolvers/material.resolver.js +3 -0
- package/lib/resolvers/receive-inventory-order.resolver.js +3 -0
- package/lib/resolvers/ship-inventory-order.resolver.js +3 -0
- package/lib/resolvers/stock.resolver.js +3 -0
- package/lib/resolvers/transfer-order.resolver.js +3 -0
- package/lib/scalars/index.d.ts +1 -0
- package/lib/scalars/json-object.scalar.d.ts +2 -0
- package/lib/scalars/json-object.scalar.js +62 -0
- package/package.json +2 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConsumptionOrderService } from '@rytass/wms-module-core';
|
|
2
|
+
import { ConsumptionOrderDto, ConsumptionOrders } from '../dto/consumption-order.dto';
|
|
3
|
+
import { FindConsumptionOrderArgs } from '../inputs/consumption-order.args';
|
|
4
|
+
export declare class ConsumptionOrderQuery {
|
|
5
|
+
private readonly consumptionOrderService;
|
|
6
|
+
constructor(consumptionOrderService: ConsumptionOrderService);
|
|
7
|
+
consumptionOrder(id: string): Promise<ConsumptionOrderDto>;
|
|
8
|
+
consumptionOrders(args: FindConsumptionOrderArgs): Promise<ConsumptionOrders>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { __decorate, __param, __metadata } from 'tslib';
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
|
+
import { Query, Args, ID, Resolver } from '@nestjs/graphql';
|
|
4
|
+
import { ConsumptionOrderService } from '@rytass/wms-module-core';
|
|
5
|
+
import { ConsumptionOrderDto, ConsumptionOrders } from '../dto/consumption-order.dto.js';
|
|
6
|
+
import { FindConsumptionOrderArgs } from '../inputs/consumption-order.args.js';
|
|
7
|
+
import '../auth/wms-auth.guard.js';
|
|
8
|
+
import { WmsOperation } from '../auth/wms-operation.decorator.js';
|
|
9
|
+
|
|
10
|
+
let ConsumptionOrderQuery = class ConsumptionOrderQuery {
|
|
11
|
+
consumptionOrderService;
|
|
12
|
+
constructor(consumptionOrderService) {
|
|
13
|
+
this.consumptionOrderService = consumptionOrderService;
|
|
14
|
+
}
|
|
15
|
+
consumptionOrder(id) {
|
|
16
|
+
return this.consumptionOrderService.findOne(id);
|
|
17
|
+
}
|
|
18
|
+
async consumptionOrders(args) {
|
|
19
|
+
const [items, total] = await this.consumptionOrderService.findMany(args);
|
|
20
|
+
return { items, total };
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
__decorate([
|
|
24
|
+
Query(() => ConsumptionOrderDto),
|
|
25
|
+
WmsOperation({ resource: 'consumption-order', action: 'read' }),
|
|
26
|
+
__param(0, Args('id', { type: () => ID })),
|
|
27
|
+
__metadata("design:type", Function),
|
|
28
|
+
__metadata("design:paramtypes", [String]),
|
|
29
|
+
__metadata("design:returntype", Promise)
|
|
30
|
+
], ConsumptionOrderQuery.prototype, "consumptionOrder", null);
|
|
31
|
+
__decorate([
|
|
32
|
+
Query(() => ConsumptionOrders),
|
|
33
|
+
WmsOperation({ resource: 'consumption-order', action: 'read' }),
|
|
34
|
+
__param(0, Args()),
|
|
35
|
+
__metadata("design:type", Function),
|
|
36
|
+
__metadata("design:paramtypes", [FindConsumptionOrderArgs]),
|
|
37
|
+
__metadata("design:returntype", Promise)
|
|
38
|
+
], ConsumptionOrderQuery.prototype, "consumptionOrders", null);
|
|
39
|
+
ConsumptionOrderQuery = __decorate([
|
|
40
|
+
Injectable(),
|
|
41
|
+
Resolver(),
|
|
42
|
+
__metadata("design:paramtypes", [ConsumptionOrderService])
|
|
43
|
+
], ConsumptionOrderQuery);
|
|
44
|
+
|
|
45
|
+
export { ConsumptionOrderQuery };
|
|
@@ -27,6 +27,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
27
27
|
import '../dto/quality-inspection-order.dto.js';
|
|
28
28
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
29
29
|
import '../dto/inventory-count-order.dto.js';
|
|
30
|
+
import '../dto/consumption-order.dto.js';
|
|
31
|
+
import '../dto/consumption-order-item.dto.js';
|
|
32
|
+
import '../dto/order-reference.dto.js';
|
|
30
33
|
import { FindLoaderArgs } from '../inputs/find-loader.args.js';
|
|
31
34
|
import { FindLoaderTypeArgs } from '../inputs/find-loader-type.args.js';
|
|
32
35
|
import { LoaderUnitDto, LoaderUnit } from '../dto/loader-unit.dto.js';
|
|
@@ -26,6 +26,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
26
26
|
import '../dto/quality-inspection-order.dto.js';
|
|
27
27
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
28
28
|
import '../dto/inventory-count-order.dto.js';
|
|
29
|
+
import '../dto/consumption-order.dto.js';
|
|
30
|
+
import '../dto/consumption-order-item.dto.js';
|
|
31
|
+
import '../dto/order-reference.dto.js';
|
|
29
32
|
import { MaterialService } from '@rytass/wms-module-core';
|
|
30
33
|
import { FindMaterialArgs } from '../inputs/find-material.args.js';
|
|
31
34
|
import '../auth/wms-auth.guard.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OrderReferenceService } from '@rytass/wms-module-core';
|
|
2
|
+
import { OrderReferences } from '../dto/order-reference.dto';
|
|
3
|
+
import { FindOrderReferenceArgs } from '../inputs/order-reference.args';
|
|
4
|
+
export declare class OrderReferenceQuery {
|
|
5
|
+
private readonly orderReferenceService;
|
|
6
|
+
constructor(orderReferenceService: OrderReferenceService);
|
|
7
|
+
orderReferences(args: FindOrderReferenceArgs): Promise<OrderReferences>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __decorate, __param, __metadata } from 'tslib';
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
|
+
import { Query, Args, Resolver } from '@nestjs/graphql';
|
|
4
|
+
import { OrderReferenceService } from '@rytass/wms-module-core';
|
|
5
|
+
import { OrderReferences } from '../dto/order-reference.dto.js';
|
|
6
|
+
import { FindOrderReferenceArgs } from '../inputs/order-reference.args.js';
|
|
7
|
+
import '../auth/wms-auth.guard.js';
|
|
8
|
+
import { WmsOperation } from '../auth/wms-operation.decorator.js';
|
|
9
|
+
|
|
10
|
+
let OrderReferenceQuery = class OrderReferenceQuery {
|
|
11
|
+
orderReferenceService;
|
|
12
|
+
constructor(orderReferenceService) {
|
|
13
|
+
this.orderReferenceService = orderReferenceService;
|
|
14
|
+
}
|
|
15
|
+
async orderReferences(args) {
|
|
16
|
+
const [items, total] = await this.orderReferenceService.findMany(args);
|
|
17
|
+
return { items, total };
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
__decorate([
|
|
21
|
+
Query(() => OrderReferences),
|
|
22
|
+
WmsOperation({ resource: 'order-reference', action: 'read' }),
|
|
23
|
+
__param(0, Args()),
|
|
24
|
+
__metadata("design:type", Function),
|
|
25
|
+
__metadata("design:paramtypes", [FindOrderReferenceArgs]),
|
|
26
|
+
__metadata("design:returntype", Promise)
|
|
27
|
+
], OrderReferenceQuery.prototype, "orderReferences", null);
|
|
28
|
+
OrderReferenceQuery = __decorate([
|
|
29
|
+
Injectable(),
|
|
30
|
+
Resolver(),
|
|
31
|
+
__metadata("design:paramtypes", [OrderReferenceService])
|
|
32
|
+
], OrderReferenceQuery);
|
|
33
|
+
|
|
34
|
+
export { OrderReferenceQuery };
|
|
@@ -27,6 +27,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
27
27
|
import '../dto/quality-inspection-order.dto.js';
|
|
28
28
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
29
29
|
import '../dto/inventory-count-order.dto.js';
|
|
30
|
+
import '../dto/consumption-order.dto.js';
|
|
31
|
+
import '../dto/consumption-order-item.dto.js';
|
|
32
|
+
import '../dto/order-reference.dto.js';
|
|
30
33
|
import { FindReceiveInventoryOrderArgs } from '../inputs/find-receive-inventory-order.args.js';
|
|
31
34
|
import '../auth/wms-auth.guard.js';
|
|
32
35
|
import { WmsOperation } from '../auth/wms-operation.decorator.js';
|
|
@@ -27,6 +27,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
27
27
|
import '../dto/quality-inspection-order.dto.js';
|
|
28
28
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
29
29
|
import '../dto/inventory-count-order.dto.js';
|
|
30
|
+
import '../dto/consumption-order.dto.js';
|
|
31
|
+
import '../dto/consumption-order-item.dto.js';
|
|
32
|
+
import '../dto/order-reference.dto.js';
|
|
30
33
|
import { FindShipInventoryOrderArgs } from '../inputs/find-ship-inventory-order.args.js';
|
|
31
34
|
import '../auth/wms-auth.guard.js';
|
|
32
35
|
import { WmsOperation } from '../auth/wms-operation.decorator.js';
|
|
@@ -27,6 +27,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
27
27
|
import '../dto/quality-inspection-order.dto.js';
|
|
28
28
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
29
29
|
import '../dto/inventory-count-order.dto.js';
|
|
30
|
+
import '../dto/consumption-order.dto.js';
|
|
31
|
+
import '../dto/consumption-order-item.dto.js';
|
|
32
|
+
import '../dto/order-reference.dto.js';
|
|
30
33
|
import { FindStockArgs } from '../inputs/find-stock.args.js';
|
|
31
34
|
import '../auth/wms-auth.guard.js';
|
|
32
35
|
import { WmsOperation } from '../auth/wms-operation.decorator.js';
|
|
@@ -25,6 +25,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
25
25
|
import '../dto/quality-inspection-order.dto.js';
|
|
26
26
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
27
27
|
import '../dto/inventory-count-order.dto.js';
|
|
28
|
+
import '../dto/consumption-order.dto.js';
|
|
29
|
+
import '../dto/consumption-order-item.dto.js';
|
|
30
|
+
import '../dto/order-reference.dto.js';
|
|
28
31
|
import { StockService, WmsEntities, BatchGroupEntityClass, LoadersEntityClass } from '@rytass/wms-module-core';
|
|
29
32
|
import { BatchDto } from '../dto/batch.dto.js';
|
|
30
33
|
import { LocationDto } from '../dto/location.dto.js';
|
|
@@ -25,6 +25,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
25
25
|
import '../dto/quality-inspection-order.dto.js';
|
|
26
26
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
27
27
|
import '../dto/inventory-count-order.dto.js';
|
|
28
|
+
import '../dto/consumption-order.dto.js';
|
|
29
|
+
import '../dto/consumption-order-item.dto.js';
|
|
30
|
+
import '../dto/order-reference.dto.js';
|
|
28
31
|
import { StockEntityClass, WmsEntities, BatchGroupEntityClass } from '@rytass/wms-module-core';
|
|
29
32
|
import { LocationDto } from '../dto/location.dto.js';
|
|
30
33
|
import { BatchDto } from '../dto/batch.dto.js';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BatchEntityClass, ConsumptionOrderChangeEntityClass, ConsumptionOrderItemEntityClass, LoadersEntityClass, LocationEntityClass, MaterialEntityClass, WmsEntities } from '@rytass/wms-module-core';
|
|
2
|
+
import { ConsumptionOrderDto } from '../dto/consumption-order.dto';
|
|
3
|
+
import { ConsumptionOrderItemDto } from '../dto/consumption-order-item.dto';
|
|
4
|
+
import { LoaderDto, MaterialDto } from '../dto';
|
|
5
|
+
import { BatchDto } from '../dto/batch.dto';
|
|
6
|
+
import { LocationDto } from '../dto/location.dto';
|
|
7
|
+
import { type LoaderType } from '../helpers';
|
|
8
|
+
export declare class ConsumptionOrderResolver {
|
|
9
|
+
items({ id }: ConsumptionOrderDto, { loaders }: LoaderType<ConsumptionOrderItemEntityClass>): Promise<ConsumptionOrderItemDto[]>;
|
|
10
|
+
}
|
|
11
|
+
export declare class ConsumptionOrderItemResolver {
|
|
12
|
+
private readonly entities;
|
|
13
|
+
/**
|
|
14
|
+
* The configured entities, not the built-in classes: `__entity` decides which
|
|
15
|
+
* repository the DataLoader opens, so it has to follow whatever the consumer
|
|
16
|
+
* passed to `WMSBaseModuleOptions`. Loading a built-in class outright filters
|
|
17
|
+
* on its single-table-inheritance discriminator and resolves nothing for an
|
|
18
|
+
* override.
|
|
19
|
+
*/
|
|
20
|
+
constructor(entities: WmsEntities);
|
|
21
|
+
/**
|
|
22
|
+
* How much this line has moved, by kind.
|
|
23
|
+
*
|
|
24
|
+
* Read back from the changes rather than denormalised onto the item: the
|
|
25
|
+
* changes are what the stock ledger and the `stock.*` events agree with, and a
|
|
26
|
+
* counter maintained alongside them is a second answer waiting to disagree.
|
|
27
|
+
*/
|
|
28
|
+
private movedQuantity;
|
|
29
|
+
material({ materialId }: ConsumptionOrderItemEntityClass, { loaders }: LoaderType<MaterialEntityClass>): Promise<MaterialDto>;
|
|
30
|
+
batch({ batchId }: ConsumptionOrderItemEntityClass, { loaders }: LoaderType<BatchEntityClass>): Promise<BatchDto | null>;
|
|
31
|
+
location({ locationId }: ConsumptionOrderItemEntityClass, { loaders }: LoaderType<LocationEntityClass>): Promise<LocationDto | null>;
|
|
32
|
+
targetLocation({ targetLocationId }: ConsumptionOrderItemEntityClass, { loaders }: LoaderType<LocationEntityClass>): Promise<LocationDto | null>;
|
|
33
|
+
loader({ loaderId }: ConsumptionOrderItemEntityClass, { loaders }: LoaderType<LoadersEntityClass>): Promise<LoaderDto | null>;
|
|
34
|
+
targetLoader({ targetLoaderId }: ConsumptionOrderItemEntityClass, { loaders }: LoaderType<LoadersEntityClass>): Promise<LoaderDto | null>;
|
|
35
|
+
issuedQuantity({ id }: ConsumptionOrderItemEntityClass, { loaders }: LoaderType<ConsumptionOrderChangeEntityClass>): Promise<number>;
|
|
36
|
+
returnedQuantity({ id }: ConsumptionOrderItemEntityClass, { loaders }: LoaderType<ConsumptionOrderChangeEntityClass>): Promise<number>;
|
|
37
|
+
settledQuantity({ id }: ConsumptionOrderItemEntityClass, { loaders }: LoaderType<ConsumptionOrderChangeEntityClass>): Promise<number>;
|
|
38
|
+
/** Issued minus returned minus settled: what the process still holds. */
|
|
39
|
+
outstandingQuantity({ id }: ConsumptionOrderItemEntityClass, { loaders }: LoaderType<ConsumptionOrderChangeEntityClass>): Promise<number>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { __decorate, __param, __metadata } from 'tslib';
|
|
2
|
+
import { ResolveField, Parent, Context, Resolver, Float } from '@nestjs/graphql';
|
|
3
|
+
import { ConsumptionOrderItemEntityClass, WmsEntities, ConsumptionOrderChangeEntityClass, BatchGroupEntityClass, LoadersEntityClass, ConsumptionChangeKind } from '@rytass/wms-module-core';
|
|
4
|
+
import { ConsumptionOrderDto } from '../dto/consumption-order.dto.js';
|
|
5
|
+
import { ConsumptionOrderItemDto } from '../dto/consumption-order-item.dto.js';
|
|
6
|
+
import '../dto/loader-type.dto.js';
|
|
7
|
+
import { LoaderDto } from '../dto/loader.dto.js';
|
|
8
|
+
import { MaterialDto } from '../dto/material.dto.js';
|
|
9
|
+
import '../dto/material-unit.dto.js';
|
|
10
|
+
import '../dto/stock.dto.js';
|
|
11
|
+
import '../dto/sale-order.dto.js';
|
|
12
|
+
import '../dto/receive-inventory-order.dto.js';
|
|
13
|
+
import '../dto/receive-inventory-order-item.dto.js';
|
|
14
|
+
import '../dto/ship-inventory-order.dto.js';
|
|
15
|
+
import '../dto/ship-inventory-order-item.dto.js';
|
|
16
|
+
import '../dto/hold-inventory-order.dto.js';
|
|
17
|
+
import '../dto/hold-inventory-order-item.dto.js';
|
|
18
|
+
import '../dto/allocate-inventory-order.dto.js';
|
|
19
|
+
import '../dto/allocate-inventory-order-item.dto.js';
|
|
20
|
+
import '../dto/transfer-order.dto.js';
|
|
21
|
+
import '../dto/transfer-order-item.dto.js';
|
|
22
|
+
import '../dto/transfer-customer-order.dto.js';
|
|
23
|
+
import '../dto/transfer-customer-order-item.dto.js';
|
|
24
|
+
import '../dto/transfer-vendor-order.dto.js';
|
|
25
|
+
import '../dto/transfer-vendor-order-item.dto.js';
|
|
26
|
+
import '../dto/scrape-order.dto.js';
|
|
27
|
+
import '../dto/scrape-order-item.dto.js';
|
|
28
|
+
import '../dto/quality-inspection-order.dto.js';
|
|
29
|
+
import '../dto/quality-inspection-order-item.dto.js';
|
|
30
|
+
import '../dto/inventory-count-order.dto.js';
|
|
31
|
+
import '../dto/order-reference.dto.js';
|
|
32
|
+
import { BatchDto } from '../dto/batch.dto.js';
|
|
33
|
+
import { LocationDto } from '../dto/location.dto.js';
|
|
34
|
+
|
|
35
|
+
let ConsumptionOrderResolver = class ConsumptionOrderResolver {
|
|
36
|
+
items({ id }, { loaders }) {
|
|
37
|
+
return loaders.batchMany.load({
|
|
38
|
+
__entity: ConsumptionOrderItemEntityClass,
|
|
39
|
+
__from: { orderId: id },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
__decorate([
|
|
44
|
+
ResolveField(() => [ConsumptionOrderItemDto]),
|
|
45
|
+
__param(0, Parent()),
|
|
46
|
+
__param(1, Context()),
|
|
47
|
+
__metadata("design:type", Function),
|
|
48
|
+
__metadata("design:paramtypes", [ConsumptionOrderDto, Object]),
|
|
49
|
+
__metadata("design:returntype", Promise)
|
|
50
|
+
], ConsumptionOrderResolver.prototype, "items", null);
|
|
51
|
+
ConsumptionOrderResolver = __decorate([
|
|
52
|
+
Resolver(() => ConsumptionOrderDto)
|
|
53
|
+
], ConsumptionOrderResolver);
|
|
54
|
+
let ConsumptionOrderItemResolver = class ConsumptionOrderItemResolver {
|
|
55
|
+
entities;
|
|
56
|
+
/**
|
|
57
|
+
* The configured entities, not the built-in classes: `__entity` decides which
|
|
58
|
+
* repository the DataLoader opens, so it has to follow whatever the consumer
|
|
59
|
+
* passed to `WMSBaseModuleOptions`. Loading a built-in class outright filters
|
|
60
|
+
* on its single-table-inheritance discriminator and resolves nothing for an
|
|
61
|
+
* override.
|
|
62
|
+
*/
|
|
63
|
+
constructor(entities) {
|
|
64
|
+
this.entities = entities;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* How much this line has moved, by kind.
|
|
68
|
+
*
|
|
69
|
+
* Read back from the changes rather than denormalised onto the item: the
|
|
70
|
+
* changes are what the stock ledger and the `stock.*` events agree with, and a
|
|
71
|
+
* counter maintained alongside them is a second answer waiting to disagree.
|
|
72
|
+
*/
|
|
73
|
+
async movedQuantity(itemId, kind, loaders) {
|
|
74
|
+
const changes = await loaders.batchMany.load({
|
|
75
|
+
__entity: ConsumptionOrderChangeEntityClass,
|
|
76
|
+
__from: { itemId },
|
|
77
|
+
});
|
|
78
|
+
return changes
|
|
79
|
+
.filter((change) => change.kind === kind)
|
|
80
|
+
.reduce((total, { quantityChanged }) => total + Math.abs(Number(quantityChanged)), 0);
|
|
81
|
+
}
|
|
82
|
+
material({ materialId }, { loaders }) {
|
|
83
|
+
return loaders.batchSingle.load({
|
|
84
|
+
__entity: this.entities.material,
|
|
85
|
+
__from: { id: materialId },
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async batch({ batchId }, { loaders }) {
|
|
89
|
+
if (!batchId)
|
|
90
|
+
return null;
|
|
91
|
+
const { groupId } = await loaders.batchSingle.load({
|
|
92
|
+
__entity: this.entities.batch,
|
|
93
|
+
__from: { id: batchId },
|
|
94
|
+
});
|
|
95
|
+
return loaders.batchSingle.load({
|
|
96
|
+
__entity: BatchGroupEntityClass,
|
|
97
|
+
__from: { id: groupId },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async location({ locationId }, { loaders }) {
|
|
101
|
+
if (!locationId)
|
|
102
|
+
return null;
|
|
103
|
+
return loaders.batchSingle.load({
|
|
104
|
+
__entity: this.entities.location,
|
|
105
|
+
__from: { id: locationId },
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async targetLocation({ targetLocationId }, { loaders }) {
|
|
109
|
+
if (!targetLocationId)
|
|
110
|
+
return null;
|
|
111
|
+
return loaders.batchSingle.load({
|
|
112
|
+
__entity: this.entities.location,
|
|
113
|
+
__from: { id: targetLocationId },
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async loader({ loaderId }, { loaders }) {
|
|
117
|
+
if (!loaderId)
|
|
118
|
+
return null;
|
|
119
|
+
return loaders.batchSingle.load({
|
|
120
|
+
__entity: LoadersEntityClass,
|
|
121
|
+
__from: { id: loaderId },
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async targetLoader({ targetLoaderId }, { loaders }) {
|
|
125
|
+
if (!targetLoaderId)
|
|
126
|
+
return null;
|
|
127
|
+
return loaders.batchSingle.load({
|
|
128
|
+
__entity: LoadersEntityClass,
|
|
129
|
+
__from: { id: targetLoaderId },
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
issuedQuantity({ id }, { loaders }) {
|
|
133
|
+
return this.movedQuantity(id, ConsumptionChangeKind.ISSUE, loaders);
|
|
134
|
+
}
|
|
135
|
+
returnedQuantity({ id }, { loaders }) {
|
|
136
|
+
return this.movedQuantity(id, ConsumptionChangeKind.RETURN, loaders);
|
|
137
|
+
}
|
|
138
|
+
settledQuantity({ id }, { loaders }) {
|
|
139
|
+
return this.movedQuantity(id, ConsumptionChangeKind.SETTLE, loaders);
|
|
140
|
+
}
|
|
141
|
+
/** Issued minus returned minus settled: what the process still holds. */
|
|
142
|
+
async outstandingQuantity({ id }, { loaders }) {
|
|
143
|
+
const changes = await loaders.batchMany.load({
|
|
144
|
+
__entity: ConsumptionOrderChangeEntityClass,
|
|
145
|
+
__from: { itemId: id },
|
|
146
|
+
});
|
|
147
|
+
// The sign already carries the direction here — an issue is positive, a
|
|
148
|
+
// return and a settlement negative — so the outstanding amount is just the
|
|
149
|
+
// sum, no filtering by kind needed.
|
|
150
|
+
return changes.reduce((total, { quantityChanged }) => total + Number(quantityChanged), 0);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
__decorate([
|
|
154
|
+
ResolveField(() => MaterialDto),
|
|
155
|
+
__param(0, Parent()),
|
|
156
|
+
__param(1, Context()),
|
|
157
|
+
__metadata("design:type", Function),
|
|
158
|
+
__metadata("design:paramtypes", [ConsumptionOrderItemEntityClass, Object]),
|
|
159
|
+
__metadata("design:returntype", Promise)
|
|
160
|
+
], ConsumptionOrderItemResolver.prototype, "material", null);
|
|
161
|
+
__decorate([
|
|
162
|
+
ResolveField(() => BatchDto, { nullable: true }),
|
|
163
|
+
__param(0, Parent()),
|
|
164
|
+
__param(1, Context()),
|
|
165
|
+
__metadata("design:type", Function),
|
|
166
|
+
__metadata("design:paramtypes", [ConsumptionOrderItemEntityClass, Object]),
|
|
167
|
+
__metadata("design:returntype", Promise)
|
|
168
|
+
], ConsumptionOrderItemResolver.prototype, "batch", null);
|
|
169
|
+
__decorate([
|
|
170
|
+
ResolveField(() => LocationDto, { nullable: true }),
|
|
171
|
+
__param(0, Parent()),
|
|
172
|
+
__param(1, Context()),
|
|
173
|
+
__metadata("design:type", Function),
|
|
174
|
+
__metadata("design:paramtypes", [ConsumptionOrderItemEntityClass, Object]),
|
|
175
|
+
__metadata("design:returntype", Promise)
|
|
176
|
+
], ConsumptionOrderItemResolver.prototype, "location", null);
|
|
177
|
+
__decorate([
|
|
178
|
+
ResolveField(() => LocationDto, { nullable: true }),
|
|
179
|
+
__param(0, Parent()),
|
|
180
|
+
__param(1, Context()),
|
|
181
|
+
__metadata("design:type", Function),
|
|
182
|
+
__metadata("design:paramtypes", [ConsumptionOrderItemEntityClass, Object]),
|
|
183
|
+
__metadata("design:returntype", Promise)
|
|
184
|
+
], ConsumptionOrderItemResolver.prototype, "targetLocation", null);
|
|
185
|
+
__decorate([
|
|
186
|
+
ResolveField(() => LoaderDto, { nullable: true }),
|
|
187
|
+
__param(0, Parent()),
|
|
188
|
+
__param(1, Context()),
|
|
189
|
+
__metadata("design:type", Function),
|
|
190
|
+
__metadata("design:paramtypes", [ConsumptionOrderItemEntityClass, Object]),
|
|
191
|
+
__metadata("design:returntype", Promise)
|
|
192
|
+
], ConsumptionOrderItemResolver.prototype, "loader", null);
|
|
193
|
+
__decorate([
|
|
194
|
+
ResolveField(() => LoaderDto, { nullable: true }),
|
|
195
|
+
__param(0, Parent()),
|
|
196
|
+
__param(1, Context()),
|
|
197
|
+
__metadata("design:type", Function),
|
|
198
|
+
__metadata("design:paramtypes", [ConsumptionOrderItemEntityClass, Object]),
|
|
199
|
+
__metadata("design:returntype", Promise)
|
|
200
|
+
], ConsumptionOrderItemResolver.prototype, "targetLoader", null);
|
|
201
|
+
__decorate([
|
|
202
|
+
ResolveField(() => Float),
|
|
203
|
+
__param(0, Parent()),
|
|
204
|
+
__param(1, Context()),
|
|
205
|
+
__metadata("design:type", Function),
|
|
206
|
+
__metadata("design:paramtypes", [ConsumptionOrderItemEntityClass, Object]),
|
|
207
|
+
__metadata("design:returntype", Promise)
|
|
208
|
+
], ConsumptionOrderItemResolver.prototype, "issuedQuantity", null);
|
|
209
|
+
__decorate([
|
|
210
|
+
ResolveField(() => Float),
|
|
211
|
+
__param(0, Parent()),
|
|
212
|
+
__param(1, Context()),
|
|
213
|
+
__metadata("design:type", Function),
|
|
214
|
+
__metadata("design:paramtypes", [ConsumptionOrderItemEntityClass, Object]),
|
|
215
|
+
__metadata("design:returntype", Promise)
|
|
216
|
+
], ConsumptionOrderItemResolver.prototype, "returnedQuantity", null);
|
|
217
|
+
__decorate([
|
|
218
|
+
ResolveField(() => Float),
|
|
219
|
+
__param(0, Parent()),
|
|
220
|
+
__param(1, Context()),
|
|
221
|
+
__metadata("design:type", Function),
|
|
222
|
+
__metadata("design:paramtypes", [ConsumptionOrderItemEntityClass, Object]),
|
|
223
|
+
__metadata("design:returntype", Promise)
|
|
224
|
+
], ConsumptionOrderItemResolver.prototype, "settledQuantity", null);
|
|
225
|
+
__decorate([
|
|
226
|
+
ResolveField(() => Float),
|
|
227
|
+
__param(0, Parent()),
|
|
228
|
+
__param(1, Context()),
|
|
229
|
+
__metadata("design:type", Function),
|
|
230
|
+
__metadata("design:paramtypes", [ConsumptionOrderItemEntityClass, Object]),
|
|
231
|
+
__metadata("design:returntype", Promise)
|
|
232
|
+
], ConsumptionOrderItemResolver.prototype, "outstandingQuantity", null);
|
|
233
|
+
ConsumptionOrderItemResolver = __decorate([
|
|
234
|
+
Resolver(() => ConsumptionOrderItemDto),
|
|
235
|
+
__metadata("design:paramtypes", [WmsEntities])
|
|
236
|
+
], ConsumptionOrderItemResolver);
|
|
237
|
+
|
|
238
|
+
export { ConsumptionOrderItemResolver, ConsumptionOrderResolver };
|
|
@@ -25,6 +25,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
25
25
|
import '../dto/quality-inspection-order.dto.js';
|
|
26
26
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
27
27
|
import '../dto/inventory-count-order.dto.js';
|
|
28
|
+
import '../dto/consumption-order.dto.js';
|
|
29
|
+
import '../dto/consumption-order-item.dto.js';
|
|
30
|
+
import '../dto/order-reference.dto.js';
|
|
28
31
|
import { LoaderTypeEntityClass, LoadersEntityClass } from '@rytass/wms-module-core';
|
|
29
32
|
|
|
30
33
|
let LoaderTypeResolver = class LoaderTypeResolver {
|
|
@@ -25,6 +25,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
25
25
|
import '../dto/quality-inspection-order.dto.js';
|
|
26
26
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
27
27
|
import '../dto/inventory-count-order.dto.js';
|
|
28
|
+
import '../dto/consumption-order.dto.js';
|
|
29
|
+
import '../dto/consumption-order-item.dto.js';
|
|
30
|
+
import '../dto/order-reference.dto.js';
|
|
28
31
|
import { LoadersEntityClass, WmsEntities, StockService, LoaderTypeEntityClass } from '@rytass/wms-module-core';
|
|
29
32
|
import { LocationDto } from '../dto/location.dto.js';
|
|
30
33
|
import _ from 'lodash';
|
|
@@ -25,6 +25,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
25
25
|
import '../dto/quality-inspection-order.dto.js';
|
|
26
26
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
27
27
|
import '../dto/inventory-count-order.dto.js';
|
|
28
|
+
import '../dto/consumption-order.dto.js';
|
|
29
|
+
import '../dto/consumption-order-item.dto.js';
|
|
30
|
+
import '../dto/order-reference.dto.js';
|
|
28
31
|
import { MaterialEntityClass, StockService, MaterialUnitEntityClass, UnitEntityClass } from '@rytass/wms-module-core';
|
|
29
32
|
import { UnitDto } from '../dto/unit.dto.js';
|
|
30
33
|
|
|
@@ -25,6 +25,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
25
25
|
import '../dto/quality-inspection-order.dto.js';
|
|
26
26
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
27
27
|
import '../dto/inventory-count-order.dto.js';
|
|
28
|
+
import '../dto/consumption-order.dto.js';
|
|
29
|
+
import '../dto/consumption-order-item.dto.js';
|
|
30
|
+
import '../dto/order-reference.dto.js';
|
|
28
31
|
import { ReceiveInventoryOrderItemEntityClass, WmsEntities, BatchGroupEntityClass, LoadersEntityClass, ReceiveInventoryOrderChangeEntityClass } from '@rytass/wms-module-core';
|
|
29
32
|
import { BatchDto } from '../dto/batch.dto.js';
|
|
30
33
|
import { LocationDto } from '../dto/location.dto.js';
|
|
@@ -25,6 +25,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
25
25
|
import '../dto/quality-inspection-order.dto.js';
|
|
26
26
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
27
27
|
import '../dto/inventory-count-order.dto.js';
|
|
28
|
+
import '../dto/consumption-order.dto.js';
|
|
29
|
+
import '../dto/consumption-order-item.dto.js';
|
|
30
|
+
import '../dto/order-reference.dto.js';
|
|
28
31
|
import { ShipInventoryOrderEntityClass, ShipInventoryOrderItemEntityClass, WmsEntities, ShipInventoryOrderReferenceEntityClass, BatchGroupEntityClass, LoadersEntityClass, ShipInventoryOrderChangeEntityClass } from '@rytass/wms-module-core';
|
|
29
32
|
import { BatchDto } from '../dto/batch.dto.js';
|
|
30
33
|
import { LocationDto } from '../dto/location.dto.js';
|
|
@@ -25,6 +25,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
25
25
|
import '../dto/quality-inspection-order.dto.js';
|
|
26
26
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
27
27
|
import '../dto/inventory-count-order.dto.js';
|
|
28
|
+
import '../dto/consumption-order.dto.js';
|
|
29
|
+
import '../dto/consumption-order-item.dto.js';
|
|
30
|
+
import '../dto/order-reference.dto.js';
|
|
28
31
|
import { StockEntityClass, WmsEntities, BatchGroupEntityClass } from '@rytass/wms-module-core';
|
|
29
32
|
import { LocationDto } from '../dto/location.dto.js';
|
|
30
33
|
import { BatchDto } from '../dto/batch.dto.js';
|
|
@@ -26,6 +26,9 @@ import '../dto/scrape-order-item.dto.js';
|
|
|
26
26
|
import '../dto/quality-inspection-order.dto.js';
|
|
27
27
|
import '../dto/quality-inspection-order-item.dto.js';
|
|
28
28
|
import '../dto/inventory-count-order.dto.js';
|
|
29
|
+
import '../dto/consumption-order.dto.js';
|
|
30
|
+
import '../dto/consumption-order-item.dto.js';
|
|
31
|
+
import '../dto/order-reference.dto.js';
|
|
29
32
|
import { BatchDto } from '../dto/batch.dto.js';
|
|
30
33
|
import { LocationDto } from '../dto/location.dto.js';
|
|
31
34
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GraphQLJSONObject } from './json-object.scalar';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { GraphQLScalarType, Kind, GraphQLError } from 'graphql';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A JSON object scalar, defined here rather than pulled from `graphql-type-json`
|
|
5
|
+
* so the package keeps its peer dependency list as it is — `graphql` is already
|
|
6
|
+
* required, and this is the whole of what we need from such a library.
|
|
7
|
+
*
|
|
8
|
+
* Deliberately narrower than "any JSON": the values it guards (a batch's
|
|
9
|
+
* host-defined `attributes`) are always a keyed record, and refusing a bare
|
|
10
|
+
* scalar or array at the edge means every consumer downstream can rely on that
|
|
11
|
+
* without re-checking.
|
|
12
|
+
*/
|
|
13
|
+
function parseLiteralValue(node) {
|
|
14
|
+
switch (node.kind) {
|
|
15
|
+
case Kind.STRING:
|
|
16
|
+
case Kind.BOOLEAN:
|
|
17
|
+
return node.value;
|
|
18
|
+
case Kind.INT:
|
|
19
|
+
case Kind.FLOAT:
|
|
20
|
+
return Number(node.value);
|
|
21
|
+
case Kind.NULL:
|
|
22
|
+
return null;
|
|
23
|
+
case Kind.LIST:
|
|
24
|
+
return node.values.map(parseLiteralValue);
|
|
25
|
+
case Kind.OBJECT:
|
|
26
|
+
return parseObjectLiteral(node);
|
|
27
|
+
default:
|
|
28
|
+
throw new GraphQLError(`JSONObject cannot represent a ${node.kind} literal`, { nodes: node });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function parseObjectLiteral(node) {
|
|
32
|
+
return node.fields.reduce((carry, field) => {
|
|
33
|
+
return { ...carry, [field.name.value]: parseLiteralValue(field.value) };
|
|
34
|
+
}, {});
|
|
35
|
+
}
|
|
36
|
+
function assertPlainObject(value) {
|
|
37
|
+
if (typeof value !== 'object' ||
|
|
38
|
+
value === null ||
|
|
39
|
+
Array.isArray(value) ||
|
|
40
|
+
// A Date or any other class instance serializes to something the host did
|
|
41
|
+
// not write; reject it here rather than let it reach the column.
|
|
42
|
+
Object.getPrototypeOf(value) !== Object.prototype) {
|
|
43
|
+
throw new GraphQLError('JSONObject must be a plain JSON object');
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
const GraphQLJSONObject = new GraphQLScalarType({
|
|
48
|
+
name: 'JSONObject',
|
|
49
|
+
description: 'An arbitrary JSON object supplied by the host. Its keys and values are stored verbatim and are never interpreted by this module.',
|
|
50
|
+
serialize: (value) => assertPlainObject(value),
|
|
51
|
+
parseValue: (value) => assertPlainObject(value),
|
|
52
|
+
parseLiteral: (node) => {
|
|
53
|
+
if (node.kind !== Kind.OBJECT) {
|
|
54
|
+
throw new GraphQLError('JSONObject must be an object literal', {
|
|
55
|
+
nodes: node,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return parseObjectLiteral(node);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export { GraphQLJSONObject };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rytass/wms-module-graphql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Rytass WMS Module — GraphQL schema, resolvers and DTOs for warehouse management",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rytass",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
63
63
|
"@nestjs/graphql": "^13.0.0",
|
|
64
64
|
"@rytass/wms-base-nestjs-module": "^0.4.0",
|
|
65
|
-
"@rytass/wms-module-core": "^0.
|
|
65
|
+
"@rytass/wms-module-core": "^0.9.0",
|
|
66
66
|
"graphql": "^16.0.0",
|
|
67
67
|
"reflect-metadata": "^0.1.13 || ^0.2.0",
|
|
68
68
|
"rxjs": "^7.0.0",
|