@things-factory/integration-sellercraft 4.0.11 → 4.0.16

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 (55) hide show
  1. package/dist-server/constants/index.js +14 -0
  2. package/dist-server/constants/index.js.map +1 -0
  3. package/dist-server/constants/platform.js +7 -0
  4. package/dist-server/constants/platform.js.map +1 -0
  5. package/dist-server/controllers/sellercraft-channel-integration/apis/echo.js +19 -0
  6. package/dist-server/controllers/sellercraft-channel-integration/apis/echo.js.map +1 -0
  7. package/dist-server/controllers/sellercraft-channel-integration/apis/index.js +19 -0
  8. package/dist-server/controllers/sellercraft-channel-integration/apis/index.js.map +1 -0
  9. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.js +40 -0
  10. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.js.map +1 -0
  11. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-category-attributes.js +48 -0
  12. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-category-attributes.js.map +1 -0
  13. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js +46 -0
  14. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js.map +1 -0
  15. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js +81 -0
  16. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js.map +1 -0
  17. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js +105 -0
  18. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js.map +1 -0
  19. package/dist-server/controllers/sellercraft-channel-integration/index.js +30 -0
  20. package/dist-server/controllers/sellercraft-channel-integration/index.js.map +1 -0
  21. package/dist-server/controllers/sellercraft-channel-integration/platform-action.js +33 -0
  22. package/dist-server/controllers/sellercraft-channel-integration/platform-action.js.map +1 -0
  23. package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js +90 -0
  24. package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js.map +1 -0
  25. package/dist-server/controllers/sellercraft-channel-integration-api/decorators.js +32 -0
  26. package/dist-server/controllers/sellercraft-channel-integration-api/decorators.js.map +1 -0
  27. package/dist-server/controllers/sellercraft-channel-integration-api/index.js +78 -0
  28. package/dist-server/controllers/sellercraft-channel-integration-api/index.js.map +1 -0
  29. package/dist-server/controllers/sellercraft-channel-integration-api/types.js +1 -0
  30. package/dist-server/controllers/sellercraft-channel-integration-api/types.js.map +1 -0
  31. package/dist-server/index.js +1 -0
  32. package/dist-server/index.js.map +1 -1
  33. package/dist-server/routers/sellercraft-router.js +174 -0
  34. package/dist-server/routers/sellercraft-router.js.map +1 -0
  35. package/dist-server/routes.js +4 -0
  36. package/dist-server/routes.js.map +1 -1
  37. package/package.json +15 -14
  38. package/server/constants/index.ts +1 -0
  39. package/server/constants/platform.ts +3 -0
  40. package/server/controllers/sellercraft-channel-integration/apis/echo.ts +14 -0
  41. package/server/controllers/sellercraft-channel-integration/apis/index.ts +6 -0
  42. package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.ts +38 -0
  43. package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-category-attributes.ts +65 -0
  44. package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.ts +58 -0
  45. package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.ts +79 -0
  46. package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.ts +110 -0
  47. package/server/controllers/sellercraft-channel-integration/index.ts +7 -0
  48. package/server/controllers/sellercraft-channel-integration/platform-action.ts +39 -0
  49. package/server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.ts +106 -0
  50. package/server/controllers/sellercraft-channel-integration-api/decorators.ts +45 -0
  51. package/server/controllers/sellercraft-channel-integration-api/index.ts +45 -0
  52. package/server/controllers/sellercraft-channel-integration-api/types.ts +0 -0
  53. package/server/index.ts +1 -0
  54. package/server/routers/sellercraft-router.ts +202 -0
  55. package/server/routes.ts +4 -0
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./platform"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA0B"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLATFORM = void 0;
4
+ exports.PLATFORM = {
5
+ WCM: 'woocommerce'
6
+ };
7
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../../server/constants/platform.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACtB,GAAG,EAAE,aAAa;CACnB,CAAA"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.echo = void 0;
4
+ function echo() {
5
+ return {
6
+ path: '/echo',
7
+ denormalize(req) {
8
+ return Object.assign({}, req);
9
+ },
10
+ normalize(res) {
11
+ return Object.assign({}, res);
12
+ },
13
+ action({ store, method, path, request, platformAction }) {
14
+ return Object.assign({}, request);
15
+ }
16
+ };
17
+ }
18
+ exports.echo = echo;
19
+ //# sourceMappingURL=echo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"echo.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft-channel-integration/apis/echo.ts"],"names":[],"mappings":";;;AAAA,SAAgB,IAAI;IAClB,OAAO;QACL,IAAI,EAAE,OAAO;QACb,WAAW,CAAC,GAAG;YACb,yBAAY,GAAG,EAAE;QACnB,CAAC;QACD,SAAS,CAAC,GAAG;YACX,yBAAY,GAAG,EAAE;QACnB,CAAC;QACD,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE;YACrD,yBAAY,OAAO,EAAE;QACvB,CAAC;KACF,CAAA;AACH,CAAC;AAbD,oBAaC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./echo"), exports);
14
+ __exportStar(require("./ingest-channel-categories"), exports);
15
+ __exportStar(require("./ingest-channel-category-attributes"), exports);
16
+ __exportStar(require("./ingest-channel-order-package"), exports);
17
+ __exportStar(require("./ingest-channel-order"), exports);
18
+ __exportStar(require("./ingest-channel-product"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft-channel-integration/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,8DAA2C;AAC3C,uEAAoD;AACpD,iEAA8C;AAC9C,yDAAsC;AACtC,2DAAwC"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /* https://docs.sellercraft.co/docs/api-integrations/b3A6MTY4NjQxODU-initiate-order-shipment */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ingestChannelCategories = void 0;
5
+ function ingestChannelCategories() {
6
+ return {
7
+ method: 'post',
8
+ path: '/channel/ingest/category',
9
+ denormalize(req) {
10
+ const { categories } = req;
11
+ let newCategories = categories.map(category => {
12
+ return {
13
+ channel_id: category.channelId,
14
+ native_category_id: category.categoryId,
15
+ category_name: category.categoryName,
16
+ is_leaf: category.isLeaf,
17
+ is_active: category.isActive,
18
+ children_categories: category.childrenCategories.map(childrenCategory => {
19
+ return {
20
+ channel_id: childrenCategory.channelId,
21
+ native_category_id: childrenCategory.categoryId,
22
+ category_name: childrenCategory.categoryName,
23
+ is_leaf: childrenCategory.isLeaf,
24
+ is_active: childrenCategory.isActive,
25
+ children_categories: {}
26
+ };
27
+ })
28
+ };
29
+ });
30
+ return {
31
+ payload: { newCategories }
32
+ };
33
+ },
34
+ normalize(res) {
35
+ return res;
36
+ }
37
+ };
38
+ }
39
+ exports.ingestChannelCategories = ingestChannelCategories;
40
+ //# sourceMappingURL=ingest-channel-categories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingest-channel-categories.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.ts"],"names":[],"mappings":";AAAA,+FAA+F;;;AAE/F,SAAgB,uBAAuB;IACrC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,0BAA0B;QAChC,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,CAAA;YAE1B,IAAI,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;gBAC5C,OAAO;oBACL,UAAU,EAAE,QAAQ,CAAC,SAAS;oBAC9B,kBAAkB,EAAE,QAAQ,CAAC,UAAU;oBACvC,aAAa,EAAE,QAAQ,CAAC,YAAY;oBACpC,OAAO,EAAE,QAAQ,CAAC,MAAM;oBACxB,SAAS,EAAE,QAAQ,CAAC,QAAQ;oBAC5B,mBAAmB,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE;wBACtE,OAAO;4BACL,UAAU,EAAE,gBAAgB,CAAC,SAAS;4BACtC,kBAAkB,EAAE,gBAAgB,CAAC,UAAU;4BAC/C,aAAa,EAAE,gBAAgB,CAAC,YAAY;4BAC5C,OAAO,EAAE,gBAAgB,CAAC,MAAM;4BAChC,SAAS,EAAE,gBAAgB,CAAC,QAAQ;4BACpC,mBAAmB,EAAE,EAAE;yBACxB,CAAA;oBACH,CAAC,CAAC;iBACH,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,OAAO;gBACL,OAAO,EAAE,EAAE,aAAa,EAAE;aAC3B,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAnCD,0DAmCC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /* https://docs.sellercraft.co/docs/api-integrations/b3A6MjQzODUxMTE-ingest-channel-category-attributes */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ingestChannelCategoryAttributes = void 0;
5
+ function ingestChannelCategoryAttributes() {
6
+ return {
7
+ method: 'post',
8
+ path: '/channel/ingest/category/attribute',
9
+ denormalize(req) {
10
+ let { channelAttributeKeys, scAttributeKeys } = req;
11
+ let channel_attribute_keys = channelAttributeKeys.map(e => {
12
+ const { channelCode: channel_code, channelCountry: channel_country, nativeCategoryId: native_category_id, attributeKey: attribute_key, valueType: value_type, valueOptions: value_options, displayName: display_name, isCore: is_core, isSearchProp: is_search_prop, isOptional: is_optional } = e;
13
+ return {
14
+ channel_code,
15
+ channel_country,
16
+ native_category_id,
17
+ attribute_key,
18
+ value_type,
19
+ value_options,
20
+ display_name,
21
+ is_core,
22
+ is_search_prop,
23
+ is_optional
24
+ };
25
+ });
26
+ let sc_attribute_keys = scAttributeKeys.map(e => {
27
+ const { channelCode: channel_code, channelCountry: channel_country, attributeKey: attribute_key, displayName: display_name } = e;
28
+ return {
29
+ channel_code,
30
+ channel_country,
31
+ attribute_key,
32
+ display_name
33
+ };
34
+ });
35
+ return {
36
+ payload: {
37
+ channel_attribute_keys,
38
+ sc_attribute_keys
39
+ }
40
+ };
41
+ },
42
+ normalize(res) {
43
+ return res;
44
+ }
45
+ };
46
+ }
47
+ exports.ingestChannelCategoryAttributes = ingestChannelCategoryAttributes;
48
+ //# sourceMappingURL=ingest-channel-category-attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingest-channel-category-attributes.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft-channel-integration/apis/ingest-channel-category-attributes.ts"],"names":[],"mappings":";AAAA,0GAA0G;;;AAE1G,SAAgB,+BAA+B;IAC7C,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,oCAAoC;QAC1C,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,oBAAoB,EAAE,eAAe,EAAE,GAAG,GAAG,CAAA;YAEnD,IAAI,sBAAsB,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;gBACxD,MAAM,EACJ,WAAW,EAAE,YAAY,EACzB,cAAc,EAAE,eAAe,EAC/B,gBAAgB,EAAE,kBAAkB,EACpC,YAAY,EAAE,aAAa,EAC3B,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,aAAa,EAC3B,WAAW,EAAE,YAAY,EACzB,MAAM,EAAE,OAAO,EACf,YAAY,EAAE,cAAc,EAC5B,UAAU,EAAE,WAAW,EACxB,GAAG,CAAC,CAAA;gBAEL,OAAO;oBACL,YAAY;oBACZ,eAAe;oBACf,kBAAkB;oBAClB,aAAa;oBACb,UAAU;oBACV,aAAa;oBACb,YAAY;oBACZ,OAAO;oBACP,cAAc;oBACd,WAAW;iBACZ,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,IAAI,iBAAiB,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;gBAC9C,MAAM,EACJ,WAAW,EAAE,YAAY,EACzB,cAAc,EAAE,eAAe,EAC/B,YAAY,EAAE,aAAa,EAC3B,WAAW,EAAE,YAAY,EAC1B,GAAG,CAAC,CAAA;gBAEL,OAAO;oBACL,YAAY;oBACZ,eAAe;oBACf,aAAa;oBACb,YAAY;iBACb,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,OAAO;gBACL,OAAO,EAAE;oBACP,sBAAsB;oBACtB,iBAAiB;iBAClB;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AA9DD,0EA8DC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /* https://docs.sellercraft.co/docs/api-integrations/b3A6MjQzODUxMTQ-ingest-channel-order-package */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ingestChannelOrderPackage = void 0;
5
+ function ingestChannelOrderPackage() {
6
+ return {
7
+ method: 'post',
8
+ path: '/channel/ingest/order/package',
9
+ denormalize(req) {
10
+ let { channelShopId: channel_shop_id, nativeOrderId: native_order_id, nativePackageId: native_package_id, shippingTrackingCode: shipping_tracking_code, shippingTypeValue: shipping_type_value, warehouseCode: warehouse_code, shipper, documents, shipperLastMile: shipper_last_mile, orderItemIds: order_item_ids } = req;
11
+ documents = documents.map(e => {
12
+ const { fileTypeValue: file_type_value, mimeType: mime_type, file } = e;
13
+ return {
14
+ file_type_value,
15
+ mime_type,
16
+ file
17
+ };
18
+ });
19
+ shipper = {
20
+ is_cod_supported: shipper.isCodSupported,
21
+ name: shipper.name
22
+ };
23
+ shipper_last_mile = {
24
+ is_cod_supported: shipper_last_mile.isCodSupported,
25
+ name: shipper_last_mile.name
26
+ };
27
+ return {
28
+ channel_shop_id,
29
+ native_order_id,
30
+ native_package_id,
31
+ shipping_tracking_code,
32
+ shipping_type_value,
33
+ warehouse_code,
34
+ shipper,
35
+ documents,
36
+ shipper_last_mile,
37
+ order_item_ids
38
+ };
39
+ },
40
+ normalize(res) {
41
+ return res;
42
+ }
43
+ };
44
+ }
45
+ exports.ingestChannelOrderPackage = ingestChannelOrderPackage;
46
+ //# sourceMappingURL=ingest-channel-order-package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingest-channel-order-package.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.ts"],"names":[],"mappings":";AAAA,oGAAoG;;;AAEpG,SAAgB,yBAAyB;IACvC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,+BAA+B;QACrC,WAAW,CAAC,GAAG;YACb,IAAI,EACF,aAAa,EAAE,eAAe,EAC9B,aAAa,EAAE,eAAe,EAC9B,eAAe,EAAE,iBAAiB,EAClC,oBAAoB,EAAE,sBAAsB,EAC5C,iBAAiB,EAAE,mBAAmB,EACtC,aAAa,EAAE,cAAc,EAC7B,OAAO,EACP,SAAS,EACT,eAAe,EAAE,iBAAiB,EAClC,YAAY,EAAE,cAAc,EAC7B,GAAG,GAAG,CAAA;YAEP,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;gBAC5B,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;gBAEvE,OAAO;oBACL,eAAe;oBACf,SAAS;oBACT,IAAI;iBACL,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,OAAO,GAAG;gBACR,gBAAgB,EAAE,OAAO,CAAC,cAAc;gBACxC,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB,CAAA;YAED,iBAAiB,GAAG;gBAClB,gBAAgB,EAAE,iBAAiB,CAAC,cAAc;gBAClD,IAAI,EAAE,iBAAiB,CAAC,IAAI;aAC7B,CAAA;YAED,OAAO;gBACL,eAAe;gBACf,eAAe;gBACf,iBAAiB;gBACjB,sBAAsB;gBACtB,mBAAmB;gBACnB,cAAc;gBACd,OAAO;gBACP,SAAS;gBACT,iBAAiB;gBACjB,cAAc;aACf,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAvDD,8DAuDC"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /* https://docs.sellercraft.co/docs/api-integrations/b3A6MTY4NjQxODU-initiate-order-shipment */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ingestChannelOrder = void 0;
5
+ function ingestChannelOrder() {
6
+ return {
7
+ method: 'post',
8
+ path: '/channel/ingest/order',
9
+ denormalize(req) {
10
+ const { orders } = req;
11
+ let newOrders = orders.map(order => {
12
+ return {
13
+ organisation_id: order.organisationId,
14
+ channel_shop_id: order.channelShopId,
15
+ native_order_id: order.id,
16
+ ordered_at_date: order.createdAt,
17
+ ordered_at_time: order.createdAt,
18
+ updated_at_date: order.updatedAt,
19
+ updated_at_time: order.updatedAt,
20
+ customer_first_name: order.custFirstName,
21
+ customer_last_name: order.custLastName,
22
+ address_shipping: {
23
+ first_name: order.shipFirstName,
24
+ last_name: order.shipLastName,
25
+ line_1: order.shipAddress1,
26
+ line_2: order.shipAddress2,
27
+ line_3: order.shipAddress3,
28
+ line_4: order.shipAddress4,
29
+ line_5: order.shipAddress5,
30
+ city: order.shipCity,
31
+ postal_code: order.shipPostalCode,
32
+ country: order.shipCountry,
33
+ phone_1: order.shipPhone1,
34
+ phone_2: order.shipPhone2
35
+ },
36
+ address_billing: {
37
+ first_name: order.billFirstName,
38
+ last_name: order.billLastName,
39
+ line_1: order.billAddress1,
40
+ line_2: order.billAddress2,
41
+ line_3: order.billAddress3,
42
+ line_4: order.billAddress4,
43
+ line_5: order.billAddress5,
44
+ city: order.billCity,
45
+ postal_code: order.billPostalCode,
46
+ country: order.billCountry,
47
+ phone_1: order.billPhone1,
48
+ phone_2: order.billPhone2
49
+ },
50
+ order_items: order.orderItems.map(orderItem => {
51
+ return {
52
+ native_item_id: orderItem.id,
53
+ native_variant_id: orderItem.variationId,
54
+ currency_code: orderItem.currency,
55
+ ordered_at_date: order.createdAt,
56
+ ordered_at_time: order.createdAt,
57
+ updated_at_date: order.updatedAt,
58
+ updated_at_time: order.updatedAt,
59
+ sla_expires_at: order === null || order === void 0 ? void 0 : order.slaExpiresAt,
60
+ charges: orderItem.charges.map(charge => {
61
+ return {
62
+ charge_type_value: charge.name,
63
+ amount_gross: charge.grossAmount,
64
+ amount_nett: charge.nettAmount
65
+ };
66
+ })
67
+ };
68
+ })
69
+ };
70
+ });
71
+ return {
72
+ payload: { newOrders }
73
+ };
74
+ },
75
+ normalize(res) {
76
+ return res;
77
+ }
78
+ };
79
+ }
80
+ exports.ingestChannelOrder = ingestChannelOrder;
81
+ //# sourceMappingURL=ingest-channel-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingest-channel-order.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.ts"],"names":[],"mappings":";AAAA,+FAA+F;;;AAE/F,SAAgB,kBAAkB;IAChC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,uBAAuB;QAC7B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAA;YAEtB,IAAI,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;gBACjC,OAAO;oBACL,eAAe,EAAE,KAAK,CAAC,cAAc;oBACrC,eAAe,EAAE,KAAK,CAAC,aAAa;oBACpC,eAAe,EAAE,KAAK,CAAC,EAAE;oBACzB,eAAe,EAAE,KAAK,CAAC,SAAS;oBAChC,eAAe,EAAE,KAAK,CAAC,SAAS;oBAChC,eAAe,EAAE,KAAK,CAAC,SAAS;oBAChC,eAAe,EAA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AW;4BACxC,aAAa,EAAE,SAAS,CAAC,QAAQ;4BACjC,eAAe,EAAE,KAAK,CAAC,SAAS;4BAChC,eAAe,EAAE,KAAK,CAAC,SAAS;4BAChC,eAAe,EAAE,KAAK,CAAC,SAAS;4BAChC,eAAe,EAAE,KAAK,CAAC,SAAS;4BAChC,cAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,YAAY;4BACnC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gCACtC,OAAO;oCACL,iBAAiB,EAAE,MAAM,CAAC,IAAI;oCAC9B,YAAY,EAAE,MAAM,CAAC,WAAW;oCAChC,WAAW,EAAE,MAAM,CAAC,UAAU;iCAC/B,CAAA;4BACH,CAAC,CAAC;yBACH,CAAA;oBACH,CAAC,CAAC;iBACH,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,OAAO;gBACL,OAAO,EAAE,EAAE,SAAS,EAAE;aACvB,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AA5ED,gDA4EC"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /* https://docs.sellercraft.co/docs/api-integrations/b3A6MTY4NjQxODU-initiate-order-shipment */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ingestChannelProduct = void 0;
5
+ function ingestChannelProduct() {
6
+ return {
7
+ method: 'post',
8
+ path: '/channel/ingest/product',
9
+ denormalize(req) {
10
+ const { products } = req;
11
+ let newProducts = products.map(product => {
12
+ let productVariations = product.variations.map(variant => {
13
+ return {
14
+ seller_sku: variant.variationSku,
15
+ native_variant_id: variant.variationId,
16
+ label: variant.name,
17
+ is_enabled: variant.isEnabled,
18
+ is_sellable: variant.isSellable,
19
+ variant_attributes: (variant === null || variant === void 0 ? void 0 : variant.attributes)
20
+ ? variant.attributes.map(attribute => {
21
+ return {
22
+ attribute_key: attribute.id,
23
+ values: []
24
+ };
25
+ })
26
+ : [],
27
+ stock_locked: (variant === null || variant === void 0 ? void 0 : variant.stockLocked) ? variant.stockLocked : 0,
28
+ native_stock_reported: (variant === null || variant === void 0 ? void 0 : variant.stockReported) ? variant.stockReported : 0,
29
+ price_full: variant.fullPrice,
30
+ price_discounted: variant.priceDiscounted,
31
+ price_discounts: (variant === null || variant === void 0 ? void 0 : variant.product_discounts)
32
+ ? variant.product_discounts.map(discount => {
33
+ return {
34
+ price_discounted: discount.priceDiscounted,
35
+ native_discount_id: discount.id,
36
+ name: discount.name
37
+ };
38
+ })
39
+ : [],
40
+ inventory_products: (variant === null || variant === void 0 ? void 0 : variant.inventoryProducts)
41
+ ? variant.inventoryProducts.map(inventoryProduct => {
42
+ return {
43
+ quantity: inventoryProduct.qty,
44
+ name: inventoryProduct.name,
45
+ inventory_sku: inventoryProduct.sku,
46
+ product_versions: (inventoryProduct === null || inventoryProduct === void 0 ? void 0 : inventoryProduct.productVersions)
47
+ ? inventoryProduct.productVersions.map(productVersion => {
48
+ return {
49
+ label: productVersion.label,
50
+ package_content: productVersion.packageContent,
51
+ package_length_mm: (productVersion === null || productVersion === void 0 ? void 0 : productVersion.packageLengthMM) ? productVersion.packageLengthMM : 0,
52
+ package_width_mm: (productVersion === null || productVersion === void 0 ? void 0 : productVersion.packageWidthMM) ? productVersion.packageWidthMM : 0,
53
+ package_height_mm: (productVersion === null || productVersion === void 0 ? void 0 : productVersion.packageHeightMM) ? productVersion.packageHeightMM : 0,
54
+ package_weight_gram: (productVersion === null || productVersion === void 0 ? void 0 : productVersion.packageWeightGram)
55
+ ? productVersion.packageWeightGram
56
+ : 0,
57
+ stock_available: productVersion.qty
58
+ };
59
+ })
60
+ : []
61
+ };
62
+ })
63
+ : []
64
+ };
65
+ });
66
+ return {
67
+ organisation_id: product.organisationId,
68
+ channel_shop_id: product.channelShopId,
69
+ channel_code: product.channelCode,
70
+ channel_country: product.channelCountry,
71
+ native_category_id: product.categoryId,
72
+ native_product_id: product.productId,
73
+ label: product.name,
74
+ brand: product.brand,
75
+ is_verified: product.isVerified,
76
+ images: product.images.map(image => {
77
+ return {
78
+ file_url: image.url
79
+ };
80
+ }),
81
+ product_attributes: product.attributes.map(attribute => {
82
+ return {
83
+ native_attribute_id: attribute.id,
84
+ values: []
85
+ };
86
+ })
87
+ };
88
+ });
89
+ return {
90
+ payload: {}
91
+ };
92
+ },
93
+ normalize(res) {
94
+ const { handover_type: handOverType, pickup_time: pickupTime, pickup_address: pickupAddress, dropoff_address: dropoffAddress } = res.data;
95
+ return {
96
+ handOverType,
97
+ pickupTime,
98
+ pickupAddress,
99
+ dropoffAddress
100
+ };
101
+ }
102
+ };
103
+ }
104
+ exports.ingestChannelProduct = ingestChannelProduct;
105
+ //# sourceMappingURL=ingest-channel-product.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingest-channel-product.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.ts"],"names":[],"mappings":";AAAA,+FAA+F;;;AAE/F,SAAgB,oBAAoB;IAClC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;YAExB,IAAI,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;gBACvC,IAAI,iBAAiB,GAAU,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;oBAC9D,OAAO;wBACL,UAAU,EAAE,OAAO,CAAC,YAAY;wBAChC,iBAAiB,EAAE,OAAO,CAAC,WAAW;wBACtC,KAAK,EAAE,OAAO,CAAC,IAAI;wBACnB,UAAU,EAAE,OAAO,CAAC,SAAS;wBAC7B,WAAW,EAAE,OAAO,CAAC,UAAU;wBAC/B,kBAAkB,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;4BACrC,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CAAC,UAAU;oBAC/B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;wBACjC,OAAO;4BACL,QAAQ,EAAE,KAAK,CAAC,GAAG;yBACpB,CAAA;oBACH,CAAC,CAAC;oBACF,kBAAkB,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;wBACrD,OAAO;4BACL,mBAAmB,EAAE,SAAS,CAAC,EAAE;4BACjC,MAAM,EAAE,EAAE;yBACX,CAAA;oBACH,CAAC,CAAC;iBACH,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,OAAO;gBACL,OAAO,EAAE,EAAE;aACZ,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,MAAM,EACJ,aAAa,EAAE,YAAY,EAC3B,WAAW,EAAE,UAAU,EACvB,cAAc,EAAE,aAAa,EAC7B,eAAe,EAAE,cAAc,EAChC,GAAG,GAAG,CAAC,IAAI,CAAA;YAEZ,OAAO;gBACL,YAAY;gBACZ,UAAU;gBACV,aAAa;gBACb,cAAc;aACf,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC;AA3GD,oDA2GC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const sellercraft_channel_integration_api_1 = require("../sellercraft-channel-integration-api");
26
+ const APIS = __importStar(require("./apis"));
27
+ const platform_action_1 = require("./platform-action");
28
+ __exportStar(require("./sellercraft-channel-integration"), exports);
29
+ sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.registerPlatform('sellercraftChannelIntegration', platform_action_1.action, APIS);
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/controllers/sellercraft-channel-integration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,gGAAyF;AACzF,6CAA8B;AAC9B,uDAA0C;AAE1C,oEAAiD;AAEjD,sEAAgC,CAAC,gBAAgB,CAAC,+BAA+B,EAAE,wBAAM,EAAE,IAAI,CAAC,CAAA"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.action = void 0;
4
+ const env_1 = require("@things-factory/env");
5
+ const sellercraft_channel_integration_1 = require("./sellercraft-channel-integration");
6
+ const sellercraftConfig = env_1.config.get('sellercraftChannelIntegrationConfig', {});
7
+ const { apiKey } = sellercraftConfig;
8
+ function substitute(path, obj) {
9
+ var props = [];
10
+ var re = /{([^}]+)}/g;
11
+ var text;
12
+ while ((text = re.exec(path))) {
13
+ props.push(text[1]);
14
+ }
15
+ var result = path;
16
+ props.forEach(prop => {
17
+ let value = obj[prop.trim()];
18
+ result = result.replace(`{${prop}}`, value === undefined ? '' : value);
19
+ });
20
+ return result;
21
+ }
22
+ const action = async ({ method = 'get', path, request }) => {
23
+ const client = new sellercraft_channel_integration_1.SellercraftChannelIntegration({ apiKey });
24
+ const { resource = {}, payload = {} } = request;
25
+ path = substitute(path, resource);
26
+ var response = await client[method](path, payload);
27
+ if (response.errors) {
28
+ throw response;
29
+ }
30
+ return response;
31
+ };
32
+ exports.action = action;
33
+ //# sourceMappingURL=platform-action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-action.js","sourceRoot":"","sources":["../../../server/controllers/sellercraft-channel-integration/platform-action.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,uFAAiF;AAEjF,MAAM,iBAAiB,GAAG,YAAM,CAAC,GAAG,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAA;AAC/E,MAAM,EAAE,MAAM,EAAE,GAAG,iBAAiB,CAAA;AAEpC,SAAS,UAAU,CAAC,IAAI,EAAE,GAAG;IAC3B,IAAI,KAAK,GAAG,EAAE,CAAA;IACd,IAAI,EAAE,GAAG,YAAY,CAAA;IACrB,IAAI,IAAI,CAAA;IAER,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;QAC7B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;KACpB;IAED,IAAI,MAAM,GAAG,IAAI,CAAA;IACjB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnB,IAAI,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAC5B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,GAAG,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC;AAEM,MAAM,MAAM,GAAG,KAAK,EAAE,EAAE,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,IAAI,+DAA6B,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IAE5D,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,OAAO,CAAA;IAE/C,IAAI,GAAG,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAEjC,IAAI,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAClD,IAAI,QAAQ,CAAC,MAAM,EAAE;QACnB,MAAM,QAAQ,CAAA;KACf;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAbY,QAAA,MAAM,UAalB"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SellercraftChannelIntegration = void 0;
7
+ const node_fetch_1 = __importDefault(require("node-fetch"));
8
+ const v4_1 = __importDefault(require("uuid/v4"));
9
+ const debug = require('debug')('things-factory:integration-sellercraft:sellercraft');
10
+ class SellercraftChannelIntegration {
11
+ constructor(config) {
12
+ this.config = Object.assign({}, config);
13
+ }
14
+ getBaseUrl() {
15
+ return `https://open.sellercraft.co/v1`;
16
+ }
17
+ generateRequestId() {
18
+ return (0, v4_1.default)();
19
+ }
20
+ async post(path, data = {}) {
21
+ const { apiKey } = this.config;
22
+ debug('data', data);
23
+ const jsondata = JSON.stringify(data);
24
+ const requestId = this.generateRequestId();
25
+ const fullPath = `${this.getBaseUrl()}${path}`;
26
+ const response = await (0, node_fetch_1.default)(fullPath, {
27
+ method: 'post',
28
+ headers: {
29
+ 'Content-Type': 'application/json',
30
+ request_id: requestId,
31
+ 'x-api-key': apiKey
32
+ },
33
+ body: jsondata
34
+ });
35
+ if (response.ok) {
36
+ return await response.json();
37
+ }
38
+ else {
39
+ throw new Error(`response code - ${response.status}, ${response.statusText}`);
40
+ }
41
+ }
42
+ async put(path, data = {}) {
43
+ const { apiKey } = this.config;
44
+ const jsondata = JSON.stringify(data);
45
+ const requestId = this.generateRequestId();
46
+ const fullPath = `${this.getBaseUrl()}${path}`;
47
+ debug('data', data);
48
+ const response = await (0, node_fetch_1.default)(fullPath, {
49
+ method: 'put',
50
+ headers: {
51
+ 'Content-Type': 'application/json',
52
+ request_id: requestId,
53
+ 'x-api-key': apiKey
54
+ },
55
+ body: jsondata
56
+ });
57
+ if (response.ok) {
58
+ return await response.json();
59
+ }
60
+ else {
61
+ throw new Error(`response code - ${response.status}, ${response.statusText}`);
62
+ }
63
+ }
64
+ async get(path, data = {}) {
65
+ const { apiKey } = this.config;
66
+ const qs = Object.entries(data)
67
+ .map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
68
+ .join('&');
69
+ const fullPath = `${this.getBaseUrl()}${path}`;
70
+ const endpoint = `${fullPath}${qs ? '?' + qs : ''}`;
71
+ debug('endpoint', endpoint);
72
+ const requestId = this.generateRequestId();
73
+ const response = await (0, node_fetch_1.default)(endpoint, {
74
+ method: 'get',
75
+ headers: {
76
+ 'Content-Type': 'application/json',
77
+ request_id: requestId,
78
+ 'x-api-key': apiKey
79
+ }
80
+ });
81
+ if (response.ok) {
82
+ return await response.json();
83
+ }
84
+ else {
85
+ throw new Error(`response code - ${response.status}, ${response.statusText}`);
86
+ }
87
+ }
88
+ }
89
+ exports.SellercraftChannelIntegration = SellercraftChannelIntegration;
90
+ //# sourceMappingURL=sellercraft-channel-integration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sellercraft-channel-integration.js","sourceRoot":"","sources":["../../../server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA8B;AAC9B,iDAA0B;AAE1B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAMpF,MAAa,6BAA6B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,iBAAiB,EAAE,CAAA;QAElD,MAAM,QAAQ,GAAQ,MAAM,IAAA,oBAAK,EAAC,QAAQ,EAAE;YAC1C,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,UAAU,EAAE,SAAS;gBACrB,WAAW,EAAE,MAAM;aACpB;SACF,CAAC,CAAA;QAEF,IAAI,QAAQ,CAAC,EAAE,EAAE;YACf,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;SAC7B;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,mBAAmB,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;SAC9E;IACH,CAAC;CACF;AAhGD,sEAgGC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.api = void 0;
7
+ const debug_1 = __importDefault(require("debug"));
8
+ const debug = (0, debug_1.default)('things-factory:integration-marketplace:store-api-decorator');
9
+ const NOOP = v => v;
10
+ const api = (target, property, descriptor) => {
11
+ const method = descriptor.value;
12
+ descriptor.value = async function (store, request) {
13
+ const SellercraftChannelIntegrationAPI = this;
14
+ var { platform } = store;
15
+ var { action: platformAction, apis } = SellercraftChannelIntegrationAPI.getPlatform(platform);
16
+ var m = apis[method.name];
17
+ if (!m) {
18
+ throw Error(`Sellercraft doesn't have API ${method.name}`);
19
+ }
20
+ var { path, method: httpMethod = 'post', denormalize = NOOP, normalize = NOOP, action = platformAction } = m.apply(this, [request]);
21
+ var denormalized = await denormalize(request || {}, { store });
22
+ debug('request', denormalized);
23
+ var response = await action.apply(this, [
24
+ { store, method: httpMethod, path, request: denormalized, platformAction }
25
+ ]);
26
+ debug('response', response);
27
+ return await normalize(response, { store });
28
+ };
29
+ return descriptor;
30
+ };
31
+ exports.api = api;
32
+ //# sourceMappingURL=decorators.js.map