@things-factory/integration-sellercraft 4.0.0-y.0 → 4.0.4

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 (65) hide show
  1. package/client/bootstrap.js +1 -28
  2. package/client/pages/sellercraft-store.js +22 -3
  3. package/client/utils/index.js +12 -0
  4. package/dist-server/controllers/index.js +1 -1
  5. package/dist-server/controllers/index.js.map +1 -1
  6. package/dist-server/controllers/sellercraft/apis/add-inbound-order.js +32 -1
  7. package/dist-server/controllers/sellercraft/apis/add-inbound-order.js.map +1 -1
  8. package/dist-server/controllers/sellercraft/apis/fetch-order-document.js +6 -2
  9. package/dist-server/controllers/sellercraft/apis/fetch-order-document.js.map +1 -1
  10. package/dist-server/controllers/sellercraft/apis/initiate-order-document.js +4 -1
  11. package/dist-server/controllers/sellercraft/apis/initiate-order-document.js.map +1 -1
  12. package/dist-server/controllers/sellercraft/apis/initiate-order-shipment.js +11 -2
  13. package/dist-server/controllers/sellercraft/apis/initiate-order-shipment.js.map +1 -1
  14. package/dist-server/controllers/sellercraft/apis/pack-marketplace-order.js +20 -2
  15. package/dist-server/controllers/sellercraft/apis/pack-marketplace-order.js.map +1 -1
  16. package/dist-server/controllers/sellercraft/apis/update-product.js +23 -1
  17. package/dist-server/controllers/sellercraft/apis/update-product.js.map +1 -1
  18. package/dist-server/controllers/sellercraft/index.js +7 -7
  19. package/dist-server/controllers/sellercraft/index.js.map +1 -1
  20. package/dist-server/controllers/sellercraft/platform-action.js +3 -3
  21. package/dist-server/controllers/sellercraft/platform-action.js.map +1 -1
  22. package/dist-server/controllers/sellercraft/sellercraft.js +42 -25
  23. package/dist-server/controllers/sellercraft/sellercraft.js.map +1 -1
  24. package/dist-server/controllers/sellercraft-api/decorators.js +32 -0
  25. package/dist-server/controllers/sellercraft-api/decorators.js.map +1 -0
  26. package/dist-server/controllers/sellercraft-api/index.js +92 -0
  27. package/dist-server/controllers/sellercraft-api/index.js.map +1 -0
  28. package/dist-server/controllers/sellercraft-api/types.js +1 -0
  29. package/dist-server/controllers/sellercraft-api/types.js.map +1 -0
  30. package/dist-server/index.js +2 -1
  31. package/dist-server/index.js.map +1 -1
  32. package/dist-server/service/sellercraft/sellercraft-mutation.js +5 -7
  33. package/dist-server/service/sellercraft/sellercraft-mutation.js.map +1 -1
  34. package/dist-server/service/sellercraft/sellercraft-query.js +2 -5
  35. package/dist-server/service/sellercraft/sellercraft-query.js.map +1 -1
  36. package/dist-server/service/sellercraft/sellercraft-type.js +4 -4
  37. package/dist-server/service/sellercraft/sellercraft-type.js.map +1 -1
  38. package/dist-server/service/sellercraft/sellercraft.js +11 -3
  39. package/dist-server/service/sellercraft/sellercraft.js.map +1 -1
  40. package/package.json +14 -14
  41. package/server/controllers/index.ts +1 -1
  42. package/server/controllers/sellercraft/apis/add-inbound-order.ts +40 -1
  43. package/server/controllers/sellercraft/apis/fetch-order-document.ts +6 -2
  44. package/server/controllers/sellercraft/apis/initiate-order-document.ts +4 -1
  45. package/server/controllers/sellercraft/apis/initiate-order-shipment.ts +17 -2
  46. package/server/controllers/sellercraft/apis/pack-marketplace-order.ts +23 -2
  47. package/server/controllers/sellercraft/apis/update-product.ts +26 -1
  48. package/server/controllers/sellercraft/index.ts +4 -4
  49. package/server/controllers/sellercraft/platform-action.ts +4 -3
  50. package/server/controllers/sellercraft/sellercraft.ts +41 -28
  51. package/server/controllers/{store-api → sellercraft-api}/decorators.ts +0 -0
  52. package/server/controllers/{store-api → sellercraft-api}/index.ts +1 -0
  53. package/server/controllers/{store-api → sellercraft-api}/types.ts +0 -0
  54. package/server/index.ts +3 -2
  55. package/server/service/sellercraft/sellercraft-mutation.ts +7 -7
  56. package/server/service/sellercraft/sellercraft-query.ts +5 -7
  57. package/server/service/sellercraft/sellercraft-type.ts +10 -9
  58. package/server/service/sellercraft/sellercraft.ts +13 -3
  59. package/things-factory.config.js +1 -1
  60. package/translations/en.json +4 -0
  61. package/translations/ko.json +4 -0
  62. package/translations/ms.json +4 -0
  63. package/translations/zh.json +4 -1
  64. package/client/themes/app-theme.css +0 -117
  65. package/client/themes/layout-theme.css +0 -92
@@ -1,28 +1 @@
1
- import { html } from 'lit-element'
2
- import { store, navigate } from '@things-factory/shell'
3
- import { ADD_MORENDA } from '@things-factory/more-base'
4
-
5
- export default function bootstrap() {
6
- /* for integration */
7
- store.dispatch({
8
- type: ADD_MORENDA,
9
- morenda: {
10
- icon: html` <mwc-icon>device_hub</mwc-icon> `,
11
- name: html` <i18n-msg msgid="text.connection"></i18n-msg> `,
12
- action: () => {
13
- navigate('connection')
14
- }
15
- }
16
- })
17
-
18
- store.dispatch({
19
- type: ADD_MORENDA,
20
- morenda: {
21
- icon: html` <mwc-icon>format_list_numbered</mwc-icon> `,
22
- name: html` <i18n-msg msgid="text.scenario"></i18n-msg> `,
23
- action: () => {
24
- navigate('scenario')
25
- }
26
- }
27
- })
28
- }
1
+ export default function bootstrap() {}
@@ -1,10 +1,12 @@
1
1
  import '@things-factory/form-ui'
2
+
3
+ import gql from 'graphql-tag'
4
+ import { css, html } from 'lit-element'
5
+
2
6
  import { i18next, localize } from '@things-factory/i18n-base'
3
- import { client, CustomAlert, gqlContext, PageView } from '@things-factory/shell'
7
+ import { client, CustomAlert, gqlContext, navigate, PageView } from '@things-factory/shell'
4
8
  import { CommonButtonStyles, ScrollbarStyles } from '@things-factory/styles'
5
9
  import { isMobileDevice } from '@things-factory/utils'
6
- import gql from 'graphql-tag'
7
- import { css, html } from 'lit-element'
8
10
 
9
11
  class SellercraftStore extends localize(i18next)(PageView) {
10
12
  static get styles() {
@@ -74,6 +76,20 @@ class SellercraftStore extends localize(i18next)(PageView) {
74
76
  { type: 'gutter', gutterName: 'dirty' },
75
77
  { type: 'gutter', gutterName: 'sequence' },
76
78
  { type: 'gutter', gutterName: 'row-selector', multiple: true },
79
+ {
80
+ type: 'gutter',
81
+ gutterName: 'button',
82
+ icon: record => (!record ? 'link' : record.status == 'ACTIVE' ? 'link_off' : 'link'),
83
+ handlers: {
84
+ click: (columns, data, column, record, rowIndex) => {
85
+ if (!record || record.__dirty__ == '+') {
86
+ return
87
+ }
88
+
89
+ navigate(`sellercraft-store-setting/${record.id}`)
90
+ }
91
+ }
92
+ },
77
93
  {
78
94
  type: 'string',
79
95
  name: 'id',
@@ -139,6 +155,9 @@ class SellercraftStore extends localize(i18next)(PageView) {
139
155
  sellercrafts(filters: $filters, pagination: $pagination, sortings: $sortings) {
140
156
  items {
141
157
  id
158
+ domain {
159
+ subdomain
160
+ }
142
161
  platform
143
162
  accountId
144
163
  status
@@ -0,0 +1,12 @@
1
+ import { buildGqlContext } from '@things-factory/shell'
2
+
3
+ export function buildDomainContext(domain) {
4
+ let urlSearchParam = ''
5
+ if (domain?.subdomain) {
6
+ urlSearchParam += `?${buildGqlContext({
7
+ headers: { 'x-things-factory-domain': domain.subdomain }
8
+ })}`
9
+ }
10
+
11
+ return urlSearchParam
12
+ }
@@ -11,5 +11,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  require("./sellercraft");
14
- __exportStar(require("./store-api"), exports);
14
+ __exportStar(require("./sellercraft-api"), exports);
15
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yBAAsB;AAEtB,8CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yBAAsB;AAEtB,oDAAiC"}
@@ -7,7 +7,38 @@ function addInboundOrder() {
7
7
  method: 'post',
8
8
  path: '/product/inbound',
9
9
  denormalize(req) {
10
- return req;
10
+ const { accountId, inboundId, inboundTime, inboundType, purchaseOrderId, sellercraftOPs } = req;
11
+ let orderInformation = {};
12
+ orderInformation.account_id = accountId;
13
+ orderInformation.inbound_id = inboundId;
14
+ orderInformation.inbound_time = inboundTime;
15
+ orderInformation.inbound_type = inboundType;
16
+ orderInformation.purchase_order_id = purchaseOrderId;
17
+ let products = sellercraftOPs.map(orderProduct => {
18
+ const { packageDimension, forceCreateProduct } = orderProduct;
19
+ let sellercraftOP = {};
20
+ sellercraftOP.sku = orderProduct.sku;
21
+ sellercraftOP.unit_of_measure = orderProduct.uom;
22
+ sellercraftOP.purchase_order_quantity = orderProduct.purchaseOrderQty;
23
+ sellercraftOP.received_quantity = orderProduct.receivedQty;
24
+ sellercraftOP.batch_number = orderProduct.batchId;
25
+ sellercraftOP.expiry_time = (orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct.expiryTime) ? orderProduct.expiryTime : 0;
26
+ sellercraftOP.force_create_product = forceCreateProduct;
27
+ if (forceCreateProduct) {
28
+ sellercraftOP.product_name = orderProduct.productName;
29
+ sellercraftOP.gtin = orderProduct.gtin;
30
+ sellercraftOP.package_weight_gm = orderProduct.weight;
31
+ sellercraftOP.package_dimensions = {
32
+ length_mm: packageDimension.length,
33
+ width_mm: packageDimension.width,
34
+ height_mm: packageDimension.height
35
+ };
36
+ }
37
+ return sellercraftOP;
38
+ });
39
+ return {
40
+ payload: Object.assign(Object.assign({}, orderInformation), { products })
41
+ };
11
42
  },
12
43
  normalize(res) {
13
44
  return res;
@@ -1 +1 @@
1
- {"version":3,"file":"add-inbound-order.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft/apis/add-inbound-order.ts"],"names":[],"mappings":";AAAA,gGAAgG;;;AAEhG,SAAgB,eAAe;IAC7B,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,kBAAkB;QACxB,WAAW,CAAC,GAAG;YACb,OAAO,GAAG,CAAA;QACZ,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAXD,0CAWC"}
1
+ {"version":3,"file":"add-inbound-order.js","sourceRoot":"","sources":["../../../../server/controllers/sellercra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,CAAC,YAAY,GAAG,YAAY,CAAC,WAAW,CAAA;oBACrD,aAAa,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAA;oBACtC,aAAa,CAAC,iBAAiB,GAAG,YAAY,CAAC,MAAM,CAAA;oBACrD,aAAa,CAAC,kBAAkB,GAAG;wBACjC,SAAS,EAAE,gBAAgB,CAAC,MAAM;wBAClC,QAAQ,EAAE,gBAAgB,CAAC,KAAK;wBAChC,SAAS,EAAE,gBAAgB,CAAC,MAAM;qBACnC,CAAA;iBACF;gBAED,OAAO,aAAa,CAAA;YACtB,CAAC,CAAC,CAAA;YAEF,OAAO;gBACL,OAAO,kCACF,gBAAgB,KACnB,QAAQ,GACT;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAlDD,0CAkDC"}
@@ -7,10 +7,14 @@ function fetchOrderDocument() {
7
7
  method: 'get',
8
8
  path: '/order/documents',
9
9
  denormalize(req) {
10
- return req;
10
+ const { accountId: account_id, orderId: order_id, packageId: package_id } = req;
11
+ return {
12
+ payload: { account_id, order_id, package_id }
13
+ };
11
14
  },
12
15
  normalize(res) {
13
- return res;
16
+ const { documents, tracking_no: trackingNo } = res.data;
17
+ return { documents, trackingNo };
14
18
  }
15
19
  };
16
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-order-document.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft/apis/fetch-order-document.ts"],"names":[],"mappings":";AAAA,6FAA6F;;;AAE7F,SAAgB,kBAAkB;IAChC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,kBAAkB;QACxB,WAAW,CAAC,GAAG;YACb,OAAO,GAAG,CAAA;QACZ,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAXD,gDAWC"}
1
+ {"version":3,"file":"fetch-order-document.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft/apis/fetch-order-document.ts"],"names":[],"mappings":";AAAA,6FAA6F;;;AAE7F,SAAgB,kBAAkB;IAChC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,kBAAkB;QACxB,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,GAAG,CAAA;YAC/E,OAAO;gBACL,OAAO,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE;aAC9C,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC,IAAI,CAAA;YACvD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,CAAA;QAClC,CAAC;KACF,CAAA;AACH,CAAC;AAfD,gDAeC"}
@@ -7,7 +7,10 @@ function initiateOrderDocument() {
7
7
  method: 'post',
8
8
  path: '/order/documents',
9
9
  denormalize(req) {
10
- return req;
10
+ const { accountId: account_id, orderId: order_id, packageId: package_id } = req;
11
+ return {
12
+ payload: { account_id, order_id, package_id }
13
+ };
11
14
  },
12
15
  normalize(res) {
13
16
  return res;
@@ -1 +1 @@
1
- {"version":3,"file":"initiate-order-document.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft/apis/initiate-order-document.ts"],"names":[],"mappings":";AAAA,gGAAgG;;;AAEhG,SAAgB,qBAAqB;IACnC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,kBAAkB;QACxB,WAAW,CAAC,GAAG;YACb,OAAO,GAAG,CAAA;QACZ,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAXD,sDAWC"}
1
+ {"version":3,"file":"initiate-order-document.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft/apis/initiate-order-document.ts"],"names":[],"mappings":";AAAA,gGAAgG;;;AAEhG,SAAgB,qBAAqB;IACnC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,kBAAkB;QACxB,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,GAAG,CAAA;YAC/E,OAAO;gBACL,OAAO,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE;aAC9C,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAdD,sDAcC"}
@@ -7,10 +7,19 @@ function initiateOrderShipment() {
7
7
  method: 'post',
8
8
  path: '/order/ship',
9
9
  denormalize(req) {
10
- return req;
10
+ const { accountId: account_id, orderId: order_id, packageId: package_id } = req;
11
+ return {
12
+ payload: { account_id, order_id, package_id }
13
+ };
11
14
  },
12
15
  normalize(res) {
13
- return res;
16
+ const { handover_type: handOverType, pickup_time: pickupTime, pickup_address: pickupAddress, dropoff_address: dropoffAddress } = res.data;
17
+ return {
18
+ handOverType,
19
+ pickupTime,
20
+ pickupAddress,
21
+ dropoffAddress
22
+ };
14
23
  }
15
24
  };
16
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"initiate-order-shipment.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft/apis/initiate-order-shipment.ts"],"names":[],"mappings":";AAAA,+FAA+F;;;AAE/F,SAAgB,qBAAqB;IACnC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,aAAa;QACnB,WAAW,CAAC,GAAG;YACb,OAAO,GAAG,CAAA;QACZ,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAXD,sDAWC"}
1
+ {"version":3,"file":"initiate-order-shipment.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft/apis/initiate-order-shipment.ts"],"names":[],"mappings":";AAAA,+FAA+F;;;AAE/F,SAAgB,qBAAqB;IACnC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,aAAa;QACnB,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,GAAG,CAAA;YAC/E,OAAO;gBACL,OAAO,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE;aAC9C,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;AA1BD,sDA0BC"}
@@ -7,10 +7,28 @@ function packMarketplaceOrder() {
7
7
  method: 'post',
8
8
  path: '/order/pack',
9
9
  denormalize(req) {
10
- return req;
10
+ const { accountId: account_id, orderId: order_id, sellercraftOPs } = req;
11
+ const items = sellercraftOPs.map(orderProduct => {
12
+ return {
13
+ sku: orderProduct.sku,
14
+ quantity: orderProduct.releaseQty,
15
+ unit_of_measure: orderProduct.uom
16
+ };
17
+ });
18
+ let packages = [];
19
+ packages.push({ items });
20
+ return {
21
+ payload: {
22
+ account_id,
23
+ order_id,
24
+ packages
25
+ }
26
+ };
11
27
  },
12
28
  normalize(res) {
13
- return res;
29
+ const { packages } = res.data;
30
+ const packageId = packages[0].package_id;
31
+ return packageId;
14
32
  }
15
33
  };
16
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pack-marketplace-order.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft/apis/pack-marketplace-order.ts"],"names":[],"mappings":";AAAA,qFAAqF;;;AAErF,SAAgB,oBAAoB;IAClC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,aAAa;QACnB,WAAW,CAAC,GAAG;YACb,OAAO,GAAG,CAAA;QACZ,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAXD,oDAWC"}
1
+ {"version":3,"file":"pack-marketplace-order.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft/apis/pack-marketplace-order.ts"],"names":[],"mappings":";AAAA,qFAAqF;;;AAErF,SAAgB,oBAAoB;IAClC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,aAAa;QACnB,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,GAAG,CAAA;YAExE,MAAM,KAAK,GAAU,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;gBACrD,OAAO;oBACL,GAAG,EAAE,YAAY,CAAC,GAAG;oBACrB,QAAQ,EAAE,YAAY,CAAC,UAAU;oBACjC,eAAe,EAAE,YAAY,CAAC,GAAG;iBAClC,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,IAAI,QAAQ,GAAU,EAAE,CAAA;YACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;YAExB,OAAO;gBACL,OAAO,EAAE;oBACP,UAAU;oBACV,QAAQ;oBACR,QAAQ;iBACT;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,IAAI,CAAA;YAC7B,MAAM,SAAS,GAAW,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;YAChD,OAAO,SAAS,CAAA;QAClB,CAAC;KACF,CAAA;AACH,CAAC;AAhCD,oDAgCC"}
@@ -7,7 +7,29 @@ function updateProduct() {
7
7
  method: 'put',
8
8
  path: '/product',
9
9
  denormalize(req) {
10
- return req;
10
+ const { sellercraftInv } = req;
11
+ let products = [];
12
+ const { packageDimension, accountId: account_id } = sellercraftInv;
13
+ let sellercraftOP = {};
14
+ sellercraftOP.sku = sellercraftInv.sku;
15
+ sellercraftOP.gtin = sellercraftInv.gtin;
16
+ sellercraftOP.stock = {
17
+ quantity: sellercraftInv.quantity,
18
+ unit_of_measure: sellercraftInv.uom
19
+ };
20
+ sellercraftOP.package_weight_gm = sellercraftInv.weight;
21
+ sellercraftOP.package_dimensions = {
22
+ length_mm: packageDimension.length,
23
+ width_mm: packageDimension.width,
24
+ height_mm: packageDimension.height
25
+ };
26
+ products.push(Object.assign({}, sellercraftOP));
27
+ return {
28
+ payload: {
29
+ account_id,
30
+ products
31
+ }
32
+ };
11
33
  },
12
34
  normalize(res) {
13
35
  return res;
@@ -1 +1 @@
1
- {"version":3,"file":"update-product.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft/apis/update-product.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,SAAgB,aAAa;IAC3B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,UAAU;QAChB,WAAW,CAAC,GAAG;YACb,OAAO,GAAG,CAAA;QACZ,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAXD,sCAWC"}
1
+ {"version":3,"file":"update-product.js","sourceRoot":"","sources":["../../../../server/controllers/sellercraft/apis/update-product.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,SAAgB,aAAa;IAC3B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,UAAU;QAChB,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,cAAc,EAAE,GAAG,GAAG,CAAA;YAE9B,IAAI,QAAQ,GAAU,EAAE,CAAA;YACxB,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,cAAc,CAAA;YAClE,IAAI,aAAa,GAAQ,EAAE,CAAA;YAC3B,aAAa,CAAC,GAAG,GAAG,cAAc,CAAC,GAAG,CAAA;YACtC,aAAa,CAAC,IAAI,GAAG,cAAc,CAAC,IAAI,CAAA;YACxC,aAAa,CAAC,KAAK,GAAG;gBACpB,QAAQ,EAAE,cAAc,CAAC,QAAQ;gBACjC,eAAe,EAAE,cAAc,CAAC,GAAG;aACpC,CAAA;YACD,aAAa,CAAC,iBAAiB,GAAG,cAAc,CAAC,MAAM,CAAA;YACvD,aAAa,CAAC,kBAAkB,GAAG;gBACjC,SAAS,EAAE,gBAAgB,CAAC,MAAM;gBAClC,QAAQ,EAAE,gBAAgB,CAAC,KAAK;gBAChC,SAAS,EAAE,gBAAgB,CAAC,MAAM;aACnC,CAAA;YAED,QAAQ,CAAC,IAAI,mBAAM,aAAa,EAAG,CAAA;YAEnC,OAAO;gBACL,OAAO,EAAE;oBACP,UAAU;oBACV,QAAQ;iBACT;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AApCD,sCAoCC"}
@@ -11,9 +11,6 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
11
11
  }) : function(o, v) {
12
12
  o["default"] = v;
13
13
  });
14
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
- };
17
14
  var __importStar = (this && this.__importStar) || function (mod) {
18
15
  if (mod && mod.__esModule) return mod;
19
16
  var result = {};
@@ -21,10 +18,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
21
18
  __setModuleDefault(result, mod);
22
19
  return result;
23
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
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- __exportStar(require("./sellercraft"), exports);
26
- const store_api_1 = require("../store-api");
27
- const platform_action_1 = require("./platform-action");
25
+ const sellercraft_api_1 = require("../sellercraft-api");
28
26
  const APIS = __importStar(require("./apis"));
29
- store_api_1.SellercraftAPI.registerPlatform('sellercraft', platform_action_1.action, APIS);
27
+ const platform_action_1 = require("./platform-action");
28
+ __exportStar(require("./sellercraft"), exports);
29
+ sellercraft_api_1.SellercraftAPI.registerPlatform('sellercraft', platform_action_1.action, APIS);
30
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/controllers/sellercraft/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA6B;AAE7B,4CAA6C;AAC7C,uDAA0C;AAC1C,6CAA8B;AAE9B,0BAAc,CAAC,gBAAgB,CAAC,aAAa,EAAE,wBAAM,EAAE,IAAI,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/controllers/sellercraft/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAmD;AACnD,6CAA8B;AAC9B,uDAA0C;AAE1C,gDAA6B;AAE7B,gCAAc,CAAC,gBAAgB,CAAC,aAAa,EAAE,wBAAM,EAAE,IAAI,CAAC,CAAA"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.action = void 0;
4
- const sellercraft_1 = require("./sellercraft");
5
4
  const env_1 = require("@things-factory/env");
5
+ const sellercraft_1 = require("./sellercraft");
6
6
  const sellercraftConfig = env_1.config.get('sellercraftIntegrationConfig', {});
7
7
  const { apiKey } = sellercraftConfig;
8
8
  function substitute(path, obj) {
@@ -19,11 +19,11 @@ function substitute(path, obj) {
19
19
  });
20
20
  return result;
21
21
  }
22
- const action = async ({ center, method = 'get', path, request }) => {
22
+ const action = async ({ method = 'get', path, request }) => {
23
23
  const client = new sellercraft_1.Sellercraft({ apiKey });
24
24
  const { resource = {}, payload = {} } = request;
25
25
  path = substitute(path, resource);
26
- var response = await client[method](center, path, payload);
26
+ var response = await client[method](path, payload);
27
27
  if (response.errors) {
28
28
  throw response;
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"platform-action.js","sourceRoot":"","sources":["../../../server/controllers/sellercraft/platform-action.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,6CAA4C;AAC5C,MAAM,iBAAiB,GAAG,YAAM,CAAC,GAAG,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAA;AACxE,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,EAAE,MAAM,GAAG,K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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,yBAAW,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IAE1C,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"}
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Sellercraft = void 0;
7
- const v4_1 = __importDefault(require("uuid/v4"));
8
7
  const node_fetch_1 = __importDefault(require("node-fetch"));
8
+ const v4_1 = __importDefault(require("uuid/v4"));
9
9
  const debug = require('debug')('things-factory:integration-sellercraft:sellercraft');
10
10
  class Sellercraft {
11
11
  constructor(config) {
@@ -17,56 +17,73 @@ class Sellercraft {
17
17
  generateRequestId() {
18
18
  return (0, v4_1.default)();
19
19
  }
20
- async post(endpoint, data = {}) {
20
+ async post(path, data = {}) {
21
21
  const { apiKey } = this.config;
22
22
  debug('data', data);
23
23
  const jsondata = JSON.stringify(data);
24
- const response = await (0, node_fetch_1.default)(`${this.getBaseUrl()}/${endpoint}`, {
24
+ const requestId = this.generateRequestId();
25
+ const fullPath = `${this.getBaseUrl()}${path}`;
26
+ const response = await (0, node_fetch_1.default)(fullPath, {
25
27
  method: 'post',
26
28
  headers: {
27
29
  'Content-Type': 'application/json',
28
- request_id: this.generateRequestId(),
30
+ request_id: requestId,
29
31
  'x-api-key': apiKey
30
32
  },
31
33
  body: jsondata
32
34
  });
33
- const result = await response.json();
34
- debug('response result', result);
35
- return result;
35
+ if (response.ok) {
36
+ return await response.json();
37
+ }
38
+ else {
39
+ throw new Error(`response code - ${response.status}, ${response.statusText}`);
40
+ }
36
41
  }
37
- async put(endpoint, data = {}) {
42
+ async put(path, data = {}) {
38
43
  const { apiKey } = this.config;
39
44
  const jsondata = JSON.stringify(data);
45
+ const requestId = this.generateRequestId();
46
+ const fullPath = `${this.getBaseUrl()}${path}`;
40
47
  debug('data', data);
41
- const response = await (0, node_fetch_1.default)(`${this.getBaseUrl()}/${endpoint}`, {
42
- method: 'post',
48
+ const response = await (0, node_fetch_1.default)(fullPath, {
49
+ method: 'put',
43
50
  headers: {
44
51
  'Content-Type': 'application/json',
45
- request_id: this.generateRequestId(),
52
+ request_id: requestId,
46
53
  'x-api-key': apiKey
47
54
  },
48
55
  body: jsondata
49
56
  });
50
- const result = await response.json();
51
- debug('response result', result);
52
- return result;
57
+ if (response.ok) {
58
+ return await response.json();
59
+ }
60
+ else {
61
+ throw new Error(`response code - ${response.status}, ${response.statusText}`);
62
+ }
53
63
  }
54
- async get(endpoint, data = {}) {
64
+ async get(path, data = {}) {
55
65
  const { apiKey } = this.config;
56
- const jsondata = JSON.stringify(data);
57
- debug('data', data);
58
- const response = await (0, node_fetch_1.default)(`${this.getBaseUrl()}/${endpoint}`, {
59
- method: 'post',
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',
60
75
  headers: {
61
76
  'Content-Type': 'application/json',
62
- request_id: this.generateRequestId(),
77
+ request_id: requestId,
63
78
  'x-api-key': apiKey
64
- },
65
- body: jsondata
79
+ }
66
80
  });
67
- const result = await response.json();
68
- debug('response result', result);
69
- return result;
81
+ if (response.ok) {
82
+ return await response.json();
83
+ }
84
+ else {
85
+ throw new Error(`response code - ${response.status}, ${response.statusText}`);
86
+ }
70
87
  }
71
88
  }
72
89
  exports.Sellercraft = Sellercraft;
@@ -1 +1 @@
1
- {"version":3,"file":"sellercraft.js","sourceRoot":"","sources":["../../../server/controllers/sellercraft/sellercraft.ts"],"names":[],"mappings":";;;;;;AAAA,iDAA0B;AAC1B,4DAA8B;AAE9B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAMpF,MAAa,WAAW;IAGtB,YAAY,MAAyB;QACnC,IAAI,CAAC,MAAM,qBACN,MAAM,CACV,CAAA;IACH,CAAC;IAED,UAAU;QACR,OAAO,gCAAgC,CAAA;IACzC,CAAC;IAED,iBAAiB;QACf,OAAO,IAAA,YAAI,GAAE,CAAA;IACf,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAY,EAAE;QACjC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QAE9B,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAEnB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QAErC,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,QAAQ,EAAE,EAAE;YAC/D,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kB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AAC,IAAY,EAAE,OAAY,EAAE;QACpC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QAE9B,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;aAC5B,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aACxD,IAAI,CAAC,GAAG,CAAC,CAAA;QAEZ,MAAM,QAAQ,GAAW,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,EAAE,CAAA;QACtD,MAAM,QAAQ,GAAG,GAAG,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;QACnD,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QAE3B,MAAM,SAAS,GAAW,IAAI,CAAC,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,kCAgGC"}
@@ -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 SellercraftAPI = this;
14
+ var { platform } = store;
15
+ var { action: platformAction, apis } = SellercraftAPI.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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../server/controllers/sellercraft-api/decorators.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,4DAA4D,CAAC,CAAA;AAIjF,MAAM,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAEZ,MAAM,GAAG,GAAG,CAAC,MAAc,EAAE,QAAgB,EAAE,UAAwC,EAAO,EAAE;IACrG,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAA;IAE/B,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,KAAkB,EAAE,OAAO;QAC5D,MAAM,cAAc,GAAG,IAAI,CAAA;QAE3B,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;QAExB,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QAE3E,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACzB,IAAI,CAAC,CAAC,EAAE;YACN,MAAM,KAAK,CAAC,gCAAgC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;SAC3D;QAED,IAAI,EACF,IAAI,EACJ,MAAM,EAAE,UAAU,GAAG,MAAM,EAC3B,WAAW,GAAG,IAAI,EAClB,SAAS,GAAG,IAAI,EAChB,MAAM,GAAG,cAAc,EACxB,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;QAE5B,IAAI,YAAY,GAAG,MAAM,WAAW,CAAC,OAAO,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QAC9D,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,CAAA;QAE9B,IAAI,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;YACtC,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE;SAC3E,CAAC,CAAA;QAEF,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QAE3B,OAAO,MAAM,SAAS,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;IAC7C,CAAC,CAAA;IAED,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AApCY,QAAA,GAAG,OAoCf"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SellercraftAPI = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const service_1 = require("../../service");
15
+ const decorators_1 = require("./decorators");
16
+ class SellercraftAPI {
17
+ static registerPlatform(name, action, apis) {
18
+ SellercraftAPI.platforms[name] = {
19
+ action,
20
+ apis
21
+ };
22
+ }
23
+ static getPlatform(name) {
24
+ return SellercraftAPI.platforms[name];
25
+ }
26
+ static async getSellercraft(id) {
27
+ const repository = (0, typeorm_1.getRepository)(service_1.Sellercraft);
28
+ return await repository.findOne({
29
+ where: { id },
30
+ relations: ['domain']
31
+ });
32
+ }
33
+ static echo(sellercraft, req) { }
34
+ static addInboundOrder(sellercraft, req) { }
35
+ static fetchOrderDocument(sellercraft, req) { }
36
+ static initiateOrderDocument(sellercraft, req) { }
37
+ static initiateOrderShipment(sellercraft, req) { }
38
+ static packMarketplaceOrder(sellercraft, req) { }
39
+ static updateMarketplaceOrder(sellercraft, req) { }
40
+ static updateProduct(sellercraft, req) { }
41
+ }
42
+ SellercraftAPI.platforms = {};
43
+ __decorate([
44
+ decorators_1.api,
45
+ __metadata("design:type", Function),
46
+ __metadata("design:paramtypes", [Object, Object]),
47
+ __metadata("design:returntype", Object)
48
+ ], SellercraftAPI, "echo", null);
49
+ __decorate([
50
+ decorators_1.api,
51
+ __metadata("design:type", Function),
52
+ __metadata("design:paramtypes", [Object, Object]),
53
+ __metadata("design:returntype", Object)
54
+ ], SellercraftAPI, "addInboundOrder", null);
55
+ __decorate([
56
+ decorators_1.api,
57
+ __metadata("design:type", Function),
58
+ __metadata("design:paramtypes", [Object, Object]),
59
+ __metadata("design:returntype", Object)
60
+ ], SellercraftAPI, "fetchOrderDocument", null);
61
+ __decorate([
62
+ decorators_1.api,
63
+ __metadata("design:type", Function),
64
+ __metadata("design:paramtypes", [Object, Object]),
65
+ __metadata("design:returntype", Object)
66
+ ], SellercraftAPI, "initiateOrderDocument", null);
67
+ __decorate([
68
+ decorators_1.api,
69
+ __metadata("design:type", Function),
70
+ __metadata("design:paramtypes", [Object, Object]),
71
+ __metadata("design:returntype", Object)
72
+ ], SellercraftAPI, "initiateOrderShipment", null);
73
+ __decorate([
74
+ decorators_1.api,
75
+ __metadata("design:type", Function),
76
+ __metadata("design:paramtypes", [Object, Object]),
77
+ __metadata("design:returntype", Object)
78
+ ], SellercraftAPI, "packMarketplaceOrder", null);
79
+ __decorate([
80
+ decorators_1.api,
81
+ __metadata("design:type", Function),
82
+ __metadata("design:paramtypes", [Object, Object]),
83
+ __metadata("design:returntype", Object)
84
+ ], SellercraftAPI, "updateMarketplaceOrder", null);
85
+ __decorate([
86
+ decorators_1.api,
87
+ __metadata("design:type", Function),
88
+ __metadata("design:paramtypes", [Object, Object]),
89
+ __metadata("design:returntype", Object)
90
+ ], SellercraftAPI, "updateProduct", null);
91
+ exports.SellercraftAPI = SellercraftAPI;
92
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/controllers/sellercraft-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAuC;AAEvC,2CAA2C;AAC3C,6CAAkC;AAElC,MAAa,cAAc;IAGzB,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI;QACxC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG;YAC/B,MAAM;YACN,IAAI;SACL,CAAA;IACH,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAI;QACrB,OAAO,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IACvC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;QAC5B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