@things-factory/warehouse-base 5.0.14 → 6.0.0-alpha.3
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/dist-server/controllers/ecommerce/ecommerce-controller.js +1 -1
- package/dist-server/controllers/ecommerce/ecommerce-controller.js.map +1 -1
- package/dist-server/controllers/ecommerce/sellercraft-controller.js +64 -60
- package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
- package/dist-server/controllers/warehouse-controller.js +7 -5
- package/dist-server/controllers/warehouse-controller.js.map +1 -1
- package/dist-server/service/inventory/inventory-mutation.js +6 -6
- package/dist-server/service/inventory/inventory-mutation.js.map +1 -1
- package/dist-server/service/inventory/inventory-query.js +217 -195
- package/dist-server/service/inventory/inventory-query.js.map +1 -1
- package/dist-server/service/inventory/inventory-types.js +14 -15
- package/dist-server/service/inventory/inventory-types.js.map +1 -1
- package/dist-server/service/inventory/inventory.js +62 -42
- package/dist-server/service/inventory/inventory.js.map +1 -1
- package/dist-server/service/inventory-change/inventory-change-mutation.js +252 -216
- package/dist-server/service/inventory-change/inventory-change-mutation.js.map +1 -1
- package/dist-server/service/inventory-change/inventory-change-query.js +6 -7
- package/dist-server/service/inventory-change/inventory-change-query.js.map +1 -1
- package/dist-server/service/inventory-change/inventory-change.js +7 -7
- package/dist-server/service/inventory-change/inventory-change.js.map +1 -1
- package/dist-server/service/inventory-history/inventory-history-mutation.js +1 -1
- package/dist-server/service/inventory-history/inventory-history-mutation.js.map +1 -1
- package/dist-server/service/inventory-history/inventory-history-query.js +89 -99
- package/dist-server/service/inventory-history/inventory-history-query.js.map +1 -1
- package/dist-server/service/inventory-history/inventory-history-types.js +3 -3
- package/dist-server/service/inventory-history/inventory-history-types.js.map +1 -1
- package/dist-server/service/inventory-history/inventory-history.js +7 -7
- package/dist-server/service/inventory-history/inventory-history.js.map +1 -1
- package/dist-server/service/inventory-item/inventory-item-mutation.js +10 -10
- package/dist-server/service/inventory-item/inventory-item-mutation.js.map +1 -1
- package/dist-server/service/inventory-item/inventory-item-query.js +18 -17
- package/dist-server/service/inventory-item/inventory-item-query.js.map +1 -1
- package/dist-server/service/inventory-item/inventory-item-type.js +4 -5
- package/dist-server/service/inventory-item/inventory-item-type.js.map +1 -1
- package/dist-server/service/inventory-item/inventory-item.js +5 -5
- package/dist-server/service/inventory-item/inventory-item.js.map +1 -1
- package/dist-server/service/inventory-item-change/inventory-item-change-mutation.js +4 -4
- package/dist-server/service/inventory-item-change/inventory-item-change-mutation.js.map +1 -1
- package/dist-server/service/inventory-item-change/inventory-item-change-query.js +7 -9
- package/dist-server/service/inventory-item-change/inventory-item-change-query.js.map +1 -1
- package/dist-server/service/inventory-item-change/inventory-item-change-type.js +6 -7
- package/dist-server/service/inventory-item-change/inventory-item-change-type.js.map +1 -1
- package/dist-server/service/inventory-item-change/inventory-item-change.js +3 -4
- package/dist-server/service/inventory-item-change/inventory-item-change.js.map +1 -1
- package/dist-server/service/inventory-product/inventory-product-mutation.js +4 -4
- package/dist-server/service/inventory-product/inventory-product-mutation.js.map +1 -1
- package/dist-server/service/inventory-product/inventory-product-query.js +7 -9
- package/dist-server/service/inventory-product/inventory-product-query.js.map +1 -1
- package/dist-server/service/inventory-product/inventory-product-type.js +1 -2
- package/dist-server/service/inventory-product/inventory-product-type.js.map +1 -1
- package/dist-server/service/inventory-product/inventory-product.js +5 -5
- package/dist-server/service/inventory-product/inventory-product.js.map +1 -1
- package/dist-server/service/location/location-mutation.js +5 -5
- package/dist-server/service/location/location-mutation.js.map +1 -1
- package/dist-server/service/location/location-query.js +17 -19
- package/dist-server/service/location/location-query.js.map +1 -1
- package/dist-server/service/location/location-types.js +3 -3
- package/dist-server/service/location/location-types.js.map +1 -1
- package/dist-server/service/location/location.js +14 -14
- package/dist-server/service/location/location.js.map +1 -1
- package/dist-server/service/movement/movement-mutation.js +6 -5
- package/dist-server/service/movement/movement-mutation.js.map +1 -1
- package/dist-server/service/movement/movement-query.js +15 -15
- package/dist-server/service/movement/movement-query.js.map +1 -1
- package/dist-server/service/movement/movement-types.js +4 -5
- package/dist-server/service/movement/movement-types.js.map +1 -1
- package/dist-server/service/movement/movement.js +5 -5
- package/dist-server/service/movement/movement.js.map +1 -1
- package/dist-server/service/pallet/pallet-mutation.js +5 -5
- package/dist-server/service/pallet/pallet-mutation.js.map +1 -1
- package/dist-server/service/pallet/pallet-query.js +9 -11
- package/dist-server/service/pallet/pallet-query.js.map +1 -1
- package/dist-server/service/pallet/pallet-types.js +5 -6
- package/dist-server/service/pallet/pallet-types.js.map +1 -1
- package/dist-server/service/pallet/pallet.js +6 -6
- package/dist-server/service/pallet/pallet.js.map +1 -1
- package/dist-server/service/pallet-count/pallet-count-mutation.js +1 -1
- package/dist-server/service/pallet-count/pallet-count-mutation.js.map +1 -1
- package/dist-server/service/pallet-count/pallet-count-query.js +6 -8
- package/dist-server/service/pallet-count/pallet-count-query.js.map +1 -1
- package/dist-server/service/pallet-count/pallet-count.js +3 -4
- package/dist-server/service/pallet-count/pallet-count.js.map +1 -1
- package/dist-server/service/pallet-history/pallet-history-mutation.js +1 -1
- package/dist-server/service/pallet-history/pallet-history-mutation.js.map +1 -1
- package/dist-server/service/pallet-history/pallet-history-query.js +6 -8
- package/dist-server/service/pallet-history/pallet-history-query.js.map +1 -1
- package/dist-server/service/pallet-history/pallet-history.js +6 -6
- package/dist-server/service/pallet-history/pallet-history.js.map +1 -1
- package/dist-server/service/reduced-inventory-history/reduced-inventory-history.js +1 -1
- package/dist-server/service/reduced-inventory-history/reduced-inventory-history.js.map +1 -1
- package/dist-server/service/tote/tote-mutation.js +4 -4
- package/dist-server/service/tote/tote-mutation.js.map +1 -1
- package/dist-server/service/tote/tote-query.js +12 -13
- package/dist-server/service/tote/tote-query.js.map +1 -1
- package/dist-server/service/tote/tote-types.js +2 -3
- package/dist-server/service/tote/tote-types.js.map +1 -1
- package/dist-server/service/tote/tote.js +5 -5
- package/dist-server/service/tote/tote.js.map +1 -1
- package/dist-server/service/warehouse/warehouse-mutation.js +1 -1
- package/dist-server/service/warehouse/warehouse-mutation.js.map +1 -1
- package/dist-server/service/warehouse/warehouse-query.js +9 -10
- package/dist-server/service/warehouse/warehouse-query.js.map +1 -1
- package/dist-server/service/warehouse/warehouse.js +12 -12
- package/dist-server/service/warehouse/warehouse.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/utils/inventory-util.js +16 -16
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +8 -8
- package/server/controllers/ecommerce/ecommerce-controller.ts +1 -1
- package/server/controllers/ecommerce/sellercraft-controller.ts +75 -65
- package/server/controllers/warehouse-controller.ts +9 -4
- package/server/service/inventory/inventory-mutation.ts +28 -24
- package/server/service/inventory/inventory-query.ts +269 -304
- package/server/service/inventory/inventory.ts +50 -35
- package/server/service/inventory-change/inventory-change-mutation.ts +305 -256
- package/server/service/inventory-change/inventory-change-query.ts +9 -9
- package/server/service/inventory-history/inventory-history-mutation.ts +12 -15
- package/server/service/inventory-history/inventory-history-query.ts +158 -133
- package/server/service/inventory-item/inventory-item-mutation.ts +20 -17
- package/server/service/inventory-item/inventory-item-query.ts +28 -18
- package/server/service/inventory-item-change/inventory-item-change-mutation.ts +12 -9
- package/server/service/inventory-item-change/inventory-item-change-query.ts +10 -8
- package/server/service/inventory-product/inventory-product-mutation.ts +16 -12
- package/server/service/inventory-product/inventory-product-query.ts +7 -8
- package/server/service/location/location-mutation.ts +24 -24
- package/server/service/location/location-query.ts +27 -23
- package/server/service/location/location.ts +11 -10
- package/server/service/movement/movement-mutation.ts +7 -8
- package/server/service/movement/movement-query.ts +18 -16
- package/server/service/pallet/pallet-mutation.ts +18 -20
- package/server/service/pallet/pallet-query.ts +13 -14
- package/server/service/pallet-count/pallet-count-mutation.ts +20 -17
- package/server/service/pallet-count/pallet-count-query.ts +6 -7
- package/server/service/pallet-history/pallet-history-mutation.ts +15 -15
- package/server/service/pallet-history/pallet-history-query.ts +7 -8
- package/server/service/reduced-inventory-history/reduced-inventory-history.ts +1 -1
- package/server/service/tote/tote-mutation.ts +23 -22
- package/server/service/tote/tote-query.ts +18 -14
- package/server/service/warehouse/warehouse-mutation.ts +21 -18
- package/server/service/warehouse/warehouse-query.ts +11 -11
- package/server/service/warehouse/warehouse.ts +7 -7
- package/server/utils/inventory-util.ts +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inventory-product.js","sourceRoot":"","sources":["../../../server/service/inventory-product/inventory-product.ts"],"names":[],"mappings":";;;;;AAAA,+CAAoD;AACpD,qCASgB;AAEhB,yDAAgD;AAChD,+DAAsD;AACtD,iDAA8C;AAS9C,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;CAgE5B,CAAA;AA7DC;IAFC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;4CACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"inventory-product.js","sourceRoot":"","sources":["../../../server/service/inventory-product/inventory-product.ts"],"names":[],"mappings":";;;;;AAAA,+CAAoD;AACpD,qCASgB;AAEhB,yDAAgD;AAChD,+DAAsD;AACtD,iDAA8C;AAS9C,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;CAgE5B,CAAA;AA7DC;IAFC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;4CACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjB,cAAM;gDAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC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C,EAAE,CAAC,gBAAI,EAAE;QACvB,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAChB,gBAAI;iDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,gBAAkC,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC;;mDAC3D;AAMlB;IAJC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE;QACvB,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAChB,gBAAI;iDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,gBAAkC,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC;;mDAC3D;AA/DP,gBAAgB;IAP5B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EACJ,wBAAwB,EACxB,CAAC,gBAAkC,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC,EACxF,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;GAC9C,gBAAgB,CAgE5B;AAhEY,4CAAgB","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Product } from '@things-factory/product-base'\nimport { Domain } from '@things-factory/shell'\n\n@Entity()\n@Index(\n 'ix_inventory_product_0',\n (inventoryProduct: InventoryProduct) => [inventoryProduct.domain, inventoryProduct.name],\n { unique: true }\n)\n@ObjectType({ description: 'Entity for InventoryProduct' })\nexport class InventoryProduct {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain?: Domain\n\n @RelationId((inventoryProduct: InventoryProduct) => inventoryProduct.domain)\n domainId?: string\n\n @Column()\n @Field()\n name: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n serialNumber?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n status?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n arrivalNoticeId: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n releaseGoodId: string\n\n @ManyToOne(type => Product)\n @Field({ nullable: true })\n product?: Product\n\n @RelationId((inventoryProduct: InventoryProduct) => inventoryProduct.product)\n productId?: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n creator?: User\n\n @RelationId((inventoryProduct: InventoryProduct) => inventoryProduct.creator)\n creatorId?: string\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n updater?: User\n\n @RelationId((inventoryProduct: InventoryProduct) => inventoryProduct.creator)\n updaterId?: string\n}\n"]}
|
|
@@ -11,7 +11,7 @@ let LocationMutation = class LocationMutation {
|
|
|
11
11
|
return await createLocation(location, context);
|
|
12
12
|
}
|
|
13
13
|
async updateLocation(id, patch, context) {
|
|
14
|
-
return await updateLocation(id, patch, context
|
|
14
|
+
return await updateLocation(id, patch, context);
|
|
15
15
|
}
|
|
16
16
|
async updateMultipleLocation(patches, context) {
|
|
17
17
|
let results = [];
|
|
@@ -42,7 +42,7 @@ let LocationMutation = class LocationMutation {
|
|
|
42
42
|
async deleteAllLocations(warehouseId, context) {
|
|
43
43
|
const { tx } = context.state;
|
|
44
44
|
await tx.getRepository(location_1.Location).delete({
|
|
45
|
-
warehouse:
|
|
45
|
+
warehouse: { id: warehouseId }
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
};
|
|
@@ -115,16 +115,16 @@ async function createLocation(location, context) {
|
|
|
115
115
|
const { domain, user, tx } = context.state;
|
|
116
116
|
const locationRepository = tx.getRepository(location_1.Location);
|
|
117
117
|
const warehouseRepository = tx.getRepository(warehouse_1.Warehouse);
|
|
118
|
-
return await locationRepository.save(Object.assign(Object.assign({}, location), { warehouse: await warehouseRepository.
|
|
118
|
+
return await locationRepository.save(Object.assign(Object.assign({}, location), { warehouse: await warehouseRepository.findOneBy({ id: location.warehouse.id }), domain, creator: user, updater: user }));
|
|
119
119
|
}
|
|
120
120
|
exports.createLocation = createLocation;
|
|
121
121
|
async function updateLocation(id, patch, context) {
|
|
122
122
|
const { user, tx } = context.state;
|
|
123
123
|
const locationRepository = tx.getRepository(location_1.Location);
|
|
124
124
|
const warehouseRepository = tx.getRepository(warehouse_1.Warehouse);
|
|
125
|
-
const location = await locationRepository.
|
|
125
|
+
const location = await locationRepository.findOneBy({ id });
|
|
126
126
|
if (patch.warehouse && patch.warehouse.id) {
|
|
127
|
-
patch.warehouse = await warehouseRepository.
|
|
127
|
+
patch.warehouse = await warehouseRepository.findOneBy({ id: patch.warehouse.id });
|
|
128
128
|
}
|
|
129
129
|
return await locationRepository.save(Object.assign(Object.assign(Object.assign({}, location), patch), { updater: user }));
|
|
130
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location-mutation.js","sourceRoot":"","sources":["../../../server/service/location/location-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;
|
|
1
|
+
{"version":3,"file":"location-mutation.js","sourceRoot":"","sources":["../../../server/service/location/location-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAGtE,mDAA+C;AAC/C,sDAAkD;AAClD,qDAA6D;AAG7D,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IAI3B,KAAK,CAAC,cAAc,CAAkB,QAAqB,EAAS,OAAwB;QAC1F,OAAO,MAAM,cAAc,CAAC,QAAQ,EAA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AE,GAAG,OAAO,CAAC,KAAK,CAAA;IAE5B,MAAM,UAAU,GAAyB,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAA;IACnE,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC3B,OAAO,IAAI,CAAA;AACb,CAAC;AAND,wCAMC;AAEM,KAAK,UAAU,eAAe,CAAC,GAAa,EAAE,OAAwB;IAC3E,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAE5B,MAAM,UAAU,GAAyB,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAA;IACnE,MAAM,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC5B,OAAO,IAAI,CAAA;AACb,CAAC;AAND,0CAMC","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { Repository } from 'typeorm'\n\nimport { Location } from '../location/location'\nimport { Warehouse } from '../warehouse/warehouse'\nimport { LocationPatch, NewLocation } from './location-types'\n\n@Resolver(Location)\nexport class LocationMutation {\n @Directive('@privilege(category: \"warehouse\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Location)\n async createLocation(@Arg('location') location: NewLocation, @Ctx() context: ResolverContext): Promise<Location> {\n return await createLocation(location, context)\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Location)\n async updateLocation(\n @Arg('id') id: string,\n @Arg('patch') patch: LocationPatch,\n @Ctx() context: ResolverContext\n ): Promise<Location> {\n return await updateLocation(id, patch, context)\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => [Location])\n async updateMultipleLocation(\n @Arg('patches', type => [LocationPatch]) patches: LocationPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Location[]> {\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const patch = _createRecords[i]\n const result = await createLocation(patch as NewLocation, context)\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const patch: LocationPatch = _updateRecords[i]\n const result = await updateLocation(patch.id, patch, context)\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteLocation(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n return await deleteLocation(id, context)\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteLocations(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n return await deleteLocations(ids, context)\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteAllLocations(@Arg('warehouseId') warehouseId: string, @Ctx() context: ResolverContext) {\n const { tx } = context.state\n\n await tx.getRepository(Location).delete({\n warehouse: { id: warehouseId }\n })\n }\n}\n\nexport async function createLocation(location: NewLocation, context: ResolverContext) {\n const { domain, user, tx } = context.state\n\n const locationRepository: Repository<Location> = tx.getRepository(Location)\n const warehouseRepository: Repository<Warehouse> = tx.getRepository(Warehouse)\n\n return await locationRepository.save({\n ...location,\n warehouse: await warehouseRepository.findOneBy({ id: location.warehouse.id }),\n domain,\n creator: user,\n updater: user\n })\n}\n\nexport async function updateLocation(id: string, patch: LocationPatch, context: ResolverContext) {\n const { user, tx } = context.state\n\n const locationRepository: Repository<Location> = tx.getRepository(Location)\n const warehouseRepository: Repository<Warehouse> = tx.getRepository(Warehouse)\n const location: Location = await locationRepository.findOneBy({ id })\n\n if (patch.warehouse && patch.warehouse.id) {\n patch.warehouse = await warehouseRepository.findOneBy({ id: patch.warehouse.id })\n }\n\n return await locationRepository.save({\n ...location,\n ...patch,\n updater: user\n })\n}\n\nexport async function deleteLocation(id: string, context: ResolverContext) {\n const { tx } = context.state\n\n const repository: Repository<Location> = tx.getRepository(Location)\n await repository.delete(id)\n return true\n}\n\nexport async function deleteLocations(ids: string[], context: ResolverContext) {\n const { tx } = context.state\n\n const repository: Repository<Location> = tx.getRepository(Location)\n await repository.delete(ids)\n return true\n}\n"]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c, _d;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.LocationQuery = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
5
|
const type_graphql_1 = require("type-graphql");
|
|
7
|
-
const typeorm_1 = require("typeorm");
|
|
8
6
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
7
|
const biz_base_1 = require("@things-factory/biz-base");
|
|
10
8
|
const shell_1 = require("@things-factory/shell");
|
|
@@ -14,7 +12,7 @@ const location_1 = require("./location");
|
|
|
14
12
|
const location_types_1 = require("./location-types");
|
|
15
13
|
let LocationQuery = class LocationQuery {
|
|
16
14
|
async locations(params, context) {
|
|
17
|
-
const queryBuilder = (0,
|
|
15
|
+
const queryBuilder = (0, shell_1.getRepository)(location_1.Location).createQueryBuilder();
|
|
18
16
|
(0, shell_1.buildQuery)(queryBuilder, params, context);
|
|
19
17
|
const [items, total] = await queryBuilder.getManyAndCount();
|
|
20
18
|
return { items, total };
|
|
@@ -26,7 +24,7 @@ let LocationQuery = class LocationQuery {
|
|
|
26
24
|
* ORM lagging issue (converting to object extremely withdraws the performance)
|
|
27
25
|
* */
|
|
28
26
|
async pureLocations(params, context) {
|
|
29
|
-
const queryBuilder = (0,
|
|
27
|
+
const queryBuilder = (0, shell_1.getRepository)(location_1.Location).createQueryBuilder('location');
|
|
30
28
|
(0, shell_1.buildQuery)(queryBuilder, params, context);
|
|
31
29
|
const items = await queryBuilder.getRawMany();
|
|
32
30
|
const total = await queryBuilder.getCount();
|
|
@@ -35,9 +33,9 @@ let LocationQuery = class LocationQuery {
|
|
|
35
33
|
async locationOccupancies(warehouse, types, context) {
|
|
36
34
|
var _a, _b;
|
|
37
35
|
const { domain } = context.state;
|
|
38
|
-
const foundWarehouse = await (0,
|
|
36
|
+
const foundWarehouse = await (0, shell_1.getRepository)(warehouse_1.Warehouse).findOne({
|
|
39
37
|
where: {
|
|
40
|
-
domain,
|
|
38
|
+
domain: { id: domain.id },
|
|
41
39
|
name: warehouse
|
|
42
40
|
},
|
|
43
41
|
relations: ['locations']
|
|
@@ -54,7 +52,7 @@ let LocationQuery = class LocationQuery {
|
|
|
54
52
|
return { total, occupied, empty, percentage };
|
|
55
53
|
}
|
|
56
54
|
async location(name, context) {
|
|
57
|
-
const foundLocation = await (0,
|
|
55
|
+
const foundLocation = await (0, shell_1.getRepository)(location_1.Location).findOne({
|
|
58
56
|
where: { name },
|
|
59
57
|
relations: ['domain', 'warehouse', 'creator', 'updater']
|
|
60
58
|
});
|
|
@@ -64,7 +62,7 @@ let LocationQuery = class LocationQuery {
|
|
|
64
62
|
}
|
|
65
63
|
async locationByName(name, context) {
|
|
66
64
|
const { domain } = context.state;
|
|
67
|
-
return await (0,
|
|
65
|
+
return await (0, shell_1.getRepository)(location_1.Location).findOne({
|
|
68
66
|
where: {
|
|
69
67
|
domain: domain,
|
|
70
68
|
name
|
|
@@ -77,13 +75,13 @@ let LocationQuery = class LocationQuery {
|
|
|
77
75
|
const warehouseIdParam = params.filters.find(param => (param.name = 'warehouse_id'));
|
|
78
76
|
if (!warehouseIdParam.value)
|
|
79
77
|
throw new Error(`invalid warehouse ID`);
|
|
80
|
-
const items = await (0,
|
|
78
|
+
const items = await (0, shell_1.getRepository)(location_1.Location).query(`
|
|
81
79
|
SELECT CONCAT("zone",'-',"row",'-',"column") as name, "zone", "row", "column"
|
|
82
80
|
FROM locations WHERE domain_id = '${domain.id}'
|
|
83
81
|
AND warehouse_id = '${warehouseIdParam.value}'
|
|
84
82
|
GROUP BY "zone", "row", "column"
|
|
85
83
|
`);
|
|
86
|
-
let [{ total }] = await (0,
|
|
84
|
+
let [{ total }] = await (0, shell_1.getRepository)(location_1.Location).query(`
|
|
87
85
|
SELECT COUNT(DISTINCT("zone", "row", "column")) as total
|
|
88
86
|
FROM locations WHERE domain_id = '${domain.id}'
|
|
89
87
|
AND warehouse_id = '${warehouseIdParam.value}'
|
|
@@ -95,7 +93,7 @@ let LocationQuery = class LocationQuery {
|
|
|
95
93
|
var _a, _b;
|
|
96
94
|
const { domain, user } = context.state;
|
|
97
95
|
const bizplaceIds = await (0, biz_base_1.getPermittedBizplaceIds)(domain, user);
|
|
98
|
-
const queryBuilder = (0,
|
|
96
|
+
const queryBuilder = (0, shell_1.getRepository)(location_1.Location).createQueryBuilder();
|
|
99
97
|
const warehouseNames = (_a = params.filters.find(x => x.name === 'warehouseNames' && x.operator.toLowerCase() === 'in')) === null || _a === void 0 ? void 0 : _a.value;
|
|
100
98
|
const locationTypes = (_b = params.filters.find(x => x.name === 'locationTypes' && x.operator.toLowerCase() === 'in')) === null || _b === void 0 ? void 0 : _b.value;
|
|
101
99
|
params.filters = [];
|
|
@@ -159,17 +157,17 @@ let LocationQuery = class LocationQuery {
|
|
|
159
157
|
}
|
|
160
158
|
async domain(location) {
|
|
161
159
|
var _a;
|
|
162
|
-
return await (0,
|
|
160
|
+
return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: (_a = location.domain) === null || _a === void 0 ? void 0 : _a.id });
|
|
163
161
|
}
|
|
164
162
|
async updater(location) {
|
|
165
|
-
return await (0,
|
|
163
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: location.updaterId });
|
|
166
164
|
}
|
|
167
165
|
async creator(location) {
|
|
168
|
-
return await (0,
|
|
166
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: location.creatorId });
|
|
169
167
|
}
|
|
170
168
|
async warehouse(location) {
|
|
171
169
|
var _a;
|
|
172
|
-
return await (0,
|
|
170
|
+
return await (0, shell_1.getRepository)(warehouse_1.Warehouse).findOneBy({ id: (_a = location.warehouse) === null || _a === void 0 ? void 0 : _a.id });
|
|
173
171
|
}
|
|
174
172
|
};
|
|
175
173
|
tslib_1.__decorate([
|
|
@@ -178,7 +176,7 @@ tslib_1.__decorate([
|
|
|
178
176
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
179
177
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
180
178
|
tslib_1.__metadata("design:type", Function),
|
|
181
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
179
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
182
180
|
tslib_1.__metadata("design:returntype", Promise)
|
|
183
181
|
], LocationQuery.prototype, "locations", null);
|
|
184
182
|
tslib_1.__decorate([
|
|
@@ -187,7 +185,7 @@ tslib_1.__decorate([
|
|
|
187
185
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
188
186
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
189
187
|
tslib_1.__metadata("design:type", Function),
|
|
190
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
188
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
191
189
|
tslib_1.__metadata("design:returntype", Promise)
|
|
192
190
|
], LocationQuery.prototype, "pureLocations", null);
|
|
193
191
|
tslib_1.__decorate([
|
|
@@ -224,7 +222,7 @@ tslib_1.__decorate([
|
|
|
224
222
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
225
223
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
226
224
|
tslib_1.__metadata("design:type", Function),
|
|
227
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
225
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
228
226
|
tslib_1.__metadata("design:returntype", Promise)
|
|
229
227
|
], LocationQuery.prototype, "locationsByGroup", null);
|
|
230
228
|
tslib_1.__decorate([
|
|
@@ -233,7 +231,7 @@ tslib_1.__decorate([
|
|
|
233
231
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
234
232
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
235
233
|
tslib_1.__metadata("design:type", Function),
|
|
236
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
234
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
237
235
|
tslib_1.__metadata("design:returntype", Promise)
|
|
238
236
|
], LocationQuery.prototype, "locationWithInventories", null);
|
|
239
237
|
tslib_1.__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location-query.js","sourceRoot":"","sources":["../../../server/service/location/location-query.ts"],"names":[],"mappings":";;;;;AAAA,+CAA8F;AAC9F,qCAAuC;AAEvC,yDAAgD;AAChD,uDAAkE;AAClE,iDAAqE;AAErE,yDAA4D;AAC5D,sDAAkD;AAClD,yCAAqC;AACrC,qDAAuF;AAGvF,IAAa,aAAa,GAA1B,MAAa,aAAa;IAGxB,KAAK,CAAC,SAAS,CAAS,MAAiB,EAAS,OAAY;QAC5D,MAAM,YAAY,GAAG,IAAA,uBAAa,EAAC,mBAAQ,CAAC,CAAC,kBAAkB,EAAE,CAAA;QACjE,IAAA,kBAAU,EAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACzC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY,CAAC,eAAe,EAAE,CAAA;QAE3D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAED;;;;;SAKK;IAGL,KAAK,CAAC,aAAa,CAAS,MAAiB,EAAS,OAAY;QAChE,MAAM,YAAY,GAAG,IAAA,uBAA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BAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;iEAAjB,iBAAS,oBAAT,iBAAS;;4DAgFtD;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;2CAEtC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;4CAEvC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;4CAEvC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,qBAAS,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;8CAEzC;AAtNU,aAAa;IADzB,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,aAAa,CAuNzB;AAvNY,sCAAa","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\nimport { getRepository } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { getPermittedBizplaceIds } from '@things-factory/biz-base'\nimport { buildQuery, Domain, ListParam } from '@things-factory/shell'\n\nimport { INVENTORY_STATUS } from '../../constants/inventory'\nimport { Warehouse } from '../warehouse/warehouse'\nimport { Location } from './location'\nimport { LocationInventories, LocationList, LocationOccupancy } from './location-types'\n\n@Resolver(Location)\nexport class LocationQuery {\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => LocationList)\n async locations(@Args() params: ListParam, @Ctx() context: any): Promise<LocationList> {\n const queryBuilder = getRepository(Location).createQueryBuilder()\n buildQuery(queryBuilder, params, context)\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n /**\n * @description this resolver was specially made to return huge locations data\n * without dropping off performance due to typegraphql limitations\n * @returns pure location data only. there will be no other table joined to avoid\n * ORM lagging issue (converting to object extremely withdraws the performance)\n * */\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => LocationList)\n async pureLocations(@Args() params: ListParam, @Ctx() context: any): Promise<LocationList> {\n const queryBuilder = getRepository(Location).createQueryBuilder()\n buildQuery(queryBuilder, params, context)\n const items = await queryBuilder.getRawMany()\n const total = await queryBuilder.getCount()\n\n return { items: items.map(item => new Location(item)), total }\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => LocationOccupancy)\n async locationOccupancies(\n @Arg('warehouse') warehouse: string,\n @Arg('types', type => [String], { nullable: true }) types: string[],\n @Ctx() context: any\n ): Promise<LocationOccupancy> {\n const { domain }: { domain: Domain } = context.state\n\n const foundWarehouse: Warehouse = await getRepository(Warehouse).findOne({\n where: {\n domain,\n name: warehouse\n },\n relations: ['locations']\n })\n\n if (!foundWarehouse) throw new Error(`${warehouse} was not found!`)\n\n const locations: Location[] =\n types && types.length\n ? foundWarehouse?.locations?.filter((location: Location) => types.indexOf(location.type) !== -1)\n : foundWarehouse?.locations\n\n const total: number = locations.length\n const occupied: number = locations.filter((location: Location) => location.status === 'OCCUPIED')?.length || 0\n const empty: number = total - occupied\n const percentage: number = occupied > 0 ? Math.round((occupied / total) * 100) : 0\n\n return { total, occupied, empty, percentage }\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => Location)\n async location(@Arg('name') name: string, @Ctx() context: any): Promise<Location> {\n const foundLocation: Location | null = await getRepository(Location).findOne({\n where: { name },\n relations: ['domain', 'warehouse', 'creator', 'updater']\n })\n if (!foundLocation) throw new Error(context.t('error.no_location_found'))\n\n return foundLocation\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => Location)\n async locationByName(@Arg('name') name: string, @Ctx() context: any): Promise<Location> {\n const { domain }: { domain: Domain } = context.state\n\n return await getRepository(Location).findOne({\n where: {\n domain: domain,\n name\n },\n relations: ['domain', 'warehouse', 'creator', 'updater']\n })\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => LocationList)\n async locationsByGroup(@Args() params: ListParam, @Ctx() context: any): Promise<LocationList> {\n const { domain }: { domain: Domain } = context.state\n const warehouseIdParam = params.filters.find(param => (param.name = 'warehouse_id'))\n\n if (!warehouseIdParam.value) throw new Error(`invalid warehouse ID`)\n\n const items = await getRepository(Location).query(`\n SELECT CONCAT(\"zone\",'-',\"row\",'-',\"column\") as name, \"zone\", \"row\", \"column\"\n FROM locations WHERE domain_id = '${domain.id}'\n AND warehouse_id = '${warehouseIdParam.value}'\n GROUP BY \"zone\", \"row\", \"column\"\n `)\n\n let [{ total }] = await getRepository(Location).query(`\n SELECT COUNT(DISTINCT(\"zone\", \"row\", \"column\")) as total\n FROM locations WHERE domain_id = '${domain.id}'\n AND warehouse_id = '${warehouseIdParam.value}'\n `)\n\n total = parseInt(total)\n\n return { items, total }\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => LocationInventories)\n async locationWithInventories(@Args() params: ListParam, @Ctx() context: any): Promise<LocationInventories> {\n const { domain, user }: { domain: Domain; user: User } = context.state\n const bizplaceIds = await getPermittedBizplaceIds(domain, user)\n const queryBuilder = getRepository(Location).createQueryBuilder()\n\n const warehouseNames = params.filters.find(x => x.name === 'warehouseNames' && x.operator.toLowerCase() === 'in')\n ?.value\n\n const locationTypes = params.filters.find(x => x.name === 'locationTypes' && x.operator.toLowerCase() === 'in')\n ?.value\n\n params.filters = []\n buildQuery(queryBuilder, params, context)\n\n queryBuilder\n .leftJoinAndSelect('Location.warehouse', 'Warehouse')\n .leftJoinAndSelect(\n 'inventories',\n 'Inventory',\n 'Location.id = Inventory.location_id AND Inventory.status = :InvStatus',\n {\n InvStatus: INVENTORY_STATUS.STORED\n }\n )\n .leftJoinAndSelect('Inventory.product', 'Product')\n .leftJoinAndSelect('Inventory.bizplace', 'Bizplace', 'Bizplace.id IN (:...bizplaceIds)', {\n bizplaceIds: [...new Set(bizplaceIds)]\n })\n .leftJoinAndSelect('Inventory.creator', 'Creator')\n .leftJoinAndSelect('Inventory.updater', 'Updater')\n .addSelect('SUM(\"Inventory\".\"qty\") OVER(PARTITION BY \"Location\".\"id\")', 'accumulate_qty')\n .where('Location.domain_id = :domainId', { domainId: domain.id })\n\n if (warehouseNames) {\n queryBuilder.andWhere('Warehouse.name IN (:...warehouseNames)', { warehouseNames: [...new Set(warehouseNames)] })\n }\n\n if (locationTypes) {\n queryBuilder.andWhere('Location.type ILIKE ANY (ARRAY[:...locationTypes])', {\n locationTypes: [...new Set(locationTypes)]\n })\n }\n\n let items = await queryBuilder.getRawMany()\n const total = await queryBuilder.getCount()\n\n items = items.map(item => {\n return {\n id: item.Location_id,\n name: item.Location_name,\n bizplace: {\n name: item.Bizplace_name || '',\n description: item.Bizplace_description || ''\n },\n product: {\n name: item.Product_name || '',\n sku: item.Product_sku || '',\n description: item.Product_description || ''\n },\n palletId: item.Inventory_pallet_id || '',\n batchId: item.Inventory_batch_id || '',\n qty: item.Inventory_qty || 0,\n accumulatedQty: item.accumulate_qty || 0,\n uomValue: item.Inventory_uom_value || 0.0,\n uom: item.Inventory_uom || '',\n packingType: item.Inventory_packing_type || '',\n packingSize: item.Inventory_packing_size || 0.0,\n expirationDate: item.Inventory_expiration_date\n ? new Date(item.Inventory_expiration_date).toISOString().split('T')[0].split('-').reverse().join('-')\n : '',\n warehouse: {\n name: item.Warehouse_name,\n description: item.Warehouse_description,\n type: item.Warehouse_type\n },\n zone: item.Location_zone\n }\n })\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() location: Location) {\n return await getRepository(Domain).findOne(location.domain?.id)\n }\n\n @FieldResolver(type => User)\n async updater(@Root() location: Location) {\n return await getRepository(User).findOne(location.updaterId)\n }\n\n @FieldResolver(type => User)\n async creator(@Root() location: Location) {\n return await getRepository(User).findOne(location.creatorId)\n }\n\n @FieldResolver(type => Warehouse)\n async warehouse(@Root() location: Location): Promise<Warehouse> {\n return await getRepository(Warehouse).findOne(location.warehouse?.id)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"location-query.js","sourceRoot":"","sources":["../../../server/service/location/location-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,yDAAgD;AAChD,uDAAkE;AAClE,iDAAoF;AAEpF,yDAA4D;AAC5D,sDAAkD;AAClD,yCAAqC;AACrC,qDAAuF;AAGvF,IAAa,aAAa,GAA1B,MAAa,aAAa;IAGxB,KAAK,CAAC,SAAS,CAAS,MAAiB,EAAS,OAAwB;QACxE,MAAM,YAAY,GAAG,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,kBAAkB,EAAE,CAAA;QACjE,IAAA,kBAAU,EAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACzC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY,CAAC,eAAe,EAAE,CAAA;QAE3D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAED;;;;;SAKK;IAGL,KAAK,CAAC,aAAa,CAAS,MAAiB,EAAS,OAAwB;QAC5E,MAAM,YAAY,GAAG,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAA;QAC3E,IAAA,kBAAU,EAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACzC,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,UAAU,EAAE,CAAA;QAC7C,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,CAAA;QAE3C,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,mBAAQ,CAAC,IAAI,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,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;4CAEvC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;4CAEvC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,qBAAS,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;8CAEzC;AA3NU,aAAa;IADzB,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,aAAa,CA4NzB;AA5NY,sCAAa","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\nimport { getPermittedBizplaceIds } from '@things-factory/biz-base'\nimport { buildQuery, Domain, getRepository, ListParam } from '@things-factory/shell'\n\nimport { INVENTORY_STATUS } from '../../constants/inventory'\nimport { Warehouse } from '../warehouse/warehouse'\nimport { Location } from './location'\nimport { LocationInventories, LocationList, LocationOccupancy } from './location-types'\n\n@Resolver(Location)\nexport class LocationQuery {\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => LocationList)\n async locations(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<LocationList> {\n const queryBuilder = getRepository(Location).createQueryBuilder()\n buildQuery(queryBuilder, params, context)\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n /**\n * @description this resolver was specially made to return huge locations data\n * without dropping off performance due to typegraphql limitations\n * @returns pure location data only. there will be no other table joined to avoid\n * ORM lagging issue (converting to object extremely withdraws the performance)\n * */\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => LocationList)\n async pureLocations(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<LocationList> {\n const queryBuilder = getRepository(Location).createQueryBuilder('location')\n buildQuery(queryBuilder, params, context)\n const items = await queryBuilder.getRawMany()\n const total = await queryBuilder.getCount()\n\n return { items: items.map(item => new Location(item)), total }\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => LocationOccupancy)\n async locationOccupancies(\n @Arg('warehouse') warehouse: string,\n @Arg('types', type => [String], { nullable: true }) types: string[],\n @Ctx() context: ResolverContext\n ): Promise<LocationOccupancy> {\n const { domain } = context.state\n\n const foundWarehouse: Warehouse = await getRepository(Warehouse).findOne({\n where: {\n domain: { id: domain.id },\n name: warehouse\n },\n relations: ['locations']\n })\n\n if (!foundWarehouse) throw new Error(`${warehouse} was not found!`)\n\n const locations: Location[] =\n types && types.length\n ? foundWarehouse?.locations?.filter((location: Location) => types.indexOf(location.type) !== -1)\n : foundWarehouse?.locations\n\n const total: number = locations.length\n const occupied: number = locations.filter((location: Location) => location.status === 'OCCUPIED')?.length || 0\n const empty: number = total - occupied\n const percentage: number = occupied > 0 ? Math.round((occupied / total) * 100) : 0\n\n return { total, occupied, empty, percentage }\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => Location)\n async location(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Location> {\n const foundLocation: Location | null = await getRepository(Location).findOne({\n where: { name },\n relations: ['domain', 'warehouse', 'creator', 'updater']\n })\n if (!foundLocation) throw new Error(context.t('error.no_location_found'))\n\n return foundLocation\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => Location)\n async locationByName(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Location> {\n const { domain } = context.state\n\n return await getRepository(Location).findOne({\n where: {\n domain: domain,\n name\n },\n relations: ['domain', 'warehouse', 'creator', 'updater']\n })\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => LocationList)\n async locationsByGroup(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<LocationList> {\n const { domain } = context.state\n const warehouseIdParam = params.filters.find(param => (param.name = 'warehouse_id'))\n\n if (!warehouseIdParam.value) throw new Error(`invalid warehouse ID`)\n\n const items = await getRepository(Location).query(`\n SELECT CONCAT(\"zone\",'-',\"row\",'-',\"column\") as name, \"zone\", \"row\", \"column\"\n FROM locations WHERE domain_id = '${domain.id}'\n AND warehouse_id = '${warehouseIdParam.value}'\n GROUP BY \"zone\", \"row\", \"column\"\n `)\n\n let [{ total }] = await getRepository(Location).query(`\n SELECT COUNT(DISTINCT(\"zone\", \"row\", \"column\")) as total\n FROM locations WHERE domain_id = '${domain.id}'\n AND warehouse_id = '${warehouseIdParam.value}'\n `)\n\n total = parseInt(total)\n\n return { items, total }\n }\n\n @Directive('@privilege(category: \"warehouse\", privilege: \"query\")')\n @Query(returns => LocationInventories)\n async locationWithInventories(\n @Args() params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<LocationInventories> {\n const { domain, user } = context.state\n const bizplaceIds = await getPermittedBizplaceIds(domain, user)\n const queryBuilder = getRepository(Location).createQueryBuilder()\n\n const warehouseNames = params.filters.find(\n x => x.name === 'warehouseNames' && x.operator.toLowerCase() === 'in'\n )?.value\n\n const locationTypes = params.filters.find(\n x => x.name === 'locationTypes' && x.operator.toLowerCase() === 'in'\n )?.value\n\n params.filters = []\n buildQuery(queryBuilder, params, context)\n\n queryBuilder\n .leftJoinAndSelect('Location.warehouse', 'Warehouse')\n .leftJoinAndSelect(\n 'inventories',\n 'Inventory',\n 'Location.id = Inventory.location_id AND Inventory.status = :InvStatus',\n {\n InvStatus: INVENTORY_STATUS.STORED\n }\n )\n .leftJoinAndSelect('Inventory.product', 'Product')\n .leftJoinAndSelect('Inventory.bizplace', 'Bizplace', 'Bizplace.id IN (:...bizplaceIds)', {\n bizplaceIds: [...new Set(bizplaceIds)]\n })\n .leftJoinAndSelect('Inventory.creator', 'Creator')\n .leftJoinAndSelect('Inventory.updater', 'Updater')\n .addSelect('SUM(\"Inventory\".\"qty\") OVER(PARTITION BY \"Location\".\"id\")', 'accumulate_qty')\n .where('Location.domain_id = :domainId', { domainId: domain.id })\n\n if (warehouseNames) {\n queryBuilder.andWhere('Warehouse.name IN (:...warehouseNames)', { warehouseNames: [...new Set(warehouseNames)] })\n }\n\n if (locationTypes) {\n queryBuilder.andWhere('Location.type ILIKE ANY (ARRAY[:...locationTypes])', {\n locationTypes: [...new Set(locationTypes)]\n })\n }\n\n let items = await queryBuilder.getRawMany()\n const total = await queryBuilder.getCount()\n\n items = items.map(item => {\n return {\n id: item.Location_id,\n name: item.Location_name,\n bizplace: {\n name: item.Bizplace_name || '',\n description: item.Bizplace_description || ''\n },\n product: {\n name: item.Product_name || '',\n sku: item.Product_sku || '',\n description: item.Product_description || ''\n },\n palletId: item.Inventory_pallet_id || '',\n batchId: item.Inventory_batch_id || '',\n qty: item.Inventory_qty || 0,\n accumulatedQty: item.accumulate_qty || 0,\n uomValue: item.Inventory_uom_value || 0.0,\n uom: item.Inventory_uom || '',\n packingType: item.Inventory_packing_type || '',\n packingSize: item.Inventory_packing_size || 0.0,\n expirationDate: item.Inventory_expiration_date\n ? new Date(item.Inventory_expiration_date).toISOString().split('T')[0].split('-').reverse().join('-')\n : '',\n warehouse: {\n name: item.Warehouse_name,\n description: item.Warehouse_description,\n type: item.Warehouse_type\n },\n zone: item.Location_zone\n }\n })\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() location: Location) {\n return await getRepository(Domain).findOneBy({ id: location.domain?.id })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() location: Location) {\n return await getRepository(User).findOneBy({ id: location.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() location: Location) {\n return await getRepository(User).findOneBy({ id: location.creatorId })\n }\n\n @FieldResolver(type => Warehouse)\n async warehouse(@Root() location: Location): Promise<Warehouse> {\n return await getRepository(Warehouse).findOneBy({ id: location.warehouse?.id })\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b
|
|
2
|
+
var _a, _b;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.NewLocation = exports.LocationPatch = exports.LocationOccupancy = exports.LocationList = exports.LocationInventories = exports.LocationInventory = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
@@ -133,7 +133,7 @@ tslib_1.__decorate([
|
|
|
133
133
|
], LocationPatch.prototype, "id", void 0);
|
|
134
134
|
tslib_1.__decorate([
|
|
135
135
|
(0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true }),
|
|
136
|
-
tslib_1.__metadata("design:type",
|
|
136
|
+
tslib_1.__metadata("design:type", shell_1.ObjectRef)
|
|
137
137
|
], LocationPatch.prototype, "warehouse", void 0);
|
|
138
138
|
tslib_1.__decorate([
|
|
139
139
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
@@ -191,7 +191,7 @@ let NewLocation = class NewLocation {
|
|
|
191
191
|
};
|
|
192
192
|
tslib_1.__decorate([
|
|
193
193
|
(0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true }),
|
|
194
|
-
tslib_1.__metadata("design:type",
|
|
194
|
+
tslib_1.__metadata("design:type", shell_1.ObjectRef)
|
|
195
195
|
], NewLocation.prototype, "warehouse", void 0);
|
|
196
196
|
tslib_1.__decorate([
|
|
197
197
|
(0, type_graphql_1.Field)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location-types.js","sourceRoot":"","sources":["../../../server/service/location/location-types.ts"],"names":[],"mappings":";;;;;AAAA,+CAAuE;AAEvE,uDAAmD;AACnD,+DAAsD;AACtD,iDAAiD;AAEjD,sDAAkD;AAClD,yCAAqC;AAGrC,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;CA6C7B,CAAA;AA3CC;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACf;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,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IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjC,iBAAS;8CAAA;AAGrB;IADC,IAAA,oBAAK,GAAE;;yCACI;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACb;AAGb;IADC,IAAA,oBAAK,GAAE;;yCACI;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACH;AAGvB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACF;AAGxB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACH;AAGvB;IADC,IAAA,oBAAK,GAAE;;wCACG;AAGX;IADC,IAAA,oBAAK,GAAE;;2CACM;AAGd;IADC,IAAA,oBAAK,GAAE;;0CACK;AAGb;IADC,IAAA,oBAAK,GAAE;;2CACM;AAnCH,WAAW;IADvB,IAAA,wBAAS,GAAE;GACC,WAAW,CAoCvB;AApCY,kCAAW","sourcesContent":["import { Field, Float, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { Bizplace } from '@things-factory/biz-base'\nimport { Product } from '@things-factory/product-base'\nimport { ObjectRef } from '@things-factory/shell'\n\nimport { Warehouse } from '../warehouse/warehouse'\nimport { Location } from './location'\n\n@ObjectType()\nexport class LocationInventory {\n @Field({ nullable: true })\n id?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field(type => Bizplace, { nullable: true })\n bizplace?: Bizplace\n\n @Field({ nullable: true })\n palletId?: string\n\n @Field({ nullable: true })\n batchId?: string\n\n @Field(type => Int, { nullable: true })\n qty?: number\n\n @Field(type => Int, { nullable: true })\n accumulatedQty?: number\n\n @Field(type => Float, { nullable: true })\n uomValue?: number\n\n @Field({ nullable: true })\n uom?: string\n\n @Field({ nullable: true })\n packingType?: string\n\n @Field(type => Float, { nullable: true })\n packingSize?: number\n\n @Field({ nullable: true })\n expirationDate?: string\n\n @Field(type => Warehouse, { nullable: true })\n warehouse?: Warehouse\n\n @Field(type => Product, { nullable: true })\n product?: Product\n\n @Field({ nullable: true })\n zone?: string\n}\n\n@ObjectType()\nexport class LocationInventories {\n @Field(type => [LocationInventory], { nullable: true })\n items?: LocationInventory[]\n\n @Field(type => Int, { nullable: true })\n total?: number\n}\n\n@ObjectType()\nexport class LocationList {\n @Field(type => [Location], { nullable: true })\n items?: Location[]\n\n @Field(type => Int, { nullable: true })\n total?: number\n}\n\n@ObjectType()\nexport class LocationOccupancy {\n @Field(type => Int, { nullable: true })\n total?: number\n\n @Field(type => Int, { nullable: true })\n occupied?: number\n\n @Field(type => Int, { nullable: true })\n empty?: number\n\n @Field(type => Int, { nullable: true })\n percentage?: number\n}\n\n@InputType()\nexport class LocationPatch {\n @Field({ nullable: true })\n id?: string\n\n @Field(type => ObjectRef, { nullable: true })\n warehouse?: ObjectRef\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field({ nullable: true })\n zone?: string\n\n @Field({ nullable: true })\n firstDelimiter?: string\n\n @Field({ nullable: true })\n secondDelimiter?: string\n\n @Field({ nullable: true })\n thirdDelimiter?: string\n\n @Field({ nullable: true })\n row?: string\n\n @Field({ nullable: true })\n column?: string\n\n @Field({ nullable: true })\n shelf?: string\n\n @Field({ nullable: true })\n status?: string\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@InputType()\nexport class NewLocation {\n @Field(type => ObjectRef, { nullable: true })\n warehouse?: ObjectRef\n\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field()\n zone: string\n\n @Field({ nullable: true })\n firstDelimiter?: string\n\n @Field({ nullable: true })\n secondDelimiter?: string\n\n @Field({ nullable: true })\n thirdDelimiter?: string\n\n @Field()\n row: string\n\n @Field()\n column: string\n\n @Field()\n shelf: string\n\n @Field()\n status: string\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.Location = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
@@ -11,16 +10,16 @@ const warehouse_1 = require("../warehouse/warehouse");
|
|
|
11
10
|
let Location = class Location {
|
|
12
11
|
constructor(obj) {
|
|
13
12
|
if (obj) {
|
|
14
|
-
this.id = obj.
|
|
15
|
-
this.name = obj.
|
|
16
|
-
this.description = obj.
|
|
17
|
-
this.type = obj.
|
|
18
|
-
this.zone = obj.
|
|
19
|
-
this.row = obj.
|
|
20
|
-
this.column = obj.
|
|
21
|
-
this.shelf = obj.
|
|
22
|
-
this.status = obj.
|
|
23
|
-
this.updatedAt = obj.
|
|
13
|
+
this.id = obj.location_id;
|
|
14
|
+
this.name = obj.location_name;
|
|
15
|
+
this.description = obj.location_description;
|
|
16
|
+
this.type = obj.location_type;
|
|
17
|
+
this.zone = obj.location_zone;
|
|
18
|
+
this.row = obj.location_row;
|
|
19
|
+
this.column = obj.location_column;
|
|
20
|
+
this.shelf = obj.location_shelf;
|
|
21
|
+
this.status = obj.location_status;
|
|
22
|
+
this.updatedAt = obj.location_updated_at;
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
};
|
|
@@ -32,7 +31,7 @@ tslib_1.__decorate([
|
|
|
32
31
|
tslib_1.__decorate([
|
|
33
32
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
34
33
|
(0, type_graphql_1.Field)(),
|
|
35
|
-
tslib_1.__metadata("design:type",
|
|
34
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
36
35
|
], Location.prototype, "domain", void 0);
|
|
37
36
|
tslib_1.__decorate([
|
|
38
37
|
(0, typeorm_1.RelationId)((location) => location.domain),
|
|
@@ -98,7 +97,7 @@ tslib_1.__decorate([
|
|
|
98
97
|
nullable: true
|
|
99
98
|
}),
|
|
100
99
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
101
|
-
tslib_1.__metadata("design:type",
|
|
100
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
102
101
|
], Location.prototype, "creator", void 0);
|
|
103
102
|
tslib_1.__decorate([
|
|
104
103
|
(0, typeorm_1.RelationId)((location) => location.creator),
|
|
@@ -109,7 +108,7 @@ tslib_1.__decorate([
|
|
|
109
108
|
nullable: true
|
|
110
109
|
}),
|
|
111
110
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
112
|
-
tslib_1.__metadata("design:type",
|
|
111
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
113
112
|
], Location.prototype, "updater", void 0);
|
|
114
113
|
tslib_1.__decorate([
|
|
115
114
|
(0, typeorm_1.RelationId)((location) => location.updater),
|
|
@@ -130,6 +129,7 @@ Location = tslib_1.__decorate([
|
|
|
130
129
|
(0, typeorm_1.Index)('ix_location_0', (location) => [location.domain, location.name], { unique: true }),
|
|
131
130
|
(0, typeorm_1.Index)('ix_location_1', (location) => [location.id], { unique: true }),
|
|
132
131
|
(0, typeorm_1.Index)('ix_location_2', (location) => [location.domain]),
|
|
132
|
+
(0, typeorm_1.Index)('ix_location_3', (location) => [location.domain, location.name, location.type]),
|
|
133
133
|
(0, type_graphql_1.ObjectType)(),
|
|
134
134
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
135
135
|
], Location);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location.js","sourceRoot":"","sources":["../../../server/service/location/location.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"location.js","sourceRoot":"","sources":["../../../server/service/location/location.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCASgB;AAEhB,yDAAgD;A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\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain } from '@things-factory/shell'\n\nimport { Warehouse } from '../warehouse/warehouse'\n\n@Entity()\n@Index('ix_location_0', (location: Location) => [location.domain, location.name], { unique: true })\n@Index('ix_location_1', (location: Location) => [location.id], { unique: true })\n@Index('ix_location_2', (location: Location) => [location.domain])\n@Index('ix_location_3', (location: Location) => [location.domain, location.name, location.type])\n@ObjectType()\nexport class Location {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field()\n domain: Domain\n\n @RelationId((location: Location) => location.domain)\n domainId: string\n\n @ManyToOne(type => Warehouse, warehouse => warehouse.locations, {\n nullable: false\n })\n @Field(type => Warehouse, { nullable: true })\n warehouse: Warehouse\n\n @RelationId((location: Location) => location.warehouse)\n warehouseId: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n name: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n type: string\n\n @Column()\n @Field()\n zone: string\n\n @Column()\n @Field()\n row: string\n\n @Column()\n @Field()\n column: string\n\n @Column()\n @Field()\n shelf: string\n\n @Column({ type: 'text', comment: 'occupied, hold, empty' })\n @Field()\n status: string\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n creator: User\n\n @RelationId((location: Location) => location.creator)\n creatorId: string\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n updater: User\n\n @RelationId((location: Location) => location.updater)\n updaterId: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n\n constructor(obj?) {\n if (obj) {\n this.id = obj.location_id\n this.name = obj.location_name\n this.description = obj.location_description\n this.type = obj.location_type\n this.zone = obj.location_zone\n this.row = obj.location_row\n this.column = obj.location_column\n this.shelf = obj.location_shelf\n this.status = obj.location_status\n this.updatedAt = obj.location_updated_at\n }\n }\n}\n"]}
|
|
@@ -5,16 +5,17 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
6
|
const typeorm_1 = require("typeorm");
|
|
7
7
|
const biz_base_1 = require("@things-factory/biz-base");
|
|
8
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
9
|
const inventory_1 = require("../inventory/inventory");
|
|
9
10
|
const movement_1 = require("./movement");
|
|
10
11
|
const movement_types_1 = require("./movement-types");
|
|
11
12
|
let MovementMutation = class MovementMutation {
|
|
12
13
|
async createMovement(movement, context) {
|
|
13
14
|
const { domain, user } = context.state;
|
|
14
|
-
return await (0,
|
|
15
|
+
return await (0, shell_1.getRepository)(movement_1.Movement).save(Object.assign(Object.assign({}, movement), { domain, creator: user, updater: user }));
|
|
15
16
|
}
|
|
16
17
|
async updateMovement(id, patch, context) {
|
|
17
|
-
const movement = await (0,
|
|
18
|
+
const movement = await (0, shell_1.getRepository)(movement_1.Movement).findOne({
|
|
18
19
|
where: {
|
|
19
20
|
domain: context.state.domain,
|
|
20
21
|
id,
|
|
@@ -22,12 +23,12 @@ let MovementMutation = class MovementMutation {
|
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
if (patch.inventory && patch.inventory.id) {
|
|
25
|
-
patch.inventory = await (0,
|
|
26
|
+
patch.inventory = await (0, shell_1.getRepository)(inventory_1.Inventory).findOneBy({ id: patch.inventory.id });
|
|
26
27
|
}
|
|
27
|
-
return await (0,
|
|
28
|
+
return await (0, shell_1.getRepository)(movement_1.Movement).save(Object.assign(Object.assign(Object.assign({}, movement), patch), { updater: context.state.user }));
|
|
28
29
|
}
|
|
29
30
|
async deleteMovement(name, context) {
|
|
30
|
-
await (0,
|
|
31
|
+
await (0, shell_1.getRepository)(movement_1.Movement).delete(name);
|
|
31
32
|
return true;
|
|
32
33
|
}
|
|
33
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"movement-mutation.js","sourceRoot":"","sources":["../../../server/service/movement/movement-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,
|
|
1
|
+
{"version":3,"file":"movement-mutation.js","sourceRoot":"","sources":["../../../server/service/movement/movement-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,uDAAkE;AAClE,iDAAqD;AAErD,sDAAkD;AAClD,yCAAqC;AACrC,qDAA6D;AAG7D,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IAI3B,KAAK,CAAC,cAAc,CAAkB,QAAqB,EAAS,OAAwB;QAC1F,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QACtC,OAAO,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,IAAI,iCACpC,QAAQ,KACX,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAKD,KAAK,CAAC,cAAc,CACP,EAAU,EACP,KAAoB,EAC3B,OAAwB;QAE/B,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC;YACrD,KAAK,EAAE;gBACL,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM;gBAC5B,EAAE;gBACF,QAAQ,EAAE,IAAA,YAAE,EAAC,MAAM,IAAA,kCAAuB,EAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aACtF;SACF,CAAC,CAAA;QAEF,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE;YACzC,KAAK,CAAC,SAAS,GAAG,MAAM,IAAA,qBAAa,EAAC,qBAAS,CAAC,CAAC,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AAA;;;;sDAGrD;AA/CU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,gBAAgB,CAgD5B;AAhDY,4CAAgB","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getPermittedBizplaceIds } from '@things-factory/biz-base'\nimport { getRepository } from '@things-factory/shell'\n\nimport { Inventory } from '../inventory/inventory'\nimport { Movement } from './movement'\nimport { MovementPatch, NewMovement } from './movement-types'\n\n@Resolver(Movement)\nexport class MovementMutation {\n @Directive('@privilege(category: \"movement\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Movement)\n async createMovement(@Arg('movement') movement: NewMovement, @Ctx() context: ResolverContext): Promise<Movement> {\n const { domain, user } = context.state\n return await getRepository(Movement).save({\n ...movement,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@privilege(category: \"movement\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Movement)\n async updateMovement(\n @Arg('id') id: string,\n @Arg('patch') patch: MovementPatch,\n @Ctx() context: ResolverContext\n ): Promise<Movement> {\n const movement = await getRepository(Movement).findOne({\n where: {\n domain: context.state.domain,\n id,\n bizplace: In(await getPermittedBizplaceIds(context.state.domain, context.state.user))\n }\n })\n\n if (patch.inventory && patch.inventory.id) {\n patch.inventory = await getRepository(Inventory).findOneBy({ id: patch.inventory.id })\n }\n\n return await getRepository(Movement).save({\n ...movement,\n ...patch,\n updater: context.state.user\n })\n }\n\n @Directive('@privilege(category: \"movement\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteMovement(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n await getRepository(Movement).delete(name)\n return true\n }\n}\n"]}
|