@crossdelta/cloudevents 0.7.12 → 0.7.13
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 +2 -24
- package/dist/index.cjs +41 -50
- package/dist/index.js +40 -50
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -733,28 +733,6 @@ 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
|
-
|
|
758
736
|
// src/publishing/nats.publisher.ts
|
|
759
737
|
var nats_publisher_exports = {};
|
|
760
738
|
__export(nats_publisher_exports, {
|
|
@@ -775,7 +753,6 @@ var init_nats_publisher = __esm({
|
|
|
775
753
|
"src/publishing/nats.publisher.ts"() {
|
|
776
754
|
init_domain();
|
|
777
755
|
init_infrastructure();
|
|
778
|
-
init_connection();
|
|
779
756
|
init_utils();
|
|
780
757
|
sc = StringCodec();
|
|
781
758
|
natsConnectionPromise = null;
|
|
@@ -795,7 +772,8 @@ var init_nats_publisher = __esm({
|
|
|
795
772
|
const url = servers ?? process.env.NATS_URL ?? "nats://localhost:4222";
|
|
796
773
|
natsConnectionPromise = connect({
|
|
797
774
|
servers: url,
|
|
798
|
-
|
|
775
|
+
waitOnFirstConnect: connectionConfig?.waitOnFirstConnect ?? false,
|
|
776
|
+
maxReconnectAttempts: connectionConfig?.maxReconnectAttempts ?? -1
|
|
799
777
|
}).then((connection) => {
|
|
800
778
|
logger.debug(`[NATS] connected to ${url}`);
|
|
801
779
|
return connection;
|
package/dist/index.cjs
CHANGED
|
@@ -1367,49 +1367,6 @@ 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
|
-
|
|
1413
1370
|
// src/publishing/nats.publisher.ts
|
|
1414
1371
|
var nats_publisher_exports = {};
|
|
1415
1372
|
__export(nats_publisher_exports, {
|
|
@@ -1430,7 +1387,6 @@ var init_nats_publisher = __esm({
|
|
|
1430
1387
|
"src/publishing/nats.publisher.ts"() {
|
|
1431
1388
|
init_domain();
|
|
1432
1389
|
init_infrastructure();
|
|
1433
|
-
init_connection();
|
|
1434
1390
|
init_utils();
|
|
1435
1391
|
sc = nats.StringCodec();
|
|
1436
1392
|
natsConnectionPromise = null;
|
|
@@ -1450,7 +1406,8 @@ var init_nats_publisher = __esm({
|
|
|
1450
1406
|
const url = servers ?? process.env.NATS_URL ?? "nats://localhost:4222";
|
|
1451
1407
|
natsConnectionPromise = nats.connect({
|
|
1452
1408
|
servers: url,
|
|
1453
|
-
|
|
1409
|
+
waitOnFirstConnect: connectionConfig?.waitOnFirstConnect ?? false,
|
|
1410
|
+
maxReconnectAttempts: connectionConfig?.maxReconnectAttempts ?? -1
|
|
1454
1411
|
}).then((connection) => {
|
|
1455
1412
|
logger.debug(`[NATS] connected to ${url}`);
|
|
1456
1413
|
return connection;
|
|
@@ -2234,7 +2191,7 @@ function cloudEvents(options = {}) {
|
|
|
2234
2191
|
// package.json
|
|
2235
2192
|
var package_default = {
|
|
2236
2193
|
name: "@crossdelta/cloudevents",
|
|
2237
|
-
version: "0.7.
|
|
2194
|
+
version: "0.7.13",
|
|
2238
2195
|
description: "CloudEvents toolkit for TypeScript - Zod validation, handler discovery, NATS JetStream & Core"};
|
|
2239
2196
|
|
|
2240
2197
|
// src/plugin.ts
|
|
@@ -2467,13 +2424,47 @@ function createBaseMessageProcessor(deps) {
|
|
|
2467
2424
|
};
|
|
2468
2425
|
}
|
|
2469
2426
|
|
|
2470
|
-
// src/transports/nats/
|
|
2471
|
-
|
|
2427
|
+
// src/transports/nats/connection.ts
|
|
2428
|
+
var LONG_LIVED_DEFAULTS = {
|
|
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
|
+
};
|
|
2472
2464
|
|
|
2473
2465
|
// src/transports/nats/jetstream-consumer.ts
|
|
2474
2466
|
init_domain();
|
|
2475
2467
|
init_logging();
|
|
2476
|
-
init_connection();
|
|
2477
2468
|
|
|
2478
2469
|
// src/transports/nats/jetstream-message-processor.ts
|
|
2479
2470
|
var createJetStreamMessageProcessor = (deps) => {
|
|
@@ -2765,7 +2756,6 @@ var consumeJetStreams = consumeJetStreamStreams;
|
|
|
2765
2756
|
// src/transports/nats/nats-consumer.ts
|
|
2766
2757
|
init_domain();
|
|
2767
2758
|
init_logging();
|
|
2768
|
-
init_connection();
|
|
2769
2759
|
var sc3 = nats.StringCodec();
|
|
2770
2760
|
var isRequestMessage = (msg) => Boolean(msg.reply);
|
|
2771
2761
|
var sendReply = (msg, payload) => {
|
|
@@ -2890,6 +2880,7 @@ exports.ensureJetStreams = ensureJetStreams;
|
|
|
2890
2880
|
exports.eventSchema = eventSchema;
|
|
2891
2881
|
exports.getDefaultIdempotencyStore = getDefaultIdempotencyStore;
|
|
2892
2882
|
exports.handleEvent = handleEvent;
|
|
2883
|
+
exports.isConsumerConnected = isConsumerConnected;
|
|
2893
2884
|
exports.listEvents = listEvents;
|
|
2894
2885
|
exports.parseEventFromContext = parseEventFromContext;
|
|
2895
2886
|
exports.publishEvent = publishEvent;
|
package/dist/index.js
CHANGED
|
@@ -1342,49 +1342,6 @@ 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
|
-
|
|
1388
1345
|
// src/publishing/nats.publisher.ts
|
|
1389
1346
|
var nats_publisher_exports = {};
|
|
1390
1347
|
__export(nats_publisher_exports, {
|
|
@@ -1405,7 +1362,6 @@ var init_nats_publisher = __esm({
|
|
|
1405
1362
|
"src/publishing/nats.publisher.ts"() {
|
|
1406
1363
|
init_domain();
|
|
1407
1364
|
init_infrastructure();
|
|
1408
|
-
init_connection();
|
|
1409
1365
|
init_utils();
|
|
1410
1366
|
sc = StringCodec();
|
|
1411
1367
|
natsConnectionPromise = null;
|
|
@@ -1425,7 +1381,8 @@ var init_nats_publisher = __esm({
|
|
|
1425
1381
|
const url = servers ?? process.env.NATS_URL ?? "nats://localhost:4222";
|
|
1426
1382
|
natsConnectionPromise = connect({
|
|
1427
1383
|
servers: url,
|
|
1428
|
-
|
|
1384
|
+
waitOnFirstConnect: connectionConfig?.waitOnFirstConnect ?? false,
|
|
1385
|
+
maxReconnectAttempts: connectionConfig?.maxReconnectAttempts ?? -1
|
|
1429
1386
|
}).then((connection) => {
|
|
1430
1387
|
logger.debug(`[NATS] connected to ${url}`);
|
|
1431
1388
|
return connection;
|
|
@@ -2209,7 +2166,7 @@ function cloudEvents(options = {}) {
|
|
|
2209
2166
|
// package.json
|
|
2210
2167
|
var package_default = {
|
|
2211
2168
|
name: "@crossdelta/cloudevents",
|
|
2212
|
-
version: "0.7.
|
|
2169
|
+
version: "0.7.13",
|
|
2213
2170
|
description: "CloudEvents toolkit for TypeScript - Zod validation, handler discovery, NATS JetStream & Core"};
|
|
2214
2171
|
|
|
2215
2172
|
// src/plugin.ts
|
|
@@ -2442,13 +2399,47 @@ function createBaseMessageProcessor(deps) {
|
|
|
2442
2399
|
};
|
|
2443
2400
|
}
|
|
2444
2401
|
|
|
2445
|
-
// src/transports/nats/
|
|
2446
|
-
|
|
2402
|
+
// src/transports/nats/connection.ts
|
|
2403
|
+
var LONG_LIVED_DEFAULTS = {
|
|
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
|
+
};
|
|
2447
2439
|
|
|
2448
2440
|
// src/transports/nats/jetstream-consumer.ts
|
|
2449
2441
|
init_domain();
|
|
2450
2442
|
init_logging();
|
|
2451
|
-
init_connection();
|
|
2452
2443
|
|
|
2453
2444
|
// src/transports/nats/jetstream-message-processor.ts
|
|
2454
2445
|
var createJetStreamMessageProcessor = (deps) => {
|
|
@@ -2740,7 +2731,6 @@ var consumeJetStreams = consumeJetStreamStreams;
|
|
|
2740
2731
|
// src/transports/nats/nats-consumer.ts
|
|
2741
2732
|
init_domain();
|
|
2742
2733
|
init_logging();
|
|
2743
|
-
init_connection();
|
|
2744
2734
|
var sc3 = StringCodec();
|
|
2745
2735
|
var isRequestMessage = (msg) => Boolean(msg.reply);
|
|
2746
2736
|
var sendReply = (msg, payload) => {
|
package/package.json
CHANGED