@decaf-ts/integrations 0.7.0 → 0.8.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/integrations.cjs +1 -1
- package/lib/cjs/index.cjs +3 -3
- package/lib/cjs/sftp/aws/AwsSftpService.cjs +120 -0
- package/lib/cjs/sftp/aws/AwsSftpService.cjs.map +1 -0
- package/lib/cjs/sftp/core/SftpSource.cjs +29 -0
- package/lib/cjs/sftp/core/SftpSource.cjs.map +1 -0
- package/lib/cjs/sftp/core/index.cjs +19 -0
- package/lib/cjs/sftp/core/index.cjs.map +1 -0
- package/lib/cjs/sftp/index.cjs +21 -0
- package/lib/cjs/sftp/index.cjs.map +1 -0
- package/lib/cjs/sftp/ssh2/Ssh2SftpService.cjs +172 -0
- package/lib/cjs/sftp/ssh2/Ssh2SftpService.cjs.map +1 -0
- package/lib/esm/index.js +3 -3
- package/lib/esm/sftp/aws/AwsSftpService.js +82 -0
- package/lib/esm/sftp/aws/AwsSftpService.js.map +1 -0
- package/lib/esm/sftp/core/SftpSource.js +23 -0
- package/lib/esm/sftp/core/SftpSource.js.map +1 -0
- package/lib/esm/sftp/core/index.js +2 -0
- package/lib/esm/sftp/core/index.js.map +1 -0
- package/lib/esm/sftp/index.js +4 -0
- package/lib/esm/sftp/index.js.map +1 -0
- package/lib/esm/sftp/ssh2/Ssh2SftpService.js +135 -0
- package/lib/esm/sftp/ssh2/Ssh2SftpService.js.map +1 -0
- package/lib/types/index.d.cts +2 -2
- package/lib/types/index.d.mts +2 -2
- package/lib/types/sftp/aws/AwsSftpService.d.cts +37 -0
- package/lib/types/sftp/aws/AwsSftpService.d.mts +37 -0
- package/lib/types/sftp/core/SftpSource.d.cts +40 -0
- package/lib/types/sftp/core/SftpSource.d.mts +40 -0
- package/lib/types/sftp/core/index.d.cts +1 -0
- package/lib/types/sftp/core/index.d.mts +1 -0
- package/lib/types/sftp/index.d.cts +3 -0
- package/lib/types/sftp/index.d.mts +3 -0
- package/lib/types/sftp/ssh2/Ssh2SftpService.d.cts +47 -0
- package/lib/types/sftp/ssh2/Ssh2SftpService.d.mts +47 -0
- package/package.json +15 -3
|
@@ -0,0 +1,172 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Ssh2SftpService = void 0;
|
|
37
|
+
const core_1 = require("@decaf-ts/core");
|
|
38
|
+
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
39
|
+
const SftpSource_js_1 = require("./../core/SftpSource.cjs");
|
|
40
|
+
class Ssh2SftpService extends SftpSource_js_1.SftpSource {
|
|
41
|
+
constructor() {
|
|
42
|
+
super();
|
|
43
|
+
}
|
|
44
|
+
async initialize(...args) {
|
|
45
|
+
const config = args[0];
|
|
46
|
+
if (!config || config instanceof core_1.Context)
|
|
47
|
+
throw new db_decorators_1.InternalError(`No configuration provided`);
|
|
48
|
+
(0, SftpSource_js_1.assertSftpConfig)(config);
|
|
49
|
+
const Client = await Promise.resolve().then(() => __importStar(require("ssh2"))).then((m) => m.Client)
|
|
50
|
+
.catch(() => {
|
|
51
|
+
throw new db_decorators_1.InternalError("ssh2 package not installed; run npm install ssh2");
|
|
52
|
+
});
|
|
53
|
+
const client = new Client();
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
client.on("error", (err) => reject(new db_decorators_1.InternalError(`SFTP connection error: ${err.message}`)));
|
|
56
|
+
client.on("ready", () => {
|
|
57
|
+
client.sftp((err, sftp) => {
|
|
58
|
+
if (err)
|
|
59
|
+
return reject(new db_decorators_1.InternalError(`SFTP subsystem error: ${err.message}`));
|
|
60
|
+
this.sftp = sftp;
|
|
61
|
+
resolve({ config, client });
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
client.connect({
|
|
65
|
+
host: config.host,
|
|
66
|
+
port: config.port ?? 22,
|
|
67
|
+
username: config.username,
|
|
68
|
+
password: config.password,
|
|
69
|
+
privateKey: config.privateKey
|
|
70
|
+
? Buffer.from(config.privateKey)
|
|
71
|
+
: undefined,
|
|
72
|
+
passphrase: config.passphrase,
|
|
73
|
+
readyTimeout: config.readyTimeout ?? 30_000,
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async list(remoteDir,
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
79
|
+
...args) {
|
|
80
|
+
const dir = remoteDir ?? this.config.remotePath ?? ".";
|
|
81
|
+
const sftp = this.requireSftp();
|
|
82
|
+
return new Promise((resolve, reject) => {
|
|
83
|
+
sftp.readdir(dir, (err, list) => {
|
|
84
|
+
if (err)
|
|
85
|
+
return reject(new db_decorators_1.InternalError(`SFTP readdir error: ${err.message}`));
|
|
86
|
+
resolve(list.map((entry) => ({
|
|
87
|
+
path: `${dir}/${entry.filename}`,
|
|
88
|
+
name: entry.filename,
|
|
89
|
+
size: entry.attrs.size,
|
|
90
|
+
modifyTime: entry.attrs.mtime * 1000,
|
|
91
|
+
isDirectory: (entry.attrs.mode & 0o170000) === 0o040000,
|
|
92
|
+
})));
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async fetch(remotePath,
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
98
|
+
...args) {
|
|
99
|
+
const sftp = this.requireSftp();
|
|
100
|
+
const name = remotePath.split("/").pop() ?? remotePath;
|
|
101
|
+
const stat = await new Promise((resolve, reject) => {
|
|
102
|
+
sftp.stat(remotePath, (err, st) => {
|
|
103
|
+
if (err)
|
|
104
|
+
return reject(new db_decorators_1.InternalError(`SFTP stat error: ${err.message}`));
|
|
105
|
+
resolve(st);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
const handle = await new Promise((resolve, reject) => {
|
|
109
|
+
sftp.open(remotePath, "r", (err, h) => {
|
|
110
|
+
if (err)
|
|
111
|
+
return reject(new db_decorators_1.InternalError(`SFTP open error: ${err.message}`));
|
|
112
|
+
resolve(h);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
const chunkSize = 32_768;
|
|
116
|
+
const chunks = [];
|
|
117
|
+
let position = 0;
|
|
118
|
+
while (position < stat.size) {
|
|
119
|
+
const buf = Buffer.alloc(Math.min(chunkSize, stat.size - position));
|
|
120
|
+
const bytesRead = await new Promise((resolve, reject) => {
|
|
121
|
+
sftp.read(handle, buf, 0, buf.length, position, (err, n) => {
|
|
122
|
+
if (err)
|
|
123
|
+
return reject(new db_decorators_1.InternalError(`SFTP read error: ${err.message}`));
|
|
124
|
+
resolve(n);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
chunks.push(Buffer.from(buf.buffer, 0, bytesRead));
|
|
128
|
+
position += bytesRead;
|
|
129
|
+
if (bytesRead === 0)
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
await new Promise((resolve, reject) => {
|
|
133
|
+
sftp.close(handle, (err) => {
|
|
134
|
+
if (err)
|
|
135
|
+
return reject(new db_decorators_1.InternalError(`SFTP close error: ${err.message}`));
|
|
136
|
+
resolve();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
return {
|
|
140
|
+
path: remotePath,
|
|
141
|
+
name,
|
|
142
|
+
content: Buffer.concat(chunks),
|
|
143
|
+
size: stat.size,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
async delete(remotePath,
|
|
147
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
148
|
+
...args) {
|
|
149
|
+
const sftp = this.requireSftp();
|
|
150
|
+
return new Promise((resolve, reject) => {
|
|
151
|
+
sftp.unlink(remotePath, (err) => {
|
|
152
|
+
if (err)
|
|
153
|
+
return reject(new db_decorators_1.InternalError(`SFTP unlink error: ${err.message}`));
|
|
154
|
+
resolve();
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
159
|
+
async close(...args) {
|
|
160
|
+
this.sftp?.end();
|
|
161
|
+
this.client?.end();
|
|
162
|
+
this.sftp = undefined;
|
|
163
|
+
}
|
|
164
|
+
requireSftp() {
|
|
165
|
+
if (!this.sftp)
|
|
166
|
+
throw new db_decorators_1.InternalError("SftpSource not initialized; call initialize() first");
|
|
167
|
+
return this.sftp;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.Ssh2SftpService = Ssh2SftpService;
|
|
171
|
+
//# sourceMappingURL=Ssh2SftpService.js.map
|
|
172
|
+
//# sourceMappingURL=Ssh2SftpService.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sftp/ssh2/Ssh2SftpService.cjs","sourceRoot":"","sources":["sftp/ssh2/Ssh2SftpService.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA0C;AAC1C,2DAAwD;AACxD,2DAAwE;AACxE,MAAa,eAAgB,SAAQ,0BAAU;IAC3C;QACI,KAAK,EAAE,CAAC;IACZ,CAAC;IACD,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI;QACpB,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,IAAI,MAAM,YAAY,cAAO;YACpC,MAAM,IAAI,6BAAa,CAAC,2BAA2B,CAAC,CAAC;QACzD,IAAA,gCAAgB,EAAC,MAAM,CAAC,CAAC;QACzB,MAAM,MAAM,GAAG,MAAM,kDAAO,MAAM,IAC7B,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;aACrB,KAAK,CAAC,GAAG,EAAE;YACZ,MAAM,IAAI,6BAAa,CAAC,kDAAkD,CAAC,CAAC;QAChF,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QAC5B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,6BAAa,CAAC,0BAA0B,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;YAChG,MAAM,C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,0CAkIC;AACD,2CAA2C"}
|
package/lib/esm/index.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
export * from "./utils.js";
|
|
7
7
|
export * from "./namespaces/index.js";
|
|
8
8
|
export * from "./feature-flags/index.js";
|
|
9
|
-
export const VERSION = "0.
|
|
10
|
-
export const COMMIT = "
|
|
11
|
-
export const FULL_VERSION = "0.
|
|
9
|
+
export const VERSION = "0.7.0";
|
|
10
|
+
export const COMMIT = "2a891e0";
|
|
11
|
+
export const FULL_VERSION = "0.7.0-2a891e0";
|
|
12
12
|
export const PACKAGE_NAME = "@decaf-ts/integrations";
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Context, } from "@decaf-ts/core";
|
|
2
|
+
import { InternalError } from "@decaf-ts/db-decorators";
|
|
3
|
+
import { SftpSource, assertSftpConfig, } from "./../core/SftpSource.js";
|
|
4
|
+
export class AwsSftpService extends SftpSource {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
}
|
|
8
|
+
async initialize(...args) {
|
|
9
|
+
const config = args[0];
|
|
10
|
+
if (!config || config instanceof Context)
|
|
11
|
+
throw new InternalError(`No configuration provided`);
|
|
12
|
+
assertSftpConfig(config);
|
|
13
|
+
if (!config.region)
|
|
14
|
+
throw new InternalError("AwsTransferSftpConfig.region is required");
|
|
15
|
+
if (!config.bucket)
|
|
16
|
+
throw new InternalError("AwsTransferSftpConfig.bucket is required");
|
|
17
|
+
const { S3Client } = await import("@aws-sdk/client-s3").catch(() => {
|
|
18
|
+
throw new InternalError("@aws-sdk/client-s3 not installed; run npm install @aws-sdk/client-s3");
|
|
19
|
+
});
|
|
20
|
+
const client = new S3Client({
|
|
21
|
+
region: config.region,
|
|
22
|
+
});
|
|
23
|
+
return { config, client };
|
|
24
|
+
}
|
|
25
|
+
s3Prefix() {
|
|
26
|
+
return this.config.s3Prefix ?? this.config.remotePath ?? "";
|
|
27
|
+
}
|
|
28
|
+
async list(remoteDir,
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
30
|
+
...args) {
|
|
31
|
+
const prefix = remoteDir ?? this.s3Prefix();
|
|
32
|
+
const entries = [];
|
|
33
|
+
let cursor;
|
|
34
|
+
do {
|
|
35
|
+
const page = await this.client.listObjectsV2({
|
|
36
|
+
Bucket: this.config.bucket,
|
|
37
|
+
Prefix: prefix,
|
|
38
|
+
ContinuationToken: cursor,
|
|
39
|
+
});
|
|
40
|
+
for (const obj of page.Contents ?? []) {
|
|
41
|
+
if (!obj.Key)
|
|
42
|
+
continue;
|
|
43
|
+
const name = obj.Key.split("/").pop() ?? obj.Key;
|
|
44
|
+
entries.push({
|
|
45
|
+
path: obj.Key,
|
|
46
|
+
name,
|
|
47
|
+
size: obj.Size ?? 0,
|
|
48
|
+
modifyTime: obj.LastModified?.getTime() ?? 0,
|
|
49
|
+
isDirectory: obj.Key.endsWith("/"),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
cursor = page.NextContinuationToken;
|
|
53
|
+
} while (cursor);
|
|
54
|
+
return entries;
|
|
55
|
+
}
|
|
56
|
+
async fetch(remotePath,
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
58
|
+
...args) {
|
|
59
|
+
const name = remotePath.split("/").pop() ?? remotePath;
|
|
60
|
+
const response = await this.client.getObject({
|
|
61
|
+
Bucket: this.config.bucket,
|
|
62
|
+
Key: remotePath,
|
|
63
|
+
});
|
|
64
|
+
const chunks = [];
|
|
65
|
+
for await (const chunk of response.body) {
|
|
66
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
67
|
+
}
|
|
68
|
+
const content = Buffer.concat(chunks);
|
|
69
|
+
return { path: remotePath, name, content, size: content.length };
|
|
70
|
+
}
|
|
71
|
+
async delete(remotePath,
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
73
|
+
...args) {
|
|
74
|
+
await this.client.deleteObject({
|
|
75
|
+
Bucket: this.config.bucket,
|
|
76
|
+
Key: remotePath,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
80
|
+
async close(...args) { }
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=AwsSftpService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AwsSftpService.js","sourceRoot":"","sources":["../../../../src/sftp/aws/AwsSftpService.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,GAGR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EACL,UAAU,EAIV,gBAAgB,GACjB,gCAA2B;AAqB5B,MAAM,OAAO,cAAe,SAAQ,UAGnC;IACC;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAEQ,KAAK,CAAC,UAAU,CACvB,GAAG,IAAyB;QAE5B,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,IAAI,MAAM,YAAY,OAAO;YACtC,MAAM,IAAI,aAAa,CAAC,2BAA2B,CAAC,CAAC;QACvD,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,MAAM;YAChB,MAAM,IAAI,aAAa,CAAC,0CAA0C,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,CAAC,MAAM;YAChB,MAAM,IAAI,aAAa,CAAC,0CAA0C,CAAC,CAAC;QAEtE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YACjE,MAAM,IAAI,aAAa,CACrB,sEAAsE,CACvE,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC;YAC1B,MAAM,EAAE,MAAM,CAAC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"@decaf-ts/db-decorators";
|
|
3
|
+
export class SftpSource extends ClientBasedService {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
}
|
|
7
|
+
get provider() {
|
|
8
|
+
return this.config.provider;
|
|
9
|
+
}
|
|
10
|
+
get sourceId() {
|
|
11
|
+
return this.config.sourceId;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function assertSftpConfig(config) {
|
|
15
|
+
if (!config.host)
|
|
16
|
+
throw new InternalError("SftpSourceConfig.host is required");
|
|
17
|
+
if (!config.username)
|
|
18
|
+
throw new InternalError("SftpSourceConfig.username is required");
|
|
19
|
+
if (!config.password && !config.privateKey) {
|
|
20
|
+
throw new InternalError("SftpSourceConfig requires either password or privateKey");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=SftpSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SftpSource.js","sourceRoot":"","sources":["../../../../src/sftp/core/SftpSource.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAGnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AA+BxD,MAAM,OAAgB,UAGpB,SAAQ,kBAAoC;IAC5C;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC9B,CAAC;CAsBF;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAwB;IACvD,IAAI,CAAC,MAAM,CAAC,IAAI;QAAE,MAAM,IAAI,aAAa,CAAC,mCAAmC,CAAC,CAAC;IAC/E,IAAI,CAAC,MAAM,CAAC,QAAQ;QAAE,MAAM,IAAI,aAAa,CAAC,uCAAuC,CAAC,CAAC;IACvF,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QAC3C,MAAM,IAAI,aAAa,CAAC,yDAAyD,CAAC,CAAC;IACrF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/sftp/core/index.ts"],"names":[],"mappings":"AAAA,gCAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sftp/index.ts"],"names":[],"mappings":"AAAA,0CAAuC;AACvC,wCAAqC;AACrC,qCAAkC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Context, } from "@decaf-ts/core";
|
|
2
|
+
import { InternalError } from "@decaf-ts/db-decorators";
|
|
3
|
+
import { SftpSource, assertSftpConfig, } from "./../core/SftpSource.js";
|
|
4
|
+
export class Ssh2SftpService extends SftpSource {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
}
|
|
8
|
+
async initialize(...args) {
|
|
9
|
+
const config = args[0];
|
|
10
|
+
if (!config || config instanceof Context)
|
|
11
|
+
throw new InternalError(`No configuration provided`);
|
|
12
|
+
assertSftpConfig(config);
|
|
13
|
+
const Client = await import("ssh2")
|
|
14
|
+
.then((m) => m.Client)
|
|
15
|
+
.catch(() => {
|
|
16
|
+
throw new InternalError("ssh2 package not installed; run npm install ssh2");
|
|
17
|
+
});
|
|
18
|
+
const client = new Client();
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
client.on("error", (err) => reject(new InternalError(`SFTP connection error: ${err.message}`)));
|
|
21
|
+
client.on("ready", () => {
|
|
22
|
+
client.sftp((err, sftp) => {
|
|
23
|
+
if (err)
|
|
24
|
+
return reject(new InternalError(`SFTP subsystem error: ${err.message}`));
|
|
25
|
+
this.sftp = sftp;
|
|
26
|
+
resolve({ config, client });
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
client.connect({
|
|
30
|
+
host: config.host,
|
|
31
|
+
port: config.port ?? 22,
|
|
32
|
+
username: config.username,
|
|
33
|
+
password: config.password,
|
|
34
|
+
privateKey: config.privateKey
|
|
35
|
+
? Buffer.from(config.privateKey)
|
|
36
|
+
: undefined,
|
|
37
|
+
passphrase: config.passphrase,
|
|
38
|
+
readyTimeout: config.readyTimeout ?? 30_000,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async list(remoteDir,
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
|
+
...args) {
|
|
45
|
+
const dir = remoteDir ?? this.config.remotePath ?? ".";
|
|
46
|
+
const sftp = this.requireSftp();
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
sftp.readdir(dir, (err, list) => {
|
|
49
|
+
if (err)
|
|
50
|
+
return reject(new InternalError(`SFTP readdir error: ${err.message}`));
|
|
51
|
+
resolve(list.map((entry) => ({
|
|
52
|
+
path: `${dir}/${entry.filename}`,
|
|
53
|
+
name: entry.filename,
|
|
54
|
+
size: entry.attrs.size,
|
|
55
|
+
modifyTime: entry.attrs.mtime * 1000,
|
|
56
|
+
isDirectory: (entry.attrs.mode & 0o170000) === 0o040000,
|
|
57
|
+
})));
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async fetch(remotePath,
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
63
|
+
...args) {
|
|
64
|
+
const sftp = this.requireSftp();
|
|
65
|
+
const name = remotePath.split("/").pop() ?? remotePath;
|
|
66
|
+
const stat = await new Promise((resolve, reject) => {
|
|
67
|
+
sftp.stat(remotePath, (err, st) => {
|
|
68
|
+
if (err)
|
|
69
|
+
return reject(new InternalError(`SFTP stat error: ${err.message}`));
|
|
70
|
+
resolve(st);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
const handle = await new Promise((resolve, reject) => {
|
|
74
|
+
sftp.open(remotePath, "r", (err, h) => {
|
|
75
|
+
if (err)
|
|
76
|
+
return reject(new InternalError(`SFTP open error: ${err.message}`));
|
|
77
|
+
resolve(h);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
const chunkSize = 32_768;
|
|
81
|
+
const chunks = [];
|
|
82
|
+
let position = 0;
|
|
83
|
+
while (position < stat.size) {
|
|
84
|
+
const buf = Buffer.alloc(Math.min(chunkSize, stat.size - position));
|
|
85
|
+
const bytesRead = await new Promise((resolve, reject) => {
|
|
86
|
+
sftp.read(handle, buf, 0, buf.length, position, (err, n) => {
|
|
87
|
+
if (err)
|
|
88
|
+
return reject(new InternalError(`SFTP read error: ${err.message}`));
|
|
89
|
+
resolve(n);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
chunks.push(Buffer.from(buf.buffer, 0, bytesRead));
|
|
93
|
+
position += bytesRead;
|
|
94
|
+
if (bytesRead === 0)
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
await new Promise((resolve, reject) => {
|
|
98
|
+
sftp.close(handle, (err) => {
|
|
99
|
+
if (err)
|
|
100
|
+
return reject(new InternalError(`SFTP close error: ${err.message}`));
|
|
101
|
+
resolve();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
path: remotePath,
|
|
106
|
+
name,
|
|
107
|
+
content: Buffer.concat(chunks),
|
|
108
|
+
size: stat.size,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async delete(remotePath,
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
113
|
+
...args) {
|
|
114
|
+
const sftp = this.requireSftp();
|
|
115
|
+
return new Promise((resolve, reject) => {
|
|
116
|
+
sftp.unlink(remotePath, (err) => {
|
|
117
|
+
if (err)
|
|
118
|
+
return reject(new InternalError(`SFTP unlink error: ${err.message}`));
|
|
119
|
+
resolve();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
124
|
+
async close(...args) {
|
|
125
|
+
this.sftp?.end();
|
|
126
|
+
this.client?.end();
|
|
127
|
+
this.sftp = undefined;
|
|
128
|
+
}
|
|
129
|
+
requireSftp() {
|
|
130
|
+
if (!this.sftp)
|
|
131
|
+
throw new InternalError("SftpSource not initialized; call initialize() first");
|
|
132
|
+
return this.sftp;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=Ssh2SftpService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Ssh2SftpService.js","sourceRoot":"","sources":["../../../../src/sftp/ssh2/Ssh2SftpService.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,GAGR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EACL,UAAU,EAIV,gBAAgB,GACjB,gCAA2B;AAmD5B,MAAM,OAAO,eAAgB,SAAQ,UAAsC;IAGzE;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAEQ,KAAK,CAAC,UAAU,CACvB,GAAG,IAAyB;QAE5B,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,IAAI,MAAM,YAAY,OAAO;YACtC,MAAM,IAAI,aAAa,CAAC,2BAA2B,CAAC,CAAC;QACvD,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACzB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;aAChC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;aACrB,KAAK,CAAC,GAAG,EAAE;YACV,MAAM,IAAI,aAAa,CACrB,kDAAkD,CACnD,CAAC;QACJ,CAAC,CAAC,CAAC;QACL,MAAM,MAAM,GAAG,IAAI,MAAM,EAAgB,CAAC;QAC1C,OAAO,IAAI,OAAO,CA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,EAAE,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACxB,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,IAAI,CAAC,IAAI;YACZ,MAAM,IAAI,aAAa,CACrB,qDAAqD,CACtD,CAAC;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF"}
|
package/lib/types/index.d.cts
CHANGED
|
@@ -7,6 +7,6 @@ export * from "./utils.d.cts";
|
|
|
7
7
|
export * from "./namespaces/index.d.cts";
|
|
8
8
|
export * from "./feature-flags/index.d.cts";
|
|
9
9
|
export declare const VERSION: string;
|
|
10
|
-
export declare const COMMIT = "
|
|
11
|
-
export declare const FULL_VERSION = "0.
|
|
10
|
+
export declare const COMMIT = "2a891e0";
|
|
11
|
+
export declare const FULL_VERSION = "0.7.0-2a891e0";
|
|
12
12
|
export declare const PACKAGE_NAME: string;
|
package/lib/types/index.d.mts
CHANGED
|
@@ -7,6 +7,6 @@ export * from "./utils.d.mts";
|
|
|
7
7
|
export * from "./namespaces/index.d.mts";
|
|
8
8
|
export * from "./feature-flags/index.d.mts";
|
|
9
9
|
export declare const VERSION: string;
|
|
10
|
-
export declare const COMMIT = "
|
|
11
|
-
export declare const FULL_VERSION = "0.
|
|
10
|
+
export declare const COMMIT = "2a891e0";
|
|
11
|
+
export declare const FULL_VERSION = "0.7.0-2a891e0";
|
|
12
12
|
export declare const PACKAGE_NAME: string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ContextualArgs, type MaybeContextualArg } from "@decaf-ts/core";
|
|
2
|
+
import { SftpSource, type SftpFileEntry, type SftpFileResult, type SftpSourceConfig } from "../core/SftpSource.d.cts";
|
|
3
|
+
export interface AwsTransferSftpConfig extends SftpSourceConfig {
|
|
4
|
+
provider: "aws-transfer";
|
|
5
|
+
region: string;
|
|
6
|
+
bucket: string;
|
|
7
|
+
s3Prefix?: string;
|
|
8
|
+
serverId?: string;
|
|
9
|
+
}
|
|
10
|
+
interface S3ListObjectsV2Output {
|
|
11
|
+
Contents?: Array<{
|
|
12
|
+
Key?: string;
|
|
13
|
+
Size?: number;
|
|
14
|
+
LastModified?: Date;
|
|
15
|
+
}>;
|
|
16
|
+
NextContinuationToken?: string;
|
|
17
|
+
}
|
|
18
|
+
interface S3LikeClient {
|
|
19
|
+
listObjectsV2(params: unknown): Promise<S3ListObjectsV2Output>;
|
|
20
|
+
getObject(params: unknown): Promise<{
|
|
21
|
+
body: AsyncIterable<Uint8Array>;
|
|
22
|
+
}>;
|
|
23
|
+
deleteObject(params: unknown): Promise<unknown>;
|
|
24
|
+
}
|
|
25
|
+
export declare class AwsSftpService extends SftpSource<S3LikeClient, AwsTransferSftpConfig> {
|
|
26
|
+
constructor();
|
|
27
|
+
initialize(...args: ContextualArgs<any>): Promise<{
|
|
28
|
+
config: AwsTransferSftpConfig;
|
|
29
|
+
client: S3LikeClient;
|
|
30
|
+
}>;
|
|
31
|
+
private s3Prefix;
|
|
32
|
+
list(remoteDir?: string, ...args: MaybeContextualArg<any>): Promise<SftpFileEntry[]>;
|
|
33
|
+
fetch(remotePath: string, ...args: MaybeContextualArg<any>): Promise<SftpFileResult>;
|
|
34
|
+
delete(remotePath: string, ...args: MaybeContextualArg<any>): Promise<void>;
|
|
35
|
+
close(...args: MaybeContextualArg<any>): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ContextualArgs, type MaybeContextualArg } from "@decaf-ts/core";
|
|
2
|
+
import { SftpSource, type SftpFileEntry, type SftpFileResult, type SftpSourceConfig } from "../core/SftpSource.d.mts";
|
|
3
|
+
export interface AwsTransferSftpConfig extends SftpSourceConfig {
|
|
4
|
+
provider: "aws-transfer";
|
|
5
|
+
region: string;
|
|
6
|
+
bucket: string;
|
|
7
|
+
s3Prefix?: string;
|
|
8
|
+
serverId?: string;
|
|
9
|
+
}
|
|
10
|
+
interface S3ListObjectsV2Output {
|
|
11
|
+
Contents?: Array<{
|
|
12
|
+
Key?: string;
|
|
13
|
+
Size?: number;
|
|
14
|
+
LastModified?: Date;
|
|
15
|
+
}>;
|
|
16
|
+
NextContinuationToken?: string;
|
|
17
|
+
}
|
|
18
|
+
interface S3LikeClient {
|
|
19
|
+
listObjectsV2(params: unknown): Promise<S3ListObjectsV2Output>;
|
|
20
|
+
getObject(params: unknown): Promise<{
|
|
21
|
+
body: AsyncIterable<Uint8Array>;
|
|
22
|
+
}>;
|
|
23
|
+
deleteObject(params: unknown): Promise<unknown>;
|
|
24
|
+
}
|
|
25
|
+
export declare class AwsSftpService extends SftpSource<S3LikeClient, AwsTransferSftpConfig> {
|
|
26
|
+
constructor();
|
|
27
|
+
initialize(...args: ContextualArgs<any>): Promise<{
|
|
28
|
+
config: AwsTransferSftpConfig;
|
|
29
|
+
client: S3LikeClient;
|
|
30
|
+
}>;
|
|
31
|
+
private s3Prefix;
|
|
32
|
+
list(remoteDir?: string, ...args: MaybeContextualArg<any>): Promise<SftpFileEntry[]>;
|
|
33
|
+
fetch(remotePath: string, ...args: MaybeContextualArg<any>): Promise<SftpFileResult>;
|
|
34
|
+
delete(remotePath: string, ...args: MaybeContextualArg<any>): Promise<void>;
|
|
35
|
+
close(...args: MaybeContextualArg<any>): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ClientBasedService, type ContextualArgs, type MaybeContextualArg } from "@decaf-ts/core";
|
|
2
|
+
export type SftpProvider = "ssh2" | "aws-transfer";
|
|
3
|
+
export interface SftpSourceConfig {
|
|
4
|
+
provider: SftpProvider;
|
|
5
|
+
sourceId: string;
|
|
6
|
+
host: string;
|
|
7
|
+
port?: number;
|
|
8
|
+
username: string;
|
|
9
|
+
password?: string;
|
|
10
|
+
privateKey?: string;
|
|
11
|
+
passphrase?: string;
|
|
12
|
+
remotePath?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SftpFileEntry {
|
|
15
|
+
path: string;
|
|
16
|
+
name: string;
|
|
17
|
+
size: number;
|
|
18
|
+
modifyTime: number;
|
|
19
|
+
isDirectory: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface SftpFileResult {
|
|
22
|
+
path: string;
|
|
23
|
+
name: string;
|
|
24
|
+
content: Buffer;
|
|
25
|
+
size: number;
|
|
26
|
+
}
|
|
27
|
+
export declare abstract class SftpSource<TClient = unknown, TConfig extends SftpSourceConfig = SftpSourceConfig> extends ClientBasedService<TClient, TConfig> {
|
|
28
|
+
constructor();
|
|
29
|
+
get provider(): SftpProvider;
|
|
30
|
+
get sourceId(): string;
|
|
31
|
+
abstract initialize(...args: ContextualArgs<any>): Promise<{
|
|
32
|
+
config: TConfig;
|
|
33
|
+
client: TClient;
|
|
34
|
+
}>;
|
|
35
|
+
abstract list(remoteDir?: string, ...args: MaybeContextualArg<any>): Promise<SftpFileEntry[]>;
|
|
36
|
+
abstract fetch(remotePath: string, ...args: MaybeContextualArg<any>): Promise<SftpFileResult>;
|
|
37
|
+
abstract delete(remotePath: string, ...args: MaybeContextualArg<any>): Promise<void>;
|
|
38
|
+
abstract close(...args: MaybeContextualArg<any>): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export declare function assertSftpConfig(config: SftpSourceConfig): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ClientBasedService, type ContextualArgs, type MaybeContextualArg } from "@decaf-ts/core";
|
|
2
|
+
export type SftpProvider = "ssh2" | "aws-transfer";
|
|
3
|
+
export interface SftpSourceConfig {
|
|
4
|
+
provider: SftpProvider;
|
|
5
|
+
sourceId: string;
|
|
6
|
+
host: string;
|
|
7
|
+
port?: number;
|
|
8
|
+
username: string;
|
|
9
|
+
password?: string;
|
|
10
|
+
privateKey?: string;
|
|
11
|
+
passphrase?: string;
|
|
12
|
+
remotePath?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SftpFileEntry {
|
|
15
|
+
path: string;
|
|
16
|
+
name: string;
|
|
17
|
+
size: number;
|
|
18
|
+
modifyTime: number;
|
|
19
|
+
isDirectory: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface SftpFileResult {
|
|
22
|
+
path: string;
|
|
23
|
+
name: string;
|
|
24
|
+
content: Buffer;
|
|
25
|
+
size: number;
|
|
26
|
+
}
|
|
27
|
+
export declare abstract class SftpSource<TClient = unknown, TConfig extends SftpSourceConfig = SftpSourceConfig> extends ClientBasedService<TClient, TConfig> {
|
|
28
|
+
constructor();
|
|
29
|
+
get provider(): SftpProvider;
|
|
30
|
+
get sourceId(): string;
|
|
31
|
+
abstract initialize(...args: ContextualArgs<any>): Promise<{
|
|
32
|
+
config: TConfig;
|
|
33
|
+
client: TClient;
|
|
34
|
+
}>;
|
|
35
|
+
abstract list(remoteDir?: string, ...args: MaybeContextualArg<any>): Promise<SftpFileEntry[]>;
|
|
36
|
+
abstract fetch(remotePath: string, ...args: MaybeContextualArg<any>): Promise<SftpFileResult>;
|
|
37
|
+
abstract delete(remotePath: string, ...args: MaybeContextualArg<any>): Promise<void>;
|
|
38
|
+
abstract close(...args: MaybeContextualArg<any>): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export declare function assertSftpConfig(config: SftpSourceConfig): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SftpSource.d.cts";
|