@things-factory/integration-sftp 4.3.668 → 4.3.671
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/package.json +6 -6
- package/dist-server/controllers/herbalife/apis/create-serial-number.js +0 -47
- package/dist-server/controllers/herbalife/apis/create-serial-number.js.map +0 -1
- package/dist-server/controllers/herbalife/apis/create-shipment.js +0 -85
- package/dist-server/controllers/herbalife/apis/create-shipment.js.map +0 -1
- package/dist-server/controllers/herbalife/apis/echo.js +0 -19
- package/dist-server/controllers/herbalife/apis/echo.js.map +0 -1
- package/dist-server/controllers/herbalife/apis/get-outbound-order.js +0 -115
- package/dist-server/controllers/herbalife/apis/get-outbound-order.js.map +0 -1
- package/dist-server/controllers/herbalife/apis/index.js +0 -21
- package/dist-server/controllers/herbalife/apis/index.js.map +0 -1
- package/dist-server/controllers/herbalife/herbalife.js +0 -44
- package/dist-server/controllers/herbalife/herbalife.js.map +0 -1
- package/dist-server/controllers/herbalife/index.js +0 -34
- package/dist-server/controllers/herbalife/index.js.map +0 -1
- package/dist-server/controllers/herbalife/platform-action.js +0 -30
- package/dist-server/controllers/herbalife/platform-action.js.map +0 -1
- package/dist-server/controllers/index.js +0 -20
- package/dist-server/controllers/index.js.map +0 -1
- package/dist-server/controllers/sftp-api/decorators.js +0 -30
- package/dist-server/controllers/sftp-api/decorators.js.map +0 -1
- package/dist-server/controllers/sftp-api/index.js +0 -71
- package/dist-server/controllers/sftp-api/index.js.map +0 -1
- package/dist-server/controllers/sftp-api/types.js +0 -1
- package/dist-server/controllers/sftp-api/types.js.map +0 -1
- package/dist-server/controllers/yltc/apis/create-yltc-inventory-report.js +0 -40
- package/dist-server/controllers/yltc/apis/create-yltc-inventory-report.js.map +0 -1
- package/dist-server/controllers/yltc/apis/echo.js +0 -19
- package/dist-server/controllers/yltc/apis/echo.js.map +0 -1
- package/dist-server/controllers/yltc/apis/index.js +0 -19
- package/dist-server/controllers/yltc/apis/index.js.map +0 -1
- package/dist-server/controllers/yltc/index.js +0 -34
- package/dist-server/controllers/yltc/index.js.map +0 -1
- package/dist-server/controllers/yltc/platform-action.js +0 -30
- package/dist-server/controllers/yltc/platform-action.js.map +0 -1
- package/dist-server/controllers/yltc/yltc.js +0 -71
- package/dist-server/controllers/yltc/yltc.js.map +0 -1
- package/dist-server/index.js +0 -23
- package/dist-server/index.js.map +0 -1
- package/dist-server/middlewares/index.js +0 -8
- package/dist-server/middlewares/index.js.map +0 -1
- package/dist-server/routes.js +0 -25
- package/dist-server/routes.js.map +0 -1
- package/dist-server/service/index.js +0 -32
- package/dist-server/service/index.js.map +0 -1
- package/dist-server/service/sftp/index.js +0 -9
- package/dist-server/service/sftp/index.js.map +0 -1
- package/dist-server/service/sftp/sftp-mutation.js +0 -280
- package/dist-server/service/sftp/sftp-mutation.js.map +0 -1
- package/dist-server/service/sftp/sftp-query.js +0 -87
- package/dist-server/service/sftp/sftp-query.js.map +0 -1
- package/dist-server/service/sftp/sftp-type.js +0 -121
- package/dist-server/service/sftp/sftp-type.js.map +0 -1
- package/dist-server/service/sftp/sftp.js +0 -213
- package/dist-server/service/sftp/sftp.js.map +0 -1
- package/dist-server/sftp-const.js +0 -50
- package/dist-server/sftp-const.js.map +0 -1
- package/dist-server/sftp-s3.js +0 -113
- package/dist-server/sftp-s3.js.map +0 -1
- package/dist-server/storage/providers/ftp-storage.provider.js +0 -178
- package/dist-server/storage/providers/ftp-storage.provider.js.map +0 -1
- package/dist-server/storage/providers/local-storage.provider.js +0 -153
- package/dist-server/storage/providers/local-storage.provider.js.map +0 -1
- package/dist-server/storage/providers/s3-storage.provider.js +0 -181
- package/dist-server/storage/providers/s3-storage.provider.js.map +0 -1
- package/dist-server/storage/providers/sftp-storage.provider.js +0 -133
- package/dist-server/storage/providers/sftp-storage.provider.js.map +0 -1
- package/dist-server/storage/storage-factory.js +0 -55
- package/dist-server/storage/storage-factory.js.map +0 -1
- package/dist-server/storage/storage-manager.js +0 -86
- package/dist-server/storage/storage-manager.js.map +0 -1
- package/dist-server/storage/storage-provider.interface.js +0 -3
- package/dist-server/storage/storage-provider.interface.js.map +0 -1
- package/dist-server/util/file-formatters.js +0 -100
- package/dist-server/util/file-formatters.js.map +0 -1
- package/dist-server/util/generate-files.js +0 -90
- package/dist-server/util/generate-files.js.map +0 -1
- package/dist-server/util/get-permitted-directories.js +0 -20
- package/dist-server/util/get-permitted-directories.js.map +0 -1
- package/dist-server/util/index.js +0 -19
- package/dist-server/util/index.js.map +0 -1
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createYLTCInventoryReport = void 0;
|
|
4
|
-
function createYLTCInventoryReport() {
|
|
5
|
-
return {
|
|
6
|
-
method: 'post',
|
|
7
|
-
path: '{folderPath}',
|
|
8
|
-
denormalize(req) {
|
|
9
|
-
const { sftp, title, backupTitle, content, backupPath, contentType } = req;
|
|
10
|
-
const { folderPath, platform } = sftp;
|
|
11
|
-
// Values used by platform-action substitute() for path placeholders
|
|
12
|
-
const resource = {
|
|
13
|
-
folderPath: folderPath || ''
|
|
14
|
-
};
|
|
15
|
-
// Build payload with required fields only
|
|
16
|
-
const payload = {
|
|
17
|
-
sftp,
|
|
18
|
-
title,
|
|
19
|
-
content,
|
|
20
|
-
contentType,
|
|
21
|
-
folderPath,
|
|
22
|
-
platform
|
|
23
|
-
};
|
|
24
|
-
// Include optionals only when present
|
|
25
|
-
if (backupTitle)
|
|
26
|
-
payload.backupTitle = backupTitle;
|
|
27
|
-
if (backupPath)
|
|
28
|
-
payload.backupPath = backupPath;
|
|
29
|
-
return {
|
|
30
|
-
resource,
|
|
31
|
-
payload
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
normalize(res) {
|
|
35
|
-
return res;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
exports.createYLTCInventoryReport = createYLTCInventoryReport;
|
|
40
|
-
//# sourceMappingURL=create-yltc-inventory-report.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-yltc-inventory-report.js","sourceRoot":"","sources":["../../../../server/controllers/yltc/apis/create-yltc-inventory-report.ts"],"names":[],"mappings":";;;AAAA,SAAgB,yBAAyB;IACvC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,cAAc;QACpB,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,GAAG,CAAA;YAC1E,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;YAErC,oEAAoE;YACpE,MAAM,QAAQ,GAAG;gBACf,UAAU,EAAE,UAAU,IAAI,EAAE;aAC7B,CAAA;YAED,0CAA0C;YAC1C,MAAM,OAAO,GAAQ;gBACnB,IAAI;gBACJ,KAAK;gBACL,OAAO;gBACP,WAAW;gBACX,UAAU;gBACV,QAAQ;aACT,CAAA;YAED,sCAAsC;YACtC,IAAI,WAAW;gBAAE,OAAO,CAAC,WAAW,GAAG,WAAW,CAAA;YAClD,IAAI,UAAU;gBAAE,OAAO,CAAC,UAAU,GAAG,UAAU,CAAA;YAE/C,OAAO;gBACL,QAAQ;gBACR,OAAO;aACR,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AApCD,8DAoCC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.echo = void 0;
|
|
4
|
-
function echo() {
|
|
5
|
-
return {
|
|
6
|
-
path: '/echo',
|
|
7
|
-
denormalize(req) {
|
|
8
|
-
return Object.assign({}, req);
|
|
9
|
-
},
|
|
10
|
-
normalize(res) {
|
|
11
|
-
return Object.assign({}, res);
|
|
12
|
-
},
|
|
13
|
-
action({ store, method, path, request, platformAction }) {
|
|
14
|
-
return Object.assign({}, request);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
exports.echo = echo;
|
|
19
|
-
//# sourceMappingURL=echo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"echo.js","sourceRoot":"","sources":["../../../../server/controllers/yltc/apis/echo.ts"],"names":[],"mappings":";;;AAAA,SAAgB,IAAI;IAClB,OAAO;QACL,IAAI,EAAE,OAAO;QACb,WAAW,CAAC,GAAG;YACb,yBAAY,GAAG,EAAE;QACnB,CAAC;QACD,SAAS,CAAC,GAAG;YACX,yBAAY,GAAG,EAAE;QACnB,CAAC;QACD,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE;YACrD,yBAAY,OAAO,EAAE;QACvB,CAAC;KACF,CAAA;AACH,CAAC;AAbD,oBAaC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./echo"), exports);
|
|
18
|
-
__exportStar(require("./create-yltc-inventory-report"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/yltc/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAsB;AACtB,iEAA8C"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const sftp_api_1 = require("../sftp-api");
|
|
30
|
-
const APIS = __importStar(require("./apis"));
|
|
31
|
-
const platform_action_1 = require("./platform-action");
|
|
32
|
-
__exportStar(require("./yltc"), exports);
|
|
33
|
-
sftp_api_1.SftpAPI.registerPlatform('yltc', platform_action_1.action, APIS);
|
|
34
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/controllers/yltc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAqC;AACrC,6CAA8B;AAC9B,uDAA0C;AAE1C,yCAAsB;AAEtB,kBAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,wBAAM,EAAE,IAAI,CAAC,CAAA"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.action = void 0;
|
|
4
|
-
const yltc_1 = require("./yltc");
|
|
5
|
-
function substitute(path, obj) {
|
|
6
|
-
var props = [];
|
|
7
|
-
var re = /{([^}]+)}/g;
|
|
8
|
-
var text;
|
|
9
|
-
while ((text = re.exec(path))) {
|
|
10
|
-
props.push(text[1]);
|
|
11
|
-
}
|
|
12
|
-
var result = path;
|
|
13
|
-
props.forEach(prop => {
|
|
14
|
-
let value = obj[prop.trim()];
|
|
15
|
-
result = result.replace(`{${prop}}`, value === undefined ? '' : value);
|
|
16
|
-
});
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
const action = async ({ method = 'get', path, request }) => {
|
|
20
|
-
const client = new yltc_1.Yltc();
|
|
21
|
-
const { resource = {}, payload = {} } = request;
|
|
22
|
-
path = substitute(path, resource);
|
|
23
|
-
var response = await client[method](path, payload);
|
|
24
|
-
if (response.errors) {
|
|
25
|
-
throw response;
|
|
26
|
-
}
|
|
27
|
-
return response;
|
|
28
|
-
};
|
|
29
|
-
exports.action = action;
|
|
30
|
-
//# sourceMappingURL=platform-action.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platform-action.js","sourceRoot":"","sources":["../../../server/controllers/yltc/platform-action.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B,SAAS,UAAU,CAAC,IAAI,EAAE,GAAG;IAC3B,IAAI,KAAK,GAAG,EAAE,CAAA;IACd,IAAI,EAAE,GAAG,YAAY,CAAA;IACrB,IAAI,IAAI,CAAA;IAER,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;QAC7B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;KACpB;IAED,IAAI,MAAM,GAAG,IAAI,CAAA;IACjB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnB,IAAI,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAC5B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,GAAG,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC;AAEM,MAAM,MAAM,GAAG,KAAK,EAAE,EAAE,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,IAAI,WAAI,EAAE,CAAA;IAEzB,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"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Yltc = void 0;
|
|
4
|
-
const env_1 = require("@things-factory/env");
|
|
5
|
-
const storage_manager_1 = require("../../storage/storage-manager");
|
|
6
|
-
const generate_files_1 = require("../../util/generate-files");
|
|
7
|
-
const file_formatters_1 = require("../../util/file-formatters");
|
|
8
|
-
class Yltc {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.storageManager = storage_manager_1.StorageManager.getInstance();
|
|
11
|
-
}
|
|
12
|
-
buildRuntimeConfigFromSftp(sftp) {
|
|
13
|
-
if (sftp && (sftp.host || sftp.username || sftp.password)) {
|
|
14
|
-
return {
|
|
15
|
-
type: 'sftp',
|
|
16
|
-
host: sftp.host,
|
|
17
|
-
port: sftp.port,
|
|
18
|
-
username: sftp.username,
|
|
19
|
-
password: sftp.password,
|
|
20
|
-
basePath: sftp.basePath || sftp.folderPath,
|
|
21
|
-
timeout: sftp.timeout,
|
|
22
|
-
retries: sftp.retries
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
// Fallback to external config if Sftp entity does not carry connection info
|
|
26
|
-
return env_1.config.get('sftpExternal') || env_1.config.get('sftpFileStorage');
|
|
27
|
-
}
|
|
28
|
-
async get(path, data = {}) {
|
|
29
|
-
const runtimeConfig = this.buildRuntimeConfigFromSftp(data === null || data === void 0 ? void 0 : data.sftp);
|
|
30
|
-
const fileResult = await this.storageManager.readFile(runtimeConfig, path, 'utf-8');
|
|
31
|
-
// Check if file is CSV and parse accordingly
|
|
32
|
-
if (path.toLowerCase().endsWith('.csv')) {
|
|
33
|
-
return (0, file_formatters_1.parseCSV)(fileResult);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
// Fallback to XML parsing for backward compatibility
|
|
37
|
-
const { xml2js } = require('xml-js');
|
|
38
|
-
const item = xml2js(fileResult, {
|
|
39
|
-
compact: true
|
|
40
|
-
});
|
|
41
|
-
return Object.assign({}, item);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async post(path, data = {}) {
|
|
45
|
-
const { title, backupTitle, content, sftp, backupPath, contentType = 'csv' // Default to CSV
|
|
46
|
-
} = data;
|
|
47
|
-
const runtimeConfig = this.buildRuntimeConfigFromSftp(sftp);
|
|
48
|
-
let params = [];
|
|
49
|
-
const body = Array.isArray(content) ? (0, file_formatters_1.formatData)(content, contentType) : content;
|
|
50
|
-
// Ensure extension matches content type
|
|
51
|
-
const ext = contentType === 'xml' ? '.xml' : contentType === 'xlsx' ? '.xlsx' : '.csv';
|
|
52
|
-
const normalizedTitle = title.endsWith(ext) ? title : `${title}${ext}`;
|
|
53
|
-
// If basePath is configured, uploading to basePath root requires empty uploadPath
|
|
54
|
-
const mainUploadPath = runtimeConfig.basePath ? '' : path;
|
|
55
|
-
const platformPrefix = ((sftp === null || sftp === void 0 ? void 0 : sftp.platform) || (data === null || data === void 0 ? void 0 : data.platform) || '').toString().trim();
|
|
56
|
-
params.push({
|
|
57
|
-
title: normalizedTitle,
|
|
58
|
-
uploadPath: mainUploadPath,
|
|
59
|
-
content: body,
|
|
60
|
-
platform: platformPrefix
|
|
61
|
-
});
|
|
62
|
-
if (backupPath && backupTitle) {
|
|
63
|
-
const normalizedBackupTitle = backupTitle.endsWith(ext) ? backupTitle : `${backupTitle}${ext}`;
|
|
64
|
-
params.push({ title: normalizedBackupTitle, uploadPath: backupPath, content: body, platform: platformPrefix });
|
|
65
|
-
}
|
|
66
|
-
await (0, generate_files_1.generateFiles)(params, runtimeConfig);
|
|
67
|
-
return sftp;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.Yltc = Yltc;
|
|
71
|
-
//# sourceMappingURL=yltc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"yltc.js","sourceRoot":"","sources":["../../../server/controllers/yltc/yltc.ts"],"names":[],"mappings":"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"}
|
package/dist-server/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
require("./routes");
|
|
18
|
-
__exportStar(require("./middlewares"), exports);
|
|
19
|
-
__exportStar(require("./service"), exports);
|
|
20
|
-
__exportStar(require("./sftp-const"), exports);
|
|
21
|
-
__exportStar(require("./controllers"), exports);
|
|
22
|
-
__exportStar(require("./util"), exports);
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
package/dist-server/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oBAAiB;AAEjB,gDAA6B;AAC7B,4CAAyB;AACzB,+CAA4B;AAC5B,gDAA6B;AAC7B,yCAAsB"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initMiddlewares = void 0;
|
|
4
|
-
function initMiddlewares(app) {
|
|
5
|
-
/* can add middlewares into app */
|
|
6
|
-
}
|
|
7
|
-
exports.initMiddlewares = initMiddlewares;
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/middlewares/index.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAC,GAAG;IACjC,kCAAkC;AACpC,CAAC;AAFD,0CAEC"}
|
package/dist-server/routes.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const debug = require('debug')('things-factory:integration-sftp:routes');
|
|
2
|
-
process.on('bootstrap-module-global-public-route', (app, globalPublicRouter) => {
|
|
3
|
-
/*
|
|
4
|
-
* can add global public routes to application (auth not required, tenancy not required)
|
|
5
|
-
*
|
|
6
|
-
* ex) routes.get('/path', async(context, next) => {})
|
|
7
|
-
* ex) routes.post('/path', async(context, next) => {})
|
|
8
|
-
*/
|
|
9
|
-
});
|
|
10
|
-
process.on('bootstrap-module-global-private-route', (app, globalPrivateRouter) => {
|
|
11
|
-
/*
|
|
12
|
-
* can add global private routes to application (auth required, tenancy not required)
|
|
13
|
-
*/
|
|
14
|
-
});
|
|
15
|
-
process.on('bootstrap-module-domain-public-route', (app, domainPublicRouter) => {
|
|
16
|
-
/*
|
|
17
|
-
* can add domain public routes to application (auth not required, tenancy required)
|
|
18
|
-
*/
|
|
19
|
-
});
|
|
20
|
-
process.on('bootstrap-module-domain-private-route', (app, domainPrivateRouter) => {
|
|
21
|
-
/*
|
|
22
|
-
* can add domain private routes to application (auth required, tenancy required)
|
|
23
|
-
*/
|
|
24
|
-
});
|
|
25
|
-
//# sourceMappingURL=routes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,wCAAwC,CAAC,CAAA;AAExE,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF;;;;;OAKG;AACL,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"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.schema = exports.entities = void 0;
|
|
18
|
-
/* EXPORT ENTITY TYPES */
|
|
19
|
-
__exportStar(require("./sftp/sftp"), exports);
|
|
20
|
-
/* IMPORT ENTITIES AND RESOLVERS */
|
|
21
|
-
const sftp_1 = require("./sftp");
|
|
22
|
-
exports.entities = [
|
|
23
|
-
/* ENTITIES */
|
|
24
|
-
...sftp_1.entities,
|
|
25
|
-
];
|
|
26
|
-
exports.schema = {
|
|
27
|
-
resolverClasses: [
|
|
28
|
-
/* RESOLVER CLASSES */
|
|
29
|
-
...sftp_1.resolvers,
|
|
30
|
-
]
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yBAAyB;AACzB,8CAA2B;AAE3B,mCAAmC;AACnC,iCAA6E;AAEhE,QAAA,QAAQ,GAAG;IACtB,cAAc;IACf,GAAG,eAAY;CACf,CAAA;AAGY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACxB,GAAG,gBAAa;KACf;CACF,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvers = exports.entities = void 0;
|
|
4
|
-
const sftp_1 = require("./sftp");
|
|
5
|
-
const sftp_query_1 = require("./sftp-query");
|
|
6
|
-
const sftp_mutation_1 = require("./sftp-mutation");
|
|
7
|
-
exports.entities = [sftp_1.Sftp];
|
|
8
|
-
exports.resolvers = [sftp_query_1.SftpQuery, sftp_mutation_1.SftpMutation];
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/sftp/index.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,6CAAwC;AACxC,mDAA8C;AAEjC,QAAA,QAAQ,GAAG,CAAC,WAAI,CAAC,CAAA;AACjB,QAAA,SAAS,GAAG,CAAC,sBAAS,EAAE,4BAAY,CAAC,CAAA"}
|
|
@@ -1,280 +0,0 @@
|
|
|
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
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
15
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
16
|
-
var m = o[Symbol.asyncIterator], i;
|
|
17
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
18
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
19
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.getCustomerBizplace = exports.processSftp = exports.SftpMutation = void 0;
|
|
23
|
-
const type_graphql_1 = require("type-graphql");
|
|
24
|
-
const typeorm_1 = require("typeorm");
|
|
25
|
-
const biz_base_1 = require("@things-factory/biz-base");
|
|
26
|
-
const integration_fulfillment_1 = require("@things-factory/integration-fulfillment");
|
|
27
|
-
const shell_1 = require("@things-factory/shell");
|
|
28
|
-
const controllers_1 = require("../../controllers");
|
|
29
|
-
const sftp_const_1 = require("../../sftp-const");
|
|
30
|
-
const storage_manager_1 = require("../../storage/storage-manager");
|
|
31
|
-
const util_1 = require("../../util");
|
|
32
|
-
const sftp_1 = require("./sftp");
|
|
33
|
-
const sftp_type_1 = require("./sftp-type");
|
|
34
|
-
let SftpMutation = class SftpMutation {
|
|
35
|
-
constructor() {
|
|
36
|
-
this.storageManager = storage_manager_1.StorageManager.getInstance();
|
|
37
|
-
this.sftpConfig = (0, sftp_const_1.getSftpStorageConfig)();
|
|
38
|
-
}
|
|
39
|
-
async createSftp(sftp, context) {
|
|
40
|
-
const { domain, user, tx } = context.state;
|
|
41
|
-
return await tx.getRepository(sftp_1.Sftp).save(Object.assign(Object.assign({}, sftp), { domain, creator: user, updater: user }));
|
|
42
|
-
}
|
|
43
|
-
async updateSftp(id, patch, context) {
|
|
44
|
-
const { domain, user, tx } = context.state;
|
|
45
|
-
const repository = tx.getRepository(sftp_1.Sftp);
|
|
46
|
-
const sftp = await repository.findOne({
|
|
47
|
-
where: { domain, id }
|
|
48
|
-
});
|
|
49
|
-
return await repository.save(Object.assign(Object.assign(Object.assign({}, sftp), patch), { updater: user }));
|
|
50
|
-
}
|
|
51
|
-
async updateMultipleSftp(patches, context) {
|
|
52
|
-
const { domain, user, tx } = context.state;
|
|
53
|
-
let results = [];
|
|
54
|
-
const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
|
|
55
|
-
const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
|
|
56
|
-
const sftpRepo = tx.getRepository(sftp_1.Sftp);
|
|
57
|
-
if (_createRecords.length > 0) {
|
|
58
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
59
|
-
const newRecord = _createRecords[i];
|
|
60
|
-
const result = await sftpRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
|
|
61
|
-
results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (_updateRecords.length > 0) {
|
|
65
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
66
|
-
const newRecord = _updateRecords[i];
|
|
67
|
-
const sftp = await sftpRepo.findOne(newRecord.id);
|
|
68
|
-
const result = await sftpRepo.save(Object.assign(Object.assign(Object.assign({}, sftp), newRecord), { updater: user }));
|
|
69
|
-
results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return results;
|
|
73
|
-
}
|
|
74
|
-
async deleteSftp(id, context) {
|
|
75
|
-
const { domain, tx } = context.state;
|
|
76
|
-
await tx.getRepository(sftp_1.Sftp).delete({ domain, id });
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
async deleteSftps(ids, context) {
|
|
80
|
-
const { domain, tx } = context.state;
|
|
81
|
-
await tx.getRepository(sftp_1.Sftp).delete({
|
|
82
|
-
domain,
|
|
83
|
-
id: (0, typeorm_1.In)(ids)
|
|
84
|
-
});
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
async syncSftpOrders(customerDomainId, context) {
|
|
88
|
-
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
89
|
-
const customerDomain = await tx.getRepository(shell_1.Domain).findOne(customerDomainId);
|
|
90
|
-
const customerBizplace = await getCustomerBizplace(customerDomainId, tx);
|
|
91
|
-
const sftpUsers = await tx.getRepository(sftp_1.Sftp).find({
|
|
92
|
-
where: { domain: customerDomain, status: 'ACTIVE' },
|
|
93
|
-
relations: ['fulfillmentCenter']
|
|
94
|
-
});
|
|
95
|
-
for (var i = 0; i < sftpUsers.length; i++) {
|
|
96
|
-
const sftpUser = sftpUsers[i];
|
|
97
|
-
processSftp(sftpUser, context, customerBizplace.id, this.storageManager, this.sftpConfig);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
async syncAllSftpOrders(context) {
|
|
103
|
-
try {
|
|
104
|
-
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
105
|
-
const sftps = await tx
|
|
106
|
-
.getRepository(sftp_1.Sftp)
|
|
107
|
-
.createQueryBuilder('s')
|
|
108
|
-
.where('s.status = :status', { status: 'ACTIVE' })
|
|
109
|
-
.getMany();
|
|
110
|
-
if (sftps.length === 0)
|
|
111
|
-
return;
|
|
112
|
-
for (const sftp of sftps) {
|
|
113
|
-
const customerBizplace = await getCustomerBizplace(sftp.domainId, tx);
|
|
114
|
-
await processSftp(sftp, context, customerBizplace.id, this.storageManager, this.sftpConfig);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
catch (e) {
|
|
119
|
-
console.log(e);
|
|
120
|
-
}
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
__decorate([
|
|
125
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
126
|
-
(0, type_graphql_1.Mutation)(returns => sftp_1.Sftp, { description: 'To create new Sftp' }),
|
|
127
|
-
__param(0, (0, type_graphql_1.Arg)('sftp')),
|
|
128
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
129
|
-
__metadata("design:type", Function),
|
|
130
|
-
__metadata("design:paramtypes", [sftp_type_1.NewSftp, Object]),
|
|
131
|
-
__metadata("design:returntype", Promise)
|
|
132
|
-
], SftpMutation.prototype, "createSftp", null);
|
|
133
|
-
__decorate([
|
|
134
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
135
|
-
(0, type_graphql_1.Mutation)(returns => sftp_1.Sftp, { description: 'To modify Sftp information' }),
|
|
136
|
-
__param(0, (0, type_graphql_1.Arg)('id')),
|
|
137
|
-
__param(1, (0, type_graphql_1.Arg)('patch')),
|
|
138
|
-
__param(2, (0, type_graphql_1.Ctx)()),
|
|
139
|
-
__metadata("design:type", Function),
|
|
140
|
-
__metadata("design:paramtypes", [String, sftp_type_1.SftpPatch, Object]),
|
|
141
|
-
__metadata("design:returntype", Promise)
|
|
142
|
-
], SftpMutation.prototype, "updateSftp", null);
|
|
143
|
-
__decorate([
|
|
144
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
145
|
-
(0, type_graphql_1.Mutation)(returns => [sftp_1.Sftp], { description: "To modify multiple Sftps' information" }),
|
|
146
|
-
__param(0, (0, type_graphql_1.Arg)('patches', type => [sftp_type_1.SftpPatch])),
|
|
147
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
148
|
-
__metadata("design:type", Function),
|
|
149
|
-
__metadata("design:paramtypes", [Array, Object]),
|
|
150
|
-
__metadata("design:returntype", Promise)
|
|
151
|
-
], SftpMutation.prototype, "updateMultipleSftp", null);
|
|
152
|
-
__decorate([
|
|
153
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
154
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete Sftp' }),
|
|
155
|
-
__param(0, (0, type_graphql_1.Arg)('id')),
|
|
156
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
157
|
-
__metadata("design:type", Function),
|
|
158
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
159
|
-
__metadata("design:returntype", Promise)
|
|
160
|
-
], SftpMutation.prototype, "deleteSftp", null);
|
|
161
|
-
__decorate([
|
|
162
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
163
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple sftps' }),
|
|
164
|
-
__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
165
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
166
|
-
__metadata("design:type", Function),
|
|
167
|
-
__metadata("design:paramtypes", [Array, Object]),
|
|
168
|
-
__metadata("design:returntype", Promise)
|
|
169
|
-
], SftpMutation.prototype, "deleteSftps", null);
|
|
170
|
-
__decorate([
|
|
171
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To sync all orders from sftp' }),
|
|
172
|
-
__param(0, (0, type_graphql_1.Arg)('customerDomainId', type => String)),
|
|
173
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
174
|
-
__metadata("design:type", Function),
|
|
175
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
176
|
-
__metadata("design:returntype", Promise)
|
|
177
|
-
], SftpMutation.prototype, "syncSftpOrders", null);
|
|
178
|
-
__decorate([
|
|
179
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
180
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Calls syncSftpOrders for all domain Ids' }),
|
|
181
|
-
__param(0, (0, type_graphql_1.Ctx)()),
|
|
182
|
-
__metadata("design:type", Function),
|
|
183
|
-
__metadata("design:paramtypes", [Object]),
|
|
184
|
-
__metadata("design:returntype", Promise)
|
|
185
|
-
], SftpMutation.prototype, "syncAllSftpOrders", null);
|
|
186
|
-
SftpMutation = __decorate([
|
|
187
|
-
(0, type_graphql_1.Resolver)(sftp_1.Sftp)
|
|
188
|
-
], SftpMutation);
|
|
189
|
-
exports.SftpMutation = SftpMutation;
|
|
190
|
-
async function processSftp(sftpUser, context, customerBizplaceId, storageManager, sftpConfig) {
|
|
191
|
-
var _a, e_1, _b, _c;
|
|
192
|
-
// Use provided storage manager or get singleton instance
|
|
193
|
-
const manager = storageManager || storage_manager_1.StorageManager.getInstance();
|
|
194
|
-
const config = sftpConfig || (0, sftp_const_1.getSftpStorageConfig)();
|
|
195
|
-
const fulfilmentCenter = sftpUser.fulfillmentCenter;
|
|
196
|
-
const isDevelopment = sftpUser.isDevelopment;
|
|
197
|
-
const folderPath = sftpUser.folderPath;
|
|
198
|
-
const folderType = isDevelopment ? 'dev' : 'prd';
|
|
199
|
-
let initialDataPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUBMITDATAPATH}/`;
|
|
200
|
-
const results = await (0, util_1.getPermittedDirectories)({ path: initialDataPath }, context, config);
|
|
201
|
-
const filesDirectories = results.filter(result => result.Size > 0);
|
|
202
|
-
try {
|
|
203
|
-
for (var _d = true, filesDirectories_1 = __asyncValues(filesDirectories), filesDirectories_1_1; filesDirectories_1_1 = await filesDirectories_1.next(), _a = filesDirectories_1_1.done, !_a;) {
|
|
204
|
-
_c = filesDirectories_1_1.value;
|
|
205
|
-
_d = false;
|
|
206
|
-
try {
|
|
207
|
-
let fileDirectory = _c;
|
|
208
|
-
let dataPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUBMITDATAPATH}/`;
|
|
209
|
-
let successPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUCCESSDATAPATH}/`;
|
|
210
|
-
let failedPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.FAILEDDATAPATH}/`;
|
|
211
|
-
const fileKey = fileDirectory.Key;
|
|
212
|
-
const lastSlashIdx = fileKey.lastIndexOf('/');
|
|
213
|
-
const fileString = fileKey.substring(lastSlashIdx + 1, fileKey.length);
|
|
214
|
-
try {
|
|
215
|
-
const sftp = sftpUser;
|
|
216
|
-
let result = await controllers_1.SftpAPI.getOutboundOrder(sftp, { folderPath, folderType, fileKey: fileString });
|
|
217
|
-
let isAccept = result.isAccept;
|
|
218
|
-
if (isAccept) {
|
|
219
|
-
delete result.isAccept;
|
|
220
|
-
if (result) {
|
|
221
|
-
let { items: releaseOrders } = await integration_fulfillment_1.FulfillmentAPI.getOutboundOrders(fulfilmentCenter, {
|
|
222
|
-
customerBizplaceId,
|
|
223
|
-
refNo: result.refNo
|
|
224
|
-
});
|
|
225
|
-
if (releaseOrders) {
|
|
226
|
-
result.collectionOrderNo = result.collectionOrderNo + ' - ' + (releaseOrders.length + 1);
|
|
227
|
-
}
|
|
228
|
-
result.requiredDraft = false;
|
|
229
|
-
const releaseOrder = await integration_fulfillment_1.FulfillmentAPI.createOutboundOrder(fulfilmentCenter, {
|
|
230
|
-
customerBizplaceId,
|
|
231
|
-
releaseOrder: result
|
|
232
|
-
});
|
|
233
|
-
if (releaseOrder) {
|
|
234
|
-
let movePaths = {
|
|
235
|
-
source: (dataPath += fileString),
|
|
236
|
-
destination: (successPath += fileString)
|
|
237
|
-
};
|
|
238
|
-
await manager.moveFile(config, movePaths);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
let movePaths = {
|
|
244
|
-
source: (dataPath += fileString),
|
|
245
|
-
destination: (failedPath += fileString)
|
|
246
|
-
};
|
|
247
|
-
await manager.moveFile(config, movePaths);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
catch (e) {
|
|
251
|
-
let movePaths = {
|
|
252
|
-
source: (dataPath += fileString),
|
|
253
|
-
destination: (failedPath += fileString)
|
|
254
|
-
};
|
|
255
|
-
await manager.moveFile(config, movePaths);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
finally {
|
|
259
|
-
_d = true;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
264
|
-
finally {
|
|
265
|
-
try {
|
|
266
|
-
if (!_d && !_a && (_b = filesDirectories_1.return)) await _b.call(filesDirectories_1);
|
|
267
|
-
}
|
|
268
|
-
finally { if (e_1) throw e_1.error; }
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
exports.processSftp = processSftp;
|
|
272
|
-
async function getCustomerBizplace(customerDomainId, tx) {
|
|
273
|
-
const customerDomain = await tx.getRepository(shell_1.Domain).findOne(customerDomainId);
|
|
274
|
-
const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
|
|
275
|
-
where: { domain: customerDomain }
|
|
276
|
-
});
|
|
277
|
-
return customerBizplace;
|
|
278
|
-
}
|
|
279
|
-
exports.getCustomerBizplace = getCustomerBizplace;
|
|
280
|
-
//# sourceMappingURL=sftp-mutation.js.map
|