@lad-tech/nsc-toolkit 1.26.2 → 1.27.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 CHANGED
@@ -1,6 +1,6 @@
1
- ## [1.26.2](https://github.com/lad-tech/nsc-toolkit/compare/v1.26.1...v1.26.2) (2025-01-22)
1
+ # [1.27.0](https://github.com/lad-tech/nsc-toolkit/compare/v1.26.2...v1.27.0) (2025-02-06)
2
2
 
3
3
 
4
- ### Bug Fixes
4
+ ### Features
5
5
 
6
- * rollup pull consumer ([#142](https://github.com/lad-tech/nsc-toolkit/issues/142)) ([974dcb8](https://github.com/lad-tech/nsc-toolkit/commit/974dcb8a2fd748b3a835c6b3fb67ffb32490b963))
6
+ * New option for consumer ackPolicy ([#144](https://github.com/lad-tech/nsc-toolkit/issues/144)) ([0426f4e](https://github.com/lad-tech/nsc-toolkit/commit/0426f4e1da4ff092354f0e175d9ad9a295dfb074))
@@ -73,11 +73,20 @@ class StreamManager extends Root_1.Root {
73
73
  const isPullConsumer = StreamManager.isPullConsumerOptions(setting);
74
74
  options
75
75
  .durable(consumerName)
76
- .manualAck()
77
- .ackExplicit()
78
76
  .filterSubject(subject)
79
77
  .maxAckPending((setting === null || setting === void 0 ? void 0 : setting.maxPending) || 10);
80
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
+ }
81
90
  if (setting.maxPullRequestExpires) {
82
91
  options.maxPullRequestExpires(setting.maxPullRequestExpires);
83
92
  }
@@ -85,6 +94,10 @@ class StreamManager extends Root_1.Root {
85
94
  options.maxPullBatch(setting.maxPullRequestBatch);
86
95
  }
87
96
  }
97
+ else {
98
+ options.manualAck();
99
+ options.ackExplicit();
100
+ }
88
101
  if (setting === null || setting === void 0 ? void 0 : setting.maxAckWaiting) {
89
102
  options.ackWait(setting.maxAckWaiting);
90
103
  }
@@ -114,7 +127,11 @@ class StreamManager extends Root_1.Root {
114
127
  await this.jsm.consumers.add(streamName, { ...options.config, filter_subject: subject });
115
128
  }
116
129
  else {
117
- await this.jsm.consumers.update(streamName, consumerName, { ...options.config, filter_subject: subject, deliver_subject: undefined });
130
+ await this.jsm.consumers.update(streamName, consumerName, {
131
+ ...options.config,
132
+ filter_subject: subject,
133
+ deliver_subject: undefined,
134
+ });
118
135
  }
119
136
  }
120
137
  const consumer = await this.broker.jetstream().consumers.get(streamName, consumerName);
@@ -75,6 +75,7 @@ export interface GetBatchListenerOptions extends GetListenerOptions {
75
75
  batch: true;
76
76
  maxPullRequestBatch?: number;
77
77
  maxPullRequestExpires?: number;
78
+ ackPolicy?: 'all' | 'none';
78
79
  }
79
80
  export interface StreamManagerParam {
80
81
  serviceName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lad-tech/nsc-toolkit",
3
- "version": "1.26.2",
3
+ "version": "1.27.0",
4
4
  "description": "Toolkit for create microservices around NATS",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/types/index.d.ts",