@things-factory/integration-sftp 3.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +21 -0
  3. package/client/bootstrap.js +1 -0
  4. package/client/index.js +0 -0
  5. package/client/pages/main.js +25 -0
  6. package/client/route.js +10 -0
  7. package/client/themes/app-theme.css +59 -0
  8. package/config/config.development.js +1 -0
  9. package/config/config.production.js +1 -0
  10. package/dist-server/controllers/herbalife/apis/echo.js +19 -0
  11. package/dist-server/controllers/herbalife/apis/echo.js.map +1 -0
  12. package/dist-server/controllers/herbalife/apis/get-outbound-order.js +73 -0
  13. package/dist-server/controllers/herbalife/apis/get-outbound-order.js.map +1 -0
  14. package/dist-server/controllers/herbalife/apis/index.js +15 -0
  15. package/dist-server/controllers/herbalife/apis/index.js.map +1 -0
  16. package/dist-server/controllers/herbalife/herbalife.js +20 -0
  17. package/dist-server/controllers/herbalife/herbalife.js.map +1 -0
  18. package/dist-server/controllers/herbalife/index.js +30 -0
  19. package/dist-server/controllers/herbalife/index.js.map +1 -0
  20. package/dist-server/controllers/herbalife/platform-action.js +30 -0
  21. package/dist-server/controllers/herbalife/platform-action.js.map +1 -0
  22. package/dist-server/controllers/index.js +15 -0
  23. package/dist-server/controllers/index.js.map +1 -0
  24. package/dist-server/controllers/sftp-api/decorators.js +30 -0
  25. package/dist-server/controllers/sftp-api/decorators.js.map +1 -0
  26. package/dist-server/controllers/sftp-api/index.js +50 -0
  27. package/dist-server/controllers/sftp-api/index.js.map +1 -0
  28. package/dist-server/controllers/sftp-api/types.js +1 -0
  29. package/dist-server/controllers/sftp-api/types.js.map +1 -0
  30. package/dist-server/index.js +18 -0
  31. package/dist-server/index.js.map +1 -0
  32. package/dist-server/middlewares/index.js +8 -0
  33. package/dist-server/middlewares/index.js.map +1 -0
  34. package/dist-server/routes.js +25 -0
  35. package/dist-server/routes.js.map +1 -0
  36. package/dist-server/service/index.js +28 -0
  37. package/dist-server/service/index.js.map +1 -0
  38. package/dist-server/service/sftp/index.js +9 -0
  39. package/dist-server/service/sftp/index.js.map +1 -0
  40. package/dist-server/service/sftp/sftp-mutation.js +191 -0
  41. package/dist-server/service/sftp/sftp-mutation.js.map +1 -0
  42. package/dist-server/service/sftp/sftp-query.js +87 -0
  43. package/dist-server/service/sftp/sftp-query.js.map +1 -0
  44. package/dist-server/service/sftp/sftp-type.js +113 -0
  45. package/dist-server/service/sftp/sftp-type.js.map +1 -0
  46. package/dist-server/service/sftp/sftp.js +131 -0
  47. package/dist-server/service/sftp/sftp.js.map +1 -0
  48. package/dist-server/sftp-const.js +9 -0
  49. package/dist-server/sftp-const.js.map +1 -0
  50. package/dist-server/sftp-s3.js +53 -0
  51. package/dist-server/sftp-s3.js.map +1 -0
  52. package/dist-server/util/get-permitted-directories.js +16 -0
  53. package/dist-server/util/get-permitted-directories.js.map +1 -0
  54. package/dist-server/util/index.js +14 -0
  55. package/dist-server/util/index.js.map +1 -0
  56. package/package.json +36 -0
  57. package/server/controllers/herbalife/apis/echo.ts +14 -0
  58. package/server/controllers/herbalife/apis/get-outbound-order.ts +76 -0
  59. package/server/controllers/herbalife/apis/index.ts +2 -0
  60. package/server/controllers/herbalife/herbalife.ts +22 -0
  61. package/server/controllers/herbalife/index.ts +7 -0
  62. package/server/controllers/herbalife/platform-action.ts +34 -0
  63. package/server/controllers/index.ts +3 -0
  64. package/server/controllers/sftp-api/decorators.ts +43 -0
  65. package/server/controllers/sftp-api/index.ts +33 -0
  66. package/server/controllers/sftp-api/types.ts +0 -0
  67. package/server/index.ts +6 -0
  68. package/server/middlewares/index.ts +3 -0
  69. package/server/routes.ts +28 -0
  70. package/server/service/index.ts +18 -0
  71. package/server/service/sftp/index.ts +6 -0
  72. package/server/service/sftp/sftp-mutation.ts +185 -0
  73. package/server/service/sftp/sftp-query.ts +45 -0
  74. package/server/service/sftp/sftp-type.ts +72 -0
  75. package/server/service/sftp/sftp.ts +106 -0
  76. package/server/sftp-const.ts +6 -0
  77. package/server/sftp-s3.ts +64 -0
  78. package/server/util/get-permitted-directories.ts +15 -0
  79. package/server/util/index.ts +1 -0
  80. package/things-factory.config.js +13 -0
  81. package/translations/en.json +1 -0
  82. package/translations/ko.json +1 -0
  83. package/translations/ms.json +1 -0
  84. package/translations/zh.json +1 -0
  85. package/tsconfig.json +9 -0
@@ -0,0 +1,191 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.SftpMutation = void 0;
16
+ require("../../sftp-s3");
17
+ const type_graphql_1 = require("type-graphql");
18
+ const typeorm_1 = require("typeorm");
19
+ const biz_base_1 = require("@things-factory/biz-base");
20
+ const integration_fulfillment_1 = require("@things-factory/integration-fulfillment");
21
+ const shell_1 = require("@things-factory/shell");
22
+ const controllers_1 = require("../../controllers");
23
+ const sftp_const_1 = require("../../sftp-const");
24
+ const util_1 = require("../../util");
25
+ const sftp_1 = require("./sftp");
26
+ const sftp_type_1 = require("./sftp-type");
27
+ let SftpMutation = class SftpMutation {
28
+ async createSftp(sftp, context) {
29
+ const { domain, user, tx } = context.state;
30
+ return await tx.getRepository(sftp_1.Sftp).save(Object.assign(Object.assign({}, sftp), { domain, creator: user, updater: user }));
31
+ }
32
+ async updateSftp(id, patch, context) {
33
+ const { domain, user, tx } = context.state;
34
+ const repository = tx.getRepository(sftp_1.Sftp);
35
+ const sftp = await repository.findOne({
36
+ where: { domain, id }
37
+ });
38
+ return await repository.save(Object.assign(Object.assign(Object.assign({}, sftp), patch), { updater: user }));
39
+ }
40
+ async updateMultipleSftp(patches, context) {
41
+ const { domain, user, tx } = context.state;
42
+ let results = [];
43
+ const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
44
+ const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
45
+ const sftpRepo = tx.getRepository(sftp_1.Sftp);
46
+ if (_createRecords.length > 0) {
47
+ for (let i = 0; i < _createRecords.length; i++) {
48
+ const newRecord = _createRecords[i];
49
+ const result = await sftpRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
50
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
51
+ }
52
+ }
53
+ if (_updateRecords.length > 0) {
54
+ for (let i = 0; i < _updateRecords.length; i++) {
55
+ const newRecord = _updateRecords[i];
56
+ const sftp = await sftpRepo.findOne(newRecord.id);
57
+ const result = await sftpRepo.save(Object.assign(Object.assign(Object.assign({}, sftp), newRecord), { updater: user }));
58
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
59
+ }
60
+ }
61
+ return results;
62
+ }
63
+ async deleteSftp(id, context) {
64
+ const { domain, tx } = context.state;
65
+ await tx.getRepository(sftp_1.Sftp).delete({ domain, id });
66
+ return true;
67
+ }
68
+ async deleteSftps(ids, context) {
69
+ const { domain, tx } = context.state;
70
+ await tx.getRepository(sftp_1.Sftp).delete({
71
+ domain,
72
+ id: (0, typeorm_1.In)(ids)
73
+ });
74
+ return true;
75
+ }
76
+ async syncSftpOrders(customerDomainId, context) {
77
+ const { tx } = context.state;
78
+ const customerDomain = await tx.getRepository(shell_1.Domain).findOne(customerDomainId);
79
+ const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
80
+ where: { domain: customerDomain }
81
+ });
82
+ const customerBizplaceId = customerBizplace.id;
83
+ const sftpUsers = await tx.getRepository(sftp_1.Sftp).find({
84
+ where: { domain: customerDomain },
85
+ relations: ['fulfillmentCenter']
86
+ });
87
+ for (var i = 0; i < sftpUsers.length; i++) {
88
+ const sftpUser = sftpUsers[i];
89
+ const fulfilmentCenter = sftpUser.fulfillmentCenter;
90
+ const isDevelopment = sftpUser.isDevelopment;
91
+ const folderPath = sftpUser.folderPath;
92
+ const folderType = isDevelopment ? 'development' : 'production';
93
+ let dataPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUBMITDATAPATH}/`;
94
+ let successPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUCCESSDATAPATH}/`;
95
+ let failedPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.FAILEDDATAPATH}/`;
96
+ const results = await (0, util_1.getPermittedDirectories)({ path: dataPath }, context);
97
+ const filesDirectories = results.filter(result => result.Size > 0);
98
+ for (var j = 0; j < filesDirectories.length; j++) {
99
+ const fileDirectory = filesDirectories[j];
100
+ const fileKey = fileDirectory.Key;
101
+ const lastSlashIdx = fileKey.lastIndexOf('/');
102
+ const fileString = fileKey.substring(lastSlashIdx + 1, fileKey.length);
103
+ try {
104
+ const sftp = { platform: sftpUser.platform };
105
+ const result = await controllers_1.SftpAPI.getOutboundOrder(sftp, { folderPath, folderType, fileKey: fileString });
106
+ if (result) {
107
+ var releaseOrder = await integration_fulfillment_1.FulfillmentAPI.createOutboundOrder(fulfilmentCenter, {
108
+ customerBizplaceId,
109
+ releaseOrder: result
110
+ });
111
+ if (releaseOrder) {
112
+ let movePaths = {
113
+ source: dataPath += fileString,
114
+ destination: successPath += fileString
115
+ };
116
+ await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
117
+ }
118
+ }
119
+ }
120
+ catch (e) {
121
+ let movePaths = {
122
+ source: dataPath += fileString,
123
+ destination: failedPath += fileString
124
+ };
125
+ await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
126
+ }
127
+ }
128
+ }
129
+ return true;
130
+ }
131
+ };
132
+ __decorate([
133
+ (0, type_graphql_1.Directive)('@transaction'),
134
+ (0, type_graphql_1.Mutation)(returns => sftp_1.Sftp, { description: 'To create new Sftp' }),
135
+ __param(0, (0, type_graphql_1.Arg)('sftp')),
136
+ __param(1, (0, type_graphql_1.Ctx)()),
137
+ __metadata("design:type", Function),
138
+ __metadata("design:paramtypes", [sftp_type_1.NewSftp, Object]),
139
+ __metadata("design:returntype", Promise)
140
+ ], SftpMutation.prototype, "createSftp", null);
141
+ __decorate([
142
+ (0, type_graphql_1.Directive)('@transaction'),
143
+ (0, type_graphql_1.Mutation)(returns => sftp_1.Sftp, { description: 'To modify Sftp information' }),
144
+ __param(0, (0, type_graphql_1.Arg)('id')),
145
+ __param(1, (0, type_graphql_1.Arg)('patch')),
146
+ __param(2, (0, type_graphql_1.Ctx)()),
147
+ __metadata("design:type", Function),
148
+ __metadata("design:paramtypes", [String, sftp_type_1.SftpPatch, Object]),
149
+ __metadata("design:returntype", Promise)
150
+ ], SftpMutation.prototype, "updateSftp", null);
151
+ __decorate([
152
+ (0, type_graphql_1.Directive)('@transaction'),
153
+ (0, type_graphql_1.Mutation)(returns => [sftp_1.Sftp], { description: "To modify multiple Sftps' information" }),
154
+ __param(0, (0, type_graphql_1.Arg)('patches', type => [sftp_type_1.SftpPatch])),
155
+ __param(1, (0, type_graphql_1.Ctx)()),
156
+ __metadata("design:type", Function),
157
+ __metadata("design:paramtypes", [Array, Object]),
158
+ __metadata("design:returntype", Promise)
159
+ ], SftpMutation.prototype, "updateMultipleSftp", null);
160
+ __decorate([
161
+ (0, type_graphql_1.Directive)('@transaction'),
162
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete Sftp' }),
163
+ __param(0, (0, type_graphql_1.Arg)('id')),
164
+ __param(1, (0, type_graphql_1.Ctx)()),
165
+ __metadata("design:type", Function),
166
+ __metadata("design:paramtypes", [String, Object]),
167
+ __metadata("design:returntype", Promise)
168
+ ], SftpMutation.prototype, "deleteSftp", null);
169
+ __decorate([
170
+ (0, type_graphql_1.Directive)('@transaction'),
171
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple sftps' }),
172
+ __param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
173
+ __param(1, (0, type_graphql_1.Ctx)()),
174
+ __metadata("design:type", Function),
175
+ __metadata("design:paramtypes", [Array, Object]),
176
+ __metadata("design:returntype", Promise)
177
+ ], SftpMutation.prototype, "deleteSftps", null);
178
+ __decorate([
179
+ (0, type_graphql_1.Directive)('@transaction'),
180
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To sync all orders from sftp' }),
181
+ __param(0, (0, type_graphql_1.Arg)('customerDomainId', type => String)),
182
+ __param(1, (0, type_graphql_1.Ctx)()),
183
+ __metadata("design:type", Function),
184
+ __metadata("design:paramtypes", [String, Object]),
185
+ __metadata("design:returntype", Promise)
186
+ ], SftpMutation.prototype, "syncSftpOrders", null);
187
+ SftpMutation = __decorate([
188
+ (0, type_graphql_1.Resolver)(sftp_1.Sftp)
189
+ ], SftpMutation);
190
+ exports.SftpMutation = SftpMutation;
191
+ //# sourceMappingURL=sftp-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sftp-mutation.js","sourceRoot":"","sources":["../../../server/service/sftp/sftp-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yBAAsB;AAEtB,+CAAsE;AACtE,qCAA4B;AAE5B,uDAAmD;AACnD,qFAA2F;AAC3F,iDAA8C;AAE9C,mDAA2C;AAC3C,iDAAmG;AACnG,qCAAoD;AACpD,iCAA6B;AAC7B,2CAAgD;AAGhD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAGvB,KAAK,CAAC,UAAU,CAAc,IAAa,EAAS,OAAY;QAC9D,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AC;IAEnF,WAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,qBAAS,CAAC,CAAC,CAAA;IACnC,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;sDAwCP;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAC9C,WAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;8CAK7C;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;IACvD,WAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAiB,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;+CASpE;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAE3E,WAAA,IAAA,kBAAG,EAAC,kBAAkB,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAA;IACvC,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;kDAgEP;AAvKU,YAAY;IADxB,IAAA,uBAAQ,EAAC,WAAI,CAAC;GACF,YAAY,CAwKxB;AAxKY,oCAAY"}
@@ -0,0 +1,87 @@
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 _a;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.SftpQuery = void 0;
17
+ const type_graphql_1 = require("type-graphql");
18
+ const typeorm_1 = require("typeorm");
19
+ const auth_base_1 = require("@things-factory/auth-base");
20
+ const shell_1 = require("@things-factory/shell");
21
+ const sftp_1 = require("./sftp");
22
+ const sftp_type_1 = require("./sftp-type");
23
+ let SftpQuery = class SftpQuery {
24
+ async sftp(id, context) {
25
+ const { domain } = context.state;
26
+ return await (0, typeorm_1.getRepository)(sftp_1.Sftp).findOne({
27
+ where: { domain, id }
28
+ });
29
+ }
30
+ async sftps(params, context) {
31
+ const { domain } = context.state;
32
+ const convertedParams = (0, shell_1.convertListParams)(params, domain.id);
33
+ const [items, total] = await (0, typeorm_1.getRepository)(sftp_1.Sftp).findAndCount(convertedParams);
34
+ return { items, total };
35
+ }
36
+ async domain(sftp) {
37
+ return await (0, typeorm_1.getRepository)(shell_1.Domain).findOne(sftp.domainId);
38
+ }
39
+ async updater(sftp) {
40
+ return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(sftp.updaterId);
41
+ }
42
+ async creator(sftp) {
43
+ return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(sftp.creatorId);
44
+ }
45
+ };
46
+ __decorate([
47
+ (0, type_graphql_1.Query)(returns => sftp_1.Sftp, { description: 'To fetch a Sftp' }),
48
+ __param(0, (0, type_graphql_1.Arg)('id')),
49
+ __param(1, (0, type_graphql_1.Ctx)()),
50
+ __metadata("design:type", Function),
51
+ __metadata("design:paramtypes", [String, Object]),
52
+ __metadata("design:returntype", Promise)
53
+ ], SftpQuery.prototype, "sftp", null);
54
+ __decorate([
55
+ (0, type_graphql_1.Query)(returns => sftp_type_1.SftpList, { description: 'To fetch multiple Sftps' }),
56
+ __param(0, (0, type_graphql_1.Args)()),
57
+ __param(1, (0, type_graphql_1.Ctx)()),
58
+ __metadata("design:type", Function),
59
+ __metadata("design:paramtypes", [typeof (_a = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _a : Object, Object]),
60
+ __metadata("design:returntype", Promise)
61
+ ], SftpQuery.prototype, "sftps", null);
62
+ __decorate([
63
+ (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
64
+ __param(0, (0, type_graphql_1.Root)()),
65
+ __metadata("design:type", Function),
66
+ __metadata("design:paramtypes", [sftp_1.Sftp]),
67
+ __metadata("design:returntype", Promise)
68
+ ], SftpQuery.prototype, "domain", null);
69
+ __decorate([
70
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
71
+ __param(0, (0, type_graphql_1.Root)()),
72
+ __metadata("design:type", Function),
73
+ __metadata("design:paramtypes", [sftp_1.Sftp]),
74
+ __metadata("design:returntype", Promise)
75
+ ], SftpQuery.prototype, "updater", null);
76
+ __decorate([
77
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
78
+ __param(0, (0, type_graphql_1.Root)()),
79
+ __metadata("design:type", Function),
80
+ __metadata("design:paramtypes", [sftp_1.Sftp]),
81
+ __metadata("design:returntype", Promise)
82
+ ], SftpQuery.prototype, "creator", null);
83
+ SftpQuery = __decorate([
84
+ (0, type_graphql_1.Resolver)(sftp_1.Sftp)
85
+ ], SftpQuery);
86
+ exports.SftpQuery = SftpQuery;
87
+ //# sourceMappingURL=sftp-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sftp-query.js","sourceRoot":"","sources":["../../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AAC,SAAS,CAAC,CAAA;IAC1D,CAAC;CACF,CAAA;AAhCC;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,WAAI,EAAE,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IAC/C,WAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;qCAMvC;AAGD;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,oBAAQ,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IAC1D,WAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,WAAA,IAAA,kBAAG,GAAE,CAAA;;yDAAjB,iBAAS,oBAAT,iBAAS;;sCAOpC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,WAAA,IAAA,mBAAI,GAAE,CAAA;;qCAAO,WAAI;;uCAE9B;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,WAAA,IAAA,mBAAI,GAAE,CAAA;;qCAAO,WAAI;;wCAE/B;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,WAAA,IAAA,mBAAI,GAAE,CAAA;;qCAAO,WAAI;;wCAE/B;AAjCU,SAAS;IADrB,IAAA,uBAAQ,EAAC,WAAI,CAAC;GACF,SAAS,CAkCrB;AAlCY,8BAAS"}
@@ -0,0 +1,113 @@
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.SftpList = exports.SftpPatch = exports.NewSftp = void 0;
13
+ const type_graphql_1 = require("type-graphql");
14
+ const sftp_1 = require("./sftp");
15
+ let NewSftp = class NewSftp {
16
+ };
17
+ __decorate([
18
+ (0, type_graphql_1.Field)(),
19
+ __metadata("design:type", String)
20
+ ], NewSftp.prototype, "name", void 0);
21
+ __decorate([
22
+ (0, type_graphql_1.Field)({ nullable: true }),
23
+ __metadata("design:type", String)
24
+ ], NewSftp.prototype, "description", void 0);
25
+ __decorate([
26
+ (0, type_graphql_1.Field)({ nullable: true }),
27
+ __metadata("design:type", String)
28
+ ], NewSftp.prototype, "username", void 0);
29
+ __decorate([
30
+ (0, type_graphql_1.Field)({ nullable: true }),
31
+ __metadata("design:type", String)
32
+ ], NewSftp.prototype, "publicKey", void 0);
33
+ __decorate([
34
+ (0, type_graphql_1.Field)({ nullable: true }),
35
+ __metadata("design:type", String)
36
+ ], NewSftp.prototype, "privateKey", void 0);
37
+ __decorate([
38
+ (0, type_graphql_1.Field)({ nullable: true }),
39
+ __metadata("design:type", String)
40
+ ], NewSftp.prototype, "folderPath", void 0);
41
+ __decorate([
42
+ (0, type_graphql_1.Field)({ nullable: true }),
43
+ __metadata("design:type", Boolean)
44
+ ], NewSftp.prototype, "isDevelopment", void 0);
45
+ __decorate([
46
+ (0, type_graphql_1.Field)({ nullable: true }),
47
+ __metadata("design:type", String)
48
+ ], NewSftp.prototype, "platform", void 0);
49
+ NewSftp = __decorate([
50
+ (0, type_graphql_1.InputType)()
51
+ ], NewSftp);
52
+ exports.NewSftp = NewSftp;
53
+ let SftpPatch = class SftpPatch {
54
+ };
55
+ __decorate([
56
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
57
+ __metadata("design:type", String)
58
+ ], SftpPatch.prototype, "id", void 0);
59
+ __decorate([
60
+ (0, type_graphql_1.Field)({ nullable: true }),
61
+ __metadata("design:type", String)
62
+ ], SftpPatch.prototype, "name", void 0);
63
+ __decorate([
64
+ (0, type_graphql_1.Field)({ nullable: true }),
65
+ __metadata("design:type", String)
66
+ ], SftpPatch.prototype, "description", void 0);
67
+ __decorate([
68
+ (0, type_graphql_1.Field)({ nullable: true }),
69
+ __metadata("design:type", String)
70
+ ], SftpPatch.prototype, "username", void 0);
71
+ __decorate([
72
+ (0, type_graphql_1.Field)({ nullable: true }),
73
+ __metadata("design:type", String)
74
+ ], SftpPatch.prototype, "publicKey", void 0);
75
+ __decorate([
76
+ (0, type_graphql_1.Field)({ nullable: true }),
77
+ __metadata("design:type", String)
78
+ ], SftpPatch.prototype, "privateKey", void 0);
79
+ __decorate([
80
+ (0, type_graphql_1.Field)({ nullable: true }),
81
+ __metadata("design:type", String)
82
+ ], SftpPatch.prototype, "folderPath", void 0);
83
+ __decorate([
84
+ (0, type_graphql_1.Field)({ nullable: true }),
85
+ __metadata("design:type", Boolean)
86
+ ], SftpPatch.prototype, "isDevelopment", void 0);
87
+ __decorate([
88
+ (0, type_graphql_1.Field)({ nullable: true }),
89
+ __metadata("design:type", String)
90
+ ], SftpPatch.prototype, "platform", void 0);
91
+ __decorate([
92
+ (0, type_graphql_1.Field)(),
93
+ __metadata("design:type", String)
94
+ ], SftpPatch.prototype, "cuFlag", void 0);
95
+ SftpPatch = __decorate([
96
+ (0, type_graphql_1.InputType)()
97
+ ], SftpPatch);
98
+ exports.SftpPatch = SftpPatch;
99
+ let SftpList = class SftpList {
100
+ };
101
+ __decorate([
102
+ (0, type_graphql_1.Field)(type => [sftp_1.Sftp]),
103
+ __metadata("design:type", Array)
104
+ ], SftpList.prototype, "items", void 0);
105
+ __decorate([
106
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int),
107
+ __metadata("design:type", Number)
108
+ ], SftpList.prototype, "total", void 0);
109
+ SftpList = __decorate([
110
+ (0, type_graphql_1.ObjectType)()
111
+ ], SftpList);
112
+ exports.SftpList = SftpList;
113
+ //# sourceMappingURL=sftp-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sftp-type.js","sourceRoot":"","sources":["../../../server/service/sftp/sftp-type.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAoE;AAEpE,iCAA6B;AAG7B,IAAa,OAAO,GAApB,MAAa,OAAO;CAwBnB,CAAA;AAtBC;IADC,IAAA,oBAAK,GAAE;;qCACI;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACT;AAGjB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACR;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACP;AAGnB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACP;AAGnB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACH;AAGvB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACT;AAvBN,OAAO;IADnB,IAAA,wBAAS,GAAE;GACC,OAAO,CAwBnB;AAxBY,0BAAO;AA2BpB,IAAa,SAAS,GAAtB,MAAa,SAAS;CA8BrB,CAAA;AA5BC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qCAC3B;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCACb;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACT;AAGjB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACR;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACP;AAGnB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACP;AAGnB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACH;AAGvB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACT;AAGjB;IADC,IAAA,oBAAK,GAAE;;yCACM;AA7BH,SAAS;IADrB,IAAA,wBAAS,GAAE;GACC,SAAS,CA8BrB;AA9BY,8BAAS;AAiCtB,IAAa,QAAQ,GAArB,MAAa,QAAQ;CAMpB,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,WAAI,CAAC,CAAC;;uCACT;AAGb;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;uCACN;AALF,QAAQ;IADpB,IAAA,yBAAU,GAAE;GACA,QAAQ,CAMpB;AANY,4BAAQ"}
@@ -0,0 +1,131 @@
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 _a, _b, _c, _d;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.Sftp = void 0;
14
+ const type_graphql_1 = require("type-graphql");
15
+ const typeorm_1 = require("typeorm");
16
+ const auth_base_1 = require("@things-factory/auth-base");
17
+ const integration_fulfillment_1 = require("@things-factory/integration-fulfillment");
18
+ const shell_1 = require("@things-factory/shell");
19
+ let Sftp = class Sftp {
20
+ };
21
+ __decorate([
22
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
23
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID),
24
+ __metadata("design:type", String)
25
+ ], Sftp.prototype, "id", void 0);
26
+ __decorate([
27
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
28
+ (0, type_graphql_1.Field)({ nullable: true }),
29
+ __metadata("design:type", typeof (_a = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _a : Object)
30
+ ], Sftp.prototype, "domain", void 0);
31
+ __decorate([
32
+ (0, typeorm_1.RelationId)((sftp) => sftp.domain),
33
+ __metadata("design:type", String)
34
+ ], Sftp.prototype, "domainId", void 0);
35
+ __decorate([
36
+ (0, typeorm_1.Column)(),
37
+ (0, type_graphql_1.Field)(),
38
+ __metadata("design:type", String)
39
+ ], Sftp.prototype, "name", void 0);
40
+ __decorate([
41
+ (0, typeorm_1.Column)({
42
+ nullable: true
43
+ }),
44
+ (0, type_graphql_1.Field)({ nullable: true }),
45
+ __metadata("design:type", String)
46
+ ], Sftp.prototype, "description", void 0);
47
+ __decorate([
48
+ (0, typeorm_1.Column)({
49
+ nullable: true
50
+ }),
51
+ (0, type_graphql_1.Field)({ nullable: true }),
52
+ __metadata("design:type", String)
53
+ ], Sftp.prototype, "username", void 0);
54
+ __decorate([
55
+ (0, typeorm_1.Column)({
56
+ nullable: true
57
+ }),
58
+ (0, type_graphql_1.Field)({ nullable: true }),
59
+ __metadata("design:type", String)
60
+ ], Sftp.prototype, "publicKey", void 0);
61
+ __decorate([
62
+ (0, typeorm_1.Column)({
63
+ nullable: true
64
+ }),
65
+ (0, type_graphql_1.Field)({ nullable: true }),
66
+ __metadata("design:type", String)
67
+ ], Sftp.prototype, "privateKey", void 0);
68
+ __decorate([
69
+ (0, typeorm_1.Column)({
70
+ nullable: true
71
+ }),
72
+ (0, type_graphql_1.Field)({ nullable: true }),
73
+ __metadata("design:type", String)
74
+ ], Sftp.prototype, "folderPath", void 0);
75
+ __decorate([
76
+ (0, typeorm_1.Column)({
77
+ nullable: true
78
+ }),
79
+ (0, type_graphql_1.Field)({ nullable: true }),
80
+ __metadata("design:type", Boolean)
81
+ ], Sftp.prototype, "isDevelopment", void 0);
82
+ __decorate([
83
+ (0, typeorm_1.Column)({
84
+ nullable: true
85
+ }),
86
+ (0, type_graphql_1.Field)({ nullable: true }),
87
+ __metadata("design:type", String)
88
+ ], Sftp.prototype, "platform", void 0);
89
+ __decorate([
90
+ (0, typeorm_1.ManyToOne)(type => integration_fulfillment_1.FulfillmentCenter, { nullable: true }),
91
+ __metadata("design:type", typeof (_b = typeof integration_fulfillment_1.FulfillmentCenter !== "undefined" && integration_fulfillment_1.FulfillmentCenter) === "function" ? _b : Object)
92
+ ], Sftp.prototype, "fulfillmentCenter", void 0);
93
+ __decorate([
94
+ (0, typeorm_1.CreateDateColumn)(),
95
+ (0, type_graphql_1.Field)({ nullable: true }),
96
+ __metadata("design:type", Date)
97
+ ], Sftp.prototype, "createdAt", void 0);
98
+ __decorate([
99
+ (0, typeorm_1.UpdateDateColumn)(),
100
+ (0, type_graphql_1.Field)({ nullable: true }),
101
+ __metadata("design:type", Date)
102
+ ], Sftp.prototype, "updatedAt", void 0);
103
+ __decorate([
104
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, {
105
+ nullable: true
106
+ }),
107
+ (0, type_graphql_1.Field)({ nullable: true }),
108
+ __metadata("design:type", typeof (_c = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _c : Object)
109
+ ], Sftp.prototype, "creator", void 0);
110
+ __decorate([
111
+ (0, typeorm_1.RelationId)((sftp) => sftp.creator),
112
+ __metadata("design:type", String)
113
+ ], Sftp.prototype, "creatorId", void 0);
114
+ __decorate([
115
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, {
116
+ nullable: true
117
+ }),
118
+ (0, type_graphql_1.Field)({ nullable: true }),
119
+ __metadata("design:type", typeof (_d = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _d : Object)
120
+ ], Sftp.prototype, "updater", void 0);
121
+ __decorate([
122
+ (0, typeorm_1.RelationId)((sftp) => sftp.creator),
123
+ __metadata("design:type", String)
124
+ ], Sftp.prototype, "updaterId", void 0);
125
+ Sftp = __decorate([
126
+ (0, typeorm_1.Entity)(),
127
+ (0, typeorm_1.Index)('ix_sftp_0', (sftp) => [sftp.domain, sftp.name], { unique: true }),
128
+ (0, type_graphql_1.ObjectType)({ description: 'Entity for Sftp' })
129
+ ], Sftp);
130
+ exports.Sftp = Sftp;
131
+ //# sourceMappingURL=sftp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sftp.js","sourceRoot":"","sources":["../../../server/service/sftp/sftp.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAoD;AACpD,qCASgB;AAEhB,yDAAgD;AAChD,qFAA2E;AAC3E,iDAA8C;AAK9C,IAAa,IAAI,GAAjB,MAAa,IAAI;CAsFhB,CAAA;AAnFC;IAFC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;gCACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,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1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FAILEDDATAPATH = exports.SUCCESSDATAPATH = exports.SUBMITDATAPATH = exports.SFTPFILESTORAGE = void 0;
4
+ const env_1 = require("@things-factory/env");
5
+ exports.SFTPFILESTORAGE = env_1.config.get('sftpFileStorage');
6
+ exports.SUBMITDATAPATH = '/submit_outbound/data';
7
+ exports.SUCCESSDATAPATH = '/submit_outbound/success';
8
+ exports.FAILEDDATAPATH = '/submit_outbound/failed';
9
+ //# sourceMappingURL=sftp-const.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sftp-const.js","sourceRoot":"","sources":["../server/sftp-const.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAEjC,QAAA,eAAe,GAAQ,YAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;AACpD,QAAA,cAAc,GAAW,uBAAuB,CAAA;AAChD,QAAA,eAAe,GAAW,0BAA0B,CAAA;AACpD,QAAA,cAAc,GAAW,yBAAyB,CAAA"}
@@ -0,0 +1,53 @@
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
+ const aws_sdk_1 = __importDefault(require("aws-sdk"));
7
+ const env_1 = require("@things-factory/env");
8
+ const sftp_const_1 = require("./sftp-const");
9
+ const { PassThrough } = require('stream');
10
+ const mime = require('mime');
11
+ const { fs } = require('memfs');
12
+ if (sftp_const_1.SFTPFILESTORAGE && sftp_const_1.SFTPFILESTORAGE.type == 's3') {
13
+ const S3 = new aws_sdk_1.default.S3({
14
+ accessKeyId: sftp_const_1.SFTPFILESTORAGE.accessKeyId,
15
+ secretAccessKey: sftp_const_1.SFTPFILESTORAGE.secretAccessKey
16
+ });
17
+ sftp_const_1.SFTPFILESTORAGE.readFolders = async (params, encoding) => {
18
+ var S3params = {
19
+ Bucket: sftp_const_1.SFTPFILESTORAGE.bucketName,
20
+ Delimiter: '/',
21
+ Prefix: params.path
22
+ };
23
+ const result = await S3.listObjects(S3params).promise();
24
+ var body = result.Contents;
25
+ return body;
26
+ };
27
+ sftp_const_1.SFTPFILESTORAGE.readFile = async (path, encoding) => {
28
+ const result = await S3.getObject({
29
+ Bucket: sftp_const_1.SFTPFILESTORAGE.bucketName,
30
+ Key: path
31
+ }).promise();
32
+ var body = result.Body;
33
+ if (encoding) {
34
+ return body.toString(encoding);
35
+ }
36
+ return body;
37
+ };
38
+ sftp_const_1.SFTPFILESTORAGE.moveFile = async (path, encoding) => {
39
+ const copyResult = await S3.copyObject({
40
+ Bucket: sftp_const_1.SFTPFILESTORAGE.bucketName,
41
+ CopySource: sftp_const_1.SFTPFILESTORAGE.bucketName + '/' + path.source,
42
+ Key: path.destination
43
+ }).promise();
44
+ var copyBody = copyResult.CopyObjectResult;
45
+ const deleteResult = await S3.deleteObject({
46
+ Bucket: sftp_const_1.SFTPFILESTORAGE.bucketName,
47
+ Key: path.source
48
+ }).promise();
49
+ return true;
50
+ };
51
+ env_1.logger.info('S3 Bucket Storage is Ready.');
52
+ }
53
+ //# sourceMappingURL=sftp-s3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sftp-s3.js","sourceRoot":"","sources":["../server/sftp-s3.ts"],"names":[],"mappings":";;;;;AAAA,sDAAyB;AAEzB,6CAA4C;AAE5C,6CAA8C;AAE9C,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AACzC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAE/B,IAAI,4BAAe,IAAI,4BAAe,CAAC,IAAI,IAAI,IAAI,EAAE;IACnD,MAAM,EAAE,GAAG,IAAI,iBAAG,CAAC,EAAE,CAAC;QACpB,WAAW,EAAE,4BAAe,CAAC,WAAW;QAC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GAAG,MAAM,EAAE,CAAC,YAAY,CAAC;YACzC,MAAM,EAAE,4BAAe,CAAC,UAAU;YAClC,GAAG,EAAE,IAAI,CAAC,MAAM;SACjB,CAAC,CAAC,OAAO,EAAE,CAAA;QAEZ,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IAED,YAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAA;CAC3C"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readFile = exports.getPermittedDirectories = void 0;
4
+ require("../sftp-s3");
5
+ const sftp_const_1 = require("../sftp-const");
6
+ async function getPermittedDirectories(params, context) {
7
+ const sftpDirectories = await sftp_const_1.SFTPFILESTORAGE.readFolders(params);
8
+ return sftpDirectories;
9
+ }
10
+ exports.getPermittedDirectories = getPermittedDirectories;
11
+ async function readFile(fileKey) {
12
+ const file = await sftp_const_1.SFTPFILESTORAGE.readFile(fileKey, 'utf-8');
13
+ return file;
14
+ }
15
+ exports.readFile = readFile;
16
+ //# sourceMappingURL=get-permitted-directories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-permitted-directories.js","sourceRoot":"","sources":["../../server/util/get-permitted-directories.ts"],"names":[],"mappings":";;;AAAA,sBAAmB;AAEnB,8CAA+C;AAExC,KAAK,UAAU,uBAAuB,CAAC,MAAW,EAAE,OAAY;IACrE,MAAM,eAAe,GAAU,MAAM,4BAAe,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IAExE,OAAO,eAAe,CAAA;AACxB,CAAC;AAJD,0DAIC;AAEM,KAAK,UAAU,QAAQ,CAAC,OAAY;IACzC,MAAM,IAAI,GAAQ,MAAM,4BAAe,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAElE,OAAO,IAAI,CAAA;AACb,CAAC;AAJD,4BAIC"}