@lad-tech/nsc-toolkit 1.28.1 → 1.28.2
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/.vscode/launch.json +77 -0
- package/.vscode/tasks.json +25 -0
- package/package.json +1 -1
- package/CHANGELOG.md +0 -6
- package/dist/Client.js +0 -303
- package/dist/Container.js +0 -124
- package/dist/Meter.js +0 -77
- package/dist/Method.js +0 -7
- package/dist/Root.js +0 -120
- package/dist/Service.js +0 -677
- package/dist/StreamBatchMsgFetcher.js +0 -17
- package/dist/StreamManager.js +0 -173
- package/dist/StreamOptions/BufferToJsonTransform.js +0 -34
- package/dist/StreamOptions/JsonToBufferTransform.js +0 -11
- package/dist/StreamOptions/index.js +0 -19
- package/dist/StreamSingleMsgFetcher.js +0 -28
- package/dist/Union/Broker.js +0 -95
- package/dist/Union/ConsumerApi.js +0 -28
- package/dist/Union/JetStreamClient.js +0 -40
- package/dist/Union/JetStreamManager.js +0 -26
- package/dist/Union/StreamApi.js +0 -46
- package/dist/Union/Subscription.js +0 -47
- package/dist/Union/index.js +0 -18
- package/dist/index.js +0 -24
- package/dist/injector.js +0 -65
- package/dist/interfaces.js +0 -16
- package/dist/types/Client.d.ts +0 -32
- package/dist/types/Container.d.ts +0 -54
- package/dist/types/Meter.d.ts +0 -13
- package/dist/types/Method.d.ts +0 -6
- package/dist/types/Root.d.ts +0 -29
- package/dist/types/Service.d.ts +0 -140
- package/dist/types/StreamBatchMsgFetcher.d.ts +0 -13
- package/dist/types/StreamManager.d.ts +0 -26
- package/dist/types/StreamOptions/BufferToJsonTransform.d.ts +0 -14
- package/dist/types/StreamOptions/JsonToBufferTransform.d.ts +0 -6
- package/dist/types/StreamOptions/index.d.ts +0 -2
- package/dist/types/StreamSingleMsgFetcher.d.ts +0 -16
- package/dist/types/Union/Broker.d.ts +0 -32
- package/dist/types/Union/ConsumerApi.d.ts +0 -16
- package/dist/types/Union/JetStreamClient.d.ts +0 -18
- package/dist/types/Union/JetStreamManager.d.ts +0 -12
- package/dist/types/Union/StreamApi.d.ts +0 -16
- package/dist/types/Union/Subscription.d.ts +0 -19
- package/dist/types/Union/index.d.ts +0 -1
- package/dist/types/index.d.ts +0 -7
- package/dist/types/injector.d.ts +0 -14
- package/dist/types/interfaces.d.ts +0 -181
package/dist/StreamManager.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StreamManager = void 0;
|
|
4
|
-
const nats_1 = require("nats");
|
|
5
|
-
const Root_1 = require("./Root");
|
|
6
|
-
const StreamBatchMsgFetcher_1 = require("./StreamBatchMsgFetcher");
|
|
7
|
-
const types_1 = require("nats/lib/jetstream/types");
|
|
8
|
-
const StreamSingleMsgFetcher_1 = require("./StreamSingleMsgFetcher");
|
|
9
|
-
class StreamManager extends Root_1.Root {
|
|
10
|
-
constructor(param) {
|
|
11
|
-
super(param.broker, param.outputFormatter);
|
|
12
|
-
this.param = param;
|
|
13
|
-
this.STAR_WILDCARD = '*';
|
|
14
|
-
this.GREATER_WILDCARD = '>';
|
|
15
|
-
this.TWO_WEEKS_IN_SECOND = 1209600;
|
|
16
|
-
this.ONE_DAY_IN_SECOND = 86400;
|
|
17
|
-
this.CONSUMER_NOT_FOUND = 'consumer not found';
|
|
18
|
-
this.defaultStreamOption = {
|
|
19
|
-
storage: 'file',
|
|
20
|
-
retentionPolicy: 'limits',
|
|
21
|
-
discardPolicy: 'old',
|
|
22
|
-
messageTTL: this.TWO_WEEKS_IN_SECOND,
|
|
23
|
-
duplicateTrackingTime: this.ONE_DAY_IN_SECOND,
|
|
24
|
-
replication: 1,
|
|
25
|
-
rollUps: true,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
static isPullConsumerOptions(setting) {
|
|
29
|
-
return !!(setting === null || setting === void 0 ? void 0 : setting.batch);
|
|
30
|
-
}
|
|
31
|
-
static isStreamFetcher(consumer) {
|
|
32
|
-
return !!(consumer === null || consumer === void 0 ? void 0 : consumer.fetch);
|
|
33
|
-
}
|
|
34
|
-
async createStreams() {
|
|
35
|
-
if (!this.jsm) {
|
|
36
|
-
this.jsm = await this.param.broker.jetstreamManager();
|
|
37
|
-
}
|
|
38
|
-
for await (const { action, ...options } of this.param.options.actions) {
|
|
39
|
-
const streamName = this.getStreamName(action);
|
|
40
|
-
const config = {
|
|
41
|
-
name: streamName,
|
|
42
|
-
subjects: [`${this.param.serviceName}.${this.param.options.prefix}.${action}`],
|
|
43
|
-
retention: (options.retentionPolicy || this.defaultStreamOption.retentionPolicy),
|
|
44
|
-
storage: (options.storage || this.defaultStreamOption.storage),
|
|
45
|
-
num_replicas: options.replication || this.defaultStreamOption.replication,
|
|
46
|
-
discard: (options.discardPolicy || this.defaultStreamOption.discardPolicy),
|
|
47
|
-
max_age: this.convertSecondsToNanoseconds(options.messageTTL || this.defaultStreamOption.messageTTL),
|
|
48
|
-
max_bytes: options.maxBytes,
|
|
49
|
-
duplicate_window: this.convertSecondsToNanoseconds(options.duplicateTrackingTime || this.defaultStreamOption.duplicateTrackingTime),
|
|
50
|
-
allow_rollup_hdrs: options.rollUps || this.defaultStreamOption.rollUps,
|
|
51
|
-
};
|
|
52
|
-
const existingStream = await this.jsm.streams.info(streamName).catch(error => {
|
|
53
|
-
if (this.isNotFoundStreamError(error)) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
throw error;
|
|
57
|
-
});
|
|
58
|
-
if (!existingStream) {
|
|
59
|
-
await this.jsm.streams.add(config);
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
await this.jsm.streams.update(streamName, { ...existingStream.config, ...config });
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async createConsumer(serviceNameFrom, eventName, setting) {
|
|
66
|
-
const consumerName = this.capitalizeFirstLetter(serviceNameFrom) + this.capitalizeFirstLetter(eventName);
|
|
67
|
-
const prefix = this.param.options.prefix;
|
|
68
|
-
const subject = `${this.param.serviceName}.${prefix}.${eventName}.*`;
|
|
69
|
-
if (!this.jsm) {
|
|
70
|
-
this.jsm = await this.param.broker.jetstreamManager();
|
|
71
|
-
}
|
|
72
|
-
const options = (0, nats_1.consumerOpts)();
|
|
73
|
-
const isPullConsumer = StreamManager.isPullConsumerOptions(setting);
|
|
74
|
-
options
|
|
75
|
-
.durable(consumerName)
|
|
76
|
-
.filterSubject(subject)
|
|
77
|
-
.maxAckPending((setting === null || setting === void 0 ? void 0 : setting.maxPending) || 10);
|
|
78
|
-
if (isPullConsumer) {
|
|
79
|
-
if (setting.ackPolicy === 'all') {
|
|
80
|
-
options.manualAck();
|
|
81
|
-
options.ackAll();
|
|
82
|
-
}
|
|
83
|
-
if (setting.ackPolicy === 'none') {
|
|
84
|
-
options.ackNone();
|
|
85
|
-
}
|
|
86
|
-
if (!setting.ackPolicy) {
|
|
87
|
-
options.manualAck();
|
|
88
|
-
options.ackExplicit();
|
|
89
|
-
}
|
|
90
|
-
if (setting.maxPullRequestExpires) {
|
|
91
|
-
options.maxPullRequestExpires(setting.maxPullRequestExpires);
|
|
92
|
-
}
|
|
93
|
-
if (setting.maxPullRequestBatch) {
|
|
94
|
-
options.maxPullBatch(setting.maxPullRequestBatch);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
options.manualAck();
|
|
99
|
-
options.ackExplicit();
|
|
100
|
-
}
|
|
101
|
-
if (setting === null || setting === void 0 ? void 0 : setting.maxAckWaiting) {
|
|
102
|
-
options.ackWait(setting.maxAckWaiting);
|
|
103
|
-
}
|
|
104
|
-
if (setting === null || setting === void 0 ? void 0 : setting.queue) {
|
|
105
|
-
options.queue(setting.queue);
|
|
106
|
-
}
|
|
107
|
-
if (setting === null || setting === void 0 ? void 0 : setting.deliver) {
|
|
108
|
-
if (setting.deliver === 'new') {
|
|
109
|
-
options.deliverNew();
|
|
110
|
-
}
|
|
111
|
-
if (setting.deliver === 'all') {
|
|
112
|
-
options.deliverAll();
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
const streamName = await this.jsm.streams.find(subject);
|
|
116
|
-
if (!streamName) {
|
|
117
|
-
throw new Error(`Error creating consumer ${consumerName}. Stream for subject ${subject} not found`);
|
|
118
|
-
}
|
|
119
|
-
if ((0, types_1.isConsumerOptsBuilder)(options)) {
|
|
120
|
-
const isConsumerExist = await this.jsm.consumers.info(streamName, consumerName).catch(async (error) => {
|
|
121
|
-
if (error.message === this.CONSUMER_NOT_FOUND) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
throw error;
|
|
125
|
-
});
|
|
126
|
-
if (!isConsumerExist) {
|
|
127
|
-
await this.jsm.consumers.add(streamName, { ...options.config, filter_subject: subject });
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
await this.jsm.consumers.update(streamName, consumerName, {
|
|
131
|
-
...options.config,
|
|
132
|
-
filter_subject: subject,
|
|
133
|
-
deliver_subject: undefined,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
const consumer = await this.broker.jetstream().consumers.get(streamName, consumerName);
|
|
138
|
-
return isPullConsumer
|
|
139
|
-
? new StreamBatchMsgFetcher_1.StreamBatchMsgFetcher(consumer, {
|
|
140
|
-
batchSize: setting.maxPullRequestBatch,
|
|
141
|
-
batchTimeout: setting.maxPullRequestExpires,
|
|
142
|
-
})
|
|
143
|
-
: new StreamSingleMsgFetcher_1.StreamSingleMsgFetcher(consumer);
|
|
144
|
-
}
|
|
145
|
-
getStreamName(eventName) {
|
|
146
|
-
const serviceName = this.capitalizeFirstLetter(this.param.serviceName);
|
|
147
|
-
const prefix = this.buildPrefixForStreamName(this.param.options.prefix);
|
|
148
|
-
let streamName = `${serviceName}${prefix}`;
|
|
149
|
-
if (eventName !== this.STAR_WILDCARD && eventName !== this.GREATER_WILDCARD) {
|
|
150
|
-
streamName += this.capitalizeFirstLetter(eventName);
|
|
151
|
-
}
|
|
152
|
-
return streamName;
|
|
153
|
-
}
|
|
154
|
-
isNotFoundStreamError(error) {
|
|
155
|
-
const ERROR_TYPE = 'NatsError';
|
|
156
|
-
const ERROR_NOT_FOUND_STREAM = 'stream not found';
|
|
157
|
-
if (error instanceof Error) {
|
|
158
|
-
return error.name === ERROR_TYPE && error.message === ERROR_NOT_FOUND_STREAM;
|
|
159
|
-
}
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
buildPrefixForStreamName(prefix) {
|
|
163
|
-
return prefix.split(this.SUBJECT_DELIMITER).map(this.capitalizeFirstLetter).join();
|
|
164
|
-
}
|
|
165
|
-
capitalizeFirstLetter(word) {
|
|
166
|
-
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
167
|
-
}
|
|
168
|
-
convertSecondsToNanoseconds(seconds) {
|
|
169
|
-
return seconds * 1000000000;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
exports.StreamManager = StreamManager;
|
|
173
|
-
//# sourceMappingURL=StreamManager.js.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BufferToJsonTransform = void 0;
|
|
4
|
-
const stream_1 = require("stream");
|
|
5
|
-
class BufferToJsonTransform extends stream_1.Transform {
|
|
6
|
-
constructor(options) {
|
|
7
|
-
super({ objectMode: true, highWaterMark: 10, ...options });
|
|
8
|
-
this.head = Buffer.from('');
|
|
9
|
-
this.logger = options.logger;
|
|
10
|
-
}
|
|
11
|
-
async _transform(tail, _, cb) {
|
|
12
|
-
var _a;
|
|
13
|
-
try {
|
|
14
|
-
tail = Buffer.concat([this.head, Buffer.from(tail)]);
|
|
15
|
-
const jsonData = JSON.parse(tail.toString());
|
|
16
|
-
cb(null, jsonData);
|
|
17
|
-
this.head = Buffer.from('');
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
if (error instanceof SyntaxError) {
|
|
21
|
-
this.head = Buffer.from(tail);
|
|
22
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.error(BufferToJsonTransform.errors.CONVERSION_ERROR, tail.toString());
|
|
23
|
-
cb();
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
cb(error);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.BufferToJsonTransform = BufferToJsonTransform;
|
|
31
|
-
BufferToJsonTransform.errors = {
|
|
32
|
-
CONVERSION_ERROR: 'Failed to convert data',
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=BufferToJsonTransform.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JsonToBufferTransform = void 0;
|
|
4
|
-
const stream_1 = require("stream");
|
|
5
|
-
class JsonToBufferTransform extends stream_1.Transform {
|
|
6
|
-
_transform(chunk, encoding, cb) {
|
|
7
|
-
cb(null, Buffer.from(JSON.stringify(chunk)));
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.JsonToBufferTransform = JsonToBufferTransform;
|
|
11
|
-
//# sourceMappingURL=JsonToBufferTransform.js.map
|
|
@@ -1,19 +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 __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("./JsonToBufferTransform"), exports);
|
|
18
|
-
__exportStar(require("./BufferToJsonTransform"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StreamSingleMsgFetcher = void 0;
|
|
4
|
-
class StreamSingleMsgFetcher {
|
|
5
|
-
constructor(consumer) {
|
|
6
|
-
this.consumer = consumer;
|
|
7
|
-
this.done = false;
|
|
8
|
-
}
|
|
9
|
-
[Symbol.asyncIterator]() {
|
|
10
|
-
return {
|
|
11
|
-
next: async () => {
|
|
12
|
-
const msg = await this.consumer.next();
|
|
13
|
-
if (msg) {
|
|
14
|
-
return {
|
|
15
|
-
value: msg,
|
|
16
|
-
done: this.done,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
return { done: false };
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
unsubscribe() {
|
|
24
|
-
this.done = true;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.StreamSingleMsgFetcher = StreamSingleMsgFetcher;
|
|
28
|
-
//# sourceMappingURL=StreamSingleMsgFetcher.js.map
|
package/dist/Union/Broker.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnionBroker = void 0;
|
|
4
|
-
const node_stream_1 = require("node:stream");
|
|
5
|
-
const node_stream_2 = require("node:stream");
|
|
6
|
-
const node_crypto_1 = require("node:crypto");
|
|
7
|
-
const Subscription_1 = require("./Subscription");
|
|
8
|
-
const JetStreamManager_1 = require("./JetStreamManager");
|
|
9
|
-
const JetStreamClient_1 = require("./JetStreamClient");
|
|
10
|
-
class UnionBroker {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.isUnion = true;
|
|
13
|
-
this.DEFAULT_TIMEOUT = 60000; // 1 Minut
|
|
14
|
-
this.emitter = new node_stream_1.EventEmitter();
|
|
15
|
-
}
|
|
16
|
-
publishMessage(msg) {
|
|
17
|
-
throw new Error('Method not implemented.');
|
|
18
|
-
}
|
|
19
|
-
respondMessage(msg) {
|
|
20
|
-
throw new Error('Method not implemented.');
|
|
21
|
-
}
|
|
22
|
-
requestMany(subject, payload, opts) {
|
|
23
|
-
throw new Error('Method not implemented.');
|
|
24
|
-
}
|
|
25
|
-
reconnect() {
|
|
26
|
-
throw new Error('Method not implemented.');
|
|
27
|
-
}
|
|
28
|
-
closed() {
|
|
29
|
-
return Promise.resolve();
|
|
30
|
-
}
|
|
31
|
-
close() {
|
|
32
|
-
return Promise.resolve();
|
|
33
|
-
}
|
|
34
|
-
publish(subject, data, options) {
|
|
35
|
-
this.emitter.emit(subject, { data });
|
|
36
|
-
}
|
|
37
|
-
subscribe(subject, opts) {
|
|
38
|
-
const subscription = new Subscription_1.UnionSubscription({ objectMode: true });
|
|
39
|
-
const listener = (message, uniqResponseKey) => {
|
|
40
|
-
if (uniqResponseKey) {
|
|
41
|
-
message['respond'] = (data) => this.emitter.emit(uniqResponseKey, { data });
|
|
42
|
-
}
|
|
43
|
-
subscription.write(message);
|
|
44
|
-
};
|
|
45
|
-
this.emitter.on(subject, listener);
|
|
46
|
-
subscription.on('close', () => {
|
|
47
|
-
this.emitter.off(subject, listener);
|
|
48
|
-
});
|
|
49
|
-
return subscription;
|
|
50
|
-
}
|
|
51
|
-
request(subject, data, opts) {
|
|
52
|
-
const uniqResponseKey = (0, node_crypto_1.randomUUID)();
|
|
53
|
-
const timeout = (opts === null || opts === void 0 ? void 0 : opts.timeout) || this.DEFAULT_TIMEOUT;
|
|
54
|
-
this.emitter.emit(subject, { data }, uniqResponseKey);
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
const timer = setTimeout(reject, timeout);
|
|
57
|
-
this.emitter.once(uniqResponseKey, response => {
|
|
58
|
-
clearTimeout(timer);
|
|
59
|
-
resolve(response);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
flush() {
|
|
64
|
-
return Promise.resolve();
|
|
65
|
-
}
|
|
66
|
-
drain() {
|
|
67
|
-
return Promise.resolve();
|
|
68
|
-
}
|
|
69
|
-
isClosed() {
|
|
70
|
-
throw new Error('Method isClosed not implemented.');
|
|
71
|
-
}
|
|
72
|
-
isDraining() {
|
|
73
|
-
throw new Error('Method isDraining not implemented.');
|
|
74
|
-
}
|
|
75
|
-
getServer() {
|
|
76
|
-
throw new Error('Method getServer not implemented.');
|
|
77
|
-
}
|
|
78
|
-
status() {
|
|
79
|
-
return new node_stream_2.PassThrough();
|
|
80
|
-
}
|
|
81
|
-
stats() {
|
|
82
|
-
throw new Error('Method stats not implemented.');
|
|
83
|
-
}
|
|
84
|
-
jetstreamManager(opts) {
|
|
85
|
-
return Promise.resolve(JetStreamManager_1.jetStreamManagerBlank);
|
|
86
|
-
}
|
|
87
|
-
jetstream(opts) {
|
|
88
|
-
return new JetStreamClient_1.JetStreamClientBlank(this.emitter);
|
|
89
|
-
}
|
|
90
|
-
rtt() {
|
|
91
|
-
throw new Error('Method rtt not implemented.');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.UnionBroker = UnionBroker;
|
|
95
|
-
//# sourceMappingURL=Broker.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConsumerApiBlank = void 0;
|
|
4
|
-
class ConsumerApiBlank {
|
|
5
|
-
info(stream, consumer) {
|
|
6
|
-
throw new Error('Method not implemented.');
|
|
7
|
-
}
|
|
8
|
-
add(stream, cfg) {
|
|
9
|
-
return Promise.resolve({});
|
|
10
|
-
}
|
|
11
|
-
update(stream, durable, cfg) {
|
|
12
|
-
throw new Error('Method not implemented.');
|
|
13
|
-
}
|
|
14
|
-
delete(stream, consumer) {
|
|
15
|
-
throw new Error('Method not implemented.');
|
|
16
|
-
}
|
|
17
|
-
list(stream) {
|
|
18
|
-
throw new Error('Method not implemented.');
|
|
19
|
-
}
|
|
20
|
-
pause(stream, name, until) {
|
|
21
|
-
throw new Error('Method not implemented.');
|
|
22
|
-
}
|
|
23
|
-
resume(stream, name) {
|
|
24
|
-
throw new Error('Method not implemented.');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.ConsumerApiBlank = ConsumerApiBlank;
|
|
28
|
-
//# sourceMappingURL=ConsumerApi.js.map
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JetStreamClientBlank = void 0;
|
|
4
|
-
const Subscription_1 = require("./Subscription");
|
|
5
|
-
class JetStreamClientBlank {
|
|
6
|
-
constructor(emitter) {
|
|
7
|
-
this.emitter = emitter;
|
|
8
|
-
}
|
|
9
|
-
jetstreamManager(checkAPI) {
|
|
10
|
-
throw new Error('Method not implemented.');
|
|
11
|
-
}
|
|
12
|
-
getOptions() {
|
|
13
|
-
throw new Error('Method not implemented.');
|
|
14
|
-
}
|
|
15
|
-
publish(subj, data, options) {
|
|
16
|
-
throw new Error('Method publish not implemented.');
|
|
17
|
-
}
|
|
18
|
-
pull(stream, durable, expires) {
|
|
19
|
-
throw new Error('Method pull not implemented.');
|
|
20
|
-
}
|
|
21
|
-
fetch(stream, durable, opts) {
|
|
22
|
-
throw new Error('Method fetch not implemented.');
|
|
23
|
-
}
|
|
24
|
-
pullSubscribe(subject, opts) {
|
|
25
|
-
throw new Error('Method pullSubscribe not implemented.');
|
|
26
|
-
}
|
|
27
|
-
subscribe(subject, opts) {
|
|
28
|
-
const subscription = new Subscription_1.UnionSubscription({ objectMode: true });
|
|
29
|
-
const listener = ({ data }) => {
|
|
30
|
-
subscription.write({ data, ack: () => Promise.resolve(), nak: () => Promise.resolve() });
|
|
31
|
-
};
|
|
32
|
-
this.emitter.on(subject, listener);
|
|
33
|
-
subscription.on('close', () => {
|
|
34
|
-
this.emitter.off(subject, listener);
|
|
35
|
-
});
|
|
36
|
-
return Promise.resolve(subscription);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.JetStreamClientBlank = JetStreamClientBlank;
|
|
40
|
-
//# sourceMappingURL=JetStreamClient.js.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jetStreamManagerBlank = exports.JetStreamManagerBlank = void 0;
|
|
4
|
-
const StreamApi_1 = require("./StreamApi");
|
|
5
|
-
const ConsumerApi_1 = require("./ConsumerApi");
|
|
6
|
-
class JetStreamManagerBlank {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.consumers = new ConsumerApi_1.ConsumerApiBlank();
|
|
9
|
-
this.streams = new StreamApi_1.StreamApiBlank();
|
|
10
|
-
}
|
|
11
|
-
getOptions() {
|
|
12
|
-
throw new Error('Method not implemented.');
|
|
13
|
-
}
|
|
14
|
-
jetstream() {
|
|
15
|
-
throw new Error('Method not implemented.');
|
|
16
|
-
}
|
|
17
|
-
getAccountInfo() {
|
|
18
|
-
throw new Error('Method getAccountInfo not implemented.');
|
|
19
|
-
}
|
|
20
|
-
advisories() {
|
|
21
|
-
throw new Error('Method advisories not implemented.');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.JetStreamManagerBlank = JetStreamManagerBlank;
|
|
25
|
-
exports.jetStreamManagerBlank = new JetStreamManagerBlank();
|
|
26
|
-
//# sourceMappingURL=JetStreamManager.js.map
|
package/dist/Union/StreamApi.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StreamApiBlank = void 0;
|
|
4
|
-
class StreamApiBlank {
|
|
5
|
-
listKvs() {
|
|
6
|
-
throw new Error('Method not implemented.');
|
|
7
|
-
}
|
|
8
|
-
listObjectStores() {
|
|
9
|
-
throw new Error('Method not implemented.');
|
|
10
|
-
}
|
|
11
|
-
names(subject) {
|
|
12
|
-
throw new Error('Method not implemented.');
|
|
13
|
-
}
|
|
14
|
-
get(name) {
|
|
15
|
-
throw new Error('Method not implemented.');
|
|
16
|
-
}
|
|
17
|
-
info(stream, opts) {
|
|
18
|
-
return Promise.resolve({});
|
|
19
|
-
}
|
|
20
|
-
add(cfg) {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
update(name, cfg) {
|
|
24
|
-
return {};
|
|
25
|
-
}
|
|
26
|
-
purge(stream, opts) {
|
|
27
|
-
throw new Error('Method purge not implemented.');
|
|
28
|
-
}
|
|
29
|
-
delete(stream) {
|
|
30
|
-
throw new Error('Method delete not implemented.');
|
|
31
|
-
}
|
|
32
|
-
list() {
|
|
33
|
-
throw new Error('Method list not implemented.');
|
|
34
|
-
}
|
|
35
|
-
deleteMessage(stream, seq, erase) {
|
|
36
|
-
throw new Error('Method deleteMessage not implemented.');
|
|
37
|
-
}
|
|
38
|
-
getMessage(stream, query) {
|
|
39
|
-
throw new Error('Method getMessage not implemented.');
|
|
40
|
-
}
|
|
41
|
-
find(subject) {
|
|
42
|
-
return Promise.resolve('Ok');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.StreamApiBlank = StreamApiBlank;
|
|
46
|
-
//# sourceMappingURL=StreamApi.js.map
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnionSubscription = void 0;
|
|
4
|
-
const node_stream_1 = require("node:stream");
|
|
5
|
-
class UnionSubscription extends node_stream_1.PassThrough {
|
|
6
|
-
unsubscribe(max) {
|
|
7
|
-
this.destroy();
|
|
8
|
-
}
|
|
9
|
-
drain() {
|
|
10
|
-
throw new Error('Method drain not implemented.');
|
|
11
|
-
}
|
|
12
|
-
isDraining() {
|
|
13
|
-
throw new Error('Method isDraining not implemented.');
|
|
14
|
-
}
|
|
15
|
-
isClosed() {
|
|
16
|
-
throw new Error('Method isClosed not implemented.');
|
|
17
|
-
}
|
|
18
|
-
callback(err, msg) {
|
|
19
|
-
throw new Error('Method callback not implemented.');
|
|
20
|
-
}
|
|
21
|
-
getSubject() {
|
|
22
|
-
throw new Error('Method getSubject not implemented.');
|
|
23
|
-
}
|
|
24
|
-
getReceived() {
|
|
25
|
-
throw new Error('Method getReceived not implemented.');
|
|
26
|
-
}
|
|
27
|
-
getProcessed() {
|
|
28
|
-
throw new Error('Method getProcessed not implemented.');
|
|
29
|
-
}
|
|
30
|
-
getPending() {
|
|
31
|
-
throw new Error('Method getPending not implemented.');
|
|
32
|
-
}
|
|
33
|
-
getID() {
|
|
34
|
-
throw new Error('Method getID not implemented.');
|
|
35
|
-
}
|
|
36
|
-
getMax() {
|
|
37
|
-
throw new Error('Method getMax not implemented.');
|
|
38
|
-
}
|
|
39
|
-
destroy(error) {
|
|
40
|
-
throw new Error('Method destroy not implemented.');
|
|
41
|
-
}
|
|
42
|
-
consumerInfo() {
|
|
43
|
-
throw new Error('Method consumerInfo not implemented.');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.UnionSubscription = UnionSubscription;
|
|
47
|
-
//# sourceMappingURL=Subscription.js.map
|
package/dist/Union/index.js
DELETED
|
@@ -1,18 +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 __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("./Broker"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js
DELETED
|
@@ -1,24 +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 __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("./Service"), exports);
|
|
18
|
-
__exportStar(require("./Client"), exports);
|
|
19
|
-
__exportStar(require("./Method"), exports);
|
|
20
|
-
__exportStar(require("./injector"), exports);
|
|
21
|
-
__exportStar(require("./Container"), exports);
|
|
22
|
-
__exportStar(require("./interfaces"), exports);
|
|
23
|
-
__exportStar(require("./StreamOptions"), exports);
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
package/dist/injector.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inject = exports.instance = exports.service = exports.related = exports.ConstructorDependencyKey = exports.InstanceContainer = exports.ServiceContainer = exports.dependencyStorageMetaKey = void 0;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const serviceMetaKey = Symbol('services');
|
|
6
|
-
const instanceMetaKey = Symbol('instance');
|
|
7
|
-
exports.dependencyStorageMetaKey = Symbol('dependency');
|
|
8
|
-
exports.ServiceContainer = new Map();
|
|
9
|
-
exports.InstanceContainer = new Map();
|
|
10
|
-
exports.ConstructorDependencyKey = 'constructor';
|
|
11
|
-
function related(target) {
|
|
12
|
-
const dependencies = Reflect.getMetadata(serviceMetaKey, target.prototype);
|
|
13
|
-
const instances = Reflect.getMetadata(instanceMetaKey, target.prototype);
|
|
14
|
-
exports.ServiceContainer.set(target.settings.action, dependencies);
|
|
15
|
-
exports.InstanceContainer.set(target.settings.action, instances);
|
|
16
|
-
}
|
|
17
|
-
exports.related = related;
|
|
18
|
-
function setMetaData({ item, itemName, metaKey, target, index }) {
|
|
19
|
-
let storage;
|
|
20
|
-
if (Reflect.hasMetadata(metaKey, target)) {
|
|
21
|
-
storage = Reflect.getMetadata(metaKey, target);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
storage = new Map();
|
|
25
|
-
Reflect.defineMetadata(metaKey, storage, target);
|
|
26
|
-
}
|
|
27
|
-
if (typeof index === 'number') {
|
|
28
|
-
let constructor;
|
|
29
|
-
if (storage.has(exports.ConstructorDependencyKey)) {
|
|
30
|
-
constructor = storage.get(exports.ConstructorDependencyKey);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
constructor = [];
|
|
34
|
-
storage.set(exports.ConstructorDependencyKey, constructor);
|
|
35
|
-
}
|
|
36
|
-
constructor[index] = item;
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
storage.set(itemName, item);
|
|
40
|
-
}
|
|
41
|
-
function service(dependence) {
|
|
42
|
-
return function (target, dependenceName) {
|
|
43
|
-
setMetaData({ item: dependence, itemName: dependenceName, metaKey: serviceMetaKey, target });
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
exports.service = service;
|
|
47
|
-
function instance(instance) {
|
|
48
|
-
return function (target, instanceName) {
|
|
49
|
-
setMetaData({ item: instance, itemName: instanceName, metaKey: instanceMetaKey, target });
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
exports.instance = instance;
|
|
53
|
-
function inject(key) {
|
|
54
|
-
return function (target, property, index) {
|
|
55
|
-
setMetaData({
|
|
56
|
-
item: key,
|
|
57
|
-
itemName: property,
|
|
58
|
-
metaKey: exports.dependencyStorageMetaKey,
|
|
59
|
-
target: typeof index === 'number' ? target : target.constructor,
|
|
60
|
-
index,
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
exports.inject = inject;
|
|
65
|
-
//# sourceMappingURL=injector.js.map
|