@things-factory/product-base 6.2.177 → 6.2.178
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/constants/index.d.ts +1 -0
- package/dist-server/constants/product.d.ts +21 -0
- package/dist-server/controllers/index.d.ts +0 -0
- package/dist-server/index.d.ts +2 -0
- package/dist-server/middlewares/index.d.ts +0 -0
- package/dist-server/migrations/index.d.ts +1 -0
- package/dist-server/service/index.d.ts +20 -0
- package/dist-server/service/product/index.d.ts +5 -0
- package/dist-server/service/product/product-mutation.d.ts +16 -0
- package/dist-server/service/product/product-mutation.js +6 -6
- package/dist-server/service/product/product-mutation.js.map +1 -1
- package/dist-server/service/product/product-query.d.ts +28 -0
- package/dist-server/service/product/product-query.js +2 -2
- package/dist-server/service/product/product-query.js.map +1 -1
- package/dist-server/service/product/product-types.d.ts +151 -0
- package/dist-server/service/product/product-types.js +7 -8
- package/dist-server/service/product/product-types.js.map +1 -1
- package/dist-server/service/product/product.d.ts +112 -0
- package/dist-server/service/product/product.js +10 -12
- package/dist-server/service/product/product.js.map +1 -1
- package/dist-server/service/product/validate-product.d.ts +2 -0
- package/dist-server/service/product/validate-product.js +1 -2
- package/dist-server/service/product/validate-product.js.map +1 -1
- package/dist-server/service/product-bundle/index.d.ts +5 -0
- package/dist-server/service/product-bundle/product-bundle-mutation.d.ts +9 -0
- package/dist-server/service/product-bundle/product-bundle-mutation.js +2 -2
- package/dist-server/service/product-bundle/product-bundle-mutation.js.map +1 -1
- package/dist-server/service/product-bundle/product-bundle-query.d.ts +12 -0
- package/dist-server/service/product-bundle/product-bundle-query.js +2 -2
- package/dist-server/service/product-bundle/product-bundle-query.js.map +1 -1
- package/dist-server/service/product-bundle/product-bundle-types.d.ts +20 -0
- package/dist-server/service/product-bundle/product-bundle-types.js +6 -6
- package/dist-server/service/product-bundle/product-bundle-types.js.map +1 -1
- package/dist-server/service/product-bundle/product-bundle.d.ts +25 -0
- package/dist-server/service/product-bundle/product-bundle.js +3 -4
- package/dist-server/service/product-bundle/product-bundle.js.map +1 -1
- package/dist-server/service/product-bundle-setting/index.d.ts +5 -0
- package/dist-server/service/product-bundle-setting/product-bundle-setting-mutation.d.ts +10 -0
- package/dist-server/service/product-bundle-setting/product-bundle-setting-mutation.js +4 -4
- package/dist-server/service/product-bundle-setting/product-bundle-setting-mutation.js.map +1 -1
- package/dist-server/service/product-bundle-setting/product-bundle-setting-query.d.ts +6 -0
- package/dist-server/service/product-bundle-setting/product-bundle-setting-query.js +2 -2
- package/dist-server/service/product-bundle-setting/product-bundle-setting-query.js.map +1 -1
- package/dist-server/service/product-bundle-setting/product-bundle-setting-types.d.ts +16 -0
- package/dist-server/service/product-bundle-setting/product-bundle-setting-types.js +4 -4
- package/dist-server/service/product-bundle-setting/product-bundle-setting-types.js.map +1 -1
- package/dist-server/service/product-bundle-setting/product-bundle-setting.d.ts +12 -0
- package/dist-server/service/product-bundle-setting/product-bundle-setting.js +2 -2
- package/dist-server/service/product-bundle-setting/product-bundle-setting.js.map +1 -1
- package/dist-server/service/product-combination/index.d.ts +5 -0
- package/dist-server/service/product-combination/product-combination-mutation.d.ts +9 -0
- package/dist-server/service/product-combination/product-combination-mutation.js +2 -2
- package/dist-server/service/product-combination/product-combination-mutation.js.map +1 -1
- package/dist-server/service/product-combination/product-combination-query.d.ts +11 -0
- package/dist-server/service/product-combination/product-combination-query.js +2 -2
- package/dist-server/service/product-combination/product-combination-query.js.map +1 -1
- package/dist-server/service/product-combination/product-combination-type.d.ts +20 -0
- package/dist-server/service/product-combination/product-combination-type.js +6 -6
- package/dist-server/service/product-combination/product-combination-type.js.map +1 -1
- package/dist-server/service/product-combination/product-combination.d.ts +33 -0
- package/dist-server/service/product-combination/product-combination.js +3 -3
- package/dist-server/service/product-combination/product-combination.js.map +1 -1
- package/dist-server/service/product-combination-setting/index.d.ts +5 -0
- package/dist-server/service/product-combination-setting/product-combination-setting-mutation.d.ts +11 -0
- package/dist-server/service/product-combination-setting/product-combination-setting-mutation.js +4 -4
- package/dist-server/service/product-combination-setting/product-combination-setting-mutation.js.map +1 -1
- package/dist-server/service/product-combination-setting/product-combination-setting-query.d.ts +14 -0
- package/dist-server/service/product-combination-setting/product-combination-setting-query.js +2 -2
- package/dist-server/service/product-combination-setting/product-combination-setting-query.js.map +1 -1
- package/dist-server/service/product-combination-setting/product-combination-setting-type.d.ts +18 -0
- package/dist-server/service/product-combination-setting/product-combination-setting-type.js +6 -6
- package/dist-server/service/product-combination-setting/product-combination-setting-type.js.map +1 -1
- package/dist-server/service/product-combination-setting/product-combination-setting.d.ts +22 -0
- package/dist-server/service/product-combination-setting/product-combination-setting.js +2 -2
- package/dist-server/service/product-combination-setting/product-combination-setting.js.map +1 -1
- package/dist-server/service/product-detail/index.d.ts +5 -0
- package/dist-server/service/product-detail/product-detail-mutation.d.ts +11 -0
- package/dist-server/service/product-detail/product-detail-mutation.js +18 -23
- package/dist-server/service/product-detail/product-detail-mutation.js.map +1 -1
- package/dist-server/service/product-detail/product-detail-query.d.ts +12 -0
- package/dist-server/service/product-detail/product-detail-query.js +2 -2
- package/dist-server/service/product-detail/product-detail-query.js.map +1 -1
- package/dist-server/service/product-detail/product-detail-types.d.ts +98 -0
- package/dist-server/service/product-detail/product-detail-types.js +6 -6
- package/dist-server/service/product-detail/product-detail-types.js.map +1 -1
- package/dist-server/service/product-detail/product-detail.d.ts +121 -0
- package/dist-server/service/product-detail/product-detail.js +7 -8
- package/dist-server/service/product-detail/product-detail.js.map +1 -1
- package/dist-server/service/product-detail-bizplace-setting/index.d.ts +5 -0
- package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-mutation.d.ts +8 -0
- package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-mutation.js +2 -2
- package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-mutation.js.map +1 -1
- package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-query.d.ts +11 -0
- package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-query.js +2 -2
- package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-query.js.map +1 -1
- package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-types.d.ts +24 -0
- package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-types.js +6 -6
- package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-types.js.map +1 -1
- package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting.d.ts +34 -0
- package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting.js +2 -2
- package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting.js.map +1 -1
- package/dist-server/service/product-set/index.d.ts +5 -0
- package/dist-server/service/product-set/product-set-mutation.d.ts +39 -0
- package/dist-server/service/product-set/product-set-mutation.js +5 -5
- package/dist-server/service/product-set/product-set-mutation.js.map +1 -1
- package/dist-server/service/product-set/product-set-query.d.ts +12 -0
- package/dist-server/service/product-set/product-set-query.js +2 -2
- package/dist-server/service/product-set/product-set-query.js.map +1 -1
- package/dist-server/service/product-set/product-set-types.d.ts +18 -0
- package/dist-server/service/product-set/product-set-types.js +6 -6
- package/dist-server/service/product-set/product-set-types.js.map +1 -1
- package/dist-server/service/product-set/product-set.d.ts +22 -0
- package/dist-server/service/product-set/product-set.js +3 -4
- package/dist-server/service/product-set/product-set.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/utils/index.d.ts +1 -0
- package/dist-server/utils/product-util.d.ts +3 -0
- package/package.json +4 -4
- package/server/service/product/product.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-bundle-mutation.js","sourceRoot":"","sources":["../../../server/service/product-bundle/product-bundle-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAA2D;AAC3D,qCAAwC;AAExC,uDAAmD;AACnD,iDAAqD;AAErD,+CAAuD;AACvD,qDAAgD;AAChD,iEAA6E;AAGtE,IAAM,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GAAG,CAAC,CAAA;QACzF,MAAM,iBAAiB,GAAG,IAAA,qBAAa,EAAC,8BAAa,CAAC,CAAA;QACtD,MAAM,YAAY,GAAG,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAA;QAE5C,IAAI,QAAkB,CAAA;QAEtB,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"product-bundle-mutation.js","sourceRoot":"","sources":["../../../server/service/product-bundle/product-bundle-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAA2D;AAC3D,qCAAwC;AAExC,uDAAmD;AACnD,iDAAqD;AAErD,+CAAuD;AACvD,qDAAgD;AAChD,iEAA6E;AAGtE,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAE1B,AAAN,KAAK,CAAC,mBAAmB,CACD,aAA+B,EAC9C,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEtC,OAAO,MAAM,IAAA,qBAAa,EAAC,8BAAa,CAAC,CAAC,IAAI,iCACzC,aAAa,KAChB,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAGK,AAAN,KAAK,CAAC,mBAAmB,CACV,IAAY,EACX,KAAyB,EAChC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEtC,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,8BAAa,CAAC,CAAA;QAC/C,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YAC7C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE;SAC3C,CAAC,CAAA;QAEF,OAAO,MAAM,UAAU,CAAC,IAAI,+CACvB,aAAa,GACb,KAAK,KACR,OAAO,EAAE,IAAI,IACb,CA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,GAAE,CAAA;;qDADe,yCAAkB;;gEAexC;AAGK;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,8BAAa,CAAC,CAAC;IAElC,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,yCAAkB,CAAC,CAAC,CAAA;IAC5C,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wEAwDP;AAGK;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;IACF,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gEAM1D;AAGK;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;IAE1B,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iEAkBP;gCA/HU,qBAAqB;IADjC,IAAA,uBAAQ,EAAC,8BAAa,CAAC;GACX,qBAAqB,CAgIjC","sourcesContent":["import { Arg, Ctx, Mutation, Resolver } from 'type-graphql'\nimport { In, Repository } from 'typeorm'\n\nimport { Bizplace } from '@things-factory/biz-base'\nimport { getRepository } from '@things-factory/shell'\n\nimport { PRODUCT_BUNDLE_STATUS } from '../../constants'\nimport { ProductBundle } from './product-bundle'\nimport { NewProductBundle, ProductBundlePatch } from './product-bundle-types'\n\n@Resolver(ProductBundle)\nexport class ProductBundleMutation {\n @Mutation(returns => ProductBundle)\n async createProductBundle(\n @Arg('productBundle') productBundle: NewProductBundle,\n @Ctx() context: ResolverContext\n ): Promise<ProductBundle> {\n const { domain, user } = context.state\n\n return await getRepository(ProductBundle).save({\n ...productBundle,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Mutation(returns => ProductBundle)\n async updateProductBundle(\n @Arg('name') name: string,\n @Arg('patch') patch: ProductBundlePatch,\n @Ctx() context: ResolverContext\n ): Promise<ProductBundle> {\n const { domain, user } = context.state\n\n const repository = getRepository(ProductBundle)\n const productBundle = await repository.findOne({\n where: { domain: { id: domain.id }, name }\n })\n\n return await repository.save({\n ...productBundle,\n ...patch,\n updater: user\n })\n }\n\n @Mutation(returns => [ProductBundle])\n async updateMultipleProductBundle(\n @Arg('patches', type => [ProductBundlePatch]) patches: ProductBundlePatch[],\n @Ctx() context: ResolverContext\n ): Promise<ProductBundle[]> {\n const { domain, user } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const productBundleRepo = getRepository(ProductBundle)\n const bizplaceRepo = getRepository(Bizplace)\n\n let bizplace: Bizplace\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n let newRecord = _createRecords[i]\n let status = newRecord.status || ''\n\n bizplace = await bizplaceRepo.findOne({ where: { name: domain.name } })\n\n if (!newRecord.status || newRecord.status === '') {\n newRecord.status = PRODUCT_BUNDLE_STATUS.INACTIVE\n }\n\n const result = await productBundleRepo.save({\n ...newRecord,\n domain,\n bizplace,\n status: newRecord.status.toUpperCase(),\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const productBundle = await productBundleRepo.findOneBy({ domain: { id: domain.id }, id: newRecord.id })\n\n if (newRecord.status) {\n newRecord.status = newRecord.status.toUpperCase()\n }\n\n const result = await productBundleRepo.save({\n ...productBundle,\n ...newRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Mutation(returns => Boolean)\n async deleteProductBundle(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n const { domain, user } = context.state\n\n await getRepository(ProductBundle).delete({ domain: { id: domain.id }, name })\n\n return true\n }\n\n @Mutation(returns => Boolean)\n async deleteProductBundles(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n const { tx, user } = context.state\n const productBundleRepo: Repository<ProductBundle> = getRepository(ProductBundle) || tx.getRepository(ProductBundle)\n\n let productBundles = await productBundleRepo.find({ where: { id: In(ids) } })\n\n for (let i = 0; i < productBundles.length; i++) {\n const product = productBundles[i]\n\n const result = await productBundleRepo.save({\n ...product,\n status: PRODUCT_BUNDLE_STATUS.DELETED,\n updater: user\n })\n }\n\n return true\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { User } from '@things-factory/auth-base';
|
|
2
|
+
import { Domain, ListParam } from '@things-factory/shell';
|
|
3
|
+
import { ProductBundle } from './product-bundle';
|
|
4
|
+
import { ProductBundleList } from './product-bundle-types';
|
|
5
|
+
export declare class ProductBundleQuery {
|
|
6
|
+
myBizplaceProductBundles(params: ListParam, context: ResolverContext): Promise<ProductBundleList>;
|
|
7
|
+
productBundles(params: ListParam, context: ResolverContext): Promise<ProductBundleList>;
|
|
8
|
+
productBundle(name: string, context: ResolverContext): Promise<ProductBundle>;
|
|
9
|
+
domain(productBundle: ProductBundle): Promise<Domain>;
|
|
10
|
+
creator(productBundle: ProductBundle): Promise<User>;
|
|
11
|
+
updater(productBundle: ProductBundle): Promise<User>;
|
|
12
|
+
}
|
|
@@ -64,6 +64,7 @@ let ProductBundleQuery = class ProductBundleQuery {
|
|
|
64
64
|
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: productBundle.updaterId });
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
+
exports.ProductBundleQuery = ProductBundleQuery;
|
|
67
68
|
tslib_1.__decorate([
|
|
68
69
|
(0, type_graphql_1.Query)(returns => product_bundle_types_1.ProductBundleList),
|
|
69
70
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
@@ -109,8 +110,7 @@ tslib_1.__decorate([
|
|
|
109
110
|
tslib_1.__metadata("design:paramtypes", [product_bundle_1.ProductBundle]),
|
|
110
111
|
tslib_1.__metadata("design:returntype", Promise)
|
|
111
112
|
], ProductBundleQuery.prototype, "updater", null);
|
|
112
|
-
ProductBundleQuery = tslib_1.__decorate([
|
|
113
|
+
exports.ProductBundleQuery = ProductBundleQuery = tslib_1.__decorate([
|
|
113
114
|
(0, type_graphql_1.Resolver)(product_bundle_1.ProductBundle)
|
|
114
115
|
], ProductBundleQuery);
|
|
115
|
-
exports.ProductBundleQuery = ProductBundleQuery;
|
|
116
116
|
//# sourceMappingURL=product-bundle-query.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-bundle-query.js","sourceRoot":"","sources":["../../../server/service/product-bundle/product-bundle-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AACnF,qCAAsD;AAEtD,yDAAgD;AAChD,uDAAmD;AACnD,iDAAuH;AAEvH,+CAAuD;AACvD,qDAAgD;AAChD,iEAA0D;AAGnD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAEvB,AAAN,KAAK,CAAC,wBAAwB,CACpB,MAAiB,EAClB,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,EAAE,GAAsC,IAAA,qBAAa,EAAC,8BAAa,CAAC,CAAC,kBAAkB,EAAE,CAAA;QAE/F,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,cAAc,CAAC,CAAA;QAC9E,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,CAAA;QAC3D,IAAI,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,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,IAAA,mBAAI,GAAE,CAAA;;6CAAgB,8BAAa;;iDAEjD;6BAvFU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,8BAAa,CAAC;GACX,kBAAkB,CAwF9B","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\nimport { Brackets, SelectQueryBuilder } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Bizplace } from '@things-factory/biz-base'\nimport { buildCondition, buildQuery, convertListParams, Domain, getRepository, ListParam } from '@things-factory/shell'\n\nimport { PRODUCT_BUNDLE_STATUS } from '../../constants'\nimport { ProductBundle } from './product-bundle'\nimport { ProductBundleList } from './product-bundle-types'\n\n@Resolver(ProductBundle)\nexport class ProductBundleQuery {\n @Query(returns => ProductBundleList)\n async myBizplaceProductBundles(\n @Args() params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<ProductBundleList> {\n const { domain } = context.state\n\n const qb: SelectQueryBuilder<ProductBundle> = getRepository(ProductBundle).createQueryBuilder()\n\n const productBundleFilter = params.filters.find(x => x.name == 'product_info')\n const productFilterColumns = ['sku', 'name', 'description']\n let filters = params.filters.filter(x => x.name != 'product_info')\n\n // add status filter to prevent user to see DELETED product bundles\n filters = [...filters, { name: 'status', operator: 'noteq', value: PRODUCT_BUNDLE_STATUS.DELETED }]\n\n if (!params.filters.find(filter => filter.name === 'bizplace_id')) {\n let bizplace: Bizplace = await getRepository(Bizplace).findOne({ where: { domain: { id: domain.id } } })\n params.filters = [...filters, { name: 'bizplace_id', operator: 'in', value: [bizplace.id] }]\n }\n\n buildQuery(qb, params, context, { domainRef: false })\n if (productBundleFilter) {\n qb.andWhere(\n new Brackets(qb2 => {\n productFilterColumns.forEach(filter => {\n const condition = buildCondition(\n qb.alias,\n filter,\n productBundleFilter.operator,\n productBundleFilter.value,\n productBundleFilter.relation,\n Object.keys(qb.getParameters()).length\n )\n\n qb2.orWhere(condition.clause, condition.parameters)\n })\n })\n )\n }\n\n const [items, total] = await qb\n .leftJoinAndSelect('ProductBundle.productBundleSettings', 'ProductBundleSetting')\n .leftJoinAndSelect('ProductBundleSetting.product', 'Product')\n .leftJoinAndSelect('ProductBundleSetting.productDetail', 'ProductDetail')\n .leftJoinAndSelect('ProductBundle.bizplace', 'Bizplace')\n .leftJoinAndSelect('ProductBundle.creator', 'Creator')\n .leftJoinAndSelect('ProductBundle.updater', 'Updater')\n .getManyAndCount()\n\n return { items, total }\n }\n\n @Query(returns => ProductBundleList)\n async productBundles(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ProductBundleList> {\n const convertedParams = convertListParams(params)\n const [items, total] = await getRepository(ProductBundle).findAndCount({\n ...convertedParams\n })\n\n return { items, total }\n }\n\n @Query(returns => ProductBundle)\n async productBundle(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<ProductBundle> {\n const { domain, user } = context.state\n const repository = getRepository(ProductBundle)\n\n return await repository.findOne({\n where: { domain: { id: domain.id }, name }\n })\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() productBundle: ProductBundle): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: productBundle.domainId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() productBundle: ProductBundle): Promise<User> {\n return await getRepository(User).findOneBy({ id: productBundle.creatorId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() productBundle: ProductBundle): Promise<User> {\n return await getRepository(User).findOneBy({ id: productBundle.updaterId })\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProductBundle } from './product-bundle';
|
|
2
|
+
export declare class NewProductBundle {
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class ProductBundleList {
|
|
7
|
+
items?: ProductBundle[];
|
|
8
|
+
total?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class ProductBundlePatch {
|
|
11
|
+
id?: string;
|
|
12
|
+
sku?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
refCode?: string;
|
|
16
|
+
type?: string;
|
|
17
|
+
status?: string;
|
|
18
|
+
packingType?: string;
|
|
19
|
+
cuFlag?: string;
|
|
20
|
+
}
|
|
@@ -6,6 +6,7 @@ const type_graphql_1 = require("type-graphql");
|
|
|
6
6
|
const product_bundle_1 = require("./product-bundle");
|
|
7
7
|
let NewProductBundle = class NewProductBundle {
|
|
8
8
|
};
|
|
9
|
+
exports.NewProductBundle = NewProductBundle;
|
|
9
10
|
tslib_1.__decorate([
|
|
10
11
|
(0, type_graphql_1.Field)(),
|
|
11
12
|
tslib_1.__metadata("design:type", String)
|
|
@@ -14,12 +15,12 @@ tslib_1.__decorate([
|
|
|
14
15
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
15
16
|
tslib_1.__metadata("design:type", String)
|
|
16
17
|
], NewProductBundle.prototype, "description", void 0);
|
|
17
|
-
NewProductBundle = tslib_1.__decorate([
|
|
18
|
+
exports.NewProductBundle = NewProductBundle = tslib_1.__decorate([
|
|
18
19
|
(0, type_graphql_1.InputType)()
|
|
19
20
|
], NewProductBundle);
|
|
20
|
-
exports.NewProductBundle = NewProductBundle;
|
|
21
21
|
let ProductBundleList = class ProductBundleList {
|
|
22
22
|
};
|
|
23
|
+
exports.ProductBundleList = ProductBundleList;
|
|
23
24
|
tslib_1.__decorate([
|
|
24
25
|
(0, type_graphql_1.Field)(type => [product_bundle_1.ProductBundle], { nullable: true }),
|
|
25
26
|
tslib_1.__metadata("design:type", Array)
|
|
@@ -28,12 +29,12 @@ tslib_1.__decorate([
|
|
|
28
29
|
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
|
|
29
30
|
tslib_1.__metadata("design:type", Number)
|
|
30
31
|
], ProductBundleList.prototype, "total", void 0);
|
|
31
|
-
ProductBundleList = tslib_1.__decorate([
|
|
32
|
+
exports.ProductBundleList = ProductBundleList = tslib_1.__decorate([
|
|
32
33
|
(0, type_graphql_1.ObjectType)()
|
|
33
34
|
], ProductBundleList);
|
|
34
|
-
exports.ProductBundleList = ProductBundleList;
|
|
35
35
|
let ProductBundlePatch = class ProductBundlePatch {
|
|
36
36
|
};
|
|
37
|
+
exports.ProductBundlePatch = ProductBundlePatch;
|
|
37
38
|
tslib_1.__decorate([
|
|
38
39
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
39
40
|
tslib_1.__metadata("design:type", String)
|
|
@@ -70,8 +71,7 @@ tslib_1.__decorate([
|
|
|
70
71
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
71
72
|
tslib_1.__metadata("design:type", String)
|
|
72
73
|
], ProductBundlePatch.prototype, "cuFlag", void 0);
|
|
73
|
-
ProductBundlePatch = tslib_1.__decorate([
|
|
74
|
+
exports.ProductBundlePatch = ProductBundlePatch = tslib_1.__decorate([
|
|
74
75
|
(0, type_graphql_1.InputType)()
|
|
75
76
|
], ProductBundlePatch);
|
|
76
|
-
exports.ProductBundlePatch = ProductBundlePatch;
|
|
77
77
|
//# sourceMappingURL=product-bundle-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-bundle-types.js","sourceRoot":"","sources":["../../../server/service/product-bundle/product-bundle-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAEhE,qDAAgD;AAGzC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAM5B,CAAA;
|
|
1
|
+
{"version":3,"file":"product-bundle-types.js","sourceRoot":"","sources":["../../../server/service/product-bundle/product-bundle-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAEhE,qDAAgD;AAGzC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAM5B,CAAA;AANY,4CAAgB;AAE3B;IADC,IAAA,oBAAK,GAAE;;8CACI;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACN;2BALT,gBAAgB;IAD5B,IAAA,wBAAS,GAAE;GACC,gBAAgB,CAM5B;AAGM,IAAM,iB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from './product-bundle'\n\n@InputType()\nexport class NewProductBundle {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n}\n\n@ObjectType()\nexport class ProductBundleList {\n @Field(type => [ProductBundle], { nullable: true })\n items?: ProductBundle[]\n\n @Field(type => Int, { nullable: true })\n total?: number\n}\n\n@InputType()\nexport class ProductBundlePatch {\n @Field({ nullable: true })\n id?: string\n\n @Field({ nullable: true })\n sku?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n refCode?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field({ nullable: true })\n status?: string\n\n @Field({ nullable: true })\n packingType?: string\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { User } from '@things-factory/auth-base';
|
|
2
|
+
import { Bizplace } from '@things-factory/biz-base';
|
|
3
|
+
import { Domain } from '@things-factory/shell';
|
|
4
|
+
import { ProductBundleSetting } from '../product-bundle-setting/product-bundle-setting';
|
|
5
|
+
export declare class ProductBundle {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
domain: Domain;
|
|
8
|
+
domainId: string;
|
|
9
|
+
bizplace: Bizplace;
|
|
10
|
+
productBundleSettings: ProductBundleSetting[];
|
|
11
|
+
sku: string;
|
|
12
|
+
refCode: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
type: string;
|
|
16
|
+
status: string;
|
|
17
|
+
packingType: string;
|
|
18
|
+
packingSize: number;
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
updatedAt: Date;
|
|
21
|
+
creator: User;
|
|
22
|
+
creatorId: string;
|
|
23
|
+
updater: User;
|
|
24
|
+
updaterId: string;
|
|
25
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.ProductBundle = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
@@ -11,6 +10,7 @@ const typeorm_1 = require("typeorm");
|
|
|
11
10
|
const product_bundle_setting_1 = require("../product-bundle-setting/product-bundle-setting");
|
|
12
11
|
let ProductBundle = class ProductBundle {
|
|
13
12
|
};
|
|
13
|
+
exports.ProductBundle = ProductBundle;
|
|
14
14
|
tslib_1.__decorate([
|
|
15
15
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
16
16
|
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
@@ -30,7 +30,7 @@ tslib_1.__decorate([
|
|
|
30
30
|
nullable: false
|
|
31
31
|
}),
|
|
32
32
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
33
|
-
tslib_1.__metadata("design:type",
|
|
33
|
+
tslib_1.__metadata("design:type", biz_base_1.Bizplace)
|
|
34
34
|
], ProductBundle.prototype, "bizplace", void 0);
|
|
35
35
|
tslib_1.__decorate([
|
|
36
36
|
(0, typeorm_1.OneToMany)(type => product_bundle_setting_1.ProductBundleSetting, productBundleSetting => productBundleSetting.productBundle),
|
|
@@ -109,12 +109,11 @@ tslib_1.__decorate([
|
|
|
109
109
|
(0, typeorm_1.RelationId)((productBundle) => productBundle.updater),
|
|
110
110
|
tslib_1.__metadata("design:type", String)
|
|
111
111
|
], ProductBundle.prototype, "updaterId", void 0);
|
|
112
|
-
ProductBundle = tslib_1.__decorate([
|
|
112
|
+
exports.ProductBundle = ProductBundle = tslib_1.__decorate([
|
|
113
113
|
(0, typeorm_1.Entity)(),
|
|
114
114
|
(0, typeorm_1.Index)('ix_product_bundle_0', (productBundle) => [productBundle.domain, productBundle.id], {
|
|
115
115
|
unique: true
|
|
116
116
|
}),
|
|
117
117
|
(0, type_graphql_1.ObjectType)()
|
|
118
118
|
], ProductBundle);
|
|
119
|
-
exports.ProductBundle = ProductBundle;
|
|
120
119
|
//# sourceMappingURL=product-bundle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-bundle.js","sourceRoot":"","sources":["../../../server/service/product-bundle/product-bundle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"product-bundle.js","sourceRoot":"","sources":["../../../server/service/product-bundle/product-bundle.ts"],"names":[],"mappings":";;;;AAAA,yDAAgD;AAChD,uDAAmD;AACnD,iDAAgE;AAChE,+CAAoD;AACpD,qCAA6I;AAC7I,6FAAuF;AAOhF,IAAM,aAAa,GAAnB,MAAM,aAAa;CA+EzB,CAAA;AA/EY,sCAAa;AAGf;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;yCACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,GAAE;sCACA,cAAM;6CAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,aAA4B,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC;;+CACnD;AAMhB;IAJC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,mBAAQ,EAAE;QAC3B,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAChB,mBAAQ;+CAAA;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,6CAAoB,EAAE,oBAAoB,CAAC,EAAE,CAAC,oBAAoB,CAAC,aAAa,CAAC;IACnG,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,6CAAoB,CAAC,CAAC;;4DACO;AAI7C;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;0CACG;AAIX;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EA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E,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjB,gBAAI;8CAAA;AAGb;IADC,IAAA,oBAAU,EAAC,CAAC,aAA4B,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC;;gDACnD;wBA9EN,aAAa;IALzB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,qBAAqB,EAAE,CAAC,aAA4B,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC,EAAE;QACxG,MAAM,EAAE,IAAI;KACb,CAAC;IACD,IAAA,yBAAU,GAAE;GACA,aAAa,CA+EzB","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { Bizplace } from '@things-factory/biz-base'\nimport { Domain, roundTransformer } from '@things-factory/shell'\nimport { Field, ID, ObjectType } from 'type-graphql'\nimport { Column, CreateDateColumn, Entity, Index, ManyToOne, OneToMany, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\nimport { ProductBundleSetting } from '../product-bundle-setting/product-bundle-setting'\n\n@Entity()\n@Index('ix_product_bundle_0', (productBundle: ProductBundle) => [productBundle.domain, productBundle.id], {\n unique: true\n})\n@ObjectType()\nexport class ProductBundle {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field()\n domain: Domain\n\n @RelationId((productBundle: ProductBundle) => productBundle.domain)\n domainId: string\n\n @ManyToOne(type => Bizplace, {\n nullable: false\n })\n @Field({ nullable: true })\n bizplace: Bizplace\n\n @OneToMany(type => ProductBundleSetting, productBundleSetting => productBundleSetting.productBundle)\n @Field(type => [ProductBundleSetting])\n productBundleSettings: ProductBundleSetting[]\n\n @Column()\n @Field()\n sku: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n refCode: string\n\n @Column()\n @Field()\n name: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n description: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n type: string\n\n @Column()\n @Field()\n status: string\n\n @Column()\n @Field()\n packingType: string\n\n @Column({ type: 'float', default: 1, transformer: roundTransformer })\n @Field()\n packingSize: number\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((productBundle: ProductBundle) => productBundle.creator)\n creatorId: string\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n updater: User\n\n @RelationId((productBundle: ProductBundle) => productBundle.updater)\n updaterId: string\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ProductBundleSetting } from './product-bundle-setting';
|
|
2
|
+
import { ProductBundleSettingMutation } from './product-bundle-setting-mutation';
|
|
3
|
+
import { ProductBundleSettingQuery } from './product-bundle-setting-query';
|
|
4
|
+
export declare const entities: (typeof ProductBundleSetting)[];
|
|
5
|
+
export declare const resolvers: (typeof ProductBundleSettingMutation | typeof ProductBundleSettingQuery)[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm';
|
|
2
|
+
import { ProductBundleSetting } from './product-bundle-setting';
|
|
3
|
+
import { ProductBundleSettingPatch } from './product-bundle-setting-types';
|
|
4
|
+
export declare class ProductBundleSettingMutation {
|
|
5
|
+
updateMultipleProductBundleSetting(patches: ProductBundleSettingPatch[], context: ResolverContext): Promise<ProductBundleSetting[]>;
|
|
6
|
+
deleteProductBundleSetting(id: string, context: ResolverContext): Promise<Boolean>;
|
|
7
|
+
deleteProductBundleSettings(ids: string[], context: ResolverContext): Promise<Boolean>;
|
|
8
|
+
linkProductBundle(productBundleId: string, patches: ProductBundleSettingPatch[], context: ResolverContext): Promise<Boolean>;
|
|
9
|
+
}
|
|
10
|
+
export declare function updateMultipleProductBundleSetting(patches: ProductBundleSettingPatch[], tx?: EntityManager): Promise<ProductBundleSetting[]>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ProductBundleSettingMutation = void 0;
|
|
4
|
+
exports.updateMultipleProductBundleSetting = updateMultipleProductBundleSetting;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const type_graphql_1 = require("type-graphql");
|
|
6
7
|
const typeorm_1 = require("typeorm");
|
|
@@ -91,6 +92,7 @@ let ProductBundleSettingMutation = class ProductBundleSettingMutation {
|
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
};
|
|
95
|
+
exports.ProductBundleSettingMutation = ProductBundleSettingMutation;
|
|
94
96
|
tslib_1.__decorate([
|
|
95
97
|
(0, type_graphql_1.Mutation)(returns => [product_bundle_setting_1.ProductBundleSetting]),
|
|
96
98
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [product_bundle_setting_types_1.ProductBundleSettingPatch])),
|
|
@@ -125,10 +127,9 @@ tslib_1.__decorate([
|
|
|
125
127
|
tslib_1.__metadata("design:paramtypes", [String, Array, Object]),
|
|
126
128
|
tslib_1.__metadata("design:returntype", Promise)
|
|
127
129
|
], ProductBundleSettingMutation.prototype, "linkProductBundle", null);
|
|
128
|
-
ProductBundleSettingMutation = tslib_1.__decorate([
|
|
130
|
+
exports.ProductBundleSettingMutation = ProductBundleSettingMutation = tslib_1.__decorate([
|
|
129
131
|
(0, type_graphql_1.Resolver)(product_bundle_setting_1.ProductBundleSetting)
|
|
130
132
|
], ProductBundleSettingMutation);
|
|
131
|
-
exports.ProductBundleSettingMutation = ProductBundleSettingMutation;
|
|
132
133
|
async function updateMultipleProductBundleSetting(patches, tx) {
|
|
133
134
|
let results = [];
|
|
134
135
|
const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
|
|
@@ -151,5 +152,4 @@ async function updateMultipleProductBundleSetting(patches, tx) {
|
|
|
151
152
|
}
|
|
152
153
|
return results;
|
|
153
154
|
}
|
|
154
|
-
exports.updateMultipleProductBundleSetting = updateMultipleProductBundleSetting;
|
|
155
155
|
//# sourceMappingURL=product-bundle-setting-mutation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-bundle-setting-mutation.js","sourceRoot":"","sources":["../../../server/service/product-bundle-setting/product-bundle-setting-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA+D;AAE/D,iDAAqD;AAErD,qEAA+D;AAC/D,iFAA0E;AAE1E,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,2CAA2C,CAAC,CAAA;AAGpE,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAEjC,AAAN,KAAK,CAAC,kCAAkC,CACe,OAAoC,EAClF,OAAwB;QAE/B,OAAO,MAAM,kCAAkC,CAAC,OAAO,CAAC,CAAA;IAC1D,CAAC;IAGK,AAAN,KAAK,CAAC,0BAA0B,CAAY,EAAU,EAAS,OAAwB;QACrF,MAAM,IAAA,qBAAa,EAAC,6CAAoB,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;QAExD,OAAO,IAAI,CAAA;IACb,CAAC;IAGK,AAAN,KAAK,CAAC,2BAA2B,CACD,GAAa,EACpC,OAAwB;QAE/B,MAAM,IAAA,qBAAa,EAAC,6CAAoB,CAAC,CAAC,MAAM,CAAC;YAC/C,OAAO,EAAE,IAAA,YAAE,EAAC,GAAG,CAAC;SACjB,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;IAIK,AAAN,KAAK,CAAC,iBAAiB,CACG,eAAuB,EACM,OAAoC,EAClF,OAAwB;QAE/B,IAAI;YACF,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YAEpC,yGAAyG;YACzG,+CAA+C;YAC/C,6DAA6D;YA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AAA;YACnC,MAAM,oBAAoB,GAAG,MAAM,wBAAwB,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAA;YAE3F,MAAM,MAAM,GAAG,MAAM,wBAAwB,CAAC,IAAI,iCAC7C,oBAAoB,GACpB,SAAS,EACZ,CAAA;YAEF,OAAO,CAAC,IAAI,iCAAM,MAAM,KAAE,MAAM,EAAE,GAAG,IAAG,CAAA;SACzC;KACF;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AApCD,gFAoCC","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { EntityManager, In, SelectQueryBuilder } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { ProductBundleSetting } from './product-bundle-setting'\nimport { ProductBundleSettingPatch } from './product-bundle-setting-types'\n\nconst debug = require('debug')('things-factory:product-base:productBundle')\n\n@Resolver(ProductBundleSetting)\nexport class ProductBundleSettingMutation {\n @Mutation(returns => [ProductBundleSetting])\n async updateMultipleProductBundleSetting(\n @Arg('patches', type => [ProductBundleSettingPatch]) patches: ProductBundleSettingPatch[],\n @Ctx() context: ResolverContext\n ): Promise<ProductBundleSetting[]> {\n return await updateMultipleProductBundleSetting(patches)\n }\n\n @Mutation(returns => Boolean)\n async deleteProductBundleSetting(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n await getRepository(ProductBundleSetting).delete({ id })\n\n return true\n }\n\n @Mutation(returns => Boolean)\n async deleteProductBundleSettings(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n await getRepository(ProductBundleSetting).delete({\n product: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async linkProductBundle(\n @Arg('productBundleId') productBundleId: string,\n @Arg('patches', type => [ProductBundleSettingPatch]) patches: ProductBundleSettingPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n try {\n const { domain, tx } = context.state\n\n // const existingBundleLink: ProductBundleSetting[] = await tx.getRepository(ProductBundleSetting).find({\n // where: { productBundle: productBundleId },\n // relations: ['product', 'productDetail', 'productBundle']\n // })\n\n const qb: SelectQueryBuilder<ProductBundleSetting> = tx\n .getRepository(ProductBundleSetting)\n .createQueryBuilder('pbs')\n .innerJoinAndSelect('pbs.product', 'prd')\n .innerJoinAndSelect('pbs.productDetail', 'pd')\n .innerJoinAndSelect('pbs.productBundle', 'pb')\n .where('pb.id = :productBundleId', { productBundleId })\n .andWhere('pb.domain_id = :domainId', { domainId: domain.id })\n\n const existingBundleLink = await qb.getMany()\n\n let newBundleLink: ProductBundleSetting[] = patches.reduce((acc, curr) => {\n if (\n !existingBundleLink.find(\n item => item.product.id === curr.product.id && item.productDetail.id === curr.productDetail.id\n )\n ) {\n acc.push({\n productBundle: { id: productBundleId },\n product: { id: curr.product.id },\n productDetail: { id: curr.productDetail.id },\n bundleQty: curr.bundleQty,\n cuFlag: '+'\n })\n }\n // check if there is existing bundle link but changes in bundle qty\n else if (\n existingBundleLink.find(\n item =>\n item.product.id === curr.product.id &&\n item.productDetail.id === curr.productDetail.id &&\n item.bundleQty !== curr.bundleQty\n )\n ) {\n acc.push({\n id: curr.id,\n productBundle: { id: productBundleId },\n product: { id: curr.product.id },\n productDetail: { id: curr.productDetail.id },\n bundleQty: curr.bundleQty,\n cuFlag: 'M'\n })\n }\n return acc\n }, [])\n\n let removeBundleLink: ProductBundleSetting[] = existingBundleLink.reduce((acc, curr) => {\n if (!patches.find(item => item.id == curr.id)) {\n acc.push({\n id: curr.id,\n productBundle: { id: productBundleId },\n product: { id: curr.product.id },\n productDetail: { id: curr.productDetail.id },\n bundleQty: curr.bundleQty\n })\n }\n return acc\n }, [])\n\n if (newBundleLink.length > 0) {\n await updateMultipleProductBundleSetting(newBundleLink, tx)\n }\n\n if (removeBundleLink.length > 0) {\n await tx.getRepository(ProductBundleSetting).delete({\n id: In(removeBundleLink.map(bundleLink => bundleLink.id))\n })\n }\n\n return true\n } catch (error) {\n debug('link-product-bundle', error)\n throw error\n }\n }\n}\n\nexport async function updateMultipleProductBundleSetting(\n patches: ProductBundleSettingPatch[],\n tx?: EntityManager\n): Promise<ProductBundleSetting[]> {\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const productBundleSettingRepo = tx.getRepository(ProductBundleSetting)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await productBundleSettingRepo.save({\n ...newRecord\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const productBundleSetting = await productBundleSettingRepo.findOneBy({ id: newRecord.id })\n\n const result = await productBundleSettingRepo.save({\n ...productBundleSetting,\n ...newRecord\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n}\n"]}
|
|
1
|
+
{"version":3,"file":"product-bundle-setting-mutation.js","sourceRoot":"","sources":["../../../server/service/product-bundle-setting/product-bundle-setting-mutation.ts"],"names":[],"mappings":";;;AAmIA,gFAoCC;;AAvKD,+CAAsE;AACtE,qCAA+D;AAE/D,iDAAqD;AAErD,qEAA+D;AAC/D,iFAA0E;AAE1E,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,2CAA2C,CAAC,CAAA;AAGpE,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAEjC,AAAN,KAAK,CAAC,kCAAkC,CACe,OAAoC,EAClF,OAAwB;QAE/B,OAAO,MAAM,kCAAkC,CAAC,OAAO,CAAC,CAAA;IAC1D,CAAC;IAGK,AAAN,KAAK,CAAC,0BAA0B,CAAY,EAAU,EAAS,OAAwB;QACrF,MAAM,IAAA,qBAAa,EAAC,6CAAoB,CAAC,CAAC,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a,CAAC,6CAAoB,CAAC,CAAA;IAEvE,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/C,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;YAEnC,MAAM,MAAM,GAAG,MAAM,wBAAwB,CAAC,IAAI,mBAC7C,SAAS,EACZ,CAAA;YAEF,OAAO,CAAC,IAAI,iCAAM,MAAM,KAAE,MAAM,EAAE,GAAG,IAAG,CAAA;QAC1C,CAAC;IACH,CAAC;IAED,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/C,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;YACnC,MAAM,oBAAoB,GAAG,MAAM,wBAAwB,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAA;YAE3F,MAAM,MAAM,GAAG,MAAM,wBAAwB,CAAC,IAAI,iCAC7C,oBAAoB,GACpB,SAAS,EACZ,CAAA;YAEF,OAAO,CAAC,IAAI,iCAAM,MAAM,KAAE,MAAM,EAAE,GAAG,IAAG,CAAA;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { EntityManager, In, SelectQueryBuilder } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { ProductBundleSetting } from './product-bundle-setting'\nimport { ProductBundleSettingPatch } from './product-bundle-setting-types'\n\nconst debug = require('debug')('things-factory:product-base:productBundle')\n\n@Resolver(ProductBundleSetting)\nexport class ProductBundleSettingMutation {\n @Mutation(returns => [ProductBundleSetting])\n async updateMultipleProductBundleSetting(\n @Arg('patches', type => [ProductBundleSettingPatch]) patches: ProductBundleSettingPatch[],\n @Ctx() context: ResolverContext\n ): Promise<ProductBundleSetting[]> {\n return await updateMultipleProductBundleSetting(patches)\n }\n\n @Mutation(returns => Boolean)\n async deleteProductBundleSetting(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n await getRepository(ProductBundleSetting).delete({ id })\n\n return true\n }\n\n @Mutation(returns => Boolean)\n async deleteProductBundleSettings(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n await getRepository(ProductBundleSetting).delete({\n product: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async linkProductBundle(\n @Arg('productBundleId') productBundleId: string,\n @Arg('patches', type => [ProductBundleSettingPatch]) patches: ProductBundleSettingPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n try {\n const { domain, tx } = context.state\n\n // const existingBundleLink: ProductBundleSetting[] = await tx.getRepository(ProductBundleSetting).find({\n // where: { productBundle: productBundleId },\n // relations: ['product', 'productDetail', 'productBundle']\n // })\n\n const qb: SelectQueryBuilder<ProductBundleSetting> = tx\n .getRepository(ProductBundleSetting)\n .createQueryBuilder('pbs')\n .innerJoinAndSelect('pbs.product', 'prd')\n .innerJoinAndSelect('pbs.productDetail', 'pd')\n .innerJoinAndSelect('pbs.productBundle', 'pb')\n .where('pb.id = :productBundleId', { productBundleId })\n .andWhere('pb.domain_id = :domainId', { domainId: domain.id })\n\n const existingBundleLink = await qb.getMany()\n\n let newBundleLink: ProductBundleSetting[] = patches.reduce((acc, curr) => {\n if (\n !existingBundleLink.find(\n item => item.product.id === curr.product.id && item.productDetail.id === curr.productDetail.id\n )\n ) {\n acc.push({\n productBundle: { id: productBundleId },\n product: { id: curr.product.id },\n productDetail: { id: curr.productDetail.id },\n bundleQty: curr.bundleQty,\n cuFlag: '+'\n })\n }\n // check if there is existing bundle link but changes in bundle qty\n else if (\n existingBundleLink.find(\n item =>\n item.product.id === curr.product.id &&\n item.productDetail.id === curr.productDetail.id &&\n item.bundleQty !== curr.bundleQty\n )\n ) {\n acc.push({\n id: curr.id,\n productBundle: { id: productBundleId },\n product: { id: curr.product.id },\n productDetail: { id: curr.productDetail.id },\n bundleQty: curr.bundleQty,\n cuFlag: 'M'\n })\n }\n return acc\n }, [])\n\n let removeBundleLink: ProductBundleSetting[] = existingBundleLink.reduce((acc, curr) => {\n if (!patches.find(item => item.id == curr.id)) {\n acc.push({\n id: curr.id,\n productBundle: { id: productBundleId },\n product: { id: curr.product.id },\n productDetail: { id: curr.productDetail.id },\n bundleQty: curr.bundleQty\n })\n }\n return acc\n }, [])\n\n if (newBundleLink.length > 0) {\n await updateMultipleProductBundleSetting(newBundleLink, tx)\n }\n\n if (removeBundleLink.length > 0) {\n await tx.getRepository(ProductBundleSetting).delete({\n id: In(removeBundleLink.map(bundleLink => bundleLink.id))\n })\n }\n\n return true\n } catch (error) {\n debug('link-product-bundle', error)\n throw error\n }\n }\n}\n\nexport async function updateMultipleProductBundleSetting(\n patches: ProductBundleSettingPatch[],\n tx?: EntityManager\n): Promise<ProductBundleSetting[]> {\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const productBundleSettingRepo = tx.getRepository(ProductBundleSetting)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await productBundleSettingRepo.save({\n ...newRecord\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const productBundleSetting = await productBundleSettingRepo.findOneBy({ id: newRecord.id })\n\n const result = await productBundleSettingRepo.save({\n ...productBundleSetting,\n ...newRecord\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ListParam } from '@things-factory/shell';
|
|
2
|
+
import { ProductBundleSettingList } from './product-bundle-setting-types';
|
|
3
|
+
export declare class ProductBundleSettingQuery {
|
|
4
|
+
productBundleSettings(params: ListParam, context: ResolverContext): Promise<ProductBundleSettingList>;
|
|
5
|
+
productBundleSets(params: ListParam, context: ResolverContext): Promise<ProductBundleSettingList>;
|
|
6
|
+
}
|
|
@@ -76,6 +76,7 @@ let ProductBundleSettingQuery = class ProductBundleSettingQuery {
|
|
|
76
76
|
return { items, total };
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
+
exports.ProductBundleSettingQuery = ProductBundleSettingQuery;
|
|
79
80
|
tslib_1.__decorate([
|
|
80
81
|
(0, type_graphql_1.Query)(returns => product_bundle_setting_types_1.ProductBundleSettingList),
|
|
81
82
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
@@ -92,8 +93,7 @@ tslib_1.__decorate([
|
|
|
92
93
|
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
93
94
|
tslib_1.__metadata("design:returntype", Promise)
|
|
94
95
|
], ProductBundleSettingQuery.prototype, "productBundleSets", null);
|
|
95
|
-
ProductBundleSettingQuery = tslib_1.__decorate([
|
|
96
|
+
exports.ProductBundleSettingQuery = ProductBundleSettingQuery = tslib_1.__decorate([
|
|
96
97
|
(0, type_graphql_1.Resolver)(product_bundle_setting_1.ProductBundleSetting)
|
|
97
98
|
], ProductBundleSettingQuery);
|
|
98
|
-
exports.ProductBundleSettingQuery = ProductBundleSettingQuery;
|
|
99
99
|
//# sourceMappingURL=product-bundle-setting-query.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-bundle-setting-query.js","sourceRoot":"","sources":["../../../server/service/product-bundle-setting/product-bundle-setting-query.ts"],"names":[],"mappings":";;;;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,GAAG,OAAO,CAAC,CAAA;QAE7B,MAAM,CAAC,QAAQ,GAAG;YAChB,EAAE,IAAI,EAAE,SAAS,EAAE;YACnB,EAAE,IAAI,EAAE,aAAa,EAAE;YACvB,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;gBAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;gBAC9D,uCACK,OAAO,KACV,IAAI,IACL;YACH,CAAC,CAAC;SACH,CAAA;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,aAAa,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"product-bundle-setting-query.js","sourceRoot":"","sources":["../../../server/service/product-bundle-setting/product-bundle-setting-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAyD;AACzD,qCAAsD;AAEtD,uDAAmD;AACnD,iDAA+G;AAE/G,gDAA4C;AAC5C,qEAA+D;AAC/D,iFAAyE;AAGlE,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAE9B,AAAN,KAAK,CAAC,qBAAqB,CACjB,MAAiB,EAClB,OAAwB;QAE/B,MAAM,eAAe,GAAG,IAAA,yBAAiB,EAAC,MAAM,CAAC,CAAA;QACjD,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,IAAA,qBAAa,EAAC,6CAAoB,CAAC,CAAC,YAAY,mBACxE,eAAe,EAClB,CAAA;QAEF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAGK,AAAN,KAAK,CAAC,iBAAiB,CACb,MAAiB,EAClB,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI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,CAAC;IAExC,mBAAA,IAAA,mBAAI,GAAE,CAAA;IACN,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CADU,iBAAS;;kEA8G1B;oCA9HU,yBAAyB;IADrC,IAAA,uBAAQ,EAAC,6CAAoB,CAAC;GAClB,yBAAyB,CA+HrC","sourcesContent":["import { Args, Ctx, Query, Resolver } from 'type-graphql'\nimport { Brackets, SelectQueryBuilder } from 'typeorm'\n\nimport { Bizplace } from '@things-factory/biz-base'\nimport { buildCondition, buildQuery, convertListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Product } from '../product/product'\nimport { ProductBundleSetting } from './product-bundle-setting'\nimport { ProductBundleSettingList } from './product-bundle-setting-types'\n\n@Resolver(ProductBundleSetting)\nexport class ProductBundleSettingQuery {\n @Query(returns => ProductBundleSettingList)\n async productBundleSettings(\n @Args() params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<ProductBundleSettingList> {\n const convertedParams = convertListParams(params)\n const [items, total] = await getRepository(ProductBundleSetting).findAndCount({\n ...convertedParams\n })\n\n return { items, total }\n }\n\n @Query(returns => ProductBundleSettingList)\n async productBundleSets(\n @Args() params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<ProductBundleSettingList> {\n const { domain } = context.state\n const page = params.pagination.page\n const limit = params.pagination.limit\n\n const filters = params.filters.filter(x => x.name !== 'product_info' && x.name !== 'productBundleId')\n const productBundleId = params.filters.find(x => x.name === 'productBundleId')\n const productInfoFilter = params.filters.find(x => x.name === 'product_info')\n const productInfoColumns = ['sku', 'name', 'description']\n params.filters = [...filters]\n\n params.sortings = [\n { name: 'prd.sku' },\n { name: 'prdDet.gtin' },\n ...params.sortings.map(sorting => {\n const name = sorting.name.replace('product', '').toLowerCase()\n return {\n ...sorting,\n name\n }\n })\n ]\n\n if (!params.filters.find(filter => filter.name === 'bizplace_id')) {\n let bizplace: Bizplace = await getRepository(Bizplace).findOne({ where: { domain: { id: domain.id } } })\n params.filters = [...filters, { name: 'bizplace_id', operator: 'in', value: [bizplace.id] }]\n }\n\n const qb: SelectQueryBuilder<Product> = getRepository(Product).createQueryBuilder('prd')\n buildQuery(qb, params, context)\n\n qb.innerJoinAndSelect('product_details', 'prdDet', 'prdDet.product_id = prd.id')\n qb.leftJoinAndSelect(\n 'product_bundle_settings',\n 'pbs',\n 'pbs.product_id = prd.id and pbs.product_detail_id = prdDet.id'\n )\n qb.leftJoinAndSelect('pbs.productBundle', 'pb')\n\n if (productInfoFilter) {\n qb.andWhere(\n new Brackets(qb2 => {\n productInfoColumns.forEach(filter => {\n const condition = buildCondition(\n qb.alias,\n filter,\n productInfoFilter.operator,\n productInfoFilter.value,\n productInfoFilter.relation,\n Object.keys(qb.getParameters()).length\n )\n\n qb2.orWhere(condition.clause, condition.parameters)\n })\n })\n )\n }\n\n if (productBundleId && productBundleId.operator === 'eq') {\n qb.andWhere('pb.id = :bundleId::uuid', {\n bundleId: productBundleId.value\n })\n }\n\n let productBundleSets = await qb\n .offset((page - 1) * limit)\n .limit(limit)\n .getRawMany()\n\n const items = productBundleSets.map(item => {\n return {\n // id: item.pbs_id,\n // productDetailId: item.prdDet_id,\n // gtin: item.prdDet_gtin,\n // packingType: item.prdDet_packing_type,\n // packingSize: item.prdDet_packing_size,\n // productId: item.prd_id,\n // productSku: item.prd_sku,\n // productName: item.prd_name,\n // productDescription: item.prd_description,\n // productType: item.prd_type,\n // bundleId: item.pb_id,\n // bundleSku: item.pb_sku,\n // bundleName: item.pb_name,\n // bundleDescription: item.pb_description,\n // bundleQty: item.pbs_bundle_qty\n ...item,\n id: item.pbs_id,\n product: {\n id: item.prd_id,\n sku: item.prd_sku,\n name: item.prd_name,\n description: item.prd_description,\n type: item.prd_type\n },\n productDetail: {\n id: item.prdDet_id,\n gtin: item.prdDet_gtin,\n packingType: item.prdDet_packing_type,\n packingSize: item.prdDet_packing_size\n },\n bundleQty: item.pbs_bundle_qty\n }\n })\n\n const total = await qb.getCount()\n\n return { items, total }\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ObjectRef } from '@things-factory/shell';
|
|
2
|
+
import { ProductBundleSetting } from './product-bundle-setting';
|
|
3
|
+
export declare class ProductBundleSettingList {
|
|
4
|
+
items?: ProductBundleSetting[];
|
|
5
|
+
total?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class ProductBundleSettingPatch {
|
|
8
|
+
id?: string;
|
|
9
|
+
product?: ObjectRef;
|
|
10
|
+
productDetail?: ObjectRef;
|
|
11
|
+
productBundle?: ObjectRef;
|
|
12
|
+
bundleQty?: number;
|
|
13
|
+
packingType?: string;
|
|
14
|
+
packingSize?: number;
|
|
15
|
+
cuFlag?: string;
|
|
16
|
+
}
|
|
@@ -7,6 +7,7 @@ const shell_1 = require("@things-factory/shell");
|
|
|
7
7
|
const product_bundle_setting_1 = require("./product-bundle-setting");
|
|
8
8
|
let ProductBundleSettingList = class ProductBundleSettingList {
|
|
9
9
|
};
|
|
10
|
+
exports.ProductBundleSettingList = ProductBundleSettingList;
|
|
10
11
|
tslib_1.__decorate([
|
|
11
12
|
(0, type_graphql_1.Field)(type => [product_bundle_setting_1.ProductBundleSetting], { nullable: true }),
|
|
12
13
|
tslib_1.__metadata("design:type", Array)
|
|
@@ -15,12 +16,12 @@ tslib_1.__decorate([
|
|
|
15
16
|
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
|
|
16
17
|
tslib_1.__metadata("design:type", Number)
|
|
17
18
|
], ProductBundleSettingList.prototype, "total", void 0);
|
|
18
|
-
ProductBundleSettingList = tslib_1.__decorate([
|
|
19
|
+
exports.ProductBundleSettingList = ProductBundleSettingList = tslib_1.__decorate([
|
|
19
20
|
(0, type_graphql_1.ObjectType)()
|
|
20
21
|
], ProductBundleSettingList);
|
|
21
|
-
exports.ProductBundleSettingList = ProductBundleSettingList;
|
|
22
22
|
let ProductBundleSettingPatch = class ProductBundleSettingPatch {
|
|
23
23
|
};
|
|
24
|
+
exports.ProductBundleSettingPatch = ProductBundleSettingPatch;
|
|
24
25
|
tslib_1.__decorate([
|
|
25
26
|
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
|
|
26
27
|
tslib_1.__metadata("design:type", String)
|
|
@@ -53,8 +54,7 @@ tslib_1.__decorate([
|
|
|
53
54
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
54
55
|
tslib_1.__metadata("design:type", String)
|
|
55
56
|
], ProductBundleSettingPatch.prototype, "cuFlag", void 0);
|
|
56
|
-
ProductBundleSettingPatch = tslib_1.__decorate([
|
|
57
|
+
exports.ProductBundleSettingPatch = ProductBundleSettingPatch = tslib_1.__decorate([
|
|
57
58
|
(0, type_graphql_1.InputType)()
|
|
58
59
|
], ProductBundleSettingPatch);
|
|
59
|
-
exports.ProductBundleSettingPatch = ProductBundleSettingPatch;
|
|
60
60
|
//# sourceMappingURL=product-bundle-setting-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-bundle-setting-types.js","sourceRoot":"","sources":["../../../server/service/product-bundle-setting/product-bundle-setting-types.ts"],"names":[],"mappings":";;;;AAAA,+CAA2E;AAE3E,iDAAiD;AAEjD,qEAA+D;AAGxD,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;CAMpC,CAAA;
|
|
1
|
+
{"version":3,"file":"product-bundle-setting-types.js","sourceRoot":"","sources":["../../../server/service/product-bundle-setting/product-bundle-setting-types.ts"],"names":[],"mappings":";;;;AAAA,+CAA2E;AAE3E,iDAAiD;AAEjD,qEAA+D;AAGxD,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;CAMpC,CAAA;AANY,4DAAwB;AAEnC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,6CAAoB,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uDAC5B;AAG9B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uDACzB;mCALH,wBAAwB;IADpC,IAAA,yBAAU,GAAE;GACA,wBAAwB,CAMpC;AAGM,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;CAwBrC,CAAA;AAxBY,8DAAyB;AAEpC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDAC3B;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAChB,iBAAS;0DAAA;AAGnB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACV,iBAAS;gEAAA;AAGzB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACV,iBAAS;gEAAA;AAGzB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4DACrB;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8DACN;AAGpB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8DACrB;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yDACX;oCAvBJ,yBAAyB;IADrC,IAAA,wBAAS,GAAE;GACC,yBAAyB,CAwBrC","sourcesContent":["import { Field, Float, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { ObjectRef } from '@things-factory/shell'\n\nimport { ProductBundleSetting } from './product-bundle-setting'\n\n@ObjectType()\nexport class ProductBundleSettingList {\n @Field(type => [ProductBundleSetting], { nullable: true })\n items?: ProductBundleSetting[]\n\n @Field(type => Int, { nullable: true })\n total?: number\n}\n\n@InputType()\nexport class ProductBundleSettingPatch {\n @Field(type => ID, { nullable: true })\n id?: string\n\n @Field({ nullable: true })\n product?: ObjectRef\n\n @Field({ nullable: true })\n productDetail?: ObjectRef\n\n @Field({ nullable: true })\n productBundle?: ObjectRef\n\n @Field(type => Int, { nullable: true })\n bundleQty?: number\n\n @Field({ nullable: true })\n packingType?: string\n\n @Field(type => Float, { nullable: true })\n packingSize?: number\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ProductBundle } from '../product-bundle/product-bundle';
|
|
2
|
+
import { ProductDetail } from '../product-detail/product-detail';
|
|
3
|
+
import { Product } from '../product/product';
|
|
4
|
+
export declare class ProductBundleSetting {
|
|
5
|
+
readonly id?: string;
|
|
6
|
+
product?: Product;
|
|
7
|
+
productDetail?: ProductDetail;
|
|
8
|
+
productBundle?: ProductBundle;
|
|
9
|
+
bundleQty?: number;
|
|
10
|
+
productId?: string;
|
|
11
|
+
bundleId?: string;
|
|
12
|
+
}
|
|
@@ -9,6 +9,7 @@ const product_detail_1 = require("../product-detail/product-detail");
|
|
|
9
9
|
const product_1 = require("../product/product");
|
|
10
10
|
let ProductBundleSetting = class ProductBundleSetting {
|
|
11
11
|
};
|
|
12
|
+
exports.ProductBundleSetting = ProductBundleSetting;
|
|
12
13
|
tslib_1.__decorate([
|
|
13
14
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
14
15
|
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
|
|
@@ -42,7 +43,7 @@ tslib_1.__decorate([
|
|
|
42
43
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
43
44
|
tslib_1.__metadata("design:type", String)
|
|
44
45
|
], ProductBundleSetting.prototype, "bundleId", void 0);
|
|
45
|
-
ProductBundleSetting = tslib_1.__decorate([
|
|
46
|
+
exports.ProductBundleSetting = ProductBundleSetting = tslib_1.__decorate([
|
|
46
47
|
(0, typeorm_1.Entity)(),
|
|
47
48
|
(0, typeorm_1.Index)('ix_product_bundle_setting_0', (productBundleSetting) => [
|
|
48
49
|
productBundleSetting.product,
|
|
@@ -51,5 +52,4 @@ ProductBundleSetting = tslib_1.__decorate([
|
|
|
51
52
|
], { unique: true }),
|
|
52
53
|
(0, type_graphql_1.ObjectType)()
|
|
53
54
|
], ProductBundleSetting);
|
|
54
|
-
exports.ProductBundleSetting = ProductBundleSetting;
|
|
55
55
|
//# sourceMappingURL=product-bundle-setting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-bundle-setting.js","sourceRoot":"","sources":["../../../server/service/product-bundle-setting/product-bundle-setting.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCAAkF;AAElF,qEAAgE;AAChE,qEAAgE;AAChE,gDAA4C;AAarC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CA0BhC,CAAA;
|
|
1
|
+
{"version":3,"file":"product-bundle-setting.js","sourceRoot":"","sources":["../../../server/service/product-bundle-setting/product-bundle-setting.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCAAkF;AAElF,qEAAgE;AAChE,qEAAgE;AAChE,gDAA4C;AAarC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CA0BhC,CAAA;AA1BY,oDAAoB;AAGtB;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDAClB;AAIpB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC9C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjC,iBAAO;qDAAA;AAIjB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACpD,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjC,8BAAa;2DAAA;AAI7B;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACpD,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjC,8BAAa;2DAAA;AAI7B;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uDACR;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uDACR;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sDACT;+BAzBN,oBAAoB;IAXhC,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EACJ,6BAA6B,EAC7B,CAAC,oBAA0C,EAAE,EAAE,CAAC;QAC9C,oBAAoB,CAAC,OAAO;QAC5B,oBAAoB,CAAC,aAAa;QAClC,oBAAoB,CAAC,aAAa;KACnC,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,GAAE;GACA,oBAAoB,CA0BhC","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'\n\nimport { ProductBundle } from '../product-bundle/product-bundle'\nimport { ProductDetail } from '../product-detail/product-detail'\nimport { Product } from '../product/product'\n\n@Entity()\n@Index(\n 'ix_product_bundle_setting_0',\n (productBundleSetting: ProductBundleSetting) => [\n productBundleSetting.product,\n productBundleSetting.productDetail,\n productBundleSetting.productBundle\n ],\n { unique: true }\n)\n@ObjectType()\nexport class ProductBundleSetting {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { nullable: true })\n readonly id?: string\n\n @ManyToOne(type => Product, { nullable: true })\n @Field(type => Product, { nullable: true })\n product?: Product\n\n @ManyToOne(type => ProductDetail, { nullable: true })\n @Field(type => ProductDetail, { nullable: true })\n productDetail?: ProductDetail\n\n @ManyToOne(type => ProductBundle, { nullable: true })\n @Field(type => ProductBundle, { nullable: true })\n productBundle?: ProductBundle\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n bundleQty?: number\n\n @Field({ nullable: true })\n productId?: string\n\n @Field({ nullable: true })\n bundleId?: string\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ProductCombination } from './product-combination';
|
|
2
|
+
import { ProductCombinationQuery } from './product-combination-query';
|
|
3
|
+
import { ProductCombinationMutation } from './product-combination-mutation';
|
|
4
|
+
export declare const entities: (typeof ProductCombination)[];
|
|
5
|
+
export declare const resolvers: (typeof ProductCombinationQuery | typeof ProductCombinationMutation)[];
|