@flowcore/data-pump 0.10.0 → 0.12.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/CHANGELOG.md +20 -0
- package/esm/data-pump/data-pump.d.ts +1 -0
- package/esm/data-pump/data-pump.d.ts.map +1 -1
- package/esm/data-pump/data-pump.js +11 -0
- package/esm/data-pump/data-source.d.ts +92 -8
- package/esm/data-pump/data-source.d.ts.map +1 -1
- package/esm/data-pump/data-source.js +75 -0
- package/esm/data-pump/no-op-logger.d.ts +3 -0
- package/esm/data-pump/no-op-logger.d.ts.map +1 -0
- package/esm/data-pump/no-op-logger.js +6 -0
- package/esm/data-pump/notifier.js +1 -1
- package/esm/mod.d.ts +1 -2
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -2
- package/package.json +1 -1
- package/script/data-pump/data-pump.d.ts +1 -0
- package/script/data-pump/data-pump.d.ts.map +1 -1
- package/script/data-pump/data-pump.js +11 -0
- package/script/data-pump/data-source.d.ts +92 -8
- package/script/data-pump/data-source.d.ts.map +1 -1
- package/script/data-pump/data-source.js +75 -0
- package/script/data-pump/no-op-logger.d.ts +3 -0
- package/script/data-pump/no-op-logger.d.ts.map +1 -0
- package/script/data-pump/no-op-logger.js +9 -0
- package/script/data-pump/notifier.js +2 -2
- package/script/mod.d.ts +1 -2
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +1 -2
- package/esm/lib/data-pump-create.d.ts +0 -46
- package/esm/lib/data-pump-create.d.ts.map +0 -1
- package/esm/lib/data-pump-create.js +0 -64
- package/esm/lib/data-pump.d.ts +0 -80
- package/esm/lib/data-pump.d.ts.map +0 -1
- package/esm/lib/data-pump.js +0 -437
- package/esm/lib/nats-notifier.d.ts +0 -18
- package/esm/lib/nats-notifier.d.ts.map +0 -1
- package/esm/lib/nats-notifier.js +0 -88
- package/esm/lib/ws-notifier.d.ts +0 -37
- package/esm/lib/ws-notifier.d.ts.map +0 -1
- package/esm/lib/ws-notifier.js +0 -86
- package/script/lib/data-pump-create.d.ts +0 -46
- package/script/lib/data-pump-create.d.ts.map +0 -1
- package/script/lib/data-pump-create.js +0 -68
- package/script/lib/data-pump.d.ts +0 -80
- package/script/lib/data-pump.d.ts.map +0 -1
- package/script/lib/data-pump.js +0 -441
- package/script/lib/nats-notifier.d.ts +0 -18
- package/script/lib/nats-notifier.d.ts.map +0 -1
- package/script/lib/nats-notifier.js +0 -115
- package/script/lib/ws-notifier.d.ts +0 -37
- package/script/lib/ws-notifier.d.ts.map +0 -1
- package/script/lib/ws-notifier.js +0 -90
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.NatsNotifier = void 0;
|
|
27
|
-
const Nats = __importStar(require("nats"));
|
|
28
|
-
class NatsNotifier {
|
|
29
|
-
constructor(options) {
|
|
30
|
-
Object.defineProperty(this, "options", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
configurable: true,
|
|
33
|
-
writable: true,
|
|
34
|
-
value: options
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(this, "nats", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
configurable: true,
|
|
39
|
-
writable: true,
|
|
40
|
-
value: void 0
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(this, "timeoutMs", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
configurable: true,
|
|
45
|
-
writable: true,
|
|
46
|
-
value: void 0
|
|
47
|
-
});
|
|
48
|
-
this.timeoutMs = options.timeoutMs ?? 20_000;
|
|
49
|
-
}
|
|
50
|
-
async start() {
|
|
51
|
-
if (this.nats) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
this.nats = await Nats.connect({ servers: this.options.servers });
|
|
55
|
-
}
|
|
56
|
-
async stop() {
|
|
57
|
-
if (this.nats) {
|
|
58
|
-
await this.nats.close();
|
|
59
|
-
this.nats = undefined;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
awaitMessage(subjects, timeoutMs) {
|
|
63
|
-
const abortController = new AbortController();
|
|
64
|
-
const promise = new Promise((resolve) => {
|
|
65
|
-
const timer = setTimeout(() => {
|
|
66
|
-
for (const subscription of subscriptions) {
|
|
67
|
-
subscription.unsubscribe();
|
|
68
|
-
}
|
|
69
|
-
resolve();
|
|
70
|
-
}, timeoutMs);
|
|
71
|
-
const subscriptions = [];
|
|
72
|
-
for (const subject of subjects) {
|
|
73
|
-
subscriptions.push(this.getSubscription(subject, (_message) => {
|
|
74
|
-
for (const subscription of subscriptions) {
|
|
75
|
-
clearTimeout(timer);
|
|
76
|
-
subscription.unsubscribe();
|
|
77
|
-
}
|
|
78
|
-
resolve();
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
abortController.signal.addEventListener("abort", () => {
|
|
82
|
-
for (const subscription of subscriptions) {
|
|
83
|
-
subscription.unsubscribe();
|
|
84
|
-
clearTimeout(timer);
|
|
85
|
-
}
|
|
86
|
-
resolve();
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
return [promise, abortController];
|
|
90
|
-
}
|
|
91
|
-
getSubscription(subject, onMessage) {
|
|
92
|
-
if (!this.nats) {
|
|
93
|
-
throw new Error("NatsClient is not started");
|
|
94
|
-
}
|
|
95
|
-
const subscription = this.nats.subscribe(subject);
|
|
96
|
-
(async () => {
|
|
97
|
-
for await (const message of subscription) {
|
|
98
|
-
await onMessage(message, subscription);
|
|
99
|
-
}
|
|
100
|
-
})().catch(console.error);
|
|
101
|
-
return subscription;
|
|
102
|
-
}
|
|
103
|
-
getNotifier() {
|
|
104
|
-
return {
|
|
105
|
-
wait: async (dataSource, signal) => {
|
|
106
|
-
await this.start();
|
|
107
|
-
const topics = dataSource.eventTypes.map((eventType) => `stored.event.notify.0.${dataSource.dataCoreId}.${dataSource.flowType}.${eventType}`);
|
|
108
|
-
const [promise, abortController] = this.awaitMessage(topics, this.timeoutMs);
|
|
109
|
-
signal?.addEventListener("abort", () => abortController.abort());
|
|
110
|
-
await promise;
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
exports.NatsNotifier = NatsNotifier;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { DataPumpNotifier, Logger } from "./data-pump.js";
|
|
2
|
-
interface WebSocketNotifierOptionsAuthOidcClient {
|
|
3
|
-
oidcClient: {
|
|
4
|
-
getToken: () => Promise<{
|
|
5
|
-
accessToken: string;
|
|
6
|
-
}>;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
interface WebSocketNotifierOptionsAuthApiKey {
|
|
10
|
-
apiKey: string;
|
|
11
|
-
apiKeyId: string;
|
|
12
|
-
}
|
|
13
|
-
type WebSocketNotifierOptionsAuth = WebSocketNotifierOptionsAuthOidcClient | WebSocketNotifierOptionsAuthApiKey;
|
|
14
|
-
export declare class WebSocketNotifier {
|
|
15
|
-
private readonly authOptions;
|
|
16
|
-
private subject?;
|
|
17
|
-
private notificationClient?;
|
|
18
|
-
private dataSource;
|
|
19
|
-
private eventResolver?;
|
|
20
|
-
private logger?;
|
|
21
|
-
private timeoutMs;
|
|
22
|
-
constructor(options: {
|
|
23
|
-
auth: WebSocketNotifierOptionsAuth;
|
|
24
|
-
dataSource: {
|
|
25
|
-
tenant: string;
|
|
26
|
-
dataCore: string;
|
|
27
|
-
flowType: string;
|
|
28
|
-
eventTypes: string[];
|
|
29
|
-
};
|
|
30
|
-
logger?: Logger;
|
|
31
|
-
timeoutMs?: number;
|
|
32
|
-
});
|
|
33
|
-
private onEvent;
|
|
34
|
-
getNotifier(): DataPumpNotifier;
|
|
35
|
-
}
|
|
36
|
-
export {};
|
|
37
|
-
//# sourceMappingURL=ws-notifier.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ws-notifier.d.ts","sourceRoot":"","sources":["../../src/lib/ws-notifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAI9D,UAAU,sCAAsC;IAC9C,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,OAAO,CAAC;YAAE,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KACjD,CAAA;CACF;AAED,UAAU,kCAAkC;IAC1C,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,KAAK,4BAA4B,GAAG,sCAAsC,GAAG,kCAAkC,CAAA;AAE/G,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8B;IAC1D,OAAO,CAAC,OAAO,CAAC,CAA4B;IAC5C,OAAO,CAAC,kBAAkB,CAAC,CAAoB;IAC/C,OAAO,CAAC,UAAU,CAKjB;IACD,OAAO,CAAC,aAAa,CAAC,CAAY;IAClC,OAAO,CAAC,MAAM,CAAC,CAAQ;IACvB,OAAO,CAAC,SAAS,CAAQ;gBAEb,OAAO,EAAE;QACnB,IAAI,EAAE,4BAA4B,CAAA;QAClC,UAAU,EAAE;YACV,MAAM,EAAE,MAAM,CAAA;YACd,QAAQ,EAAE,MAAM,CAAA;YAChB,QAAQ,EAAE,MAAM,CAAA;YAChB,UAAU,EAAE,MAAM,EAAE,CAAA;SACrB,CAAA;QACD,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB;IAOD,OAAO,CAAC,OAAO;IAMR,WAAW,IAAI,gBAAgB;CAkCvC"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebSocketNotifier = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const mod_js_1 = require("../deps/jsr.io/@flowcore/sdk/1.26.3/src/mod.js");
|
|
6
|
-
class WebSocketNotifier {
|
|
7
|
-
constructor(options) {
|
|
8
|
-
Object.defineProperty(this, "authOptions", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: void 0
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "subject", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: void 0
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(this, "notificationClient", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: void 0
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(this, "dataSource", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
configurable: true,
|
|
29
|
-
writable: true,
|
|
30
|
-
value: void 0
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(this, "eventResolver", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true,
|
|
35
|
-
writable: true,
|
|
36
|
-
value: void 0
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(this, "logger", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: true,
|
|
42
|
-
value: void 0
|
|
43
|
-
});
|
|
44
|
-
Object.defineProperty(this, "timeoutMs", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
configurable: true,
|
|
47
|
-
writable: true,
|
|
48
|
-
value: void 0
|
|
49
|
-
});
|
|
50
|
-
this.authOptions = options.auth;
|
|
51
|
-
this.dataSource = options.dataSource;
|
|
52
|
-
this.logger = options.logger;
|
|
53
|
-
this.timeoutMs = options.timeoutMs ?? 20_000;
|
|
54
|
-
}
|
|
55
|
-
onEvent(event) {
|
|
56
|
-
if (this.dataSource.eventTypes.includes(event.data.eventType)) {
|
|
57
|
-
this.eventResolver?.();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
getNotifier() {
|
|
61
|
-
return {
|
|
62
|
-
wait: async (_, signal) => {
|
|
63
|
-
this.subject = new rxjs_1.Subject();
|
|
64
|
-
this.subject.subscribe({
|
|
65
|
-
next: this.onEvent.bind(this),
|
|
66
|
-
error: (error) => this.logger?.error("Notification stream error:", error),
|
|
67
|
-
complete: () => this.logger?.info("Notification stream completed"),
|
|
68
|
-
});
|
|
69
|
-
this.notificationClient = new mod_js_1.NotificationClient(this.subject, this.authOptions, {
|
|
70
|
-
tenant: this.dataSource.tenant,
|
|
71
|
-
dataCore: this.dataSource.dataCore,
|
|
72
|
-
flowType: this.dataSource.flowType,
|
|
73
|
-
}, {
|
|
74
|
-
logger: this.logger,
|
|
75
|
-
reconnectInterval: 1000,
|
|
76
|
-
});
|
|
77
|
-
await this.notificationClient.connect();
|
|
78
|
-
const promise = new Promise((resolve) => {
|
|
79
|
-
this.eventResolver = resolve;
|
|
80
|
-
});
|
|
81
|
-
setTimeout(() => this.eventResolver?.(), this.timeoutMs);
|
|
82
|
-
signal?.addEventListener("abort", () => this.eventResolver?.());
|
|
83
|
-
await promise;
|
|
84
|
-
this.eventResolver = undefined;
|
|
85
|
-
this.notificationClient.disconnect();
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.WebSocketNotifier = WebSocketNotifier;
|