@crossdelta/cloudevents 0.6.1 → 0.6.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/dist/index.cjs +20 -2
- package/dist/index.d.mts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +19 -3
- 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;
|
|
@@ -1594,9 +1610,11 @@ exports.extractTypeFromSchema = extractTypeFromSchema;
|
|
|
1594
1610
|
exports.getDefaultIdempotencyStore = getDefaultIdempotencyStore;
|
|
1595
1611
|
exports.handleEvent = handleEvent;
|
|
1596
1612
|
exports.parseEventFromContext = parseEventFromContext;
|
|
1613
|
+
exports.pluralize = pluralize;
|
|
1597
1614
|
exports.publish = publish;
|
|
1598
1615
|
exports.publishEvent = publishEvent;
|
|
1599
1616
|
exports.publishNatsEvent = publishNatsEvent;
|
|
1600
1617
|
exports.publishNatsRawEvent = publishNatsRawEvent;
|
|
1601
1618
|
exports.publishRawEvent = publishRawEvent;
|
|
1602
1619
|
exports.resetDefaultIdempotencyStore = resetDefaultIdempotencyStore;
|
|
1620
|
+
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;
|
|
@@ -1571,4 +1587,4 @@ async function consumeNatsEvents(options) {
|
|
|
1571
1587
|
return sub;
|
|
1572
1588
|
}
|
|
1573
1589
|
|
|
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 };
|
|
1590
|
+
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 };
|