@things-factory/integration-sellercraft 9.0.0-beta.25 → 9.0.0-beta.27

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 (146) hide show
  1. package/package.json +4 -4
  2. package/dist-server/constants/index.d.ts +0 -2
  3. package/dist-server/constants/index.js +0 -6
  4. package/dist-server/constants/index.js.map +0 -1
  5. package/dist-server/constants/order-status-mapping.d.ts +0 -27
  6. package/dist-server/constants/order-status-mapping.js +0 -31
  7. package/dist-server/constants/order-status-mapping.js.map +0 -1
  8. package/dist-server/constants/platform.d.ts +0 -6
  9. package/dist-server/constants/platform.js +0 -10
  10. package/dist-server/constants/platform.js.map +0 -1
  11. package/dist-server/controllers/index.d.ts +0 -4
  12. package/dist-server/controllers/index.js +0 -8
  13. package/dist-server/controllers/index.js.map +0 -1
  14. package/dist-server/controllers/sellercraft/apis/add-inbound-order.d.ts +0 -8
  15. package/dist-server/controllers/sellercraft/apis/add-inbound-order.js +0 -46
  16. package/dist-server/controllers/sellercraft/apis/add-inbound-order.js.map +0 -1
  17. package/dist-server/controllers/sellercraft/apis/echo.d.ts +0 -12
  18. package/dist-server/controllers/sellercraft/apis/echo.js +0 -18
  19. package/dist-server/controllers/sellercraft/apis/echo.js.map +0 -1
  20. package/dist-server/controllers/sellercraft/apis/fetch-order-document.d.ts +0 -16
  21. package/dist-server/controllers/sellercraft/apis/fetch-order-document.js +0 -21
  22. package/dist-server/controllers/sellercraft/apis/fetch-order-document.js.map +0 -1
  23. package/dist-server/controllers/sellercraft/apis/index.d.ts +0 -8
  24. package/dist-server/controllers/sellercraft/apis/index.js +0 -12
  25. package/dist-server/controllers/sellercraft/apis/index.js.map +0 -1
  26. package/dist-server/controllers/sellercraft/apis/initiate-order-document.d.ts +0 -12
  27. package/dist-server/controllers/sellercraft/apis/initiate-order-document.js +0 -20
  28. package/dist-server/controllers/sellercraft/apis/initiate-order-document.js.map +0 -1
  29. package/dist-server/controllers/sellercraft/apis/initiate-order-shipment.d.ts +0 -17
  30. package/dist-server/controllers/sellercraft/apis/initiate-order-shipment.js +0 -26
  31. package/dist-server/controllers/sellercraft/apis/initiate-order-shipment.js.map +0 -1
  32. package/dist-server/controllers/sellercraft/apis/pack-marketplace-order.d.ts +0 -12
  33. package/dist-server/controllers/sellercraft/apis/pack-marketplace-order.js +0 -35
  34. package/dist-server/controllers/sellercraft/apis/pack-marketplace-order.js.map +0 -1
  35. package/dist-server/controllers/sellercraft/apis/update-marketplace-order.d.ts +0 -6
  36. package/dist-server/controllers/sellercraft/apis/update-marketplace-order.js +0 -17
  37. package/dist-server/controllers/sellercraft/apis/update-marketplace-order.js.map +0 -1
  38. package/dist-server/controllers/sellercraft/apis/update-product.d.ts +0 -11
  39. package/dist-server/controllers/sellercraft/apis/update-product.js +0 -23
  40. package/dist-server/controllers/sellercraft/apis/update-product.js.map +0 -1
  41. package/dist-server/controllers/sellercraft/index.d.ts +0 -1
  42. package/dist-server/controllers/sellercraft/index.js +0 -9
  43. package/dist-server/controllers/sellercraft/index.js.map +0 -1
  44. package/dist-server/controllers/sellercraft/platform-action.d.ts +0 -5
  45. package/dist-server/controllers/sellercraft/platform-action.js +0 -33
  46. package/dist-server/controllers/sellercraft/platform-action.js.map +0 -1
  47. package/dist-server/controllers/sellercraft/sellercraft.d.ts +0 -12
  48. package/dist-server/controllers/sellercraft/sellercraft.js +0 -91
  49. package/dist-server/controllers/sellercraft/sellercraft.js.map +0 -1
  50. package/dist-server/controllers/sellercraft-api/decorators.d.ts +0 -1
  51. package/dist-server/controllers/sellercraft-api/decorators.js +0 -38
  52. package/dist-server/controllers/sellercraft-api/decorators.js.map +0 -1
  53. package/dist-server/controllers/sellercraft-api/index.d.ts +0 -15
  54. package/dist-server/controllers/sellercraft-api/index.js +0 -84
  55. package/dist-server/controllers/sellercraft-api/index.js.map +0 -1
  56. package/dist-server/controllers/sellercraft-api/types.d.ts +0 -0
  57. package/dist-server/controllers/sellercraft-api/types.js +0 -1
  58. package/dist-server/controllers/sellercraft-api/types.js.map +0 -1
  59. package/dist-server/controllers/sellercraft-channel-integration/apis/echo.d.ts +0 -12
  60. package/dist-server/controllers/sellercraft-channel-integration/apis/echo.js +0 -18
  61. package/dist-server/controllers/sellercraft-channel-integration/apis/echo.js.map +0 -1
  62. package/dist-server/controllers/sellercraft-channel-integration/apis/index.d.ts +0 -6
  63. package/dist-server/controllers/sellercraft-channel-integration/apis/index.js +0 -10
  64. package/dist-server/controllers/sellercraft-channel-integration/apis/index.js.map +0 -1
  65. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.d.ts +0 -8
  66. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.js +0 -38
  67. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.js.map +0 -1
  68. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-category-attributes.d.ts +0 -11
  69. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-category-attributes.js +0 -47
  70. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-category-attributes.js.map +0 -1
  71. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.d.ts +0 -8
  72. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js +0 -48
  73. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js.map +0 -1
  74. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.d.ts +0 -8
  75. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js +0 -92
  76. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js.map +0 -1
  77. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.d.ts +0 -8
  78. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js +0 -90
  79. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js.map +0 -1
  80. package/dist-server/controllers/sellercraft-channel-integration/index.d.ts +0 -1
  81. package/dist-server/controllers/sellercraft-channel-integration/index.js +0 -9
  82. package/dist-server/controllers/sellercraft-channel-integration/index.js.map +0 -1
  83. package/dist-server/controllers/sellercraft-channel-integration/platform-action.d.ts +0 -5
  84. package/dist-server/controllers/sellercraft-channel-integration/platform-action.js +0 -33
  85. package/dist-server/controllers/sellercraft-channel-integration/platform-action.js.map +0 -1
  86. package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.d.ts +0 -12
  87. package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js +0 -99
  88. package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js.map +0 -1
  89. package/dist-server/controllers/sellercraft-channel-integration-api/decorators.d.ts +0 -1
  90. package/dist-server/controllers/sellercraft-channel-integration-api/decorators.js +0 -30
  91. package/dist-server/controllers/sellercraft-channel-integration-api/decorators.js.map +0 -1
  92. package/dist-server/controllers/sellercraft-channel-integration-api/index.d.ts +0 -13
  93. package/dist-server/controllers/sellercraft-channel-integration-api/index.js +0 -70
  94. package/dist-server/controllers/sellercraft-channel-integration-api/index.js.map +0 -1
  95. package/dist-server/controllers/sellercraft-channel-integration-api/types.d.ts +0 -0
  96. package/dist-server/controllers/sellercraft-channel-integration-api/types.js +0 -1
  97. package/dist-server/controllers/sellercraft-channel-integration-api/types.js.map +0 -1
  98. package/dist-server/index.d.ts +0 -6
  99. package/dist-server/index.js +0 -10
  100. package/dist-server/index.js.map +0 -1
  101. package/dist-server/middlewares/index.d.ts +0 -1
  102. package/dist-server/middlewares/index.js +0 -7
  103. package/dist-server/middlewares/index.js.map +0 -1
  104. package/dist-server/migrations/index.d.ts +0 -1
  105. package/dist-server/migrations/index.js +0 -12
  106. package/dist-server/migrations/index.js.map +0 -1
  107. package/dist-server/routers/sellercraft-router.d.ts +0 -1
  108. package/dist-server/routers/sellercraft-router.js +0 -284
  109. package/dist-server/routers/sellercraft-router.js.map +0 -1
  110. package/dist-server/routes.d.ts +0 -1
  111. package/dist-server/routes.js +0 -29
  112. package/dist-server/routes.js.map +0 -1
  113. package/dist-server/service/index.d.ts +0 -7
  114. package/dist-server/service/index.js +0 -23
  115. package/dist-server/service/index.js.map +0 -1
  116. package/dist-server/service/marketplace-channel/index.d.ts +0 -5
  117. package/dist-server/service/marketplace-channel/index.js +0 -9
  118. package/dist-server/service/marketplace-channel/index.js.map +0 -1
  119. package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.d.ts +0 -3
  120. package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js +0 -391
  121. package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js.map +0 -1
  122. package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.d.ts +0 -3
  123. package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js +0 -244
  124. package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js.map +0 -1
  125. package/dist-server/service/marketplace-channel/marketplace-channel.d.ts +0 -18
  126. package/dist-server/service/marketplace-channel/marketplace-channel.js +0 -84
  127. package/dist-server/service/marketplace-channel/marketplace-channel.js.map +0 -1
  128. package/dist-server/service/sellercraft/index.d.ts +0 -5
  129. package/dist-server/service/sellercraft/index.js +0 -9
  130. package/dist-server/service/sellercraft/index.js.map +0 -1
  131. package/dist-server/service/sellercraft/sellercraft-mutation.d.ts +0 -9
  132. package/dist-server/service/sellercraft/sellercraft-mutation.js +0 -111
  133. package/dist-server/service/sellercraft/sellercraft-mutation.js.map +0 -1
  134. package/dist-server/service/sellercraft/sellercraft-query.d.ts +0 -11
  135. package/dist-server/service/sellercraft/sellercraft-query.js +0 -71
  136. package/dist-server/service/sellercraft/sellercraft-query.js.map +0 -1
  137. package/dist-server/service/sellercraft/sellercraft-type.d.ts +0 -21
  138. package/dist-server/service/sellercraft/sellercraft-type.js +0 -81
  139. package/dist-server/service/sellercraft/sellercraft-type.js.map +0 -1
  140. package/dist-server/service/sellercraft/sellercraft.d.ts +0 -27
  141. package/dist-server/service/sellercraft/sellercraft.js +0 -107
  142. package/dist-server/service/sellercraft/sellercraft.js.map +0 -1
  143. package/dist-server/tsconfig.tsbuildinfo +0 -1
  144. package/dist-server/utils/tokencraft-util.d.ts +0 -2
  145. package/dist-server/utils/tokencraft-util.js +0 -62
  146. package/dist-server/utils/tokencraft-util.js.map +0 -1
@@ -1,244 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MarketplaceChannelProductMutation = void 0;
4
- const tslib_1 = require("tslib");
5
- const type_graphql_1 = require("type-graphql");
6
- const env_1 = require("@things-factory/env");
7
- const integration_marketplace_1 = require("@things-factory/integration-marketplace");
8
- const shell_1 = require("@things-factory/shell");
9
- const sellercraft_channel_integration_api_1 = require("../../controllers/sellercraft-channel-integration-api");
10
- const tokencraft_util_1 = require("../../utils/tokencraft-util");
11
- const marketplace_channel_1 = require("./marketplace-channel");
12
- let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation {
13
- async syncAllMarketplaceChannelProducts(context, fromUpdatedDate, toUpdatedDate, productBatchSize, channelId, shopId, airflow) {
14
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
15
- const sellercraftChannelIntegrationConfig = env_1.config.get('sellercraftChannelIntegrationConfig', {});
16
- let channels = await (0, shell_1.getRepository)(marketplace_channel_1.MarketplaceChannel).find({ where: { isActive: true } });
17
- let errors = [];
18
- if (channelId) {
19
- channels = channels.filter(channel => channel.channelId == channelId);
20
- }
21
- for (var i = 0; i < channels.length; i++) {
22
- try {
23
- let shops = await (0, tokencraft_util_1.getShops)(channels[i].channelId);
24
- if (shopId) {
25
- shops = shops.filter(shop => shop.channel_shop_id == shopId);
26
- }
27
- for (var j = 0; j < shops.length; j++) {
28
- try {
29
- var store = {
30
- accessKey: ((_b = (_a = shops[j]) === null || _a === void 0 ? void 0 : _a.credential) === null || _b === void 0 ? void 0 : _b.consumer_key) || '',
31
- accessSecret: ((_d = (_c = shops[j]) === null || _c === void 0 ? void 0 : _c.credential) === null || _d === void 0 ? void 0 : _d.consumer_secret) || '',
32
- storeURL: ((_f = (_e = shops[j]) === null || _e === void 0 ? void 0 : _e.credential) === null || _f === void 0 ? void 0 : _f.store_url) || '',
33
- platform: channels[i].name,
34
- accessToken: (_h = (_g = shops[j]) === null || _g === void 0 ? void 0 : _g.credential) === null || _h === void 0 ? void 0 : _h.access_token, // Magento+, Tiktok
35
- channelShopId: (_j = shops[j]) === null || _j === void 0 ? void 0 : _j.channel_shop_id,
36
- storeId: ((_l = (_k = shops[j]) === null || _k === void 0 ? void 0 : _k.credential) === null || _l === void 0 ? void 0 : _l.store_url) || ''
37
- };
38
- let countryCode = shops[j].country_code;
39
- let channelCode = shops[j].org_prefix;
40
- let organisationId = shops[j].account_id;
41
- let channelShopId = shops[j].channel_shop_id;
42
- var sellercraftStore = Object.assign(Object.assign({}, store), { platform: 'sellercraftChannelIntegration' });
43
- const productResult = [];
44
- let totalPages = 1;
45
- let limit = 50;
46
- let parentLinks = [];
47
- let cursor;
48
- for (let page = 0; page < totalPages; page++) {
49
- const { results, total, parentLinkList, page_info: nextCursor } = await integration_marketplace_1.StoreAPI.getStoreProducts(store, {
50
- pagination: { page, limit },
51
- pageInfo: cursor,
52
- fromUpdatedDate,
53
- toUpdatedDate
54
- });
55
- totalPages = Math.ceil(total / limit);
56
- productResult.push(...results);
57
- if (store.platform == 'magento')
58
- parentLinks.push(...parentLinkList);
59
- cursor = nextCursor;
60
- }
61
- const categoryResult = [];
62
- let totalPagesCategory = 1;
63
- let limitCategory = 100;
64
- if (store.platform != 'shopify') {
65
- for (let page = 0; page < totalPagesCategory; page++) {
66
- const { results, total } = await integration_marketplace_1.StoreAPI.getStoreProductCategories(store, {
67
- pagination: { page, limitCategory }
68
- });
69
- totalPagesCategory = Math.ceil(total / limitCategory);
70
- categoryResult.push(...results);
71
- }
72
- }
73
- else {
74
- categoryResult.push({ id: 1, name: 'default', isActive: true });
75
- }
76
- let mappedProducts = productResult.map(item => {
77
- var _a;
78
- let { categoryId, itemId: productId, name, brand, isVerified, images, sellercraftAttributes, variations } = item;
79
- variations = variations.map(variation => {
80
- let { variationSku, variationId, name, isEnabled: isEnabled, isSellable: isSellable, sellercraftAttributes, stockLocked, qty: stockReported, costPrice: fullPrice, sellPrice: priceDiscounted, length, width, height, weight, extraMetadata } = variation;
81
- return {
82
- variationSku,
83
- variationId,
84
- name,
85
- isEnabled,
86
- isSellable,
87
- attributes: sellercraftAttributes || [],
88
- stockLocked,
89
- stockReported,
90
- fullPrice: parseFloat(fullPrice) || 0,
91
- priceDiscounted: parseFloat(priceDiscounted) || 0,
92
- inventoryProducts: [
93
- {
94
- qty: 1,
95
- name: `${name} - ${variationSku}`,
96
- sku: variationSku,
97
- productVersions: [
98
- {
99
- label: 'Default',
100
- packageLengthMM: length,
101
- packageWidthMM: width,
102
- packageHeightMM: height,
103
- packageWeightGram: weight,
104
- qty: stockReported
105
- }
106
- ]
107
- }
108
- ],
109
- extraMetadata
110
- };
111
- });
112
- images = images === null || images === void 0 ? void 0 : images.map(image => {
113
- return {
114
- url: image
115
- };
116
- });
117
- return {
118
- organisationId,
119
- channelShopId: channelShopId,
120
- channelCode: channels[i].channelCode,
121
- channelCountry: shops[j].country_code,
122
- categoryId: store.platform == 'shopify' ? 1 : categoryId,
123
- productId: ((_a = parentLinks.find(e => e.children.includes(productId))) === null || _a === void 0 ? void 0 : _a.id) || productId,
124
- name,
125
- brand,
126
- isVerified,
127
- images,
128
- attributes: sellercraftAttributes || [],
129
- variations
130
- };
131
- });
132
- let mappedCategories = categoryResult.map(category => {
133
- let { id: categoryId, name: categoryName, parent, isActive } = category;
134
- return {
135
- categoryId,
136
- categoryName,
137
- parent,
138
- isActive: isActive || true,
139
- channelCode,
140
- countryCode,
141
- childrenCategories: []
142
- };
143
- });
144
- if (store.platform == 'magento') {
145
- let newList = [];
146
- for (let np of mappedProducts) {
147
- if (np.productId == np.variations[0].variationId) {
148
- let vars = mappedProducts
149
- .filter(e => e.productId == np.productId)
150
- .map(e => {
151
- return e.variations[0];
152
- });
153
- np.variations = vars;
154
- if (np.variations.length > 1) {
155
- np.variations = np.variations.filter(v => v.variationId != np.productId);
156
- }
157
- newList.push(np);
158
- }
159
- }
160
- mappedProducts = newList;
161
- }
162
- try {
163
- let filterList = [];
164
- mappedCategories = mappedCategories.map(category => {
165
- if (mappedCategories.filter(e => e.parent == category.categoryId).length > 0) {
166
- category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId);
167
- filterList.push(...mappedCategories.filter(e => e.parent == category.categoryId));
168
- }
169
- return category;
170
- });
171
- mappedCategories = mappedCategories
172
- .map(mc => {
173
- if (filterList.indexOf(mc) == -1) {
174
- return mc;
175
- }
176
- })
177
- .filter(e => e);
178
- await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {
179
- categories: mappedCategories
180
- });
181
- }
182
- catch (e) {
183
- errors.push({
184
- name: 'Category Ingestion Error',
185
- msg: JSON.stringify(e) || {}
186
- });
187
- }
188
- let bs = parseInt(productBatchSize) || mappedProducts.length;
189
- if (mappedProducts.length > 0) {
190
- while (mappedProducts.length > 0) {
191
- let spliceResult = mappedProducts.splice(0, mappedProducts.length >= bs ? bs : mappedProducts.length);
192
- try {
193
- await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelProduct(sellercraftStore, {
194
- products: spliceResult
195
- });
196
- }
197
- catch (e) {
198
- errors.push({
199
- name: 'Product Ingestion Error',
200
- msg: JSON.stringify(e) || {}
201
- });
202
- }
203
- }
204
- }
205
- }
206
- catch (e) {
207
- errors.push({
208
- name: 'Product Processing / Mapping Error',
209
- msg: JSON.stringify(e) || {}
210
- });
211
- }
212
- }
213
- }
214
- catch (e) {
215
- errors.push({
216
- name: 'Store Error',
217
- msg: JSON.stringify(e) || {}
218
- });
219
- }
220
- }
221
- if (errors.length > 1 && airflow) {
222
- throw errors;
223
- }
224
- return true;
225
- }
226
- };
227
- exports.MarketplaceChannelProductMutation = MarketplaceChannelProductMutation;
228
- tslib_1.__decorate([
229
- (0, type_graphql_1.Mutation)(returns => Boolean),
230
- tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
231
- tslib_1.__param(1, (0, type_graphql_1.Arg)('fromUpdatedDate', { nullable: true })),
232
- tslib_1.__param(2, (0, type_graphql_1.Arg)('toUpdatedDate', { nullable: true })),
233
- tslib_1.__param(3, (0, type_graphql_1.Arg)('productBatchSize', { nullable: true })),
234
- tslib_1.__param(4, (0, type_graphql_1.Arg)('channelId', { nullable: true })),
235
- tslib_1.__param(5, (0, type_graphql_1.Arg)('shopId', { nullable: true })),
236
- tslib_1.__param(6, (0, type_graphql_1.Arg)('airflow', { nullable: true })),
237
- tslib_1.__metadata("design:type", Function),
238
- tslib_1.__metadata("design:paramtypes", [Object, String, String, String, String, String, Boolean]),
239
- tslib_1.__metadata("design:returntype", Promise)
240
- ], MarketplaceChannelProductMutation.prototype, "syncAllMarketplaceChannelProducts", null);
241
- exports.MarketplaceChannelProductMutation = MarketplaceChannelProductMutation = tslib_1.__decorate([
242
- (0, type_graphql_1.Resolver)()
243
- ], MarketplaceChannelProductMutation);
244
- //# sourceMappingURL=marketplace-channel-product-mutation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"marketplace-channel-product-mutation.js","sourceRoot":"","sources":["../../../server/service/marketplace-channel/marketplace-channel-product-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAA2D;AAE3D,6CAA4C;AAC5C,qFAAkE;AAClE,iDAAqD;AAErD,+GAAwG;AACxG,iEAAsD;AACtD,+DAA0D;AAGnD,IAAM,iCAAiC,GAAvC,MAAM,iCAAiC;IAEtC,AAAN,KAAK,CAAC,iCAAiC,CAC9B,OAAwB,EACa,eAAwB,EAC1B,aAAsB,EACnB,gBAAyB,EAChC,SAAkB,EACrB,MAAe,EACd,OAAiB;;QAErD,MAAM,mCAAmC,GAAG,YAAM,CAAC,GAAG,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAA;QAEjG,IAAI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AC,EAAE,CAAC;gBACX,MAAM,CAAC,IAAI,CAAC;oBACV,IAAI,EAAE,aAAa;oBACnB,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE;iBAC7B,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC;YACjC,MAAM,MAAM,CAAA;QACd,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AA9QY,8EAAiC;AAEtC;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;IAE1B,mBAAA,IAAA,kBAAG,GAAE,CAAA;IACL,mBAAA,IAAA,kBAAG,EAAC,iBAAiB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1C,mBAAA,IAAA,kBAAG,EAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IACxC,mBAAA,IAAA,kBAAG,EAAC,kBAAkB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3C,mBAAA,IAAA,kBAAG,EAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IACpC,mBAAA,IAAA,kBAAG,EAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IACjC,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;;;0FAoQpC;4CA7QU,iCAAiC;IAD7C,IAAA,uBAAQ,GAAE;GACE,iCAAiC,CA8Q7C","sourcesContent":["import { Arg, Ctx, Mutation, Resolver } from 'type-graphql'\n\nimport { config } from '@things-factory/env'\nimport { StoreAPI } from '@things-factory/integration-marketplace'\nimport { getRepository } from '@things-factory/shell'\n\nimport { SellercraftChannelIntegrationAPI } from '../../controllers/sellercraft-channel-integration-api'\nimport { getShops } from '../../utils/tokencraft-util'\nimport { MarketplaceChannel } from './marketplace-channel'\n\n@Resolver()\nexport class MarketplaceChannelProductMutation {\n @Mutation(returns => Boolean)\n async syncAllMarketplaceChannelProducts(\n @Ctx() context: ResolverContext,\n @Arg('fromUpdatedDate', { nullable: true }) fromUpdatedDate?: string,\n @Arg('toUpdatedDate', { nullable: true }) toUpdatedDate?: string,\n @Arg('productBatchSize', { nullable: true }) productBatchSize?: string,\n @Arg('channelId', { nullable: true }) channelId?: string,\n @Arg('shopId', { nullable: true }) shopId?: string,\n @Arg('airflow', { nullable: true }) airflow?: boolean\n ): Promise<boolean> {\n const sellercraftChannelIntegrationConfig = config.get('sellercraftChannelIntegrationConfig', {})\n\n let channels: MarketplaceChannel[] = await getRepository(MarketplaceChannel).find({ where: { isActive: true } })\n let errors: any = []\n\n if (channelId) {\n channels = channels.filter(channel => channel.channelId == channelId)\n }\n\n for (var i = 0; i < channels.length; i++) {\n try {\n let shops: any = await getShops(channels[i].channelId)\n\n if (shopId) {\n shops = shops.filter(shop => shop.channel_shop_id == shopId)\n }\n\n for (var j = 0; j < shops.length; j++) {\n try {\n var store = {\n accessKey: shops[j]?.credential?.consumer_key || '',\n accessSecret: shops[j]?.credential?.consumer_secret || '',\n storeURL: shops[j]?.credential?.store_url || '',\n platform: channels[i].name,\n accessToken: shops[j]?.credential?.access_token, // Magento+, Tiktok\n channelShopId: shops[j]?.channel_shop_id,\n storeId: shops[j]?.credential?.store_url || ''\n }\n\n let countryCode = shops[j].country_code\n let channelCode = shops[j].org_prefix\n let organisationId = shops[j].account_id\n let channelShopId = shops[j].channel_shop_id\n\n var sellercraftStore = { ...store, platform: 'sellercraftChannelIntegration' }\n\n const productResult = []\n let totalPages: number = 1\n let limit: number = 50\n let parentLinks = []\n let cursor: string\n\n for (let page = 0; page < totalPages; page++) {\n const {\n results,\n total,\n parentLinkList,\n page_info: nextCursor\n } = await StoreAPI.getStoreProducts(store, {\n pagination: { page, limit },\n pageInfo: cursor,\n fromUpdatedDate,\n toUpdatedDate\n })\n totalPages = Math.ceil(total / limit)\n productResult.push(...results)\n if (store.platform == 'magento') parentLinks.push(...parentLinkList)\n cursor = nextCursor\n }\n\n const categoryResult = []\n let totalPagesCategory: number = 1\n let limitCategory: number = 100\n\n if (store.platform != 'shopify') {\n for (let page = 0; page < totalPagesCategory; page++) {\n const { results, total } = await StoreAPI.getStoreProductCategories(store, {\n pagination: { page, limitCategory }\n })\n totalPagesCategory = Math.ceil(total / limitCategory)\n categoryResult.push(...results)\n }\n } else {\n categoryResult.push({ id: 1, name: 'default', isActive: true })\n }\n\n let mappedProducts = productResult.map(item => {\n let {\n categoryId,\n itemId: productId,\n name,\n brand,\n isVerified,\n images,\n sellercraftAttributes,\n variations\n } = item\n\n variations = variations.map(variation => {\n let {\n variationSku,\n variationId,\n name,\n isEnabled: isEnabled,\n isSellable: isSellable,\n sellercraftAttributes,\n stockLocked,\n qty: stockReported,\n costPrice: fullPrice,\n sellPrice: priceDiscounted,\n length,\n width,\n height,\n weight,\n extraMetadata\n } = variation\n\n return {\n variationSku,\n variationId,\n name,\n isEnabled,\n isSellable,\n attributes: sellercraftAttributes || [],\n stockLocked,\n stockReported,\n fullPrice: parseFloat(fullPrice) || 0,\n priceDiscounted: parseFloat(priceDiscounted) || 0,\n inventoryProducts: [\n {\n qty: 1,\n name: `${name} - ${variationSku}`,\n sku: variationSku,\n productVersions: [\n {\n label: 'Default',\n packageLengthMM: length,\n packageWidthMM: width,\n packageHeightMM: height,\n packageWeightGram: weight,\n qty: stockReported\n }\n ]\n }\n ],\n extraMetadata\n }\n })\n\n images = images?.map(image => {\n return {\n url: image\n }\n })\n\n return {\n organisationId,\n channelShopId: channelShopId,\n channelCode: channels[i].channelCode,\n channelCountry: shops[j].country_code,\n categoryId: store.platform == 'shopify' ? 1 : categoryId,\n productId: parentLinks.find(e => e.children.includes(productId))?.id || productId,\n name,\n brand,\n isVerified,\n images,\n attributes: sellercraftAttributes || [],\n variations\n }\n })\n\n let mappedCategories = categoryResult.map(category => {\n let { id: categoryId, name: categoryName, parent, isActive } = category\n\n return {\n categoryId,\n categoryName,\n parent,\n isActive: isActive || true,\n channelCode,\n countryCode,\n childrenCategories: []\n }\n })\n\n if (store.platform == 'magento') {\n let newList = []\n for (let np of mappedProducts) {\n if (np.productId == np.variations[0].variationId) {\n let vars = mappedProducts\n .filter(e => e.productId == np.productId)\n .map(e => {\n return e.variations[0]\n })\n np.variations = vars\n if (np.variations.length > 1) {\n np.variations = np.variations.filter(v => v.variationId != np.productId)\n }\n newList.push(np)\n }\n }\n mappedProducts = newList\n }\n\n try {\n let filterList = []\n mappedCategories = mappedCategories.map(category => {\n if (mappedCategories.filter(e => e.parent == category.categoryId).length > 0) {\n category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId)\n filterList.push(...mappedCategories.filter(e => e.parent == category.categoryId))\n }\n return category\n })\n\n mappedCategories = mappedCategories\n .map(mc => {\n if (filterList.indexOf(mc) == -1) {\n return mc\n }\n })\n .filter(e => e)\n\n await SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {\n categories: mappedCategories\n })\n } catch (e) {\n errors.push({\n name: 'Category Ingestion Error',\n msg: JSON.stringify(e) || {}\n })\n }\n\n let bs = parseInt(productBatchSize) || mappedProducts.length\n\n if (mappedProducts.length > 0) {\n while (mappedProducts.length > 0) {\n let spliceResult = mappedProducts.splice(0, mappedProducts.length >= bs ? bs : mappedProducts.length)\n\n try {\n await SellercraftChannelIntegrationAPI.ingestChannelProduct(sellercraftStore, {\n products: spliceResult\n })\n } catch (e) {\n errors.push({\n name: 'Product Ingestion Error',\n msg: JSON.stringify(e) || {}\n })\n }\n }\n }\n } catch (e) {\n errors.push({\n name: 'Product Processing / Mapping Error',\n msg: JSON.stringify(e) || {}\n })\n }\n }\n } catch (e) {\n errors.push({\n name: 'Store Error',\n msg: JSON.stringify(e) || {}\n })\n }\n }\n if (errors.length > 1 && airflow) {\n throw errors\n }\n return true\n }\n}\n"]}
@@ -1,18 +0,0 @@
1
- import { User } from '@things-factory/auth-base';
2
- import { Domain } from '@things-factory/shell';
3
- export declare class MarketplaceChannel {
4
- readonly id: string;
5
- domain?: Domain;
6
- domainId?: string;
7
- name: string;
8
- channelCode: string;
9
- channelId: string;
10
- countryCode: string;
11
- isActive: boolean;
12
- createdAt?: Date;
13
- updatedAt?: Date;
14
- creator?: User;
15
- creatorId?: string;
16
- updater?: User;
17
- updaterId?: string;
18
- }
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MarketplaceChannel = void 0;
4
- const tslib_1 = require("tslib");
5
- const type_graphql_1 = require("type-graphql");
6
- const typeorm_1 = require("typeorm");
7
- const auth_base_1 = require("@things-factory/auth-base");
8
- const shell_1 = require("@things-factory/shell");
9
- let MarketplaceChannel = class MarketplaceChannel {
10
- };
11
- exports.MarketplaceChannel = MarketplaceChannel;
12
- tslib_1.__decorate([
13
- (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
14
- (0, type_graphql_1.Field)(type => type_graphql_1.ID),
15
- tslib_1.__metadata("design:type", String)
16
- ], MarketplaceChannel.prototype, "id", void 0);
17
- tslib_1.__decorate([
18
- (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
19
- (0, type_graphql_1.Field)(type => shell_1.Domain),
20
- tslib_1.__metadata("design:type", shell_1.Domain)
21
- ], MarketplaceChannel.prototype, "domain", void 0);
22
- tslib_1.__decorate([
23
- (0, typeorm_1.RelationId)((marketplaceChannel) => marketplaceChannel.domain),
24
- tslib_1.__metadata("design:type", String)
25
- ], MarketplaceChannel.prototype, "domainId", void 0);
26
- tslib_1.__decorate([
27
- (0, typeorm_1.Column)(),
28
- (0, type_graphql_1.Field)(),
29
- tslib_1.__metadata("design:type", String)
30
- ], MarketplaceChannel.prototype, "name", void 0);
31
- tslib_1.__decorate([
32
- (0, typeorm_1.Column)(),
33
- (0, type_graphql_1.Field)(),
34
- tslib_1.__metadata("design:type", String)
35
- ], MarketplaceChannel.prototype, "channelCode", void 0);
36
- tslib_1.__decorate([
37
- (0, typeorm_1.Column)(),
38
- (0, type_graphql_1.Field)(),
39
- tslib_1.__metadata("design:type", String)
40
- ], MarketplaceChannel.prototype, "channelId", void 0);
41
- tslib_1.__decorate([
42
- (0, typeorm_1.Column)({ nullable: true }),
43
- (0, type_graphql_1.Field)({ nullable: true }),
44
- tslib_1.__metadata("design:type", String)
45
- ], MarketplaceChannel.prototype, "countryCode", void 0);
46
- tslib_1.__decorate([
47
- (0, typeorm_1.Column)({ default: true }),
48
- (0, type_graphql_1.Field)(),
49
- tslib_1.__metadata("design:type", Boolean)
50
- ], MarketplaceChannel.prototype, "isActive", void 0);
51
- tslib_1.__decorate([
52
- (0, typeorm_1.CreateDateColumn)(),
53
- (0, type_graphql_1.Field)({ nullable: true }),
54
- tslib_1.__metadata("design:type", Date)
55
- ], MarketplaceChannel.prototype, "createdAt", void 0);
56
- tslib_1.__decorate([
57
- (0, typeorm_1.UpdateDateColumn)(),
58
- (0, type_graphql_1.Field)({ nullable: true }),
59
- tslib_1.__metadata("design:type", Date)
60
- ], MarketplaceChannel.prototype, "updatedAt", void 0);
61
- tslib_1.__decorate([
62
- (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
63
- (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
64
- tslib_1.__metadata("design:type", auth_base_1.User)
65
- ], MarketplaceChannel.prototype, "creator", void 0);
66
- tslib_1.__decorate([
67
- (0, typeorm_1.RelationId)((marketplaceChannel) => marketplaceChannel.creator),
68
- tslib_1.__metadata("design:type", String)
69
- ], MarketplaceChannel.prototype, "creatorId", void 0);
70
- tslib_1.__decorate([
71
- (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
72
- (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
73
- tslib_1.__metadata("design:type", auth_base_1.User)
74
- ], MarketplaceChannel.prototype, "updater", void 0);
75
- tslib_1.__decorate([
76
- (0, typeorm_1.RelationId)((marketplaceChannel) => marketplaceChannel.updater),
77
- tslib_1.__metadata("design:type", String)
78
- ], MarketplaceChannel.prototype, "updaterId", void 0);
79
- exports.MarketplaceChannel = MarketplaceChannel = tslib_1.__decorate([
80
- (0, typeorm_1.Entity)(),
81
- (0, typeorm_1.Index)('ix_marketplace_channel_0 ', (marketplaceChannel) => [marketplaceChannel.domain, marketplaceChannel.name], { unique: true }),
82
- (0, type_graphql_1.ObjectType)({ description: 'Entity for Marketplace Channel' })
83
- ], MarketplaceChannel);
84
- //# sourceMappingURL=marketplace-channel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"marketplace-channel.js","sourceRoot":"","sources":["../../../server/service/marketplace-channel/marketplace-channel.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCASgB;AAEhB,yDAAgD;AAChD,iDAA8C;AASvC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAqD9B,CAAA;AArDY,gDAAkB;AAGpB;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;8CACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;sCACb,cAAM;kDAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,kBAAsC,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,CAAC;;oDACjE;AAIjB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;gDACI;AAIZ;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;uDACW;AAInB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;qDACS;AAIjB;IAFC,IAAA,gBAAM,EAAC,EAAE,QAA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kBAAkB,CAAC,IAAI,CAAC,EAChG,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;GACjD,kBAAkB,CAqD9B","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain } from '@things-factory/shell'\n\n@Entity()\n@Index(\n 'ix_marketplace_channel_0 ',\n (marketplaceChannel: MarketplaceChannel) => [marketplaceChannel.domain, marketplaceChannel.name],\n { unique: true }\n)\n@ObjectType({ description: 'Entity for Marketplace Channel' })\nexport class MarketplaceChannel {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain)\n domain?: Domain\n\n @RelationId((marketplaceChannel: MarketplaceChannel) => marketplaceChannel.domain)\n domainId?: string\n\n @Column()\n @Field()\n name: string\n\n @Column()\n @Field()\n channelCode: string\n\n @Column()\n @Field()\n channelId: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n countryCode: string\n\n @Column({ default: true })\n @Field()\n isActive: boolean\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((marketplaceChannel: MarketplaceChannel) => marketplaceChannel.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((marketplaceChannel: MarketplaceChannel) => marketplaceChannel.updater)\n updaterId?: string\n}\n"]}
@@ -1,5 +0,0 @@
1
- import { Sellercraft } from './sellercraft';
2
- import { SellercraftQuery } from './sellercraft-query';
3
- import { SellercraftMutation } from './sellercraft-mutation';
4
- export declare const entities: (typeof Sellercraft)[];
5
- export declare const resolvers: (typeof SellercraftQuery | typeof SellercraftMutation)[];
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvers = exports.entities = void 0;
4
- const sellercraft_1 = require("./sellercraft");
5
- const sellercraft_query_1 = require("./sellercraft-query");
6
- const sellercraft_mutation_1 = require("./sellercraft-mutation");
7
- exports.entities = [sellercraft_1.Sellercraft];
8
- exports.resolvers = [sellercraft_query_1.SellercraftQuery, sellercraft_mutation_1.SellercraftMutation];
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/sellercraft/index.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAC3C,2DAAsD;AACtD,iEAA4D;AAE/C,QAAA,QAAQ,GAAG,CAAC,yBAAW,CAAC,CAAA;AACxB,QAAA,SAAS,GAAG,CAAC,oCAAgB,EAAE,0CAAmB,CAAC,CAAA","sourcesContent":["import { Sellercraft } from './sellercraft'\nimport { SellercraftQuery } from './sellercraft-query'\nimport { SellercraftMutation } from './sellercraft-mutation'\n\nexport const entities = [Sellercraft]\nexport const resolvers = [SellercraftQuery, SellercraftMutation]\n"]}
@@ -1,9 +0,0 @@
1
- import { Sellercraft } from './sellercraft';
2
- import { NewSellercraft, SellercraftPatch } from './sellercraft-type';
3
- export declare class SellercraftMutation {
4
- createSellercraft(sellercraft: NewSellercraft, context: ResolverContext): Promise<Sellercraft>;
5
- updateSellercraft(id: string, patch: SellercraftPatch, context: ResolverContext): Promise<Sellercraft>;
6
- updateMultipleSellercraft(patches: SellercraftPatch[], context: ResolverContext): Promise<Sellercraft[]>;
7
- deleteSellercraft(id: string, context: ResolverContext): Promise<boolean>;
8
- deleteSellercrafts(ids: string[], context: ResolverContext): Promise<boolean>;
9
- }
@@ -1,111 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SellercraftMutation = void 0;
4
- const tslib_1 = require("tslib");
5
- const type_graphql_1 = require("type-graphql");
6
- const typeorm_1 = require("typeorm");
7
- const uuid_1 = require("uuid");
8
- const sellercraft_1 = require("./sellercraft");
9
- const sellercraft_type_1 = require("./sellercraft-type");
10
- let SellercraftMutation = class SellercraftMutation {
11
- async createSellercraft(sellercraft, context) {
12
- const { domain, user, tx } = context.state;
13
- return await tx.getRepository(sellercraft_1.Sellercraft).save(Object.assign(Object.assign({}, sellercraft), { name: (0, uuid_1.v4)(), domain, creator: user, updater: user }));
14
- }
15
- async updateSellercraft(id, patch, context) {
16
- const { user, tx } = context.state;
17
- const repository = tx.getRepository(sellercraft_1.Sellercraft);
18
- const sellercraft = await repository.findOneBy({ id });
19
- return await repository.save(Object.assign(Object.assign(Object.assign({}, sellercraft), patch), { updater: user }));
20
- }
21
- async updateMultipleSellercraft(patches, context) {
22
- const { domain, user, tx } = context.state;
23
- let results = [];
24
- const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
25
- const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
26
- const sellercraftRepo = tx.getRepository(sellercraft_1.Sellercraft);
27
- if (_createRecords.length > 0) {
28
- for (let i = 0; i < _createRecords.length; i++) {
29
- const newRecord = _createRecords[i];
30
- const result = await sellercraftRepo.save(Object.assign(Object.assign({}, newRecord), { domain, name: (0, uuid_1.v4)(), status: sellercraft_1.SellercraftStatus.ACTIVE, platform: sellercraft_1.SellercraftPlatform.SELLERCRAFT, creator: user, updater: user }));
31
- results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
32
- }
33
- }
34
- if (_updateRecords.length > 0) {
35
- for (let i = 0; i < _updateRecords.length; i++) {
36
- const newRecord = _updateRecords[i];
37
- const sellercraft = await sellercraftRepo.findOneBy({ id: newRecord.id });
38
- const result = await sellercraftRepo.save(Object.assign(Object.assign(Object.assign({}, sellercraft), newRecord), { updater: user }));
39
- results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
40
- }
41
- }
42
- return results;
43
- }
44
- async deleteSellercraft(id, context) {
45
- const { domain, tx } = context.state;
46
- await tx.getRepository(sellercraft_1.Sellercraft).delete({ domain: { id: domain.id }, id });
47
- return true;
48
- }
49
- async deleteSellercrafts(ids, context) {
50
- const { domain, tx, user } = context.state;
51
- let sellercrafts = await tx
52
- .getRepository(sellercraft_1.Sellercraft)
53
- .find({ where: { domain: { id: domain.id }, id: (0, typeorm_1.In)(ids) } });
54
- sellercrafts = sellercrafts.map((sellercraft) => {
55
- return Object.assign(Object.assign({}, sellercraft), { status: sellercraft_1.SellercraftStatus.TERMINATED, updater: user });
56
- });
57
- await tx.getRepository(sellercraft_1.Sellercraft).save(sellercrafts);
58
- return true;
59
- }
60
- };
61
- exports.SellercraftMutation = SellercraftMutation;
62
- tslib_1.__decorate([
63
- (0, type_graphql_1.Directive)('@transaction'),
64
- (0, type_graphql_1.Mutation)(returns => sellercraft_1.Sellercraft, { description: 'To create new Sellercraft' }),
65
- tslib_1.__param(0, (0, type_graphql_1.Arg)('sellercraft')),
66
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
67
- tslib_1.__metadata("design:type", Function),
68
- tslib_1.__metadata("design:paramtypes", [sellercraft_type_1.NewSellercraft, Object]),
69
- tslib_1.__metadata("design:returntype", Promise)
70
- ], SellercraftMutation.prototype, "createSellercraft", null);
71
- tslib_1.__decorate([
72
- (0, type_graphql_1.Directive)('@transaction'),
73
- (0, type_graphql_1.Mutation)(returns => sellercraft_1.Sellercraft, { description: 'To modify Sellercraft information' }),
74
- tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
75
- tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
76
- tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
77
- tslib_1.__metadata("design:type", Function),
78
- tslib_1.__metadata("design:paramtypes", [String, sellercraft_type_1.SellercraftPatch, Object]),
79
- tslib_1.__metadata("design:returntype", Promise)
80
- ], SellercraftMutation.prototype, "updateSellercraft", null);
81
- tslib_1.__decorate([
82
- (0, type_graphql_1.Directive)('@transaction'),
83
- (0, type_graphql_1.Mutation)(returns => [sellercraft_1.Sellercraft], { description: "To modify multiple Sellercrafts' information" }),
84
- tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [sellercraft_type_1.SellercraftPatch])),
85
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
86
- tslib_1.__metadata("design:type", Function),
87
- tslib_1.__metadata("design:paramtypes", [Array, Object]),
88
- tslib_1.__metadata("design:returntype", Promise)
89
- ], SellercraftMutation.prototype, "updateMultipleSellercraft", null);
90
- tslib_1.__decorate([
91
- (0, type_graphql_1.Directive)('@transaction'),
92
- (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete Sellercraft' }),
93
- tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
94
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
95
- tslib_1.__metadata("design:type", Function),
96
- tslib_1.__metadata("design:paramtypes", [String, Object]),
97
- tslib_1.__metadata("design:returntype", Promise)
98
- ], SellercraftMutation.prototype, "deleteSellercraft", null);
99
- tslib_1.__decorate([
100
- (0, type_graphql_1.Directive)('@transaction'),
101
- (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple sellercrafts' }),
102
- tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
103
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
104
- tslib_1.__metadata("design:type", Function),
105
- tslib_1.__metadata("design:paramtypes", [Array, Object]),
106
- tslib_1.__metadata("design:returntype", Promise)
107
- ], SellercraftMutation.prototype, "deleteSellercrafts", null);
108
- exports.SellercraftMutation = SellercraftMutation = tslib_1.__decorate([
109
- (0, type_graphql_1.Resolver)(sellercraft_1.Sellercraft)
110
- ], SellercraftMutation);
111
- //# sourceMappingURL=sellercraft-mutation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sell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AAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;6DAiBP;8BApHU,mBAAmB;IAD/B,IAAA,uBAAQ,EAAC,yBAAW,CAAC;GACT,mBAAmB,CAqH/B","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { v4 as uuidv4 } from 'uuid'\n\nimport { Sellercraft, SellercraftPlatform, SellercraftStatus } from './sellercraft'\nimport { NewSellercraft, SellercraftPatch } from './sellercraft-type'\n\n@Resolver(Sellercraft)\nexport class SellercraftMutation {\n @Directive('@transaction')\n @Mutation(returns => Sellercraft, { description: 'To create new Sellercraft' })\n async createSellercraft(\n @Arg('sellercraft') sellercraft: NewSellercraft,\n @Ctx() context: ResolverContext\n ): Promise<Sellercraft> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Sellercraft).save({\n ...sellercraft,\n name: uuidv4(),\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Sellercraft, { description: 'To modify Sellercraft information' })\n async updateSellercraft(\n @Arg('id') id: string,\n @Arg('patch') patch: SellercraftPatch,\n @Ctx() context: ResolverContext\n ): Promise<Sellercraft> {\n const { user, tx } = context.state\n\n const repository = tx.getRepository(Sellercraft)\n const sellercraft = await repository.findOneBy({ id })\n\n return await repository.save({\n ...sellercraft,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Sellercraft], { description: \"To modify multiple Sellercrafts' information\" })\n async updateMultipleSellercraft(\n @Arg('patches', type => [SellercraftPatch]) patches: SellercraftPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Sellercraft[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const sellercraftRepo = tx.getRepository(Sellercraft)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await sellercraftRepo.save({\n ...newRecord,\n domain,\n name: uuidv4(),\n status: SellercraftStatus.ACTIVE,\n platform: SellercraftPlatform.SELLERCRAFT,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const sellercraft = await sellercraftRepo.findOneBy({ id: newRecord.id })\n\n const result = await sellercraftRepo.save({\n ...sellercraft,\n ...newRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete Sellercraft' })\n async deleteSellercraft(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Sellercraft).delete({ domain: { id: domain.id }, id })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple sellercrafts' })\n async deleteSellercrafts(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx, user } = context.state\n let sellercrafts: Sellercraft[] = await tx\n .getRepository(Sellercraft)\n .find({ where: { domain: { id: domain.id }, id: In(ids) } })\n\n sellercrafts = sellercrafts.map((sellercraft: Sellercraft) => {\n return {\n ...sellercraft,\n status: SellercraftStatus.TERMINATED,\n updater: user\n }\n })\n\n await tx.getRepository(Sellercraft).save(sellercrafts)\n return true\n }\n}\n"]}
@@ -1,11 +0,0 @@
1
- import { User } from '@things-factory/auth-base';
2
- import { Domain, ListParam } from '@things-factory/shell';
3
- import { Sellercraft } from './sellercraft';
4
- import { SellercraftList } from './sellercraft-type';
5
- export declare class SellercraftQuery {
6
- sellercraft(id: string, context: ResolverContext): Promise<Sellercraft>;
7
- sellercrafts(params: ListParam, context: ResolverContext): Promise<SellercraftList>;
8
- domain(sellercraft: Sellercraft): Promise<Domain>;
9
- updater(sellercraft: Sellercraft): Promise<User>;
10
- creator(sellercraft: Sellercraft): Promise<User>;
11
- }