cap-js-community / event-queue

An event queue that enables secure multi-tenant enabled transactional processing of asynchronous events, featuring instant event processing with Redis Pub/Sub and load distribution across all application instances.
https://cap-js-community.github.io/event-queue/
Apache License 2.0
11 stars 1 forks source link

Add types #177

Closed soccermax closed 2 months ago

soccermax commented 2 months ago

fix https://github.com/cap-js-community/event-queue/issues/155

niklasvieth commented 2 months ago

@soccermax I checked other libraries with TypeScript support, they add in the package.json

{
...
   "main": "src/index.js",
   "types": "src/index.d.ts",
...
)

One additional comment regarding EventProcessingStatusType. I think the type should be defined like this if you don't want to use an enum for the EventProcessingStatus.

declare type EventProcessingStatusKeysType  = keyof typeof EventProcessingStatus
export declare type EventProcessingStatusType = typeof EventProcessingStatus[EventProcessingStatusKeysType];

That would look like this image

instead of this with the current type image

Because looking at the return type of processEvent https://github.com/cap-js-community/event-queue/blob/acaad703fa19be611a7758ec4b7991b6a54e5abe/src/index.d.ts#L105 The jsdoc states that the value is the integer 0 not the key Open. https://github.com/cap-js-community/event-queue/blob/acaad703fa19be611a7758ec4b7991b6a54e5abe/src/EventQueueProcessorBase.js#L84-L86

Other than that our current implementation with CAP TypeScript would work with this update, thanks again for taking the time!