@golemio/core 1.2.24 → 1.2.25-dev.722047718
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/integration-engine/data-access/pubsub/AbstractPubSubChannel.d.ts +5 -0
- package/dist/integration-engine/data-access/pubsub/AbstractPubSubChannel.js +7 -0
- package/dist/integration-engine/data-access/pubsub/AbstractPubSubChannel.js.map +1 -0
- package/dist/integration-engine/data-access/pubsub/RedisPubSubChannel.d.ts +13 -0
- package/dist/integration-engine/data-access/pubsub/RedisPubSubChannel.js +34 -0
- package/dist/integration-engine/data-access/pubsub/RedisPubSubChannel.js.map +1 -0
- package/dist/integration-engine/data-access/pubsub/helpers/getRedisChannel.d.ts +1 -0
- package/dist/integration-engine/data-access/pubsub/helpers/getRedisChannel.js +8 -0
- package/dist/integration-engine/data-access/pubsub/helpers/getRedisChannel.js.map +1 -0
- package/dist/integration-engine/data-access/pubsub/index.d.ts +1 -0
- package/dist/integration-engine/data-access/pubsub/index.js +18 -0
- package/dist/integration-engine/data-access/pubsub/index.js.map +1 -0
- package/dist/integration-engine/data-access/pubsub/subscribers/AbstractSubscriber.d.ts +5 -0
- package/dist/integration-engine/data-access/pubsub/subscribers/AbstractSubscriber.js +7 -0
- package/dist/integration-engine/data-access/pubsub/subscribers/AbstractSubscriber.js.map +1 -0
- package/dist/integration-engine/data-access/pubsub/subscribers/RedisSubscriber.d.ts +17 -0
- package/dist/integration-engine/data-access/pubsub/subscribers/RedisSubscriber.js +91 -0
- package/dist/integration-engine/data-access/pubsub/subscribers/RedisSubscriber.js.map +1 -0
- package/dist/integration-engine/data-access/pubsub/subscribers/interfaces/ISubscribeMessage.d.ts +4 -0
- package/dist/integration-engine/data-access/pubsub/subscribers/interfaces/ISubscribeMessage.js +3 -0
- package/dist/integration-engine/data-access/pubsub/subscribers/interfaces/ISubscribeMessage.js.map +1 -0
- package/dist/integration-engine/datasources/protocol-strategy/FTPProtocolStrategy.d.ts +8 -7
- package/dist/integration-engine/datasources/protocol-strategy/FTPProtocolStrategy.js +38 -78
- package/dist/integration-engine/datasources/protocol-strategy/FTPProtocolStrategy.js.map +1 -1
- package/dist/integration-engine/datasources/protocol-strategy/HTTPProtocolStrategy.d.ts +1 -0
- package/dist/integration-engine/datasources/protocol-strategy/HTTPProtocolStrategy.js +26 -15
- package/dist/integration-engine/datasources/protocol-strategy/HTTPProtocolStrategy.js.map +1 -1
- package/dist/integration-engine/datasources/protocol-strategy/IProtocolStrategy.d.ts +12 -2
- package/dist/integration-engine/datasources/protocol-strategy/IProtocolStrategy.js +6 -1
- package/dist/integration-engine/datasources/protocol-strategy/IProtocolStrategy.js.map +1 -1
- package/dist/integration-engine/datasources/protocol-strategy/helpers/FTPFileProcessor.d.ts +13 -0
- package/dist/integration-engine/datasources/protocol-strategy/helpers/FTPFileProcessor.js +87 -0
- package/dist/integration-engine/datasources/protocol-strategy/helpers/FTPFileProcessor.js.map +1 -0
- package/dist/integration-engine/helpers/FileCompressor.d.ts +17 -0
- package/dist/integration-engine/helpers/FileCompressor.js +113 -0
- package/dist/integration-engine/helpers/FileCompressor.js.map +1 -0
- package/dist/integration-engine/helpers/interfaces/IInflatedFileMetadata.d.ts +6 -0
- package/dist/integration-engine/helpers/interfaces/IInflatedFileMetadata.js +3 -0
- package/dist/integration-engine/helpers/interfaces/IInflatedFileMetadata.js.map +1 -0
- package/dist/integration-engine/helpers/interfaces/Predicate.d.ts +1 -0
- package/dist/integration-engine/helpers/interfaces/Predicate.js +3 -0
- package/dist/integration-engine/helpers/interfaces/Predicate.js.map +1 -0
- package/dist/integration-engine/models/RedisModel.d.ts +11 -1
- package/dist/integration-engine/models/RedisModel.js +28 -2
- package/dist/integration-engine/models/RedisModel.js.map +1 -1
- package/package.json +7 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractPubSubChannel.js","sourceRoot":"","sources":["../../../../src/integration-engine/data-access/pubsub/AbstractPubSubChannel.ts"],"names":[],"mappings":";;;AAEA,MAAsB,aAAa;CAGlC;AAHD,sCAGC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PubSubChannel } from "./AbstractPubSubChannel";
|
|
2
|
+
import { RedisSubscriber } from "./subscribers/RedisSubscriber";
|
|
3
|
+
interface IPublishMessageOptions {
|
|
4
|
+
channelSuffix?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class RedisPubSubChannel extends PubSubChannel {
|
|
7
|
+
private readonly channel;
|
|
8
|
+
private readonly connection;
|
|
9
|
+
constructor(channel: string);
|
|
10
|
+
publishMessage(message: string, options?: IPublishMessageOptions): Promise<void>;
|
|
11
|
+
createSubscriber(): RedisSubscriber;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RedisPubSubChannel = void 0;
|
|
13
|
+
const RedisConnector_1 = require("../../connectors/RedisConnector");
|
|
14
|
+
const AbstractPubSubChannel_1 = require("./AbstractPubSubChannel");
|
|
15
|
+
const getRedisChannel_1 = require("./helpers/getRedisChannel");
|
|
16
|
+
const RedisSubscriber_1 = require("./subscribers/RedisSubscriber");
|
|
17
|
+
class RedisPubSubChannel extends AbstractPubSubChannel_1.PubSubChannel {
|
|
18
|
+
constructor(channel) {
|
|
19
|
+
super();
|
|
20
|
+
this.channel = channel;
|
|
21
|
+
this.connection = RedisConnector_1.RedisConnector.getConnection();
|
|
22
|
+
}
|
|
23
|
+
publishMessage(message, options = {}) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const redisChannel = (0, getRedisChannel_1.getRedisChannel)(this.channel, options.channelSuffix);
|
|
26
|
+
yield this.connection.publish(redisChannel, message);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
createSubscriber() {
|
|
30
|
+
return new RedisSubscriber_1.RedisSubscriber(this.channel);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.RedisPubSubChannel = RedisPubSubChannel;
|
|
34
|
+
//# sourceMappingURL=RedisPubSubChannel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedisPubSubChannel.js","sourceRoot":"","sources":["../../../../src/integration-engine/data-access/pubsub/RedisPubSubChannel.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oEAA+D;AAE/D,mEAAwD;AACxD,+DAA4D;AAC5D,mEAAgE;AAMhE,MAAa,kBAAmB,SAAQ,qCAAa;IAGjD,YAA6B,OAAe;QACxC,KAAK,EAAE,CAAC;QADiB,YAAO,GAAP,OAAO,CAAQ;QAExC,IAAI,CAAC,UAAU,GAAG,+BAAc,CAAC,aAAa,EAAE,CAAC;IACrD,CAAC;IAEY,cAAc,CAAC,OAAe,EAAE,UAAkC,EAAE;;YAC7E,MAAM,YAAY,GAAG,IAAA,iCAAe,EAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;YAC1E,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzD,CAAC;KAAA;IAEM,gBAAgB;QACnB,OAAO,IAAI,iCAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACJ;AAhBD,gDAgBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getRedisChannel: (channel: string, channelSuffix: string | undefined) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRedisChannel = void 0;
|
|
4
|
+
const getRedisChannel = (channel, channelSuffix) => {
|
|
5
|
+
return channelSuffix ? `${channel}:${channelSuffix}` : channel;
|
|
6
|
+
};
|
|
7
|
+
exports.getRedisChannel = getRedisChannel;
|
|
8
|
+
//# sourceMappingURL=getRedisChannel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRedisChannel.js","sourceRoot":"","sources":["../../../../../src/integration-engine/data-access/pubsub/helpers/getRedisChannel.ts"],"names":[],"mappings":";;;AAAO,MAAM,eAAe,GAAG,CAAC,OAAe,EAAE,aAAiC,EAAU,EAAE;IAC1F,OAAO,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,aAAa,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AACnE,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./RedisPubSubChannel";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./RedisPubSubChannel"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/integration-engine/data-access/pubsub/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractSubscriber.js","sourceRoot":"","sources":["../../../../../src/integration-engine/data-access/pubsub/subscribers/AbstractSubscriber.ts"],"names":[],"mappings":";;;AAEA,MAAsB,UAAU;CAG/B;AAHD,gCAGC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Subscriber } from "./AbstractSubscriber";
|
|
2
|
+
import { ISubscribeMessage } from "./interfaces/ISubscribeMessage";
|
|
3
|
+
interface ISubscribeOptions {
|
|
4
|
+
channelSuffix?: string;
|
|
5
|
+
maxMessages?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class RedisSubscriber extends Subscriber {
|
|
8
|
+
private readonly channel;
|
|
9
|
+
private static DEFAULT_MAX_MESSAGES;
|
|
10
|
+
private readonly connection;
|
|
11
|
+
private activeChannels;
|
|
12
|
+
constructor(channel: string);
|
|
13
|
+
subscribe(options?: ISubscribeOptions): Promise<AsyncGenerator<ISubscribeMessage>>;
|
|
14
|
+
unsubscribeAll(): Promise<void>;
|
|
15
|
+
private listenForMessages;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
12
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
13
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
14
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
15
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
16
|
+
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
17
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
18
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
19
|
+
function fulfill(value) { resume("next", value); }
|
|
20
|
+
function reject(value) { resume("throw", value); }
|
|
21
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
22
|
+
};
|
|
23
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.RedisSubscriber = void 0;
|
|
28
|
+
const config_1 = require("../../../config");
|
|
29
|
+
const helpers_1 = require("../../../helpers");
|
|
30
|
+
const errors_1 = require("@golemio/errors");
|
|
31
|
+
const ioredis_1 = __importDefault(require("ioredis"));
|
|
32
|
+
const getRedisChannel_1 = require("../helpers/getRedisChannel");
|
|
33
|
+
const AbstractSubscriber_1 = require("./AbstractSubscriber");
|
|
34
|
+
class RedisSubscriber extends AbstractSubscriber_1.Subscriber {
|
|
35
|
+
constructor(channel) {
|
|
36
|
+
super();
|
|
37
|
+
this.channel = channel;
|
|
38
|
+
this.activeChannels = new Set();
|
|
39
|
+
this.connection = new ioredis_1.default(config_1.config.REDIS_CONN, {
|
|
40
|
+
connectionName: `Subscriber for ${channel}`,
|
|
41
|
+
lazyConnect: true,
|
|
42
|
+
autoResubscribe: true,
|
|
43
|
+
});
|
|
44
|
+
this.connection.on("error", (err) => {
|
|
45
|
+
throw new errors_1.CustomError("Error while connecting to Redis", true, this.constructor.name, undefined, err);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
subscribe(options = {}) {
|
|
49
|
+
var _a;
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const maxMessages = (_a = options.maxMessages) !== null && _a !== void 0 ? _a : RedisSubscriber.DEFAULT_MAX_MESSAGES;
|
|
52
|
+
const redisChannel = (0, getRedisChannel_1.getRedisChannel)(this.channel, options.channelSuffix);
|
|
53
|
+
if (this.connection.status !== "ready") {
|
|
54
|
+
yield this.connection.connect();
|
|
55
|
+
}
|
|
56
|
+
if (this.activeChannels.has(redisChannel)) {
|
|
57
|
+
helpers_1.log.warn(`Already subscribed to Redis channel ${redisChannel}`);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.activeChannels.add(redisChannel);
|
|
61
|
+
yield this.connection.subscribe(redisChannel);
|
|
62
|
+
}
|
|
63
|
+
return this.listenForMessages(redisChannel, maxMessages);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
unsubscribeAll() {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
for (const channel of this.activeChannels) {
|
|
69
|
+
this.activeChannels.delete(channel);
|
|
70
|
+
yield this.connection.unsubscribe(channel);
|
|
71
|
+
}
|
|
72
|
+
this.connection.disconnect();
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
listenForMessages(redisChannel, maxMessages) {
|
|
76
|
+
return __asyncGenerator(this, arguments, function* listenForMessages_1() {
|
|
77
|
+
for (let i = 0; i < maxMessages; i++) {
|
|
78
|
+
yield yield __await(yield __await(new Promise((resolve) => {
|
|
79
|
+
this.connection.once("message", (channel, message) => {
|
|
80
|
+
if (channel === redisChannel) {
|
|
81
|
+
resolve({ message, messageCount: i + 1 });
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
})));
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.RedisSubscriber = RedisSubscriber;
|
|
90
|
+
RedisSubscriber.DEFAULT_MAX_MESSAGES = 1;
|
|
91
|
+
//# sourceMappingURL=RedisSubscriber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedisSubscriber.js","sourceRoot":"","sources":["../../../../../src/integration-engine/data-access/pubsub/subscribers/RedisSubscriber.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoC;AACpC,8CAAkC;AAClC,4CAA8C;AAC9C,sDAAwD;AACxD,gEAA6D;AAC7D,6DAAkD;AAQlD,MAAa,eAAgB,SAAQ,+BAAU;IAK3C,YAA6B,OAAe;QACxC,KAAK,EAAE,CAAC;QADiB,YAAO,GAAP,OAAO,CAAQ;QAFpC,mBAAc,GAAgB,IAAI,GAAG,EAAE,CAAC;QAI5C,IAAI,CAAC,UAAU,GAAG,IAAI,iBAAK,CAAC,eAAM,CAAC,UAAU,EAAE;YAC3C,cAAc,EAAE,kBAAkB,OAAO,EAAE;YAC3C,WAAW,EAAE,IAAI;YACjB,eAAe,EAAE,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CAAC,YAAoB,EAAE,WAAmB;;YACtE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE;gBAClC,oBAAM,cAAM,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,EAAE;oBACnD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;wBACjD,IAAI,OAAO,KAAK,YAAY,EAAE;4BAC1B,OAAO,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;yBAC7C;oBACL,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAA,CAAA,CAAC;aACN;QACL,CAAC;KAAA;;AAvDL,0CAwDC;AAvDkB,oCAAoB,GAAG,CAAC,CAAC"}
|
package/dist/integration-engine/data-access/pubsub/subscribers/interfaces/ISubscribeMessage.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ISubscribeMessage.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/data-access/pubsub/subscribers/interfaces/ISubscribeMessage.ts"],"names":[],"mappings":""}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { ProtocolStrategy } from "./ProtocolStrategy";
|
|
2
1
|
import { IFile, IFTPSettings } from "./IProtocolStrategy";
|
|
2
|
+
import { ProtocolStrategy } from "./ProtocolStrategy";
|
|
3
|
+
interface IRawDataOutput {
|
|
4
|
+
data: IFile | IFile[];
|
|
5
|
+
}
|
|
3
6
|
export declare class FTPProtocolStrategy extends ProtocolStrategy {
|
|
4
7
|
protected connectionSettings: IFTPSettings;
|
|
5
8
|
private ftpClient;
|
|
9
|
+
private fileProcessor;
|
|
10
|
+
private downloadPath;
|
|
6
11
|
constructor(settings: IFTPSettings);
|
|
7
12
|
setConnectionSettings: (settings: IFTPSettings) => void;
|
|
8
|
-
getRawData: () => Promise<
|
|
9
|
-
data: IFile | IFile[];
|
|
10
|
-
}>;
|
|
13
|
+
getRawData: () => Promise<IRawDataOutput>;
|
|
11
14
|
getLastModified: () => Promise<string | null>;
|
|
12
|
-
private encode;
|
|
13
|
-
private readFile;
|
|
14
|
-
private readDir;
|
|
15
15
|
}
|
|
16
|
+
export {};
|
|
@@ -13,84 +13,70 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.FTPProtocolStrategy = void 0;
|
|
16
|
+
const IProtocolStrategy_1 = require("./IProtocolStrategy");
|
|
17
|
+
const ProtocolStrategy_1 = require("./ProtocolStrategy");
|
|
18
|
+
const helpers_1 = require("../../helpers");
|
|
16
19
|
const errors_1 = require("@golemio/errors");
|
|
20
|
+
const basic_ftp_1 = require("basic-ftp");
|
|
21
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
22
|
const moment_1 = __importDefault(require("moment"));
|
|
23
|
+
const os_1 = __importDefault(require("os"));
|
|
18
24
|
const path_1 = __importDefault(require("path"));
|
|
19
|
-
const
|
|
20
|
-
const basic_ftp_1 = require("basic-ftp");
|
|
21
|
-
const decompress_1 = __importDefault(require("decompress"));
|
|
22
|
-
const helpers_1 = require("../../helpers");
|
|
23
|
-
const ProtocolStrategy_1 = require("./ProtocolStrategy");
|
|
24
|
-
const IProtocolStrategy_1 = require("./IProtocolStrategy");
|
|
25
|
+
const FTPFileProcessor_1 = require("./helpers/FTPFileProcessor");
|
|
25
26
|
const defaultSettings = {
|
|
26
|
-
tmpDir:
|
|
27
|
+
tmpDir: os_1.default.tmpdir(),
|
|
27
28
|
targetType: IProtocolStrategy_1.FTPTargetType.FILE,
|
|
29
|
+
returnType: IProtocolStrategy_1.FTPReturnType.File,
|
|
28
30
|
};
|
|
29
31
|
class FTPProtocolStrategy extends ProtocolStrategy_1.ProtocolStrategy {
|
|
30
32
|
constructor(settings) {
|
|
31
33
|
super(Object.assign(Object.assign({}, defaultSettings), settings));
|
|
32
34
|
this.setConnectionSettings = (settings) => {
|
|
33
35
|
this.connectionSettings = Object.assign(Object.assign({}, defaultSettings), settings);
|
|
36
|
+
this.downloadPath = this.connectionSettings.tmpDir;
|
|
37
|
+
this.fileProcessor = new FTPFileProcessor_1.FTPFileProcessor(this.connectionSettings, this.downloadPath);
|
|
34
38
|
};
|
|
35
39
|
this.getRawData = () => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
|
|
40
|
+
try {
|
|
41
|
+
const dirHandle = yield fs_1.default.promises.open(this.downloadPath, fs_1.default.constants.O_DIRECTORY);
|
|
42
|
+
yield dirHandle.close();
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
throw new errors_1.CustomError("FTP download path is not a directory", true, this.constructor.name, undefined, err);
|
|
46
|
+
}
|
|
37
47
|
try {
|
|
38
48
|
yield this.ftpClient.access(this.connectionSettings.url);
|
|
39
49
|
yield this.ftpClient.cd(this.connectionSettings.path);
|
|
40
|
-
yield this.ftpClient.downloadTo(fs_1.default.createWriteStream(path_1.default.join(
|
|
41
|
-
|
|
42
|
-
|
|
50
|
+
yield this.ftpClient.downloadTo(fs_1.default.createWriteStream(path_1.default.join(this.downloadPath, this.connectionSettings.filename)), this.connectionSettings.filename);
|
|
51
|
+
this.ftpClient.close();
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
throw new errors_1.CustomError("Error while downloading FTP files", true, this.constructor.name, undefined, err);
|
|
55
|
+
}
|
|
56
|
+
const prefix = path_1.default.parse(this.connectionSettings.filename).name + "/";
|
|
57
|
+
let result;
|
|
58
|
+
try {
|
|
43
59
|
if (this.connectionSettings.targetType === IProtocolStrategy_1.FTPTargetType.COMPRESSED) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
const result = files.map((file) => {
|
|
50
|
-
return {
|
|
51
|
-
data: this.encode(file.data),
|
|
52
|
-
filepath: prefix + file.path,
|
|
53
|
-
name: path_1.default.parse(file.path).name,
|
|
54
|
-
mtime: file.mtime,
|
|
55
|
-
type: file.type,
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
return { data: result };
|
|
60
|
+
result = yield this.fileProcessor.processTargetCompressed(prefix);
|
|
61
|
+
}
|
|
62
|
+
else if (this.connectionSettings.targetType === IProtocolStrategy_1.FTPTargetType.FOLDER) {
|
|
63
|
+
result = yield this.fileProcessor.processTargetFolder(prefix);
|
|
59
64
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (this.connectionSettings.whitelistedFiles && this.connectionSettings.whitelistedFiles.length) {
|
|
63
|
-
files = files.filter((file) => { var _a; return ((_a = this.connectionSettings.whitelistedFiles) === null || _a === void 0 ? void 0 : _a.indexOf(file)) !== -1; });
|
|
64
|
-
}
|
|
65
|
-
const result = yield Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const buffer = yield this.readFile(path_1.default.join(tmpDir, prefix, file));
|
|
67
|
-
return {
|
|
68
|
-
data: this.encode(buffer),
|
|
69
|
-
filepath: prefix + file,
|
|
70
|
-
name: path_1.default.parse(file).name,
|
|
71
|
-
};
|
|
72
|
-
})));
|
|
73
|
-
return { data: result };
|
|
65
|
+
else {
|
|
66
|
+
result = yield this.fileProcessor.processTargetFile();
|
|
74
67
|
}
|
|
75
|
-
const buffer = yield this.readFile(path_1.default.join(tmpDir, this.connectionSettings.filename));
|
|
76
|
-
return {
|
|
77
|
-
data: {
|
|
78
|
-
data: this.encode(buffer),
|
|
79
|
-
filepath: this.connectionSettings.filename,
|
|
80
|
-
name: path_1.default.parse(this.connectionSettings.filename).name,
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
68
|
}
|
|
84
69
|
catch (err) {
|
|
85
|
-
throw new errors_1.CustomError("Error while
|
|
70
|
+
throw new errors_1.CustomError("Error while processing downloaded FTP files", true, this.constructor.name, undefined, err);
|
|
86
71
|
}
|
|
72
|
+
return { data: result };
|
|
87
73
|
});
|
|
88
74
|
this.getLastModified = () => __awaiter(this, void 0, void 0, function* () {
|
|
89
75
|
try {
|
|
90
76
|
yield this.ftpClient.access(this.connectionSettings.url);
|
|
91
77
|
yield this.ftpClient.cd(this.connectionSettings.path);
|
|
92
78
|
const lastModified = yield this.ftpClient.lastMod(this.connectionSettings.filename);
|
|
93
|
-
|
|
79
|
+
this.ftpClient.close();
|
|
94
80
|
return lastModified ? (0, moment_1.default)(lastModified, "MM-DD-YYYY hh:mmA").toISOString() : null;
|
|
95
81
|
}
|
|
96
82
|
catch (err) {
|
|
@@ -98,37 +84,11 @@ class FTPProtocolStrategy extends ProtocolStrategy_1.ProtocolStrategy {
|
|
|
98
84
|
return null;
|
|
99
85
|
}
|
|
100
86
|
});
|
|
101
|
-
this.encode = (data) => {
|
|
102
|
-
return this.connectionSettings.encoding ? data.toString(this.connectionSettings.encoding) : data;
|
|
103
|
-
};
|
|
104
|
-
this.readFile = (file) => {
|
|
105
|
-
return new Promise((resolve, reject) => {
|
|
106
|
-
const stream = fs_1.default.createReadStream(file);
|
|
107
|
-
const chunks = [];
|
|
108
|
-
stream.on("error", (err) => {
|
|
109
|
-
reject(err);
|
|
110
|
-
});
|
|
111
|
-
stream.on("data", (data) => {
|
|
112
|
-
chunks.push(data);
|
|
113
|
-
});
|
|
114
|
-
stream.on("close", () => {
|
|
115
|
-
resolve(Buffer.concat(chunks));
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
this.readDir = (dirPath) => {
|
|
120
|
-
return new Promise((resolve, reject) => {
|
|
121
|
-
fs_1.default.readdir(dirPath, (err, files) => {
|
|
122
|
-
if (err) {
|
|
123
|
-
return reject(err);
|
|
124
|
-
}
|
|
125
|
-
return resolve(files);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
87
|
this.ftpClient = new basic_ftp_1.Client();
|
|
130
88
|
this.ftpClient.ftp.log = helpers_1.log.silly;
|
|
131
89
|
this.ftpClient.ftp.verbose = true;
|
|
90
|
+
this.downloadPath = this.connectionSettings.tmpDir;
|
|
91
|
+
this.fileProcessor = new FTPFileProcessor_1.FTPFileProcessor(this.connectionSettings, this.downloadPath);
|
|
132
92
|
}
|
|
133
93
|
}
|
|
134
94
|
exports.FTPProtocolStrategy = FTPProtocolStrategy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FTPProtocolStrategy.js","sourceRoot":"","sources":["../../../../src/integration-engine/datasources/protocol-strategy/FTPProtocolStrategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"FTPProtocolStrategy.js","sourceRoot":"","sources":["../../../../src/integration-engine/datasources/protocol-strategy/FTPProtocolStrategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2DAAwH;AACxH,yDAAsF;AACtF,2CAAkC;AAClC,4CAA8C;AAC9C,yCAAmC;AACnC,4CAAoB;AACpB,oDAA4B;AAC5B,4CAAoB;AACpB,gDAAwB;AACxB,iEAA8D;AAM9D,MAAM,eAAe,GAA0B;IAC3C,MAAM,EAAE,YAAE,CAAC,MAAM,EAAE;IACnB,UAAU,EAAE,iCAAa,CAAC,IAAI;IAC9B,UAAU,EAAE,iCAAa,CAAC,IAAI;CACjC,CAAC;AAEF,MAAa,mBAAoB,SAAQ,mCAAgB;IAMrD,YAAY,QAAsB;QAC9B,KAAK,iCAAM,eAAe,GAAK,QAAQ,EAAG,CAAC;QAQxC,0BAAqB,GAAG,CAAC,QAAsB,EAAQ,EAAE;YAC5D,IAAI,CAAC,kBAAkB,mCAAQ,eAAe,GAAK,QAAQ,CAAE,CAAC;YAC9D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAO,CAAC;YACpD,IAAI,CAAC,aAAa,GAAG,IAAI,mCAAgB,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC1F,CAAC,C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AAA,CAAC;QA/DE,IAAI,CAAC,SAAS,GAAG,IAAI,kBAAM,EAAE,CAAC;QAC9B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,aAAG,CAAC,KAAK,CAAC;QACnC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;QAClC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAO,CAAC;QACpD,IAAI,CAAC,aAAa,GAAG,IAAI,mCAAgB,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC1F,CAAC;CA2DJ;AAxED,kDAwEC"}
|
|
@@ -2,6 +2,7 @@ import { IHTTPSettings } from "./IProtocolStrategy";
|
|
|
2
2
|
import { ProtocolStrategy } from "./ProtocolStrategy";
|
|
3
3
|
export declare class HTTPProtocolStrategy extends ProtocolStrategy {
|
|
4
4
|
protected connectionSettings: IHTTPSettings;
|
|
5
|
+
private fileCompressor;
|
|
5
6
|
constructor(settings: IHTTPSettings);
|
|
6
7
|
setConnectionSettings: (settings: IHTTPSettings) => void;
|
|
7
8
|
getRawData: () => Promise<any>;
|
|
@@ -13,22 +13,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.HTTPProtocolStrategy = void 0;
|
|
16
|
+
const ProtocolStrategy_1 = require("./ProtocolStrategy");
|
|
17
|
+
const helpers_1 = require("../../helpers");
|
|
18
|
+
const FileCompressor_1 = require("../../helpers/FileCompressor");
|
|
19
|
+
const models_1 = require("../../models");
|
|
16
20
|
const errors_1 = require("@golemio/errors");
|
|
21
|
+
const axios_1 = __importDefault(require("axios"));
|
|
22
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
17
23
|
const moment_1 = __importDefault(require("moment"));
|
|
24
|
+
const os_1 = __importDefault(require("os"));
|
|
18
25
|
const path_1 = __importDefault(require("path"));
|
|
19
|
-
const decompress_1 = __importDefault(require("decompress"));
|
|
20
|
-
const zlib_1 = require("zlib");
|
|
21
26
|
const util_1 = require("util");
|
|
22
|
-
const
|
|
23
|
-
const models_1 = require("../../models");
|
|
24
|
-
const ProtocolStrategy_1 = require("./ProtocolStrategy");
|
|
25
|
-
const axios_1 = __importDefault(require("axios"));
|
|
27
|
+
const zlib_1 = require("zlib");
|
|
26
28
|
const gunzip = (0, util_1.promisify)(zlib_1.gunzip);
|
|
29
|
+
const defaultSettings = {
|
|
30
|
+
tmpDir: os_1.default.tmpdir(),
|
|
31
|
+
};
|
|
27
32
|
class HTTPProtocolStrategy extends ProtocolStrategy_1.ProtocolStrategy {
|
|
28
33
|
constructor(settings) {
|
|
29
|
-
super(settings);
|
|
34
|
+
super(Object.assign(Object.assign({}, defaultSettings), settings));
|
|
30
35
|
this.setConnectionSettings = (settings) => {
|
|
31
|
-
this.connectionSettings = settings;
|
|
36
|
+
this.connectionSettings = Object.assign(Object.assign({}, defaultSettings), settings);
|
|
37
|
+
this.fileCompressor = new FileCompressor_1.FileCompressor(this.connectionSettings.tmpDir);
|
|
32
38
|
};
|
|
33
39
|
this.getRawData = () => __awaiter(this, void 0, void 0, function* () {
|
|
34
40
|
var _a;
|
|
@@ -50,10 +56,11 @@ class HTTPProtocolStrategy extends ProtocolStrategy_1.ProtocolStrategy {
|
|
|
50
56
|
}
|
|
51
57
|
if (this.connectionSettings.isCompressed) {
|
|
52
58
|
const prefix = path_1.default.parse(this.connectionSettings.url).name + "/";
|
|
53
|
-
const files = yield
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
const { extractionPath, files } = yield this.fileCompressor.inflateBuffer(body, (filename) => {
|
|
60
|
+
if (this.connectionSettings.whitelistedFiles) {
|
|
61
|
+
return this.connectionSettings.whitelistedFiles.indexOf(filename) >= 0;
|
|
62
|
+
}
|
|
63
|
+
return !!filename;
|
|
57
64
|
});
|
|
58
65
|
const redisModel = new models_1.RedisModel("HTTPProtocolStrategy" + "Model", {
|
|
59
66
|
isKeyConstructedFromData: false,
|
|
@@ -61,14 +68,17 @@ class HTTPProtocolStrategy extends ProtocolStrategy_1.ProtocolStrategy {
|
|
|
61
68
|
}, null);
|
|
62
69
|
const encoding = (_a = this.connectionSettings.encoding) !== null && _a !== void 0 ? _a : "utf8";
|
|
63
70
|
body = yield Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
yield
|
|
71
|
+
const data = yield promises_1.default.readFile(file.path, encoding);
|
|
72
|
+
const relativePath = path_1.default.join(prefix, file.name);
|
|
73
|
+
yield redisModel.hset(relativePath, data.toString(encoding));
|
|
65
74
|
return {
|
|
66
|
-
filepath:
|
|
75
|
+
filepath: relativePath,
|
|
67
76
|
mtime: file.mtime,
|
|
68
|
-
name: path_1.default.parse(
|
|
77
|
+
name: path_1.default.parse(relativePath).name,
|
|
69
78
|
path: file.path,
|
|
70
79
|
};
|
|
71
80
|
})));
|
|
81
|
+
yield promises_1.default.rm(extractionPath, { recursive: true, force: true });
|
|
72
82
|
}
|
|
73
83
|
return {
|
|
74
84
|
data: body,
|
|
@@ -98,6 +108,7 @@ class HTTPProtocolStrategy extends ProtocolStrategy_1.ProtocolStrategy {
|
|
|
98
108
|
return null;
|
|
99
109
|
}
|
|
100
110
|
});
|
|
111
|
+
this.fileCompressor = new FileCompressor_1.FileCompressor(this.connectionSettings.tmpDir);
|
|
101
112
|
}
|
|
102
113
|
}
|
|
103
114
|
exports.HTTPProtocolStrategy = HTTPProtocolStrategy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HTTPProtocolStrategy.js","sourceRoot":"","sources":["../../../../src/integration-engine/datasources/protocol-strategy/HTTPProtocolStrategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"HTTPProtocolStrategy.js","sourceRoot":"","sources":["../../../../src/integration-engine/datasources/protocol-strategy/HTTPProtocolStr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3B,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAA,gBAAM,EAAC,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aACnG;YAAC,OAAO,GAAG,EAAE;gBACV,aAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACf,OAAO,IAAI,CAAC;aACf;QACL,CAAC,CAAA,CAAC;QAzFE,IAAI,CAAC,cAAc,GAAG,IAAI,+BAAc,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAO,CAAC,CAAC;IAC9E,CAAC;CAyFJ;AAhGD,oDAgGC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
2
|
+
/// <reference types="node" />
|
|
3
3
|
import { DataSourceStream } from "./..";
|
|
4
4
|
import { AccessOptions } from "basic-ftp";
|
|
5
|
+
import { ReadStream } from "fs";
|
|
6
|
+
import { ModelAttributes } from "sequelize";
|
|
5
7
|
export interface IHTTPSettings {
|
|
6
8
|
/** (optional) Data to send with request, e.g. credentials */
|
|
7
9
|
body?: any;
|
|
@@ -13,6 +15,8 @@ export interface IHTTPSettings {
|
|
|
13
15
|
method: string;
|
|
14
16
|
/** Url of the data source. */
|
|
15
17
|
url: string;
|
|
18
|
+
/** Tmp directory, default: /tmp */
|
|
19
|
+
tmpDir?: string;
|
|
16
20
|
httpsAgent?: any;
|
|
17
21
|
strictSSL?: boolean;
|
|
18
22
|
encoding?: any;
|
|
@@ -28,8 +32,12 @@ export declare enum FTPTargetType {
|
|
|
28
32
|
FOLDER = "FOLDER",
|
|
29
33
|
COMPRESSED = "COMPRESSED"
|
|
30
34
|
}
|
|
35
|
+
export declare enum FTPReturnType {
|
|
36
|
+
File = 0,
|
|
37
|
+
Stream = 1
|
|
38
|
+
}
|
|
31
39
|
export interface IFile {
|
|
32
|
-
data: Buffer | Record<string, any> | string;
|
|
40
|
+
data: ReadStream | Buffer | Record<string, any> | string;
|
|
33
41
|
filepath: string;
|
|
34
42
|
name: string;
|
|
35
43
|
mtime?: string;
|
|
@@ -47,6 +55,8 @@ export interface IFTPSettings {
|
|
|
47
55
|
tmpDir?: string;
|
|
48
56
|
/** Type of downloaded file, default: FTPTargetType.FILE */
|
|
49
57
|
targetType?: FTPTargetType;
|
|
58
|
+
/** Return a file/stream or a readable stream/collection of readable streams */
|
|
59
|
+
returnType?: FTPReturnType;
|
|
50
60
|
/** Whitelist of files for FOLDER and COMPRESSED (archive) type **/
|
|
51
61
|
whitelistedFiles?: string[];
|
|
52
62
|
/** Encoding for file content, i.e. 'utf8' **/
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFileObject = exports.FTPTargetType = void 0;
|
|
3
|
+
exports.isFileObject = exports.FTPReturnType = exports.FTPTargetType = void 0;
|
|
4
4
|
var FTPTargetType;
|
|
5
5
|
(function (FTPTargetType) {
|
|
6
6
|
FTPTargetType["FILE"] = "FILE";
|
|
7
7
|
FTPTargetType["FOLDER"] = "FOLDER";
|
|
8
8
|
FTPTargetType["COMPRESSED"] = "COMPRESSED";
|
|
9
9
|
})(FTPTargetType = exports.FTPTargetType || (exports.FTPTargetType = {}));
|
|
10
|
+
var FTPReturnType;
|
|
11
|
+
(function (FTPReturnType) {
|
|
12
|
+
FTPReturnType[FTPReturnType["File"] = 0] = "File";
|
|
13
|
+
FTPReturnType[FTPReturnType["Stream"] = 1] = "Stream";
|
|
14
|
+
})(FTPReturnType = exports.FTPReturnType || (exports.FTPReturnType = {}));
|
|
10
15
|
const isFileObject = (obj) => {
|
|
11
16
|
return obj instanceof Object && obj.data !== undefined && obj.filepath !== undefined && obj.name !== undefined;
|
|
12
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IProtocolStrategy.js","sourceRoot":"","sources":["../../../../src/integration-engine/datasources/protocol-strategy/IProtocolStrategy.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"IProtocolStrategy.js","sourceRoot":"","sources":["../../../../src/integration-engine/datasources/protocol-strategy/IProtocolStrategy.ts"],"names":[],"mappings":";;;AAkCA,IAAY,aAIX;AAJD,WAAY,aAAa;IACrB,8BAAa,CAAA;IACb,kCAAiB,CAAA;IACjB,0CAAyB,CAAA;AAC7B,CAAC,EAJW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAIxB;AAED,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,iDAAI,CAAA;IACJ,qDAAM,CAAA;AACV,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AAUM,MAAM,YAAY,GAAG,CAAC,GAAQ,EAAgB,EAAE;IACnD,OAAO,GAAG,YAAY,MAAM,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC;AACnH,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IFile, IFTPSettings } from "../IProtocolStrategy";
|
|
2
|
+
export declare class FTPFileProcessor {
|
|
3
|
+
private readonly connectionSettings;
|
|
4
|
+
private readonly downloadPath;
|
|
5
|
+
private readonly fileCompressor;
|
|
6
|
+
constructor(connectionSettings: IFTPSettings, downloadPath: string);
|
|
7
|
+
processTargetFile(): Promise<IFile>;
|
|
8
|
+
processTargetFolder(prefix: string): Promise<IFile[]>;
|
|
9
|
+
processTargetCompressed(prefix: string): Promise<IFile[]>;
|
|
10
|
+
private prepareFileData;
|
|
11
|
+
private encode;
|
|
12
|
+
private createWhitelistPredicate;
|
|
13
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FTPFileProcessor = void 0;
|
|
16
|
+
const IProtocolStrategy_1 = require("../IProtocolStrategy");
|
|
17
|
+
const FileCompressor_1 = require("../../../helpers/FileCompressor");
|
|
18
|
+
const fs_1 = require("fs");
|
|
19
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
20
|
+
const path_1 = __importDefault(require("path"));
|
|
21
|
+
class FTPFileProcessor {
|
|
22
|
+
constructor(connectionSettings, downloadPath) {
|
|
23
|
+
this.connectionSettings = connectionSettings;
|
|
24
|
+
this.downloadPath = downloadPath;
|
|
25
|
+
this.fileCompressor = new FileCompressor_1.FileCompressor(this.downloadPath);
|
|
26
|
+
}
|
|
27
|
+
processTargetFile() {
|
|
28
|
+
return this.prepareFileData(path_1.default.join(this.downloadPath, this.connectionSettings.filename), this.connectionSettings.filename);
|
|
29
|
+
}
|
|
30
|
+
processTargetFolder(prefix) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const whitelistPredicate = this.createWhitelistPredicate();
|
|
33
|
+
const files = (yield promises_1.default.readdir(path_1.default.join(this.downloadPath, this.connectionSettings.filename))).filter(whitelistPredicate);
|
|
34
|
+
const result = [];
|
|
35
|
+
for (const file of files) {
|
|
36
|
+
result.push(yield this.prepareFileData(path_1.default.join(this.downloadPath, prefix, file), path_1.default.join(prefix, file)));
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
processTargetCompressed(prefix) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const whitelistPredicate = this.createWhitelistPredicate();
|
|
44
|
+
const { files } = yield this.fileCompressor.inflateFile(path_1.default.join(this.downloadPath, this.connectionSettings.filename), whitelistPredicate);
|
|
45
|
+
const result = [];
|
|
46
|
+
for (const file of files) {
|
|
47
|
+
const fileResult = yield this.prepareFileData(file.path, path_1.default.join(prefix, file.name));
|
|
48
|
+
result.push(Object.assign(Object.assign({}, fileResult), { mtime: file.mtime.toISOString(), type: file.type }));
|
|
49
|
+
if (fileResult.data instanceof fs_1.ReadStream) {
|
|
50
|
+
fileResult.data.once("end", () => __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
yield promises_1.default.rm(file.path, { force: true });
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
yield promises_1.default.rm(file.path, { force: true });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
prepareFileData(absoluteFilePath, relativeFilePath) {
|
|
62
|
+
var _a;
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const data = this.connectionSettings.returnType === IProtocolStrategy_1.FTPReturnType.Stream
|
|
65
|
+
? (0, fs_1.createReadStream)(absoluteFilePath, (_a = this.connectionSettings.encoding) !== null && _a !== void 0 ? _a : undefined)
|
|
66
|
+
: this.encode(yield promises_1.default.readFile(absoluteFilePath));
|
|
67
|
+
return {
|
|
68
|
+
data,
|
|
69
|
+
filepath: relativeFilePath,
|
|
70
|
+
name: path_1.default.parse(relativeFilePath).name,
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
encode(data) {
|
|
75
|
+
return this.connectionSettings.encoding ? data.toString(this.connectionSettings.encoding) : data;
|
|
76
|
+
}
|
|
77
|
+
createWhitelistPredicate() {
|
|
78
|
+
return (filename) => {
|
|
79
|
+
if (this.connectionSettings.whitelistedFiles) {
|
|
80
|
+
return this.connectionSettings.whitelistedFiles.indexOf(filename) >= 0;
|
|
81
|
+
}
|
|
82
|
+
return !!filename;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.FTPFileProcessor = FTPFileProcessor;
|
|
87
|
+
//# sourceMappingURL=FTPFileProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FTPFileProcessor.js","sourceRoot":"","sources":["../../../../../src/integration-engine/datasources/protocol-strategy/helpers/FTPFileProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAAyG;AACzG,oEAA4D;AAE5D,2BAAkD;AAClD,2DAA6B;AAC7B,gDAAwB;AAExB,MAAa,gBAAgB;IAGzB,YAA6B,kBAAgC,EAAmB,YAAoB;QAAvE,uBAAkB,GAAlB,kBAAkB,CAAc;QAAmB,iBAAY,GAAZ,YAAY,CAAQ;QAChG,IAAI,CAAC,cAAc,GAAG,IAAI,+BAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAChE,CAAC;IAEM,iBAAiB;QACpB,OAAO,IAAI,CAAC,eAAe,CACvB,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAC9D,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CACnC,CAAC;IACN,CAAC;IAEY,mBAAmB,CAAC,MAAc;;YAC3C,MAAM,kBAAkB,GAAG,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAC3D,MAAM,KAAK,GAAG,CAAC,MAAM,kBAAE,CAAC,OAAO,CAAC,cAAI,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Q,CAAC;QACtB,CAAC,CAAC;IACN,CAAC;CACJ;AAnFD,4CAmFC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IInflatedFileMetadata } from "./interfaces/IInflatedFileMetadata";
|
|
3
|
+
import { Predicate } from "./interfaces/Predicate";
|
|
4
|
+
interface IInflateOutput {
|
|
5
|
+
extractionPath: string;
|
|
6
|
+
files: IInflatedFileMetadata[];
|
|
7
|
+
}
|
|
8
|
+
export declare class FileCompressor {
|
|
9
|
+
private readonly basePath;
|
|
10
|
+
private static LIB_OPTIONS;
|
|
11
|
+
constructor(basePath: string);
|
|
12
|
+
inflateBuffer(buffer: Buffer, extractFilePredicate: Predicate<[string]>): Promise<IInflateOutput>;
|
|
13
|
+
inflateFile(archivePath: string, extractFilePredicate: Predicate<[string]>): Promise<IInflateOutput>;
|
|
14
|
+
private processZipFile;
|
|
15
|
+
private getFileMetadata;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FileCompressor = void 0;
|
|
16
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
17
|
+
const fs_1 = require("fs");
|
|
18
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const yauzl_1 = __importDefault(require("yauzl"));
|
|
21
|
+
const Logger_1 = require("./Logger");
|
|
22
|
+
class FileCompressor {
|
|
23
|
+
constructor(basePath) {
|
|
24
|
+
this.basePath = basePath;
|
|
25
|
+
}
|
|
26
|
+
inflateBuffer(buffer, extractFilePredicate) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const archiveName = crypto_1.default.randomBytes(5).toString("hex");
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
yauzl_1.default.fromBuffer(buffer, FileCompressor.LIB_OPTIONS, (err, zipFile) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
if (err) {
|
|
32
|
+
reject(err);
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const result = yield this.processZipFile(archiveName, zipFile, extractFilePredicate);
|
|
36
|
+
resolve(result);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
reject(err);
|
|
40
|
+
}
|
|
41
|
+
zipFile.close();
|
|
42
|
+
}));
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
inflateFile(archivePath, extractFilePredicate) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const archiveName = path_1.default.basename(archivePath);
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
yauzl_1.default.open(archivePath, FileCompressor.LIB_OPTIONS, (err, zipFile) => __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
if (err) {
|
|
52
|
+
reject(err);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const result = yield this.processZipFile(archiveName, zipFile, extractFilePredicate);
|
|
56
|
+
resolve(result);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
zipFile.close();
|
|
60
|
+
reject(err);
|
|
61
|
+
}
|
|
62
|
+
zipFile.close();
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
processZipFile(archiveName, zipFile, extractFilePredicate) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const extractionPath = yield promises_1.default.mkdtemp(path_1.default.join(this.basePath, `${archiveName}-`));
|
|
70
|
+
let files = [];
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
zipFile.readEntry();
|
|
73
|
+
zipFile.on("entry", (entry) => {
|
|
74
|
+
if (!extractFilePredicate(entry.fileName)) {
|
|
75
|
+
zipFile.readEntry();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
zipFile.openReadStream(entry, (err, readStream) => {
|
|
79
|
+
if (err) {
|
|
80
|
+
reject(err);
|
|
81
|
+
}
|
|
82
|
+
const filePath = path_1.default.resolve(extractionPath, entry.fileName);
|
|
83
|
+
const fileStream = (0, fs_1.createWriteStream)(filePath).on("finish", () => __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
Logger_1.log.info(`Extracted ${archiveName}:${entry.fileName}`);
|
|
85
|
+
files.push(yield this.getFileMetadata(filePath, entry.fileName));
|
|
86
|
+
zipFile.readEntry();
|
|
87
|
+
}));
|
|
88
|
+
readStream.pipe(fileStream);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
zipFile.once("end", () => {
|
|
92
|
+
resolve({ extractionPath, files });
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
getFileMetadata(filePath, fileName) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const { mtime } = yield promises_1.default.stat(filePath);
|
|
100
|
+
return {
|
|
101
|
+
path: filePath,
|
|
102
|
+
name: fileName,
|
|
103
|
+
mtime,
|
|
104
|
+
type: "file", // backwards compatibility with the "decompress" output
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.FileCompressor = FileCompressor;
|
|
110
|
+
FileCompressor.LIB_OPTIONS = {
|
|
111
|
+
lazyEntries: true,
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=FileCompressor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileCompressor.js","sourceRoot":"","sources":["../../../src/integration-engine/helpers/FileCompressor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAA4B;AAC5B,2BAAuC;AACvC,2DAA6B;AAC7B,gDAAwB;AACxB,kDAAuD;AAGvD,qCAA+B;AAO/B,MAAa,cAAc;IAKvB,YAA6B,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;IAAG,CAAC;IAEpC,aAAa,CAAC,MAAc,EAAE,oBAAyC;;YAChF,MAAM,WAAW,GAAG,gBAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC1D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACnC,eAAK,CAAC,UAAU,CAAC,MAAM,EAAE,cAAc,CAAC,WAAW,EAAE,CAAO,GAAG,EAAE,OAAO,EAAE,EAAE;oBACxE,IAAI,GAAG,EAAE;wBACL,MAAM,CAAC,GAAG,CAAC,CAAC;qBACf;oBAED,IAAI;wBACA,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC;wBACrF,OAAO,CAAC,MAAM,CAAC,CAAC;qBACnB;oBAAC,OAAO,GAAG,EAAE;wBACV,MAAM,CAAC,GAAG,CAAC,CAAC;qBACf;oBAED,OAAO,CAAC,KAAK,EAAE,CAAC;gBACpB,CAAC,CAAA,CAAC,CAAC;YAC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0BAAW,GAAY;IAClC,WAAW,EAAE,IAAI;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IInflatedFileMetadata.js","sourceRoot":"","sources":["../../../../src/integration-engine/helpers/interfaces/IInflatedFileMetadata.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type Predicate<T extends any[]> = (...params: T) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Predicate.js","sourceRoot":"","sources":["../../../../src/integration-engine/helpers/interfaces/Predicate.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { IRedisModel, IRedisSettings } from "./";
|
|
1
2
|
import { Validator } from "@golemio/validator";
|
|
3
|
+
import { ReadStream } from "fs";
|
|
2
4
|
import { Redis } from "ioredis";
|
|
3
|
-
import {
|
|
5
|
+
import { Readable } from "stream";
|
|
4
6
|
export declare class RedisModel implements IRedisModel {
|
|
5
7
|
/** Model name */
|
|
6
8
|
name: string;
|
|
@@ -28,6 +30,14 @@ export declare class RedisModel implements IRedisModel {
|
|
|
28
30
|
hset: (key: string, data: any) => Promise<any>;
|
|
29
31
|
get: (key: string) => Promise<any>;
|
|
30
32
|
hget: (key: string) => Promise<any>;
|
|
33
|
+
/**
|
|
34
|
+
* Stream data into a key from file read stream via SET/APPEND
|
|
35
|
+
*/
|
|
36
|
+
pipeStream: (key: string, readStream: ReadStream) => Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Get a readable stream of data from a key via GETRANGE
|
|
39
|
+
*/
|
|
40
|
+
getReadableStream: (key: string) => Readable;
|
|
31
41
|
delete: (key?: string) => Promise<any>;
|
|
32
42
|
truncate: (namespace?: boolean) => Promise<number>;
|
|
33
43
|
flush: () => Promise<"OK">;
|
|
@@ -8,12 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.RedisModel = void 0;
|
|
13
|
-
const errors_1 = require("@golemio/errors");
|
|
14
|
-
const utils_1 = require("@golemio/utils");
|
|
15
16
|
const connectors_1 = require("../connectors");
|
|
16
17
|
const helpers_1 = require("../helpers");
|
|
18
|
+
const errors_1 = require("@golemio/errors");
|
|
19
|
+
const utils_1 = require("@golemio/utils");
|
|
20
|
+
const redis_rstream_1 = __importDefault(require("redis-rstream"));
|
|
21
|
+
const redis_wstream_1 = __importDefault(require("redis-wstream"));
|
|
17
22
|
class RedisModel {
|
|
18
23
|
constructor(name, settings, validator = null) {
|
|
19
24
|
var _a;
|
|
@@ -88,6 +93,27 @@ class RedisModel {
|
|
|
88
93
|
// getting and decoding the data from redis hash
|
|
89
94
|
return this.decodeDataAfterGet(yield this.connection.hget(this.prefix, key));
|
|
90
95
|
});
|
|
96
|
+
/**
|
|
97
|
+
* Stream data into a key from file read stream via SET/APPEND
|
|
98
|
+
*/
|
|
99
|
+
this.pipeStream = (key, readStream) => __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
const redisWriteStream = new redis_wstream_1.default(this.connection, `${this.prefix}:${key}`);
|
|
101
|
+
return new Promise((resolve, reject) => {
|
|
102
|
+
redisWriteStream.on("finish", () => {
|
|
103
|
+
resolve();
|
|
104
|
+
});
|
|
105
|
+
redisWriteStream.on("error", (err) => {
|
|
106
|
+
reject(err);
|
|
107
|
+
});
|
|
108
|
+
readStream.pipe(redisWriteStream);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
/**
|
|
112
|
+
* Get a readable stream of data from a key via GETRANGE
|
|
113
|
+
*/
|
|
114
|
+
this.getReadableStream = (key) => {
|
|
115
|
+
return new redis_rstream_1.default(this.connection, `${this.prefix}:${key}`);
|
|
116
|
+
};
|
|
91
117
|
this.delete = (key) => __awaiter(this, void 0, void 0, function* () {
|
|
92
118
|
if (key) {
|
|
93
119
|
return this.connection.del(`${this.prefix}:${key}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedisModel.js","sourceRoot":"","sources":["../../../src/integration-engine/models/RedisModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RedisModel.js","sourceRoot":"","sources":["../../../src/integration-engine/models/RedisModel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,8CAAgD;AAChD,wCAAkC;AAElC,4CAA8C;AAC9C,0CAAgD;AAIhD,kEAAyC;AACzC,kEAAyC;AAGzC,MAAa,UAAU;IAgBnB,YAAY,IAAY,EAAE,QAAwB,EAAE,YAA8B,IAAI;;QAetF;;;;;;WAMG;QACI,QAAG,GAAG,CAAO,GAAW,EAAE,IAAS,EAAE,UAAmB,EAAE,eAAwB,EAAgB,EAAE;YACvG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAE1B,IAAI,IAAI,YAAY,KAAK,EAAE;gBACvB,8BAA8B;gBAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;gBAEtC,KAAK,MAAM,QAAQ,IAAI,IAAI,EAAE;oBACzB,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC;oBAClE,MAAM,WAAW,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;oBAExD,IAAI,UAAU,EAAE;wBACZ,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;qBACzD;yBAAM,IAAI,eAAe,EAAE;wBACxB,iCAAiC;wBACjC,OAAO,KAAK,CAAC,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,CAAC;QACzG,IAAI,CAAC,kBAAkB,GAAG,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC;QAEnG,IAAI,MAAA,IAAI,CAAC,SAAS,0CAAE,SAAS,EAAE;YAC3B,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,aAAG,CAAC,CAAC;SACjC;IACL,CAAC;CAuKJ;AApMD,gCAoMC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemio/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.25-dev.722047718",
|
|
4
4
|
"description": "Golemio Core Module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"@types/chai-as-promised": "7.1.2",
|
|
37
37
|
"@types/content-type": "^1.1.3",
|
|
38
38
|
"@types/debug": "0.0.31",
|
|
39
|
-
"@types/decompress": "^4.2.3",
|
|
40
39
|
"@types/mocha": "^8.2.0",
|
|
41
40
|
"@types/node": "^16.11.35",
|
|
42
41
|
"@types/sinon": "7.0.13",
|
|
43
42
|
"@types/ssh2-sftp-client": "^5.3.1",
|
|
44
43
|
"@types/supertest": "^2.0.11",
|
|
45
44
|
"@types/uuid": "^8.3.4",
|
|
45
|
+
"@types/yauzl": "^2.10.0",
|
|
46
46
|
"chai": "4.2.0",
|
|
47
47
|
"chai-as-promised": "7.1.1",
|
|
48
48
|
"cross-env": "^7.0.3",
|
|
@@ -97,7 +97,6 @@
|
|
|
97
97
|
"class-validator": "^0.13.2",
|
|
98
98
|
"content-type": "^1.0.4",
|
|
99
99
|
"debug": "3.1.0",
|
|
100
|
-
"decompress": "^4.2.1",
|
|
101
100
|
"dotenv": "^8.2.0",
|
|
102
101
|
"express": "^4.16.4",
|
|
103
102
|
"express-validator": "^5.3.1",
|
|
@@ -120,12 +119,15 @@
|
|
|
120
119
|
"pino-pretty": "^9.1.1",
|
|
121
120
|
"prom-client": "^14.0.0",
|
|
122
121
|
"redis": "^3.1.1",
|
|
122
|
+
"redis-rstream": "^1.0.1",
|
|
123
123
|
"redis-semaphore": "^5.2.0",
|
|
124
|
+
"redis-wstream": "^1.0.0",
|
|
124
125
|
"request": "2.88.0",
|
|
125
126
|
"request-promise": "^4.2.5",
|
|
126
127
|
"sequelize": "^6.21.2",
|
|
127
128
|
"ssh2-sftp-client": "^7.1.0",
|
|
128
|
-
"xml2js-es6-promise": "^1.1.1"
|
|
129
|
+
"xml2js-es6-promise": "^1.1.1",
|
|
130
|
+
"yauzl": "^2.10.0"
|
|
129
131
|
},
|
|
130
132
|
"resolutions": {}
|
|
131
|
-
}
|
|
133
|
+
}
|