@crossdelta/cloudevents 0.7.18 → 0.7.19
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/bin/cli.js +2 -4
- package/dist/index.cjs +13 -12
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +13 -12
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -661,14 +661,12 @@ var init_errors = __esm({
|
|
|
661
661
|
});
|
|
662
662
|
|
|
663
663
|
// src/infrastructure/logging.ts
|
|
664
|
-
var
|
|
664
|
+
var createLogger, logger;
|
|
665
665
|
var init_logging = __esm({
|
|
666
666
|
"src/infrastructure/logging.ts"() {
|
|
667
|
-
LOG_PREFIX = "cloudevents";
|
|
668
667
|
createLogger = (enabled) => {
|
|
669
668
|
const logWithArgs = (consoleFn, message, args) => {
|
|
670
|
-
|
|
671
|
-
args !== void 0 ? consoleFn(formattedMessage, args) : consoleFn(formattedMessage);
|
|
669
|
+
args !== void 0 ? consoleFn(message, args) : consoleFn(message);
|
|
672
670
|
};
|
|
673
671
|
return {
|
|
674
672
|
log: (message, args) => enabled && logWithArgs(console.log, message, args),
|
package/dist/index.cjs
CHANGED
|
@@ -84,14 +84,12 @@ var init_errors = __esm({
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
// src/infrastructure/logging.ts
|
|
87
|
-
var
|
|
87
|
+
var createLogger, logger;
|
|
88
88
|
var init_logging = __esm({
|
|
89
89
|
"src/infrastructure/logging.ts"() {
|
|
90
|
-
LOG_PREFIX = "cloudevents";
|
|
91
90
|
createLogger = (enabled) => {
|
|
92
91
|
const logWithArgs = (consoleFn, message, args) => {
|
|
93
|
-
|
|
94
|
-
args !== void 0 ? consoleFn(formattedMessage, args) : consoleFn(formattedMessage);
|
|
92
|
+
args !== void 0 ? consoleFn(message, args) : consoleFn(message);
|
|
95
93
|
};
|
|
96
94
|
return {
|
|
97
95
|
log: (message, args) => enabled && logWithArgs(console.log, message, args),
|
|
@@ -2188,7 +2186,7 @@ function cloudEvents(options = {}) {
|
|
|
2188
2186
|
// package.json
|
|
2189
2187
|
var package_default = {
|
|
2190
2188
|
name: "@crossdelta/cloudevents",
|
|
2191
|
-
version: "0.7.
|
|
2189
|
+
version: "0.7.19",
|
|
2192
2190
|
description: "CloudEvents toolkit for TypeScript - Zod validation, handler discovery, NATS JetStream & Core"};
|
|
2193
2191
|
|
|
2194
2192
|
// src/plugin.ts
|
|
@@ -2457,7 +2455,7 @@ var connectWithRetry = async (options, label) => {
|
|
|
2457
2455
|
return await nats.connect(options);
|
|
2458
2456
|
} catch (error) {
|
|
2459
2457
|
const elapsed = Date.now() - startedAt;
|
|
2460
|
-
const logLevel = elapsed >= ESCALATE_AFTER_MS ? "error" : "
|
|
2458
|
+
const logLevel = elapsed >= ESCALATE_AFTER_MS ? "error" : "warn";
|
|
2461
2459
|
logger[logLevel](`[${label}] NATS connect failed, retrying in ${delay}ms...`, error);
|
|
2462
2460
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2463
2461
|
delay = Math.min(delay * 2, MAX_RETRY_DELAY_MS);
|
|
@@ -2618,7 +2616,7 @@ async function ensureConsumer(jsm, streamName, consumerName, options) {
|
|
|
2618
2616
|
// Filter subjects at consumer level (optional)
|
|
2619
2617
|
filter_subjects: options.filterSubjects
|
|
2620
2618
|
});
|
|
2621
|
-
logger.
|
|
2619
|
+
logger.debug(`[jetstream] created durable consumer ${consumerName} on stream ${streamName}`);
|
|
2622
2620
|
}
|
|
2623
2621
|
}
|
|
2624
2622
|
async function consumeJetStreamEvents(options) {
|
|
@@ -2629,7 +2627,7 @@ async function consumeJetStreamEvents(options) {
|
|
|
2629
2627
|
const handlerConstructors = await discoverHandlers(options.discover);
|
|
2630
2628
|
const processedHandlers = handlerConstructors.map(processHandler).filter((h) => h !== null);
|
|
2631
2629
|
const handlerNames = processedHandlers.map((h) => h.name).join(", ");
|
|
2632
|
-
logger.info(`[${name}] discovered ${processedHandlers.length} handler
|
|
2630
|
+
logger.info(`[${name}] discovered ${processedHandlers.length} handler${processedHandlers.length === 1 ? "" : "s"}: ${handlerNames}`);
|
|
2633
2631
|
const nc = await connectWithRetry(
|
|
2634
2632
|
{
|
|
2635
2633
|
servers,
|
|
@@ -2647,7 +2645,7 @@ async function consumeJetStreamEvents(options) {
|
|
|
2647
2645
|
const messages = await consumer.consume({
|
|
2648
2646
|
max_messages: options.maxMessages ?? 100
|
|
2649
2647
|
});
|
|
2650
|
-
logger.info(`[${name}] consuming from stream ${options.stream}`);
|
|
2648
|
+
logger.info(`[${name}] consuming from stream: ${options.stream}`);
|
|
2651
2649
|
const dlqEnabled = Boolean(options.quarantineTopic || options.errorTopic);
|
|
2652
2650
|
const idempotencyStore = options.idempotencyStore === false ? null : options.idempotencyStore ?? getDefaultIdempotencyStore();
|
|
2653
2651
|
const idempotencyTtl = options.idempotencyTtl;
|
|
@@ -2702,7 +2700,7 @@ async function consumeJetStreamStreams(options) {
|
|
|
2702
2700
|
const handlerConstructors = await discoverHandlers(options.discover);
|
|
2703
2701
|
const processedHandlers = handlerConstructors.map(processHandler).filter((h) => h !== null);
|
|
2704
2702
|
const handlerNames = processedHandlers.map((h) => h.name).join(", ");
|
|
2705
|
-
logger.info(`[${name}] discovered ${processedHandlers.length} handler
|
|
2703
|
+
logger.info(`[${name}] discovered ${processedHandlers.length} handler${processedHandlers.length === 1 ? "" : "s"}: ${handlerNames}`);
|
|
2706
2704
|
const nc = await connectWithRetry(
|
|
2707
2705
|
{
|
|
2708
2706
|
servers,
|
|
@@ -2759,7 +2757,6 @@ async function consumeJetStreamStreams(options) {
|
|
|
2759
2757
|
const messages = await consumer.consume({
|
|
2760
2758
|
max_messages: options.maxMessages ?? 100
|
|
2761
2759
|
});
|
|
2762
|
-
logger.info(`[${name}] consuming from stream ${stream}`);
|
|
2763
2760
|
(async () => {
|
|
2764
2761
|
try {
|
|
2765
2762
|
for await (const msg of messages) {
|
|
@@ -2771,6 +2768,9 @@ async function consumeJetStreamStreams(options) {
|
|
|
2771
2768
|
})();
|
|
2772
2769
|
allMessages.push(messages);
|
|
2773
2770
|
}
|
|
2771
|
+
const streamList = options.streams.join(", ");
|
|
2772
|
+
const streamLabel = options.streams.length === 1 ? "stream" : "streams";
|
|
2773
|
+
logger.info(`[${name}] consuming from ${streamLabel}: ${streamList}`);
|
|
2774
2774
|
return allMessages;
|
|
2775
2775
|
}
|
|
2776
2776
|
var ensureJetStreams = ensureJetStreamStreams;
|
|
@@ -2851,7 +2851,8 @@ async function consumeNatsEvents(options) {
|
|
|
2851
2851
|
const handlerConstructors = await discoverHandlers(options.discover);
|
|
2852
2852
|
const processedHandlers = handlerConstructors.map(processHandler).filter((h) => h !== null);
|
|
2853
2853
|
const handlerNames = processedHandlers.map((h) => h.name).join(", ");
|
|
2854
|
-
|
|
2854
|
+
const handlerLabel = processedHandlers.length === 1 ? "handler" : "handlers";
|
|
2855
|
+
logger.info(`[${name}] discovered ${processedHandlers.length} ${handlerLabel}: ${handlerNames}`);
|
|
2855
2856
|
const nc = await connectWithRetry(
|
|
2856
2857
|
{
|
|
2857
2858
|
servers,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
2
|
import { CloudEventV1 } from 'cloudevents';
|
|
3
|
-
import {
|
|
3
|
+
import { ZodType, z } from 'zod';
|
|
4
4
|
import { ChangeResult, FlowContext, FsContextMixin, GenerationContextMixin, FlowStep } from '@crossdelta/flowcore';
|
|
5
5
|
import { ConsumerMessages, Subscription } from 'nats';
|
|
6
6
|
|
|
@@ -413,7 +413,7 @@ interface EventHandler<T = unknown> {
|
|
|
413
413
|
*/
|
|
414
414
|
type HandlerConstructor<T = unknown> = (new (...args: unknown[]) => EventHandler<T>) & {
|
|
415
415
|
__eventarcMetadata?: {
|
|
416
|
-
schema:
|
|
416
|
+
schema: ZodType;
|
|
417
417
|
declaredType?: string;
|
|
418
418
|
match?: (event: EnrichedEvent<T>) => boolean;
|
|
419
419
|
safeParse?: boolean;
|
|
@@ -455,7 +455,7 @@ interface ChannelConfig {
|
|
|
455
455
|
* Note: In Zod v4, we use a more relaxed schema constraint to allow
|
|
456
456
|
* contracts defined in external packages to work correctly.
|
|
457
457
|
*/
|
|
458
|
-
interface HandleEventOptions<S =
|
|
458
|
+
interface HandleEventOptions<S = ZodType> {
|
|
459
459
|
schema: S;
|
|
460
460
|
type?: string;
|
|
461
461
|
match?: MatchFn<unknown>;
|
|
@@ -491,7 +491,7 @@ interface IdempotencyStore {
|
|
|
491
491
|
* Type helper to extract data type from a Zod schema
|
|
492
492
|
* Handles both data-only schemas and full CloudEvent schemas with a 'data' field
|
|
493
493
|
*/
|
|
494
|
-
type InferEventData<S extends
|
|
494
|
+
type InferEventData<S extends ZodType> = S['_output'] extends {
|
|
495
495
|
data: infer D;
|
|
496
496
|
} ? D : S['_output'];
|
|
497
497
|
|
|
@@ -542,7 +542,7 @@ type InferEventData<S extends ZodTypeAny> = S['_output'] extends {
|
|
|
542
542
|
* })
|
|
543
543
|
* ```
|
|
544
544
|
*/
|
|
545
|
-
declare function createContract<TSchema extends
|
|
545
|
+
declare function createContract<TSchema extends ZodType>(options: {
|
|
546
546
|
type: string;
|
|
547
547
|
schema: TSchema;
|
|
548
548
|
match?: HandleEventOptions['match'];
|
|
@@ -594,15 +594,15 @@ declare function createContract<TSchema extends ZodTypeAny>(options: {
|
|
|
594
594
|
* })
|
|
595
595
|
* ```
|
|
596
596
|
*/
|
|
597
|
-
declare function handleEvent<TSchema extends
|
|
597
|
+
declare function handleEvent<TSchema extends ZodType>(schemaOrOptions: TSchema | HandleEventOptions<TSchema> | HandleEventOptions, handler: (payload: TSchema['_output'], context?: EventContext) => Promise<unknown> | unknown, eventType?: string): HandlerConstructor;
|
|
598
598
|
/**
|
|
599
599
|
* Creates an event schema with type inference
|
|
600
600
|
* Automatically enforces the presence of a 'type' field
|
|
601
601
|
*/
|
|
602
|
-
declare function eventSchema<T extends Record<string,
|
|
603
|
-
type:
|
|
602
|
+
declare function eventSchema<T extends Record<string, ZodType>>(schema: T & {
|
|
603
|
+
type: ZodType;
|
|
604
604
|
}): z.ZodObject<T & {
|
|
605
|
-
type:
|
|
605
|
+
type: ZodType;
|
|
606
606
|
} extends infer T_1 ? { -readonly [P in keyof T_1]: T_1[P]; } : never, z.core.$strip>;
|
|
607
607
|
|
|
608
608
|
/**
|
|
@@ -797,7 +797,7 @@ declare const normalizeSubject: (eventType: string) => string;
|
|
|
797
797
|
* @param schema - Zod schema to extract type from
|
|
798
798
|
* @returns Event type string or undefined if not found
|
|
799
799
|
*/
|
|
800
|
-
declare const extractTypeFromSchema: (schema:
|
|
800
|
+
declare const extractTypeFromSchema: (schema: ZodType) => string | undefined;
|
|
801
801
|
|
|
802
802
|
/**
|
|
803
803
|
* Create Event Flow
|
|
@@ -1354,7 +1354,7 @@ declare const __resetNatsPublisher: () => Promise<void>;
|
|
|
1354
1354
|
declare const deriveSubjectFromType: (eventType: string, config?: RoutingConfig) => string;
|
|
1355
1355
|
declare const deriveStreamFromType: (eventType: string, config?: RoutingConfig) => string | undefined;
|
|
1356
1356
|
declare const publishNatsRawEvent: (subjectName: string, eventType: string, eventData: unknown, options?: PublishNatsEventOptions) => Promise<string>;
|
|
1357
|
-
declare const publishNatsEvent: <T extends
|
|
1357
|
+
declare const publishNatsEvent: <T extends ZodType>(subjectName: string, schema: T, eventData: unknown, options?: PublishNatsEventOptions) => Promise<string>;
|
|
1358
1358
|
declare const publish: (eventTypeOrContract: string | {
|
|
1359
1359
|
type: string;
|
|
1360
1360
|
channel?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
2
|
import { CloudEventV1 } from 'cloudevents';
|
|
3
|
-
import {
|
|
3
|
+
import { ZodType, z } from 'zod';
|
|
4
4
|
import { ChangeResult, FlowContext, FsContextMixin, GenerationContextMixin, FlowStep } from '@crossdelta/flowcore';
|
|
5
5
|
import { ConsumerMessages, Subscription } from 'nats';
|
|
6
6
|
|
|
@@ -413,7 +413,7 @@ interface EventHandler<T = unknown> {
|
|
|
413
413
|
*/
|
|
414
414
|
type HandlerConstructor<T = unknown> = (new (...args: unknown[]) => EventHandler<T>) & {
|
|
415
415
|
__eventarcMetadata?: {
|
|
416
|
-
schema:
|
|
416
|
+
schema: ZodType;
|
|
417
417
|
declaredType?: string;
|
|
418
418
|
match?: (event: EnrichedEvent<T>) => boolean;
|
|
419
419
|
safeParse?: boolean;
|
|
@@ -455,7 +455,7 @@ interface ChannelConfig {
|
|
|
455
455
|
* Note: In Zod v4, we use a more relaxed schema constraint to allow
|
|
456
456
|
* contracts defined in external packages to work correctly.
|
|
457
457
|
*/
|
|
458
|
-
interface HandleEventOptions<S =
|
|
458
|
+
interface HandleEventOptions<S = ZodType> {
|
|
459
459
|
schema: S;
|
|
460
460
|
type?: string;
|
|
461
461
|
match?: MatchFn<unknown>;
|
|
@@ -491,7 +491,7 @@ interface IdempotencyStore {
|
|
|
491
491
|
* Type helper to extract data type from a Zod schema
|
|
492
492
|
* Handles both data-only schemas and full CloudEvent schemas with a 'data' field
|
|
493
493
|
*/
|
|
494
|
-
type InferEventData<S extends
|
|
494
|
+
type InferEventData<S extends ZodType> = S['_output'] extends {
|
|
495
495
|
data: infer D;
|
|
496
496
|
} ? D : S['_output'];
|
|
497
497
|
|
|
@@ -542,7 +542,7 @@ type InferEventData<S extends ZodTypeAny> = S['_output'] extends {
|
|
|
542
542
|
* })
|
|
543
543
|
* ```
|
|
544
544
|
*/
|
|
545
|
-
declare function createContract<TSchema extends
|
|
545
|
+
declare function createContract<TSchema extends ZodType>(options: {
|
|
546
546
|
type: string;
|
|
547
547
|
schema: TSchema;
|
|
548
548
|
match?: HandleEventOptions['match'];
|
|
@@ -594,15 +594,15 @@ declare function createContract<TSchema extends ZodTypeAny>(options: {
|
|
|
594
594
|
* })
|
|
595
595
|
* ```
|
|
596
596
|
*/
|
|
597
|
-
declare function handleEvent<TSchema extends
|
|
597
|
+
declare function handleEvent<TSchema extends ZodType>(schemaOrOptions: TSchema | HandleEventOptions<TSchema> | HandleEventOptions, handler: (payload: TSchema['_output'], context?: EventContext) => Promise<unknown> | unknown, eventType?: string): HandlerConstructor;
|
|
598
598
|
/**
|
|
599
599
|
* Creates an event schema with type inference
|
|
600
600
|
* Automatically enforces the presence of a 'type' field
|
|
601
601
|
*/
|
|
602
|
-
declare function eventSchema<T extends Record<string,
|
|
603
|
-
type:
|
|
602
|
+
declare function eventSchema<T extends Record<string, ZodType>>(schema: T & {
|
|
603
|
+
type: ZodType;
|
|
604
604
|
}): z.ZodObject<T & {
|
|
605
|
-
type:
|
|
605
|
+
type: ZodType;
|
|
606
606
|
} extends infer T_1 ? { -readonly [P in keyof T_1]: T_1[P]; } : never, z.core.$strip>;
|
|
607
607
|
|
|
608
608
|
/**
|
|
@@ -797,7 +797,7 @@ declare const normalizeSubject: (eventType: string) => string;
|
|
|
797
797
|
* @param schema - Zod schema to extract type from
|
|
798
798
|
* @returns Event type string or undefined if not found
|
|
799
799
|
*/
|
|
800
|
-
declare const extractTypeFromSchema: (schema:
|
|
800
|
+
declare const extractTypeFromSchema: (schema: ZodType) => string | undefined;
|
|
801
801
|
|
|
802
802
|
/**
|
|
803
803
|
* Create Event Flow
|
|
@@ -1354,7 +1354,7 @@ declare const __resetNatsPublisher: () => Promise<void>;
|
|
|
1354
1354
|
declare const deriveSubjectFromType: (eventType: string, config?: RoutingConfig) => string;
|
|
1355
1355
|
declare const deriveStreamFromType: (eventType: string, config?: RoutingConfig) => string | undefined;
|
|
1356
1356
|
declare const publishNatsRawEvent: (subjectName: string, eventType: string, eventData: unknown, options?: PublishNatsEventOptions) => Promise<string>;
|
|
1357
|
-
declare const publishNatsEvent: <T extends
|
|
1357
|
+
declare const publishNatsEvent: <T extends ZodType>(subjectName: string, schema: T, eventData: unknown, options?: PublishNatsEventOptions) => Promise<string>;
|
|
1358
1358
|
declare const publish: (eventTypeOrContract: string | {
|
|
1359
1359
|
type: string;
|
|
1360
1360
|
channel?: {
|
package/dist/index.js
CHANGED
|
@@ -59,14 +59,12 @@ var init_errors = __esm({
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
// src/infrastructure/logging.ts
|
|
62
|
-
var
|
|
62
|
+
var createLogger, logger;
|
|
63
63
|
var init_logging = __esm({
|
|
64
64
|
"src/infrastructure/logging.ts"() {
|
|
65
|
-
LOG_PREFIX = "cloudevents";
|
|
66
65
|
createLogger = (enabled) => {
|
|
67
66
|
const logWithArgs = (consoleFn, message, args) => {
|
|
68
|
-
|
|
69
|
-
args !== void 0 ? consoleFn(formattedMessage, args) : consoleFn(formattedMessage);
|
|
67
|
+
args !== void 0 ? consoleFn(message, args) : consoleFn(message);
|
|
70
68
|
};
|
|
71
69
|
return {
|
|
72
70
|
log: (message, args) => enabled && logWithArgs(console.log, message, args),
|
|
@@ -2163,7 +2161,7 @@ function cloudEvents(options = {}) {
|
|
|
2163
2161
|
// package.json
|
|
2164
2162
|
var package_default = {
|
|
2165
2163
|
name: "@crossdelta/cloudevents",
|
|
2166
|
-
version: "0.7.
|
|
2164
|
+
version: "0.7.19",
|
|
2167
2165
|
description: "CloudEvents toolkit for TypeScript - Zod validation, handler discovery, NATS JetStream & Core"};
|
|
2168
2166
|
|
|
2169
2167
|
// src/plugin.ts
|
|
@@ -2432,7 +2430,7 @@ var connectWithRetry = async (options, label) => {
|
|
|
2432
2430
|
return await connect(options);
|
|
2433
2431
|
} catch (error) {
|
|
2434
2432
|
const elapsed = Date.now() - startedAt;
|
|
2435
|
-
const logLevel = elapsed >= ESCALATE_AFTER_MS ? "error" : "
|
|
2433
|
+
const logLevel = elapsed >= ESCALATE_AFTER_MS ? "error" : "warn";
|
|
2436
2434
|
logger[logLevel](`[${label}] NATS connect failed, retrying in ${delay}ms...`, error);
|
|
2437
2435
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2438
2436
|
delay = Math.min(delay * 2, MAX_RETRY_DELAY_MS);
|
|
@@ -2593,7 +2591,7 @@ async function ensureConsumer(jsm, streamName, consumerName, options) {
|
|
|
2593
2591
|
// Filter subjects at consumer level (optional)
|
|
2594
2592
|
filter_subjects: options.filterSubjects
|
|
2595
2593
|
});
|
|
2596
|
-
logger.
|
|
2594
|
+
logger.debug(`[jetstream] created durable consumer ${consumerName} on stream ${streamName}`);
|
|
2597
2595
|
}
|
|
2598
2596
|
}
|
|
2599
2597
|
async function consumeJetStreamEvents(options) {
|
|
@@ -2604,7 +2602,7 @@ async function consumeJetStreamEvents(options) {
|
|
|
2604
2602
|
const handlerConstructors = await discoverHandlers(options.discover);
|
|
2605
2603
|
const processedHandlers = handlerConstructors.map(processHandler).filter((h) => h !== null);
|
|
2606
2604
|
const handlerNames = processedHandlers.map((h) => h.name).join(", ");
|
|
2607
|
-
logger.info(`[${name}] discovered ${processedHandlers.length} handler
|
|
2605
|
+
logger.info(`[${name}] discovered ${processedHandlers.length} handler${processedHandlers.length === 1 ? "" : "s"}: ${handlerNames}`);
|
|
2608
2606
|
const nc = await connectWithRetry(
|
|
2609
2607
|
{
|
|
2610
2608
|
servers,
|
|
@@ -2622,7 +2620,7 @@ async function consumeJetStreamEvents(options) {
|
|
|
2622
2620
|
const messages = await consumer.consume({
|
|
2623
2621
|
max_messages: options.maxMessages ?? 100
|
|
2624
2622
|
});
|
|
2625
|
-
logger.info(`[${name}] consuming from stream ${options.stream}`);
|
|
2623
|
+
logger.info(`[${name}] consuming from stream: ${options.stream}`);
|
|
2626
2624
|
const dlqEnabled = Boolean(options.quarantineTopic || options.errorTopic);
|
|
2627
2625
|
const idempotencyStore = options.idempotencyStore === false ? null : options.idempotencyStore ?? getDefaultIdempotencyStore();
|
|
2628
2626
|
const idempotencyTtl = options.idempotencyTtl;
|
|
@@ -2677,7 +2675,7 @@ async function consumeJetStreamStreams(options) {
|
|
|
2677
2675
|
const handlerConstructors = await discoverHandlers(options.discover);
|
|
2678
2676
|
const processedHandlers = handlerConstructors.map(processHandler).filter((h) => h !== null);
|
|
2679
2677
|
const handlerNames = processedHandlers.map((h) => h.name).join(", ");
|
|
2680
|
-
logger.info(`[${name}] discovered ${processedHandlers.length} handler
|
|
2678
|
+
logger.info(`[${name}] discovered ${processedHandlers.length} handler${processedHandlers.length === 1 ? "" : "s"}: ${handlerNames}`);
|
|
2681
2679
|
const nc = await connectWithRetry(
|
|
2682
2680
|
{
|
|
2683
2681
|
servers,
|
|
@@ -2734,7 +2732,6 @@ async function consumeJetStreamStreams(options) {
|
|
|
2734
2732
|
const messages = await consumer.consume({
|
|
2735
2733
|
max_messages: options.maxMessages ?? 100
|
|
2736
2734
|
});
|
|
2737
|
-
logger.info(`[${name}] consuming from stream ${stream}`);
|
|
2738
2735
|
(async () => {
|
|
2739
2736
|
try {
|
|
2740
2737
|
for await (const msg of messages) {
|
|
@@ -2746,6 +2743,9 @@ async function consumeJetStreamStreams(options) {
|
|
|
2746
2743
|
})();
|
|
2747
2744
|
allMessages.push(messages);
|
|
2748
2745
|
}
|
|
2746
|
+
const streamList = options.streams.join(", ");
|
|
2747
|
+
const streamLabel = options.streams.length === 1 ? "stream" : "streams";
|
|
2748
|
+
logger.info(`[${name}] consuming from ${streamLabel}: ${streamList}`);
|
|
2749
2749
|
return allMessages;
|
|
2750
2750
|
}
|
|
2751
2751
|
var ensureJetStreams = ensureJetStreamStreams;
|
|
@@ -2826,7 +2826,8 @@ async function consumeNatsEvents(options) {
|
|
|
2826
2826
|
const handlerConstructors = await discoverHandlers(options.discover);
|
|
2827
2827
|
const processedHandlers = handlerConstructors.map(processHandler).filter((h) => h !== null);
|
|
2828
2828
|
const handlerNames = processedHandlers.map((h) => h.name).join(", ");
|
|
2829
|
-
|
|
2829
|
+
const handlerLabel = processedHandlers.length === 1 ? "handler" : "handlers";
|
|
2830
|
+
logger.info(`[${name}] discovered ${processedHandlers.length} ${handlerLabel}: ${handlerNames}`);
|
|
2830
2831
|
const nc = await connectWithRetry(
|
|
2831
2832
|
{
|
|
2832
2833
|
servers,
|
package/package.json
CHANGED