@things-factory/integration-sellercraft 4.0.9 → 4.0.13
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/constants/index.js +14 -0
- package/dist-server/constants/index.js.map +1 -0
- package/dist-server/constants/platform.js +7 -0
- package/dist-server/constants/platform.js.map +1 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/echo.js +19 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/echo.js.map +1 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/index.js +19 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/index.js.map +1 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.js +40 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.js.map +1 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-category-attributes.js +48 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-category-attributes.js.map +1 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js +46 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js.map +1 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js +81 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js.map +1 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js +105 -0
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js.map +1 -0
- package/dist-server/controllers/sellercraft-channel-integration/index.js +30 -0
- package/dist-server/controllers/sellercraft-channel-integration/index.js.map +1 -0
- package/dist-server/controllers/sellercraft-channel-integration/platform-action.js +33 -0
- package/dist-server/controllers/sellercraft-channel-integration/platform-action.js.map +1 -0
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js +90 -0
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js.map +1 -0
- package/dist-server/controllers/sellercraft-channel-integration-api/decorators.js +32 -0
- package/dist-server/controllers/sellercraft-channel-integration-api/decorators.js.map +1 -0
- package/dist-server/controllers/sellercraft-channel-integration-api/index.js +78 -0
- package/dist-server/controllers/sellercraft-channel-integration-api/index.js.map +1 -0
- package/dist-server/controllers/sellercraft-channel-integration-api/types.js +1 -0
- package/dist-server/controllers/sellercraft-channel-integration-api/types.js.map +1 -0
- package/dist-server/index.js +1 -0
- package/dist-server/index.js.map +1 -1
- package/dist-server/routers/sellercraft-router.js +174 -0
- package/dist-server/routers/sellercraft-router.js.map +1 -0
- package/dist-server/routes.js +4 -0
- package/dist-server/routes.js.map +1 -1
- package/package.json +15 -14
- package/server/constants/index.ts +1 -0
- package/server/constants/platform.ts +3 -0
- package/server/controllers/sellercraft-channel-integration/apis/echo.ts +14 -0
- package/server/controllers/sellercraft-channel-integration/apis/index.ts +6 -0
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.ts +38 -0
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-category-attributes.ts +65 -0
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.ts +58 -0
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.ts +79 -0
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.ts +110 -0
- package/server/controllers/sellercraft-channel-integration/index.ts +7 -0
- package/server/controllers/sellercraft-channel-integration/platform-action.ts +39 -0
- package/server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.ts +106 -0
- package/server/controllers/sellercraft-channel-integration-api/decorators.ts +45 -0
- package/server/controllers/sellercraft-channel-integration-api/index.ts +45 -0
- package/server/controllers/sellercraft-channel-integration-api/types.ts +0 -0
- package/server/index.ts +1 -0
- package/server/routers/sellercraft-router.ts +202 -0
- package/server/routes.ts +4 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../server/controllers/sellercraft-channel-integration-api/decorators.ts"],"names":[],"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E,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,78 @@
|
|
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.SellercraftChannelIntegrationAPI = void 0;
|
13
|
+
const typeorm_1 = require("typeorm");
|
14
|
+
const service_1 = require("../../service");
|
15
|
+
const decorators_1 = require("./decorators");
|
16
|
+
class SellercraftChannelIntegrationAPI {
|
17
|
+
static registerPlatform(name, action, apis) {
|
18
|
+
SellercraftChannelIntegrationAPI.platforms[name] = {
|
19
|
+
action,
|
20
|
+
apis
|
21
|
+
};
|
22
|
+
}
|
23
|
+
static getPlatform(name) {
|
24
|
+
return SellercraftChannelIntegrationAPI.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 ingestChannelCategories(sellercraft, req) { }
|
35
|
+
static ingestChannelCategoryAttributes(sellercraft, req) { }
|
36
|
+
static ingestChannelOrderPackage(sellercraft, req) { }
|
37
|
+
static ingestChannelOrder(sellercraft, req) { }
|
38
|
+
static ingestChannelProduct(sellercraft, req) { }
|
39
|
+
}
|
40
|
+
SellercraftChannelIntegrationAPI.platforms = {};
|
41
|
+
__decorate([
|
42
|
+
decorators_1.api,
|
43
|
+
__metadata("design:type", Function),
|
44
|
+
__metadata("design:paramtypes", [Object, Object]),
|
45
|
+
__metadata("design:returntype", Object)
|
46
|
+
], SellercraftChannelIntegrationAPI, "echo", null);
|
47
|
+
__decorate([
|
48
|
+
decorators_1.api,
|
49
|
+
__metadata("design:type", Function),
|
50
|
+
__metadata("design:paramtypes", [Object, Object]),
|
51
|
+
__metadata("design:returntype", Object)
|
52
|
+
], SellercraftChannelIntegrationAPI, "ingestChannelCategories", null);
|
53
|
+
__decorate([
|
54
|
+
decorators_1.api,
|
55
|
+
__metadata("design:type", Function),
|
56
|
+
__metadata("design:paramtypes", [Object, Object]),
|
57
|
+
__metadata("design:returntype", Object)
|
58
|
+
], SellercraftChannelIntegrationAPI, "ingestChannelCategoryAttributes", null);
|
59
|
+
__decorate([
|
60
|
+
decorators_1.api,
|
61
|
+
__metadata("design:type", Function),
|
62
|
+
__metadata("design:paramtypes", [Object, Object]),
|
63
|
+
__metadata("design:returntype", Object)
|
64
|
+
], SellercraftChannelIntegrationAPI, "ingestChannelOrderPackage", null);
|
65
|
+
__decorate([
|
66
|
+
decorators_1.api,
|
67
|
+
__metadata("design:type", Function),
|
68
|
+
__metadata("design:paramtypes", [Object, Object]),
|
69
|
+
__metadata("design:returntype", Object)
|
70
|
+
], SellercraftChannelIntegrationAPI, "ingestChannelOrder", null);
|
71
|
+
__decorate([
|
72
|
+
decorators_1.api,
|
73
|
+
__metadata("design:type", Function),
|
74
|
+
__metadata("design:paramtypes", [Object, Object]),
|
75
|
+
__metadata("design:returntype", Object)
|
76
|
+
], SellercraftChannelIntegrationAPI, "ingestChannelProduct", null);
|
77
|
+
exports.SellercraftChannelIntegrationAPI = SellercraftChannelIntegrationAPI;
|
78
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/controllers/sellercraft-channel-integration-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAuC;AAEvC,2CAA2C;AAC3C,6CAAkC;AAElC,MAAa,gCAAgC;IAG3C,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI;QACxC,gCAAgC,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG;YACjD,MAAM;YACN,IAAI;SACL,CAAA;IACH,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAI;QACrB,OAAO,gCAAgC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IACzD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;QAC5B,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,qBAAW,CAAC,CAAA;QAC7C,OAAO,MAAM,UAAU,CAAC,OAAO,CAAC;YAC9B,KAAK,EAAE,EAAE,EAAE,EAAE;YACb,SAAS,EAAE,CAAC,QAAQ,CAAC;SACtB,CAAC,CAAA;IACJ,CAAC;IAGD,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,IAAQ,CAAC;IAGrC,MAAM,CAAC,uBAAuB,CAAC,WAAW,EAAE,GAAG,IAAQ,CAAC;IAGxD,MAAM,CAAC,+BAA+B,CAAC,WAAW,EAAE,GAAG,IAAQ,CAAC;IAGhE,MAAM,CAAC,yBAAyB,CAAC,WAAW,EAAE,GAAG,IAAQ,CAAC;IAG1D,MAAM,CAAC,kBAAkB,CAAC,WAAW,EAAE,GAAG,IAAQ,CAAC;IAGnD,MAAM,CAAC,oBAAoB,CAAC,WAAW,EAAE,GAAG,IAAQ,CAAC;;AArC9C,0CAAS,GAAG,EAAE,CAAA;AAsBrB;IADC,gBAAG;;;;kDACiC;AAGrC;IADC,gBAAG;;;;qEACoD;AAGxD;IADC,gBAAG;;;;6EAC4D;AAGhE;IADC,gBAAG;;;;uEACsD;AAG1D;IADC,gBAAG;;;;gEAC+C;AAGnD;IADC,gBAAG;;;;kEACiD;AAtCvD,4EAuCC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../server/controllers/sellercraft-channel-integration-api/types.ts"],"names":[],"mappings":""}
|
package/dist-server/index.js
CHANGED
@@ -15,4 +15,5 @@ __exportStar(require("./migrations"), exports);
|
|
15
15
|
__exportStar(require("./middlewares"), exports);
|
16
16
|
__exportStar(require("./controllers"), exports);
|
17
17
|
__exportStar(require("./service"), exports);
|
18
|
+
__exportStar(require("./constants"), exports);
|
18
19
|
//# sourceMappingURL=index.js.map
|
package/dist-server/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oBAAiB;AAEjB,+CAA4B;AAC5B,gDAA6B;AAC7B,gDAA6B;AAC7B,4CAAyB"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oBAAiB;AAEjB,+CAA4B;AAC5B,gDAA6B;AAC7B,gDAA6B;AAC7B,4CAAyB;AACzB,8CAA2B"}
|
@@ -0,0 +1,174 @@
|
|
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.sellercraftRouter = void 0;
|
7
|
+
const koa_router_1 = __importDefault(require("koa-router"));
|
8
|
+
const env_1 = require("@things-factory/env");
|
9
|
+
const integration_marketplace_1 = require("@things-factory/integration-marketplace");
|
10
|
+
const constants_1 = require("../constants");
|
11
|
+
const debug = require('debug')('things-factory:integration-sellercraft:sellercraft-router');
|
12
|
+
exports.sellercraftRouter = new koa_router_1.default();
|
13
|
+
exports.sellercraftRouter.post('/sellercraft/store/update-product-price', async (context, next) => {
|
14
|
+
const sellercraftChannelIntegrationConfig = env_1.config.get('sellercraftChannelIntegrationConfig', {});
|
15
|
+
const { apiKey, tokenCraftUrl } = sellercraftChannelIntegrationConfig;
|
16
|
+
const xApiKey = context.headers['x-api-key'];
|
17
|
+
if (apiKey !== xApiKey)
|
18
|
+
context.throw(400, 'api key validation failed');
|
19
|
+
const requestBody = context.request.body;
|
20
|
+
for (var i = 0; i < requestBody.length; i++) {
|
21
|
+
var store = {}; // get from tokencraft
|
22
|
+
var result;
|
23
|
+
// https://staging-tokencraft.sellercraft.co/v1/get-shop?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=dd9cf3b7-114f-4d74-a7e2-7b524ae086f2
|
24
|
+
var fullPath = tokenCraftUrl + '?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=' + requestBody[i].shop_id;
|
25
|
+
const response = await fetch(fullPath, {
|
26
|
+
method: 'get',
|
27
|
+
headers: {
|
28
|
+
'Content-Type': 'application/json',
|
29
|
+
'x-api-key': apiKey
|
30
|
+
}
|
31
|
+
});
|
32
|
+
if (response.ok) {
|
33
|
+
store = await response.json();
|
34
|
+
}
|
35
|
+
let mappedStore = {
|
36
|
+
accessKey: store.shop.credential.consumer_key,
|
37
|
+
accessSecret: store.shop.credential.consumer_secret,
|
38
|
+
storeURL: store.shop.credential.store_url,
|
39
|
+
platform: constants_1.PLATFORM[`${store.shop.org_prefix}`]
|
40
|
+
};
|
41
|
+
if (requestBody[i].native_variant_id) {
|
42
|
+
const req = {
|
43
|
+
costPrice: requestBody[i].full_price,
|
44
|
+
sellPrice: requestBody[i].sale_price,
|
45
|
+
productId: requestBody[i].native_product_id,
|
46
|
+
variationId: requestBody[i].native_variant_id
|
47
|
+
};
|
48
|
+
result = await integration_marketplace_1.StoreAPI.updateStoreProductVariationPrice(mappedStore, req);
|
49
|
+
}
|
50
|
+
else {
|
51
|
+
const req = {
|
52
|
+
costPrice: requestBody[i].full_price,
|
53
|
+
sellPrice: requestBody[i].sale_price,
|
54
|
+
productId: requestBody[i].native_product_id
|
55
|
+
};
|
56
|
+
result = await integration_marketplace_1.StoreAPI.updateStoreProductPrice(mappedStore, req);
|
57
|
+
}
|
58
|
+
debug(result);
|
59
|
+
}
|
60
|
+
context.status = 200;
|
61
|
+
});
|
62
|
+
exports.sellercraftRouter.post('/sellercraft/store/update-product-stock', async (context, next) => {
|
63
|
+
const sellercraftChannelIntegrationConfig = env_1.config.get('sellercraftChannelIntegrationConfig', {});
|
64
|
+
const { apiKey, tokenCraftUrl } = sellercraftChannelIntegrationConfig;
|
65
|
+
const xApiKey = context.headers['x-api-key'];
|
66
|
+
if (apiKey !== xApiKey)
|
67
|
+
context.throw(400, 'api key validation failed');
|
68
|
+
const requestBody = context.request.body;
|
69
|
+
for (var i = 0; i < requestBody.length; i++) {
|
70
|
+
var store = {}; // get from tokencraft
|
71
|
+
var result;
|
72
|
+
// https://staging-tokencraft.sellercraft.co/v1/get-shop?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=dd9cf3b7-114f-4d74-a7e2-7b524ae086f2
|
73
|
+
var fullPath = tokenCraftUrl + '?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=' + requestBody[i].shop_id;
|
74
|
+
const response = await fetch(fullPath, {
|
75
|
+
method: 'get',
|
76
|
+
headers: {
|
77
|
+
'Content-Type': 'application/json',
|
78
|
+
'x-api-key': apiKey
|
79
|
+
}
|
80
|
+
});
|
81
|
+
if (response.ok) {
|
82
|
+
store = await response.json();
|
83
|
+
}
|
84
|
+
let mappedStore = {
|
85
|
+
accessKey: store.shop.credential.consumer_key,
|
86
|
+
accessSecret: store.shop.credential.consumer_secret,
|
87
|
+
storeURL: store.shop.credential.store_url,
|
88
|
+
platform: constants_1.PLATFORM[`${store.shop.org_prefix}`]
|
89
|
+
};
|
90
|
+
if (requestBody[i].native_variant_id) {
|
91
|
+
const req = {
|
92
|
+
qty: requestBody[i].stock,
|
93
|
+
itemId: requestBody[i].native_product_id,
|
94
|
+
variationId: requestBody[i].native_variant_id
|
95
|
+
};
|
96
|
+
result = await integration_marketplace_1.StoreAPI.updateStoreProductVariationStock(mappedStore, req);
|
97
|
+
}
|
98
|
+
else {
|
99
|
+
const req = {
|
100
|
+
qty: requestBody[i].stock,
|
101
|
+
itemId: requestBody[i].native_product_id
|
102
|
+
};
|
103
|
+
result = await integration_marketplace_1.StoreAPI.updateStoreProductStock(mappedStore, req);
|
104
|
+
}
|
105
|
+
debug(result);
|
106
|
+
}
|
107
|
+
context.status = 200;
|
108
|
+
});
|
109
|
+
exports.sellercraftRouter.post('/sellercraft/store/update-order-status', async (context, next) => {
|
110
|
+
const sellercraftChannelIntegrationConfig = env_1.config.get('sellercraftChannelIntegrationConfig', {});
|
111
|
+
const { apiKey, tokenCraftUrl } = sellercraftChannelIntegrationConfig;
|
112
|
+
const xApiKey = context.headers['x-api-key'];
|
113
|
+
if (apiKey !== xApiKey)
|
114
|
+
context.throw(400, 'api key validation failed');
|
115
|
+
const requestBody = context.request.body;
|
116
|
+
var result;
|
117
|
+
var store = {};
|
118
|
+
// https://staging-tokencraft.sellercraft.co/v1/get-shop?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=dd9cf3b7-114f-4d74-a7e2-7b524ae086f2
|
119
|
+
var fullPath = tokenCraftUrl + '?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=' + requestBody.shop_id;
|
120
|
+
const response = await fetch(fullPath, {
|
121
|
+
method: 'get',
|
122
|
+
headers: {
|
123
|
+
'Content-Type': 'application/json',
|
124
|
+
'x-api-key': apiKey
|
125
|
+
}
|
126
|
+
});
|
127
|
+
if (response.ok) {
|
128
|
+
store = await response.json();
|
129
|
+
}
|
130
|
+
let mappedStore = {
|
131
|
+
accessKey: store.shop.credential.consumer_key,
|
132
|
+
accessSecret: store.shop.credential.consumer_secret,
|
133
|
+
storeURL: store.shop.credential.store_url,
|
134
|
+
platform: constants_1.PLATFORM[`${store.shop.org_prefix}`]
|
135
|
+
};
|
136
|
+
const reqBody = { orderId: requestBody.native_order_id, status: requestBody.order_status };
|
137
|
+
result = await integration_marketplace_1.StoreAPI.updateOrder(mappedStore, reqBody);
|
138
|
+
debug(result);
|
139
|
+
context.status = 200;
|
140
|
+
});
|
141
|
+
exports.sellercraftRouter.post('/sellercraft/store/update-product-attribute', async (context, next) => {
|
142
|
+
const sellercraftChannelIntegrationConfig = env_1.config.get('sellercraftChannelIntegrationConfig', {});
|
143
|
+
const { apiKey, tokenCraftUrl } = sellercraftChannelIntegrationConfig;
|
144
|
+
const xApiKey = context.headers['x-api-key'];
|
145
|
+
if (apiKey !== xApiKey)
|
146
|
+
context.throw(400, 'api key validation failed');
|
147
|
+
const requestBody = context.request.body;
|
148
|
+
var store = {};
|
149
|
+
const attributes = requestBody.attributes;
|
150
|
+
// https://staging-tokencraft.sellercraft.co/v1/get-shop?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=dd9cf3b7-114f-4d74-a7e2-7b524ae086f2
|
151
|
+
var fullPath = tokenCraftUrl + '?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=' + requestBody.shop_id;
|
152
|
+
const response = await fetch(fullPath, {
|
153
|
+
method: 'get',
|
154
|
+
headers: {
|
155
|
+
'Content-Type': 'application/json',
|
156
|
+
'x-api-key': apiKey
|
157
|
+
}
|
158
|
+
});
|
159
|
+
if (response.ok) {
|
160
|
+
store = await response.json();
|
161
|
+
}
|
162
|
+
let mappedStore = {
|
163
|
+
accessKey: store.shop.credential.consumer_key,
|
164
|
+
accessSecret: store.shop.credential.consumer_secret,
|
165
|
+
storeURL: store.shop.credential.store_url,
|
166
|
+
platform: constants_1.PLATFORM[`${store.shop.org_prefix}`]
|
167
|
+
};
|
168
|
+
await Promise.all(attributes.map(async (attribute) => {
|
169
|
+
const attributeReqBody = { attributeId: attribute.native_attribute_id, name: attribute.attribute_key };
|
170
|
+
await integration_marketplace_1.StoreAPI.updateProductAttribute(mappedStore, attributeReqBody);
|
171
|
+
}));
|
172
|
+
context.status = 200;
|
173
|
+
});
|
174
|
+
//# sourceMappingURL=sellercraft-router.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sellercraft-router.js","sourceRoot":"","sources":["../../server/routers/sellercraft-router.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAE/B,6CAA4C;AAC5C,qFAAkE;AAClE,4CAAuC;AAEvC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,2DAA2D,CAAC,CAAA;AAE9E,QAAA,iBAAiB,GAAG,IAAI,oBAAM,EAAE,CAAA;AAE7C,yBAAiB,CAAC,IAAI,CAAC,yCAAyC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACxF,MAAM,mCAAmC,GAAG,YAAM,CAAC,GAAG,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAA;IACjG,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,mCAAmC,CAAA;IAErE,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,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;IAExC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GA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QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS;QACzC,QAAQ,EAAE,oBAAQ,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;KAC/C,CAAA;IAED,MAAM,OAAO,CAAC,GAAG,CACf,UAAU,CAAC,GAAG,CAAC,KAAK,EAAC,SAAS,EAAC,EAAE;QAC/B,MAAM,gBAAgB,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,mBAAmB,EAAE,IAAI,EAAE,SAAS,CAAC,aAAa,EAAE,CAAA;QAEtG,MAAM,kCAAQ,CAAC,sBAAsB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAA;IACtE,CAAC,CAAC,CACH,CAAA;IAED,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA;AACtB,CAAC,CAAC,CAAA"}
|
package/dist-server/routes.js
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const sellercraft_router_1 = require("./routers/sellercraft-router");
|
1
4
|
const debug = require('debug')('things-factory:integration-sellercraft:routes');
|
2
5
|
process.on('bootstrap-module-global-public-route', (app, globalPublicRouter) => {
|
3
6
|
/*
|
@@ -6,6 +9,7 @@ process.on('bootstrap-module-global-public-route', (app, globalPublicRouter) =>
|
|
6
9
|
* ex) routes.get('/path', async(context, next) => {})
|
7
10
|
* ex) routes.post('/path', async(context, next) => {})
|
8
11
|
*/
|
12
|
+
globalPublicRouter.use(sellercraft_router_1.sellercraftRouter.routes(), sellercraft_router_1.sellercraftRouter.allowedMethods());
|
9
13
|
});
|
10
14
|
process.on('bootstrap-module-global-private-route', (app, globalPrivateRouter) => {
|
11
15
|
/*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,+CAA+C,CAAC,CAAA;AAE/E,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF;;;;;OAKG;
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,qEAAgE;AAEhE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,+CAA+C,CAAC,CAAA;AAE/E,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF;;;;;OAKG;IAEH,kBAAkB,CAAC,GAAG,CAAC,sCAAiB,CAAC,MAAM,EAAE,EAAE,sCAAiB,CAAC,cAAc,EAAE,CAAC,CAAA;AACxF,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF;;OAEG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF;;OAEG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF;;OAEG;AACL,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/integration-sellercraft",
|
3
|
-
"version": "4.0.
|
3
|
+
"version": "4.0.13",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -24,18 +24,19 @@
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
|
-
"@things-factory/apptool-ui": "^4.0.
|
28
|
-
"@things-factory/auth-ui": "^4.0.
|
29
|
-
"@things-factory/biz-base": "^4.0.
|
30
|
-
"@things-factory/code-ui": "^4.0.
|
31
|
-
"@things-factory/context-ui": "^4.0.
|
32
|
-
"@things-factory/grist-ui": "^4.0.
|
33
|
-
"@things-factory/i18n-ui": "^4.0.
|
34
|
-
"@things-factory/integration-
|
35
|
-
"@things-factory/
|
36
|
-
"@things-factory/
|
37
|
-
"@things-factory/
|
38
|
-
"@things-factory/
|
27
|
+
"@things-factory/apptool-ui": "^4.0.13",
|
28
|
+
"@things-factory/auth-ui": "^4.0.13",
|
29
|
+
"@things-factory/biz-base": "^4.0.13",
|
30
|
+
"@things-factory/code-ui": "^4.0.13",
|
31
|
+
"@things-factory/context-ui": "^4.0.13",
|
32
|
+
"@things-factory/grist-ui": "^4.0.13",
|
33
|
+
"@things-factory/i18n-ui": "^4.0.13",
|
34
|
+
"@things-factory/integration-marketplace": "^4.0.13",
|
35
|
+
"@things-factory/integration-ui": "^4.0.13",
|
36
|
+
"@things-factory/more-ui": "^4.0.13",
|
37
|
+
"@things-factory/resource-ui": "^4.0.13",
|
38
|
+
"@things-factory/setting-ui": "^4.0.13",
|
39
|
+
"@things-factory/system-ui": "^4.0.13",
|
39
40
|
"debug": "^4.1.1",
|
40
41
|
"node-fetch": "^2.6.0",
|
41
42
|
"querystring": "^0.2.1"
|
@@ -51,5 +52,5 @@
|
|
51
52
|
"nock": "^13.0.2",
|
52
53
|
"should": "^13.2.3"
|
53
54
|
},
|
54
|
-
"gitHead": "
|
55
|
+
"gitHead": "a542fdd4e7c447c3b571fe91c92f5919561bdc2c"
|
55
56
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './platform'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/* https://docs.sellercraft.co/docs/api-integrations/b3A6MTY4NjQxODU-initiate-order-shipment */
|
2
|
+
|
3
|
+
export function ingestChannelCategories() {
|
4
|
+
return {
|
5
|
+
method: 'post',
|
6
|
+
path: '/channel/ingest/category',
|
7
|
+
denormalize(req) {
|
8
|
+
const { categories } = req
|
9
|
+
|
10
|
+
let newCategories = categories.map(category => {
|
11
|
+
return {
|
12
|
+
channel_id: category.channelId,
|
13
|
+
native_category_id: category.categoryId,
|
14
|
+
category_name: category.categoryName,
|
15
|
+
is_leaf: category.isLeaf,
|
16
|
+
is_active: category.isActive,
|
17
|
+
children_categories: category.childrenCategories.map(childrenCategory => {
|
18
|
+
return {
|
19
|
+
channel_id: childrenCategory.channelId,
|
20
|
+
native_category_id: childrenCategory.categoryId,
|
21
|
+
category_name: childrenCategory.categoryName,
|
22
|
+
is_leaf: childrenCategory.isLeaf,
|
23
|
+
is_active: childrenCategory.isActive,
|
24
|
+
children_categories: {}
|
25
|
+
}
|
26
|
+
})
|
27
|
+
}
|
28
|
+
})
|
29
|
+
|
30
|
+
return {
|
31
|
+
payload: { newCategories }
|
32
|
+
}
|
33
|
+
},
|
34
|
+
normalize(res) {
|
35
|
+
return res
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
/* https://docs.sellercraft.co/docs/api-integrations/b3A6MjQzODUxMTE-ingest-channel-category-attributes */
|
2
|
+
|
3
|
+
export function ingestChannelCategoryAttributes() {
|
4
|
+
return {
|
5
|
+
method: 'post',
|
6
|
+
path: '/channel/ingest/category/attribute',
|
7
|
+
denormalize(req) {
|
8
|
+
let { channelAttributeKeys, scAttributeKeys } = req
|
9
|
+
|
10
|
+
let channel_attribute_keys = channelAttributeKeys.map(e => {
|
11
|
+
const {
|
12
|
+
channelCode: channel_code,
|
13
|
+
channelCountry: channel_country,
|
14
|
+
nativeCategoryId: native_category_id,
|
15
|
+
attributeKey: attribute_key,
|
16
|
+
valueType: value_type,
|
17
|
+
valueOptions: value_options,
|
18
|
+
displayName: display_name,
|
19
|
+
isCore: is_core,
|
20
|
+
isSearchProp: is_search_prop,
|
21
|
+
isOptional: is_optional
|
22
|
+
} = e
|
23
|
+
|
24
|
+
return {
|
25
|
+
channel_code,
|
26
|
+
channel_country,
|
27
|
+
native_category_id,
|
28
|
+
attribute_key,
|
29
|
+
value_type,
|
30
|
+
value_options,
|
31
|
+
display_name,
|
32
|
+
is_core,
|
33
|
+
is_search_prop,
|
34
|
+
is_optional
|
35
|
+
}
|
36
|
+
})
|
37
|
+
|
38
|
+
let sc_attribute_keys = scAttributeKeys.map(e => {
|
39
|
+
const {
|
40
|
+
channelCode: channel_code,
|
41
|
+
channelCountry: channel_country,
|
42
|
+
attributeKey: attribute_key,
|
43
|
+
displayName: display_name
|
44
|
+
} = e
|
45
|
+
|
46
|
+
return {
|
47
|
+
channel_code,
|
48
|
+
channel_country,
|
49
|
+
attribute_key,
|
50
|
+
display_name
|
51
|
+
}
|
52
|
+
})
|
53
|
+
|
54
|
+
return {
|
55
|
+
payload: {
|
56
|
+
channel_attribute_keys,
|
57
|
+
sc_attribute_keys
|
58
|
+
}
|
59
|
+
}
|
60
|
+
},
|
61
|
+
normalize(res) {
|
62
|
+
return res
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.ts
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
/* https://docs.sellercraft.co/docs/api-integrations/b3A6MjQzODUxMTQ-ingest-channel-order-package */
|
2
|
+
|
3
|
+
export function ingestChannelOrderPackage() {
|
4
|
+
return {
|
5
|
+
method: 'post',
|
6
|
+
path: '/channel/ingest/order/package',
|
7
|
+
denormalize(req) {
|
8
|
+
let {
|
9
|
+
channelShopId: channel_shop_id,
|
10
|
+
nativeOrderId: native_order_id,
|
11
|
+
nativePackageId: native_package_id,
|
12
|
+
shippingTrackingCode: shipping_tracking_code,
|
13
|
+
shippingTypeValue: shipping_type_value,
|
14
|
+
warehouseCode: warehouse_code,
|
15
|
+
shipper,
|
16
|
+
documents,
|
17
|
+
shipperLastMile: shipper_last_mile,
|
18
|
+
orderItemIds: order_item_ids
|
19
|
+
} = req
|
20
|
+
|
21
|
+
documents = documents.map(e => {
|
22
|
+
const { fileTypeValue: file_type_value, mimeType: mime_type, file } = e
|
23
|
+
|
24
|
+
return {
|
25
|
+
file_type_value,
|
26
|
+
mime_type,
|
27
|
+
file
|
28
|
+
}
|
29
|
+
})
|
30
|
+
|
31
|
+
shipper = {
|
32
|
+
is_cod_supported: shipper.isCodSupported,
|
33
|
+
name: shipper.name
|
34
|
+
}
|
35
|
+
|
36
|
+
shipper_last_mile = {
|
37
|
+
is_cod_supported: shipper_last_mile.isCodSupported,
|
38
|
+
name: shipper_last_mile.name
|
39
|
+
}
|
40
|
+
|
41
|
+
return {
|
42
|
+
channel_shop_id,
|
43
|
+
native_order_id,
|
44
|
+
native_package_id,
|
45
|
+
shipping_tracking_code,
|
46
|
+
shipping_type_value,
|
47
|
+
warehouse_code,
|
48
|
+
shipper,
|
49
|
+
documents,
|
50
|
+
shipper_last_mile,
|
51
|
+
order_item_ids
|
52
|
+
}
|
53
|
+
},
|
54
|
+
normalize(res) {
|
55
|
+
return res
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
/* https://docs.sellercraft.co/docs/api-integrations/b3A6MTY4NjQxODU-initiate-order-shipment */
|
2
|
+
|
3
|
+
export function ingestChannelOrder() {
|
4
|
+
return {
|
5
|
+
method: 'post',
|
6
|
+
path: '/channel/ingest/order',
|
7
|
+
denormalize(req) {
|
8
|
+
const { orders } = req
|
9
|
+
|
10
|
+
let newOrders = orders.map(order => {
|
11
|
+
return {
|
12
|
+
organisation_id: order.organisationId,
|
13
|
+
channel_shop_id: order.channelShopId,
|
14
|
+
native_order_id: order.id,
|
15
|
+
ordered_at_date: order.createdAt,
|
16
|
+
ordered_at_time: order.createdAt,
|
17
|
+
updated_at_date: order.updatedAt,
|
18
|
+
updated_at_time: order.updatedAt,
|
19
|
+
customer_first_name: order.custFirstName,
|
20
|
+
customer_last_name: order.custLastName,
|
21
|
+
address_shipping: {
|
22
|
+
first_name: order.shipFirstName,
|
23
|
+
last_name: order.shipLastName,
|
24
|
+
line_1: order.shipAddress1,
|
25
|
+
line_2: order.shipAddress2,
|
26
|
+
line_3: order.shipAddress3,
|
27
|
+
line_4: order.shipAddress4,
|
28
|
+
line_5: order.shipAddress5,
|
29
|
+
city: order.shipCity,
|
30
|
+
postal_code: order.shipPostalCode,
|
31
|
+
country: order.shipCountry,
|
32
|
+
phone_1: order.shipPhone1,
|
33
|
+
phone_2: order.shipPhone2
|
34
|
+
},
|
35
|
+
address_billing: {
|
36
|
+
first_name: order.billFirstName,
|
37
|
+
last_name: order.billLastName,
|
38
|
+
line_1: order.billAddress1,
|
39
|
+
line_2: order.billAddress2,
|
40
|
+
line_3: order.billAddress3,
|
41
|
+
line_4: order.billAddress4,
|
42
|
+
line_5: order.billAddress5,
|
43
|
+
city: order.billCity,
|
44
|
+
postal_code: order.billPostalCode,
|
45
|
+
country: order.billCountry,
|
46
|
+
phone_1: order.billPhone1,
|
47
|
+
phone_2: order.billPhone2
|
48
|
+
},
|
49
|
+
order_items: order.orderItems.map(orderItem => {
|
50
|
+
return {
|
51
|
+
native_item_id: orderItem.id,
|
52
|
+
native_variant_id: orderItem.variationId,
|
53
|
+
currency_code: orderItem.currency,
|
54
|
+
ordered_at_date: order.createdAt,
|
55
|
+
ordered_at_time: order.createdAt,
|
56
|
+
updated_at_date: order.updatedAt,
|
57
|
+
updated_at_time: order.updatedAt,
|
58
|
+
sla_expires_at: order?.slaExpiresAt,
|
59
|
+
charges: orderItem.charges.map(charge => {
|
60
|
+
return {
|
61
|
+
charge_type_value: charge.name,
|
62
|
+
amount_gross: charge.grossAmount,
|
63
|
+
amount_nett: charge.nettAmount
|
64
|
+
}
|
65
|
+
})
|
66
|
+
}
|
67
|
+
})
|
68
|
+
}
|
69
|
+
})
|
70
|
+
|
71
|
+
return {
|
72
|
+
payload: { newOrders }
|
73
|
+
}
|
74
|
+
},
|
75
|
+
normalize(res) {
|
76
|
+
return res
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|