@zdavison/matador 2.0.1
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/cli.ts +453 -0
- package/dist/checkpoint/context.d.ts +59 -0
- package/dist/checkpoint/context.d.ts.map +1 -0
- package/dist/checkpoint/context.js +140 -0
- package/dist/checkpoint/context.test.d.ts +2 -0
- package/dist/checkpoint/context.test.d.ts.map +1 -0
- package/dist/checkpoint/context.test.js +424 -0
- package/dist/checkpoint/index.d.ts +7 -0
- package/dist/checkpoint/index.d.ts.map +1 -0
- package/dist/checkpoint/index.js +6 -0
- package/dist/checkpoint/stores/memory.d.ts +29 -0
- package/dist/checkpoint/stores/memory.d.ts.map +1 -0
- package/dist/checkpoint/stores/memory.js +39 -0
- package/dist/checkpoint/stores/noop.d.ts +14 -0
- package/dist/checkpoint/stores/noop.d.ts.map +1 -0
- package/dist/checkpoint/stores/noop.js +18 -0
- package/dist/checkpoint/stores/stores.test.d.ts +2 -0
- package/dist/checkpoint/stores/stores.test.d.ts.map +1 -0
- package/dist/checkpoint/stores/stores.test.js +146 -0
- package/dist/checkpoint/types.d.ts +119 -0
- package/dist/checkpoint/types.d.ts.map +1 -0
- package/dist/checkpoint/types.js +1 -0
- package/dist/codec/codec.d.ts +29 -0
- package/dist/codec/codec.d.ts.map +1 -0
- package/dist/codec/codec.js +15 -0
- package/dist/codec/header-aware-codec.d.ts +36 -0
- package/dist/codec/header-aware-codec.d.ts.map +1 -0
- package/dist/codec/header-aware-codec.js +1 -0
- package/dist/codec/index.d.ts +6 -0
- package/dist/codec/index.d.ts.map +1 -0
- package/dist/codec/index.js +3 -0
- package/dist/codec/json-codec.d.ts +13 -0
- package/dist/codec/json-codec.d.ts.map +1 -0
- package/dist/codec/json-codec.js +64 -0
- package/dist/codec/rabbitmq-codec.d.ts +28 -0
- package/dist/codec/rabbitmq-codec.d.ts.map +1 -0
- package/dist/codec/rabbitmq-codec.js +242 -0
- package/dist/codec/rabbitmq-codec.test.d.ts +2 -0
- package/dist/codec/rabbitmq-codec.test.d.ts.map +1 -0
- package/dist/codec/rabbitmq-codec.test.js +433 -0
- package/dist/core/fanout.d.ts +59 -0
- package/dist/core/fanout.d.ts.map +1 -0
- package/dist/core/fanout.js +121 -0
- package/dist/core/fanout.test.d.ts +2 -0
- package/dist/core/fanout.test.d.ts.map +1 -0
- package/dist/core/fanout.test.js +1055 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +3 -0
- package/dist/core/matador.d.ts +133 -0
- package/dist/core/matador.d.ts.map +1 -0
- package/dist/core/matador.js +222 -0
- package/dist/core/matador.test.d.ts +2 -0
- package/dist/core/matador.test.d.ts.map +1 -0
- package/dist/core/matador.test.js +446 -0
- package/dist/core/shutdown.d.ts +78 -0
- package/dist/core/shutdown.d.ts.map +1 -0
- package/dist/core/shutdown.js +111 -0
- package/dist/core/shutdown.test.d.ts +2 -0
- package/dist/core/shutdown.test.d.ts.map +1 -0
- package/dist/core/shutdown.test.js +524 -0
- package/dist/errors/checkpoint-errors.d.ts +30 -0
- package/dist/errors/checkpoint-errors.d.ts.map +1 -0
- package/dist/errors/checkpoint-errors.js +49 -0
- package/dist/errors/has-description.d.ts +18 -0
- package/dist/errors/has-description.d.ts.map +1 -0
- package/dist/errors/has-description.js +9 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +22 -0
- package/dist/errors/matador-errors.d.ts +183 -0
- package/dist/errors/matador-errors.d.ts.map +1 -0
- package/dist/errors/matador-errors.js +376 -0
- package/dist/errors/retry-errors.d.ts +67 -0
- package/dist/errors/retry-errors.d.ts.map +1 -0
- package/dist/errors/retry-errors.js +108 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/safe-hooks.d.ts +34 -0
- package/dist/hooks/safe-hooks.d.ts.map +1 -0
- package/dist/hooks/safe-hooks.js +135 -0
- package/dist/hooks/types.d.ts +189 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +9 -0
- package/dist/index.cjs +3156 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline/index.d.ts +3 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +1 -0
- package/dist/pipeline/pipeline.d.ts +60 -0
- package/dist/pipeline/pipeline.d.ts.map +1 -0
- package/dist/pipeline/pipeline.js +261 -0
- package/dist/pipeline/pipeline.test.d.ts +2 -0
- package/dist/pipeline/pipeline.test.d.ts.map +1 -0
- package/dist/pipeline/pipeline.test.js +1065 -0
- package/dist/retry/index.d.ts +4 -0
- package/dist/retry/index.d.ts.map +1 -0
- package/dist/retry/index.js +1 -0
- package/dist/retry/policy.d.ts +43 -0
- package/dist/retry/policy.d.ts.map +1 -0
- package/dist/retry/policy.js +1 -0
- package/dist/retry/standard-policy.d.ts +44 -0
- package/dist/retry/standard-policy.d.ts.map +1 -0
- package/dist/retry/standard-policy.js +102 -0
- package/dist/retry/standard-policy.test.d.ts +2 -0
- package/dist/retry/standard-policy.test.d.ts.map +1 -0
- package/dist/retry/standard-policy.test.js +190 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +2 -0
- package/dist/schema/registry.d.ts +63 -0
- package/dist/schema/registry.d.ts.map +1 -0
- package/dist/schema/registry.js +171 -0
- package/dist/schema/registry.test.d.ts +2 -0
- package/dist/schema/registry.test.d.ts.map +1 -0
- package/dist/schema/registry.test.js +278 -0
- package/dist/schema/types.d.ts +158 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +74 -0
- package/dist/schema/types.test.d.ts +2 -0
- package/dist/schema/types.test.d.ts.map +1 -0
- package/dist/schema/types.test.js +243 -0
- package/dist/topology/builder.d.ts +66 -0
- package/dist/topology/builder.d.ts.map +1 -0
- package/dist/topology/builder.js +156 -0
- package/dist/topology/builder.test.d.ts +2 -0
- package/dist/topology/builder.test.d.ts.map +1 -0
- package/dist/topology/builder.test.js +222 -0
- package/dist/topology/index.d.ts +5 -0
- package/dist/topology/index.d.ts.map +1 -0
- package/dist/topology/index.js +2 -0
- package/dist/topology/types.d.ts +76 -0
- package/dist/topology/types.d.ts.map +1 -0
- package/dist/topology/types.js +18 -0
- package/dist/transport/capabilities.d.ts +66 -0
- package/dist/transport/capabilities.d.ts.map +1 -0
- package/dist/transport/capabilities.js +18 -0
- package/dist/transport/connection-manager.d.ts +95 -0
- package/dist/transport/connection-manager.d.ts.map +1 -0
- package/dist/transport/connection-manager.js +144 -0
- package/dist/transport/index.d.ts +11 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +5 -0
- package/dist/transport/local/local-transport.d.ts +62 -0
- package/dist/transport/local/local-transport.d.ts.map +1 -0
- package/dist/transport/local/local-transport.js +241 -0
- package/dist/transport/local/local-transport.test.d.ts +2 -0
- package/dist/transport/local/local-transport.test.d.ts.map +1 -0
- package/dist/transport/local/local-transport.test.js +192 -0
- package/dist/transport/multi/multi-transport.d.ts +94 -0
- package/dist/transport/multi/multi-transport.d.ts.map +1 -0
- package/dist/transport/multi/multi-transport.js +184 -0
- package/dist/transport/multi/multi-transport.test.d.ts +2 -0
- package/dist/transport/multi/multi-transport.test.d.ts.map +1 -0
- package/dist/transport/multi/multi-transport.test.js +236 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.d.ts +73 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.d.ts.map +1 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.js +518 -0
- package/dist/transport/transport.d.ts +152 -0
- package/dist/transport/transport.d.ts.map +1 -0
- package/dist/transport/transport.js +1 -0
- package/dist/types/common.d.ts +41 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +12 -0
- package/dist/types/envelope.d.ts +82 -0
- package/dist/types/envelope.d.ts.map +1 -0
- package/dist/types/envelope.js +36 -0
- package/dist/types/event.d.ts +96 -0
- package/dist/types/event.d.ts.map +1 -0
- package/dist/types/event.js +26 -0
- package/dist/types/event.test.d.ts +2 -0
- package/dist/types/event.test.d.ts.map +1 -0
- package/dist/types/event.test.js +130 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/subscriber.d.ts +207 -0
- package/dist/types/subscriber.d.ts.map +1 -0
- package/dist/types/subscriber.js +99 -0
- package/examples/config.ts +126 -0
- package/examples/event.ts +26 -0
- package/examples/order-event.json +19 -0
- package/package.json +66 -0
- package/src/checkpoint/context.test.ts +510 -0
- package/src/checkpoint/context.ts +213 -0
- package/src/checkpoint/index.ts +30 -0
- package/src/checkpoint/stores/memory.ts +47 -0
- package/src/checkpoint/stores/noop.ts +22 -0
- package/src/checkpoint/stores/stores.test.ts +177 -0
- package/src/checkpoint/types.ts +147 -0
- package/src/codec/codec.ts +42 -0
- package/src/codec/header-aware-codec.ts +41 -0
- package/src/codec/index.ts +11 -0
- package/src/codec/json-codec.ts +69 -0
- package/src/codec/rabbitmq-codec.test.ts +516 -0
- package/src/codec/rabbitmq-codec.ts +336 -0
- package/src/core/fanout.test.ts +1351 -0
- package/src/core/fanout.ts +184 -0
- package/src/core/index.ts +12 -0
- package/src/core/matador.test.ts +575 -0
- package/src/core/matador.ts +344 -0
- package/src/core/shutdown.test.ts +853 -0
- package/src/core/shutdown.ts +165 -0
- package/src/errors/checkpoint-errors.ts +62 -0
- package/src/errors/has-description.ts +25 -0
- package/src/errors/index.ts +57 -0
- package/src/errors/matador-errors.ts +477 -0
- package/src/errors/retry-errors.ts +134 -0
- package/src/hooks/index.ts +15 -0
- package/src/hooks/safe-hooks.ts +223 -0
- package/src/hooks/types.ts +248 -0
- package/src/index.ts +231 -0
- package/src/pipeline/index.ts +2 -0
- package/src/pipeline/pipeline.test.ts +1317 -0
- package/src/pipeline/pipeline.ts +371 -0
- package/src/retry/index.ts +4 -0
- package/src/retry/policy.ts +46 -0
- package/src/retry/standard-policy.test.ts +282 -0
- package/src/retry/standard-policy.ts +156 -0
- package/src/schema/index.ts +16 -0
- package/src/schema/registry.test.ts +339 -0
- package/src/schema/registry.ts +226 -0
- package/src/schema/types.test.ts +281 -0
- package/src/schema/types.ts +217 -0
- package/src/topology/builder.test.ts +275 -0
- package/src/topology/builder.ts +199 -0
- package/src/topology/index.ts +15 -0
- package/src/topology/types.ts +109 -0
- package/src/transport/capabilities.ts +88 -0
- package/src/transport/connection-manager.ts +218 -0
- package/src/transport/index.ts +42 -0
- package/src/transport/local/local-transport.test.ts +262 -0
- package/src/transport/local/local-transport.ts +327 -0
- package/src/transport/multi/multi-transport.test.ts +320 -0
- package/src/transport/multi/multi-transport.ts +294 -0
- package/src/transport/rabbitmq/rabbitmq-transport.ts +753 -0
- package/src/transport/transport.ts +200 -0
- package/src/types/common.ts +53 -0
- package/src/types/envelope.ts +152 -0
- package/src/types/event.test.ts +157 -0
- package/src/types/event.ts +118 -0
- package/src/types/index.ts +52 -0
- package/src/types/subscriber.ts +310 -0
- package/test/e2e/multi-transport.e2e.test.ts +236 -0
- package/test/e2e/rabbitmq-transport.e2e.test.ts +327 -0
- package/test/e2e/transport-compliance.e2e.test.ts +505 -0
- package/test/integration/matador.integration.test.ts +634 -0
- package/tsconfig.json +29 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsup.config.ts +13 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import type { SubscriberContext } from '../checkpoint/index.js';
|
|
2
|
+
import type { Idempotency, Importance } from './common.js';
|
|
3
|
+
import type { Envelope } from './envelope.js';
|
|
4
|
+
import type { MatadorEvent } from './event.js';
|
|
5
|
+
/**
|
|
6
|
+
* Helper type to get the envelope type for a subscriber callback.
|
|
7
|
+
* Extracts the data type from a MatadorEvent and wraps it in an Envelope.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* async callback(envelope: EnvelopeOf<MyEvent>) {
|
|
11
|
+
* console.log(envelope.data.someField); // Type-safe access
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
export type EnvelopeOf<T extends MatadorEvent> = Envelope<T['data']>;
|
|
15
|
+
/**
|
|
16
|
+
* Callback function executed when an event is received (standard subscribers).
|
|
17
|
+
* Receives the full envelope containing id, data, and docket.
|
|
18
|
+
*/
|
|
19
|
+
export type StandardCallback<T = unknown> = (envelope: Envelope<T>) => Promise<void> | void;
|
|
20
|
+
/**
|
|
21
|
+
* Callback function for resumable subscribers.
|
|
22
|
+
* Receives the envelope and a SubscriberContext with io() for checkpointed operations.
|
|
23
|
+
*/
|
|
24
|
+
export type ResumableCallback<T = unknown> = (envelope: Envelope<T>, context: SubscriberContext) => Promise<void> | void;
|
|
25
|
+
/**
|
|
26
|
+
* Callback function executed when an event is received.
|
|
27
|
+
* @deprecated Use StandardCallback or ResumableCallback instead.
|
|
28
|
+
*/
|
|
29
|
+
export type SubscriberCallback<T = unknown> = StandardCallback<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Base configuration options shared by all subscriber types.
|
|
32
|
+
*/
|
|
33
|
+
export interface BaseSubscriberOptions {
|
|
34
|
+
/** Human-readable description of what this subscriber does */
|
|
35
|
+
readonly description: string;
|
|
36
|
+
/** Route this subscriber's events to a specific queue */
|
|
37
|
+
readonly targetQueue?: string | undefined;
|
|
38
|
+
/** Importance level for monitoring and alerting */
|
|
39
|
+
readonly importance?: Importance | undefined;
|
|
40
|
+
/** Feature flag function to conditionally enable/disable the subscriber */
|
|
41
|
+
readonly enabled?: (() => boolean | Promise<boolean>) | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Options for standard (non-resumable) subscribers.
|
|
45
|
+
*/
|
|
46
|
+
export interface StandardSubscriberOptions extends BaseSubscriberOptions {
|
|
47
|
+
/** Idempotency declaration for retry handling (non-resumable) */
|
|
48
|
+
readonly idempotent?: 'yes' | 'no' | 'unknown' | undefined;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Options for resumable subscribers that use io() for checkpointed operations.
|
|
52
|
+
*/
|
|
53
|
+
export interface ResumableSubscriberOptions extends BaseSubscriberOptions {
|
|
54
|
+
/** Must be 'resumable' to enable checkpoint-based idempotency */
|
|
55
|
+
readonly idempotent: 'resumable';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Configuration options for a subscriber.
|
|
59
|
+
* Discriminated union based on idempotent value.
|
|
60
|
+
*/
|
|
61
|
+
export type SubscriberOptions = StandardSubscriberOptions | ResumableSubscriberOptions;
|
|
62
|
+
/**
|
|
63
|
+
* Standard subscriber definition with standard callback.
|
|
64
|
+
*/
|
|
65
|
+
export interface StandardSubscriber<T extends MatadorEvent> extends StandardSubscriberOptions {
|
|
66
|
+
/** Human-readable name for the subscriber */
|
|
67
|
+
readonly name: string;
|
|
68
|
+
/** Callback function to execute when event is received */
|
|
69
|
+
readonly callback: StandardCallback<T['data']>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Resumable subscriber definition with resumable callback.
|
|
73
|
+
*/
|
|
74
|
+
export interface ResumableSubscriber<T extends MatadorEvent> extends ResumableSubscriberOptions {
|
|
75
|
+
/** Human-readable name for the subscriber */
|
|
76
|
+
readonly name: string;
|
|
77
|
+
/** Callback function with SubscriberContext for checkpointed operations */
|
|
78
|
+
readonly callback: ResumableCallback<T['data']>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Full subscriber definition with callback (either standard or resumable).
|
|
82
|
+
*/
|
|
83
|
+
export type Subscriber<T extends MatadorEvent> = StandardSubscriber<T> | ResumableSubscriber<T>;
|
|
84
|
+
/**
|
|
85
|
+
* Subscriber stub for multi-codebase scenarios where subscriber implementation
|
|
86
|
+
* is in a remote service. Declares the subscriber contract without providing
|
|
87
|
+
* the callback.
|
|
88
|
+
*/
|
|
89
|
+
export interface SubscriberStub extends StandardSubscriberOptions {
|
|
90
|
+
/** Human-readable name for the subscriber */
|
|
91
|
+
readonly name: string;
|
|
92
|
+
/** Indicates this is a stub without implementation */
|
|
93
|
+
readonly isStub: true;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Union type for any subscriber definition (full or stub).
|
|
97
|
+
* This is the type-erased version for use in collections and schema.
|
|
98
|
+
* Uses `any` because Subscriber<T> is contravariant in T (callback parameter),
|
|
99
|
+
* making it impossible to assign Subscriber<SpecificEvent> to Subscriber<MatadorEvent<unknown>>.
|
|
100
|
+
*/
|
|
101
|
+
export type AnySubscriber = Subscriber<MatadorEvent<any>> | SubscriberStub;
|
|
102
|
+
/**
|
|
103
|
+
* Type guard to check if a subscriber is a stub.
|
|
104
|
+
*/
|
|
105
|
+
export declare function isSubscriberStub(subscriber: AnySubscriber): subscriber is SubscriberStub;
|
|
106
|
+
/**
|
|
107
|
+
* Type guard to check if a subscriber has a callback implementation.
|
|
108
|
+
*/
|
|
109
|
+
export declare function isSubscriber(subscriber: AnySubscriber): subscriber is Subscriber<MatadorEvent<any>>;
|
|
110
|
+
/**
|
|
111
|
+
* Type guard to check if a subscriber is resumable.
|
|
112
|
+
*/
|
|
113
|
+
export declare function isResumableSubscriber(subscriber: AnySubscriber): subscriber is ResumableSubscriber<MatadorEvent<any>>;
|
|
114
|
+
/**
|
|
115
|
+
* Type guard to check if a subscriber is a standard (non-resumable) subscriber.
|
|
116
|
+
*/
|
|
117
|
+
export declare function isStandardSubscriber(subscriber: AnySubscriber): subscriber is StandardSubscriber<MatadorEvent<any>>;
|
|
118
|
+
/**
|
|
119
|
+
* Input options for createSubscriber with standard callback.
|
|
120
|
+
*/
|
|
121
|
+
export interface CreateStandardSubscriberInput<T extends MatadorEvent> {
|
|
122
|
+
readonly name: string;
|
|
123
|
+
readonly description: string;
|
|
124
|
+
readonly callback: StandardCallback<T['data']>;
|
|
125
|
+
readonly idempotent?: 'yes' | 'no' | 'unknown' | undefined;
|
|
126
|
+
readonly importance?: Importance | undefined;
|
|
127
|
+
readonly targetQueue?: string | undefined;
|
|
128
|
+
readonly enabled?: (() => boolean | Promise<boolean>) | undefined;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Input options for createSubscriber with resumable callback.
|
|
132
|
+
*/
|
|
133
|
+
export interface CreateResumableSubscriberInput<T extends MatadorEvent> {
|
|
134
|
+
readonly name: string;
|
|
135
|
+
readonly description: string;
|
|
136
|
+
readonly callback: ResumableCallback<T['data']>;
|
|
137
|
+
readonly idempotent: 'resumable';
|
|
138
|
+
readonly importance?: Importance | undefined;
|
|
139
|
+
readonly targetQueue?: string | undefined;
|
|
140
|
+
readonly enabled?: (() => boolean | Promise<boolean>) | undefined;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Input options for createSubscriber (discriminated union).
|
|
144
|
+
*/
|
|
145
|
+
export type CreateSubscriberInput<T extends MatadorEvent> = CreateStandardSubscriberInput<T> | CreateResumableSubscriberInput<T>;
|
|
146
|
+
/**
|
|
147
|
+
* Creates a subscriber definition.
|
|
148
|
+
*
|
|
149
|
+
* @example Standard subscriber
|
|
150
|
+
* ```typescript
|
|
151
|
+
* const subscriber = createSubscriber<MyEvent>({
|
|
152
|
+
* name: 'my-subscriber',
|
|
153
|
+
* description: 'Handles MyEvent by logging the data',
|
|
154
|
+
* callback: async (envelope) => {
|
|
155
|
+
* console.log(envelope.data);
|
|
156
|
+
* },
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @example Resumable subscriber with io()
|
|
161
|
+
* ```typescript
|
|
162
|
+
* const subscriber = createSubscriber<MyEvent>({
|
|
163
|
+
* name: 'my-resumable-subscriber',
|
|
164
|
+
* description: 'Processes MyEvent with checkpoint-based idempotency',
|
|
165
|
+
* idempotent: 'resumable',
|
|
166
|
+
* callback: async (envelope, { io }) => {
|
|
167
|
+
* await io('step-1', () => doSomething());
|
|
168
|
+
* },
|
|
169
|
+
* });
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export declare function createSubscriber<T extends MatadorEvent>(input: CreateSubscriberInput<T>): Subscriber<T>;
|
|
173
|
+
/**
|
|
174
|
+
* Input options for createSubscriberStub.
|
|
175
|
+
*/
|
|
176
|
+
export interface CreateSubscriberStubInput {
|
|
177
|
+
readonly name: string;
|
|
178
|
+
readonly description: string;
|
|
179
|
+
readonly idempotent?: 'yes' | 'no' | 'unknown' | undefined;
|
|
180
|
+
readonly importance?: Importance | undefined;
|
|
181
|
+
readonly targetQueue?: string | undefined;
|
|
182
|
+
readonly enabled?: (() => boolean | Promise<boolean>) | undefined;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Creates a subscriber stub for remote implementations.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* const stub = createSubscriberStub({
|
|
190
|
+
* name: 'remote-analytics',
|
|
191
|
+
* description: 'Sends events to remote analytics service',
|
|
192
|
+
* targetQueue: 'analytics-worker',
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
export declare function createSubscriberStub(input: CreateSubscriberStubInput): SubscriberStub;
|
|
197
|
+
/**
|
|
198
|
+
* Definition interface used by the pipeline (excludes event class reference).
|
|
199
|
+
*/
|
|
200
|
+
export interface SubscriberDefinition {
|
|
201
|
+
readonly name: string;
|
|
202
|
+
readonly description: string;
|
|
203
|
+
readonly idempotent: Idempotency;
|
|
204
|
+
readonly importance: Importance;
|
|
205
|
+
readonly targetQueue?: string | undefined;
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=subscriber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriber.d.ts","sourceRoot":"","sources":["../../src/types/subscriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAA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AAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard to check if a subscriber is a stub.
|
|
3
|
+
*/
|
|
4
|
+
export function isSubscriberStub(subscriber) {
|
|
5
|
+
return 'isStub' in subscriber && subscriber.isStub === true;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Type guard to check if a subscriber has a callback implementation.
|
|
9
|
+
*/
|
|
10
|
+
export function isSubscriber(subscriber) {
|
|
11
|
+
return 'callback' in subscriber && typeof subscriber.callback === 'function';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Type guard to check if a subscriber is resumable.
|
|
15
|
+
*/
|
|
16
|
+
export function isResumableSubscriber(subscriber) {
|
|
17
|
+
return isSubscriber(subscriber) && subscriber.idempotent === 'resumable';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Type guard to check if a subscriber is a standard (non-resumable) subscriber.
|
|
21
|
+
*/
|
|
22
|
+
export function isStandardSubscriber(subscriber) {
|
|
23
|
+
return isSubscriber(subscriber) && subscriber.idempotent !== 'resumable';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a subscriber definition.
|
|
27
|
+
*
|
|
28
|
+
* @example Standard subscriber
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const subscriber = createSubscriber<MyEvent>({
|
|
31
|
+
* name: 'my-subscriber',
|
|
32
|
+
* description: 'Handles MyEvent by logging the data',
|
|
33
|
+
* callback: async (envelope) => {
|
|
34
|
+
* console.log(envelope.data);
|
|
35
|
+
* },
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example Resumable subscriber with io()
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const subscriber = createSubscriber<MyEvent>({
|
|
42
|
+
* name: 'my-resumable-subscriber',
|
|
43
|
+
* description: 'Processes MyEvent with checkpoint-based idempotency',
|
|
44
|
+
* idempotent: 'resumable',
|
|
45
|
+
* callback: async (envelope, { io }) => {
|
|
46
|
+
* await io('step-1', () => doSomething());
|
|
47
|
+
* },
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export function createSubscriber(input) {
|
|
52
|
+
const base = {
|
|
53
|
+
name: input.name,
|
|
54
|
+
description: input.description,
|
|
55
|
+
callback: input.callback,
|
|
56
|
+
importance: input.importance ?? 'should-investigate',
|
|
57
|
+
...(input.targetQueue !== undefined && {
|
|
58
|
+
targetQueue: input.targetQueue,
|
|
59
|
+
}),
|
|
60
|
+
...(input.enabled !== undefined && { enabled: input.enabled }),
|
|
61
|
+
};
|
|
62
|
+
if (input.idempotent === 'resumable') {
|
|
63
|
+
return {
|
|
64
|
+
...base,
|
|
65
|
+
idempotent: 'resumable',
|
|
66
|
+
callback: input.callback,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
...base,
|
|
71
|
+
idempotent: input.idempotent ?? 'unknown',
|
|
72
|
+
callback: input.callback,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Creates a subscriber stub for remote implementations.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const stub = createSubscriberStub({
|
|
81
|
+
* name: 'remote-analytics',
|
|
82
|
+
* description: 'Sends events to remote analytics service',
|
|
83
|
+
* targetQueue: 'analytics-worker',
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export function createSubscriberStub(input) {
|
|
88
|
+
return {
|
|
89
|
+
name: input.name,
|
|
90
|
+
description: input.description,
|
|
91
|
+
isStub: true,
|
|
92
|
+
idempotent: input.idempotent ?? 'unknown',
|
|
93
|
+
importance: input.importance ?? 'should-investigate',
|
|
94
|
+
...(input.targetQueue !== undefined && {
|
|
95
|
+
targetQueue: input.targetQueue,
|
|
96
|
+
}),
|
|
97
|
+
...(input.enabled !== undefined && { enabled: input.enabled }),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example Matador configuration for CLI testing
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to structure a config file for the CLI.
|
|
5
|
+
* It exports:
|
|
6
|
+
* - schema: MatadorSchema mapping event keys to event classes and subscribers
|
|
7
|
+
* - topology: Topology configuration
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
MatadorEvent,
|
|
12
|
+
type MatadorSchema,
|
|
13
|
+
type Topology,
|
|
14
|
+
TopologyBuilder,
|
|
15
|
+
createSubscriber,
|
|
16
|
+
} from '../src/index.js';
|
|
17
|
+
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// Events
|
|
20
|
+
// ============================================================================
|
|
21
|
+
|
|
22
|
+
export class UserCreatedEvent extends MatadorEvent {
|
|
23
|
+
static readonly key = 'user.created';
|
|
24
|
+
static readonly description = 'Fired when a new user is created';
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
public data: {
|
|
28
|
+
userId: string;
|
|
29
|
+
email: string;
|
|
30
|
+
name: string;
|
|
31
|
+
},
|
|
32
|
+
) {
|
|
33
|
+
super();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class OrderPlacedEvent extends MatadorEvent {
|
|
38
|
+
static readonly key = 'order.placed';
|
|
39
|
+
static readonly description = 'Fired when a new order is placed';
|
|
40
|
+
|
|
41
|
+
constructor(
|
|
42
|
+
public data: {
|
|
43
|
+
orderId: string;
|
|
44
|
+
userId: string;
|
|
45
|
+
amount: number;
|
|
46
|
+
items: Array<{ productId: string; quantity: number }>;
|
|
47
|
+
},
|
|
48
|
+
) {
|
|
49
|
+
super();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// Subscribers
|
|
55
|
+
// ============================================================================
|
|
56
|
+
|
|
57
|
+
const sendWelcomeEmail = createSubscriber({
|
|
58
|
+
name: 'send-welcome-email',
|
|
59
|
+
description: 'Sends a welcome email to newly registered users',
|
|
60
|
+
callback: async ({ data, docket }) => {
|
|
61
|
+
console.log(` 📧 Sending welcome email to ${data.email}`);
|
|
62
|
+
console.log(` User: ${data.name} (${data.userId})`);
|
|
63
|
+
if (docket.correlationId) {
|
|
64
|
+
console.log(` Correlation ID: ${docket.correlationId}`);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
idempotent: 'yes',
|
|
68
|
+
importance: 'should-investigate',
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const trackUserAnalytics = createSubscriber({
|
|
72
|
+
name: 'track-user-analytics',
|
|
73
|
+
description: 'Tracks user creation in analytics system',
|
|
74
|
+
callback: async ({ data }) => {
|
|
75
|
+
console.log(` 📊 Tracking analytics for new user: ${data.userId}`);
|
|
76
|
+
},
|
|
77
|
+
idempotent: 'yes',
|
|
78
|
+
importance: 'can-ignore',
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const processOrder = createSubscriber({
|
|
82
|
+
name: 'process-order',
|
|
83
|
+
description: 'Processes order for fulfillment',
|
|
84
|
+
callback: async ({ data }) => {
|
|
85
|
+
console.log(` 📦 Processing order ${data.orderId}`);
|
|
86
|
+
console.log(` Amount: $${data.amount.toFixed(2)}`);
|
|
87
|
+
console.log(` Items: ${data.items.length} item(s)`);
|
|
88
|
+
},
|
|
89
|
+
idempotent: 'no',
|
|
90
|
+
importance: 'must-investigate',
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const sendOrderConfirmation = createSubscriber({
|
|
94
|
+
name: 'send-order-confirmation',
|
|
95
|
+
description: 'Sends order confirmation email to customer',
|
|
96
|
+
callback: async ({ data }) => {
|
|
97
|
+
console.log(` 📧 Sending order confirmation for ${data.orderId}`);
|
|
98
|
+
},
|
|
99
|
+
idempotent: 'yes',
|
|
100
|
+
importance: 'should-investigate',
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// ============================================================================
|
|
104
|
+
// Exports
|
|
105
|
+
// ============================================================================
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Matador schema mapping event keys to event classes and their subscribers.
|
|
109
|
+
* Uses the tuple format: [EventClass, Subscribers[]]
|
|
110
|
+
*/
|
|
111
|
+
export const schema: MatadorSchema = {
|
|
112
|
+
[UserCreatedEvent.key]: [
|
|
113
|
+
UserCreatedEvent,
|
|
114
|
+
[sendWelcomeEmail, trackUserAnalytics],
|
|
115
|
+
],
|
|
116
|
+
[OrderPlacedEvent.key]: [
|
|
117
|
+
OrderPlacedEvent,
|
|
118
|
+
[processOrder, sendOrderConfirmation],
|
|
119
|
+
],
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const topology: Topology = TopologyBuilder.create()
|
|
123
|
+
.withNamespace('example')
|
|
124
|
+
.addQueue('events', { concurrency: 5 })
|
|
125
|
+
.withoutDeadLetter()
|
|
126
|
+
.build();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example event file for CLI testing
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to structure an event file for the CLI.
|
|
5
|
+
* It exports:
|
|
6
|
+
* - eventKey: The key of the event to dispatch (must match an event in config)
|
|
7
|
+
* - data: The event payload
|
|
8
|
+
* - before: (optional) Previous state for change events
|
|
9
|
+
* - options: (optional) Dispatch options like correlationId, metadata
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const eventKey = 'user.created';
|
|
13
|
+
|
|
14
|
+
export const data = {
|
|
15
|
+
userId: 'usr_12345',
|
|
16
|
+
email: 'alice@example.com',
|
|
17
|
+
name: 'Alice Smith',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const options = {
|
|
21
|
+
correlationId: 'req_abc123',
|
|
22
|
+
metadata: {
|
|
23
|
+
source: 'cli-test',
|
|
24
|
+
timestamp: new Date().toISOString(),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"eventKey": "order.placed",
|
|
3
|
+
"data": {
|
|
4
|
+
"orderId": "ord_98765",
|
|
5
|
+
"userId": "usr_12345",
|
|
6
|
+
"amount": 149.99,
|
|
7
|
+
"items": [
|
|
8
|
+
{ "productId": "prod_001", "quantity": 2 },
|
|
9
|
+
{ "productId": "prod_002", "quantity": 1 }
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"options": {
|
|
13
|
+
"correlationId": "req_xyz789",
|
|
14
|
+
"metadata": {
|
|
15
|
+
"source": "cli-test",
|
|
16
|
+
"channel": "web"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zdavison/matador",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "A batteries-included event system.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"matador": "./cli.ts"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "rm -rf dist *.tsbuildinfo && tsup && tsc --build && cp dist/index.d.ts dist/index.d.cts",
|
|
26
|
+
"test": "bun test",
|
|
27
|
+
"test:watch": "bun test --watch",
|
|
28
|
+
"test:integration": "bun test --grep integration",
|
|
29
|
+
"lint": "bunx biome check .",
|
|
30
|
+
"lint:fix": "bunx biome check . --fix",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"clean": "rm -rf dist",
|
|
33
|
+
"cli": "bun ./cli.ts",
|
|
34
|
+
"send-test-event": "bun ./cli.ts ./examples/config.ts ./examples/event.ts"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"amqplib": "^0.10.4"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@testcontainers/rabbitmq": "^10.16.0",
|
|
41
|
+
"@types/amqplib": "^0.10.5",
|
|
42
|
+
"testcontainers": "^10.16.0",
|
|
43
|
+
"tsup": "^8.3.5"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"zod": "^3.0.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"zod": {
|
|
50
|
+
"optional": true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=18.0.0"
|
|
55
|
+
},
|
|
56
|
+
"keywords": [
|
|
57
|
+
"events",
|
|
58
|
+
"messaging",
|
|
59
|
+
"queue",
|
|
60
|
+
"rabbitmq",
|
|
61
|
+
"bullmq",
|
|
62
|
+
"kafka",
|
|
63
|
+
"transport"
|
|
64
|
+
],
|
|
65
|
+
"license": "MIT"
|
|
66
|
+
}
|