@crossdelta/cloudevents 0.6.1 → 0.6.3
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/dist/index.cjs +21 -7
- package/dist/index.d.mts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +20 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -528,8 +528,8 @@ init_infrastructure();
|
|
|
528
528
|
// src/processing/dlq-safe.ts
|
|
529
529
|
init_infrastructure();
|
|
530
530
|
init_infrastructure();
|
|
531
|
-
|
|
532
|
-
|
|
531
|
+
|
|
532
|
+
// src/utils/pluralize.ts
|
|
533
533
|
var pluralize = (word) => {
|
|
534
534
|
if (word.endsWith("y") && !["a", "e", "i", "o", "u"].includes(word[word.length - 2])) {
|
|
535
535
|
return `${word.slice(0, -1)}ies`;
|
|
@@ -539,6 +539,22 @@ var pluralize = (word) => {
|
|
|
539
539
|
}
|
|
540
540
|
return `${word}s`;
|
|
541
541
|
};
|
|
542
|
+
var singularize = (word) => {
|
|
543
|
+
if (word.endsWith("ies")) {
|
|
544
|
+
return `${word.slice(0, -3)}y`;
|
|
545
|
+
}
|
|
546
|
+
if (word.endsWith("xes") || word.endsWith("shes") || word.endsWith("ches") || word.endsWith("ses")) {
|
|
547
|
+
return word.slice(0, -2);
|
|
548
|
+
}
|
|
549
|
+
if (word.endsWith("s")) {
|
|
550
|
+
return word.slice(0, -1);
|
|
551
|
+
}
|
|
552
|
+
return word;
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
// src/publishing/nats.publisher.ts
|
|
556
|
+
var sc = nats.StringCodec();
|
|
557
|
+
var natsConnectionPromise = null;
|
|
542
558
|
var deriveSubjectFromEventType = (eventType) => {
|
|
543
559
|
const parts = eventType.split(".");
|
|
544
560
|
if (parts.length < 2) return eventType;
|
|
@@ -1123,11 +1139,7 @@ function createBaseMessageProcessor(deps) {
|
|
|
1123
1139
|
const findHandler = (event) => processedHandlers.find(
|
|
1124
1140
|
(handler) => handler.type === event.eventType && (!handler.match || handler.match(event))
|
|
1125
1141
|
);
|
|
1126
|
-
const handleMissingHandler = async (
|
|
1127
|
-
logger2.warn(`[${name}] no handler for event type: ${eventType}`);
|
|
1128
|
-
if (dlqEnabled) {
|
|
1129
|
-
await quarantineMessage(context, "no_handler", options, new Error(`No handler for event type ${eventType}`));
|
|
1130
|
-
}
|
|
1142
|
+
const handleMissingHandler = async (_context, _eventType) => {
|
|
1131
1143
|
return { handled: true, shouldAck: true };
|
|
1132
1144
|
};
|
|
1133
1145
|
const handleValidationFailure = async (validationResult, handler, context) => {
|
|
@@ -1594,9 +1606,11 @@ exports.extractTypeFromSchema = extractTypeFromSchema;
|
|
|
1594
1606
|
exports.getDefaultIdempotencyStore = getDefaultIdempotencyStore;
|
|
1595
1607
|
exports.handleEvent = handleEvent;
|
|
1596
1608
|
exports.parseEventFromContext = parseEventFromContext;
|
|
1609
|
+
exports.pluralize = pluralize;
|
|
1597
1610
|
exports.publish = publish;
|
|
1598
1611
|
exports.publishEvent = publishEvent;
|
|
1599
1612
|
exports.publishNatsEvent = publishNatsEvent;
|
|
1600
1613
|
exports.publishNatsRawEvent = publishNatsRawEvent;
|
|
1601
1614
|
exports.publishRawEvent = publishRawEvent;
|
|
1602
1615
|
exports.resetDefaultIdempotencyStore = resetDefaultIdempotencyStore;
|
|
1616
|
+
exports.singularize = singularize;
|
package/dist/index.d.mts
CHANGED
|
@@ -809,4 +809,34 @@ interface NatsConsumerOptions extends Pick<CloudEventsOptions, 'quarantineTopic'
|
|
|
809
809
|
*/
|
|
810
810
|
declare function consumeNatsEvents(options: NatsConsumerOptions): Promise<Subscription>;
|
|
811
811
|
|
|
812
|
-
|
|
812
|
+
/**
|
|
813
|
+
* Pluralization Utilities
|
|
814
|
+
*
|
|
815
|
+
* Central place for English pluralization rules.
|
|
816
|
+
* Used by both cloudevents (subject derivation) and platform-sdk (contract generation).
|
|
817
|
+
*
|
|
818
|
+
* Rules follow standard English grammar:
|
|
819
|
+
* - consonant + y → ies (policy → policies)
|
|
820
|
+
* - s, sh, ch, x → +es (max → maxes, batch → batches)
|
|
821
|
+
* - all other → +s (order → orders)
|
|
822
|
+
*/
|
|
823
|
+
/**
|
|
824
|
+
* Convert singular word to plural
|
|
825
|
+
*
|
|
826
|
+
* @example pluralize('order') => 'orders'
|
|
827
|
+
* @example pluralize('policy') => 'policies'
|
|
828
|
+
* @example pluralize('max') => 'maxes'
|
|
829
|
+
* @example pluralize('batch') => 'batches'
|
|
830
|
+
*/
|
|
831
|
+
declare const pluralize: (word: string) => string;
|
|
832
|
+
/**
|
|
833
|
+
* Convert plural word to singular (inverse of pluralize)
|
|
834
|
+
*
|
|
835
|
+
* @example singularize('orders') => 'order'
|
|
836
|
+
* @example singularize('policies') => 'policy'
|
|
837
|
+
* @example singularize('maxes') => 'max'
|
|
838
|
+
* @example singularize('batches') => 'batch'
|
|
839
|
+
*/
|
|
840
|
+
declare const singularize: (word: string) => string;
|
|
841
|
+
|
|
842
|
+
export { type ChannelConfig, type ChannelMetadata, type EnrichedEvent, type EventContext, type HandleEventOptions, type IdempotencyStore, type InferEventData, type JetStreamConsumerOptions, type JetStreamStreamOptions, type JetStreamStreamsConsumerOptions, type JetStreamStreamsOptions, type PublishEventOptions, type PublishNatsEventOptions, type RoutingConfig, type StreamConfig, type StreamDefinition, __resetNatsPublisher, checkAndMarkProcessed, clearHandlerCache, cloudEvents, consumeJetStreamEvents, consumeJetStreamStreams, consumeJetStreams, consumeNatsEvents, createContract, createInMemoryIdempotencyStore, deriveStreamFromType, deriveSubjectFromType, ensureJetStreamStream, ensureJetStreamStreams, ensureJetStreams, eventSchema, extractTypeFromSchema, getDefaultIdempotencyStore, handleEvent, parseEventFromContext, pluralize, publish, publishEvent, publishNatsEvent, publishNatsRawEvent, publishRawEvent, resetDefaultIdempotencyStore, singularize };
|
package/dist/index.d.ts
CHANGED
|
@@ -809,4 +809,34 @@ interface NatsConsumerOptions extends Pick<CloudEventsOptions, 'quarantineTopic'
|
|
|
809
809
|
*/
|
|
810
810
|
declare function consumeNatsEvents(options: NatsConsumerOptions): Promise<Subscription>;
|
|
811
811
|
|
|
812
|
-
|
|
812
|
+
/**
|
|
813
|
+
* Pluralization Utilities
|
|
814
|
+
*
|
|
815
|
+
* Central place for English pluralization rules.
|
|
816
|
+
* Used by both cloudevents (subject derivation) and platform-sdk (contract generation).
|
|
817
|
+
*
|
|
818
|
+
* Rules follow standard English grammar:
|
|
819
|
+
* - consonant + y → ies (policy → policies)
|
|
820
|
+
* - s, sh, ch, x → +es (max → maxes, batch → batches)
|
|
821
|
+
* - all other → +s (order → orders)
|
|
822
|
+
*/
|
|
823
|
+
/**
|
|
824
|
+
* Convert singular word to plural
|
|
825
|
+
*
|
|
826
|
+
* @example pluralize('order') => 'orders'
|
|
827
|
+
* @example pluralize('policy') => 'policies'
|
|
828
|
+
* @example pluralize('max') => 'maxes'
|
|
829
|
+
* @example pluralize('batch') => 'batches'
|
|
830
|
+
*/
|
|
831
|
+
declare const pluralize: (word: string) => string;
|
|
832
|
+
/**
|
|
833
|
+
* Convert plural word to singular (inverse of pluralize)
|
|
834
|
+
*
|
|
835
|
+
* @example singularize('orders') => 'order'
|
|
836
|
+
* @example singularize('policies') => 'policy'
|
|
837
|
+
* @example singularize('maxes') => 'max'
|
|
838
|
+
* @example singularize('batches') => 'batch'
|
|
839
|
+
*/
|
|
840
|
+
declare const singularize: (word: string) => string;
|
|
841
|
+
|
|
842
|
+
export { type ChannelConfig, type ChannelMetadata, type EnrichedEvent, type EventContext, type HandleEventOptions, type IdempotencyStore, type InferEventData, type JetStreamConsumerOptions, type JetStreamStreamOptions, type JetStreamStreamsConsumerOptions, type JetStreamStreamsOptions, type PublishEventOptions, type PublishNatsEventOptions, type RoutingConfig, type StreamConfig, type StreamDefinition, __resetNatsPublisher, checkAndMarkProcessed, clearHandlerCache, cloudEvents, consumeJetStreamEvents, consumeJetStreamStreams, consumeJetStreams, consumeNatsEvents, createContract, createInMemoryIdempotencyStore, deriveStreamFromType, deriveSubjectFromType, ensureJetStreamStream, ensureJetStreamStreams, ensureJetStreams, eventSchema, extractTypeFromSchema, getDefaultIdempotencyStore, handleEvent, parseEventFromContext, pluralize, publish, publishEvent, publishNatsEvent, publishNatsRawEvent, publishRawEvent, resetDefaultIdempotencyStore, singularize };
|
package/dist/index.js
CHANGED
|
@@ -525,8 +525,8 @@ init_infrastructure();
|
|
|
525
525
|
// src/processing/dlq-safe.ts
|
|
526
526
|
init_infrastructure();
|
|
527
527
|
init_infrastructure();
|
|
528
|
-
|
|
529
|
-
|
|
528
|
+
|
|
529
|
+
// src/utils/pluralize.ts
|
|
530
530
|
var pluralize = (word) => {
|
|
531
531
|
if (word.endsWith("y") && !["a", "e", "i", "o", "u"].includes(word[word.length - 2])) {
|
|
532
532
|
return `${word.slice(0, -1)}ies`;
|
|
@@ -536,6 +536,22 @@ var pluralize = (word) => {
|
|
|
536
536
|
}
|
|
537
537
|
return `${word}s`;
|
|
538
538
|
};
|
|
539
|
+
var singularize = (word) => {
|
|
540
|
+
if (word.endsWith("ies")) {
|
|
541
|
+
return `${word.slice(0, -3)}y`;
|
|
542
|
+
}
|
|
543
|
+
if (word.endsWith("xes") || word.endsWith("shes") || word.endsWith("ches") || word.endsWith("ses")) {
|
|
544
|
+
return word.slice(0, -2);
|
|
545
|
+
}
|
|
546
|
+
if (word.endsWith("s")) {
|
|
547
|
+
return word.slice(0, -1);
|
|
548
|
+
}
|
|
549
|
+
return word;
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
// src/publishing/nats.publisher.ts
|
|
553
|
+
var sc = StringCodec();
|
|
554
|
+
var natsConnectionPromise = null;
|
|
539
555
|
var deriveSubjectFromEventType = (eventType) => {
|
|
540
556
|
const parts = eventType.split(".");
|
|
541
557
|
if (parts.length < 2) return eventType;
|
|
@@ -1120,11 +1136,7 @@ function createBaseMessageProcessor(deps) {
|
|
|
1120
1136
|
const findHandler = (event) => processedHandlers.find(
|
|
1121
1137
|
(handler) => handler.type === event.eventType && (!handler.match || handler.match(event))
|
|
1122
1138
|
);
|
|
1123
|
-
const handleMissingHandler = async (
|
|
1124
|
-
logger2.warn(`[${name}] no handler for event type: ${eventType}`);
|
|
1125
|
-
if (dlqEnabled) {
|
|
1126
|
-
await quarantineMessage(context, "no_handler", options, new Error(`No handler for event type ${eventType}`));
|
|
1127
|
-
}
|
|
1139
|
+
const handleMissingHandler = async (_context, _eventType) => {
|
|
1128
1140
|
return { handled: true, shouldAck: true };
|
|
1129
1141
|
};
|
|
1130
1142
|
const handleValidationFailure = async (validationResult, handler, context) => {
|
|
@@ -1571,4 +1583,4 @@ async function consumeNatsEvents(options) {
|
|
|
1571
1583
|
return sub;
|
|
1572
1584
|
}
|
|
1573
1585
|
|
|
1574
|
-
export { __resetNatsPublisher, checkAndMarkProcessed, clearHandlerCache, cloudEvents, consumeJetStreamEvents, consumeJetStreamStreams, consumeJetStreams, consumeNatsEvents, createContract, createInMemoryIdempotencyStore, deriveStreamFromType, deriveSubjectFromType, ensureJetStreamStream, ensureJetStreamStreams, ensureJetStreams, eventSchema, extractTypeFromSchema, getDefaultIdempotencyStore, handleEvent, parseEventFromContext, publish, publishEvent, publishNatsEvent, publishNatsRawEvent, publishRawEvent, resetDefaultIdempotencyStore };
|
|
1586
|
+
export { __resetNatsPublisher, checkAndMarkProcessed, clearHandlerCache, cloudEvents, consumeJetStreamEvents, consumeJetStreamStreams, consumeJetStreams, consumeNatsEvents, createContract, createInMemoryIdempotencyStore, deriveStreamFromType, deriveSubjectFromType, ensureJetStreamStream, ensureJetStreamStreams, ensureJetStreams, eventSchema, extractTypeFromSchema, getDefaultIdempotencyStore, handleEvent, parseEventFromContext, pluralize, publish, publishEvent, publishNatsEvent, publishNatsRawEvent, publishRawEvent, resetDefaultIdempotencyStore, singularize };
|