@things-factory/integration-sellercraft 9.0.0-beta.8 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/controllers/sellercraft/apis/add-inbound-order.js +5 -2
- package/dist-server/controllers/sellercraft/apis/add-inbound-order.js.map +1 -1
- package/dist-server/controllers/sellercraft/apis/echo.js +3 -3
- package/dist-server/controllers/sellercraft/apis/echo.js.map +1 -1
- package/dist-server/controllers/sellercraft/sellercraft.d.ts +1 -1
- package/dist-server/controllers/sellercraft/sellercraft.js +3 -1
- package/dist-server/controllers/sellercraft/sellercraft.js.map +1 -1
- package/dist-server/controllers/sellercraft-api/decorators.js +2 -2
- package/dist-server/controllers/sellercraft-api/decorators.js.map +1 -1
- package/dist-server/controllers/sellercraft-api/index.js +1 -1
- package/dist-server/controllers/sellercraft-api/index.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/echo.js +3 -3
- package/dist-server/controllers/sellercraft-channel-integration/apis/echo.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js +5 -5
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js +23 -19
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.d.ts +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js +4 -3
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration-api/index.js +1 -1
- package/dist-server/controllers/sellercraft-channel-integration-api/index.js.map +1 -1
- package/dist-server/routers/sellercraft-router.js +21 -23
- package/dist-server/routers/sellercraft-router.js.map +1 -1
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js +22 -21
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js.map +1 -1
- package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js +9 -11
- package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js.map +1 -1
- package/dist-server/service/sellercraft/sellercraft-mutation.js +33 -7
- package/dist-server/service/sellercraft/sellercraft-mutation.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/utils/tokencraft-util.js +12 -11
- package/dist-server/utils/tokencraft-util.js.map +1 -1
- package/package.json +14 -14
@@ -2,18 +2,19 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getShop = getShop;
|
4
4
|
exports.getShops = getShops;
|
5
|
+
const tslib_1 = require("tslib");
|
6
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
5
7
|
const env_1 = require("@things-factory/env");
|
6
8
|
const constants_1 = require("../constants");
|
7
9
|
const integration_base_1 = require("@things-factory/integration-base");
|
8
10
|
async function getShop(context, channelId, shopId) {
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
10
11
|
const sellercraftChannelIntegrationConfig = env_1.config.get('sellercraftChannelIntegrationConfig', {});
|
11
12
|
const { tokenCraftApiKey: apiKey, tokenCraftUrl } = sellercraftChannelIntegrationConfig;
|
12
13
|
const xApiKey = context.headers['x-api-key'];
|
13
14
|
if (apiKey !== xApiKey)
|
14
15
|
context.throw(400, 'api key validation failed');
|
15
16
|
var fullPath = `${tokenCraftUrl}?channel_id=${channelId}&shop_id=${shopId}`;
|
16
|
-
const response = await
|
17
|
+
const response = await (0, node_fetch_1.default)(fullPath, {
|
17
18
|
method: 'get',
|
18
19
|
headers: {
|
19
20
|
'Content-Type': 'application/json',
|
@@ -23,18 +24,18 @@ async function getShop(context, channelId, shopId) {
|
|
23
24
|
if (response.ok) {
|
24
25
|
let store = await response.json();
|
25
26
|
let mappedStore = {
|
26
|
-
accessKey:
|
27
|
-
accessSecret:
|
28
|
-
storeURL:
|
27
|
+
accessKey: store.shop?.credential?.consumer_key || '',
|
28
|
+
accessSecret: store.shop?.credential?.consumer_secret || '',
|
29
|
+
storeURL: store.shop?.credential?.store_url,
|
29
30
|
platform: constants_1.PLATFORM[`${store.shop.org_prefix}`],
|
30
|
-
accessToken:
|
31
|
-
channelShopId:
|
32
|
-
storeId:
|
31
|
+
accessToken: store.shop?.credential?.access_token,
|
32
|
+
channelShopId: store.shop?.channel_shop_id,
|
33
|
+
storeId: store.shop?.credential?.store_url
|
33
34
|
};
|
34
35
|
return mappedStore;
|
35
36
|
}
|
36
37
|
else {
|
37
|
-
(0, integration_base_1.createPayloadLog)(shopId, tokenCraftUrl, `channel_id=${channelId}&shop_id=${shopId}`,
|
38
|
+
(0, integration_base_1.createPayloadLog)(shopId, tokenCraftUrl, `channel_id=${channelId}&shop_id=${shopId}`, response?.statusText || 500, {
|
38
39
|
state: { domain: null }
|
39
40
|
});
|
40
41
|
}
|
@@ -43,7 +44,7 @@ async function getShops(channelId) {
|
|
43
44
|
const sellercraftChannelIntegrationConfig = env_1.config.get('sellercraftChannelIntegrationConfig', {});
|
44
45
|
const { tokenCraftApiKey: apiKey, getShopsTokenCraftUrl } = sellercraftChannelIntegrationConfig;
|
45
46
|
var channelsFullPath = getShopsTokenCraftUrl + '?channel_id=' + channelId;
|
46
|
-
const channelResponse = await
|
47
|
+
const channelResponse = await (0, node_fetch_1.default)(channelsFullPath, {
|
47
48
|
method: 'get',
|
48
49
|
headers: {
|
49
50
|
'Content-Type': 'application/json',
|
@@ -51,7 +52,7 @@ async function getShops(channelId) {
|
|
51
52
|
}
|
52
53
|
});
|
53
54
|
if (!channelResponse.ok) {
|
54
|
-
(0, integration_base_1.createPayloadLog)(channelId, getShopsTokenCraftUrl, `channel_id=${channelId}`,
|
55
|
+
(0, integration_base_1.createPayloadLog)(channelId, getShopsTokenCraftUrl, `channel_id=${channelId}`, channelResponse?.statusText || 500, {
|
55
56
|
state: { domain: null }
|
56
57
|
});
|
57
58
|
throw new Error(channelResponse);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tokencraft-util.js","sourceRoot":"","sources":["../../server/utils/tokencraft-util.ts"],"names":[],"mappings":";;
|
1
|
+
{"version":3,"file":"tokencraft-util.js","sourceRoot":"","sources":["../../server/utils/tokencraft-util.ts"],"names":[],"mappings":";;AAMA,0BAgCC;AAED,4BAqBC;;AA7DD,oEAA8B;AAE9B,6CAA4C;AAC5C,4CAAuC;AACvC,uEAAmE;AAE5D,KAAK,UAAU,OAAO,CAAC,OAAY,EAAE,SAAiB,EAAE,MAAc;IAC3E,MAAM,mCAAmC,GAAG,YAAM,CAAC,GAAG,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAA;IACjG,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,mCAAmC,CAAA;IACvF,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAE5C,IAAI,MAAM,KAAK,OAAO;QAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,2BAA2B,CAAC,CAAA;IAEvE,IAAI,QAAQ,GAAG,GAAG,aAAa,eAAe,SAAS,YAAY,MAAM,EAAE,CAAA;IAC3E,MAAM,QAAQ,GAAQ,MAAM,IAAA,oBAAK,EAAC,QAAQ,EAAE;QAC1C,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,WAAW,EAAE,MAAM;SACpB;KACF,CAAC,CAAA;IACF,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;QAChB,IAAI,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QACjC,IAAI,WAAW,GAAQ;YACrB,SAAS,EAAE,KAAK,CAAC,IAAI,EA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qB,EAAE,cAAc,SAAS,EAAE,EAAE,eAAe,EAAE,UAAU,IAAI,GAAG,EAAE;YAChH,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;SACxB,CAAC,CAAA;QACF,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;IAClC,CAAC;IACD,IAAI,aAAa,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,CAAA;IAChD,OAAO,aAAa,CAAC,KAAK,CAAA;AAC5B,CAAC","sourcesContent":["import fetch from 'node-fetch'\n\nimport { config } from '@things-factory/env'\nimport { PLATFORM } from '../constants'\nimport { createPayloadLog } from '@things-factory/integration-base'\n\nexport async function getShop(context: any, channelId: string, shopId: string) {\n const sellercraftChannelIntegrationConfig = config.get('sellercraftChannelIntegrationConfig', {})\n const { tokenCraftApiKey: apiKey, tokenCraftUrl } = sellercraftChannelIntegrationConfig\n const xApiKey = context.headers['x-api-key']\n\n if (apiKey !== xApiKey) context.throw(400, 'api key validation failed')\n\n var fullPath = `${tokenCraftUrl}?channel_id=${channelId}&shop_id=${shopId}`\n const response: any = await fetch(fullPath, {\n method: 'get',\n headers: {\n 'Content-Type': 'application/json',\n 'x-api-key': apiKey\n }\n })\n if (response.ok) {\n let store = await response.json()\n let mappedStore: any = {\n accessKey: store.shop?.credential?.consumer_key || '',\n accessSecret: store.shop?.credential?.consumer_secret || '',\n storeURL: store.shop?.credential?.store_url,\n platform: PLATFORM[`${store.shop.org_prefix}`],\n accessToken: store.shop?.credential?.access_token,\n channelShopId: store.shop?.channel_shop_id,\n storeId: store.shop?.credential?.store_url\n }\n return mappedStore\n } else {\n createPayloadLog(shopId, tokenCraftUrl, `channel_id=${channelId}&shop_id=${shopId}`, response?.statusText || 500, {\n state: { domain: null }\n })\n }\n}\n\nexport async function getShops(channelId: string) {\n const sellercraftChannelIntegrationConfig = config.get('sellercraftChannelIntegrationConfig', {})\n const { tokenCraftApiKey: apiKey, getShopsTokenCraftUrl } = sellercraftChannelIntegrationConfig\n\n var channelsFullPath = getShopsTokenCraftUrl + '?channel_id=' + channelId\n const channelResponse: any = await fetch(channelsFullPath, {\n method: 'get',\n headers: {\n 'Content-Type': 'application/json',\n 'x-api-key': apiKey\n }\n })\n\n if (!channelResponse.ok) {\n createPayloadLog(channelId, getShopsTokenCraftUrl, `channel_id=${channelId}`, channelResponse?.statusText || 500, {\n state: { domain: null }\n })\n throw new Error(channelResponse)\n }\n var shopsResponse = await channelResponse.json()\n return shopsResponse.shops\n}\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/integration-sellercraft",
|
3
|
-
"version": "9.0.0
|
3
|
+
"version": "9.0.0",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -24,18 +24,18 @@
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create ./server/migrations/migration"
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
|
-
"@operato/data-grist": "^9.0.0
|
28
|
-
"@things-factory/apptool-ui": "^9.0.0
|
29
|
-
"@things-factory/auth-ui": "^9.0.0
|
30
|
-
"@things-factory/biz-base": "^9.0.0
|
31
|
-
"@things-factory/code-ui": "^9.0.0
|
32
|
-
"@things-factory/context-ui": "^9.0.0
|
33
|
-
"@things-factory/i18n-base": "^9.0.0
|
34
|
-
"@things-factory/integration-marketplace": "^9.0.0
|
35
|
-
"@things-factory/integration-ui": "^9.0.0
|
36
|
-
"@things-factory/more-ui": "^9.0.0
|
37
|
-
"@things-factory/resource-ui": "^9.0.0
|
38
|
-
"@things-factory/setting-ui": "^9.0.0
|
27
|
+
"@operato/data-grist": "^9.0.0",
|
28
|
+
"@things-factory/apptool-ui": "^9.0.0",
|
29
|
+
"@things-factory/auth-ui": "^9.0.0",
|
30
|
+
"@things-factory/biz-base": "^9.0.0",
|
31
|
+
"@things-factory/code-ui": "^9.0.0",
|
32
|
+
"@things-factory/context-ui": "^9.0.0",
|
33
|
+
"@things-factory/i18n-base": "^9.0.0",
|
34
|
+
"@things-factory/integration-marketplace": "^9.0.0",
|
35
|
+
"@things-factory/integration-ui": "^9.0.0",
|
36
|
+
"@things-factory/more-ui": "^9.0.0",
|
37
|
+
"@things-factory/resource-ui": "^9.0.0",
|
38
|
+
"@things-factory/setting-ui": "^9.0.0",
|
39
39
|
"debug": "^4.1.1",
|
40
40
|
"node-fetch": "^2.6.0"
|
41
41
|
},
|
@@ -49,5 +49,5 @@
|
|
49
49
|
"nock": "^13.0.2",
|
50
50
|
"should": "^13.2.3"
|
51
51
|
},
|
52
|
-
"gitHead": "
|
52
|
+
"gitHead": "d6b5293b3ad571461b4282f19bc89288bdab2acc"
|
53
53
|
}
|