@zdavison/matador 2.0.9 → 2.0.11
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/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/{src/checkpoint/stores/noop.ts → dist/checkpoint/stores/noop.d.ts} +5 -13
- 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/{src/codec/index.ts → dist/codec/index.d.ts} +2 -7
- 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 +1054 -0
- package/{src/core/index.ts → dist/core/index.d.ts} +2 -7
- 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 +228 -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 +102 -0
- package/dist/errors/retry-errors.d.ts.map +1 -0
- package/dist/errors/retry-errors.js +155 -0
- package/dist/errors/retry-errors.test.d.ts +2 -0
- package/dist/errors/retry-errors.test.d.ts.map +1 -0
- package/dist/errors/retry-errors.test.js +136 -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 +32 -0
- package/dist/hooks/safe-hooks.d.ts.map +1 -0
- package/dist/hooks/safe-hooks.js +120 -0
- package/dist/hooks/types.d.ts +172 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +9 -0
- package/dist/index.cjs +3228 -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/{src/pipeline/index.ts → dist/pipeline/index.d.ts} +1 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +1 -0
- package/dist/pipeline/pipeline.d.ts +63 -0
- package/dist/pipeline/pipeline.d.ts.map +1 -0
- package/dist/pipeline/pipeline.js +273 -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 +1112 -0
- package/{src/retry/index.ts → dist/retry/index.d.ts} +1 -1
- 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 +196 -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 +174 -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/{src/schema/types.ts → dist/schema/types.d.ts} +29 -88
- 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 +242 -0
- package/dist/topology/builder.d.ts +80 -0
- package/dist/topology/builder.d.ts.map +1 -0
- package/dist/topology/builder.js +165 -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 +360 -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 +128 -0
- package/dist/topology/types.d.ts.map +1 -0
- package/dist/topology/types.js +28 -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 +83 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.d.ts.map +1 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.js +541 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.test.d.ts +2 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.test.d.ts.map +1 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.test.js +100 -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/{src/types/common.ts → dist/types/common.d.ts} +8 -20
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +12 -0
- package/dist/types/dispatcher.d.ts +14 -0
- package/dist/types/dispatcher.d.ts.map +1 -0
- package/dist/types/dispatcher.js +1 -0
- package/dist/types/envelope.d.ts +131 -0
- package/dist/types/envelope.d.ts.map +1 -0
- package/dist/types/envelope.js +99 -0
- package/dist/types/event.d.ts +92 -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 +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/subscriber.d.ts +227 -0
- package/dist/types/subscriber.d.ts.map +1 -0
- package/dist/types/subscriber.js +97 -0
- 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/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/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/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 -242
- package/src/pipeline/pipeline.test.ts +0 -1377
- package/src/pipeline/pipeline.ts +0 -393
- 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/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/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/tsup.config.ts +0 -13
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, mock } from 'bun:test';
|
|
2
|
-
import type { Logger } from '../../hooks/index.js';
|
|
3
|
-
import { RabbitMQTransport, redactAmqpUrl } from './rabbitmq-transport.js';
|
|
4
|
-
|
|
5
|
-
describe('redactAmqpUrl', () => {
|
|
6
|
-
it('should redact username and password with 4 asterisks', () => {
|
|
7
|
-
const url = 'amqp://myuser:mypassword@localhost:5672';
|
|
8
|
-
const redacted = redactAmqpUrl(url);
|
|
9
|
-
expect(redacted).toBe('amqp://****:****@localhost:5672');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('should redact credentials in amqps URLs', () => {
|
|
13
|
-
const url = 'amqps://admin:secret123@rabbitmq.example.com:5671';
|
|
14
|
-
const redacted = redactAmqpUrl(url);
|
|
15
|
-
expect(redacted).toBe('amqps://****:****@rabbitmq.example.com:5671');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should redact long credentials to exactly 4 asterisks', () => {
|
|
19
|
-
const url =
|
|
20
|
-
'amqp://verylongusername:verylongpassword@rabbitmq-cluster.svc.local:5672';
|
|
21
|
-
const redacted = redactAmqpUrl(url);
|
|
22
|
-
expect(redacted).toBe('amqp://****:****@rabbitmq-cluster.svc.local:5672');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should redact short credentials to exactly 4 asterisks', () => {
|
|
26
|
-
const url = 'amqp://a:b@host:5672';
|
|
27
|
-
const redacted = redactAmqpUrl(url);
|
|
28
|
-
expect(redacted).toBe('amqp://****:****@host:5672');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should preserve vhost in URL', () => {
|
|
32
|
-
const url = 'amqp://user:pass@host:5672/myvhost';
|
|
33
|
-
const redacted = redactAmqpUrl(url);
|
|
34
|
-
expect(redacted).toBe('amqp://****:****@host:5672/myvhost');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should not modify URL without credentials', () => {
|
|
38
|
-
const url = 'amqp://localhost:5672';
|
|
39
|
-
const redacted = redactAmqpUrl(url);
|
|
40
|
-
expect(redacted).toBe('amqp://localhost:5672');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should not modify URL with only username (no password)', () => {
|
|
44
|
-
const url = 'amqp://guest@localhost:5672';
|
|
45
|
-
const redacted = redactAmqpUrl(url);
|
|
46
|
-
expect(redacted).toBe('amqp://guest@localhost:5672');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should handle URL-encoded credentials', () => {
|
|
50
|
-
// URL-encoded @ in password: p%40ssword
|
|
51
|
-
const url = 'amqp://user:p%40ssword@host:5672';
|
|
52
|
-
const redacted = redactAmqpUrl(url);
|
|
53
|
-
expect(redacted).toBe('amqp://****:****@host:5672');
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe('RabbitMQTransport', () => {
|
|
58
|
-
describe('connection logging', () => {
|
|
59
|
-
it('should log redacted connection URL when connecting', async () => {
|
|
60
|
-
const mockLogger: Logger = {
|
|
61
|
-
debug: mock(() => {}),
|
|
62
|
-
info: mock(() => {}),
|
|
63
|
-
warn: mock(() => {}),
|
|
64
|
-
error: mock(() => {}),
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const transport = new RabbitMQTransport({
|
|
68
|
-
url: 'amqp://testuser:testpass@localhost:5672',
|
|
69
|
-
connectionName: 'test-connection',
|
|
70
|
-
logger: mockLogger,
|
|
71
|
-
connection: {
|
|
72
|
-
maxReconnectAttempts: 1, // Only try once to avoid long retries
|
|
73
|
-
initialReconnectDelay: 10,
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Attempt to connect - it will fail since there's no RabbitMQ server
|
|
78
|
-
// but the log should still be emitted before the connection attempt
|
|
79
|
-
try {
|
|
80
|
-
await transport.connect();
|
|
81
|
-
} catch {
|
|
82
|
-
// Expected to fail - no RabbitMQ server running
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Verify the log was called with the redacted URL
|
|
86
|
-
expect(mockLogger.info).toHaveBeenCalledWith(
|
|
87
|
-
"[Matador] \u23F3 Connecting to RabbitMQ at 'amqp://****:****@localhost:5672'.",
|
|
88
|
-
);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('should log connection URL as-is when no credentials provided', async () => {
|
|
92
|
-
const mockLogger: Logger = {
|
|
93
|
-
debug: mock(() => {}),
|
|
94
|
-
info: mock(() => {}),
|
|
95
|
-
warn: mock(() => {}),
|
|
96
|
-
error: mock(() => {}),
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const transport = new RabbitMQTransport({
|
|
100
|
-
url: 'amqp://localhost:5672',
|
|
101
|
-
connectionName: 'test-connection',
|
|
102
|
-
logger: mockLogger,
|
|
103
|
-
connection: {
|
|
104
|
-
maxReconnectAttempts: 1,
|
|
105
|
-
initialReconnectDelay: 10,
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
try {
|
|
110
|
-
await transport.connect();
|
|
111
|
-
} catch {
|
|
112
|
-
// Expected to fail
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
expect(mockLogger.info).toHaveBeenCalledWith(
|
|
116
|
-
"[Matador] \u23F3 Connecting to RabbitMQ at 'amqp://localhost:5672'.",
|
|
117
|
-
);
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|