@crossdelta/cloudevents 0.7.13 → 0.7.14
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/bin/cli.js +24 -2
- package/dist/index.cjs +50 -41
- package/dist/index.js +50 -40
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -733,6 +733,28 @@ var init_domain = __esm({
|
|
|
733
733
|
}
|
|
734
734
|
});
|
|
735
735
|
|
|
736
|
+
// src/transports/nats/connection.ts
|
|
737
|
+
var LONG_LIVED_DEFAULTS, SHORT_LIVED_DEFAULTS, buildConnectOptions;
|
|
738
|
+
var init_connection = __esm({
|
|
739
|
+
"src/transports/nats/connection.ts"() {
|
|
740
|
+
LONG_LIVED_DEFAULTS = {
|
|
741
|
+
waitOnFirstConnect: true,
|
|
742
|
+
maxReconnectAttempts: -1
|
|
743
|
+
};
|
|
744
|
+
SHORT_LIVED_DEFAULTS = {
|
|
745
|
+
waitOnFirstConnect: true,
|
|
746
|
+
maxReconnectAttempts: 10
|
|
747
|
+
};
|
|
748
|
+
buildConnectOptions = (config, mode) => {
|
|
749
|
+
const defaults = mode === "long-lived" ? LONG_LIVED_DEFAULTS : SHORT_LIVED_DEFAULTS;
|
|
750
|
+
return {
|
|
751
|
+
waitOnFirstConnect: config?.waitOnFirstConnect ?? defaults.waitOnFirstConnect,
|
|
752
|
+
maxReconnectAttempts: config?.maxReconnectAttempts ?? defaults.maxReconnectAttempts
|
|
753
|
+
};
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
|
|
736
758
|
// src/publishing/nats.publisher.ts
|
|
737
759
|
var nats_publisher_exports = {};
|
|
738
760
|
__export(nats_publisher_exports, {
|
|
@@ -753,6 +775,7 @@ var init_nats_publisher = __esm({
|
|
|
753
775
|
"src/publishing/nats.publisher.ts"() {
|
|
754
776
|
init_domain();
|
|
755
777
|
init_infrastructure();
|
|
778
|
+
init_connection();
|
|
756
779
|
init_utils();
|
|
757
780
|
sc = StringCodec();
|
|
758
781
|
natsConnectionPromise = null;
|
|
@@ -772,8 +795,7 @@ var init_nats_publisher = __esm({
|
|
|
772
795
|
const url = servers ?? process.env.NATS_URL ?? "nats://localhost:4222";
|
|
773
796
|
natsConnectionPromise = connect({
|
|
774
797
|
servers: url,
|
|
775
|
-
|
|
776
|
-
maxReconnectAttempts: connectionConfig?.maxReconnectAttempts ?? -1
|
|
798
|
+
...buildConnectOptions(connectionConfig, "long-lived")
|
|
777
799
|
}).then((connection) => {
|
|
778
800
|
logger.debug(`[NATS] connected to ${url}`);
|
|
779
801
|
return connection;
|
package/dist/index.cjs
CHANGED
|
@@ -1367,6 +1367,49 @@ var init_domain = __esm({
|
|
|
1367
1367
|
}
|
|
1368
1368
|
});
|
|
1369
1369
|
|
|
1370
|
+
// src/transports/nats/connection.ts
|
|
1371
|
+
var LONG_LIVED_DEFAULTS, SHORT_LIVED_DEFAULTS, buildConnectOptions, CONNECTION_REGISTRY_KEY, getConnectionRegistry, registerConnection, unregisterConnection; exports.isConsumerConnected = void 0;
|
|
1372
|
+
var init_connection = __esm({
|
|
1373
|
+
"src/transports/nats/connection.ts"() {
|
|
1374
|
+
LONG_LIVED_DEFAULTS = {
|
|
1375
|
+
waitOnFirstConnect: true,
|
|
1376
|
+
maxReconnectAttempts: -1
|
|
1377
|
+
};
|
|
1378
|
+
SHORT_LIVED_DEFAULTS = {
|
|
1379
|
+
waitOnFirstConnect: true,
|
|
1380
|
+
maxReconnectAttempts: 10
|
|
1381
|
+
};
|
|
1382
|
+
buildConnectOptions = (config, mode) => {
|
|
1383
|
+
const defaults = mode === "long-lived" ? LONG_LIVED_DEFAULTS : SHORT_LIVED_DEFAULTS;
|
|
1384
|
+
return {
|
|
1385
|
+
waitOnFirstConnect: config?.waitOnFirstConnect ?? defaults.waitOnFirstConnect,
|
|
1386
|
+
maxReconnectAttempts: config?.maxReconnectAttempts ?? defaults.maxReconnectAttempts
|
|
1387
|
+
};
|
|
1388
|
+
};
|
|
1389
|
+
CONNECTION_REGISTRY_KEY = "__crossdelta_nats_connections__";
|
|
1390
|
+
getConnectionRegistry = () => {
|
|
1391
|
+
if (!globalThis[CONNECTION_REGISTRY_KEY]) {
|
|
1392
|
+
globalThis[CONNECTION_REGISTRY_KEY] = /* @__PURE__ */ new Map();
|
|
1393
|
+
}
|
|
1394
|
+
return globalThis[CONNECTION_REGISTRY_KEY];
|
|
1395
|
+
};
|
|
1396
|
+
registerConnection = (name, connection) => {
|
|
1397
|
+
getConnectionRegistry().set(name, connection);
|
|
1398
|
+
};
|
|
1399
|
+
unregisterConnection = (name) => {
|
|
1400
|
+
getConnectionRegistry().delete(name);
|
|
1401
|
+
};
|
|
1402
|
+
exports.isConsumerConnected = () => {
|
|
1403
|
+
const registry = getConnectionRegistry();
|
|
1404
|
+
if (registry.size === 0) return false;
|
|
1405
|
+
for (const connection of registry.values()) {
|
|
1406
|
+
if (!connection.isClosed() && !connection.isDraining()) return true;
|
|
1407
|
+
}
|
|
1408
|
+
return false;
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
});
|
|
1412
|
+
|
|
1370
1413
|
// src/publishing/nats.publisher.ts
|
|
1371
1414
|
var nats_publisher_exports = {};
|
|
1372
1415
|
__export(nats_publisher_exports, {
|
|
@@ -1387,6 +1430,7 @@ var init_nats_publisher = __esm({
|
|
|
1387
1430
|
"src/publishing/nats.publisher.ts"() {
|
|
1388
1431
|
init_domain();
|
|
1389
1432
|
init_infrastructure();
|
|
1433
|
+
init_connection();
|
|
1390
1434
|
init_utils();
|
|
1391
1435
|
sc = nats.StringCodec();
|
|
1392
1436
|
natsConnectionPromise = null;
|
|
@@ -1406,8 +1450,7 @@ var init_nats_publisher = __esm({
|
|
|
1406
1450
|
const url = servers ?? process.env.NATS_URL ?? "nats://localhost:4222";
|
|
1407
1451
|
natsConnectionPromise = nats.connect({
|
|
1408
1452
|
servers: url,
|
|
1409
|
-
|
|
1410
|
-
maxReconnectAttempts: connectionConfig?.maxReconnectAttempts ?? -1
|
|
1453
|
+
...buildConnectOptions(connectionConfig, "long-lived")
|
|
1411
1454
|
}).then((connection) => {
|
|
1412
1455
|
logger.debug(`[NATS] connected to ${url}`);
|
|
1413
1456
|
return connection;
|
|
@@ -2191,7 +2234,7 @@ function cloudEvents(options = {}) {
|
|
|
2191
2234
|
// package.json
|
|
2192
2235
|
var package_default = {
|
|
2193
2236
|
name: "@crossdelta/cloudevents",
|
|
2194
|
-
version: "0.7.
|
|
2237
|
+
version: "0.7.14",
|
|
2195
2238
|
description: "CloudEvents toolkit for TypeScript - Zod validation, handler discovery, NATS JetStream & Core"};
|
|
2196
2239
|
|
|
2197
2240
|
// src/plugin.ts
|
|
@@ -2424,47 +2467,13 @@ function createBaseMessageProcessor(deps) {
|
|
|
2424
2467
|
};
|
|
2425
2468
|
}
|
|
2426
2469
|
|
|
2427
|
-
// src/transports/nats/
|
|
2428
|
-
|
|
2429
|
-
waitOnFirstConnect: true,
|
|
2430
|
-
maxReconnectAttempts: -1
|
|
2431
|
-
};
|
|
2432
|
-
var SHORT_LIVED_DEFAULTS = {
|
|
2433
|
-
waitOnFirstConnect: true,
|
|
2434
|
-
maxReconnectAttempts: 10
|
|
2435
|
-
};
|
|
2436
|
-
var buildConnectOptions = (config, mode) => {
|
|
2437
|
-
const defaults = mode === "long-lived" ? LONG_LIVED_DEFAULTS : SHORT_LIVED_DEFAULTS;
|
|
2438
|
-
return {
|
|
2439
|
-
waitOnFirstConnect: config?.waitOnFirstConnect ?? defaults.waitOnFirstConnect,
|
|
2440
|
-
maxReconnectAttempts: config?.maxReconnectAttempts ?? defaults.maxReconnectAttempts
|
|
2441
|
-
};
|
|
2442
|
-
};
|
|
2443
|
-
var CONNECTION_REGISTRY_KEY = "__crossdelta_nats_connections__";
|
|
2444
|
-
var getConnectionRegistry = () => {
|
|
2445
|
-
if (!globalThis[CONNECTION_REGISTRY_KEY]) {
|
|
2446
|
-
globalThis[CONNECTION_REGISTRY_KEY] = /* @__PURE__ */ new Map();
|
|
2447
|
-
}
|
|
2448
|
-
return globalThis[CONNECTION_REGISTRY_KEY];
|
|
2449
|
-
};
|
|
2450
|
-
var registerConnection = (name, connection) => {
|
|
2451
|
-
getConnectionRegistry().set(name, connection);
|
|
2452
|
-
};
|
|
2453
|
-
var unregisterConnection = (name) => {
|
|
2454
|
-
getConnectionRegistry().delete(name);
|
|
2455
|
-
};
|
|
2456
|
-
var isConsumerConnected = () => {
|
|
2457
|
-
const registry = getConnectionRegistry();
|
|
2458
|
-
if (registry.size === 0) return false;
|
|
2459
|
-
for (const connection of registry.values()) {
|
|
2460
|
-
if (!connection.isClosed() && !connection.isDraining()) return true;
|
|
2461
|
-
}
|
|
2462
|
-
return false;
|
|
2463
|
-
};
|
|
2470
|
+
// src/transports/nats/index.ts
|
|
2471
|
+
init_connection();
|
|
2464
2472
|
|
|
2465
2473
|
// src/transports/nats/jetstream-consumer.ts
|
|
2466
2474
|
init_domain();
|
|
2467
2475
|
init_logging();
|
|
2476
|
+
init_connection();
|
|
2468
2477
|
|
|
2469
2478
|
// src/transports/nats/jetstream-message-processor.ts
|
|
2470
2479
|
var createJetStreamMessageProcessor = (deps) => {
|
|
@@ -2756,6 +2765,7 @@ var consumeJetStreams = consumeJetStreamStreams;
|
|
|
2756
2765
|
// src/transports/nats/nats-consumer.ts
|
|
2757
2766
|
init_domain();
|
|
2758
2767
|
init_logging();
|
|
2768
|
+
init_connection();
|
|
2759
2769
|
var sc3 = nats.StringCodec();
|
|
2760
2770
|
var isRequestMessage = (msg) => Boolean(msg.reply);
|
|
2761
2771
|
var sendReply = (msg, payload) => {
|
|
@@ -2880,7 +2890,6 @@ exports.ensureJetStreams = ensureJetStreams;
|
|
|
2880
2890
|
exports.eventSchema = eventSchema;
|
|
2881
2891
|
exports.getDefaultIdempotencyStore = getDefaultIdempotencyStore;
|
|
2882
2892
|
exports.handleEvent = handleEvent;
|
|
2883
|
-
exports.isConsumerConnected = isConsumerConnected;
|
|
2884
2893
|
exports.listEvents = listEvents;
|
|
2885
2894
|
exports.parseEventFromContext = parseEventFromContext;
|
|
2886
2895
|
exports.publishEvent = publishEvent;
|
package/dist/index.js
CHANGED
|
@@ -1342,6 +1342,49 @@ var init_domain = __esm({
|
|
|
1342
1342
|
}
|
|
1343
1343
|
});
|
|
1344
1344
|
|
|
1345
|
+
// src/transports/nats/connection.ts
|
|
1346
|
+
var LONG_LIVED_DEFAULTS, SHORT_LIVED_DEFAULTS, buildConnectOptions, CONNECTION_REGISTRY_KEY, getConnectionRegistry, registerConnection, unregisterConnection, isConsumerConnected;
|
|
1347
|
+
var init_connection = __esm({
|
|
1348
|
+
"src/transports/nats/connection.ts"() {
|
|
1349
|
+
LONG_LIVED_DEFAULTS = {
|
|
1350
|
+
waitOnFirstConnect: true,
|
|
1351
|
+
maxReconnectAttempts: -1
|
|
1352
|
+
};
|
|
1353
|
+
SHORT_LIVED_DEFAULTS = {
|
|
1354
|
+
waitOnFirstConnect: true,
|
|
1355
|
+
maxReconnectAttempts: 10
|
|
1356
|
+
};
|
|
1357
|
+
buildConnectOptions = (config, mode) => {
|
|
1358
|
+
const defaults = mode === "long-lived" ? LONG_LIVED_DEFAULTS : SHORT_LIVED_DEFAULTS;
|
|
1359
|
+
return {
|
|
1360
|
+
waitOnFirstConnect: config?.waitOnFirstConnect ?? defaults.waitOnFirstConnect,
|
|
1361
|
+
maxReconnectAttempts: config?.maxReconnectAttempts ?? defaults.maxReconnectAttempts
|
|
1362
|
+
};
|
|
1363
|
+
};
|
|
1364
|
+
CONNECTION_REGISTRY_KEY = "__crossdelta_nats_connections__";
|
|
1365
|
+
getConnectionRegistry = () => {
|
|
1366
|
+
if (!globalThis[CONNECTION_REGISTRY_KEY]) {
|
|
1367
|
+
globalThis[CONNECTION_REGISTRY_KEY] = /* @__PURE__ */ new Map();
|
|
1368
|
+
}
|
|
1369
|
+
return globalThis[CONNECTION_REGISTRY_KEY];
|
|
1370
|
+
};
|
|
1371
|
+
registerConnection = (name, connection) => {
|
|
1372
|
+
getConnectionRegistry().set(name, connection);
|
|
1373
|
+
};
|
|
1374
|
+
unregisterConnection = (name) => {
|
|
1375
|
+
getConnectionRegistry().delete(name);
|
|
1376
|
+
};
|
|
1377
|
+
isConsumerConnected = () => {
|
|
1378
|
+
const registry = getConnectionRegistry();
|
|
1379
|
+
if (registry.size === 0) return false;
|
|
1380
|
+
for (const connection of registry.values()) {
|
|
1381
|
+
if (!connection.isClosed() && !connection.isDraining()) return true;
|
|
1382
|
+
}
|
|
1383
|
+
return false;
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
});
|
|
1387
|
+
|
|
1345
1388
|
// src/publishing/nats.publisher.ts
|
|
1346
1389
|
var nats_publisher_exports = {};
|
|
1347
1390
|
__export(nats_publisher_exports, {
|
|
@@ -1362,6 +1405,7 @@ var init_nats_publisher = __esm({
|
|
|
1362
1405
|
"src/publishing/nats.publisher.ts"() {
|
|
1363
1406
|
init_domain();
|
|
1364
1407
|
init_infrastructure();
|
|
1408
|
+
init_connection();
|
|
1365
1409
|
init_utils();
|
|
1366
1410
|
sc = StringCodec();
|
|
1367
1411
|
natsConnectionPromise = null;
|
|
@@ -1381,8 +1425,7 @@ var init_nats_publisher = __esm({
|
|
|
1381
1425
|
const url = servers ?? process.env.NATS_URL ?? "nats://localhost:4222";
|
|
1382
1426
|
natsConnectionPromise = connect({
|
|
1383
1427
|
servers: url,
|
|
1384
|
-
|
|
1385
|
-
maxReconnectAttempts: connectionConfig?.maxReconnectAttempts ?? -1
|
|
1428
|
+
...buildConnectOptions(connectionConfig, "long-lived")
|
|
1386
1429
|
}).then((connection) => {
|
|
1387
1430
|
logger.debug(`[NATS] connected to ${url}`);
|
|
1388
1431
|
return connection;
|
|
@@ -2166,7 +2209,7 @@ function cloudEvents(options = {}) {
|
|
|
2166
2209
|
// package.json
|
|
2167
2210
|
var package_default = {
|
|
2168
2211
|
name: "@crossdelta/cloudevents",
|
|
2169
|
-
version: "0.7.
|
|
2212
|
+
version: "0.7.14",
|
|
2170
2213
|
description: "CloudEvents toolkit for TypeScript - Zod validation, handler discovery, NATS JetStream & Core"};
|
|
2171
2214
|
|
|
2172
2215
|
// src/plugin.ts
|
|
@@ -2399,47 +2442,13 @@ function createBaseMessageProcessor(deps) {
|
|
|
2399
2442
|
};
|
|
2400
2443
|
}
|
|
2401
2444
|
|
|
2402
|
-
// src/transports/nats/
|
|
2403
|
-
|
|
2404
|
-
waitOnFirstConnect: true,
|
|
2405
|
-
maxReconnectAttempts: -1
|
|
2406
|
-
};
|
|
2407
|
-
var SHORT_LIVED_DEFAULTS = {
|
|
2408
|
-
waitOnFirstConnect: true,
|
|
2409
|
-
maxReconnectAttempts: 10
|
|
2410
|
-
};
|
|
2411
|
-
var buildConnectOptions = (config, mode) => {
|
|
2412
|
-
const defaults = mode === "long-lived" ? LONG_LIVED_DEFAULTS : SHORT_LIVED_DEFAULTS;
|
|
2413
|
-
return {
|
|
2414
|
-
waitOnFirstConnect: config?.waitOnFirstConnect ?? defaults.waitOnFirstConnect,
|
|
2415
|
-
maxReconnectAttempts: config?.maxReconnectAttempts ?? defaults.maxReconnectAttempts
|
|
2416
|
-
};
|
|
2417
|
-
};
|
|
2418
|
-
var CONNECTION_REGISTRY_KEY = "__crossdelta_nats_connections__";
|
|
2419
|
-
var getConnectionRegistry = () => {
|
|
2420
|
-
if (!globalThis[CONNECTION_REGISTRY_KEY]) {
|
|
2421
|
-
globalThis[CONNECTION_REGISTRY_KEY] = /* @__PURE__ */ new Map();
|
|
2422
|
-
}
|
|
2423
|
-
return globalThis[CONNECTION_REGISTRY_KEY];
|
|
2424
|
-
};
|
|
2425
|
-
var registerConnection = (name, connection) => {
|
|
2426
|
-
getConnectionRegistry().set(name, connection);
|
|
2427
|
-
};
|
|
2428
|
-
var unregisterConnection = (name) => {
|
|
2429
|
-
getConnectionRegistry().delete(name);
|
|
2430
|
-
};
|
|
2431
|
-
var isConsumerConnected = () => {
|
|
2432
|
-
const registry = getConnectionRegistry();
|
|
2433
|
-
if (registry.size === 0) return false;
|
|
2434
|
-
for (const connection of registry.values()) {
|
|
2435
|
-
if (!connection.isClosed() && !connection.isDraining()) return true;
|
|
2436
|
-
}
|
|
2437
|
-
return false;
|
|
2438
|
-
};
|
|
2445
|
+
// src/transports/nats/index.ts
|
|
2446
|
+
init_connection();
|
|
2439
2447
|
|
|
2440
2448
|
// src/transports/nats/jetstream-consumer.ts
|
|
2441
2449
|
init_domain();
|
|
2442
2450
|
init_logging();
|
|
2451
|
+
init_connection();
|
|
2443
2452
|
|
|
2444
2453
|
// src/transports/nats/jetstream-message-processor.ts
|
|
2445
2454
|
var createJetStreamMessageProcessor = (deps) => {
|
|
@@ -2731,6 +2740,7 @@ var consumeJetStreams = consumeJetStreamStreams;
|
|
|
2731
2740
|
// src/transports/nats/nats-consumer.ts
|
|
2732
2741
|
init_domain();
|
|
2733
2742
|
init_logging();
|
|
2743
|
+
init_connection();
|
|
2734
2744
|
var sc3 = StringCodec();
|
|
2735
2745
|
var isRequestMessage = (msg) => Boolean(msg.reply);
|
|
2736
2746
|
var sendReply = (msg, payload) => {
|
package/package.json
CHANGED