@things-factory/integration-sftp 5.0.7 → 6.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/controllers/herbalife/apis/create-serial-number.js.map +1 -1
- package/dist-server/controllers/herbalife/apis/create-shipment.js +42 -38
- package/dist-server/controllers/herbalife/apis/create-shipment.js.map +1 -1
- package/dist-server/controllers/herbalife/apis/echo.js.map +1 -1
- package/dist-server/controllers/herbalife/apis/get-outbound-order.js +6 -1
- package/dist-server/controllers/herbalife/apis/get-outbound-order.js.map +1 -1
- package/dist-server/controllers/herbalife/apis/index.js +5 -18
- package/dist-server/controllers/herbalife/apis/index.js.map +1 -1
- package/dist-server/controllers/herbalife/herbalife.js.map +1 -1
- package/dist-server/controllers/herbalife/index.js +3 -28
- package/dist-server/controllers/herbalife/index.js.map +1 -1
- package/dist-server/controllers/herbalife/platform-action.js.map +1 -1
- package/dist-server/controllers/index.js +2 -15
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/sftp-api/decorators.js +2 -4
- package/dist-server/controllers/sftp-api/decorators.js.map +1 -1
- package/dist-server/controllers/sftp-api/index.js +19 -27
- package/dist-server/controllers/sftp-api/index.js.map +1 -1
- package/dist-server/controllers/sftp-api/types.js.map +1 -1
- package/dist-server/index.js +6 -19
- package/dist-server/index.js.map +1 -1
- package/dist-server/middlewares/index.js.map +1 -1
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/index.js +2 -15
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/sftp/index.js.map +1 -1
- package/dist-server/service/sftp/sftp-mutation.js +157 -137
- package/dist-server/service/sftp/sftp-mutation.js.map +1 -1
- package/dist-server/service/sftp/sftp-query.js +35 -48
- package/dist-server/service/sftp/sftp-query.js.map +1 -1
- package/dist-server/service/sftp/sftp-type.js +48 -56
- package/dist-server/service/sftp/sftp-type.js.map +1 -1
- package/dist-server/service/sftp/sftp.js +52 -55
- package/dist-server/service/sftp/sftp.js.map +1 -1
- package/dist-server/sftp-const.js.map +1 -1
- package/dist-server/sftp-s3.js +2 -4
- package/dist-server/sftp-s3.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/dist-server/util/generate-files.js.map +1 -1
- package/dist-server/util/get-permitted-directories.js.map +1 -1
- package/dist-server/util/index.js +3 -16
- package/dist-server/util/index.js.map +1 -1
- package/package.json +8 -8
- package/server/controllers/herbalife/apis/create-shipment.ts +43 -42
- package/server/controllers/herbalife/apis/get-outbound-order.ts +7 -1
- package/server/controllers/sftp-api/index.ts +1 -1
- package/server/service/sftp/sftp-mutation.ts +114 -78
- package/server/service/sftp/sftp-query.ts +7 -8
- package/server/service/sftp/sftp.ts +4 -0
- package/server/util/get-permitted-directories.ts +1 -1
@@ -1,25 +1,7 @@
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
22
|
-
exports.SftpMutation = void 0;
|
3
|
+
exports.getCustomerBizplace = exports.processSftp = exports.SftpMutation = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
23
5
|
require("../../sftp-s3");
|
24
6
|
const type_graphql_1 = require("type-graphql");
|
25
7
|
const typeorm_1 = require("typeorm");
|
@@ -40,7 +22,7 @@ let SftpMutation = class SftpMutation {
|
|
40
22
|
const { domain, user, tx } = context.state;
|
41
23
|
const repository = tx.getRepository(sftp_1.Sftp);
|
42
24
|
const sftp = await repository.findOne({
|
43
|
-
where: { domain, id }
|
25
|
+
where: { domain: { id: domain.id }, id }
|
44
26
|
});
|
45
27
|
return await repository.save(Object.assign(Object.assign(Object.assign({}, sftp), patch), { updater: user }));
|
46
28
|
}
|
@@ -60,7 +42,7 @@ let SftpMutation = class SftpMutation {
|
|
60
42
|
if (_updateRecords.length > 0) {
|
61
43
|
for (let i = 0; i < _updateRecords.length; i++) {
|
62
44
|
const newRecord = _updateRecords[i];
|
63
|
-
const sftp = await sftpRepo.
|
45
|
+
const sftp = await sftpRepo.findOneBy({ id: newRecord.id });
|
64
46
|
const result = await sftpRepo.save(Object.assign(Object.assign(Object.assign({}, sftp), newRecord), { updater: user }));
|
65
47
|
results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
|
66
48
|
}
|
@@ -69,160 +51,198 @@ let SftpMutation = class SftpMutation {
|
|
69
51
|
}
|
70
52
|
async deleteSftp(id, context) {
|
71
53
|
const { domain, tx } = context.state;
|
72
|
-
await tx.getRepository(sftp_1.Sftp).delete({ domain, id });
|
54
|
+
await tx.getRepository(sftp_1.Sftp).delete({ domain: { id: domain.id }, id });
|
73
55
|
return true;
|
74
56
|
}
|
75
57
|
async deleteSftps(ids, context) {
|
76
58
|
const { domain, tx } = context.state;
|
77
59
|
await tx.getRepository(sftp_1.Sftp).delete({
|
78
|
-
domain,
|
60
|
+
domain: { id: domain.id },
|
79
61
|
id: (0, typeorm_1.In)(ids)
|
80
62
|
});
|
81
63
|
return true;
|
82
64
|
}
|
83
65
|
async syncSftpOrders(customerDomainId, context) {
|
84
66
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
85
|
-
|
86
|
-
const
|
87
|
-
const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
|
88
|
-
where: { domain: customerDomain }
|
89
|
-
});
|
90
|
-
const customerBizplaceId = customerBizplace.id;
|
67
|
+
const customerDomain = await tx.getRepository(shell_1.Domain).findOneBy({ id: customerDomainId });
|
68
|
+
const customerBizplace = await getCustomerBizplace(customerDomainId, tx);
|
91
69
|
const sftpUsers = await tx.getRepository(sftp_1.Sftp).find({
|
92
|
-
where: { domain:
|
70
|
+
where: { domain: { id: customerDomainId }, status: sftp_1.SftpStatus.ACTIVE },
|
93
71
|
relations: ['fulfillmentCenter']
|
94
72
|
});
|
95
73
|
for (var i = 0; i < sftpUsers.length; i++) {
|
96
74
|
const sftpUser = sftpUsers[i];
|
97
|
-
|
98
|
-
const isDevelopment = sftpUser.isDevelopment;
|
99
|
-
const folderPath = sftpUser.folderPath;
|
100
|
-
const folderType = isDevelopment ? 'dev' : 'prd';
|
101
|
-
let initialDataPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUBMITDATAPATH}/`;
|
102
|
-
const results = await (0, util_1.getPermittedDirectories)({ path: initialDataPath }, context);
|
103
|
-
const filesDirectories = results.filter(result => result.Size > 0);
|
104
|
-
try {
|
105
|
-
for (var filesDirectories_1 = (e_1 = void 0, __asyncValues(filesDirectories)), filesDirectories_1_1; filesDirectories_1_1 = await filesDirectories_1.next(), !filesDirectories_1_1.done;) {
|
106
|
-
let fileDirectory = filesDirectories_1_1.value;
|
107
|
-
let dataPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUBMITDATAPATH}/`;
|
108
|
-
let successPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUCCESSDATAPATH}/`;
|
109
|
-
let failedPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.FAILEDDATAPATH}/`;
|
110
|
-
const fileKey = fileDirectory.Key;
|
111
|
-
const lastSlashIdx = fileKey.lastIndexOf('/');
|
112
|
-
const fileString = fileKey.substring(lastSlashIdx + 1, fileKey.length);
|
113
|
-
try {
|
114
|
-
const sftp = sftpUser;
|
115
|
-
let result = await controllers_1.SftpAPI.getOutboundOrder(sftp, { folderPath, folderType, fileKey: fileString });
|
116
|
-
let isAccept = result.isAccept;
|
117
|
-
if (isAccept) {
|
118
|
-
delete result.isAccept;
|
119
|
-
if (result) {
|
120
|
-
let { items: releaseOrders } = await integration_fulfillment_1.FulfillmentAPI.getOutboundOrders(fulfilmentCenter, {
|
121
|
-
customerBizplaceId,
|
122
|
-
refNo: result.refNo
|
123
|
-
});
|
124
|
-
if (releaseOrders) {
|
125
|
-
result.collectionOrderNo = result.collectionOrderNo + ' - ' + (releaseOrders.length + 1);
|
126
|
-
}
|
127
|
-
result.requiredDraft = false;
|
128
|
-
const releaseOrder = await integration_fulfillment_1.FulfillmentAPI.createOutboundOrder(fulfilmentCenter, {
|
129
|
-
customerBizplaceId,
|
130
|
-
releaseOrder: result
|
131
|
-
});
|
132
|
-
if (releaseOrder) {
|
133
|
-
let movePaths = {
|
134
|
-
source: (dataPath += fileString),
|
135
|
-
destination: (successPath += fileString)
|
136
|
-
};
|
137
|
-
await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
|
138
|
-
}
|
139
|
-
}
|
140
|
-
}
|
141
|
-
else {
|
142
|
-
let movePaths = {
|
143
|
-
source: (dataPath += fileString),
|
144
|
-
destination: (failedPath += fileString)
|
145
|
-
};
|
146
|
-
await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
|
147
|
-
}
|
148
|
-
}
|
149
|
-
catch (e) {
|
150
|
-
let movePaths = {
|
151
|
-
source: (dataPath += fileString),
|
152
|
-
destination: (failedPath += fileString)
|
153
|
-
};
|
154
|
-
await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
|
155
|
-
}
|
156
|
-
}
|
157
|
-
}
|
158
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
159
|
-
finally {
|
160
|
-
try {
|
161
|
-
if (filesDirectories_1_1 && !filesDirectories_1_1.done && (_a = filesDirectories_1.return)) await _a.call(filesDirectories_1);
|
162
|
-
}
|
163
|
-
finally { if (e_1) throw e_1.error; }
|
164
|
-
}
|
75
|
+
processSftp(sftpUser, context, customerBizplace.id);
|
165
76
|
}
|
166
77
|
});
|
167
78
|
return true;
|
168
79
|
}
|
80
|
+
async syncAllSftpOrders(context) {
|
81
|
+
try {
|
82
|
+
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
83
|
+
const sftps = await tx
|
84
|
+
.getRepository(sftp_1.Sftp)
|
85
|
+
.createQueryBuilder('s')
|
86
|
+
.where('s.status = :status', { status: 'ACTIVE' })
|
87
|
+
.getMany();
|
88
|
+
if (sftps.length === 0)
|
89
|
+
return;
|
90
|
+
for (const sftp of sftps) {
|
91
|
+
const customerBizplace = await getCustomerBizplace(sftp.domainId, tx);
|
92
|
+
await processSftp(sftp, context, customerBizplace.id);
|
93
|
+
}
|
94
|
+
});
|
95
|
+
}
|
96
|
+
catch (e) {
|
97
|
+
console.log(e);
|
98
|
+
}
|
99
|
+
return true;
|
100
|
+
}
|
169
101
|
};
|
170
|
-
__decorate([
|
102
|
+
tslib_1.__decorate([
|
171
103
|
(0, type_graphql_1.Directive)('@transaction'),
|
172
104
|
(0, type_graphql_1.Mutation)(returns => sftp_1.Sftp, { description: 'To create new Sftp' }),
|
173
|
-
__param(0, (0, type_graphql_1.Arg)('sftp')),
|
174
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
175
|
-
__metadata("design:type", Function),
|
176
|
-
__metadata("design:paramtypes", [sftp_type_1.NewSftp, Object]),
|
177
|
-
__metadata("design:returntype", Promise)
|
105
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('sftp')),
|
106
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
107
|
+
tslib_1.__metadata("design:type", Function),
|
108
|
+
tslib_1.__metadata("design:paramtypes", [sftp_type_1.NewSftp, Object]),
|
109
|
+
tslib_1.__metadata("design:returntype", Promise)
|
178
110
|
], SftpMutation.prototype, "createSftp", null);
|
179
|
-
__decorate([
|
111
|
+
tslib_1.__decorate([
|
180
112
|
(0, type_graphql_1.Directive)('@transaction'),
|
181
113
|
(0, type_graphql_1.Mutation)(returns => sftp_1.Sftp, { description: 'To modify Sftp information' }),
|
182
|
-
__param(0, (0, type_graphql_1.Arg)('id')),
|
183
|
-
__param(1, (0, type_graphql_1.Arg)('patch')),
|
184
|
-
__param(2, (0, type_graphql_1.Ctx)()),
|
185
|
-
__metadata("design:type", Function),
|
186
|
-
__metadata("design:paramtypes", [String, sftp_type_1.SftpPatch, Object]),
|
187
|
-
__metadata("design:returntype", Promise)
|
114
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
115
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
116
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
117
|
+
tslib_1.__metadata("design:type", Function),
|
118
|
+
tslib_1.__metadata("design:paramtypes", [String, sftp_type_1.SftpPatch, Object]),
|
119
|
+
tslib_1.__metadata("design:returntype", Promise)
|
188
120
|
], SftpMutation.prototype, "updateSftp", null);
|
189
|
-
__decorate([
|
121
|
+
tslib_1.__decorate([
|
190
122
|
(0, type_graphql_1.Directive)('@transaction'),
|
191
123
|
(0, type_graphql_1.Mutation)(returns => [sftp_1.Sftp], { description: "To modify multiple Sftps' information" }),
|
192
|
-
__param(0, (0, type_graphql_1.Arg)('patches', type => [sftp_type_1.SftpPatch])),
|
193
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
194
|
-
__metadata("design:type", Function),
|
195
|
-
__metadata("design:paramtypes", [Array, Object]),
|
196
|
-
__metadata("design:returntype", Promise)
|
124
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [sftp_type_1.SftpPatch])),
|
125
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
126
|
+
tslib_1.__metadata("design:type", Function),
|
127
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
128
|
+
tslib_1.__metadata("design:returntype", Promise)
|
197
129
|
], SftpMutation.prototype, "updateMultipleSftp", null);
|
198
|
-
__decorate([
|
130
|
+
tslib_1.__decorate([
|
199
131
|
(0, type_graphql_1.Directive)('@transaction'),
|
200
132
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete Sftp' }),
|
201
|
-
__param(0, (0, type_graphql_1.Arg)('id')),
|
202
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
203
|
-
__metadata("design:type", Function),
|
204
|
-
__metadata("design:paramtypes", [String, Object]),
|
205
|
-
__metadata("design:returntype", Promise)
|
133
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
134
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
135
|
+
tslib_1.__metadata("design:type", Function),
|
136
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
137
|
+
tslib_1.__metadata("design:returntype", Promise)
|
206
138
|
], SftpMutation.prototype, "deleteSftp", null);
|
207
|
-
__decorate([
|
139
|
+
tslib_1.__decorate([
|
208
140
|
(0, type_graphql_1.Directive)('@transaction'),
|
209
141
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple sftps' }),
|
210
|
-
__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
211
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
212
|
-
__metadata("design:type", Function),
|
213
|
-
__metadata("design:paramtypes", [Array, Object]),
|
214
|
-
__metadata("design:returntype", Promise)
|
142
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
143
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
144
|
+
tslib_1.__metadata("design:type", Function),
|
145
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
146
|
+
tslib_1.__metadata("design:returntype", Promise)
|
215
147
|
], SftpMutation.prototype, "deleteSftps", null);
|
216
|
-
__decorate([
|
148
|
+
tslib_1.__decorate([
|
217
149
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To sync all orders from sftp' }),
|
218
|
-
__param(0, (0, type_graphql_1.Arg)('customerDomainId', type => String)),
|
219
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
220
|
-
__metadata("design:type", Function),
|
221
|
-
__metadata("design:paramtypes", [String, Object]),
|
222
|
-
__metadata("design:returntype", Promise)
|
150
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('customerDomainId', type => String)),
|
151
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
152
|
+
tslib_1.__metadata("design:type", Function),
|
153
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
154
|
+
tslib_1.__metadata("design:returntype", Promise)
|
223
155
|
], SftpMutation.prototype, "syncSftpOrders", null);
|
224
|
-
|
156
|
+
tslib_1.__decorate([
|
157
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
158
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Calls syncSftpOrders for all domain Ids' }),
|
159
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
160
|
+
tslib_1.__metadata("design:type", Function),
|
161
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
162
|
+
tslib_1.__metadata("design:returntype", Promise)
|
163
|
+
], SftpMutation.prototype, "syncAllSftpOrders", null);
|
164
|
+
SftpMutation = tslib_1.__decorate([
|
225
165
|
(0, type_graphql_1.Resolver)(sftp_1.Sftp)
|
226
166
|
], SftpMutation);
|
227
167
|
exports.SftpMutation = SftpMutation;
|
168
|
+
async function processSftp(sftpUser, context, customerBizplaceId) {
|
169
|
+
var e_1, _a;
|
170
|
+
const fulfilmentCenter = sftpUser.fulfillmentCenter;
|
171
|
+
const isDevelopment = sftpUser.isDevelopment;
|
172
|
+
const folderPath = sftpUser.folderPath;
|
173
|
+
const folderType = isDevelopment ? 'dev' : 'prd';
|
174
|
+
let initialDataPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUBMITDATAPATH}/`;
|
175
|
+
const results = await (0, util_1.getPermittedDirectories)({ path: initialDataPath }, context);
|
176
|
+
const filesDirectories = results.filter(result => result.Size > 0);
|
177
|
+
try {
|
178
|
+
for (var filesDirectories_1 = tslib_1.__asyncValues(filesDirectories), filesDirectories_1_1; filesDirectories_1_1 = await filesDirectories_1.next(), !filesDirectories_1_1.done;) {
|
179
|
+
let fileDirectory = filesDirectories_1_1.value;
|
180
|
+
let dataPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUBMITDATAPATH}/`;
|
181
|
+
let successPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUCCESSDATAPATH}/`;
|
182
|
+
let failedPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.FAILEDDATAPATH}/`;
|
183
|
+
const fileKey = fileDirectory.Key;
|
184
|
+
const lastSlashIdx = fileKey.lastIndexOf('/');
|
185
|
+
const fileString = fileKey.substring(lastSlashIdx + 1, fileKey.length);
|
186
|
+
try {
|
187
|
+
const sftp = sftpUser;
|
188
|
+
let result = await controllers_1.SftpAPI.getOutboundOrder(sftp, { folderPath, folderType, fileKey: fileString });
|
189
|
+
let isAccept = result.isAccept;
|
190
|
+
if (isAccept) {
|
191
|
+
delete result.isAccept;
|
192
|
+
if (result) {
|
193
|
+
let { items: releaseOrders } = await integration_fulfillment_1.FulfillmentAPI.getOutboundOrders(fulfilmentCenter, {
|
194
|
+
customerBizplaceId,
|
195
|
+
refNo: result.refNo
|
196
|
+
});
|
197
|
+
if (releaseOrders) {
|
198
|
+
result.collectionOrderNo = result.collectionOrderNo + ' - ' + (releaseOrders.length + 1);
|
199
|
+
}
|
200
|
+
result.requiredDraft = false;
|
201
|
+
const releaseOrder = await integration_fulfillment_1.FulfillmentAPI.createOutboundOrder(fulfilmentCenter, {
|
202
|
+
customerBizplaceId,
|
203
|
+
releaseOrder: result
|
204
|
+
});
|
205
|
+
if (releaseOrder) {
|
206
|
+
let movePaths = {
|
207
|
+
source: (dataPath += fileString),
|
208
|
+
destination: (successPath += fileString)
|
209
|
+
};
|
210
|
+
await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
|
211
|
+
}
|
212
|
+
}
|
213
|
+
}
|
214
|
+
else {
|
215
|
+
let movePaths = {
|
216
|
+
source: (dataPath += fileString),
|
217
|
+
destination: (failedPath += fileString)
|
218
|
+
};
|
219
|
+
await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
|
220
|
+
}
|
221
|
+
}
|
222
|
+
catch (e) {
|
223
|
+
let movePaths = {
|
224
|
+
source: (dataPath += fileString),
|
225
|
+
destination: (failedPath += fileString)
|
226
|
+
};
|
227
|
+
await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
|
228
|
+
}
|
229
|
+
}
|
230
|
+
}
|
231
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
232
|
+
finally {
|
233
|
+
try {
|
234
|
+
if (filesDirectories_1_1 && !filesDirectories_1_1.done && (_a = filesDirectories_1.return)) await _a.call(filesDirectories_1);
|
235
|
+
}
|
236
|
+
finally { if (e_1) throw e_1.error; }
|
237
|
+
}
|
238
|
+
}
|
239
|
+
exports.processSftp = processSftp;
|
240
|
+
async function getCustomerBizplace(customerDomainId, tx) {
|
241
|
+
const customerDomain = await tx.getRepository(shell_1.Domain).findOneBy({ id: customerDomainId });
|
242
|
+
const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
|
243
|
+
where: { domain: customerDomain }
|
244
|
+
});
|
245
|
+
return customerBizplace;
|
246
|
+
}
|
247
|
+
exports.getCustomerBizplace = getCustomerBizplace;
|
228
248
|
//# sourceMappingURL=sftp-mutation.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sftp-mutation.js","sourceRoot":"","sources":["../../../server/service/sftp/sftp-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAsB;AAEtB,+CAAsE;AACtE,qCAA0D;AAE1D,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,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,WAAI,CAAC,CAAC,IAAI,iCACnC,IAAI,KACP,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAID,KAAK,CAAC,UAAU,CAAY,EAAU,EAAgB,KAAgB,EAAS,OAAY;QACzF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,WAAI,CAAC,CAAA;QACzC,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YACpC,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;SACtB,CAAC,CAAA;QAEF,OAAO,MA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AAO,CAAC;QAC1E,KAAK,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE;KAClC,CAAC,CAAA;IAEF,OAAO,gBAAgB,CAAA;AACzB,CAAC;AARD,kDAQC","sourcesContent":["import '../../sftp-s3'\n\nimport { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { EntityManager, getConnection, In } from 'typeorm'\n\nimport { Bizplace } from '@things-factory/biz-base'\nimport { FulfillmentAPI, FulfillmentCenter } from '@things-factory/integration-fulfillment'\nimport { Domain } from '@things-factory/shell'\n\nimport { SftpAPI } from '../../controllers'\nimport { FAILEDDATAPATH, SFTPFILESTORAGE, SUBMITDATAPATH, SUCCESSDATAPATH } from '../../sftp-const'\nimport { getPermittedDirectories } from '../../util'\nimport { Sftp, SftpStatus } from './sftp'\nimport { NewSftp, SftpPatch } from './sftp-type'\n\n@Resolver(Sftp)\nexport class SftpMutation {\n @Directive('@transaction')\n @Mutation(returns => Sftp, { description: 'To create new Sftp' })\n async createSftp(@Arg('sftp') sftp: NewSftp, @Ctx() context: ResolverContext): Promise<Sftp> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Sftp).save({\n ...sftp,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Sftp, { description: 'To modify Sftp information' })\n async updateSftp(\n @Arg('id') id: string,\n @Arg('patch') patch: SftpPatch,\n @Ctx() context: ResolverContext\n ): Promise<Sftp> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Sftp)\n const sftp = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n return await repository.save({\n ...sftp,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Sftp], { description: \"To modify multiple Sftps' information\" })\n async updateMultipleSftp(\n @Arg('patches', type => [SftpPatch]) patches: SftpPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Sftp[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const sftpRepo = tx.getRepository(Sftp)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await sftpRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const sftp = await sftpRepo.findOneBy({ id: newRecord.id })\n\n const result = await sftpRepo.save({\n ...sftp,\n ...newRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete Sftp' })\n async deleteSftp(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Sftp).delete({ domain: { id: domain.id }, id })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple sftps' })\n async deleteSftps(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Sftp).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Mutation(returns => Boolean, { description: 'To sync all orders from sftp' })\n async syncSftpOrders(\n @Arg('customerDomainId', type => String) customerDomainId: string,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n await getConnection().transaction(async (tx: EntityManager) => {\n const customerDomain: Domain = await tx.getRepository(Domain).findOneBy({ id: customerDomainId })\n\n const customerBizplace: Bizplace = await getCustomerBizplace(customerDomainId, tx)\n\n const sftpUsers: Sftp[] = await tx.getRepository(Sftp).find({\n where: { domain: { id: customerDomainId }, status: SftpStatus.ACTIVE },\n relations: ['fulfillmentCenter']\n })\n\n for (var i = 0; i < sftpUsers.length; i++) {\n const sftpUser: Sftp = sftpUsers[i]\n processSftp(sftpUser, context, customerBizplace.id)\n }\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'Calls syncSftpOrders for all domain Ids' })\n async syncAllSftpOrders(@Ctx() context: ResolverContext): Promise<Boolean> {\n try {\n await getConnection().transaction(async tx => {\n const sftps = await tx\n .getRepository(Sftp)\n .createQueryBuilder('s')\n .where('s.status = :status', { status: 'ACTIVE' })\n .getMany()\n\n if (sftps.length === 0) return\n for (const sftp of sftps) {\n const customerBizplace = await getCustomerBizplace(sftp.domainId, tx)\n await processSftp(sftp, context, customerBizplace.id)\n }\n })\n } catch (e) {\n console.log(e)\n }\n return true\n }\n}\n\nexport async function processSftp(sftpUser, context, customerBizplaceId) {\n const fulfilmentCenter: FulfillmentCenter = sftpUser.fulfillmentCenter\n const isDevelopment: boolean = sftpUser.isDevelopment\n const folderPath: string = sftpUser.folderPath\n const folderType: string = isDevelopment ? 'dev' : 'prd'\n let initialDataPath: string = `${sftpUser.folderPath}/${folderType}${SUBMITDATAPATH}/`\n const results: any[] = await getPermittedDirectories({ path: initialDataPath }, context)\n const filesDirectories: any[] = results.filter(result => result.Size > 0)\n\n for await (let fileDirectory of filesDirectories) {\n let dataPath: string = `${sftpUser.folderPath}/${folderType}${SUBMITDATAPATH}/`\n let successPath: string = `${sftpUser.folderPath}/${folderType}${SUCCESSDATAPATH}/`\n let failedPath: string = `${sftpUser.folderPath}/${folderType}${FAILEDDATAPATH}/`\n const fileKey: string = fileDirectory.Key\n const lastSlashIdx = fileKey.lastIndexOf('/')\n const fileString: string = fileKey.substring(lastSlashIdx + 1, fileKey.length)\n try {\n const sftp: any = sftpUser\n let result: any = await SftpAPI.getOutboundOrder(sftp, { folderPath, folderType, fileKey: fileString })\n let isAccept: boolean = result.isAccept\n\n if (isAccept) {\n delete result.isAccept\n if (result) {\n let { items: releaseOrders }: any = await FulfillmentAPI.getOutboundOrders(fulfilmentCenter, {\n customerBizplaceId,\n refNo: result.refNo\n })\n\n if (releaseOrders) {\n result.collectionOrderNo = result.collectionOrderNo + ' - ' + (releaseOrders.length + 1)\n }\n\n result.requiredDraft = false\n\n const releaseOrder: any = await FulfillmentAPI.createOutboundOrder(fulfilmentCenter, {\n customerBizplaceId,\n releaseOrder: result\n })\n\n if (releaseOrder) {\n let movePaths = {\n source: (dataPath += fileString),\n destination: (successPath += fileString)\n }\n await SFTPFILESTORAGE.moveFile(movePaths)\n }\n }\n } else {\n let movePaths = {\n source: (dataPath += fileString),\n destination: (failedPath += fileString)\n }\n await SFTPFILESTORAGE.moveFile(movePaths)\n }\n } catch (e) {\n let movePaths = {\n source: (dataPath += fileString),\n destination: (failedPath += fileString)\n }\n await SFTPFILESTORAGE.moveFile(movePaths)\n }\n }\n}\n\nexport async function getCustomerBizplace(customerDomainId, tx): Promise<Bizplace> {\n const customerDomain: Domain = await tx.getRepository(Domain).findOneBy({ id: customerDomainId })\n\n const customerBizplace: Bizplace = await tx.getRepository(Bizplace).findOne({\n where: { domain: customerDomain }\n })\n\n return customerBizplace\n}\n"]}
|
@@ -1,21 +1,8 @@
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
16
3
|
exports.SftpQuery = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
17
5
|
const type_graphql_1 = require("type-graphql");
|
18
|
-
const typeorm_1 = require("typeorm");
|
19
6
|
const auth_base_1 = require("@things-factory/auth-base");
|
20
7
|
const shell_1 = require("@things-factory/shell");
|
21
8
|
const sftp_1 = require("./sftp");
|
@@ -23,64 +10,64 @@ const sftp_type_1 = require("./sftp-type");
|
|
23
10
|
let SftpQuery = class SftpQuery {
|
24
11
|
async sftp(id, context) {
|
25
12
|
const { domain } = context.state;
|
26
|
-
return await (0,
|
27
|
-
where: { domain, id }
|
13
|
+
return await (0, shell_1.getRepository)(sftp_1.Sftp).findOne({
|
14
|
+
where: { domain: { id: domain.id }, id }
|
28
15
|
});
|
29
16
|
}
|
30
17
|
async sftps(params, context) {
|
31
18
|
const { domain } = context.state;
|
32
19
|
const convertedParams = (0, shell_1.convertListParams)(params, { domain });
|
33
|
-
const [items, total] = await (0,
|
20
|
+
const [items, total] = await (0, shell_1.getRepository)(sftp_1.Sftp).findAndCount(convertedParams);
|
34
21
|
return { items, total };
|
35
22
|
}
|
36
23
|
async domain(sftp) {
|
37
|
-
return await (0,
|
24
|
+
return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: sftp.domainId });
|
38
25
|
}
|
39
26
|
async updater(sftp) {
|
40
|
-
return await (0,
|
27
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: sftp.updaterId });
|
41
28
|
}
|
42
29
|
async creator(sftp) {
|
43
|
-
return await (0,
|
30
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: sftp.creatorId });
|
44
31
|
}
|
45
32
|
};
|
46
|
-
__decorate([
|
33
|
+
tslib_1.__decorate([
|
47
34
|
(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)
|
35
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
36
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
37
|
+
tslib_1.__metadata("design:type", Function),
|
38
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
39
|
+
tslib_1.__metadata("design:returntype", Promise)
|
53
40
|
], SftpQuery.prototype, "sftp", null);
|
54
|
-
__decorate([
|
41
|
+
tslib_1.__decorate([
|
55
42
|
(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", [
|
60
|
-
__metadata("design:returntype", Promise)
|
43
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
44
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
45
|
+
tslib_1.__metadata("design:type", Function),
|
46
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
47
|
+
tslib_1.__metadata("design:returntype", Promise)
|
61
48
|
], SftpQuery.prototype, "sftps", null);
|
62
|
-
__decorate([
|
49
|
+
tslib_1.__decorate([
|
63
50
|
(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)
|
51
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
52
|
+
tslib_1.__metadata("design:type", Function),
|
53
|
+
tslib_1.__metadata("design:paramtypes", [sftp_1.Sftp]),
|
54
|
+
tslib_1.__metadata("design:returntype", Promise)
|
68
55
|
], SftpQuery.prototype, "domain", null);
|
69
|
-
__decorate([
|
56
|
+
tslib_1.__decorate([
|
70
57
|
(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)
|
58
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
59
|
+
tslib_1.__metadata("design:type", Function),
|
60
|
+
tslib_1.__metadata("design:paramtypes", [sftp_1.Sftp]),
|
61
|
+
tslib_1.__metadata("design:returntype", Promise)
|
75
62
|
], SftpQuery.prototype, "updater", null);
|
76
|
-
__decorate([
|
63
|
+
tslib_1.__decorate([
|
77
64
|
(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)
|
65
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
66
|
+
tslib_1.__metadata("design:type", Function),
|
67
|
+
tslib_1.__metadata("design:paramtypes", [sftp_1.Sftp]),
|
68
|
+
tslib_1.__metadata("design:returntype", Promise)
|
82
69
|
], SftpQuery.prototype, "creator", null);
|
83
|
-
SftpQuery = __decorate([
|
70
|
+
SftpQuery = tslib_1.__decorate([
|
84
71
|
(0, type_graphql_1.Resolver)(sftp_1.Sftp)
|
85
72
|
], SftpQuery);
|
86
73
|
exports.SftpQuery = SftpQuery;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sftp-query.js","sourceRoot":"","sources":["../../../server/service/sftp/sftp-query.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3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,CAAC,OAAO,CAAS,IAAU;QAC9B,OAAO,MAAM,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;IACpE,CAAC;CACF,CAAA;AAhCC;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,WAAI,EAAE,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IAC/C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;qCAMvC;AAGD;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,oBAAQ,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IAC1D,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;sCAOpC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,WAAI;;uCAE9B;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,WAAI;;wCAE/B;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,WAAI;;wCAE/B;AAjCU,SAAS;IADrB,IAAA,uBAAQ,EAAC,WAAI,CAAC;GACF,SAAS,CAkCrB;AAlCY,8BAAS","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\nimport { convertListParams, Domain, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Sftp } from './sftp'\nimport { SftpList } from './sftp-type'\n\n@Resolver(Sftp)\nexport class SftpQuery {\n @Query(returns => Sftp, { description: 'To fetch a Sftp' })\n async sftp(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Sftp> {\n const { domain } = context.state\n\n return await getRepository(Sftp).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => SftpList, { description: 'To fetch multiple Sftps' })\n async sftps(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<SftpList> {\n const { domain } = context.state\n\n const convertedParams = convertListParams(params, { domain })\n const [items, total] = await getRepository(Sftp).findAndCount(convertedParams)\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() sftp: Sftp): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: sftp.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() sftp: Sftp): Promise<User> {\n return await getRepository(User).findOneBy({ id: sftp.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() sftp: Sftp): Promise<User> {\n return await getRepository(User).findOneBy({ id: sftp.creatorId })\n }\n}\n"]}
|