@nitra/nats 4.3.0 → 4.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitra/nats",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
4
4
  "description": "nats helper",
5
5
  "keywords": [
6
6
  "nats",
package/src/index.js CHANGED
@@ -2,3 +2,4 @@ export { publish } from './publish.js'
2
2
  export { read, finish } from './read.js'
3
3
  export { readM, finishM, nakM } from './read-m.js'
4
4
  export { getPendingCount } from './pending-count.js'
5
+ export { closeNats } from './nats.js'
@@ -17,7 +17,11 @@ export async function getPendingCount(consumer) {
17
17
 
18
18
  try {
19
19
  const info = await jsm.consumers.info(stream, consumer)
20
- return info.num_pending + info.num_ack_pending
20
+
21
+ // return info.num_pending + info.num_ack_pending
22
+
23
+ // Тільки не взяті ніким повідомлення
24
+ return info.num_pending
21
25
  } catch (error) {
22
26
  // Перевірити що це ClosedConnectionError
23
27
  if (error instanceof ClosedConnectionError) {
package/src/publish.js CHANGED
@@ -1,10 +1,9 @@
1
- import { log } from '@nitra/pino'
2
- import { env } from 'node:process'
3
- import { js } from './nats.js'
4
- import { checkSubjectFormat } from './utils.js'
5
1
  import { headers } from '@nats-io/nats-core'
6
2
  import { createHash } from 'node:crypto'
3
+ import { env } from 'node:process'
4
+ import { js } from './nats.js'
7
5
  import { stream } from './stream.js'
6
+ import { checkSubjectFormat } from './utils.js'
8
7
 
9
8
  /**
10
9
  * Публікує повідомлення у JetStream для вказаного subject.
@@ -23,7 +22,7 @@ export async function publish(subject, data, options = {}) {
23
22
  // перевіряємо чи subject відповідає формату stream.project:subject
24
23
  checkSubjectFormat(stream, `${stream}.${subject}`)
25
24
 
26
- log.debug('publish:', data)
25
+ // log.debug('publish:', data)
27
26
  const payload = JSON.stringify(data)
28
27
  let suffix = ''
29
28
 
package/src/read-m.js CHANGED
@@ -59,7 +59,7 @@ export async function readM(consumer, count = 1) {
59
59
  throw new Error(`Invalid JSON in message: ${error.message}`)
60
60
  }
61
61
 
62
- decodedMessages.push(decoded)
62
+ decodedMessages.push({ msg, data: decoded })
63
63
  }
64
64
 
65
65
  if (!decodedMessages.length) {