@lad-tech/nsc-toolkit 1.22.0 → 1.22.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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
- # [1.22.0](https://github.com/lad-tech/nsc-toolkit/compare/v1.21.0...v1.22.0) (2024-08-14)
1
+ ## [1.22.2](https://github.com/lad-tech/nsc-toolkit/compare/v1.22.1...v1.22.2) (2024-08-16)
2
2
 
3
3
 
4
- ### Features
4
+ ### Bug Fixes
5
5
 
6
- * Add support pull consumer ([#110](https://github.com/lad-tech/nsc-toolkit/issues/110)) ([ed77ad7](https://github.com/lad-tech/nsc-toolkit/commit/ed77ad7fa0542c0e8d0b56e71b430a14672bafae))
6
+ * Fix monolite mode ([#117](https://github.com/lad-tech/nsc-toolkit/issues/117)) ([202f34d](https://github.com/lad-tech/nsc-toolkit/commit/202f34d3fc2f836349546005388217b5da09d634))
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StreamManager = void 0;
4
4
  const nats_1 = require("nats");
5
5
  const Root_1 = require("./Root");
6
- const jsconsumeropts_1 = require("nats/lib/nats-base-client/jsconsumeropts");
7
6
  const StreamFetcher_1 = require("./StreamFetcher");
7
+ const types_1 = require("nats/lib/jetstream/types");
8
8
  class StreamManager extends Root_1.Root {
9
9
  constructor(param) {
10
10
  super(param.broker, param.outputFormatter);
@@ -104,7 +104,7 @@ class StreamManager extends Root_1.Root {
104
104
  if (!streamName) {
105
105
  throw new Error(`Error creating consumer ${consumerName}. Stream for subject ${subject} not found`);
106
106
  }
107
- if ((0, jsconsumeropts_1.isConsumerOptsBuilder)(options)) {
107
+ if ((0, types_1.isConsumerOptsBuilder)(options)) {
108
108
  await this.jsm.consumers.add(streamName, options.config);
109
109
  }
110
110
  return isPullConsumer
@@ -13,6 +13,18 @@ class UnionBroker {
13
13
  this.DEFAULT_TIMEOUT = 60000; // 1 Minut
14
14
  this.emitter = new node_stream_1.EventEmitter();
15
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
+ }
16
28
  closed() {
17
29
  return Promise.resolve();
18
30
  }
@@ -0,0 +1,28 @@
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
@@ -6,6 +6,12 @@ class JetStreamClientBlank {
6
6
  constructor(emitter) {
7
7
  this.emitter = emitter;
8
8
  }
9
+ jetstreamManager(checkAPI) {
10
+ throw new Error('Method not implemented.');
11
+ }
12
+ getOptions() {
13
+ throw new Error('Method not implemented.');
14
+ }
9
15
  publish(subj, data, options) {
10
16
  throw new Error('Method publish not implemented.');
11
17
  }
@@ -2,10 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.jetStreamManagerBlank = exports.JetStreamManagerBlank = void 0;
4
4
  const StreamApi_1 = require("./StreamApi");
5
+ const ConsumerApi_1 = require("./ConsumerApi");
5
6
  class JetStreamManagerBlank {
6
7
  constructor() {
8
+ this.consumers = new ConsumerApi_1.ConsumerApiBlank();
7
9
  this.streams = new StreamApi_1.StreamApiBlank();
8
10
  }
11
+ getOptions() {
12
+ throw new Error('Method not implemented.');
13
+ }
14
+ jetstream() {
15
+ throw new Error('Method not implemented.');
16
+ }
9
17
  getAccountInfo() {
10
18
  throw new Error('Method getAccountInfo not implemented.');
11
19
  }
@@ -2,6 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StreamApiBlank = void 0;
4
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
+ }
5
17
  info(stream, opts) {
6
18
  return Promise.resolve({});
7
19
  }
@@ -27,7 +39,7 @@ class StreamApiBlank {
27
39
  throw new Error('Method getMessage not implemented.');
28
40
  }
29
41
  find(subject) {
30
- throw new Error('Method find not implemented.');
42
+ return Promise.resolve('Ok');
31
43
  }
32
44
  }
33
45
  exports.StreamApiBlank = StreamApiBlank;
@@ -1,5 +1,4 @@
1
- import { JetStreamClient, JsMsg } from 'nats';
2
- import { QueuedIterator } from 'nats/lib/nats-base-client/queued_iterator';
1
+ import { JetStreamClient, JsMsg, QueuedIterator } from 'nats';
3
2
  interface BatcherOptions {
4
3
  batchSize?: number;
5
4
  batchTimeout?: number;
@@ -1,9 +1,14 @@
1
- import { JetStreamClient, JetStreamManager, JetStreamOptions, Msg, NatsConnection, PublishOptions, RequestOptions, ServerInfo, Stats, Status, Subscription, SubscriptionOptions } from 'nats';
1
+ import { JetStreamClient, JetStreamManager, JetStreamOptions, Msg, NatsConnection, Payload, PublishOptions, RequestManyOptions, RequestOptions, ServerInfo, ServicesAPI, Stats, Status, Subscription, SubscriptionOptions } from 'nats';
2
2
  interface Union {
3
3
  isUnion?: boolean;
4
4
  }
5
5
  export type Broker = NatsConnection & Union;
6
6
  export declare class UnionBroker implements Broker {
7
+ publishMessage(msg: Msg): void;
8
+ respondMessage(msg: Msg): boolean;
9
+ requestMany(subject: string, payload?: Payload | undefined, opts?: Partial<RequestManyOptions> | undefined): Promise<AsyncIterable<Msg>>;
10
+ services: ServicesAPI;
11
+ reconnect(): Promise<void>;
7
12
  info?: ServerInfo;
8
13
  isUnion: boolean;
9
14
  private DEFAULT_TIMEOUT;
@@ -0,0 +1,16 @@
1
+ import { ConsumerAPI, ConsumerConfig, ConsumerInfo, ConsumerUpdateConfig, Lister } from 'nats';
2
+ export declare class ConsumerApiBlank implements ConsumerAPI {
3
+ info(stream: string, consumer: string): Promise<ConsumerInfo>;
4
+ add(stream: string, cfg: Partial<ConsumerConfig>): Promise<ConsumerInfo>;
5
+ update(stream: string, durable: string, cfg: Partial<ConsumerUpdateConfig>): Promise<ConsumerInfo>;
6
+ delete(stream: string, consumer: string): Promise<boolean>;
7
+ list(stream: string): Lister<ConsumerInfo>;
8
+ pause(stream: string, name: string, until?: Date | undefined): Promise<{
9
+ paused: boolean;
10
+ pause_until?: string | undefined;
11
+ }>;
12
+ resume(stream: string, name: string): Promise<{
13
+ paused: boolean;
14
+ pause_until?: string | undefined;
15
+ }>;
16
+ }
@@ -1,12 +1,15 @@
1
1
  /// <reference types="node" />
2
- import { ConsumerOpts, ConsumerOptsBuilder, JetStreamClient, JetStreamPublishOptions, JetStreamPullSubscription, JetStreamSubscription, JsMsg, PubAck, PullOptions } from 'nats';
3
- import { QueuedIterator } from 'nats/lib/nats-base-client/queued_iterator';
4
- import { Views } from 'nats/lib/nats-base-client/types';
2
+ import { ConsumerOpts, ConsumerOptsBuilder, Consumers, JetStreamClient, JetStreamManager, JetStreamOptions, JetStreamPublishOptions, JetStreamPullSubscription, JetStreamSubscription, JsMsg, PubAck, PullOptions, QueuedIterator, Streams, Views } from 'nats';
5
3
  import { EventEmitter } from 'stream';
6
4
  export declare class JetStreamClientBlank implements JetStreamClient {
7
5
  private emitter;
8
6
  views: Views;
9
7
  constructor(emitter: EventEmitter);
8
+ apiPrefix: string;
9
+ consumers: Consumers;
10
+ streams: Streams;
11
+ jetstreamManager(checkAPI?: boolean | undefined): Promise<JetStreamManager>;
12
+ getOptions(): JetStreamOptions;
10
13
  publish(subj: string, data?: Uint8Array, options?: Partial<JetStreamPublishOptions>): Promise<PubAck>;
11
14
  pull(stream: string, durable: string, expires?: number): Promise<JsMsg>;
12
15
  fetch(stream: string, durable: string, opts?: Partial<PullOptions>): QueuedIterator<JsMsg>;
@@ -1,8 +1,10 @@
1
- import { JetStreamAccountStats, JetStreamManager } from 'nats';
2
- import { ConsumerAPI, Advisory } from 'nats/lib/nats-base-client/types';
1
+ import { Advisory, JetStreamAccountStats, JetStreamClient, JetStreamManager, JetStreamOptions } from 'nats';
3
2
  import { StreamApiBlank } from './StreamApi';
3
+ import { ConsumerApiBlank } from './ConsumerApi';
4
4
  export declare class JetStreamManagerBlank implements JetStreamManager {
5
- consumers: ConsumerAPI;
5
+ getOptions(): JetStreamOptions;
6
+ jetstream(): JetStreamClient;
7
+ consumers: ConsumerApiBlank;
6
8
  streams: StreamApiBlank;
7
9
  getAccountInfo(): Promise<JetStreamAccountStats>;
8
10
  advisories(): AsyncIterable<Advisory>;
@@ -1,5 +1,9 @@
1
- import { Lister, MsgRequest, PurgeOpts, PurgeResponse, StoredMsg, StreamAPI, StreamConfig, StreamInfo, StreamInfoRequestOptions, StreamUpdateConfig } from 'nats/lib/nats-base-client/types';
1
+ import { StreamAPI, StreamInfoRequestOptions, StreamInfo, StreamConfig, StreamUpdateConfig, PurgeOpts, PurgeResponse, Lister, MsgRequest, StoredMsg, KvStatus, ObjectStoreStatus, Stream } from 'nats';
2
2
  export declare class StreamApiBlank implements StreamAPI {
3
+ listKvs(): Lister<KvStatus>;
4
+ listObjectStores(): Lister<ObjectStoreStatus>;
5
+ names(subject?: string | undefined): Lister<string>;
6
+ get(name: string): Promise<Stream>;
3
7
  info(stream: string, opts?: Partial<StreamInfoRequestOptions>): Promise<StreamInfo>;
4
8
  add(cfg: Partial<StreamConfig>): Promise<StreamInfo>;
5
9
  update(name: string, cfg: Partial<StreamUpdateConfig>): Promise<StreamInfo>;
@@ -1,6 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Msg, NatsError, Subscription } from 'nats';
3
- import { Closed, ConsumerInfoable, Destroyable } from 'nats/lib/nats-base-client/types';
2
+ import { Closed, ConsumerInfoable, Destroyable, Msg, NatsError, Subscription } from 'nats';
4
3
  import { PassThrough } from 'node:stream';
5
4
  export declare class UnionSubscription extends PassThrough implements Subscription, Destroyable, Closed, ConsumerInfoable {
6
5
  closed: Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lad-tech/nsc-toolkit",
3
- "version": "1.22.0",
3
+ "version": "1.22.2",
4
4
  "description": "Toolkit for create microservices around NATS",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -41,9 +41,12 @@
41
41
  "@opentelemetry/sdk-trace-base": "^1.3.1",
42
42
  "@opentelemetry/semantic-conventions": "^1.3.1",
43
43
  "ajv": "^8.11.0",
44
- "nats": "^2.6.1",
44
+ "nats": "^2.28.2",
45
45
  "reflect-metadata": "^0.1.13"
46
46
  },
47
+ "peerDependencies": {
48
+ "nats": "^2.15.0"
49
+ },
47
50
  "jest": {
48
51
  "preset": "ts-jest",
49
52
  "testEnvironment": "node",