@zdavison/matador 2.0.8 → 2.0.10
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.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +6 -2
- package/examples/config.ts +0 -126
- package/examples/event.ts +0 -26
- package/examples/order-event.json +0 -19
- package/src/checkpoint/context.test.ts +0 -510
- package/src/checkpoint/context.ts +0 -213
- package/src/checkpoint/index.ts +0 -30
- package/src/checkpoint/stores/memory.ts +0 -47
- package/src/checkpoint/stores/noop.ts +0 -22
- package/src/checkpoint/stores/stores.test.ts +0 -177
- package/src/checkpoint/types.ts +0 -147
- package/src/codec/codec.ts +0 -42
- package/src/codec/header-aware-codec.ts +0 -41
- package/src/codec/index.ts +0 -11
- package/src/codec/json-codec.ts +0 -69
- package/src/codec/rabbitmq-codec.test.ts +0 -516
- package/src/codec/rabbitmq-codec.ts +0 -336
- package/src/core/fanout.test.ts +0 -1350
- package/src/core/fanout.ts +0 -184
- package/src/core/index.ts +0 -12
- package/src/core/matador.test.ts +0 -575
- package/src/core/matador.ts +0 -357
- package/src/core/shutdown.test.ts +0 -853
- package/src/core/shutdown.ts +0 -165
- package/src/errors/checkpoint-errors.ts +0 -62
- package/src/errors/has-description.ts +0 -25
- package/src/errors/index.ts +0 -58
- package/src/errors/matador-errors.ts +0 -477
- package/src/errors/retry-errors.test.ts +0 -175
- package/src/errors/retry-errors.ts +0 -188
- package/src/hooks/index.ts +0 -14
- package/src/hooks/safe-hooks.ts +0 -200
- package/src/hooks/types.ts +0 -226
- package/src/index.ts +0 -241
- package/src/pipeline/index.ts +0 -2
- package/src/pipeline/pipeline.test.ts +0 -1377
- package/src/pipeline/pipeline.ts +0 -393
- package/src/retry/index.ts +0 -4
- package/src/retry/policy.ts +0 -46
- package/src/retry/standard-policy.test.ts +0 -290
- package/src/retry/standard-policy.ts +0 -156
- package/src/schema/index.ts +0 -16
- package/src/schema/registry.test.ts +0 -339
- package/src/schema/registry.ts +0 -229
- package/src/schema/types.test.ts +0 -280
- package/src/schema/types.ts +0 -217
- package/src/topology/builder.test.ts +0 -451
- package/src/topology/builder.ts +0 -238
- package/src/topology/index.ts +0 -19
- package/src/topology/types.ts +0 -183
- package/src/transport/capabilities.ts +0 -88
- package/src/transport/connection-manager.ts +0 -218
- package/src/transport/index.ts +0 -42
- package/src/transport/local/local-transport.test.ts +0 -262
- package/src/transport/local/local-transport.ts +0 -330
- package/src/transport/multi/multi-transport.test.ts +0 -320
- package/src/transport/multi/multi-transport.ts +0 -294
- package/src/transport/rabbitmq/rabbitmq-transport.test.ts +0 -120
- package/src/transport/rabbitmq/rabbitmq-transport.ts +0 -782
- package/src/transport/transport.ts +0 -200
- package/src/types/common.ts +0 -53
- package/src/types/dispatcher.ts +0 -18
- package/src/types/envelope.ts +0 -244
- package/src/types/event.test.ts +0 -157
- package/src/types/event.ts +0 -112
- package/src/types/index.ts +0 -62
- package/src/types/subscriber.ts +0 -333
- package/test/e2e/multi-transport.e2e.test.ts +0 -237
- package/test/e2e/rabbitmq-transport.e2e.test.ts +0 -618
- package/test/e2e/transport-compliance.e2e.test.ts +0 -506
- package/test/integration/matador.integration.test.ts +0 -634
- package/tsconfig.json +0 -29
- package/tsconfig.tsbuildinfo +0 -1
- package/tsup.config.ts +0 -13
package/dist/index.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ export type { DeadLetterConfig, DeadLetterQueueConfig, QueueDefinition, QueueOpt
|
|
|
8
8
|
export { getDeadLetterQueueName, getQualifiedQueueName, getRetryQueueName, resolveQueueName, TopologyBuilder, TopologyValidationError, } from './topology/index.js';
|
|
9
9
|
export type { Codec, EncodedMessage, HeaderAwareCodec, } from './codec/index.js';
|
|
10
10
|
export { CodecDecodeError, JsonCodec, RabbitMQCodec } from './codec/index.js';
|
|
11
|
-
export type { MatadorSchema, RegisterOptions, SchemaEntry, SchemaEntryTuple, SchemaIssue, SchemaPlugin, SchemaValidationResult, } from './schema/index.js';
|
|
11
|
+
export type { MatadorSchema, RegisterOptions, RuntimeSchemaEntryTuple, SchemaEntry, SchemaEntryTuple, SchemaIssue, SchemaPlugin, SchemaValidationResult, } from './schema/index.js';
|
|
12
12
|
export { bind, installPlugins, isSchemaEntryTuple, SchemaError, SchemaRegistry, } from './schema/index.js';
|
|
13
13
|
export type { RetryContext, RetryDecision, RetryPolicy, StandardRetryPolicyConfig, } from './retry/index.js';
|
|
14
14
|
export { defaultRetryConfig, StandardRetryPolicy, } from './retry/index.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type { DeadLetterConfig, DeadLetterQueueConfig, QueueDefinition, QueueOpt
|
|
|
8
8
|
export { getDeadLetterQueueName, getQualifiedQueueName, getRetryQueueName, resolveQueueName, TopologyBuilder, TopologyValidationError, } from './topology/index.js';
|
|
9
9
|
export type { Codec, EncodedMessage, HeaderAwareCodec, } from './codec/index.js';
|
|
10
10
|
export { CodecDecodeError, JsonCodec, RabbitMQCodec } from './codec/index.js';
|
|
11
|
-
export type { MatadorSchema, RegisterOptions, SchemaEntry, SchemaEntryTuple, SchemaIssue, SchemaPlugin, SchemaValidationResult, } from './schema/index.js';
|
|
11
|
+
export type { MatadorSchema, RegisterOptions, RuntimeSchemaEntryTuple, SchemaEntry, SchemaEntryTuple, SchemaIssue, SchemaPlugin, SchemaValidationResult, } from './schema/index.js';
|
|
12
12
|
export { bind, installPlugins, isSchemaEntryTuple, SchemaError, SchemaRegistry, } from './schema/index.js';
|
|
13
13
|
export type { RetryContext, RetryDecision, RetryPolicy, StandardRetryPolicyConfig, } from './retry/index.js';
|
|
14
14
|
export { defaultRetryConfig, StandardRetryPolicy, } from './retry/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,YAAY,EACZ,aAAa,EACb,aA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e,EACf,iBAAiB,EACjB,uBAAuB,EAEvB,0BAA0B,EAC1B,4BAA4B,EAC5B,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,gCAAgC,EAEhC,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,8BAA8B,EAC9B,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,oCAAoC,EAEpC,kBAAkB,EAElB,iBAAiB,EAEjB,yBAAyB,EACzB,2BAA2B,EAC3B,iCAAiC,EACjC,mCAAmC,EAEnC,YAAY,EAEZ,cAAc,GACf,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EACV,UAAU,EACV,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EACb,SAAS,EACT,UAAU,EACV,cAAc,EACd,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,OAAO,EACP,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,UAAU,EACV,KAAK,EACL,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,wBAAwB,EACxB,gBAAgB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EACV,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zdavison/matador",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"description": "A batteries-included event system.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -63,5 +63,9 @@
|
|
|
63
63
|
"kafka",
|
|
64
64
|
"transport"
|
|
65
65
|
],
|
|
66
|
-
"license": "MIT"
|
|
66
|
+
"license": "MIT",
|
|
67
|
+
"files": [
|
|
68
|
+
"dist",
|
|
69
|
+
"cli.ts"
|
|
70
|
+
]
|
|
67
71
|
}
|
package/examples/config.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
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();
|
package/examples/event.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|