@things-factory/operato-hub 5.0.13 → 6.0.0-alpha.1

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.
Files changed (217) hide show
  1. package/dist-server/controllers/bizplace-initializer/dataset/codes.js +9 -0
  2. package/dist-server/controllers/bizplace-initializer/dataset/codes.js.map +1 -1
  3. package/dist-server/controllers/bizplace-initializer/dataset/settings.js +5 -0
  4. package/dist-server/controllers/bizplace-initializer/dataset/settings.js.map +1 -1
  5. package/dist-server/controllers/bizplace-initializer/generate-bizplace-domain-roles.js +3 -3
  6. package/dist-server/controllers/bizplace-initializer/generate-bizplace-domain-roles.js.map +1 -1
  7. package/dist-server/controllers/bizplace-initializer/generate-bizplace-domain.js +2 -2
  8. package/dist-server/controllers/bizplace-initializer/generate-bizplace-domain.js.map +1 -1
  9. package/dist-server/controllers/bizplace-initializer/menus.js +2 -2
  10. package/dist-server/controllers/bizplace-initializer/menus.js.map +1 -1
  11. package/dist-server/controllers/company-initializer/business-register.js +6 -7
  12. package/dist-server/controllers/company-initializer/business-register.js.map +1 -1
  13. package/dist-server/controllers/company-initializer/generate-company-roles.js +4 -4
  14. package/dist-server/controllers/company-initializer/generate-company-roles.js.map +1 -1
  15. package/dist-server/controllers/invitation.js +9 -9
  16. package/dist-server/controllers/invitation.js.map +1 -1
  17. package/dist-server/controllers/utils/save-invitation-token.js +2 -2
  18. package/dist-server/controllers/utils/save-invitation-token.js.map +1 -1
  19. package/dist-server/graphql/resolvers/generators/generate-bizplace.js.map +1 -1
  20. package/dist-server/graphql/resolvers/generators/generate-company.js +4 -3
  21. package/dist-server/graphql/resolvers/generators/generate-company.js.map +1 -1
  22. package/dist-server/graphql/resolvers/generators/update-domain-extType.js +1 -1
  23. package/dist-server/graphql/resolvers/generators/update-domain-extType.js.map +1 -1
  24. package/dist-server/graphql/resolvers/invitations/partner-invitation.js +6 -6
  25. package/dist-server/graphql/resolvers/invitations/partner-invitation.js.map +1 -1
  26. package/dist-server/graphql/resolvers/oauth2/company-roles-by-scope.js +5 -2
  27. package/dist-server/graphql/resolvers/oauth2/company-roles-by-scope.js.map +1 -1
  28. package/dist-server/graphql/resolvers/synchronization/auto-update-all-marketplace-product-variation-quantity.js +149 -0
  29. package/dist-server/graphql/resolvers/synchronization/auto-update-all-marketplace-product-variation-quantity.js.map +1 -0
  30. package/dist-server/graphql/resolvers/synchronization/create-dat-shipments.js +58 -0
  31. package/dist-server/graphql/resolvers/synchronization/create-dat-shipments.js.map +1 -0
  32. package/dist-server/graphql/resolvers/synchronization/fetch-sync-products.js +3 -3
  33. package/dist-server/graphql/resolvers/synchronization/fetch-sync-products.js.map +1 -1
  34. package/dist-server/graphql/resolvers/synchronization/index.js +6 -2
  35. package/dist-server/graphql/resolvers/synchronization/index.js.map +1 -1
  36. package/dist-server/graphql/resolvers/synchronization/sellercraft-pack-marketplace-order.js +68 -0
  37. package/dist-server/graphql/resolvers/synchronization/sellercraft-pack-marketplace-order.js.map +1 -0
  38. package/dist-server/graphql/resolvers/synchronization/sync-all-products-to-sellercraft.js +35 -0
  39. package/dist-server/graphql/resolvers/synchronization/sync-all-products-to-sellercraft.js.map +1 -0
  40. package/dist-server/graphql/resolvers/synchronization/sync-products-from-account.js +1 -1
  41. package/dist-server/graphql/resolvers/synchronization/sync-products-from-account.js.map +1 -1
  42. package/dist-server/graphql/resolvers/synchronization/sync-products-to-account.js +1 -1
  43. package/dist-server/graphql/resolvers/synchronization/sync-products-to-account.js.map +1 -1
  44. package/dist-server/graphql/resolvers/synchronization/sync-products-to-sellercraft.js +4 -2
  45. package/dist-server/graphql/resolvers/synchronization/sync-products-to-sellercraft.js.map +1 -1
  46. package/dist-server/graphql/types/synchronization/index.js +4 -0
  47. package/dist-server/graphql/types/synchronization/index.js.map +1 -1
  48. package/dist-server/index.js +5 -5
  49. package/dist-server/index.js.map +1 -1
  50. package/dist-server/middlewares/business-middleware.js +2 -3
  51. package/dist-server/middlewares/business-middleware.js.map +1 -1
  52. package/dist-server/middlewares/store-middleware.js +2 -2
  53. package/dist-server/middlewares/store-middleware.js.map +1 -1
  54. package/dist-server/middlewares/warehouse-middleware.js +3 -2
  55. package/dist-server/middlewares/warehouse-middleware.js.map +1 -1
  56. package/dist-server/migrations/1597668478399-SeedBusinessDomain.js +2 -3
  57. package/dist-server/migrations/1597668478399-SeedBusinessDomain.js.map +1 -1
  58. package/dist-server/migrations/1597668478401-SeedBusinessRoles.js +2 -2
  59. package/dist-server/migrations/1597668478401-SeedBusinessRoles.js.map +1 -1
  60. package/dist-server/migrations/1608009991065-SeedUser.js +5 -6
  61. package/dist-server/migrations/1608009991065-SeedUser.js.map +1 -1
  62. package/dist-server/routers/api/restful-apis/unstable/add-draft-release-order.js +2 -1
  63. package/dist-server/routers/api/restful-apis/unstable/add-draft-release-order.js.map +1 -1
  64. package/dist-server/routers/api/restful-apis/unstable/add-inbound-order.js +5 -4
  65. package/dist-server/routers/api/restful-apis/unstable/add-inbound-order.js.map +1 -1
  66. package/dist-server/routers/api/restful-apis/unstable/add-marketplace-order.js +5 -2
  67. package/dist-server/routers/api/restful-apis/unstable/add-marketplace-order.js.map +1 -1
  68. package/dist-server/routers/api/restful-apis/unstable/add-products.js +32 -16
  69. package/dist-server/routers/api/restful-apis/unstable/add-products.js.map +1 -1
  70. package/dist-server/routers/api/restful-apis/unstable/add-release-order.js +149 -40
  71. package/dist-server/routers/api/restful-apis/unstable/add-release-order.js.map +1 -1
  72. package/dist-server/routers/api/restful-apis/unstable/cancel-release-order.js +4 -4
  73. package/dist-server/routers/api/restful-apis/unstable/cancel-release-order.js.map +1 -1
  74. package/dist-server/routers/api/restful-apis/unstable/get-delivery-orders.js +27 -11
  75. package/dist-server/routers/api/restful-apis/unstable/get-delivery-orders.js.map +1 -1
  76. package/dist-server/routers/api/restful-apis/unstable/get-goods-received-notes.js +9 -2
  77. package/dist-server/routers/api/restful-apis/unstable/get-goods-received-notes.js.map +1 -1
  78. package/dist-server/routers/api/restful-apis/unstable/get-onhand-inventories.js +2 -2
  79. package/dist-server/routers/api/restful-apis/unstable/get-onhand-inventories.js.map +1 -1
  80. package/dist-server/routers/api/restful-apis/unstable/get-partners.js +5 -4
  81. package/dist-server/routers/api/restful-apis/unstable/get-partners.js.map +1 -1
  82. package/dist-server/routers/api/restful-apis/unstable/get-products.js +1 -0
  83. package/dist-server/routers/api/restful-apis/unstable/get-products.js.map +1 -1
  84. package/dist-server/routers/api/restful-apis/unstable/get-warehouses.js +2 -2
  85. package/dist-server/routers/api/restful-apis/unstable/get-warehouses.js.map +1 -1
  86. package/dist-server/routers/api/restful-apis/unstable/update-release-order-details.js +2 -2
  87. package/dist-server/routers/api/restful-apis/unstable/update-release-order-details.js.map +1 -1
  88. package/dist-server/routers/api/restful-apis/v1/add-inbound-order.js +6 -5
  89. package/dist-server/routers/api/restful-apis/v1/add-inbound-order.js.map +1 -1
  90. package/dist-server/routers/api/restful-apis/v1/add-marketplace-order.js +8 -5
  91. package/dist-server/routers/api/restful-apis/v1/add-marketplace-order.js.map +1 -1
  92. package/dist-server/routers/api/restful-apis/v1/add-products.js +32 -16
  93. package/dist-server/routers/api/restful-apis/v1/add-products.js.map +1 -1
  94. package/dist-server/routers/api/restful-apis/v1/add-release-order.js +8 -6
  95. package/dist-server/routers/api/restful-apis/v1/add-release-order.js.map +1 -1
  96. package/dist-server/routers/api/restful-apis/v1/cancel-release-order.js +4 -4
  97. package/dist-server/routers/api/restful-apis/v1/cancel-release-order.js.map +1 -1
  98. package/dist-server/routers/api/restful-apis/v1/get-delivery-orders.js +27 -11
  99. package/dist-server/routers/api/restful-apis/v1/get-delivery-orders.js.map +1 -1
  100. package/dist-server/routers/api/restful-apis/v1/get-goods-received-notes.js +9 -2
  101. package/dist-server/routers/api/restful-apis/v1/get-goods-received-notes.js.map +1 -1
  102. package/dist-server/routers/api/restful-apis/v1/get-onhand-inventories.js +2 -2
  103. package/dist-server/routers/api/restful-apis/v1/get-onhand-inventories.js.map +1 -1
  104. package/dist-server/routers/api/restful-apis/v1/get-partners.js +5 -4
  105. package/dist-server/routers/api/restful-apis/v1/get-partners.js.map +1 -1
  106. package/dist-server/routers/api/restful-apis/v1/get-products.js +1 -0
  107. package/dist-server/routers/api/restful-apis/v1/get-products.js.map +1 -1
  108. package/dist-server/routers/api/restful-apis/v1/get-warehouses.js +2 -2
  109. package/dist-server/routers/api/restful-apis/v1/get-warehouses.js.map +1 -1
  110. package/dist-server/routers/api/restful-apis/v1/update-release-order-details.js +2 -2
  111. package/dist-server/routers/api/restful-apis/v1/update-release-order-details.js.map +1 -1
  112. package/dist-server/routers/api/restful-apis/v2/add-inbound-order.js +6 -5
  113. package/dist-server/routers/api/restful-apis/v2/add-inbound-order.js.map +1 -1
  114. package/dist-server/routers/api/restful-apis/v2/add-marketplace-order.js +8 -5
  115. package/dist-server/routers/api/restful-apis/v2/add-marketplace-order.js.map +1 -1
  116. package/dist-server/routers/api/restful-apis/v2/add-products.js +32 -16
  117. package/dist-server/routers/api/restful-apis/v2/add-products.js.map +1 -1
  118. package/dist-server/routers/api/restful-apis/v2/add-release-order.js +8 -6
  119. package/dist-server/routers/api/restful-apis/v2/add-release-order.js.map +1 -1
  120. package/dist-server/routers/api/restful-apis/v2/cancel-release-order.js +4 -4
  121. package/dist-server/routers/api/restful-apis/v2/cancel-release-order.js.map +1 -1
  122. package/dist-server/routers/api/restful-apis/v2/get-delivery-orders.js +27 -11
  123. package/dist-server/routers/api/restful-apis/v2/get-delivery-orders.js.map +1 -1
  124. package/dist-server/routers/api/restful-apis/v2/get-goods-received-notes.js +9 -2
  125. package/dist-server/routers/api/restful-apis/v2/get-goods-received-notes.js.map +1 -1
  126. package/dist-server/routers/api/restful-apis/v2/get-onhand-inventories.js +2 -2
  127. package/dist-server/routers/api/restful-apis/v2/get-onhand-inventories.js.map +1 -1
  128. package/dist-server/routers/api/restful-apis/v2/get-partners.js +5 -4
  129. package/dist-server/routers/api/restful-apis/v2/get-partners.js.map +1 -1
  130. package/dist-server/routers/api/restful-apis/v2/get-products.js +1 -0
  131. package/dist-server/routers/api/restful-apis/v2/get-products.js.map +1 -1
  132. package/dist-server/routers/api/restful-apis/v2/get-warehouses.js +2 -2
  133. package/dist-server/routers/api/restful-apis/v2/get-warehouses.js.map +1 -1
  134. package/dist-server/routers/api/restful-apis/v2/update-release-order-details.js +2 -2
  135. package/dist-server/routers/api/restful-apis/v2/update-release-order-details.js.map +1 -1
  136. package/dist-server/routers/auth-invitation-router.js +2 -2
  137. package/dist-server/routers/auth-invitation-router.js.map +1 -1
  138. package/dist-server/routers/business/bizplace-register-router.js +3 -3
  139. package/dist-server/routers/business/bizplace-register-router.js.map +1 -1
  140. package/dist-server/tsconfig.tsbuildinfo +1 -1
  141. package/dist-server/utils/get-warehouses.js +15 -11
  142. package/dist-server/utils/get-warehouses.js.map +1 -1
  143. package/openapi/unstable/product.yaml +9 -3
  144. package/openapi/v1/product.yaml +9 -3
  145. package/openapi/v2/product.yaml +9 -3
  146. package/package.json +47 -47
  147. package/server/controllers/bizplace-initializer/dataset/codes.ts +9 -0
  148. package/server/controllers/bizplace-initializer/dataset/settings.ts +5 -0
  149. package/server/controllers/bizplace-initializer/generate-bizplace-domain-roles.ts +4 -2
  150. package/server/controllers/bizplace-initializer/generate-bizplace-domain.ts +4 -3
  151. package/server/controllers/bizplace-initializer/menus.ts +4 -2
  152. package/server/controllers/company-initializer/business-register.ts +5 -3
  153. package/server/controllers/company-initializer/generate-company-roles.ts +4 -3
  154. package/server/controllers/invitation.ts +11 -7
  155. package/server/controllers/utils/save-invitation-token.ts +1 -1
  156. package/server/graphql/resolvers/generators/generate-bizplace.ts +1 -1
  157. package/server/graphql/resolvers/generators/generate-company.ts +5 -4
  158. package/server/graphql/resolvers/generators/update-domain-extType.ts +7 -5
  159. package/server/graphql/resolvers/invitations/partner-invitation.ts +5 -5
  160. package/server/graphql/resolvers/oauth2/company-roles-by-scope.ts +8 -6
  161. package/server/graphql/resolvers/synchronization/auto-update-all-marketplace-product-variation-quantity.ts +180 -0
  162. package/server/graphql/resolvers/synchronization/create-dat-shipments.ts +64 -0
  163. package/server/graphql/resolvers/synchronization/fetch-sync-products.ts +3 -2
  164. package/server/graphql/resolvers/synchronization/index.ts +10 -2
  165. package/server/graphql/resolvers/synchronization/sellercraft-pack-marketplace-order.ts +91 -0
  166. package/server/graphql/resolvers/synchronization/sync-all-products-to-sellercraft.ts +39 -0
  167. package/server/graphql/resolvers/synchronization/sync-products-from-account.ts +4 -4
  168. package/server/graphql/resolvers/synchronization/sync-products-to-account.ts +4 -4
  169. package/server/graphql/resolvers/synchronization/sync-products-to-sellercraft.ts +19 -12
  170. package/server/graphql/types/synchronization/index.ts +4 -0
  171. package/server/index.ts +7 -7
  172. package/server/middlewares/business-middleware.ts +1 -2
  173. package/server/middlewares/store-middleware.ts +1 -1
  174. package/server/middlewares/warehouse-middleware.ts +3 -2
  175. package/server/migrations/1597668478399-SeedBusinessDomain.ts +3 -2
  176. package/server/migrations/1597668478401-SeedBusinessRoles.ts +2 -2
  177. package/server/migrations/1608009991065-SeedUser.ts +5 -3
  178. package/server/routers/api/restful-apis/unstable/add-draft-release-order.ts +2 -1
  179. package/server/routers/api/restful-apis/unstable/add-inbound-order.ts +3 -2
  180. package/server/routers/api/restful-apis/unstable/add-marketplace-order.ts +13 -2
  181. package/server/routers/api/restful-apis/unstable/add-products.ts +40 -16
  182. package/server/routers/api/restful-apis/unstable/add-release-order.ts +98 -48
  183. package/server/routers/api/restful-apis/unstable/cancel-release-order.ts +2 -2
  184. package/server/routers/api/restful-apis/unstable/get-delivery-orders.ts +27 -11
  185. package/server/routers/api/restful-apis/unstable/get-goods-received-notes.ts +9 -2
  186. package/server/routers/api/restful-apis/unstable/get-onhand-inventories.ts +1 -1
  187. package/server/routers/api/restful-apis/unstable/get-partners.ts +4 -2
  188. package/server/routers/api/restful-apis/unstable/get-products.ts +1 -0
  189. package/server/routers/api/restful-apis/unstable/get-warehouses.ts +3 -2
  190. package/server/routers/api/restful-apis/unstable/update-release-order-details.ts +1 -1
  191. package/server/routers/api/restful-apis/v1/add-inbound-order.ts +4 -3
  192. package/server/routers/api/restful-apis/v1/add-marketplace-order.ts +17 -5
  193. package/server/routers/api/restful-apis/v1/add-products.ts +40 -16
  194. package/server/routers/api/restful-apis/v1/add-release-order.ts +10 -6
  195. package/server/routers/api/restful-apis/v1/cancel-release-order.ts +2 -2
  196. package/server/routers/api/restful-apis/v1/get-delivery-orders.ts +27 -11
  197. package/server/routers/api/restful-apis/v1/get-goods-received-notes.ts +9 -2
  198. package/server/routers/api/restful-apis/v1/get-onhand-inventories.ts +1 -1
  199. package/server/routers/api/restful-apis/v1/get-partners.ts +4 -2
  200. package/server/routers/api/restful-apis/v1/get-products.ts +1 -0
  201. package/server/routers/api/restful-apis/v1/get-warehouses.ts +3 -2
  202. package/server/routers/api/restful-apis/v1/update-release-order-details.ts +1 -1
  203. package/server/routers/api/restful-apis/v2/add-inbound-order.ts +4 -3
  204. package/server/routers/api/restful-apis/v2/add-marketplace-order.ts +17 -5
  205. package/server/routers/api/restful-apis/v2/add-products.ts +40 -16
  206. package/server/routers/api/restful-apis/v2/add-release-order.ts +10 -6
  207. package/server/routers/api/restful-apis/v2/cancel-release-order.ts +2 -2
  208. package/server/routers/api/restful-apis/v2/get-delivery-orders.ts +27 -11
  209. package/server/routers/api/restful-apis/v2/get-goods-received-notes.ts +9 -2
  210. package/server/routers/api/restful-apis/v2/get-onhand-inventories.ts +1 -1
  211. package/server/routers/api/restful-apis/v2/get-partners.ts +4 -2
  212. package/server/routers/api/restful-apis/v2/get-products.ts +1 -0
  213. package/server/routers/api/restful-apis/v2/get-warehouses.ts +3 -2
  214. package/server/routers/api/restful-apis/v2/update-release-order-details.ts +1 -1
  215. package/server/routers/auth-invitation-router.ts +2 -2
  216. package/server/routers/business/bizplace-register-router.ts +3 -1
  217. package/server/utils/get-warehouses.ts +46 -36
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.syncAllProductsToSellercraftResolver = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const biz_base_1 = require("@things-factory/biz-base");
6
+ const integration_fulfillment_1 = require("@things-factory/integration-fulfillment");
7
+ const integration_sellercraft_1 = require("@things-factory/integration-sellercraft");
8
+ const sync_products_to_sellercraft_1 = require("./sync-products-to-sellercraft");
9
+ exports.syncAllProductsToSellercraftResolver = {
10
+ async syncAllProductsToSellercraft(_, {}, context) {
11
+ const { user } = context.state;
12
+ try {
13
+ await (0, typeorm_1.getConnection)().transaction(async (tx) => {
14
+ const qb = await tx
15
+ .getRepository(integration_sellercraft_1.Sellercraft)
16
+ .createQueryBuilder('sellercraft')
17
+ .innerJoinAndSelect('sellercraft.domain', 'domain')
18
+ .innerJoinAndSelect(biz_base_1.Bizplace, 'bizplace', 'bizplace.domain_id = domain.id')
19
+ .where('sellercraft.status = :status', { status: 'ACTIVE' });
20
+ const sellercrafts = await qb.getRawMany();
21
+ for (const sellercraft of sellercrafts) {
22
+ const companyBizplace = await (0, biz_base_1.getCompanyBizplace)(null, null, sellercraft.bizplace_id, tx);
23
+ const fulfillmentCenter = await tx.getRepository(integration_fulfillment_1.FulfillmentCenter).find({
24
+ where: { domain: companyBizplace.domain }
25
+ });
26
+ await sync_products_to_sellercraft_1.syncProductsToSellercraftResolver.syncProductsToSellercraft(null, { sellercraftId: sellercraft.id, fulfillmentCenterId: fulfillmentCenter.id, toCreateSku: false }, context);
27
+ }
28
+ });
29
+ }
30
+ catch (e) {
31
+ console.log(e);
32
+ }
33
+ }
34
+ };
35
+ //# sourceMappingURL=sync-all-products-to-sellercraft.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-all-products-to-sellercraft.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/sync-all-products-to-sellercraft.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAEvC,uDAAuE;AACvE,qFAA2E;AAC3E,qFAAqE;AAErE,iFAA8F;AAEjF,QAAA,oCAAoC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","sourcesContent":["import { getConnection } from 'typeorm'\n\nimport { Bizplace, getCompanyBizplace } from '@things-factory/biz-base'\nimport { FulfillmentCenter } from '@things-factory/integration-fulfillment'\nimport { Sellercraft } from '@things-factory/integration-sellercraft'\n\nimport { syncProductsToSellercraftResolver as resolver } from './sync-products-to-sellercraft'\n\nexport const syncAllProductsToSellercraftResolver = {\n async syncAllProductsToSellercraft(_: any, {}, context: ResolverContext): Promise<void> {\n const { user } = context.state\n try {\n await getConnection().transaction(async tx => {\n const qb = await tx\n .getRepository(Sellercraft)\n .createQueryBuilder('sellercraft')\n .innerJoinAndSelect('sellercraft.domain', 'domain')\n .innerJoinAndSelect(Bizplace, 'bizplace', 'bizplace.domain_id = domain.id')\n .where('sellercraft.status = :status', { status: 'ACTIVE' })\n\n const sellercrafts: Sellercraft[] = await qb.getRawMany()\n\n for (const sellercraft of sellercrafts) {\n const companyBizplace: Bizplace = await getCompanyBizplace(null, null, sellercraft.bizplace_id, tx)\n const fulfillmentCenter: FulfillmentCenter = await tx.getRepository(FulfillmentCenter).find({\n where: { domain: companyBizplace.domain }\n })\n await resolver.syncProductsToSellercraft(\n null,\n { sellercraftId: sellercraft.id, fulfillmentCenterId: fulfillmentCenter.id, toCreateSku: false },\n context\n )\n }\n })\n } catch (e) {\n console.log(e)\n }\n }\n}\n"]}
@@ -10,7 +10,7 @@ exports.syncProductsFromAccountResolver = {
10
10
  try {
11
11
  const { tx } = context.state;
12
12
  let platformProducts = await (0, fetch_sync_products_1.getAccountingProducts)(accountId);
13
- const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOne(bizplaceId);
13
+ const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOneBy({ id: bizplaceId });
14
14
  const platformProductsMap = (0, build_map_1.buildMap)(platformProducts, 'sku');
15
15
  let bizplaceProducts = await tx.getRepository(product_base_1.Product).find({ where: { bizplace } });
16
16
  const updateTargetProducts = bizplaceProducts
@@ -1 +1 @@
1
- {"version":3,"file":"sync-products-from-account.js","sour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AC,CAAC,CAAA;gBAEF,OAAO,eAAe,CAAA;YACxB,CAAC,CAAC,CAAA;YAEJ,MAAM,EAAE,CAAC,aAAa,CAAC,sBAAO,CAAC,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;SAC3E;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAA;SACR;IACH,CAAC;CACF,CAAA","sourcesContent":["import { Bizplace } from '@things-factory/biz-base'\nimport { Product } from '@things-factory/product-base'\nimport { EntityManager } from 'typeorm'\nimport { buildMap } from '../../../utils/build-map'\nimport { getAccountingProducts } from './fetch-sync-products'\n\nexport const syncProductsFromAccountResolver = {\n async syncProductsFromAccount(\n _: void,\n { accountId, bizplaceId }: { accountId: string; bizplaceId: string },\n context: any\n ): Promise<void> {\n try {\n const { tx }: { tx: EntityManager } = context.state\n let platformProducts: Product[] = await getAccountingProducts(accountId)\n const bizplace: Bizplace = await tx.getRepository(Bizplace).findOne(bizplaceId)\n const platformProductsMap: Map<string, Product> = buildMap(platformProducts, 'sku')\n\n let bizplaceProducts: Product[] = await tx.getRepository(Product).find({ where: { bizplace } })\n\n const updateTargetProducts: Product[] = bizplaceProducts\n .filter(({ sku }: Product) => platformProductsMap.has(sku))\n .map((bizplaceProduct: Product) => {\n const platformProduct: Product = platformProductsMap.get(bizplaceProduct.sku)\n\n Object.keys(platformProduct).forEach((key: string) => {\n bizplaceProduct[key] = platformProduct[key] === undefined ? null : platformProduct[key]\n })\n\n return bizplaceProduct\n })\n\n await tx.getRepository(Product).save(updateTargetProducts, { chunk: 500 })\n } catch (e) {\n throw e\n }\n }\n}\n"]}
1
+ {"version":3,"file":"sync-products-from-account.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/sync-products-from-account.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,+DAAsD;AAEtD,wDAAmD;AACnD,+DAA6D;AAEhD,QAAA,+BAA+B,GAAG;IAC7C,KAA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AAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;SAC3E;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAA;SACR;IACH,CAAC;CACF,CAAA","sourcesContent":["import { Bizplace } from '@things-factory/biz-base'\nimport { Product } from '@things-factory/product-base'\n\nimport { buildMap } from '../../../utils/build-map'\nimport { getAccountingProducts } from './fetch-sync-products'\n\nexport const syncProductsFromAccountResolver = {\n async syncProductsFromAccount(\n _: void,\n { accountId, bizplaceId }: { accountId: string; bizplaceId: string },\n context: ResolverContext\n ): Promise<void> {\n try {\n const { tx } = context.state\n let platformProducts: Product[] = await getAccountingProducts(accountId)\n const bizplace: Bizplace = await tx.getRepository(Bizplace).findOneBy({ id: bizplaceId })\n const platformProductsMap: Map<string, Product> = buildMap(platformProducts, 'sku')\n\n let bizplaceProducts: Product[] = await tx.getRepository(Product).find({ where: { bizplace } })\n\n const updateTargetProducts: Product[] = bizplaceProducts\n .filter(({ sku }: Product) => platformProductsMap.has(sku))\n .map((bizplaceProduct: Product) => {\n const platformProduct: Product = platformProductsMap.get(bizplaceProduct.sku)\n\n Object.keys(platformProduct).forEach((key: string) => {\n bizplaceProduct[key] = platformProduct[key] === undefined ? null : platformProduct[key]\n })\n\n return bizplaceProduct\n })\n\n await tx.getRepository(Product).save(updateTargetProducts, { chunk: 500 })\n } catch (e) {\n throw e\n }\n }\n}\n"]}
@@ -10,7 +10,7 @@ exports.syncProductsToAccountResolver = {
10
10
  async syncProductsToAccount(_, { accountId, bizplaceId }, context) {
11
11
  try {
12
12
  const { tx } = context.state;
13
- const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOne(bizplaceId);
13
+ const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOneBy({ id: bizplaceId });
14
14
  const bizplaceProducts = await tx.getRepository(product_base_1.Product).find({ where: { bizplace } });
15
15
  let platformProducts = await (0, fetch_sync_products_1.getAccountingProducts)(accountId);
16
16
  let platformProductsMap = (0, build_map_1.buildMap)(platformProducts, 'sku');
@@ -1 +1 @@
1
- {"version":3,"file":"sync-products-to-account.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/sync-products-to-account.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,mFAAsE;AACtE,+DAAsD;AAEtD,wDAAmD;AACnD,+DAA6D;AAEhD,QAAA,6BAA6B,GAAG;IAC3C,KAAK,CAAC,qBAAqB,CACzB,CAAO,EACP,EAAE,SAAS,EAAE,UAAU,EAA6C,EACpE,OAAY;QAEZ,IAAI;YACF,MAAM,EAAE,EAAE,EAAE,GAA0B,OAAO,CAAC,KAAK,CAAA;YAEnD,MAAM,QAAQ,GAAa,MAAM,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;YAC/E,MAAM,gBAAgB,GAAc,MAAM,EAAE,CAAC,aAAa,CAAC,sBAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAA;YAEjG,IAAI,gBAAgB,GAAc,MAAM,IAAA,2CAAqB,EAAC,SAAS,CAAC,CAAA;YACxE,IAAI,mBAAmB,GAAyB,IAAA,oBAAQ,EAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;YAEjF,MAAM,oBAAoB,GAAc,gBAAgB,CAAC,GAAG,CAAC,CAAC,eAAwB,EAAE,EAAE;gBACxF,IAAI,eAAe,GAAY,EAAE,CAAA;gBACjC,IAAI,mBAAmB,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE;oBAChD,eAAe,GAAG,mBAAmB,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;iBAC/D;gBAED,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;oBACnD,eAAe,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,CAAA;gBAC7C,CAAC,CAAC,CAAA;gBAEF,OAAO,eAAe,CAAA;YACxB,CAAC,CAAC,CAAA;YAEF,MAAM,eAAe,GAAgB,UAAU,CAAC,oBAAoB,CAAC,CAAA;YACrE,MAAM,UAAU,GAAkB,MAAM,sCAAa,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;YAE9E,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACvD,MAAM,QAAQ,GAAc,eAAe,CAAC,CAAC,CAAC,CAAA;gBAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;gBACvB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAA;gBACvB,IAAI;oBACF,MAAM,sCAAa,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;iBACjD;gBAAC,OAAO,CAAC,EAAE;oBACV,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;iBAC9B;aACF;SACF;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAA;SACR;IACH,CAAC;CACF,CAAA;AAED,SAAS,UAAU,CAAI,IAAS,EAAE,UAAkB,GAAG;IACrD,IAAI,UAAU,GAAU,EAAE,CAAA;IAC1B,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAA;KACzC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { Bizplace } from '@things-factory/biz-base'\nimport { AccountingAPI } from '@things-factory/integration-accounting'\nimport { Product } from '@things-factory/product-base'\nimport { EntityManager } from 'typeorm'\nimport { buildMap } from '../../../utils/build-map'\nimport { getAccountingProducts } from './fetch-sync-products'\n\nexport const syncProductsToAccountResolver = {\n async syncProductsToAccount(\n _: void,\n { accountId, bizplaceId }: { accountId: string; bizplaceId: string },\n context: any\n ): Promise<void> {\n try {\n const { tx }: { tx: EntityManager } = context.state\n\n const bizplace: Bizplace = await tx.getRepository(Bizplace).findOne(bizplaceId)\n const bizplaceProducts: Product[] = await tx.getRepository(Product).find({ where: { bizplace } })\n\n let platformProducts: Product[] = await getAccountingProducts(accountId)\n let platformProductsMap: Map<string, Product> = buildMap(platformProducts, 'sku')\n\n const updateTargetProducts: Product[] = bizplaceProducts.map((bizplaceProduct: Product) => {\n let platformProduct: Product = {}\n if (platformProductsMap.has(bizplaceProduct.sku)) {\n platformProduct = platformProductsMap.get(bizplaceProduct.sku)\n }\n\n Object.keys(bizplaceProduct).forEach((key: string) => {\n platformProduct[key] = bizplaceProduct[key]\n })\n\n return platformProduct\n })\n\n const chunkedProducts: Product[][] = splitChunk(updateTargetProducts)\n const accounting: AccountingAPI = await AccountingAPI.getAccounting(accountId)\n\n for (let i: number = 0; i < chunkedProducts.length; i++) {\n const products: Product[] = chunkedProducts[i]\n const req = context.req\n req.products = products\n try {\n await AccountingAPI.updateItems(accounting, req)\n } catch (e) {\n throw new Error(e.statusText)\n }\n }\n } catch (e) {\n throw e\n }\n }\n}\n\nfunction splitChunk<T>(data: T[], unitCnt: number = 100): T[][] {\n let splitChunk: T[][] = []\n while (data.length > 0) {\n splitChunk.push(data.splice(0, unitCnt))\n }\n\n return splitChunk\n}\n"]}
1
+ {"version":3,"file":"sync-products-to-account.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/sync-products-to-account.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,mFAAsE;AACtE,+DAAsD;AAEtD,wDAAmD;AACnD,+DAA6D;AAEhD,QAAA,6BAA6B,GAAG;IAC3C,KAAK,CAAC,qBAAqB,CACzB,CAAO,EACP,EAAE,SAAS,EAAE,UAAU,EAA6C,EACpE,OAAwB;QAExB,IAAI;YACF,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YAE5B,MAAM,QAAQ,GAAa,MAAM,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ACvB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAA;gBACvB,IAAI;oBACF,MAAM,sCAAa,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;iBACjD;gBAAC,OAAO,CAAC,EAAE;oBACV,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;iBAC9B;aACF;SACF;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAA;SACR;IACH,CAAC;CACF,CAAA;AAED,SAAS,UAAU,CAAI,IAAS,EAAE,UAAkB,GAAG;IACrD,IAAI,UAAU,GAAU,EAAE,CAAA;IAC1B,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAA;KACzC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { Bizplace } from '@things-factory/biz-base'\nimport { AccountingAPI } from '@things-factory/integration-accounting'\nimport { Product } from '@things-factory/product-base'\n\nimport { buildMap } from '../../../utils/build-map'\nimport { getAccountingProducts } from './fetch-sync-products'\n\nexport const syncProductsToAccountResolver = {\n async syncProductsToAccount(\n _: void,\n { accountId, bizplaceId }: { accountId: string; bizplaceId: string },\n context: ResolverContext\n ): Promise<void> {\n try {\n const { tx } = context.state\n\n const bizplace: Bizplace = await tx.getRepository(Bizplace).findOneBy({ id: bizplaceId })\n const bizplaceProducts: Product[] = await tx.getRepository(Product).find({ where: { bizplace } })\n\n let platformProducts: Product[] = await getAccountingProducts(accountId)\n let platformProductsMap: Map<string, Product> = buildMap(platformProducts, 'sku')\n\n const updateTargetProducts: Product[] = bizplaceProducts.map((bizplaceProduct: Product) => {\n let platformProduct: Product = {}\n if (platformProductsMap.has(bizplaceProduct.sku)) {\n platformProduct = platformProductsMap.get(bizplaceProduct.sku)\n }\n\n Object.keys(bizplaceProduct).forEach((key: string) => {\n platformProduct[key] = bizplaceProduct[key]\n })\n\n return platformProduct\n })\n\n const chunkedProducts: Product[][] = splitChunk(updateTargetProducts)\n const accounting: AccountingAPI = await AccountingAPI.getAccounting(accountId)\n\n for (let i: number = 0; i < chunkedProducts.length; i++) {\n const products: Product[] = chunkedProducts[i]\n const req = context.req\n req.products = products\n try {\n await AccountingAPI.updateItems(accounting, req)\n } catch (e) {\n throw new Error(e.statusText)\n }\n }\n } catch (e) {\n throw e\n }\n }\n}\n\nfunction splitChunk<T>(data: T[], unitCnt: number = 100): T[][] {\n let splitChunk: T[][] = []\n while (data.length > 0) {\n splitChunk.push(data.splice(0, unitCnt))\n }\n\n return splitChunk\n}\n"]}
@@ -13,7 +13,9 @@ exports.syncProductsToSellercraftResolver = {
13
13
  let page = 0;
14
14
  let hasMorePage = true;
15
15
  const limit = 50;
16
- const sellercraft = await tx.getRepository(integration_sellercraft_1.Sellercraft).findOne({ where: { id: sellercraftId }, relations: ['domain'] });
16
+ const sellercraft = await tx
17
+ .getRepository(integration_sellercraft_1.Sellercraft)
18
+ .findOne({ where: { id: sellercraftId }, relations: ['domain'] });
17
19
  const customerDomain = sellercraft.domain;
18
20
  const fulfilmentCenter = await integration_fulfillment_1.FulfillmentAPI.getFulfillmentCenter(fulfillmentCenterId);
19
21
  const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({ where: { domain: customerDomain } });
@@ -79,7 +81,7 @@ exports.syncProductsToSellercraftResolver = {
79
81
  await delay(500);
80
82
  await integration_sellercraft_1.SellercraftAPI.updateProduct(sellercraft, { context, accountId: sellercraft.accountId, sellercraftInv });
81
83
  page++;
82
- hasMorePage = (((_a = total[0]) === null || _a === void 0 ? void 0 : _a.count) || 0) > (page * limit);
84
+ hasMorePage = (((_a = total[0]) === null || _a === void 0 ? void 0 : _a.count) || 0) > page * limit;
83
85
  }
84
86
  catch (e) {
85
87
  env_1.logger.error(`[syncProductsToSellercraftResolver] sellercraftID:${sellercraftId} fulfillmentCenterId:${fulfillmentCenterId} page:${page} - ${e}`);
@@ -1 +1 @@
1
- {"version":3,"file":"sync-products-to-sellercraft.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/sync-products-to-sellercraft.ts"],"names":[],"mappings":";;;AAEA,uDAAmD;AACnD,6CAA4C;AAC5C,qFAA2F;AAC3F,qFAAqF;AAKxE,QAAA,iCAAiC,GAAG;IAC/C,KAAK,CAAC,yBAAyB,CAC7B,CAAO,EACP,EACE,aAAa,EACb,mBAAmB,EAC0D,EAC/E,OAAY;;QAEZ,IAAI;YACF,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAA0C,OAAO,CAAC,KAAK,CAAA;YAE3E,IAAI,IAAI,GAAW,CAAC,CAAA;YACpB,IAAI,WAAW,GAAY,IAAI,CAAA;YAC/B,MAAM,KAAK,GAAW,EAAE,CAAA;YAExB,MAAM,WAAW,GAAgB,MAAM,EAAE,CAAC,aAAa,CAAC,qCAAW,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;YACrI,MAAM,cAAc,GAAW,WAAW,CAAC,MAAM,CAAA;YACjD,MAAM,gBAAgB,GAAsB,MAAM,wCAAc,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,CAAA;YAC1G,MAAM,gBAAgB,GAAa,MAAM,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,CAAC,CAAA;YAElH,MAAM,EAAE,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;OAsBd,EAAE,CAAC,gBAAgB,CAAC,EAAE,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAA;YAE9C,IAAI,KAAK,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC;;OAE1B,CAAC,CAAA;YAEF,OAAO,WAAW,EAAE;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DAAkD,uBAAuB,CAAC,IAAI,GAAG,CAAC,CAAA;SACnG;KACF;IAED,OAAO,WAAW,CAAA;AACpB,CAAC;AA9CD,kDA8CC","sourcesContent":["import { EntityManager, getRepository } from 'typeorm'\n\nimport { Bizplace } from '@things-factory/biz-base'\nimport { logger } from '@things-factory/env'\nimport { FulfillmentAPI, FulfillmentCenter } from '@things-factory/integration-fulfillment'\nimport { Sellercraft, SellercraftAPI } from '@things-factory/integration-sellercraft'\nimport { Product, ProductDetail } from '@things-factory/product-base'\nimport { WarehouseBizplaceOnhandInventory } from '@things-factory/worksheet-base'\nimport { Domain } from '@things-factory/shell'\n\nexport const syncProductsToSellercraftResolver = {\n async syncProductsToSellercraft(\n _: void,\n {\n sellercraftId,\n fulfillmentCenterId\n }: { sellercraftId: string; fulfillmentCenterId: string; toCreateSku: boolean },\n context: any\n ): Promise<void> {\n try {\n const { domain, tx }: { domain: Domain; tx: EntityManager } = context.state\n\n let page: number = 0\n let hasMorePage: boolean = true\n const limit: number = 50\n\n const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({ where: { id: sellercraftId }, relations: ['domain'] })\n const customerDomain: Domain = sellercraft.domain\n const fulfilmentCenter: FulfillmentCenter = await FulfillmentAPI.getFulfillmentCenter(fulfillmentCenterId)\n const customerBizplace: Bizplace = await tx.getRepository(Bizplace).findOne({ where: { domain: customerDomain } })\n\n await tx.query(`\n create temp table temp_warehouse_product_inventory ON COMMIT DROP as (\n select p.id, p.sku as product_sku, p.name as product_name, p.description as product_description, \n pd.gtin, pd.uom, pd.packing_size, coalesce(pd.nett_weight, 0) as nett_weight, pd.width, pd.\"depth\", pd.height,\n coalesce(src.qty, 0) as available_qty, coalesce(src.qty - src.\"remainQty\", 0) as reserved_qty, coalesce(src.\"remainQty\",0) as remain_qty\n from bizplaces b\n inner join companies c on c.id = b.company_id \n inner join domains d on d.id = c.domain_id\n inner join products p on p.domain_id = b.domain_id or p.domain_id = c.domain_id \n inner join product_details pd on pd.product_id = p.id\n left join (\n select wboi.* from warehouse_bizplace_onhand_inventories wboi \n inner join domains d on d.id = wboi.\"domainId\"\n inner join fulfillment_centers fc on d.subdomain = fc.center_id \n where fc.id= $1 \n and wboi.\"bizplaceId\" = $2 and \"groupType\" = 'SINGLE'\n ) src on src.\"productId\" = pd.\"product_id\" \n and src.\"packingType\" = pd.\"packing_type\" \n and src.\"packingSize\" = pd.\"packing_size\" \n and src.\"uom\" = pd.\"uom\" \n where b.id = $2\n )\n `, [fulfilmentCenter.id, customerBizplace.id])\n\n let total = await tx.query(`\n select count(*) from temp_warehouse_product_inventory \n `)\n\n while (hasMorePage) {\n hasMorePage = false\n try {\n // const { items, total } = await FulfillmentAPI.getInventoryProductGroupOpenAPI(fulfilmentCenter, {\n // warehouseId: customerBizplace.id,\n // paginationEntriesPerPage: limit,\n // paginationOffset: page\n // })\n\n const items = await tx.query(`\n select * from temp_warehouse_product_inventory limit $1 offset $2\n `, [limit, page * limit])\n\n let sellercraftInv: any[] = []\n\n items.map(async item => {\n let packingSize: number = 1\n\n sellercraftInv.push({\n sku: item.product_sku,\n gtin: item.gtin,\n stock: {\n quantity_total: item.available_qty * packingSize < 0 ? 0 : item.available_qty * packingSize,\n quantity_reserved: item.reserved_qty * packingSize < 0 ? 0 : item.reserved_qty * packingSize,\n unit_of_measure: 'EA'\n },\n package_weight_gm: item.nett_weight <= 0 ? 1 : item.nett_weight,\n package_dimensions: {\n length_mm: item.depth <= 0 ? 1 : item.depth,\n width_mm: item.width <= 0 ? 1 : item.width,\n height_mm: item.height <= 0 ? 1 : item.height\n }\n })\n })\n\n const delay = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms))\n }\n\n await delay(500)\n\n await SellercraftAPI.updateProduct(sellercraft, { context, accountId: sellercraft.accountId, sellercraftInv })\n\n page++\n hasMorePage = (total[0]?.count || 0) > (page * limit)\n } catch (e) {\n logger.error(`[syncProductsToSellercraftResolver] sellercraftID:${sellercraftId} fulfillmentCenterId:${fulfillmentCenterId} page:${page} - ${e}`)\n }\n }\n } catch (e) {\n logger.error(`syncProductsToSellercraftResolver: ${e}`)\n }\n }\n}\n\n/**\n * @summary Check for product child qty at any scanned level\n * @description It will check every level of product detail by comparing scanned level and GAN registered level.\n * By getting the level that has relation, child qty will be retrieved\n * 1st level: PALLET -> 2 CARTONS (scan), 2nd level: CARTON -> 6 BAGS, 3rd level: BAG -> 10 UNITS, lowest: UNIT (order registered packing type)\n */\nexport async function getChildPackingSize(\n productDetails: ProductDetail[],\n defaultProductDetail: ProductDetail,\n unmatchingProductDetail: ProductDetail\n): Promise<number> {\n let hasChildRelation: boolean = Boolean(unmatchingProductDetail?.childProductDetail)\n let hasMatchingChild: boolean\n let packingSize: number = 1\n let currentChildProductDetail: ProductDetail\n\n if (hasChildRelation) {\n currentChildProductDetail = productDetails.find(\n (productDetail: ProductDetail) => productDetail.id === unmatchingProductDetail.childProductDetail.id\n )\n\n if (!currentChildProductDetail) {\n throw new Error(`Unable to find matching packing type for GTIN (${unmatchingProductDetail.gtin})`)\n }\n\n hasMatchingChild = Boolean(defaultProductDetail.id === currentChildProductDetail.id)\n if (hasMatchingChild) {\n packingSize = unmatchingProductDetail.packingSize\n } else {\n packingSize = unmatchingProductDetail.packingSize * packingSize\n }\n } else {\n throw new Error(`No child product result for GTIN (${unmatchingProductDetail.gtin})`)\n }\n\n while (hasChildRelation && !hasMatchingChild) {\n if (hasMatchingChild) {\n packingSize = currentChildProductDetail.packingSize * packingSize // 12 x 10\n } else if (!hasMatchingChild && hasChildRelation) {\n packingSize = currentChildProductDetail.packingSize * packingSize // 12 x 10\n currentChildProductDetail = productDetails.find(\n (productDetail: ProductDetail) => productDetail.id === currentChildProductDetail.childProductDetail.id\n )\n\n hasChildRelation = Boolean(currentChildProductDetail?.childProductDetail)\n hasMatchingChild = Boolean(defaultProductDetail.id === currentChildProductDetail.id)\n } else if (!hasChildRelation && !hasMatchingChild) {\n throw new Error(`Unable to find matching packing type for GTIN (${unmatchingProductDetail.gtin})`)\n }\n }\n\n return packingSize\n}\n"]}
1
+ {"version":3,"file":"sync-products-to-sellercraft.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/sync-products-to-sellercraft.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,6CAA4C;AAC5C,qFAA2F;AAC3F,qFAAqF;AAIxE,QAAA,iCAAiC,GAAG;IAC/C,KAAK,CAAC,yBAAyB,CAC7B,CAAO,EACP,EACE,aAAa,EACb,mBAAmB,EAC0D,EAC/E,OAAY;;QAEZ,IAAI;YACF,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YAEpC,IAAI,IAAI,GAAW,CAAC,CAAA;YACpB,IAAI,WAAW,GAAY,IAAI,CAAA;YAC/B,MAAM,KAAK,GAAW,EAAE,CAAA;YAExB,MAAM,WAAW,GAAgB,MAAM,EAAE;iBACtC,aAAa,CAAC,qCAAW,CAAC;iBAC1B,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;YACnE,MAAM,cAAc,GAAW,WAAW,CAAC,MAAM,CAAA;YACjD,MAAM,gBAAgB,GAAsB,MAAM,wCAAc,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,CAAA;YAC1G,MAAM,gBAAgB,GAAa,MAAM,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,CAAC,CAAA;YAElH,MAAM,EAAE,CAAC,KAAK,CACZ;;;;;;;;;;;;;;;;;;;;;;OAsBD,EACC,CAAC,gBAAgB,CAAC,EAAE,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAC3C,CAAA;YAED,IAAI,KAAK,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC;;OAE1B,CAAC,CAAA;YAEF,OAAO,WAAW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B,CAAC,IAAI,GAAG,CAAC,CAAA;SACnG;KACF;IAED,OAAO,WAAW,CAAA;AACpB,CAAC;AA9CD,kDA8CC","sourcesContent":["import { Bizplace } from '@things-factory/biz-base'\nimport { logger } from '@things-factory/env'\nimport { FulfillmentAPI, FulfillmentCenter } from '@things-factory/integration-fulfillment'\nimport { Sellercraft, SellercraftAPI } from '@things-factory/integration-sellercraft'\nimport { ProductDetail } from '@things-factory/product-base'\nimport { Domain } from '@things-factory/shell'\n\nexport const syncProductsToSellercraftResolver = {\n async syncProductsToSellercraft(\n _: void,\n {\n sellercraftId,\n fulfillmentCenterId\n }: { sellercraftId: string; fulfillmentCenterId: string; toCreateSku: boolean },\n context: any\n ): Promise<void> {\n try {\n const { domain, tx } = context.state\n\n let page: number = 0\n let hasMorePage: boolean = true\n const limit: number = 50\n\n const sellercraft: Sellercraft = await tx\n .getRepository(Sellercraft)\n .findOne({ where: { id: sellercraftId }, relations: ['domain'] })\n const customerDomain: Domain = sellercraft.domain\n const fulfilmentCenter: FulfillmentCenter = await FulfillmentAPI.getFulfillmentCenter(fulfillmentCenterId)\n const customerBizplace: Bizplace = await tx.getRepository(Bizplace).findOne({ where: { domain: customerDomain } })\n\n await tx.query(\n `\n create temp table temp_warehouse_product_inventory ON COMMIT DROP as (\n select p.id, p.sku as product_sku, p.name as product_name, p.description as product_description, \n pd.gtin, pd.uom, pd.packing_size, coalesce(pd.nett_weight, 0) as nett_weight, pd.width, pd.\"depth\", pd.height,\n coalesce(src.qty, 0) as available_qty, coalesce(src.qty - src.\"remainQty\", 0) as reserved_qty, coalesce(src.\"remainQty\",0) as remain_qty\n from bizplaces b\n inner join companies c on c.id = b.company_id \n inner join domains d on d.id = c.domain_id\n inner join products p on p.domain_id = b.domain_id or p.domain_id = c.domain_id \n inner join product_details pd on pd.product_id = p.id\n left join (\n select wboi.* from warehouse_bizplace_onhand_inventories wboi \n inner join domains d on d.id = wboi.\"domainId\"\n inner join fulfillment_centers fc on d.subdomain = fc.center_id \n where fc.id= $1 \n and wboi.\"bizplaceId\" = $2 and \"groupType\" = 'SINGLE'\n ) src on src.\"productId\" = pd.\"product_id\" \n and src.\"packingType\" = pd.\"packing_type\" \n and src.\"packingSize\" = pd.\"packing_size\" \n and src.\"uom\" = pd.\"uom\" \n where b.id = $2\n )\n `,\n [fulfilmentCenter.id, customerBizplace.id]\n )\n\n let total = await tx.query(`\n select count(*) from temp_warehouse_product_inventory \n `)\n\n while (hasMorePage) {\n hasMorePage = false\n try {\n // const { items, total } = await FulfillmentAPI.getInventoryProductGroupOpenAPI(fulfilmentCenter, {\n // warehouseId: customerBizplace.id,\n // paginationEntriesPerPage: limit,\n // paginationOffset: page\n // })\n\n const items = await tx.query(\n `\n select * from temp_warehouse_product_inventory limit $1 offset $2\n `,\n [limit, page * limit]\n )\n\n let sellercraftInv: any[] = []\n\n items.map(async item => {\n let packingSize: number = 1\n\n sellercraftInv.push({\n sku: item.product_sku,\n gtin: item.gtin,\n stock: {\n quantity_total: item.available_qty * packingSize < 0 ? 0 : item.available_qty * packingSize,\n quantity_reserved: item.reserved_qty * packingSize < 0 ? 0 : item.reserved_qty * packingSize,\n unit_of_measure: 'EA'\n },\n package_weight_gm: item.nett_weight <= 0 ? 1 : item.nett_weight,\n package_dimensions: {\n length_mm: item.depth <= 0 ? 1 : item.depth,\n width_mm: item.width <= 0 ? 1 : item.width,\n height_mm: item.height <= 0 ? 1 : item.height\n }\n })\n })\n\n const delay = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms))\n }\n\n await delay(500)\n\n await SellercraftAPI.updateProduct(sellercraft, { context, accountId: sellercraft.accountId, sellercraftInv })\n\n page++\n hasMorePage = (total[0]?.count || 0) > page * limit\n } catch (e) {\n logger.error(\n `[syncProductsToSellercraftResolver] sellercraftID:${sellercraftId} fulfillmentCenterId:${fulfillmentCenterId} page:${page} - ${e}`\n )\n }\n }\n } catch (e) {\n logger.error(`syncProductsToSellercraftResolver: ${e}`)\n }\n }\n}\n\n/**\n * @summary Check for product child qty at any scanned level\n * @description It will check every level of product detail by comparing scanned level and GAN registered level.\n * By getting the level that has relation, child qty will be retrieved\n * 1st level: PALLET -> 2 CARTONS (scan), 2nd level: CARTON -> 6 BAGS, 3rd level: BAG -> 10 UNITS, lowest: UNIT (order registered packing type)\n */\nexport async function getChildPackingSize(\n productDetails: ProductDetail[],\n defaultProductDetail: ProductDetail,\n unmatchingProductDetail: ProductDetail\n): Promise<number> {\n let hasChildRelation: boolean = Boolean(unmatchingProductDetail?.childProductDetail)\n let hasMatchingChild: boolean\n let packingSize: number = 1\n let currentChildProductDetail: ProductDetail\n\n if (hasChildRelation) {\n currentChildProductDetail = productDetails.find(\n (productDetail: ProductDetail) => productDetail.id === unmatchingProductDetail.childProductDetail.id\n )\n\n if (!currentChildProductDetail) {\n throw new Error(`Unable to find matching packing type for GTIN (${unmatchingProductDetail.gtin})`)\n }\n\n hasMatchingChild = Boolean(defaultProductDetail.id === currentChildProductDetail.id)\n if (hasMatchingChild) {\n packingSize = unmatchingProductDetail.packingSize\n } else {\n packingSize = unmatchingProductDetail.packingSize * packingSize\n }\n } else {\n throw new Error(`No child product result for GTIN (${unmatchingProductDetail.gtin})`)\n }\n\n while (hasChildRelation && !hasMatchingChild) {\n if (hasMatchingChild) {\n packingSize = currentChildProductDetail.packingSize * packingSize // 12 x 10\n } else if (!hasMatchingChild && hasChildRelation) {\n packingSize = currentChildProductDetail.packingSize * packingSize // 12 x 10\n currentChildProductDetail = productDetails.find(\n (productDetail: ProductDetail) => productDetail.id === currentChildProductDetail.childProductDetail.id\n )\n\n hasChildRelation = Boolean(currentChildProductDetail?.childProductDetail)\n hasMatchingChild = Boolean(defaultProductDetail.id === currentChildProductDetail.id)\n } else if (!hasChildRelation && !hasMatchingChild) {\n throw new Error(`Unable to find matching packing type for GTIN (${unmatchingProductDetail.gtin})`)\n }\n }\n\n return packingSize\n}\n"]}
@@ -16,6 +16,10 @@ exports.Mutation = `
16
16
  syncProductsToSellercraft(sellercraftId: String!, fulfillmentCenterId: String!): Boolean @transaction
17
17
  syncProductsFromAccount(accountId: String!, bizplaceId: String!): Boolean @transaction
18
18
  syncProductsToAccount(accountId: String!, bizplaceId: String!): Boolean @transaction
19
+ syncAllProductsToSellercraft: Boolean @transaction
20
+ sellercraftPackMarketplaceOrder: Boolean @transaction
21
+ createDatShipments: Boolean @transaction
22
+ autoUpdateAllMarketplaceProductVariationQuantity(companyDomainId: String, warehouseId: String): Boolean @transaction
19
23
  `;
20
24
  exports.Types = [
21
25
  sync_product_set_1.SyncProductSet,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/synchronization/index.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AACrD,yDAAoE;AACpE,2DAAqD;AACrD,yDAAmD;AACnD,yEAAkE;AAClE,uEAAiF;AAEpE,QAAA,KAAK,GAAiB;;;;CAIlC,CAAA;AAEY,QAAA,QAAQ,GAAiB;;;;CAIrC,CAAA;AAEY,QAAA,KAAK,GAAG;IACnB,iCAAc;IACd,mCAAe;IACf,8CAAoB;IACpB,gDAAqB;IACrB,GAAG,+BAAM;IACT,iCAAc;IACd,mCAAe;IACf,GAAG,wBAAM;CACV,CAAA","sourcesContent":["import { SyncInvoiceList } from './sync-invoice-list'\nimport { SyncInvoiceSet, Types as iTypes } from './sync-invoice-set'\nimport { SyncProductList } from './sync-product-list'\nimport { SyncProductSet } from './sync-product-set'\nimport { SyncPurchaseOrderList } from './sync-purchase-order-list'\nimport { SyncPurchaseOrderSet, Types as pTypes } from './sync-purchase-order-set'\n\nexport const Query = /* GraphQL */ `\n fetchSyncProducts(accountId: String!, bizplaceId: String!, pagination: Pagination): SyncProductList\n fetchSyncPurchaseOrders(accountId: String!, warehouseId: String!, customerBizplaceId: String, fromDate: String, toDate: String): Boolean\n fetchSyncInvoices(accountId: String!, warehouseId: String!, customerBizplaceId: String!): Boolean\n`\n\nexport const Mutation = /* GraphQL */ `\n syncProductsToSellercraft(sellercraftId: String!, fulfillmentCenterId: String!): Boolean @transaction\n syncProductsFromAccount(accountId: String!, bizplaceId: String!): Boolean @transaction\n syncProductsToAccount(accountId: String!, bizplaceId: String!): Boolean @transaction\n`\n\nexport const Types = [\n SyncProductSet,\n SyncProductList,\n SyncPurchaseOrderSet,\n SyncPurchaseOrderList,\n ...pTypes,\n SyncInvoiceSet,\n SyncInvoiceList,\n ...iTypes\n]\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/synchronization/index.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AACrD,yDAAoE;AACpE,2DAAqD;AACrD,yDAAmD;AACnD,yEAAkE;AAClE,uEAAiF;AAEpE,QAAA,KAAK,GAAiB;;;;CAIlC,CAAA;AAEY,QAAA,QAAQ,GAAiB;;;;;;;;CAQrC,CAAA;AAEY,QAAA,KAAK,GAAG;IACnB,iCAAc;IACd,mCAAe;IACf,8CAAoB;IACpB,gDAAqB;IACrB,GAAG,+BAAM;IACT,iCAAc;IACd,mCAAe;IACf,GAAG,wBAAM;CACV,CAAA","sourcesContent":["import { SyncInvoiceList } from './sync-invoice-list'\nimport { SyncInvoiceSet, Types as iTypes } from './sync-invoice-set'\nimport { SyncProductList } from './sync-product-list'\nimport { SyncProductSet } from './sync-product-set'\nimport { SyncPurchaseOrderList } from './sync-purchase-order-list'\nimport { SyncPurchaseOrderSet, Types as pTypes } from './sync-purchase-order-set'\n\nexport const Query = /* GraphQL */ `\n fetchSyncProducts(accountId: String!, bizplaceId: String!, pagination: Pagination): SyncProductList\n fetchSyncPurchaseOrders(accountId: String!, warehouseId: String!, customerBizplaceId: String, fromDate: String, toDate: String): Boolean\n fetchSyncInvoices(accountId: String!, warehouseId: String!, customerBizplaceId: String!): Boolean\n`\n\nexport const Mutation = /* GraphQL */ `\n syncProductsToSellercraft(sellercraftId: String!, fulfillmentCenterId: String!): Boolean @transaction\n syncProductsFromAccount(accountId: String!, bizplaceId: String!): Boolean @transaction\n syncProductsToAccount(accountId: String!, bizplaceId: String!): Boolean @transaction\n syncAllProductsToSellercraft: Boolean @transaction\n sellercraftPackMarketplaceOrder: Boolean @transaction\n createDatShipments: Boolean @transaction\n autoUpdateAllMarketplaceProductVariationQuantity(companyDomainId: String, warehouseId: String): Boolean @transaction\n`\n\nexport const Types = [\n SyncProductSet,\n SyncProductList,\n SyncPurchaseOrderSet,\n SyncPurchaseOrderList,\n ...pTypes,\n SyncInvoiceSet,\n SyncInvoiceList,\n ...iTypes\n]\n"]}
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ require("./routers/api");
5
+ require("./routes");
6
+ const biz_base_1 = require("@things-factory/biz-base");
7
+ const shell_1 = require("@things-factory/shell");
4
8
  tslib_1.__exportStar(require("./graphql"), exports);
5
9
  tslib_1.__exportStar(require("./middlewares"), exports);
6
10
  tslib_1.__exportStar(require("./migrations"), exports);
7
- const biz_base_1 = require("@things-factory/biz-base");
8
- const typeorm_1 = require("typeorm");
9
- require("./routers/api");
10
- require("./routes");
11
11
  process.on('bootstrap-module-start', async ({ app, config, schema }) => {
12
12
  process.superUserGranted = async (domain, user) => {
13
13
  if (!domain || !user) {
@@ -17,7 +17,7 @@ process.on('bootstrap-module-start', async ({ app, config, schema }) => {
17
17
  return domain.owner === user.id;
18
18
  }
19
19
  else {
20
- const { company } = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne({
20
+ const { company } = await (0, shell_1.getRepository)(biz_base_1.Bizplace).findOne({
21
21
  where: { domain },
22
22
  relations: ['company', 'company.domain']
23
23
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,wDAA6B;AAC7B,uDAA4B;AAG5B,uDAAmD;AAEnD,qCAAuC;AACvC,yBAAsB;AACtB,oBAAiB;AAUjB,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE;IACjF,OAAO,CAAC,gBAAgB,GAAG,KAAK,EAAE,MAAc,EAAE,IAAU,EAAoB,EAAE;QAChF,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE;YACpB,OAAO,KAAK,CAAA;SACb;QAED,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE;YAChC,OAAO,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,EAAE,CAAA;SAChC;aAAM;YACL,MAAM,EAAE,OAAO,EAAE,GAAa,MAAM,IAAA,uBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC;gBAClE,KAAK,EAAE,EAAE,MAAM,EAAE;gBACjB,SAAS,EAAE,CAAC,SAAS,EAAE,gBAAgB,CAAC;aACzC,CAAC,CAAA;YACF,MAAM,aAAa,GAAW,OAAO,CAAC,MAAM,CAAA;YAC5C,OAAO,aAAa,CAAC,KAAK,KAAK,IAAI,CAAC,EAAE,CAAA;SACvC;IACH,CAAC,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["export * from './graphql'\nexport * from './middlewares'\nexport * from './migrations'\n\nimport { User } from '@things-factory/auth-base'\nimport { Bizplace } from '@things-factory/biz-base'\nimport { Domain } from '@things-factory/shell'\nimport { getRepository } from 'typeorm'\nimport './routers/api'\nimport './routes'\n\ndeclare global {\n namespace NodeJS {\n interface Process {\n superUserGranted: (domain: Domain, user: User) => Promise<boolean>\n }\n }\n}\n\nprocess.on('bootstrap-module-start' as any, async ({ app, config, schema }: any) => {\n process.superUserGranted = async (domain: Domain, user: User): Promise<boolean> => {\n if (!domain || !user) {\n return false\n }\n\n if (domain.extType === 'company') {\n return domain.owner === user.id\n } else {\n const { company }: Bizplace = await getRepository(Bizplace).findOne({\n where: { domain },\n relations: ['company', 'company.domain']\n })\n const companyDomain: Domain = company.domain\n return companyDomain.owner === user.id\n }\n }\n})\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,yBAAsB;AACtB,oBAAiB;AAGjB,uDAAmD;AACnD,iDAA6D;AAE7D,oDAAyB;AACzB,wDAA6B;AAC7B,uDAA4B;AAU5B,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE;IACjF,OAAO,CAAC,gBAAgB,GAAG,KAAK,EAAE,MAAc,EAAE,IAAU,EAAoB,EAAE;QAChF,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE;YACpB,OAAO,KAAK,CAAA;SACb;QAED,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE;YAChC,OAAO,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,EAAE,CAAA;SAChC;aAAM;YACL,MAAM,EAAE,OAAO,EAAE,GAAa,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC;gBAClE,KAAK,EAAE,EAAE,MAAM,EAAE;gBACjB,SAAS,EAAE,CAAC,SAAS,EAAE,gBAAgB,CAAC;aACzC,CAAC,CAAA;YACF,MAAM,aAAa,GAAW,OAAO,CAAC,MAAM,CAAA;YAC5C,OAAO,aAAa,CAAC,KAAK,KAAK,IAAI,CAAC,EAAE,CAAA;SACvC;IACH,CAAC,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["import './routers/api'\nimport './routes'\n\nimport { User } from '@things-factory/auth-base'\nimport { Bizplace } from '@things-factory/biz-base'\nimport { Domain, getRepository } from '@things-factory/shell'\n\nexport * from './graphql'\nexport * from './middlewares'\nexport * from './migrations'\n\ndeclare global {\n namespace NodeJS {\n interface Process {\n superUserGranted: (domain: Domain, user: User) => Promise<boolean>\n }\n }\n}\n\nprocess.on('bootstrap-module-start' as any, async ({ app, config, schema }: any) => {\n process.superUserGranted = async (domain: Domain, user: User): Promise<boolean> => {\n if (!domain || !user) {\n return false\n }\n\n if (domain.extType === 'company') {\n return domain.owner === user.id\n } else {\n const { company }: Bizplace = await getRepository(Bizplace).findOne({\n where: { domain },\n relations: ['company', 'company.domain']\n })\n const companyDomain: Domain = company.domain\n return companyDomain.owner === user.id\n }\n }\n})\n"]}
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.businessMiddleware = void 0;
4
4
  const biz_base_1 = require("@things-factory/biz-base");
5
5
  const shell_1 = require("@things-factory/shell");
6
- const typeorm_1 = require("typeorm");
7
6
  const debug = require('debug')('things-factory:operato-hub:business-middleware');
8
7
  async function businessMiddleware(context, next) {
9
8
  const { user } = context.state;
@@ -12,10 +11,10 @@ async function businessMiddleware(context, next) {
12
11
  const domain = await (0, shell_1.getDomainFromURL)(context);
13
12
  let company;
14
13
  if (domain.extType === 'company') {
15
- company = await (0, typeorm_1.getRepository)(biz_base_1.Company).findOne({ where: { domain }, relations: ['domain'] });
14
+ company = await (0, shell_1.getRepository)(biz_base_1.Company).findOne({ where: { domain }, relations: ['domain'] });
16
15
  }
17
16
  else {
18
- const bizplace = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne({
17
+ const bizplace = await (0, shell_1.getRepository)(biz_base_1.Bizplace).findOne({
19
18
  where: { domain },
20
19
  relations: ['company', 'domain']
21
20
  });
@@ -1 +1 @@
1
- {"version":3,"file":"business-middleware.js","sourceRoot":"","sources":["../../server/middlewares/business-middleware.ts"],"names":[],"mappings":";;;AAAA,uDAA4D;AAC5D,iDAAgE;AAChE,qCAAuC;AAEvC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,gDAAgD,CAAC,CAAA;AAEzE,KAAK,UAAU,kBAAkB,CAAC,OAAO,EAAE,IAAI;IACpD,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAE9B,KAAK,CAAC,MAAM,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAC,CAAA;IAE1B,IAAI,IAAI,EAAE;QACR,MAAM,MAAM,GAAW,MAAM,IAAA,wBAAgB,EAAC,OAAO,CAAC,CAAA;QAEtD,IAAI,OAAgB,CAAA;QACpB,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE;YAChC,OAAO,GAAG,MAAM,IAAA,uBAAa,EAAC,kBAAO,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;SAC7F;aAAM;YACL,MAAM,QAAQ,GAAa,MAAM,IAAA,uBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC;gBAC/D,KAAK,EAAE,EAAE,MAAM,EAAE;gBACjB,SAAS,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;aACjC,CAAC,CAAA;YACF,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;SAC3B;QAED,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAA;KACjC;IAED,MAAM,IAAI,EAAE,CAAA;AACd,CAAC;AAvBD,gDAuBC","sourcesContent":["import { Bizplace, Company } from '@things-factory/biz-base'\nimport { Domain, getDomainFromURL } from '@things-factory/shell'\nimport { getRepository } from 'typeorm'\n\nconst debug = require('debug')('things-factory:operato-hub:business-middleware')\n\nexport async function businessMiddleware(context, next) {\n const { user } = context.state\n\n debug('user', user?.email)\n\n if (user) {\n const domain: Domain = await getDomainFromURL(context)\n\n let company: Company\n if (domain.extType === 'company') {\n company = await getRepository(Company).findOne({ where: { domain }, relations: ['domain'] })\n } else {\n const bizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { domain },\n relations: ['company', 'domain']\n })\n company = bizplace.company\n }\n\n context.state.business = company\n }\n\n await next()\n}\n"]}
1
+ {"version":3,"file":"business-middleware.js","sourceRoot":"","sources":["../../server/middlewares/business-middleware.ts"],"names":[],"mappings":";;;AAAA,uDAA4D;AAC5D,iDAA+E;AAE/E,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,gDAAgD,CAAC,CAAA;AAEzE,KAAK,UAAU,kBAAkB,CAAC,OAAO,EAAE,IAAI;IACpD,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAE9B,KAAK,CAAC,MAAM,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAC,CAAA;IAE1B,IAAI,IAAI,EAAE;QACR,MAAM,MAAM,GAAW,MAAM,IAAA,wBAAgB,EAAC,OAAO,CAAC,CAAA;QAEtD,IAAI,OAAgB,CAAA;QACpB,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE;YAChC,OAAO,GAAG,MAAM,IAAA,qBAAa,EAAC,kBAAO,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;SAC7F;aAAM;YACL,MAAM,QAAQ,GAAa,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC;gBAC/D,KAAK,EAAE,EAAE,MAAM,EAAE;gBACjB,SAAS,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;aACjC,CAAC,CAAA;YACF,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;SAC3B;QAED,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAA;KACjC;IAED,MAAM,IAAI,EAAE,CAAA;AACd,CAAC;AAvBD,gDAuBC","sourcesContent":["import { Bizplace, Company } from '@things-factory/biz-base'\nimport { Domain, getDomainFromURL, getRepository } from '@things-factory/shell'\n\nconst debug = require('debug')('things-factory:operato-hub:business-middleware')\n\nexport async function businessMiddleware(context, next) {\n const { user } = context.state\n\n debug('user', user?.email)\n\n if (user) {\n const domain: Domain = await getDomainFromURL(context)\n\n let company: Company\n if (domain.extType === 'company') {\n company = await getRepository(Company).findOne({ where: { domain }, relations: ['domain'] })\n } else {\n const bizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { domain },\n relations: ['company', 'domain']\n })\n company = bizplace.company\n }\n\n context.state.business = company\n }\n\n await next()\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.storeMiddleware = void 0;
4
- const typeorm_1 = require("typeorm");
5
4
  const integration_marketplace_1 = require("@things-factory/integration-marketplace");
5
+ const shell_1 = require("@things-factory/shell");
6
6
  const debug = require('debug')('things-factory:operato-hub:store-middleware');
7
7
  async function storeMiddleware(context, next) {
8
8
  var _a;
@@ -15,7 +15,7 @@ async function storeMiddleware(context, next) {
15
15
  context.throw(404, t('error.company not found'));
16
16
  }
17
17
  if (storeId) {
18
- marketplaceStore = await (0, typeorm_1.getRepository)(integration_marketplace_1.MarketplaceStore).findOne({
18
+ marketplaceStore = await (0, shell_1.getRepository)(integration_marketplace_1.MarketplaceStore).findOne({
19
19
  where: { domain: business.domain, name: storeId, status: 'ACTIVE' },
20
20
  relations: ['domain']
21
21
  });
@@ -1 +1 @@
1
- {"version":3,"file":"store-middleware.js","sourceRoot":"","sources":["../../server/middlewares/store-middleware.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,qFAAoG;AAEpG,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,6CAA6C,CAAC,CAAA;AAEtE,KAAK,UAAU,eAAe,CAAC,OAAO,EAAE,IAAI;;IACjD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IAClC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAClC,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAA;IAErB,IAAI,gBAAwC,CAAA;IAE5C,KAAK,CAAC,mBAAmB,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IAE7C,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAA;KACjD;IAED,IAAI,OAAO,EAAE;QACX,gBAAgB,GAAG,MAAM,IAAA,uBAAa,EAAC,0CAAsB,CAAC,CAAC,OAAO,CAAC;YACrE,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE;YACnE,SAAS,EAAE,CAAC,QAAQ,CAAC;SACtB,CAAC,CAAA;QACF,KAAK,CAAC,mBAAmB,EAAE,OAAO,EAAE,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,MAAM,0CAAE,SAAS,CAAC,CAAA;QAExE,IAAI,CAAC,gBAAgB,EAAE;YACrB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,2CAA2C,CAAC,CAAC,CAAA;SACnE;KACF;SAAM;QACL,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAA;KAClD;IAED,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;IAEjD,MAAM,IAAI,EAAE,CAAA;AACd,CAAC;AA9BD,0CA8BC","sourcesContent":["import { getRepository } from 'typeorm'\nimport { MarketplaceStore as MarketplaceStoreEntity } from '@things-factory/integration-marketplace'\n\nconst debug = require('debug')('things-factory:operato-hub:store-middleware')\n\nexport async function storeMiddleware(context, next) {\n const { storeId } = context.params\n const { business } = context.state\n const { t } = context\n\n let marketplaceStore: MarketplaceStoreEntity\n\n debug('company and store', business, storeId)\n\n if (!business) {\n context.throw(404, t('error.company not found'))\n }\n\n if (storeId) {\n marketplaceStore = await getRepository(MarketplaceStoreEntity).findOne({\n where: { domain: business.domain, name: storeId, status: 'ACTIVE' },\n relations: ['domain']\n })\n debug('marketplace-store', storeId, marketplaceStore?.domain?.subdomain)\n\n if (!marketplaceStore) {\n context.throw(404, t('error.operato marketplace store not found'))\n }\n } else {\n context.throw(404, t('error.store id not found'))\n }\n\n context.state.marketplaceStore = marketplaceStore\n\n await next()\n}\n"]}
1
+ {"version":3,"file":"store-middleware.js","sourceRoot":"","sources":["../../server/middlewares/store-middleware.ts"],"names":[],"mappings":";;;AAAA,qFAAoG;AACpG,iDAAqD;AAErD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,6CAA6C,CAAC,CAAA;AAEtE,KAAK,UAAU,eAAe,CAAC,OAAO,EAAE,IAAI;;IACjD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IAClC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAClC,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAA;IAErB,IAAI,gBAAwC,CAAA;IAE5C,KAAK,CAAC,mBAAmB,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IAE7C,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAA;KACjD;IAED,IAAI,OAAO,EAAE;QACX,gBAAgB,GAAG,MAAM,IAAA,qBAAa,EAAC,0CAAsB,CAAC,CAAC,OAAO,CAAC;YACrE,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE;YACnE,SAAS,EAAE,CAAC,QAAQ,CAAC;SACtB,CAAC,CAAA;QACF,KAAK,CAAC,mBAAmB,EAAE,OAAO,EAAE,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,MAAM,0CAAE,SAAS,CAAC,CAAA;QAExE,IAAI,CAAC,gBAAgB,EAAE;YACrB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,2CAA2C,CAAC,CAAC,CAAA;SACnE;KACF;SAAM;QACL,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAA;KAClD;IAED,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;IAEjD,MAAM,IAAI,EAAE,CAAA;AACd,CAAC;AA9BD,0CA8BC","sourcesContent":["import { MarketplaceStore as MarketplaceStoreEntity } from '@things-factory/integration-marketplace'\nimport { getRepository } from '@things-factory/shell'\n\nconst debug = require('debug')('things-factory:operato-hub:store-middleware')\n\nexport async function storeMiddleware(context, next) {\n const { storeId } = context.params\n const { business } = context.state\n const { t } = context\n\n let marketplaceStore: MarketplaceStoreEntity\n\n debug('company and store', business, storeId)\n\n if (!business) {\n context.throw(404, t('error.company not found'))\n }\n\n if (storeId) {\n marketplaceStore = await getRepository(MarketplaceStoreEntity).findOne({\n where: { domain: business.domain, name: storeId, status: 'ACTIVE' },\n relations: ['domain']\n })\n debug('marketplace-store', storeId, marketplaceStore?.domain?.subdomain)\n\n if (!marketplaceStore) {\n context.throw(404, t('error.operato marketplace store not found'))\n }\n } else {\n context.throw(404, t('error.store id not found'))\n }\n\n context.state.marketplaceStore = marketplaceStore\n\n await next()\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.warehouseMiddleware = void 0;
4
- const typeorm_1 = require("typeorm");
5
4
  const biz_base_1 = require("@things-factory/biz-base");
5
+ const shell_1 = require("@things-factory/shell");
6
6
  const debug = require('debug')('things-factory:operato-hub:warehouse-middleware');
7
7
  async function warehouseMiddleware(context, next) {
8
8
  var _a;
@@ -15,7 +15,8 @@ async function warehouseMiddleware(context, next) {
15
15
  context.throw(404, t('error.company not found'));
16
16
  }
17
17
  if (warehouseId) {
18
- warehouse = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne(warehouseId, {
18
+ warehouse = await (0, shell_1.getRepository)(biz_base_1.Bizplace).findOne({
19
+ where: { id: warehouseId },
19
20
  relations: ['company', 'domain']
20
21
  });
21
22
  debug('warehouse', warehouseId, (_a = warehouse === null || warehouse === void 0 ? void 0 : warehouse.domain) === null || _a === void 0 ? void 0 : _a.subdomain);
@@ -1 +1 @@
1
- {"version":3,"file":"warehouse-middleware.js","sourceRoot":"","sources":["../../server/middlewares/warehouse-middleware.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,uDAAmD;AAEnD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,iDAAiD,CAAC,CAAA;AAE1E,KAAK,UAAU,mBAAmB,CAAC,OAAO,EAAE,IAAI;;IACrD,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACtC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAClC,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAA;IAErB,IAAI,SAAmB,CAAA;IAEvB,KAAK,CAAC,uBAAuB,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAA;IAErD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAA;KACjD;IAED,IAAI,WAAW,EAAE;QACf,SAAS,GAAG,MAAM,IAAA,uBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE;YAC7D,SAAS,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;SACjC,CAAC,CAAA;QACF,KAAK,CAAC,WAAW,EAAE,WAAW,EAAE,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,0CAAE,SAAS,CAAC,CAAA;QAE7D,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAA;SACnD;KACF;SAAM;QACL,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAA;KACnD;IAED,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,SAAS,CAAA;IAEnC,MAAM,IAAI,EAAE,CAAA;AACd,CAAC;AA7BD,kDA6BC","sourcesContent":["import { getRepository } from 'typeorm'\nimport { Bizplace } from '@things-factory/biz-base'\n\nconst debug = require('debug')('things-factory:operato-hub:warehouse-middleware')\n\nexport async function warehouseMiddleware(context, next) {\n const { warehouseId } = context.params\n const { business } = context.state\n const { t } = context\n\n let warehouse: Bizplace\n\n debug('company and warehouse', business, warehouseId)\n\n if (!business) {\n context.throw(404, t('error.company not found'))\n }\n\n if (warehouseId) {\n warehouse = await getRepository(Bizplace).findOne(warehouseId, {\n relations: ['company', 'domain']\n })\n debug('warehouse', warehouseId, warehouse?.domain?.subdomain)\n\n if (!warehouse) {\n context.throw(404, t('error.warehouse not found'))\n }\n } else {\n context.throw(404, t('error.warehouse not found'))\n }\n\n context.state.warehouse = warehouse\n\n await next()\n}\n"]}
1
+ {"version":3,"file":"warehouse-middleware.js","sourceRoot":"","sources":["../../server/middlewares/warehouse-middleware.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,iDAAqD;AAErD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,iDAAiD,CAAC,CAAA;AAE1E,KAAK,UAAU,mBAAmB,CAAC,OAAO,EAAE,IAAI;;IACrD,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACtC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAClC,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAA;IAErB,IAAI,SAAmB,CAAA;IAEvB,KAAK,CAAC,uBAAuB,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAA;IAErD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAA;KACjD;IAED,IAAI,WAAW,EAAE;QACf,SAAS,GAAG,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC;YAChD,KAAK,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE;YAC1B,SAAS,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;SACjC,CAAC,CAAA;QACF,KAAK,CAAC,WAAW,EAAE,WAAW,EAAE,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,0CAAE,SAAS,CAAC,CAAA;QAE7D,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAA;SACnD;KACF;SAAM;QACL,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAA;KACnD;IAED,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,SAAS,CAAA;IAEnC,MAAM,IAAI,EAAE,CAAA;AACd,CAAC;AA9BD,kDA8BC","sourcesContent":["import { Bizplace } from '@things-factory/biz-base'\nimport { getRepository } from '@things-factory/shell'\n\nconst debug = require('debug')('things-factory:operato-hub:warehouse-middleware')\n\nexport async function warehouseMiddleware(context, next) {\n const { warehouseId } = context.params\n const { business } = context.state\n const { t } = context\n\n let warehouse: Bizplace\n\n debug('company and warehouse', business, warehouseId)\n\n if (!business) {\n context.throw(404, t('error.company not found'))\n }\n\n if (warehouseId) {\n warehouse = await getRepository(Bizplace).findOne({\n where: { id: warehouseId },\n relations: ['company', 'domain']\n })\n debug('warehouse', warehouseId, warehouse?.domain?.subdomain)\n\n if (!warehouse) {\n context.throw(404, t('error.warehouse not found'))\n }\n } else {\n context.throw(404, t('error.warehouse not found'))\n }\n\n context.state.warehouse = warehouse\n\n await next()\n}\n"]}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SeedBusinessDomain1597668478399 = void 0;
4
- const typeorm_1 = require("typeorm");
5
4
  const shell_1 = require("@things-factory/shell");
6
5
  const SEED_BUSINESS_DOMAIN = [
7
6
  {
@@ -11,13 +10,13 @@ const SEED_BUSINESS_DOMAIN = [
11
10
  ];
12
11
  class SeedBusinessDomain1597668478399 {
13
12
  async up(queryRunner) {
14
- const repository = (0, typeorm_1.getRepository)(shell_1.Domain);
13
+ const repository = (0, shell_1.getRepository)(shell_1.Domain);
15
14
  return await Promise.all(SEED_BUSINESS_DOMAIN.map(async (domain) => {
16
15
  await repository.save(Object.assign({}, domain));
17
16
  }));
18
17
  }
19
18
  async down(queryRunner) {
20
- const repository = (0, typeorm_1.getRepository)(shell_1.Domain);
19
+ const repository = (0, shell_1.getRepository)(shell_1.Domain);
21
20
  return await Promise.all(SEED_BUSINESS_DOMAIN.reverse().map(async (domain) => {
22
21
  await repository.delete({ subdomain: domain.subdomain });
23
22
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"1597668478399-SeedBusinessDomain.js","sourceRoot":"","sources":["../../server/migrations/1597668478399-SeedBusinessDomain.ts"],"names":[],"mappings":";;;AAAA,qCAAwE;AACxE,iDAA8C;AAE9C,MAAM,oBAAoB,GAAG;IAC3B;QACE,SAAS,EAAE,UAAU;QACrB,IAAI,EAAE,qBAAqB;KAC5B;CACF,CAAA;AAED,MAAa,+BAA+B;IACnC,KAAK,CAAC,EAAE,CAAC,WAAwB;QACtC,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,cAAM,CAAC,CAAA;QAExC,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,oBAAoB,CAAC,GAAG,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE;YACtC,MAAM,UAAU,CAAC,IAAI,mBAChB,MAAM,EACT,CAAA;QACJ,CAAC,CAAC,CACH,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAwB;QACxC,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,cAAM,CAAC,CAAA;QAExC,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,oBAAoB,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,MAAc,EAAE,EAAE;YAC1D,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAA;QAC1D,CAAC,CAAC,CACH,CAAA;IACH,CAAC;CACF;AAtBD,0EAsBC","sourcesContent":["import { MigrationInterface, QueryRunner, getRepository } from 'typeorm'\nimport { Domain } from '@things-factory/shell'\n\nconst SEED_BUSINESS_DOMAIN = [\n {\n subdomain: 'business',\n name: 'Business Hub Domain'\n }\n]\n\nexport class SeedBusinessDomain1597668478399 implements MigrationInterface {\n public async up(queryRunner: QueryRunner): Promise<any> {\n const repository = getRepository(Domain)\n\n return await Promise.all(\n SEED_BUSINESS_DOMAIN.map(async domain => {\n await repository.save({\n ...domain\n })\n })\n )\n }\n\n public async down(queryRunner: QueryRunner): Promise<any> {\n const repository = getRepository(Domain)\n\n return await Promise.all(\n SEED_BUSINESS_DOMAIN.reverse().map(async (domain: Domain) => {\n await repository.delete({ subdomain: domain.subdomain })\n })\n )\n }\n}\n"]}
1
+ {"version":3,"file":"1597668478399-SeedBusinessDomain.js","sourceRoot":"","sources":["../../server/migrations/1597668478399-SeedBusinessDomain.ts"],"names":[],"mappings":";;;AAEA,iDAA6D;AAE7D,MAAM,oBAAoB,GAAG;IAC3B;QACE,SAAS,EAAE,UAAU;QACrB,IAAI,EAAE,qBAAqB;KAC5B;CACF,CAAA;AAED,MAAa,+BAA+B;IACnC,KAAK,CAAC,EAAE,CAAC,WAAwB;QACtC,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,cAAM,CAAC,CAAA;QAExC,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,oBAAoB,CAAC,GAAG,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE;YACtC,MAAM,UAAU,CAAC,IAAI,mBAChB,MAAM,EACT,CAAA;QACJ,CAAC,CAAC,CACH,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAwB;QACxC,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,cAAM,CAAC,CAAA;QAExC,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,oBAAoB,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,MAAc,EAAE,EAAE;YAC1D,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAA;QAC1D,CAAC,CAAC,CACH,CAAA;IACH,CAAC;CACF;AAtBD,0EAsBC","sourcesContent":["import { MigrationInterface, QueryRunner } from 'typeorm'\n\nimport { Domain, getRepository } from '@things-factory/shell'\n\nconst SEED_BUSINESS_DOMAIN = [\n {\n subdomain: 'business',\n name: 'Business Hub Domain'\n }\n]\n\nexport class SeedBusinessDomain1597668478399 implements MigrationInterface {\n public async up(queryRunner: QueryRunner): Promise<any> {\n const repository = getRepository(Domain)\n\n return await Promise.all(\n SEED_BUSINESS_DOMAIN.map(async domain => {\n await repository.save({\n ...domain\n })\n })\n )\n }\n\n public async down(queryRunner: QueryRunner): Promise<any> {\n const repository = getRepository(Domain)\n\n return await Promise.all(\n SEED_BUSINESS_DOMAIN.reverse().map(async (domain: Domain) => {\n await repository.delete({ subdomain: domain.subdomain })\n })\n )\n }\n}\n"]}
@@ -350,7 +350,7 @@ class SeedBusinessRoles1597668478401 {
350
350
  // const privileges = await Promise.all(
351
351
  // role.privileges.map(
352
352
  // async privilege =>
353
- // await privilegeRepo.findOne({
353
+ // await privilegeRepo.findOneBy({
354
354
  // ...privilege
355
355
  // })
356
356
  // )
@@ -365,7 +365,7 @@ class SeedBusinessRoles1597668478401 {
365
365
  async down(queryRunner) {
366
366
  // const roleRepo = getRepository(Role)
367
367
  // const domainRepo = getRepository(Domain)
368
- // const domain = await domainRepo.findOne({ where: })
368
+ // const domain = await domainRepo.findOne({ where: ...})
369
369
  // return await Promise.all(
370
370
  // SEED_ROLES_PRIVILEGES.reverse().map(async (role: Role) => {
371
371
  // await roleRepo.delete({ domain, name: role.name })
@@ -1 +1 @@
1
- {"version":3,"file":"1597668478401-SeedBusinessRoles.js","sourceRoot":"","sources":["../../server/migrations/1597668478401-SeedBusinessRoles.ts"],"names":[],"mappings":";;;AAEA,MAAM,qBAAqB,GAAG;IAC5B;QACE,IAAI,EAAE,gBAAgB;QACtB,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,SAAS;aACpB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,SAAS;aACpB;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,UAAU;aACrB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,UAAU;aACrB;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,MAAM;aACjB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,MAAM;aACjB;SACF;KACF;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,SAAS;aACpB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,SAAS;aACpB;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,UAAU;aACrB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,UAAU;aACrB;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,MAAM;aACjB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,MAAM;aACjB;SACF;KACF;IACD;QACE,IAAI,EAAE,WAAW;QACjB,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,OAAO;g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EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAA;AAEnF,MAAa,8BAA8B;IAClC,KAAK,CAAC,EAAE,CAAC,WAAwB;QACtC,uCAAuC;QACvC,iDAAiD;QACjD,4BAA4B;QAC5B,8CAA8C;QAC9C,4CAA4C;QAC5C,6BAA6B;QAC7B,6BAA6B;QAC7B,0CAA0C;QAC1C,2BAA2B;QAC3B,eAAe;QACf,UAAU;QACV,QAAQ;QACR,4BAA4B;QAC5B,yBAAyB;QACzB,mBAAmB;QACnB,SAAS;QACT,OAAO;QACP,IAAI;IACN,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAwB;QACxC,uCAAuC;QACvC,2CAA2C;QAC3C,sDAAsD;QACtD,4BAA4B;QAC5B,gEAAgE;QAChE,yDAAyD;QACzD,OAAO;QACP,IAAI;IACN,CAAC;CACF;AAhCD,wEAgCC","sourcesContent":["import { MigrationInterface, QueryRunner } from 'typeorm'\n\nconst SEED_ROLES_PRIVILEGES = [\n {\n name: 'BUSINESS-OWNER',\n privileges: [\n {\n name: 'query',\n category: 'company'\n },\n {\n name: 'mutation',\n category: 'company'\n },\n {\n name: 'query',\n category: 'bizplace'\n },\n {\n name: 'mutation',\n category: 'bizplace'\n },\n {\n name: 'query',\n category: 'user'\n },\n {\n name: 'mutation',\n category: 'user'\n }\n ]\n },\n {\n name: 'BUSINESS-MANAGER',\n privileges: [\n {\n name: 'query',\n category: 'company'\n },\n {\n name: 'mutation',\n category: 'company'\n },\n {\n name: 'query',\n category: 'bizplace'\n },\n {\n name: 'mutation',\n category: 'bizplace'\n },\n {\n name: 'query',\n category: 'user'\n },\n {\n name: 'mutation',\n category: 'user'\n }\n ]\n },\n {\n name: 'DEVELOPER',\n privileges: [\n {\n name: 'query',\n category: 'company'\n },\n {\n name: 'mutation',\n category: 'company'\n },\n {\n name: 'query',\n category: 'bizplace'\n },\n {\n name: 'mutation',\n category: 'bizplace'\n },\n {\n name: 'query',\n category: 'user'\n },\n {\n name: 'mutation',\n category: 'user'\n }\n ]\n }\n // },\n // {\n // name: 'CUSTOMER',\n // privileges: [\n // {\n // name: 'query',\n // category: 'order_customer'\n // },\n // {\n // name: 'mutation',\n // category: 'order_customer'\n // },\n // {\n // name: 'query',\n // category: 'vas'\n // },\n // {\n // name: 'query',\n // category: 'user'\n // },\n // {\n // name: 'query',\n // category: 'bizplace'\n // },\n // {\n // name: 'query',\n // category: 'company'\n // },\n // {\n // name: 'query',\n // category: 'inventory'\n // },\n // {\n // name: 'mutation',\n // category: 'inventory'\n // },\n // {\n // name: 'mutation',\n // category: 'tutorial'\n // },\n // {\n // name: 'mutation',\n // category: 'inventory_adjustment_approval'\n // },\n // {\n // name: 'query',\n // category: 'vendor'\n // },\n // {\n // name: 'query',\n // category: 'contact_point'\n // },\n // {\n // name: 'query',\n // category: 'warehouse'\n // },\n // {\n // name: 'mutation',\n // category: 'worksheet_customer'\n // }\n // ]\n // },\n // {\n // name: 'OFFICE ADMIN',\n // privileges: [\n // {\n // name: 'query',\n // category: 'company'\n // },\n // {\n // name: 'mutation',\n // category: 'company'\n // },\n // {\n // name: 'query',\n // category: 'bizplace'\n // },\n // {\n // name: 'mutation',\n // category: 'bizplace'\n // },\n // {\n // name: 'query',\n // category: 'inventory'\n // },\n // {\n // name: 'mutation',\n // category: 'inventory'\n // },\n // {\n // name: 'query',\n // category: 'customer'\n // },\n // {\n // name: 'mutation',\n // category: 'customer'\n // },\n // {\n // name: 'query',\n // category: 'contact_point'\n // },\n // {\n // name: 'mutation',\n // category: 'contact_point'\n // },\n // {\n // name: 'query',\n // category: 'worksheet_control'\n // },\n // {\n // name: 'mutation',\n // category: 'worksheet_control'\n // },\n // {\n // name: 'query',\n // category: 'order_warehouse'\n // },\n // {\n // name: 'mutation',\n // category: 'order_warehouse'\n // },\n // {\n // name: 'mutation',\n // category: 'inventory_adjustment_approval'\n // },\n // {\n // name: 'query',\n // category: 'warehouse'\n // },\n // {\n // name: 'mutation',\n // category: 'warehouse'\n // },\n // {\n // name: 'query',\n // category: 'vas'\n // },\n // {\n // name: 'mutation',\n // category: 'vas'\n // },\n // {\n // name: 'query',\n // category: 'transport'\n // },\n // {\n // name: 'mutation',\n // category: 'transport'\n // }\n // ]\n // },\n // {\n // name: 'WAREHOUSE_MANAGER',\n // privileges: [\n // {\n // name: 'query',\n // category: 'vas'\n // },\n // {\n // name: 'query',\n // category: 'user'\n // },\n // {\n // name: 'query',\n // category: 'bizplace'\n // },\n // {\n // name: 'query',\n // category: 'inventory'\n // },\n // {\n // name: 'mutation',\n // category: 'inventory'\n // },\n // {\n // name: 'query',\n // category: 'warehouse'\n // },\n // {\n // name: 'mutation',\n // category: 'worksheet_control'\n // }\n // ]\n // },\n // {\n // name: 'WAREHOUSE_STAFF',\n // privileges: [\n // {\n // name: 'query',\n // category: 'vas'\n // },\n // {\n // name: 'query',\n // category: 'user'\n // },\n // {\n // name: 'query',\n // category: 'bizplace'\n // },\n // {\n // name: 'query',\n // category: 'inventory'\n // },\n // {\n // name: 'mutation',\n // category: 'inventory'\n // },\n // {\n // name: 'query',\n // category: 'warehouses'\n // },\n // {\n // name: 'query',\n // category: 'worksheet_execute'\n // },\n // {\n // name: 'mutation',\n // category: 'worksheet_execute'\n // },\n // {\n // name: 'mutation',\n // category: 'worksheet_control'\n // }\n // ]\n // },\n // {\n // name: 'ACCOUNTANT',\n // privileges: [\n // {\n // name: 'query',\n // category: 'user'\n // },\n // {\n // name: 'query',\n // category: 'bizplace'\n // },\n // {\n // name: 'query',\n // category: 'inventory'\n // },\n // {\n // name: 'query',\n // category: 'warehouses'\n // },\n // {\n // name: 'query',\n // category: 'order_warehouse'\n // }\n // ]\n // }\n]\n\nconst SEED_BUSINESS_DOMAIN = { subdomain: 'business', name: 'Business Hub Domain' }\n\nexport class SeedBusinessRoles1597668478401 implements MigrationInterface {\n public async up(queryRunner: QueryRunner): Promise<any> {\n // const roleRepo = getRepository(Role)\n // const privilegeRepo = getRepository(Privilege)\n // return await Promise.all(\n // SEED_ROLES_PRIVILEGES.map(async role => {\n // const privileges = await Promise.all(\n // role.privileges.map(\n // async privilege =>\n // await privilegeRepo.findOne({\n // ...privilege\n // })\n // )\n // )\n // await roleRepo.save({\n // name: role.name,\n // privileges\n // })\n // })\n // )\n }\n\n public async down(queryRunner: QueryRunner): Promise<any> {\n // const roleRepo = getRepository(Role)\n // const domainRepo = getRepository(Domain)\n // const domain = await domainRepo.findOne({ where: })\n // return await Promise.all(\n // SEED_ROLES_PRIVILEGES.reverse().map(async (role: Role) => {\n // await roleRepo.delete({ domain, name: role.name })\n // })\n // )\n }\n}\n"]}
1
+ {"version":3,"file":"1597668478401-SeedBusinessRoles.js","sourceRoot":"","sources":["../../server/migrations/1597668478401-SeedBusinessRoles.ts"],"names":[],"mappings":";;;AAEA,MAAM,qBAAqB,GAAG;IAC5B;QACE,IAAI,EAAE,gBAAgB;QACtB,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,SAAS;aACpB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,SAAS;aACpB;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,UAAU;aACrB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,UAAU;aACrB;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,MAAM;aACjB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,MAAM;aACjB;SACF;KACF;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,SAAS;aACpB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,SAAS;aACpB;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,UAAU;aACrB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,UAAU;aACrB;YACD;gBACE,IAAI,EAA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ACT,QAAQ;IACR,uBAAuB;IACvB,+BAA+B;IAC/B,SAAS;IACT,QAAQ;IACR,uBAAuB;IACvB,oCAAoC;IACpC,QAAQ;IACR,MAAM;IACN,IAAI;CACL,CAAA;AAED,MAAM,oBAAoB,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAA;AAEnF,MAAa,8BAA8B;IAClC,KAAK,CAAC,EAAE,CAAC,WAAwB;QACtC,uCAAuC;QACvC,iDAAiD;QACjD,4BAA4B;QAC5B,8CAA8C;QAC9C,4CAA4C;QAC5C,6BAA6B;QAC7B,6BAA6B;QAC7B,4CAA4C;QAC5C,2BAA2B;QAC3B,eAAe;QACf,UAAU;QACV,QAAQ;QACR,4BAA4B;QAC5B,yBAAyB;QACzB,mBAAmB;QACnB,SAAS;QACT,OAAO;QACP,IAAI;IACN,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAwB;QACxC,uCAAuC;QACvC,2CAA2C;QAC3C,yDAAyD;QACzD,4BAA4B;QAC5B,gEAAgE;QAChE,yDAAyD;QACzD,OAAO;QACP,IAAI;IACN,CAAC;CACF;AAhCD,wEAgCC","sourcesContent":["import { MigrationInterface, QueryRunner } from 'typeorm'\n\nconst SEED_ROLES_PRIVILEGES = [\n {\n name: 'BUSINESS-OWNER',\n privileges: [\n {\n name: 'query',\n category: 'company'\n },\n {\n name: 'mutation',\n category: 'company'\n },\n {\n name: 'query',\n category: 'bizplace'\n },\n {\n name: 'mutation',\n category: 'bizplace'\n },\n {\n name: 'query',\n category: 'user'\n },\n {\n name: 'mutation',\n category: 'user'\n }\n ]\n },\n {\n name: 'BUSINESS-MANAGER',\n privileges: [\n {\n name: 'query',\n category: 'company'\n },\n {\n name: 'mutation',\n category: 'company'\n },\n {\n name: 'query',\n category: 'bizplace'\n },\n {\n name: 'mutation',\n category: 'bizplace'\n },\n {\n name: 'query',\n category: 'user'\n },\n {\n name: 'mutation',\n category: 'user'\n }\n ]\n },\n {\n name: 'DEVELOPER',\n privileges: [\n {\n name: 'query',\n category: 'company'\n },\n {\n name: 'mutation',\n category: 'company'\n },\n {\n name: 'query',\n category: 'bizplace'\n },\n {\n name: 'mutation',\n category: 'bizplace'\n },\n {\n name: 'query',\n category: 'user'\n },\n {\n name: 'mutation',\n category: 'user'\n }\n ]\n }\n // },\n // {\n // name: 'CUSTOMER',\n // privileges: [\n // {\n // name: 'query',\n // category: 'order_customer'\n // },\n // {\n // name: 'mutation',\n // category: 'order_customer'\n // },\n // {\n // name: 'query',\n // category: 'vas'\n // },\n // {\n // name: 'query',\n // category: 'user'\n // },\n // {\n // name: 'query',\n // category: 'bizplace'\n // },\n // {\n // name: 'query',\n // category: 'company'\n // },\n // {\n // name: 'query',\n // category: 'inventory'\n // },\n // {\n // name: 'mutation',\n // category: 'inventory'\n // },\n // {\n // name: 'mutation',\n // category: 'tutorial'\n // },\n // {\n // name: 'mutation',\n // category: 'inventory_adjustment_approval'\n // },\n // {\n // name: 'query',\n // category: 'vendor'\n // },\n // {\n // name: 'query',\n // category: 'contact_point'\n // },\n // {\n // name: 'query',\n // category: 'warehouse'\n // },\n // {\n // name: 'mutation',\n // category: 'worksheet_customer'\n // }\n // ]\n // },\n // {\n // name: 'OFFICE ADMIN',\n // privileges: [\n // {\n // name: 'query',\n // category: 'company'\n // },\n // {\n // name: 'mutation',\n // category: 'company'\n // },\n // {\n // name: 'query',\n // category: 'bizplace'\n // },\n // {\n // name: 'mutation',\n // category: 'bizplace'\n // },\n // {\n // name: 'query',\n // category: 'inventory'\n // },\n // {\n // name: 'mutation',\n // category: 'inventory'\n // },\n // {\n // name: 'query',\n // category: 'customer'\n // },\n // {\n // name: 'mutation',\n // category: 'customer'\n // },\n // {\n // name: 'query',\n // category: 'contact_point'\n // },\n // {\n // name: 'mutation',\n // category: 'contact_point'\n // },\n // {\n // name: 'query',\n // category: 'worksheet_control'\n // },\n // {\n // name: 'mutation',\n // category: 'worksheet_control'\n // },\n // {\n // name: 'query',\n // category: 'order_warehouse'\n // },\n // {\n // name: 'mutation',\n // category: 'order_warehouse'\n // },\n // {\n // name: 'mutation',\n // category: 'inventory_adjustment_approval'\n // },\n // {\n // name: 'query',\n // category: 'warehouse'\n // },\n // {\n // name: 'mutation',\n // category: 'warehouse'\n // },\n // {\n // name: 'query',\n // category: 'vas'\n // },\n // {\n // name: 'mutation',\n // category: 'vas'\n // },\n // {\n // name: 'query',\n // category: 'transport'\n // },\n // {\n // name: 'mutation',\n // category: 'transport'\n // }\n // ]\n // },\n // {\n // name: 'WAREHOUSE_MANAGER',\n // privileges: [\n // {\n // name: 'query',\n // category: 'vas'\n // },\n // {\n // name: 'query',\n // category: 'user'\n // },\n // {\n // name: 'query',\n // category: 'bizplace'\n // },\n // {\n // name: 'query',\n // category: 'inventory'\n // },\n // {\n // name: 'mutation',\n // category: 'inventory'\n // },\n // {\n // name: 'query',\n // category: 'warehouse'\n // },\n // {\n // name: 'mutation',\n // category: 'worksheet_control'\n // }\n // ]\n // },\n // {\n // name: 'WAREHOUSE_STAFF',\n // privileges: [\n // {\n // name: 'query',\n // category: 'vas'\n // },\n // {\n // name: 'query',\n // category: 'user'\n // },\n // {\n // name: 'query',\n // category: 'bizplace'\n // },\n // {\n // name: 'query',\n // category: 'inventory'\n // },\n // {\n // name: 'mutation',\n // category: 'inventory'\n // },\n // {\n // name: 'query',\n // category: 'warehouses'\n // },\n // {\n // name: 'query',\n // category: 'worksheet_execute'\n // },\n // {\n // name: 'mutation',\n // category: 'worksheet_execute'\n // },\n // {\n // name: 'mutation',\n // category: 'worksheet_control'\n // }\n // ]\n // },\n // {\n // name: 'ACCOUNTANT',\n // privileges: [\n // {\n // name: 'query',\n // category: 'user'\n // },\n // {\n // name: 'query',\n // category: 'bizplace'\n // },\n // {\n // name: 'query',\n // category: 'inventory'\n // },\n // {\n // name: 'query',\n // category: 'warehouses'\n // },\n // {\n // name: 'query',\n // category: 'order_warehouse'\n // }\n // ]\n // }\n]\n\nconst SEED_BUSINESS_DOMAIN = { subdomain: 'business', name: 'Business Hub Domain' }\n\nexport class SeedBusinessRoles1597668478401 implements MigrationInterface {\n public async up(queryRunner: QueryRunner): Promise<any> {\n // const roleRepo = getRepository(Role)\n // const privilegeRepo = getRepository(Privilege)\n // return await Promise.all(\n // SEED_ROLES_PRIVILEGES.map(async role => {\n // const privileges = await Promise.all(\n // role.privileges.map(\n // async privilege =>\n // await privilegeRepo.findOneBy({\n // ...privilege\n // })\n // )\n // )\n // await roleRepo.save({\n // name: role.name,\n // privileges\n // })\n // })\n // )\n }\n\n public async down(queryRunner: QueryRunner): Promise<any> {\n // const roleRepo = getRepository(Role)\n // const domainRepo = getRepository(Domain)\n // const domain = await domainRepo.findOne({ where: ...})\n // return await Promise.all(\n // SEED_ROLES_PRIVILEGES.reverse().map(async (role: Role) => {\n // await roleRepo.delete({ domain, name: role.name })\n // })\n // )\n }\n}\n"]}
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SeedUser1608009991065 = void 0;
4
4
  const auth_base_1 = require("@things-factory/auth-base");
5
5
  const shell_1 = require("@things-factory/shell");
6
- const typeorm_1 = require("typeorm");
7
6
  const company_initializer_1 = require("../controllers/company-initializer");
8
7
  const ADMIN_USER = {
9
8
  name: 'Admin',
@@ -14,8 +13,8 @@ const ADMIN_USER = {
14
13
  };
15
14
  class SeedUser1608009991065 {
16
15
  async up(queryRunner) {
17
- const userRepository = (0, typeorm_1.getRepository)(auth_base_1.User);
18
- const domainRepository = (0, typeorm_1.getRepository)(shell_1.Domain);
16
+ const userRepository = (0, shell_1.getRepository)(auth_base_1.User);
17
+ const domainRepository = (0, shell_1.getRepository)(shell_1.Domain);
19
18
  let adminUser = await userRepository.findOne({ where: { name: ADMIN_USER.name }, relations: ['domains'] });
20
19
  let systemDomain = await domainRepository.findOne({ where: { systemFlag: true } });
21
20
  if (!adminUser) {
@@ -41,10 +40,10 @@ class SeedUser1608009991065 {
41
40
  await (0, company_initializer_1.businessRegister)(systemDomain, companyInput, adminUser);
42
41
  }
43
42
  async down(queryRunner) {
44
- const userRepository = (0, typeorm_1.getRepository)(auth_base_1.User);
45
- const domainRepository = (0, typeorm_1.getRepository)(shell_1.Domain);
43
+ const userRepository = (0, shell_1.getRepository)(auth_base_1.User);
44
+ const domainRepository = (0, shell_1.getRepository)(shell_1.Domain);
46
45
  const user = await userRepository.findOne({ where: { name: ADMIN_USER.name } });
47
- await userRepository.delete(user);
46
+ await userRepository.delete({ id: user.id });
48
47
  const systemDomain = await domainRepository.findOne({ where: { systemFlag: true } });
49
48
  await domainRepository.delete(systemDomain);
50
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"1608009991065-SeedUser.js","sourceRoot":"","sources":["../../server/migrations/1608009991065-SeedUser.ts"],"names":[],"mappings":";;;AAAA,yDAA4D;AAE5D,iDAA8C;AAC9C,qCAAoF;AACpF,4EAAqE;AAErE,MAAM,UAAU,GAAG;IACjB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,oBAAoB;IAC3B,QAAQ,EAAE,OAAO;IACjB,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,sBAAU,CAAC,SAAS;CAC7B,CAAA;AACD,MAAa,qBAAqB;IACzB,KAAK,CAAC,EAAE,CAAC,WAAwB;QACtC,MAAM,cAAc,GAAqB,IAAA,uBAAa,EAAC,gBAAI,CAAC,CAAA;QAC5D,MAAM,gBAAgB,GAAuB,IAAA,uBAAa,EAAC,cAAM,CAAC,CAAA;QAElE,IAAI,SAAS,GAAS,MAAM,cAAc,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAChH,IAAI,YAAY,GAAW,MAAM,gBAAgB,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;QAE1F,IAAI,CAAC,SAAS,EA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,CAAA;QACpF,MAAM,gBAAgB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAC7C,CAAC;CACF;AAhDD,sDAgDC","sourcesContent":["import { User, UserStatus } from '@things-factory/auth-base'\nimport { Company } from '@things-factory/biz-base'\nimport { Domain } from '@things-factory/shell'\nimport { getRepository, MigrationInterface, QueryRunner, Repository } from 'typeorm'\nimport { businessRegister } from '../controllers/company-initializer'\n\nconst ADMIN_USER = {\n name: 'Admin',\n email: 'admin@hatiolab.com',\n password: 'admin',\n userType: 'user',\n status: UserStatus.ACTIVATED\n}\nexport class SeedUser1608009991065 implements MigrationInterface {\n public async up(queryRunner: QueryRunner): Promise<any> {\n const userRepository: Repository<User> = getRepository(User)\n const domainRepository: Repository<Domain> = getRepository(Domain)\n\n let adminUser: User = await userRepository.findOne({ where: { name: ADMIN_USER.name }, relations: ['domains'] })\n let systemDomain: Domain = await domainRepository.findOne({ where: { systemFlag: true } })\n\n if (!adminUser) {\n const salt = User.generateSalt()\n\n adminUser = await userRepository.save({\n ...ADMIN_USER,\n salt,\n password: User.encode(ADMIN_USER.password, salt)\n })\n } else {\n adminUser.userType = 'user'\n await userRepository.save(adminUser)\n }\n\n if (systemDomain) {\n systemDomain.extType = 'company'\n await domainRepository.save(systemDomain)\n }\n\n const companyInput: Company = {\n name: systemDomain.name,\n description: systemDomain.description || null,\n address: '',\n postalCode: '',\n countryCode: '',\n brn: ''\n }\n\n await businessRegister(systemDomain, companyInput, adminUser)\n }\n\n public async down(queryRunner: QueryRunner): Promise<any> {\n const userRepository = getRepository(User)\n const domainRepository = getRepository(Domain)\n\n const user = await userRepository.findOne({ where: { name: ADMIN_USER.name } })\n await userRepository.delete(user)\n\n const systemDomain = await domainRepository.findOne({ where: { systemFlag: true } })\n await domainRepository.delete(systemDomain)\n }\n}\n"]}
1
+ {"version":3,"file":"1608009991065-SeedUser.js","sourceRoot":"","sources":["../../server/migrations/1608009991065-SeedUser.ts"],"names":[],"mappings":";;;AAEA,yDAA4D;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I;YACvB,WAAW,EAAE,YAAY,CAAC,WAAW,IAAI,IAAI;YAC7C,OAAO,EAAE,EAAE;YACX,UAAU,EAAE,EAAE;YACd,WAAW,EAAE,EAAE;YACf,GAAG,EAAE,EAAE;SACR,CAAA;QAED,MAAM,IAAA,sCAAgB,EAAC,YAAY,EAAE,YAAY,EAAE,SAAS,CAAC,CAAA;IAC/D,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAwB;QACxC,MAAM,cAAc,GAAG,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAA;QAC1C,MAAM,gBAAgB,GAAG,IAAA,qBAAa,EAAC,cAAM,CAAC,CAAA;QAE9C,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QAC/E,MAAM,cAAc,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;QAE5C,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;QACpF,MAAM,gBAAgB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAC7C,CAAC;CACF;AAhDD,sDAgDC","sourcesContent":["import { MigrationInterface, QueryRunner, Repository } from 'typeorm'\n\nimport { User, UserStatus } from '@things-factory/auth-base'\nimport { Company } from '@things-factory/biz-base'\nimport { Domain, getRepository } from '@things-factory/shell'\n\nimport { businessRegister } from '../controllers/company-initializer'\n\nconst ADMIN_USER = {\n name: 'Admin',\n email: 'admin@hatiolab.com',\n password: 'admin',\n userType: 'user',\n status: UserStatus.ACTIVATED\n}\nexport class SeedUser1608009991065 implements MigrationInterface {\n public async up(queryRunner: QueryRunner): Promise<any> {\n const userRepository: Repository<User> = getRepository(User)\n const domainRepository: Repository<Domain> = getRepository(Domain)\n\n let adminUser: User = await userRepository.findOne({ where: { name: ADMIN_USER.name }, relations: ['domains'] })\n let systemDomain: Domain = await domainRepository.findOne({ where: { systemFlag: true } })\n\n if (!adminUser) {\n const salt = User.generateSalt()\n\n adminUser = await userRepository.save({\n ...ADMIN_USER,\n salt,\n password: User.encode(ADMIN_USER.password, salt)\n })\n } else {\n adminUser.userType = 'user'\n await userRepository.save(adminUser)\n }\n\n if (systemDomain) {\n systemDomain.extType = 'company'\n await domainRepository.save(systemDomain)\n }\n\n const companyInput: Company = {\n name: systemDomain.name,\n description: systemDomain.description || null,\n address: '',\n postalCode: '',\n countryCode: '',\n brn: ''\n }\n\n await businessRegister(systemDomain, companyInput, adminUser)\n }\n\n public async down(queryRunner: QueryRunner): Promise<any> {\n const userRepository = getRepository(User)\n const domainRepository = getRepository(Domain)\n\n const user = await userRepository.findOne({ where: { name: ADMIN_USER.name } })\n await userRepository.delete({ id: user.id })\n\n const systemDomain = await domainRepository.findOne({ where: { systemFlag: true } })\n await domainRepository.delete(systemDomain)\n }\n}\n"]}
@@ -116,7 +116,8 @@ api_1.restfulApiRouter.post('/unstable/warehouse/:warehouseId/add-draft-release-
116
116
  country: ((_o = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _o === void 0 ? void 0 : _o.country) || null,
117
117
  phone1: ((_p = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _p === void 0 ? void 0 : _p.phone1) || null,
118
118
  phone2: ((_q = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _q === void 0 ? void 0 : _q.phone2) || null,
119
- email: ((_r = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _r === void 0 ? void 0 : _r.email) || null
119
+ email: ((_r = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _r === void 0 ? void 0 : _r.email) || null,
120
+ packageId: (bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.packageId) || null
120
121
  },
121
122
  orderProducts: orderInventories,
122
123
  files: []