@prosody-events/prosody 0.5.1 → 0.6.1

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/bindings.d.ts CHANGED
@@ -1,5 +1,14 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+
4
+ /**
5
+ * Which binding artifact the generated loader actually loaded: `'native'` for
6
+ * a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
7
+ * flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
8
+ * can point the loader at a WASI artifact this package does not build itself.
9
+ */
10
+ export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1'
11
+
3
12
  /**
4
13
  * Represents a client for performing administrative operations on a Prosody
5
14
  * cluster.
@@ -19,9 +28,11 @@ export declare class AdminClient {
19
28
  * @param name - The name of the topic to create.
20
29
  * @param partitionCount - The number of partitions for the topic.
21
30
  * @param replicationFactor - The replication factor for the topic.
22
- * @throws Error if the topic creation fails.
31
+ * @param options - The cleanup policy and retention. The cluster default
32
+ * applies to each setting you omit.
33
+ * @throws Error if a number cannot convert or the topic creation fails.
23
34
  */
24
- createTopic(name: string, partitionCount: number, replicationFactor: number): Promise<void>
35
+ createTopic(name: string, partitionCount: number, replicationFactor: number, options?: TopicOptions | undefined | null): Promise<void>
25
36
  /**
26
37
  * Deletes a topic from the Prosody cluster.
27
38
  *
@@ -43,6 +54,16 @@ export declare class ExciseMessage {
43
54
  get timestamp(): Date
44
55
  /** The key that this record excises. */
45
56
  get key(): string
57
+ /**
58
+ * The source system of the producer, or `null` when the record has no
59
+ * source system header.
60
+ */
61
+ get sourceSystem(): string | null
62
+ /**
63
+ * Whether the sender waits for a response from this consumer. The
64
+ * handler result becomes the response only when this is `true`.
65
+ */
66
+ get responseRequested(): boolean
46
67
  }
47
68
 
48
69
  /** A Kafka message received from a consumer. */
@@ -57,6 +78,16 @@ export declare class Message {
57
78
  get timestamp(): Date
58
79
  /** The message key used for partitioning. */
59
80
  get key(): string
81
+ /**
82
+ * The source system of the producer, or `null` when the message has no
83
+ * source system header.
84
+ */
85
+ get sourceSystem(): string | null
86
+ /**
87
+ * Whether the sender waits for a response from this consumer. The
88
+ * handler result becomes the response only when this is `true`.
89
+ */
90
+ get responseRequested(): boolean
60
91
  /**
61
92
  * The payload as the raw JSON text read from the wire.
62
93
  *
@@ -91,11 +122,13 @@ export declare class NativeClient {
91
122
  */
92
123
  consumerState(): Promise<ConsumerState>
93
124
  /** Builds a read-only view of a published value collection. */
94
- publishedValue(subsystem: string, name: string, cacheMs?: number | undefined | null, cacheDisabled?: boolean | undefined | null): Promise<NativePublishedValue>
125
+ publishedValue(subsystem: string, name: string, readCache?: ReadCacheOption | undefined | null): Promise<NativePublishedValue>
95
126
  /** Builds a read-only view of a published map collection. */
96
- publishedMap(subsystem: string, name: string, cacheMs?: number | undefined | null, cacheDisabled?: boolean | undefined | null): Promise<NativePublishedMap>
127
+ publishedMap(subsystem: string, name: string, readCache?: ReadCacheOption | undefined | null): Promise<NativePublishedMap>
128
+ /** Builds a read-only view of a published set collection. */
129
+ publishedSet(subsystem: string, name: string, readCache?: ReadCacheOption | undefined | null): Promise<NativePublishedSet>
97
130
  /** Builds a read-only view of a published deque collection. */
98
- publishedDeque(subsystem: string, name: string, cacheMs?: number | undefined | null, cacheDisabled?: boolean | undefined | null): Promise<NativePublishedDeque>
131
+ publishedDeque(subsystem: string, name: string, readCache?: ReadCacheOption | undefined | null): Promise<NativePublishedDeque>
99
132
  /**
100
133
  * Sends a message to a specified topic.
101
134
  *
@@ -110,9 +143,9 @@ export declare class NativeClient {
110
143
  * @param metadata - The event metadata read off the payload object
111
144
  * @param otelContext - The OpenTelemetry context for tracing
112
145
  * @param maybeAbort - Optional promise that resolves when the operation
113
- * should be aborted @returns A promise that resolves when the message
114
- * has been sent @throws Error if the send operation fails or is
115
- * aborted
146
+ * should be aborted
147
+ * @returns A promise that resolves when the message has been sent
148
+ * @throws Error if the send operation fails or is aborted
116
149
  */
117
150
  send(topic: string, key: string, payload: string, metadata: EventMetadata, otelContext: Record<string, string>, maybeAbort?: Promise<undefined> | undefined | null): Promise<void>
118
151
  /** Sends an excise record to a specified topic. */
@@ -167,6 +200,12 @@ export declare class NativeClient {
167
200
 
168
201
  /** Wrapper around `MessageContext` for use in Node.js bindings. */
169
202
  export declare class NativeContext {
203
+ /**
204
+ * The demand that started this handler invocation.
205
+ *
206
+ * @returns The demand kind and its retry count.
207
+ */
208
+ get demand(): NativeDemand
170
209
  /**
171
210
  * Checks whether cancellation has been signaled.
172
211
  *
@@ -223,80 +262,19 @@ export declare class NativeContext {
223
262
  * @throws Error if retrieval fails.
224
263
  */
225
264
  scheduled(otelContext: Record<string, string>): Promise<Array<Date>>
226
- /**
227
- * Vends the state handle for the named JSON value collection.
228
- *
229
- * Vending verifies the collection's registration (core-side); no span is
230
- * opened here — vended handles outlive the call, and every operation opens
231
- * its own span.
232
- *
233
- * @param name The registered collection name.
234
- * @returns The value-state handle for this event's transaction.
235
- * @throws Error (permanent) if the name is unregistered or its registered
236
- * identity mismatches.
237
- */
265
+ /** Vends the state handle for the named JSON value collection. */
238
266
  valueState(name: string): NativeJsonValueState
239
- /**
240
- * Vends the state handle for the named JSON map collection.
241
- *
242
- * Vending verifies the collection's registration (core-side); no span is
243
- * opened here — vended handles outlive the call, and every operation opens
244
- * its own span.
245
- *
246
- * @param name The registered collection name.
247
- * @returns The map-state handle for this event's transaction.
248
- * @throws Error (permanent) if the name is unregistered or its registered
249
- * identity mismatches.
250
- */
267
+ /** Vends the state handle for the named JSON map collection. */
251
268
  mapState(name: string): NativeJsonMapState
252
- /**
253
- * Vends the state handle for the named JSON deque collection.
254
- *
255
- * Vending verifies the collection's registration (core-side); no span is
256
- * opened here — vended handles outlive the call, and every operation opens
257
- * its own span.
258
- *
259
- * @param name The registered collection name.
260
- * @returns The deque-state handle for this event's transaction.
261
- * @throws Error (permanent) if the name is unregistered or its registered
262
- * identity mismatches.
263
- */
269
+ /** Vends the state handle for the named set collection. */
270
+ setState(name: string): NativeSetState
271
+ /** Vends the state handle for the named JSON deque collection. */
264
272
  dequeState(name: string): NativeJsonDequeState
265
- /**
266
- * Vends the state handle for the named Kafka-message value collection.
267
- *
268
- * Items are the full `Message` the handler received, loader-resolved on
269
- * read. Vending verifies registration (core-side); no span is opened here.
270
- *
271
- * @param name The registered collection name.
272
- * @returns The message value-state handle for this event's transaction.
273
- * @throws Error (permanent) if the name is unregistered or its registered
274
- * identity mismatches.
275
- */
273
+ /** Vends the state handle for the named Kafka-message value collection. */
276
274
  messageValueState(name: string): NativeMessageValueState
277
- /**
278
- * Vends the state handle for the named Kafka-message map collection.
279
- *
280
- * Items are the full `Message` the handler received, loader-resolved on
281
- * read. Vending verifies registration (core-side); no span is opened here.
282
- *
283
- * @param name The registered collection name.
284
- * @returns The message map-state handle for this event's transaction.
285
- * @throws Error (permanent) if the name is unregistered or its registered
286
- * identity mismatches.
287
- */
275
+ /** Vends the state handle for the named Kafka-message map collection. */
288
276
  messageMapState(name: string): NativeMessageMapState
289
- /**
290
- * Vends the state handle for the named Kafka-message deque collection.
291
- *
292
- * Items are the full `Message` the handler received, loader-resolved on
293
- * read. Vending verifies registration (core-side); no span is opened here.
294
- *
295
- * @param name The registered collection name.
296
- * @returns The message deque-state handle for this event's transaction.
297
- * @throws Error (permanent) if the name is unregistered or its registered
298
- * identity mismatches.
299
- */
277
+ /** Vends the state handle for the named Kafka-message deque collection. */
300
278
  messageDequeState(name: string): NativeMessageDequeState
301
279
  }
302
280
 
@@ -310,120 +288,32 @@ export declare class NativeJsonDequeCursor {
310
288
 
311
289
  /** JSON deque state handle for one event. */
312
290
  export declare class NativeJsonDequeState {
313
- /**
314
- * The number of live elements.
315
- *
316
- * @param otelContext The OpenTelemetry context for tracing.
317
- * @returns The element count.
318
- * @throws Error carrying the category on `cause` if the read fails, or if
319
- * the count exceeds the `u32` range.
320
- */
291
+ /** Returns the number of live elements. */
321
292
  len(otelContext: Record<string, string>): Promise<number>
322
- /**
323
- * Whether the deque holds no live elements.
324
- *
325
- * @param otelContext The OpenTelemetry context for tracing.
326
- * @returns True when the deque is empty.
327
- * @throws Error carrying the category on `cause` if the read fails.
328
- */
293
+ /** Reports whether the deque has no live elements. */
329
294
  isEmpty(otelContext: Record<string, string>): Promise<boolean>
330
- /**
331
- * Reads the element at front-relative position `index`.
332
- *
333
- * @param index The zero-based position from the front.
334
- * @param otelContext The OpenTelemetry context for tracing.
335
- * @returns The element, or null past the end.
336
- * @throws Error carrying the category on `cause` if the read fails.
337
- */
295
+ /** Reads one element by its position from the front. */
338
296
  get(index: number, otelContext: Record<string, string>): Promise<string | null>
339
- /**
340
- * Reads the front endpoint SLOT without a length round trip — exactly
341
- * `get(0)`.
342
- *
343
- * Decodes and resolves the returned element (unlike eviction). An empty
344
- * deque, or a front endpoint slot expired under a TTL, yields null even
345
- * when live interior elements exist — a peek never searches inward.
346
- *
347
- * @param otelContext The OpenTelemetry context for tracing.
348
- * @returns The front element, or null when the endpoint slot is empty.
349
- * @throws Error carrying the category on `cause` if the read fails.
350
- */
297
+ /** Reads the front endpoint. */
351
298
  peekFront(otelContext: Record<string, string>): Promise<string | null>
352
- /**
353
- * Reads the back endpoint SLOT without a length round trip — exactly
354
- * `get(len − 1)`.
355
- *
356
- * Decodes and resolves the returned element (unlike eviction). An empty
357
- * deque, or a back endpoint slot expired under a TTL, yields null even
358
- * when live interior elements exist — a peek never searches inward.
359
- *
360
- * @param otelContext The OpenTelemetry context for tracing.
361
- * @returns The back element, or null when the endpoint slot is empty.
362
- * @throws Error carrying the category on `cause` if the read fails.
363
- */
299
+ /** Reads the back endpoint. */
364
300
  peekBack(otelContext: Record<string, string>): Promise<string | null>
365
- /**
366
- * Appends a JSON document at the back.
367
- *
368
- * JSON null is not a storable element and is rejected with a transient
369
- * error.
370
- *
371
- * @param json The document's JSON text.
372
- * @param otelContext The OpenTelemetry context for tracing.
373
- * @throws Error carrying the category on `cause` if the write fails.
374
- */
301
+ /** Appends a JSON document. */
375
302
  pushBack(json: string, otelContext: Record<string, string>): Promise<void>
376
- /**
377
- * Prepends a JSON document at the front.
378
- *
379
- * JSON null is not a storable element and is rejected with a transient
380
- * error.
381
- *
382
- * @param json The document's JSON text.
383
- * @param otelContext The OpenTelemetry context for tracing.
384
- * @throws Error carrying the category on `cause` if the write fails.
385
- */
303
+ /** Prepends a JSON document. */
386
304
  pushFront(json: string, otelContext: Record<string, string>): Promise<void>
387
- /**
388
- * Removes and returns the front element.
389
- *
390
- * @param otelContext The OpenTelemetry context for tracing.
391
- * @returns The removed front element, or null when empty.
392
- * @throws Error carrying the category on `cause` if the operation fails.
393
- */
305
+ /** Removes and returns the front element. */
394
306
  popFront(otelContext: Record<string, string>): Promise<string | null>
395
- /**
396
- * Removes and returns the back element.
397
- *
398
- * @param otelContext The OpenTelemetry context for tracing.
399
- * @returns The removed back element, or null when empty.
400
- * @throws Error carrying the category on `cause` if the operation fails.
401
- */
307
+ /** Removes and returns the back element. */
402
308
  popBack(otelContext: Record<string, string>): Promise<string | null>
403
- /**
404
- * Removes every element.
405
- *
406
- * @param otelContext The OpenTelemetry context for tracing.
407
- * @throws Error carrying the category on `cause` if the clear fails.
408
- */
309
+ /** Removes every element. */
409
310
  clear(otelContext: Record<string, string>): Promise<void>
410
- /**
411
- * Opens a demand-driven cursor over the live elements in index order.
412
- *
413
- * Synchronous — it performs no I/O. The extracted JavaScript context is
414
- * active while core constructs its semantic stream span; chunk pulls do
415
- * not create binding spans.
416
- *
417
- * @param direction The scan direction (`"forward"` or `"backward"`).
418
- * @param otelContext The OpenTelemetry context for tracing.
419
- * @returns A cursor over the deque elements.
420
- * @throws Error if the direction token is invalid.
421
- */
422
- scan(direction: string, otelContext: Record<string, string>): NativeJsonDequeCursor
311
+ /** Opens a cursor over the selected elements. */
312
+ values(query: NativePositionQuery): NativeJsonDequeCursor
423
313
  /** Durably commits the buffered operations. */
424
- commit(otelContext: Record<string, string>): Promise<void>
314
+ commit(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
425
315
  /** Discards the buffered operations. */
426
- rollback(otelContext: Record<string, string>): Promise<void>
316
+ rollback(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
427
317
  }
428
318
 
429
319
  /** Demand-driven cursor with one element type. */
@@ -436,143 +326,48 @@ export declare class NativeJsonMapCursor {
436
326
 
437
327
  /** JSON ordered-map state handle for one event. */
438
328
  export declare class NativeJsonMapState {
439
- /**
440
- * Reads the value for `key`.
441
- *
442
- * @param key The map key.
443
- * @param otelContext The OpenTelemetry context for tracing.
444
- * @returns The value, or null when the key is absent.
445
- * @throws Error carrying the category on `cause` if the read fails.
446
- */
329
+ /** Reads the value for `key`. */
447
330
  get(key: string, otelContext: Record<string, string>): Promise<string | null>
448
- /**
449
- * Reads several keys in a single call.
450
- *
451
- * Returns one entry per key, in the same order requested: the entry at
452
- * index `i` is the value for `keys[i]`. A key that isn't there reads as
453
- * null, and a key listed more than once is answered at each of its spots.
454
- * The whole read happens as one step, so no other change to this event's
455
- * state can slip in partway through.
456
- *
457
- * @param keys The keys to read, in order.
458
- * @param otelContext The OpenTelemetry context for tracing.
459
- * @returns One result per input key; null for a key that is absent.
460
- * @throws Error carrying the category on `cause` if the read fails.
461
- */
331
+ /** Reads several keys in one operation. */
462
332
  getMany(keys: Array<string>, otelContext: Record<string, string>): Promise<Array<string | undefined | null>>
463
- /**
464
- * Reports whether a stored cell exists for `key`.
465
- *
466
- * Reads the event's dirty overlay (read-your-writes) and answers presence
467
- * WITHOUT decoding the value or running the resolver — a message-backed
468
- * map answers with zero Kafka fetches and can report `true` for a
469
- * message that can no longer be fetched. This is NOT "no I/O": a cache
470
- * miss can still reach Cassandra, so it is async and fallible exactly
471
- * like `get`.
472
- *
473
- * @param key The map key.
474
- * @param otelContext The OpenTelemetry context for tracing.
475
- * @returns True when a stored cell exists for `key`.
476
- * @throws Error carrying the category on `cause` if the read fails.
477
- */
333
+ /** Reports whether the map holds an entry for `key`. */
478
334
  contains(key: string, otelContext: Record<string, string>): Promise<boolean>
479
- /**
480
- * Inserts or overwrites `key` with a JSON document.
481
- *
482
- * JSON null is rejected with a transient error naming `delete` as the way
483
- * to remove an entry.
484
- *
485
- * @param key The map key.
486
- * @param json The document's JSON text.
487
- * @param otelContext The OpenTelemetry context for tracing.
488
- * @throws Error carrying the category on `cause` if the write fails.
489
- */
335
+ /** Tests several keys for presence in one read. */
336
+ containsMany(keys: Array<string>, otelContext: Record<string, string>): Promise<Array<boolean>>
337
+ /** Reports whether the map has no live entries. */
338
+ isEmpty(otelContext: Record<string, string>): Promise<boolean>
339
+ /** Inserts or overwrites `key` with a JSON document. */
490
340
  set(key: string, json: string, otelContext: Record<string, string>): Promise<void>
491
- /**
492
- * Removes `key`.
493
- *
494
- * @param key The map key.
495
- * @param otelContext The OpenTelemetry context for tracing.
496
- * @throws Error carrying the category on `cause` if the removal fails.
497
- */
341
+ /** Removes `key`. */
498
342
  remove(key: string, otelContext: Record<string, string>): Promise<void>
499
- /**
500
- * Removes every entry.
501
- *
502
- * @param otelContext The OpenTelemetry context for tracing.
503
- * @throws Error carrying the category on `cause` if the clear fails.
504
- */
343
+ /** Removes every entry. */
505
344
  clear(otelContext: Record<string, string>): Promise<void>
506
- /**
507
- * Opens a demand-driven cursor over the live entries in key order.
508
- *
509
- * Synchronous — it performs no I/O. The extracted JavaScript context is
510
- * active while core constructs its semantic stream span; chunk pulls do
511
- * not create binding spans. Entries are yielded as `(key, value)` pairs.
512
- *
513
- * @param direction The scan direction (`"forward"` or `"backward"`).
514
- * @param otelContext The OpenTelemetry context for tracing.
515
- * @returns A cursor over the map entries.
516
- * @throws Error if the direction token is invalid.
517
- */
518
- scan(direction: string, otelContext: Record<string, string>): NativeJsonMapCursor
519
- /**
520
- * Opens a demand-driven cursor over the live KEYS in key order.
521
- *
522
- * Skips the value codec and the resolver (no value decode, no Kafka
523
- * fetch), so a message-backed map enumerates keys with zero Kafka
524
- * fetches — but it still reads presence, so it is not zero-I/O.
525
- * Synchronous like `scan`: the extracted JavaScript context is active
526
- * while core constructs its semantic stream span. Yields bare keys.
527
- *
528
- * @param direction The scan direction (`"forward"` or `"backward"`).
529
- * @param otelContext The OpenTelemetry context for tracing.
530
- * @returns A cursor over the map keys.
531
- * @throws Error if the direction token is invalid.
532
- */
533
- keys(direction: string, otelContext: Record<string, string>): NativeMapKeyCursor
345
+ /** Opens a cursor over the selected entries. */
346
+ entries(query: NativeKeyQuery): NativeJsonMapCursor
347
+ /** Opens a cursor over the selected keys. */
348
+ keys(query: NativeKeyQuery): NativeKeyCursor
534
349
  /** Durably commits the buffered operations. */
535
- commit(otelContext: Record<string, string>): Promise<void>
350
+ commit(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
536
351
  /** Discards the buffered operations. */
537
- rollback(otelContext: Record<string, string>): Promise<void>
352
+ rollback(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
538
353
  }
539
354
 
540
355
  /** JSON single-value state handle for one event. */
541
356
  export declare class NativeJsonValueState {
542
- /**
543
- * Reads the current value.
544
- *
545
- * @param otelContext The OpenTelemetry context for tracing.
546
- * @returns The current value, or null when absent/cleared.
547
- * @throws Error carrying the category on `cause` if the read fails.
548
- */
357
+ /** Reads the current value. */
549
358
  get(otelContext: Record<string, string>): Promise<string | null>
550
- /**
551
- * Buffers a write of a JSON document.
552
- *
553
- * JSON null is rejected with a transient error naming `clear` as the way
554
- * to delete.
555
- *
556
- * @param json The document's JSON text.
557
- * @param otelContext The OpenTelemetry context for tracing.
558
- * @throws Error carrying the category on `cause` if the write fails.
559
- */
359
+ /** Buffers a write of a JSON document. */
560
360
  set(json: string, otelContext: Record<string, string>): Promise<void>
561
- /**
562
- * Buffers a clear of the value.
563
- *
564
- * @param otelContext The OpenTelemetry context for tracing.
565
- * @throws Error carrying the category on `cause` if the clear fails.
566
- */
361
+ /** Buffers a clear of the value. */
567
362
  clear(otelContext: Record<string, string>): Promise<void>
568
363
  /** Durably commits the buffered operations. */
569
- commit(otelContext: Record<string, string>): Promise<void>
364
+ commit(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
570
365
  /** Discards the buffered operations. */
571
- rollback(otelContext: Record<string, string>): Promise<void>
366
+ rollback(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
572
367
  }
573
368
 
574
369
  /** Demand-driven cursor with one element type. */
575
- export declare class NativeMapKeyCursor {
370
+ export declare class NativeKeyCursor {
576
371
  /** Pulls the next ready chunk. */
577
372
  nextChunk(otelContext: Record<string, string>): Promise<Array<string> | null>
578
373
  /** Closes the cursor. */
@@ -609,12 +404,12 @@ export declare class NativeMessageDequeState {
609
404
  popBack(otelContext: Record<string, string>): Promise<Message | null>
610
405
  /** Removes every element. */
611
406
  clear(otelContext: Record<string, string>): Promise<void>
612
- /** Opens a cursor over the live elements. */
613
- scan(direction: string, otelContext: Record<string, string>): NativeMessageDequeCursor
407
+ /** Opens a cursor over the selected elements. */
408
+ values(query: NativePositionQuery): NativeMessageDequeCursor
614
409
  /** Durably commits the buffered operations. */
615
- commit(otelContext: Record<string, string>): Promise<void>
410
+ commit(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
616
411
  /** Discards the buffered operations. */
617
- rollback(otelContext: Record<string, string>): Promise<void>
412
+ rollback(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
618
413
  }
619
414
 
620
415
  /** Demand-driven cursor with one element type. */
@@ -631,22 +426,26 @@ export declare class NativeMessageMapState {
631
426
  get(key: string, otelContext: Record<string, string>): Promise<Message | null>
632
427
  /** Reads several keys in one operation. */
633
428
  getMany(keys: Array<string>, otelContext: Record<string, string>): Promise<Array<Message | undefined | null>>
634
- /** Reports whether `key` has a stored cell. */
429
+ /** Reports whether the map holds an entry for `key`. */
635
430
  contains(key: string, otelContext: Record<string, string>): Promise<boolean>
431
+ /** Tests several keys for presence in one read. */
432
+ containsMany(keys: Array<string>, otelContext: Record<string, string>): Promise<Array<boolean>>
433
+ /** Reports whether the map has no live entries. */
434
+ isEmpty(otelContext: Record<string, string>): Promise<boolean>
636
435
  /** Inserts or overwrites `key` with a Kafka message. */
637
436
  set(key: string, message: Message, otelContext: Record<string, string>): Promise<void>
638
437
  /** Removes `key`. */
639
438
  remove(key: string, otelContext: Record<string, string>): Promise<void>
640
439
  /** Removes every entry. */
641
440
  clear(otelContext: Record<string, string>): Promise<void>
642
- /** Opens a cursor over entries in key order. */
643
- scan(direction: string, otelContext: Record<string, string>): NativeMessageMapCursor
644
- /** Opens a cursor over keys in key order. */
645
- keys(direction: string, otelContext: Record<string, string>): NativeMapKeyCursor
441
+ /** Opens a cursor over the selected entries. */
442
+ entries(query: NativeKeyQuery): NativeMessageMapCursor
443
+ /** Opens a cursor over the selected keys. */
444
+ keys(query: NativeKeyQuery): NativeKeyCursor
646
445
  /** Durably commits the buffered operations. */
647
- commit(otelContext: Record<string, string>): Promise<void>
446
+ commit(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
648
447
  /** Discards the buffered operations. */
649
- rollback(otelContext: Record<string, string>): Promise<void>
448
+ rollback(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
650
449
  }
651
450
 
652
451
  /** Kafka-message single-value state handle for one event. */
@@ -658,9 +457,9 @@ export declare class NativeMessageValueState {
658
457
  /** Buffers a clear of the value. */
659
458
  clear(otelContext: Record<string, string>): Promise<void>
660
459
  /** Durably commits the buffered operations. */
661
- commit(otelContext: Record<string, string>): Promise<void>
460
+ commit(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
662
461
  /** Discards the buffered operations. */
663
- rollback(otelContext: Record<string, string>): Promise<void>
462
+ rollback(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
664
463
  }
665
464
 
666
465
  /** A read-only published deque collection. */
@@ -668,15 +467,15 @@ export declare class NativePublishedDeque {
668
467
  /** Reads one front-relative element. */
669
468
  get(key: string, index: number, otelContext: Record<string, string>): Promise<string | null>
670
469
  /** Returns the committed deque length. */
671
- length(key: string, otelContext: Record<string, string>): Promise<number>
470
+ len(key: string, otelContext: Record<string, string>): Promise<number>
672
471
  /** Reports whether the committed deque is empty. */
673
472
  isEmpty(key: string, otelContext: Record<string, string>): Promise<boolean>
674
473
  /** Reads the committed front element. */
675
474
  peekFront(key: string, otelContext: Record<string, string>): Promise<string | null>
676
475
  /** Reads the committed back element. */
677
476
  peekBack(key: string, otelContext: Record<string, string>): Promise<string | null>
678
- /** Opens an ordered element cursor. */
679
- scan(key: string, direction: string, otelContext: Record<string, string>): Promise<NativeJsonDequeCursor>
477
+ /** Opens a cursor over the selected elements. */
478
+ values(key: string, query: NativePositionQuery): NativeJsonDequeCursor
680
479
  }
681
480
 
682
481
  /** A read-only published map collection. */
@@ -687,10 +486,26 @@ export declare class NativePublishedMap {
687
486
  getMany(key: string, mapKeys: Array<string>, otelContext: Record<string, string>): Promise<Array<string | undefined | null>>
688
487
  /** Reports whether a committed map entry exists. */
689
488
  contains(key: string, mapKey: string, otelContext: Record<string, string>): Promise<boolean>
690
- /** Opens an ordered entry cursor. */
691
- scan(key: string, direction: string, otelContext: Record<string, string>): Promise<NativeJsonMapCursor>
692
- /** Opens an ordered key cursor. */
693
- keys(key: string, direction: string, otelContext: Record<string, string>): Promise<NativeMapKeyCursor>
489
+ /** Tests committed presence aligned with the supplied map keys. */
490
+ containsMany(key: string, mapKeys: Array<string>, otelContext: Record<string, string>): Promise<Array<boolean>>
491
+ /** Reports whether the committed map is empty. */
492
+ isEmpty(key: string, otelContext: Record<string, string>): Promise<boolean>
493
+ /** Opens a cursor over the selected entries. */
494
+ entries(key: string, query: NativeKeyQuery): NativeJsonMapCursor
495
+ /** Opens a cursor over the selected keys. */
496
+ keys(key: string, query: NativeKeyQuery): NativeKeyCursor
497
+ }
498
+
499
+ /** A read-only published set collection. */
500
+ export declare class NativePublishedSet {
501
+ /** Reports whether the committed set contains a member. */
502
+ contains(key: string, member: string, otelContext: Record<string, string>): Promise<boolean>
503
+ /** Tests committed membership aligned with the supplied members. */
504
+ containsMany(key: string, members: Array<string>, otelContext: Record<string, string>): Promise<Array<boolean>>
505
+ /** Reports whether the committed set has no members. */
506
+ isEmpty(key: string, otelContext: Record<string, string>): Promise<boolean>
507
+ /** Opens a cursor over the selected members. */
508
+ keys(key: string, query: NativeKeyQuery): NativeKeyCursor
694
509
  }
695
510
 
696
511
  /** A read-only published value collection. */
@@ -699,6 +514,34 @@ export declare class NativePublishedValue {
699
514
  get(key: string, otelContext: Record<string, string>): Promise<string | null>
700
515
  }
701
516
 
517
+ /** Presence-only ordered set of string members for one event. */
518
+ export declare class NativeSetState {
519
+ /** Reports whether `member` belongs to the set. */
520
+ contains(member: string, otelContext: Record<string, string>): Promise<boolean>
521
+ /** Tests several members in one read. */
522
+ containsMany(members: Array<string>, otelContext: Record<string, string>): Promise<Array<boolean>>
523
+ /** Reports whether the set has no live members. */
524
+ isEmpty(otelContext: Record<string, string>): Promise<boolean>
525
+ /** Adds `member` to the set. */
526
+ insert(member: string, otelContext: Record<string, string>): Promise<void>
527
+ /** Removes `member` from the set. */
528
+ remove(member: string, otelContext: Record<string, string>): Promise<void>
529
+ /** Removes every member. */
530
+ clear(otelContext: Record<string, string>): Promise<void>
531
+ /** Opens a cursor over the selected members. */
532
+ keys(query: NativeKeyQuery): NativeKeyCursor
533
+ /** Durably commits the buffered operations. */
534
+ commit(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
535
+ /** Discards the buffered operations. */
536
+ rollback(otelContext: Record<string, string>): Promise<NativeStoreOutcome>
537
+ }
538
+
539
+ /** The kind of a keyed-state collection. */
540
+ export type CollectionKind = 'value' | 'map' | 'set' | 'deque'
541
+
542
+ /** The item payload of a value, map, or deque collection. A set has none. */
543
+ export type CollectionPayload = 'json' | 'message'
544
+
702
545
  /** Configuration options for the Prosody client. */
703
546
  export interface Configuration {
704
547
  /** Kafka servers for initial connection. */
@@ -710,8 +553,9 @@ export interface Configuration {
710
553
  /** Consumer group name. */
711
554
  groupId?: string
712
555
  /**
713
- * Global shared cache capacity across all partitions for deduplicating
714
- * messages. Must be greater than 0.
556
+ * Capacity of both idempotence caches: the producer cache that skips a
557
+ * repeated event ID, and the consumer cache that drops a duplicate
558
+ * message. The consumer cache requires at least 1.
715
559
  */
716
560
  idempotenceCacheSize?: number
717
561
  /**
@@ -726,7 +570,7 @@ export interface Configuration {
726
570
  *
727
571
  * Must be at least 1 minute. Defaults to 7 days.
728
572
  */
729
- idempotenceTtlS?: number
573
+ idempotenceTtlSeconds?: number
730
574
  /** Topics to subscribe to. */
731
575
  subscribedTopics?: string | Array<string>
732
576
  /** Allowed event type prefixes. All event types are allowed if unset. */
@@ -751,6 +595,12 @@ export interface Configuration {
751
595
  pollIntervalMs?: number
752
596
  /** Time between offset commits in milliseconds. */
753
597
  commitIntervalMs?: number
598
+ /**
599
+ * Time between librdkafka statistics reports in milliseconds. Prosody
600
+ * accepts 1 ms to 24 hours. Uses `PROSODY_STATISTICS_INTERVAL` when
601
+ * omitted, then 5 seconds.
602
+ */
603
+ statisticsIntervalMs?: number
754
604
  /** Operating mode. */
755
605
  mode?: Mode
756
606
  /** Initial delay for exponential backoff in retries in milliseconds. */
@@ -904,12 +754,14 @@ export interface Configuration {
904
754
  */
905
755
  stateCollections?: Array<StateCollectionConfig>
906
756
  /**
907
- * Disk workspace for the local keyed-state cache.
757
+ * Directory that holds the local keyed-state caches.
908
758
  *
909
- * Each live client needs its own directory because it is locked
910
- * exclusively. Falls back to the `PROSODY_STATE_CACHE_DIR` environment
911
- * variable, then a per-client temporary directory. Must not be an
912
- * empty string when set.
759
+ * Each consumer opens its cache in a fresh subdirectory and removes that
760
+ * subdirectory when the consumer drops. So clients can share the
761
+ * directory, and the mount needs no persistence. Production deployments
762
+ * must set a mounted path, for example a Kubernetes `emptyDir`. Falls
763
+ * back to the `PROSODY_STATE_CACHE_DIR` environment variable, then to
764
+ * `<temp>/prosody/keyed-state`. Must not be an empty string when set.
913
765
  */
914
766
  stateCacheDir?: string
915
767
  /**
@@ -918,6 +770,14 @@ export interface Configuration {
918
770
  * storage engine selects its default.
919
771
  */
920
772
  stateOwnedCacheSize?: string
773
+ /**
774
+ * Bytes of in-memory writes the local keyed-state cache holds for each
775
+ * assigned partition before it flushes them to disk. Memory use scales
776
+ * with the number of assigned partitions. Accepts a human-readable size.
777
+ * Uses `PROSODY_STATE_MEMTABLE_SIZE` when omitted. Otherwise, the
778
+ * storage engine's default of 64 MiB applies.
779
+ */
780
+ stateMemtableSize?: string
921
781
  /**
922
782
  * Capacity of the published-state read-through cache. Uses
923
783
  * `PROSODY_STATE_READ_CACHE_SIZE` when omitted. It then uses the owning
@@ -925,22 +785,16 @@ export interface Configuration {
925
785
  */
926
786
  stateReadCacheSize?: string
927
787
  /**
928
- * Default cache policy for published-state reads. Uses
788
+ * Default cache policy for published-state reads: `false` turns the
789
+ * cache off, and `{ ttlMs }` sets the cache duration. The older form
790
+ * `{ disabled: true }` still turns the cache off. Uses
929
791
  * `PROSODY_STATE_READ_CACHE_TTL` when omitted, then 5 seconds.
930
792
  */
931
- stateReadCache?: ReadCacheConfiguration
793
+ stateReadCache?: ReadCacheConfiguration | false
932
794
  /**
933
- * Delay in whole seconds between staging a provisional cell and the
934
- * keyed-state recovery sweep. Every registered TTL must strictly exceed
935
- * this. Falls back to the `PROSODY_STATE_RECOVERY_DELAY` environment
936
- * variable (a duration string such as `30s`), then to 30 seconds. Must be
937
- * a whole number of seconds >= 1 when set (fractional, negative, and
938
- * non-finite values are rejected).
939
- */
940
- stateRecoveryDelaySeconds?: number
941
- /**
942
- * Subsystem under which published JSON collections are advertised.
943
- * Uses `PROSODY_SUBSYSTEM` when omitted. Published collections require it.
795
+ * Subsystem under which published JSON and set collections are
796
+ * advertised. Uses `PROSODY_SUBSYSTEM` when omitted. Published
797
+ * collections require it.
944
798
  */
945
799
  subsystem?: string
946
800
  /**
@@ -971,16 +825,10 @@ export interface Configuration {
971
825
  }
972
826
 
973
827
  /** Current consumer state. */
974
- export type ConsumerState = /** The client is shut down. */
975
- 'Shutdown'|
976
- /** The consumer is not configured. */
977
- 'Unconfigured'|
978
- /** The consumer is configured but not active. */
979
- 'Configured'|
980
- /** The consumer is active. */
981
- 'Running'|
982
- /** The consumer configuration failed. */
983
- 'ConfigurationFailed';
828
+ export type ConsumerState = 'Shutdown' | 'Unconfigured' | 'Configured' | 'Running' | 'ConfigurationFailed'
829
+
830
+ /** Why the handler runs: a normal delivery or a retry after a failure. */
831
+ export type DemandKind = 'normal' | 'failure'
984
832
 
985
833
  /**
986
834
  * Event metadata read off a payload before it was serialized.
@@ -995,8 +843,7 @@ export interface EventMetadata {
995
843
  }
996
844
 
997
845
  /** Type alias for excise handler arguments. */
998
- export type ExciseHandlerArgs =
999
- [NativeContext, ExciseMessage, Record<string, string>]
846
+ export type ExciseHandlerArgs = [NativeContext, ExciseMessage, Record<string, string>]
1000
847
 
1001
848
  /**
1002
849
  * Exports all pending telemetry data.
@@ -1017,12 +864,10 @@ export declare function flushTelemetry(): void
1017
864
  export declare function initialize(): void
1018
865
 
1019
866
  /** Type alias for error classification arguments. */
1020
- export type IsPermanentArgs =
1021
- [Error]
867
+ export type IsPermanentArgs = [Error]
1022
868
 
1023
869
  /** Type alias for the arguments passed to JavaScript logging functions. */
1024
- export type LogArgs =
1025
- [string | undefined | null, any]
870
+ export type LogArgs = [string | undefined | null, any]
1026
871
 
1027
872
  /** JavaScript-compatible logger structure. */
1028
873
  export interface Logger {
@@ -1038,27 +883,25 @@ export interface Logger {
1038
883
  trace: (arg: LogArgs) => void
1039
884
  }
1040
885
 
1041
- /**
1042
- * Checks if a logger has been set in the logging system.
1043
- *
1044
- * @returns True if a logger is currently configured, false otherwise.
1045
- */
1046
- export declare function loggerIsSet(): boolean
1047
-
1048
886
  /** Type alias for message handler arguments. */
1049
- export type MessageHandlerArgs =
1050
- [NativeContext, Message, Record<string, string>]
887
+ export type MessageHandlerArgs = [NativeContext, Message, Record<string, string>]
1051
888
 
1052
889
  /** Enum representing the operating mode of the Prosody client. */
1053
- export type Mode = /** Pipeline mode for standard processing. */
1054
- 'Pipeline'|
1055
- /** Low-latency mode for faster processing with potential trade-offs. */
1056
- 'LowLatency'|
1057
- /**
1058
- * Best-effort mode for development or when messages can be discarded when
1059
- * processing fails
1060
- */
1061
- 'BestEffort';
890
+ export type Mode = 'Pipeline' | 'LowLatency' | 'BestEffort'
891
+
892
+ /** The demand that started this handler invocation. */
893
+ export interface NativeDemand {
894
+ /** Whether the handler runs for a normal delivery or a retry. */
895
+ kind: DemandKind
896
+ /**
897
+ * The retry count: 0 for normal demand and 1 on the first retry. It is
898
+ * an estimate. Keep an exact attempt count in keyed state if needed.
899
+ */
900
+ retry: number
901
+ }
902
+
903
+ /** The order of a scan. */
904
+ export type NativeDirection = 'forward' | 'backward'
1062
905
 
1063
906
  /** One excise subsystem request. */
1064
907
  export interface NativeExciseRequest {
@@ -1115,6 +958,50 @@ export interface NativeHandler {
1115
958
  isPermanent: (arg: IsPermanentArgs) => boolean
1116
959
  }
1117
960
 
961
+ /** Query options for map keys, map entries, and set members. */
962
+ export interface NativeKeyQuery {
963
+ /** The query order. */
964
+ direction?: NativeDirection
965
+ /** Keeps keys that start with this prefix. */
966
+ prefix?: string
967
+ /** Starts at this key in query order. */
968
+ from?: string
969
+ /** Starts after this key in query order. */
970
+ after?: string
971
+ /** Stops at this key in query order. */
972
+ to?: string
973
+ /** Stops before this key in query order. */
974
+ before?: string
975
+ /**
976
+ * Keeps keys from the first bound up to, but not including, the second.
977
+ * A `null` bound leaves its end open.
978
+ */
979
+ range?: [string | undefined | null, string | undefined | null]
980
+ /** The maximum number of results. */
981
+ limit?: number
982
+ }
983
+
984
+ /** Query options for deque values. Positions count from the front. */
985
+ export interface NativePositionQuery {
986
+ /** The query order. */
987
+ direction?: NativeDirection
988
+ /** Starts at this position in query order. */
989
+ from?: number
990
+ /** Starts after this position in query order. */
991
+ after?: number
992
+ /** Stops at this position in query order. */
993
+ to?: number
994
+ /** Stops before this position in query order. */
995
+ before?: number
996
+ /**
997
+ * Keeps positions from the first bound up to, but not including, the
998
+ * second. A `null` bound leaves its end open.
999
+ */
1000
+ range?: [number | undefined | null, number | undefined | null]
1001
+ /** The maximum number of results. */
1002
+ limit?: number
1003
+ }
1004
+
1118
1005
  /** One subsystem request. */
1119
1006
  export interface NativeRequest {
1120
1007
  /** Kafka topic. */
@@ -1140,10 +1027,15 @@ export interface NativeResponseError {
1140
1027
  }
1141
1028
 
1142
1029
  /** One response failure kind. */
1143
- export type NativeResponseErrorKind = 'handler'|
1144
- 'timeout'|
1145
- 'formatMismatch'|
1146
- 'malformedResponse';
1030
+ export type NativeResponseErrorKind = 'handler' | 'timeout' | 'formatMismatch' | 'malformedResponse'
1031
+
1032
+ /**
1033
+ * The effect of a commit or a rollback.
1034
+ *
1035
+ * `"applied"` means the call wrote or discarded buffered operations.
1036
+ * `"noOp"` means nothing was buffered.
1037
+ */
1038
+ export type NativeStoreOutcome = 'applied' | 'noOp'
1147
1039
 
1148
1040
  /** One subsystem and its outcome. */
1149
1041
  export interface NativeSubsystemOutcome {
@@ -1153,14 +1045,20 @@ export interface NativeSubsystemOutcome {
1153
1045
  outcome: string | NativeResponseError
1154
1046
  }
1155
1047
 
1156
- /** Default cache policy for published-state reads. */
1048
+ /** The cache options for published-state reads. */
1157
1049
  export interface ReadCacheConfiguration {
1158
- /** Cache duration in milliseconds. */
1050
+ /** Cache duration in milliseconds. Omit it to use the default duration. */
1159
1051
  ttlMs?: number
1160
- /** Read durable storage on every operation. */
1052
+ /** `true` turns the cache off, the same as `false`. */
1161
1053
  disabled?: boolean
1162
1054
  }
1163
1055
 
1056
+ /**
1057
+ * A read cache option: `false` turns the cache off, and
1058
+ * `{ ttlMs }` sets the cache duration.
1059
+ */
1060
+ export type ReadCacheOption = boolean | ReadCacheConfiguration
1061
+
1164
1062
  /**
1165
1063
  * Sets a new JavaScript logger for the Prosody client.
1166
1064
  *
@@ -1169,23 +1067,13 @@ export interface ReadCacheConfiguration {
1169
1067
  * levels.
1170
1068
  *
1171
1069
  * @param logger - The JavaScript logger object with error, warn, info, debug,
1172
- * and trace methods. @throws Error if creating the new JavaScript logger
1173
- * fails.
1174
- */
1175
- export declare function setLogger(logger: Logger): void
1176
-
1177
- /**
1178
- * Sets a JavaScript logger only if no logger is currently configured.
1070
+ * and trace methods.
1179
1071
  *
1180
- * This function is useful for providing a default logger without overriding
1181
- * an existing one that may have been set earlier.
1072
+ * # Errors
1182
1073
  *
1183
- * @param logger - The JavaScript logger object with error, warn, info, debug,
1184
- * and trace methods. @returns True if the logger was set (no previous logger
1185
- * existed), false if a logger was already configured. @throws Error if
1186
- * creating the new JavaScript logger fails.
1074
+ * Returns an error if the thread-safe logger functions cannot be created.
1187
1075
  */
1188
- export declare function setLoggerIfUnset(logger: Logger): boolean
1076
+ export declare function setLogger(logger: Logger): void
1189
1077
 
1190
1078
  /**
1191
1079
  * Stops the global telemetry providers after they export pending data.
@@ -1205,17 +1093,17 @@ export interface StateCollectionConfig {
1205
1093
  * within the definition set.
1206
1094
  */
1207
1095
  name: string
1208
- /** The collection kind: `"value"`, `"map"`, or `"deque"`. */
1209
- kind: string
1096
+ /** The collection kind. */
1097
+ kind: CollectionKind
1210
1098
  /**
1211
- * The item payload: `"json"` (JSON values) or `"message"` (the full Kafka
1212
- * message the handler received).
1099
+ * The item payload. Required for value, map, and deque collections. Set
1100
+ * collections store members only and take no payload.
1213
1101
  */
1214
- payload: string
1102
+ payload?: CollectionPayload
1215
1103
  /**
1216
1104
  * Optional per-write TTL in whole seconds. Must be a whole number >= 1
1217
1105
  * (fractional, negative, and non-finite values are rejected) and must
1218
- * exceed the recovery delay (the latter checked at consumer build).
1106
+ * stay within the Cassandra TTL limit.
1219
1107
  */
1220
1108
  ttlSeconds?: number
1221
1109
  /**
@@ -1226,10 +1114,10 @@ export interface StateCollectionConfig {
1226
1114
  /** Whether other consumer groups may read this collection. */
1227
1115
  published?: boolean
1228
1116
  /**
1229
- * Optional map-only keyset bound (`0..=4096`; default 128 core-side; `0`
1230
- * disables ordered-scan tracking). The binding rejects values that cannot
1231
- * map to an unsigned integer. Prosody enforces the semantic ceiling.
1232
- * Invalid on value or deque collections.
1117
+ * Optional keyset bound for map and set collections (`0..=4096`; default
1118
+ * 128 core-side; `0` disables ordered-scan tracking). The binding rejects
1119
+ * values that cannot map to an unsigned integer. Prosody enforces the
1120
+ * semantic ceiling. Invalid on value or deque collections.
1233
1121
  */
1234
1122
  keysetLimit?: number
1235
1123
  /**
@@ -1255,5 +1143,15 @@ export interface Timer {
1255
1143
  }
1256
1144
 
1257
1145
  /** Type alias for timer handler arguments. */
1258
- export type TimerHandlerArgs =
1259
- [NativeContext, Timer, Record<string, string>]
1146
+ export type TimerHandlerArgs = [NativeContext, Timer, Record<string, string>]
1147
+
1148
+ /** Optional settings for a new topic. */
1149
+ export interface TopicOptions {
1150
+ /**
1151
+ * The cleanup policy, such as `"delete"`, `"compact"`, or
1152
+ * `"delete,compact"`.
1153
+ */
1154
+ cleanupPolicy?: string
1155
+ /** How long the topic keeps a message before deletion, in milliseconds. */
1156
+ retentionMs?: number
1157
+ }