@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.
- package/client/bootstrap.js +1 -28
- package/client/pages/sellercraft-store.js +22 -3
- package/client/utils/index.js +12 -0
- package/dist-server/controllers/index.js +1 -1
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/sellercraft/apis/add-inbound-order.js +32 -1
- package/dist-server/controllers/sellercraft/apis/add-inbound-order.js.map +1 -1
- package/dist-server/controllers/sellercraft/apis/fetch-order-document.js +6 -2
- package/dist-server/controllers/sellercraft/apis/fetch-order-document.js.map +1 -1
- package/dist-server/controllers/sellercraft/apis/initiate-order-document.js +4 -1
- package/dist-server/controllers/sellercraft/apis/initiate-order-document.js.map +1 -1
- package/dist-server/controllers/sellercraft/apis/initiate-order-shipment.js +11 -2
- package/dist-server/controllers/sellercraft/apis/initiate-order-shipment.js.map +1 -1
- package/dist-server/controllers/sellercraft/apis/pack-marketplace-order.js +20 -2
- package/dist-server/controllers/sellercraft/apis/pack-marketplace-order.js.map +1 -1
- package/dist-server/controllers/sellercraft/apis/update-product.js +23 -1
- package/dist-server/controllers/sellercraft/apis/update-product.js.map +1 -1
- package/dist-server/controllers/sellercraft/index.js +7 -7
- package/dist-server/controllers/sellercraft/index.js.map +1 -1
- package/dist-server/controllers/sellercraft/platform-action.js +3 -3
- package/dist-server/controllers/sellercraft/platform-action.js.map +1 -1
- package/dist-server/controllers/sellercraft/sellercraft.js +42 -25
- package/dist-server/controllers/sellercraft/sellercraft.js.map +1 -1
- package/dist-server/controllers/sellercraft-api/decorators.js +32 -0
- package/dist-server/controllers/sellercraft-api/decorators.js.map +1 -0
- package/dist-server/controllers/sellercraft-api/index.js +92 -0
- package/dist-server/controllers/sellercraft-api/index.js.map +1 -0
- package/dist-server/controllers/sellercraft-api/types.js +1 -0
- package/dist-server/controllers/sellercraft-api/types.js.map +1 -0
- package/dist-server/index.js +2 -1
- package/dist-server/index.js.map +1 -1
- package/dist-server/service/sellercraft/sellercraft-mutation.js +5 -7
- package/dist-server/service/sellercraft/sellercraft-mutation.js.map +1 -1
- package/dist-server/service/sellercraft/sellercraft-query.js +2 -5
- package/dist-server/service/sellercraft/sellercraft-query.js.map +1 -1
- package/dist-server/service/sellercraft/sellercraft-type.js +4 -4
- package/dist-server/service/sellercraft/sellercraft-type.js.map +1 -1
- package/dist-server/service/sellercraft/sellercraft.js +11 -3
- package/dist-server/service/sellercraft/sellercraft.js.map +1 -1
- package/package.json +14 -14
- package/server/controllers/index.ts +1 -1
- package/server/controllers/sellercraft/apis/add-inbound-order.ts +40 -1
- package/server/controllers/sellercraft/apis/fetch-order-document.ts +6 -2
- package/server/controllers/sellercraft/apis/initiate-order-document.ts +4 -1
- package/server/controllers/sellercraft/apis/initiate-order-shipment.ts +17 -2
- package/server/controllers/sellercraft/apis/pack-marketplace-order.ts +23 -2
- package/server/controllers/sellercraft/apis/update-product.ts +26 -1
- package/server/controllers/sellercraft/index.ts +4 -4
- package/server/controllers/sellercraft/platform-action.ts +4 -3
- package/server/controllers/sellercraft/sellercraft.ts +41 -28
- package/server/controllers/{store-api → sellercraft-api}/decorators.ts +0 -0
- package/server/controllers/{store-api → sellercraft-api}/index.ts +1 -0
- package/server/controllers/{store-api → sellercraft-api}/types.ts +0 -0
- package/server/index.ts +3 -2
- package/server/service/sellercraft/sellercraft-mutation.ts +7 -7
- package/server/service/sellercraft/sellercraft-query.ts +5 -7
- package/server/service/sellercraft/sellercraft-type.ts +10 -9
- package/server/service/sellercraft/sellercraft.ts +13 -3
- package/things-factory.config.js +1 -1
- package/translations/en.json +4 -0
- package/translations/ko.json +4 -0
- package/translations/ms.json +4 -0
- package/translations/zh.json +4 -1
- package/client/themes/app-theme.css +0 -117
- package/client/themes/layout-theme.css +0 -92
@@ -0,0 +1 @@
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../server/controllers/sellercraft-api/types.ts"],"names":[],"mappings":""}
|
package/dist-server/index.js
CHANGED
@@ -10,8 +10,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
11
11
|
};
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
require("./routes");
|
13
14
|
__exportStar(require("./migrations"), exports);
|
14
15
|
__exportStar(require("./middlewares"), exports);
|
16
|
+
__exportStar(require("./controllers"), exports);
|
15
17
|
__exportStar(require("./service"), exports);
|
16
|
-
require("./routes");
|
17
18
|
//# 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,+CAA4B;AAC5B,gDAA6B;AAC7B,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oBAAiB;AAEjB,+CAA4B;AAC5B,gDAA6B;AAC7B,gDAA6B;AAC7B,4CAAyB"}
|
@@ -18,20 +18,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.SellercraftMutation = void 0;
|
19
19
|
const type_graphql_1 = require("type-graphql");
|
20
20
|
const typeorm_1 = require("typeorm");
|
21
|
+
const v4_1 = __importDefault(require("uuid/v4"));
|
21
22
|
const sellercraft_1 = require("./sellercraft");
|
22
23
|
const sellercraft_type_1 = require("./sellercraft-type");
|
23
|
-
const v4_1 = __importDefault(require("uuid/v4"));
|
24
24
|
let SellercraftMutation = class SellercraftMutation {
|
25
25
|
async createSellercraft(sellercraft, context) {
|
26
26
|
const { domain, user, tx } = context.state;
|
27
|
-
return await tx.getRepository(sellercraft_1.Sellercraft).save(Object.assign(Object.assign({}, sellercraft), { domain, creator: user, updater: user }));
|
27
|
+
return await tx.getRepository(sellercraft_1.Sellercraft).save(Object.assign(Object.assign({}, sellercraft), { name: (0, v4_1.default)(), domain, creator: user, updater: user }));
|
28
28
|
}
|
29
29
|
async updateSellercraft(id, patch, context) {
|
30
|
-
const {
|
30
|
+
const { user, tx } = context.state;
|
31
31
|
const repository = tx.getRepository(sellercraft_1.Sellercraft);
|
32
|
-
const sellercraft = await repository.findOne(
|
33
|
-
where: { domain, id }
|
34
|
-
});
|
32
|
+
const sellercraft = await repository.findOne(id);
|
35
33
|
return await repository.save(Object.assign(Object.assign(Object.assign({}, sellercraft), patch), { updater: user }));
|
36
34
|
}
|
37
35
|
async updateMultipleSellercraft(patches, context) {
|
@@ -43,7 +41,7 @@ let SellercraftMutation = class SellercraftMutation {
|
|
43
41
|
if (_createRecords.length > 0) {
|
44
42
|
for (let i = 0; i < _createRecords.length; i++) {
|
45
43
|
const newRecord = _createRecords[i];
|
46
|
-
const result = await sellercraftRepo.save(Object.assign(Object.assign({}, newRecord), { domain, name: (0, v4_1.default)(), status: sellercraft_1.SellercraftStatus.ACTIVE, platform:
|
44
|
+
const result = await sellercraftRepo.save(Object.assign(Object.assign({}, newRecord), { domain, name: (0, v4_1.default)(), status: sellercraft_1.SellercraftStatus.ACTIVE, platform: sellercraft_1.SellercraftPlatform.SELLERCRAFT, creator: user, updater: user }));
|
47
45
|
results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
|
48
46
|
}
|
49
47
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sellercraft-mutation.js","sourceRoot":"","sources":["../../../server/service/sellercraft/sellercraft-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,+
|
1
|
+
{"version":3,"file":"sellercraft-mutation.js","sourceRoot":"","sources":["../../../server/service/sellercraft/sellercraft-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA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AE,CAAC;IAEpF,WAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IACT,WAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,WAAA,IAAA,kBAAG,GAAE,CAAA;;6CADe,mCAAgB;;4DAatC;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,yBAAW,CAAC,EAAE,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;IAEjG,WAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,mCAAgB,CAAC,CAAC,CAAA;IAC1C,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;oEA2CP;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;IAC9C,WAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;4DAKpD;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,iCAAiC,EAAE,CAAC;IACvD,WAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAiB,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;6DAc3E;AA5GU,mBAAmB;IAD/B,IAAA,uBAAQ,EAAC,yBAAW,CAAC;GACT,mBAAmB,CA6G/B;AA7GY,kDAAmB"}
|
@@ -16,16 +16,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.SellercraftQuery = void 0;
|
17
17
|
const type_graphql_1 = require("type-graphql");
|
18
18
|
const typeorm_1 = require("typeorm");
|
19
|
-
const shell_1 = require("@things-factory/shell");
|
20
19
|
const auth_base_1 = require("@things-factory/auth-base");
|
20
|
+
const shell_1 = require("@things-factory/shell");
|
21
21
|
const sellercraft_1 = require("./sellercraft");
|
22
22
|
const sellercraft_type_1 = require("./sellercraft-type");
|
23
23
|
let SellercraftQuery = class SellercraftQuery {
|
24
24
|
async sellercraft(id, context) {
|
25
|
-
|
26
|
-
return await (0, typeorm_1.getRepository)(sellercraft_1.Sellercraft).findOne({
|
27
|
-
where: { domain, id }
|
28
|
-
});
|
25
|
+
return await (0, typeorm_1.getRepository)(sellercraft_1.Sellercraft).findOne(id);
|
29
26
|
}
|
30
27
|
async sellercrafts(params, context) {
|
31
28
|
const { domain } = context.state;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sellercraft-query.js","sourceRoot":"","sources":["../../../server/service/sellercraft/sellercraft-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"sellercraft-query.js","sourceRoot":"","sources":["../../../server/service/sellercraft/sellercraft-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAAmF;AACnF,qCAAuC;AAEvC,yDAAgD;AAChD,iDAA4E;AAE5E,+CAA2C;AAC3C,yDAAoD;AAGpD,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IAE3B,KAAK,CAAC,WAAW,CAAY,EAAU,EAAS,OAAY;QAC1D,OAAO,MAAM,IAAA,uBAAa,EAAC,yBAAW,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IACrD,CAAC;IAGD,KAAK,CAAC,YAAY,CAAS,MAAiB,EAAS,OAAY;QAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,eAAe,GAAG,IAAA,yBAAiB,EAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAA;QAC5D,MAAM,CAAC,KAAK,EAA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CAAC;IACb,WAAA,IAAA,mBAAI,GAAE,CAAA;;qCAAc,yBAAW;;+CAE7C;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,WAAA,IAAA,mBAAI,GAAE,CAAA;;qCAAc,yBAAW;;+CAE7C;AA7BU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,yBAAW,CAAC;GACT,gBAAgB,CA8B5B;AA9BY,4CAAgB"}
|
@@ -23,7 +23,7 @@ __decorate([
|
|
23
23
|
__metadata("design:type", String)
|
24
24
|
], NewSellercraft.prototype, "description", void 0);
|
25
25
|
__decorate([
|
26
|
-
(0, type_graphql_1.Field)(),
|
26
|
+
(0, type_graphql_1.Field)(type => sellercraft_1.SellercraftPlatform, { nullable: true }),
|
27
27
|
__metadata("design:type", String)
|
28
28
|
], NewSellercraft.prototype, "platform", void 0);
|
29
29
|
__decorate([
|
@@ -49,11 +49,11 @@ __decorate([
|
|
49
49
|
__metadata("design:type", String)
|
50
50
|
], SellercraftPatch.prototype, "name", void 0);
|
51
51
|
__decorate([
|
52
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
52
|
+
(0, type_graphql_1.Field)(type => sellercraft_1.SellercraftPlatform, { nullable: true }),
|
53
53
|
__metadata("design:type", String)
|
54
54
|
], SellercraftPatch.prototype, "platform", void 0);
|
55
55
|
__decorate([
|
56
|
-
(0, type_graphql_1.Field)(),
|
56
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
57
57
|
__metadata("design:type", String)
|
58
58
|
], SellercraftPatch.prototype, "accountId", void 0);
|
59
59
|
__decorate([
|
@@ -65,7 +65,7 @@ __decorate([
|
|
65
65
|
__metadata("design:type", String)
|
66
66
|
], SellercraftPatch.prototype, "status", void 0);
|
67
67
|
__decorate([
|
68
|
-
(0, type_graphql_1.Field)(),
|
68
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
69
69
|
__metadata("design:type", String)
|
70
70
|
], SellercraftPatch.prototype, "cuFlag", void 0);
|
71
71
|
SellercraftPatch = __decorate([
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sellercraft-type.js","sourceRoot":"","sources":["../../../server/service/sellercraft/sellercraft-type.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAoE;
|
1
|
+
{"version":3,"file":"sellercraft-type.js","sourceRoot":"","sources":["../../../server/service/sellercraft/sellercraft-type.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAoE;AAEpE,+CAAmF;AAGnF,IAAa,cAAc,GAA3B,MAAa,cAAc;CAe1B,CAAA;AAbC;IADC,IAAA,oBAAK,GAAE;;4CACI;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACN;AAGpB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iCAAmB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDAC1B;AAG7B;IADC,IAAA,oBAAK,GAAE;;iDACS;AAGjB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,+BAAiB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CAC3B;AAdf,cAAc;IAD1B,IAAA,wBAAS,GAAE;GACC,cAAc,CAe1B;AAfY,wCAAc;AAkB3B,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;CAqB5B,CAAA;AAnBC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CAC3B;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACb;AAGb;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iCAAmB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACzB;AAG9B;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACR;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACN;AAGpB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,+BAAiB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDAC3B;AAG1B;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACX;AApBJ,gBAAgB;IAD5B,IAAA,wBAAS,GAAE;GACC,gBAAgB,CAqB5B;AArBY,4CAAgB;AAwB7B,IAAa,eAAe,GAA5B,MAAa,eAAe;CAM3B,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,yBAAW,CAAC,CAAC;;8CACT;AAGpB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;8CACN;AALF,eAAe;IAD3B,IAAA,yBAAU,GAAE;GACA,eAAe,CAM3B;AANY,0CAAe"}
|
@@ -10,11 +10,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
10
|
};
|
11
11
|
var _a, _b, _c;
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
-
exports.Sellercraft = exports.SellercraftStatus = void 0;
|
14
|
-
const auth_base_1 = require("@things-factory/auth-base");
|
15
|
-
const shell_1 = require("@things-factory/shell");
|
13
|
+
exports.Sellercraft = exports.SellercraftPlatform = exports.SellercraftStatus = void 0;
|
16
14
|
const type_graphql_1 = require("type-graphql");
|
17
15
|
const typeorm_1 = require("typeorm");
|
16
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
17
|
+
const shell_1 = require("@things-factory/shell");
|
18
18
|
var SellercraftStatus;
|
19
19
|
(function (SellercraftStatus) {
|
20
20
|
SellercraftStatus["ACTIVE"] = "ACTIVE";
|
@@ -25,6 +25,14 @@ var SellercraftStatus;
|
|
25
25
|
name: 'SellercraftStatus',
|
26
26
|
description: 'state enumeration of a sellercraft'
|
27
27
|
});
|
28
|
+
var SellercraftPlatform;
|
29
|
+
(function (SellercraftPlatform) {
|
30
|
+
SellercraftPlatform["SELLERCRAFT"] = "sellercraft";
|
31
|
+
})(SellercraftPlatform = exports.SellercraftPlatform || (exports.SellercraftPlatform = {}));
|
32
|
+
(0, type_graphql_1.registerEnumType)(SellercraftPlatform, {
|
33
|
+
name: 'SellercraftPlatform',
|
34
|
+
description: 'platform enumeration of a sellercraft'
|
35
|
+
});
|
28
36
|
let Sellercraft = class Sellercraft {
|
29
37
|
};
|
30
38
|
__decorate([
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sellercraft.js","sourceRoot":"","sources":["../../../server/service/sellercraft/sellercraft.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA
|
1
|
+
{"version":3,"file":"sellercraft.js","sourceRoot":"","sources":["../../../server/service/sellercraft/sellercraft.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAsE;AACtE,qCASgB;AAEhB,yDAAgD;AAChD,iDAA8C;AAE9C,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,0CAAqB,CAAA;IACrB,8CAAyB,CAAA;AAC3B,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B;AAED,IAAA,+BAAgB,EAAC,iBAAiB,EAAE;IAClC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,oCAAoC;CAClD,CAAC,CAAA;AAEF,IAAY,mBAEX;AAFD,WAAY,mBAAmB;IAC7B,kDAA2B,CAAA;AAC7B,CAAC,EAFW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAE9B;AAED,IAAA,+BAAgB,EAAC,mBAAmB,EAAE;IACpC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,uCAAuC;CACrD,CAAC,CAAA;AAKF,IAAa,WAAW,GAAxB,MA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EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDAChB,gBAAI,oBAAJ,gBAAI;4CAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;;8CAC5C;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDAChB,gBAAI,oBAAJ,gBAAI;4CAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;;8CAC5C;AApDP,WAAW;IAHvB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,kBAAkB,EAAE,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACjH,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;GACzC,WAAW,CAqDvB;AArDY,kCAAW"}
|
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.4",
|
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 -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-ui": "^4.0.
|
35
|
-
"@things-factory/more-ui": "^4.0.
|
36
|
-
"@things-factory/resource-ui": "^4.0.
|
37
|
-
"@things-factory/setting-ui": "^4.0.
|
38
|
-
"@things-factory/system-ui": "^4.0.
|
27
|
+
"@things-factory/apptool-ui": "^4.0.4",
|
28
|
+
"@things-factory/auth-ui": "^4.0.4",
|
29
|
+
"@things-factory/biz-base": "^4.0.4",
|
30
|
+
"@things-factory/code-ui": "^4.0.4",
|
31
|
+
"@things-factory/context-ui": "^4.0.4",
|
32
|
+
"@things-factory/grist-ui": "^4.0.1",
|
33
|
+
"@things-factory/i18n-ui": "^4.0.4",
|
34
|
+
"@things-factory/integration-ui": "^4.0.4",
|
35
|
+
"@things-factory/more-ui": "^4.0.4",
|
36
|
+
"@things-factory/resource-ui": "^4.0.4",
|
37
|
+
"@things-factory/setting-ui": "^4.0.4",
|
38
|
+
"@things-factory/system-ui": "^4.0.4",
|
39
39
|
"debug": "^4.1.1",
|
40
40
|
"node-fetch": "^2.6.0",
|
41
41
|
"querystring": "^0.2.1"
|
@@ -51,5 +51,5 @@
|
|
51
51
|
"nock": "^13.0.2",
|
52
52
|
"should": "^13.2.3"
|
53
53
|
},
|
54
|
-
"gitHead": "
|
54
|
+
"gitHead": "292d7c4e2675d228d6be474ea6a0525d26ac1657"
|
55
55
|
}
|
@@ -5,7 +5,46 @@ export function addInboundOrder() {
|
|
5
5
|
method: 'post',
|
6
6
|
path: '/product/inbound',
|
7
7
|
denormalize(req) {
|
8
|
-
|
8
|
+
const { accountId, inboundId, inboundTime, inboundType, purchaseOrderId, sellercraftOPs } = req
|
9
|
+
|
10
|
+
let orderInformation: any = {}
|
11
|
+
orderInformation.account_id = accountId
|
12
|
+
orderInformation.inbound_id = inboundId
|
13
|
+
orderInformation.inbound_time = inboundTime
|
14
|
+
orderInformation.inbound_type = inboundType
|
15
|
+
orderInformation.purchase_order_id = purchaseOrderId
|
16
|
+
|
17
|
+
let products: any[] = sellercraftOPs.map(orderProduct => {
|
18
|
+
const { packageDimension, forceCreateProduct } = orderProduct
|
19
|
+
let sellercraftOP: any = {}
|
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?.expiryTime ? orderProduct.expiryTime : 0
|
26
|
+
sellercraftOP.force_create_product = forceCreateProduct
|
27
|
+
|
28
|
+
if (forceCreateProduct) {
|
29
|
+
sellercraftOP.product_name = orderProduct.productName
|
30
|
+
sellercraftOP.gtin = orderProduct.gtin
|
31
|
+
sellercraftOP.package_weight_gm = orderProduct.weight
|
32
|
+
sellercraftOP.package_dimensions = {
|
33
|
+
length_mm: packageDimension.length,
|
34
|
+
width_mm: packageDimension.width,
|
35
|
+
height_mm: packageDimension.height
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
return sellercraftOP
|
40
|
+
})
|
41
|
+
|
42
|
+
return {
|
43
|
+
payload: {
|
44
|
+
...orderInformation,
|
45
|
+
products
|
46
|
+
}
|
47
|
+
}
|
9
48
|
},
|
10
49
|
normalize(res) {
|
11
50
|
return res
|
@@ -5,10 +5,14 @@ export function fetchOrderDocument() {
|
|
5
5
|
method: 'get',
|
6
6
|
path: '/order/documents',
|
7
7
|
denormalize(req) {
|
8
|
-
|
8
|
+
const { accountId: account_id, orderId: order_id, packageId: package_id } = req
|
9
|
+
return {
|
10
|
+
payload: { account_id, order_id, package_id }
|
11
|
+
}
|
9
12
|
},
|
10
13
|
normalize(res) {
|
11
|
-
|
14
|
+
const { documents, tracking_no: trackingNo } = res.data
|
15
|
+
return { documents, trackingNo }
|
12
16
|
}
|
13
17
|
}
|
14
18
|
}
|
@@ -5,7 +5,10 @@ export function initiateOrderDocument() {
|
|
5
5
|
method: 'post',
|
6
6
|
path: '/order/documents',
|
7
7
|
denormalize(req) {
|
8
|
-
|
8
|
+
const { accountId: account_id, orderId: order_id, packageId: package_id } = req
|
9
|
+
return {
|
10
|
+
payload: { account_id, order_id, package_id }
|
11
|
+
}
|
9
12
|
},
|
10
13
|
normalize(res) {
|
11
14
|
return res
|
@@ -5,10 +5,25 @@ export function initiateOrderShipment() {
|
|
5
5
|
method: 'post',
|
6
6
|
path: '/order/ship',
|
7
7
|
denormalize(req) {
|
8
|
-
|
8
|
+
const { accountId: account_id, orderId: order_id, packageId: package_id } = req
|
9
|
+
return {
|
10
|
+
payload: { account_id, order_id, package_id }
|
11
|
+
}
|
9
12
|
},
|
10
13
|
normalize(res) {
|
11
|
-
|
14
|
+
const {
|
15
|
+
handover_type: handOverType,
|
16
|
+
pickup_time: pickupTime,
|
17
|
+
pickup_address: pickupAddress,
|
18
|
+
dropoff_address: dropoffAddress
|
19
|
+
} = res.data
|
20
|
+
|
21
|
+
return {
|
22
|
+
handOverType,
|
23
|
+
pickupTime,
|
24
|
+
pickupAddress,
|
25
|
+
dropoffAddress
|
26
|
+
}
|
12
27
|
}
|
13
28
|
}
|
14
29
|
}
|
@@ -5,10 +5,31 @@ export function packMarketplaceOrder() {
|
|
5
5
|
method: 'post',
|
6
6
|
path: '/order/pack',
|
7
7
|
denormalize(req) {
|
8
|
-
|
8
|
+
const { accountId: account_id, orderId: order_id, sellercraftOPs } = req
|
9
|
+
|
10
|
+
const items: any[] = sellercraftOPs.map(orderProduct => {
|
11
|
+
return {
|
12
|
+
sku: orderProduct.sku,
|
13
|
+
quantity: orderProduct.releaseQty,
|
14
|
+
unit_of_measure: orderProduct.uom
|
15
|
+
}
|
16
|
+
})
|
17
|
+
|
18
|
+
let packages: any[] = []
|
19
|
+
packages.push({ items })
|
20
|
+
|
21
|
+
return {
|
22
|
+
payload: {
|
23
|
+
account_id,
|
24
|
+
order_id,
|
25
|
+
packages
|
26
|
+
}
|
27
|
+
}
|
9
28
|
},
|
10
29
|
normalize(res) {
|
11
|
-
|
30
|
+
const { packages } = res.data
|
31
|
+
const packageId: string = packages[0].package_id
|
32
|
+
return packageId
|
12
33
|
}
|
13
34
|
}
|
14
35
|
}
|
@@ -5,7 +5,32 @@ export function updateProduct() {
|
|
5
5
|
method: 'put',
|
6
6
|
path: '/product',
|
7
7
|
denormalize(req) {
|
8
|
-
|
8
|
+
const { sellercraftInv } = req
|
9
|
+
|
10
|
+
let products: any[] = []
|
11
|
+
const { packageDimension, accountId: account_id } = sellercraftInv
|
12
|
+
let sellercraftOP: any = {}
|
13
|
+
sellercraftOP.sku = sellercraftInv.sku
|
14
|
+
sellercraftOP.gtin = sellercraftInv.gtin
|
15
|
+
sellercraftOP.stock = {
|
16
|
+
quantity: sellercraftInv.quantity,
|
17
|
+
unit_of_measure: sellercraftInv.uom
|
18
|
+
}
|
19
|
+
sellercraftOP.package_weight_gm = sellercraftInv.weight
|
20
|
+
sellercraftOP.package_dimensions = {
|
21
|
+
length_mm: packageDimension.length,
|
22
|
+
width_mm: packageDimension.width,
|
23
|
+
height_mm: packageDimension.height
|
24
|
+
}
|
25
|
+
|
26
|
+
products.push({ ...sellercraftOP })
|
27
|
+
|
28
|
+
return {
|
29
|
+
payload: {
|
30
|
+
account_id,
|
31
|
+
products
|
32
|
+
}
|
33
|
+
}
|
9
34
|
},
|
10
35
|
normalize(res) {
|
11
36
|
return res
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import { SellercraftAPI } from '../store-api'
|
4
|
-
import { action } from './platform-action'
|
1
|
+
import { SellercraftAPI } from '../sellercraft-api'
|
5
2
|
import * as APIS from './apis'
|
3
|
+
import { action } from './platform-action'
|
4
|
+
|
5
|
+
export * from './sellercraft'
|
6
6
|
|
7
7
|
SellercraftAPI.registerPlatform('sellercraft', action, APIS)
|
@@ -1,6 +1,7 @@
|
|
1
|
+
import { config } from '@things-factory/env'
|
2
|
+
|
1
3
|
import { Sellercraft } from './sellercraft'
|
2
4
|
|
3
|
-
import { config } from '@things-factory/env'
|
4
5
|
const sellercraftConfig = config.get('sellercraftIntegrationConfig', {})
|
5
6
|
const { apiKey } = sellercraftConfig
|
6
7
|
|
@@ -22,14 +23,14 @@ function substitute(path, obj) {
|
|
22
23
|
return result
|
23
24
|
}
|
24
25
|
|
25
|
-
export const action = async ({
|
26
|
+
export const action = async ({ method = 'get', path, request }) => {
|
26
27
|
const client = new Sellercraft({ apiKey })
|
27
28
|
|
28
29
|
const { resource = {}, payload = {} } = request
|
29
30
|
|
30
31
|
path = substitute(path, resource)
|
31
32
|
|
32
|
-
var response = await client[method](
|
33
|
+
var response = await client[method](path, payload)
|
33
34
|
if (response.errors) {
|
34
35
|
throw response
|
35
36
|
}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import uuid from 'uuid/v4'
|
2
1
|
import fetch from 'node-fetch'
|
2
|
+
import uuid from 'uuid/v4'
|
3
3
|
|
4
4
|
const debug = require('debug')('things-factory:integration-sellercraft:sellercraft')
|
5
5
|
|
@@ -24,70 +24,83 @@ export class Sellercraft {
|
|
24
24
|
return uuid()
|
25
25
|
}
|
26
26
|
|
27
|
-
async post(
|
27
|
+
async post(path: string, data: any = {}) {
|
28
28
|
const { apiKey } = this.config
|
29
29
|
|
30
30
|
debug('data', data)
|
31
31
|
|
32
32
|
const jsondata = JSON.stringify(data)
|
33
|
+
const requestId: string = this.generateRequestId()
|
34
|
+
const fullPath: string = `${this.getBaseUrl()}${path}`
|
33
35
|
|
34
|
-
const response = await fetch(
|
36
|
+
const response: any = await fetch(fullPath, {
|
35
37
|
method: 'post',
|
36
38
|
headers: {
|
37
39
|
'Content-Type': 'application/json',
|
38
|
-
request_id:
|
40
|
+
request_id: requestId,
|
39
41
|
'x-api-key': apiKey
|
40
42
|
},
|
41
43
|
body: jsondata
|
42
44
|
})
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
if (response.ok) {
|
47
|
+
return await response.json()
|
48
|
+
} else {
|
49
|
+
throw new Error(`response code - ${response.status}, ${response.statusText}`)
|
50
|
+
}
|
48
51
|
}
|
49
52
|
|
50
|
-
async put(
|
53
|
+
async put(path: string, data: any = {}) {
|
51
54
|
const { apiKey } = this.config
|
52
55
|
|
53
56
|
const jsondata = JSON.stringify(data)
|
57
|
+
const requestId: string = this.generateRequestId()
|
58
|
+
const fullPath: string = `${this.getBaseUrl()}${path}`
|
54
59
|
debug('data', data)
|
55
60
|
|
56
|
-
const response = await fetch(
|
57
|
-
method: '
|
61
|
+
const response: any = await fetch(fullPath, {
|
62
|
+
method: 'put',
|
58
63
|
headers: {
|
59
64
|
'Content-Type': 'application/json',
|
60
|
-
request_id:
|
65
|
+
request_id: requestId,
|
61
66
|
'x-api-key': apiKey
|
62
67
|
},
|
63
68
|
body: jsondata
|
64
69
|
})
|
65
70
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
71
|
+
if (response.ok) {
|
72
|
+
return await response.json()
|
73
|
+
} else {
|
74
|
+
throw new Error(`response code - ${response.status}, ${response.statusText}`)
|
75
|
+
}
|
70
76
|
}
|
71
77
|
|
72
|
-
async get(
|
78
|
+
async get(path: string, data: any = {}) {
|
73
79
|
const { apiKey } = this.config
|
74
80
|
|
75
|
-
const
|
76
|
-
|
81
|
+
const qs = Object.entries(data)
|
82
|
+
.map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
|
83
|
+
.join('&')
|
77
84
|
|
78
|
-
const
|
79
|
-
|
85
|
+
const fullPath: string = `${this.getBaseUrl()}${path}`
|
86
|
+
const endpoint = `${fullPath}${qs ? '?' + qs : ''}`
|
87
|
+
debug('endpoint', endpoint)
|
88
|
+
|
89
|
+
const requestId: string = this.generateRequestId()
|
90
|
+
|
91
|
+
const response: any = await fetch(endpoint, {
|
92
|
+
method: 'get',
|
80
93
|
headers: {
|
81
94
|
'Content-Type': 'application/json',
|
82
|
-
request_id:
|
95
|
+
request_id: requestId,
|
83
96
|
'x-api-key': apiKey
|
84
|
-
}
|
85
|
-
body: jsondata
|
97
|
+
}
|
86
98
|
})
|
87
99
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
100
|
+
if (response.ok) {
|
101
|
+
return await response.json()
|
102
|
+
} else {
|
103
|
+
throw new Error(`response code - ${response.status}, ${response.statusText}`)
|
104
|
+
}
|
92
105
|
}
|
93
106
|
}
|
File without changes
|
File without changes
|