@zdavison/matador 2.0.7 → 2.0.8

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.
@@ -1,21 +1,17 @@
1
+ import type { Jsonifiable } from 'type-fest';
1
2
  /**
2
3
  * Unique event routing key type alias.
3
4
  */
4
5
  export type EventKey = string;
5
- /**
6
- * JSON-serializable primitive types.
7
- */
8
- export type JsonPrimitive = string | number | boolean | null;
9
- /**
10
- * JSON-serializable value (recursive type for objects and arrays).
11
- */
12
- export type JsonValue = JsonPrimitive | JsonValue[] | {
13
- [key: string]: JsonValue;
14
- };
15
6
  /**
16
7
  * JSON-serializable record type for metadata.
8
+ * Uses type-fest's Jsonifiable which accepts:
9
+ * - Primitives (string, number, boolean, null)
10
+ * - Arrays of Jsonifiable values
11
+ * - Objects with Jsonifiable values
12
+ * - Objects with a toJSON() method
17
13
  */
18
- export type JsonRecord = Record<string, JsonValue>;
14
+ export type JsonRecord = Record<string, Jsonifiable>;
19
15
  /**
20
16
  * Static properties required on Event classes for schema registration.
21
17
  */
@@ -1 +1 @@
1
- {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/types/event.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,aAAa,GACb,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEjC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,uCAAuC;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IA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C,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5C;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CAC5C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,8BAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,CAAE,YAAW,KAAK,CAAC,CAAC,CAAC;IACjE,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAE5C,2DAA2D;IAC3D,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAE1B,8BAA8B;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACtE,CAAC,GACD,KAAK,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,GAClD,CAAC,KACC,IAAI,EAAE,CAAC,KACJ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -3,8 +3,9 @@ export { invalidResult, validResult } from './common.js';
3
3
  export type { Dispatcher } from './dispatcher.js';
4
4
  export type { CreateDummyEnvelopeOptions, CreateEnvelopeOptions, Docket, Envelope, } from './envelope.js';
5
5
  export { createDummyEnvelope, createEnvelope } from './envelope.js';
6
- export type { Event, EventClass, EventData, EventKey, EventOptions, EventStatic, JsonPrimitive, JsonRecord, JsonValue, } from './event.js';
6
+ export type { Event, EventClass, EventData, EventKey, EventOptions, EventStatic, JsonRecord, } from './event.js';
7
7
  export { MatadorEvent } from './event.js';
8
+ export type { Jsonifiable } from 'type-fest';
8
9
  export type { AnySubscriber, BaseSubscriberOptions, CallbackContext, CreateResumableSubscriberInput, CreateStandardSubscriberInput, CreateSubscriberInput, EnvelopeOf, ResumableCallback, ResumableCallbackContext, ResumableSubscriber, ResumableSubscriberOptions, StandardCallback, StandardSubscriber, StandardSubscriberOptions, Subscriber, SubscriberCallback, SubscriberDefinition, SubscriberOptions, SubscriberStub, } from './subscriber.js';
9
10
  export { createSubscriber, createSubscriberStub, isResumableSubscriber, isStandardSubscriber, isSubscriber, isSubscriberStub, } from './subscriber.js';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,eAAe,EACf,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzD,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,YAAY,EACV,0BAA0B,EAC1B,qBAAqB,EACrB,MAAM,EACN,QAAQ,GACT,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpE,YAAY,EACV,KAAK,EACL,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,aAAa,EACb,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,YAAY,EACV,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,8BAA8B,EAC9B,6BAA6B,EAC7B,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,GACjB,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,eAAe,EACf,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzD,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,YAAY,EACV,0BAA0B,EAC1B,qBAAqB,EACrB,MAAM,EACN,QAAQ,GACT,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpE,YAAY,EACV,KAAK,EACL,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,YAAY,EACV,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,8BAA8B,EAC9B,6BAA6B,EAC7B,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,GACjB,MAAM,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zdavison/matador",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "A batteries-included event system.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -34,7 +34,8 @@
34
34
  "send-test-event": "bun ./cli.ts ./examples/config.ts ./examples/event.ts"
35
35
  },
36
36
  "dependencies": {
37
- "amqplib": "^0.10.4"
37
+ "amqplib": "^0.10.4",
38
+ "type-fest": "^5.3.1"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@testcontainers/rabbitmq": "^10.16.0",
@@ -116,22 +116,6 @@ export class SafeHooks {
116
116
  }
117
117
  }
118
118
 
119
- async getQueueConcurrency(queueName: string): Promise<number | undefined> {
120
- if (!this.hooks.getQueueConcurrency) {
121
- return undefined;
122
- }
123
-
124
- try {
125
- return await this.hooks.getQueueConcurrency(queueName);
126
- } catch (error) {
127
- this.logger.warn(
128
- '[Matador] 🟡 Hook getQueueConcurrency threw an error',
129
- error,
130
- );
131
- return undefined;
132
- }
133
- }
134
-
135
119
  async getRetryDelay(
136
120
  envelope: Envelope,
137
121
  attemptNumber: number,
@@ -176,13 +176,6 @@ export interface MatadorHooks {
176
176
  | Record<string, unknown>
177
177
  | Promise<Record<string, unknown>>;
178
178
 
179
- /**
180
- * Dynamic queue concurrency lookup.
181
- */
182
- getQueueConcurrency?(
183
- queueName: string,
184
- ): number | undefined | Promise<number | undefined>;
185
-
186
179
  /**
187
180
  * Dynamic retry delay lookup.
188
181
  */
@@ -1,25 +1,19 @@
1
+ import type { Jsonifiable } from 'type-fest';
2
+
1
3
  /**
2
4
  * Unique event routing key type alias.
3
5
  */
4
6
  export type EventKey = string;
5
7
 
6
- /**
7
- * JSON-serializable primitive types.
8
- */
9
- export type JsonPrimitive = string | number | boolean | null;
10
-
11
- /**
12
- * JSON-serializable value (recursive type for objects and arrays).
13
- */
14
- export type JsonValue =
15
- | JsonPrimitive
16
- | JsonValue[]
17
- | { [key: string]: JsonValue };
18
-
19
8
  /**
20
9
  * JSON-serializable record type for metadata.
10
+ * Uses type-fest's Jsonifiable which accepts:
11
+ * - Primitives (string, number, boolean, null)
12
+ * - Arrays of Jsonifiable values
13
+ * - Objects with Jsonifiable values
14
+ * - Objects with a toJSON() method
21
15
  */
22
- export type JsonRecord = Record<string, JsonValue>;
16
+ export type JsonRecord = Record<string, Jsonifiable>;
23
17
 
24
18
  /**
25
19
  * Static properties required on Event classes for schema registration.
@@ -24,12 +24,13 @@ export type {
24
24
  EventKey,
25
25
  EventOptions,
26
26
  EventStatic,
27
- JsonPrimitive,
28
27
  JsonRecord,
29
- JsonValue,
30
28
  } from './event.js';
31
29
  export { MatadorEvent } from './event.js';
32
30
 
31
+ // Re-export Jsonifiable from type-fest for convenience
32
+ export type { Jsonifiable } from 'type-fest';
33
+
33
34
  export type {
34
35
  AnySubscriber,
35
36
  BaseSubscriberOptions,