diff --git a/package-lock.json b/package-lock.json index 2df603e85..335a509fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3238,6 +3238,65 @@ "node": ">=18" } }, + "node_modules/@nats-io/jetstream": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@nats-io/jetstream/-/jetstream-3.0.2.tgz", + "integrity": "sha512-dR789x1xhMyEukXILPWDo6ODW53nHpBD9LnsnnywA+pTkwYFydEkYdyhv9HzFc6s6Nfrb2TpibrT4znijlg2dg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@nats-io/nats-core": "3.0.2" + } + }, + "node_modules/@nats-io/nats-core": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@nats-io/nats-core/-/nats-core-3.0.2.tgz", + "integrity": "sha512-gACbRIhY3yQTO+5C4E1LY/qO2e5EhGUBeDsnPDT8Hd3qY9mfhNtluY6R7d7WX7/JMGsXRPbYdSLSADr/ECSy3w==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@nats-io/nkeys": "2.0.3", + "@nats-io/nuid": "2.0.3" + } + }, + "node_modules/@nats-io/nkeys": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@nats-io/nkeys/-/nkeys-2.0.3.tgz", + "integrity": "sha512-JVt56GuE6Z89KUkI4TXUbSI9fmIfAmk6PMPknijmuL72GcD+UgIomTcRWiNvvJKxA01sBbmIPStqJs5cMRBC3A==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tweetnacl": "^1.0.3" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@nats-io/nuid": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@nats-io/nuid/-/nuid-2.0.3.tgz", + "integrity": "sha512-TpA3HEBna/qMVudy+3HZr5M3mo/L1JPofpVT4t0HkFGkz2Cn9wrlrQC8tvR8Md5Oa9//GtGG26eN0qEWF5Vqew==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">= 18.x" + } + }, + "node_modules/@nats-io/transport-node": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@nats-io/transport-node/-/transport-node-3.0.2.tgz", + "integrity": "sha512-hPuep/ObVepjAM1dFy+XhqMlIzga3bQpbgQiOWM5AxwNZ9CF7GHAtfaxG7WY6+t057tBW8axC0nBL71Q8chQBQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@nats-io/nats-core": "3.0.2", + "@nats-io/nkeys": "2.0.3", + "@nats-io/nuid": "2.0.3" + }, + "engines": { + "node": ">= 18.0.0" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -14108,18 +14167,6 @@ "integrity": "sha512-E7QQoM+3jvNtlmyfqRZ0/U75VFgCls+fSkbml2MpgWkWyz3ox8Y58gNhfuziuQYGNNQAbFZJQck55LHCnCK6CA==", "dev": true }, - "node_modules/nats": { - "version": "2.28.0", - "resolved": "https://registry.npmjs.org/nats/-/nats-2.28.0.tgz", - "integrity": "sha512-zXWOTOZEizUQy8UO2lMYFAee0htGrZLmJ2sddfmsDI00nc+dsK5+gS7p7bt26O1omfdCLVU5xymlnAjaqYnOmw==", - "dev": true, - "dependencies": { - "nkeys.js": "1.1.0" - }, - "engines": { - "node": ">= 14.0.0" - } - }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -14199,18 +14246,6 @@ "dev": true, "license": "ISC" }, - "node_modules/nkeys.js": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/nkeys.js/-/nkeys.js-1.1.0.tgz", - "integrity": "sha512-tB/a0shZL5UZWSwsoeyqfTszONTt4k2YS0tuQioMOD180+MbombYVgzDUYHlx+gejYK6rgf08n/2Df99WY0Sxg==", - "dev": true, - "dependencies": { - "tweetnacl": "1.0.3" - }, - "engines": { - "node": ">=10.0.0" - } - }, "node_modules/node-abort-controller": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.1.1.tgz", @@ -18417,7 +18452,8 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==", - "dev": true + "dev": true, + "license": "Unlicense" }, "node_modules/type": { "version": "2.7.3", @@ -20165,7 +20201,8 @@ "testcontainers": "^10.27.0" }, "devDependencies": { - "nats": "^2.28.0" + "@nats-io/jetstream": "^3.0.2", + "@nats-io/transport-node": "^3.0.2" } }, "packages/modules/neo4j": { diff --git a/packages/modules/nats/package.json b/packages/modules/nats/package.json index 0c8dc0698..842923221 100644 --- a/packages/modules/nats/package.json +++ b/packages/modules/nats/package.json @@ -28,10 +28,11 @@ "prepack": "shx cp ../../../README.md . && shx cp ../../../LICENSE .", "build": "tsc --project tsconfig.build.json" }, - "devDependencies": { - "nats": "^2.28.0" - }, "dependencies": { "testcontainers": "^10.27.0" + }, + "devDependencies": { + "@nats-io/jetstream": "^3.0.2", + "@nats-io/transport-node": "^3.0.2" } } diff --git a/packages/modules/nats/src/nats-container.test.ts b/packages/modules/nats/src/nats-container.test.ts index a438c0acd..cdbb34261 100644 --- a/packages/modules/nats/src/nats-container.test.ts +++ b/packages/modules/nats/src/nats-container.test.ts @@ -1,4 +1,5 @@ -import { connect, StringCodec } from "nats"; +import { jetstreamManager } from "@nats-io/jetstream"; +import { connect } from "@nats-io/transport-node"; import { NatsContainer } from "./nats-container"; describe("NatsContainer", { timeout: 180_000 }, () => { @@ -25,19 +26,18 @@ describe("NatsContainer", { timeout: 180_000 }, () => { const container = await new NatsContainer().start(); const nc = await connect(container.getConnectionOptions()); - const sc = StringCodec(); //---------------- const sub = nc.subscribe(SUBJECT); (async () => { for await (const m of sub) { - const actual: string = sc.decode(m.data); + const actual: string = m.string(); expect(actual).toEqual(PAYLOAD); } })().then(); //---------------- - nc.publish(SUBJECT, sc.encode(PAYLOAD)); + nc.publish(SUBJECT, PAYLOAD); //---------------- await nc.drain(); @@ -73,7 +73,7 @@ describe("NatsContainer", { timeout: 180_000 }, () => { const nc = await connect(container.getConnectionOptions()); // ensure JetStream is enabled, otherwise this will throw an error - await nc.jetstream().jetstreamManager(); + await jetstreamManager(nc); // close the connection await nc.close(); @@ -90,7 +90,7 @@ describe("NatsContainer", { timeout: 180_000 }, () => { const nc = await connect(container.getConnectionOptions()); // ensure JetStream is not enabled, as this will throw an error - await expect(nc.jetstream().jetstreamManager()).rejects.toThrow("503"); + await expect(jetstreamManager(nc)).rejects.toThrow("jetstream is not enabled"); // close the connection await nc.close();