diff --git a/README.md b/README.md index cbf96dc8..2621979d 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ If the chosen transport is Google Cloud PubSub, then `options` would be: - `sub`: Options applied to the subscription instance (see also [`setOptions` method](https://googleapis.dev/nodejs/pubsub/latest/Subscription.html#setOptions)) - `create`: Options applied to the `createSubscription` method (have a look at [Create Subscription options](https://googleapis.dev/nodejs/pubsub/latest/Topic.html#createSubscription)) - `topicOptions`: Options applied to the created topic (have a look at [Topic options](https://googleapis.dev/nodejs/pubsub/latest/Topic.html#get)) +- `topicName`: Set the topic name. By default, it uses the default name with a prefix. ### `pubsub.emit(event, payload, opts)` diff --git a/package-lock.json b/package-lock.json index 489885f5..956c1f19 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,33 +9,33 @@ "version": "5.1.0", "license": "ISC", "dependencies": { - "@google-cloud/pubsub": "^3.6.0", + "@google-cloud/pubsub": "^3.7.1", "pino": "^8.14.1" }, "devDependencies": { "@algoan/eslint-config": "^1.1.7", "@amanda-mitchell/semantic-release-npm-multiple": "^3.8.0", "@ava/typescript": "^4.0.0", - "@commitlint/cli": "^17.6.3", - "@commitlint/config-conventional": "^17.6.3", + "@commitlint/cli": "^17.6.5", + "@commitlint/config-conventional": "^17.6.5", "@semantic-release/git": "^10.0.1", "@types/sinon": "^10.0.15", - "@types/uuid": "^9.0.1", + "@types/uuid": "^9.0.2", "@yelloan/tslint": "0.3.0", "ava": "^5.3.0", "commitizen": "^4.3.0", "cz-conventional-changelog": "^3.3.0", - "eslint": "^8.41.0", - "google-pubsub-emulator": "^6.0.0", + "eslint": "^8.42.0", + "google-pubsub-emulator": "^7.0.0", "husky": "^8.0.3", "lint-staged": "^13.2.2", "nyc": "^15.1.0", "prettier": "^2.8.8", "rimraf": "^5.0.1", "semantic-release": "^19.0.5", - "sinon": "^15.1.0", + "sinon": "^15.1.2", "tslint": "^6.1.3", - "typescript": "^5.0.4", + "typescript": "^5.1.3", "uuid": "^9.0.0" }, "engines": { @@ -478,13 +478,13 @@ } }, "node_modules/@commitlint/cli": { - "version": "17.6.3", - "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-17.6.3.tgz", - "integrity": "sha512-ItSz2fd4F+CujgIbQOfNNerDF1eFlsBGEfp9QcCb1kxTYMuKTYZzA6Nu1YRRrIaaWwe2E7awUGpIMrPoZkOG3A==", + "version": "17.6.5", + "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-17.6.5.tgz", + "integrity": "sha512-3PQrWr/uo6lzF5k7n5QuosCYnzaxP9qGBp3jhWP0Vmsa7XA6wrl9ccPqfQyXpSbQE3zBROVO3TDqgPKe4tfmLQ==", "dev": true, "dependencies": { "@commitlint/format": "^17.4.4", - "@commitlint/lint": "^17.6.3", + "@commitlint/lint": "^17.6.5", "@commitlint/load": "^17.5.0", "@commitlint/read": "^17.5.1", "@commitlint/types": "^17.4.4", @@ -590,9 +590,9 @@ } }, "node_modules/@commitlint/config-conventional": { - "version": "17.6.3", - "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-17.6.3.tgz", - "integrity": "sha512-bLyHEjjRWqlLQWIgYFHmUPbEFMOOLXeF3QbUinDIJev/u9e769tkoTH9YPknEywiuIrAgZaVo+OfzAIsJP0fsw==", + "version": "17.6.5", + "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-17.6.5.tgz", + "integrity": "sha512-Xl9H9KLl86NZm5CYNTNF9dcz1xelE/EbvhWIWcYxG/rn3UWYWdWmmnX2q6ZduNdLFSGbOxzUpIx61j5zxbeXxg==", "dev": true, "dependencies": { "conventional-changelog-conventionalcommits": "^5.0.0" @@ -724,9 +724,9 @@ } }, "node_modules/@commitlint/is-ignored": { - "version": "17.6.3", - "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-17.6.3.tgz", - "integrity": "sha512-LQbNdnPbxrpbcrVKR5yf51SvquqktpyZJwqXx3lUMF6+nT9PHB8xn3wLy8pi2EQv5Zwba484JnUwDE1ygVYNQA==", + "version": "17.6.5", + "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-17.6.5.tgz", + "integrity": "sha512-CQvAPt9gX7cuUbMrIaIMKczfWJqqr6m8IlJs0F2zYwyyMTQ87QMHIj5jJ5HhOaOkaj6dvTMVGx8Dd1I4xgUuoQ==", "dev": true, "dependencies": { "@commitlint/types": "^17.4.4", @@ -752,14 +752,14 @@ } }, "node_modules/@commitlint/lint": { - "version": "17.6.3", - "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-17.6.3.tgz", - "integrity": "sha512-fBlXwt6SHJFgm3Tz+luuo3DkydAx9HNC5y4eBqcKuDuMVqHd2ugMNr+bQtx6riv9mXFiPoKp7nE4Xn/ls3iVDA==", + "version": "17.6.5", + "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-17.6.5.tgz", + "integrity": "sha512-BSJMwkE4LWXrOsiP9KoHG+/heSDfvOL/Nd16+ojTS/DX8HZr8dNl8l3TfVr/d/9maWD8fSegRGtBtsyGuugFrw==", "dev": true, "dependencies": { - "@commitlint/is-ignored": "^17.6.3", - "@commitlint/parse": "^17.4.4", - "@commitlint/rules": "^17.6.1", + "@commitlint/is-ignored": "^17.6.5", + "@commitlint/parse": "^17.6.5", + "@commitlint/rules": "^17.6.5", "@commitlint/types": "^17.4.4" }, "engines": { @@ -866,9 +866,9 @@ } }, "node_modules/@commitlint/parse": { - "version": "17.4.4", - "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-17.4.4.tgz", - "integrity": "sha512-EKzz4f49d3/OU0Fplog7nwz/lAfXMaDxtriidyGF9PtR+SRbgv4FhsfF310tKxs6EPj8Y+aWWuX3beN5s+yqGg==", + "version": "17.6.5", + "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-17.6.5.tgz", + "integrity": "sha512-0zle3bcn1Hevw5Jqpz/FzEWNo2KIzUbc1XyGg6WrWEoa6GH3A1pbqNF6MvE6rjuy6OY23c8stWnb4ETRZyN+Yw==", "dev": true, "dependencies": { "@commitlint/types": "^17.4.4", @@ -927,9 +927,9 @@ } }, "node_modules/@commitlint/rules": { - "version": "17.6.1", - "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-17.6.1.tgz", - "integrity": "sha512-lUdHw6lYQ1RywExXDdLOKxhpp6857/4c95Dc/1BikrHgdysVUXz26yV0vp1GL7Gv+avx9WqZWTIVB7pNouxlfw==", + "version": "17.6.5", + "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-17.6.5.tgz", + "integrity": "sha512-uTB3zSmnPyW2qQQH+Dbq2rekjlWRtyrjDo4aLFe63uteandgkI+cc0NhhbBAzcXShzVk0qqp8SlkQMu0mgHg/A==", "dev": true, "dependencies": { "@commitlint/ensure": "^17.4.4", @@ -1256,9 +1256,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.41.0.tgz", - "integrity": "sha512-LxcyMGxwmTh2lY9FwHPGWOHmYFCZvbrFCBZL4FzSSsxsRPuhrYUg/49/0KDfW8tnIEaEHtfmn6+NPN+1DqaNmA==", + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.42.0.tgz", + "integrity": "sha512-6SWlXpWU5AvId8Ac7zjzmIOqMOba/JWY8XZ4A7q7Gn1Vlfg/SFFIlrtHXt9nPn4op9ZPAkl91Jao+QQv3r/ukw==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1309,9 +1309,9 @@ } }, "node_modules/@google-cloud/pubsub": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@google-cloud/pubsub/-/pubsub-3.6.0.tgz", - "integrity": "sha512-txGVVrQLUZZHh88BTwo2fUodCozbqC9F4YAMm7zZikQ1vlaLKrZtAK5U5QYikQcOtMwrNejFGx2rHegEKEHUuQ==", + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/@google-cloud/pubsub/-/pubsub-3.7.1.tgz", + "integrity": "sha512-J6jzgIubq1sAMafnSF2wGnOn1qkNd0l0Y5ChG33rU27/iDXmxKabaiY/dvFndX3v57TE/QcB9uQt5A6Pek+WrA==", "dependencies": { "@google-cloud/paginator": "^4.0.0", "@google-cloud/precise-date": "^3.0.0", @@ -1454,9 +1454,9 @@ } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", + "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", "dev": true, "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", @@ -2321,9 +2321,9 @@ "dev": true }, "node_modules/@types/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-rFT3ak0/2trgvp4yYZo5iKFEPsET7vKydKF+VRCxlQ9bpheehyAJH89dAkaLEq/j/RZXJIqcgsmPJKUP1Z28HA==", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.2.tgz", + "integrity": "sha512-kNnC1GFBLuhImSnV7w4njQkUiJi0ZXUycu1rUaouPqiKlXkh77JKgdRnTAp1x5eBwcIwbtI+3otwzuIDEuDoxQ==", "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { @@ -4825,16 +4825,16 @@ } }, "node_modules/eslint": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.41.0.tgz", - "integrity": "sha512-WQDQpzGBOP5IrXPo4Hc0814r4/v2rrIsB0rhT7jtunIalgg6gYXWhRMOejVO8yH21T/FGaxjmFjBMNqcIlmH1Q==", + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.42.0.tgz", + "integrity": "sha512-ulg9Ms6E1WPf67PHaEY4/6E2tEn5/f7FXGzr3t9cBMugOmf1INYvuUwwh1aXQN4MfJ6a5K2iNwP3w4AColvI9A==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.4.0", "@eslint/eslintrc": "^2.0.3", - "@eslint/js": "8.41.0", - "@humanwhocodes/config-array": "^0.11.8", + "@eslint/js": "8.42.0", + "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", @@ -5898,12 +5898,12 @@ } }, "node_modules/get-port": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/get-port/-/get-port-6.1.2.tgz", - "integrity": "sha512-BrGGraKm2uPqurfGVj/z97/zv8dPleC6x9JBNRTrDNtCkkRF4rPwrQXFgL7+I+q8QSdU4ntLQX2D7KIxSy8nGw==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/get-port/-/get-port-7.0.0.tgz", + "integrity": "sha512-mDHFgApoQd+azgMdwylJrv2DX47ywGq1i5VFJE7fZ0dttNq3iQMfsU4IvEgBHojA3KqEudyu7Vq+oN8kNaNkWw==", "dev": true, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=16" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -6199,13 +6199,13 @@ } }, "node_modules/google-pubsub-emulator": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/google-pubsub-emulator/-/google-pubsub-emulator-6.0.0.tgz", - "integrity": "sha512-Ziy/jcYluS5+1OMv3ypG2W1/ORUINvK/TZEDLrM3CABxykURvKui1g7rD5F2KpNEslbGvxCIjaiLv1LYUHxYIw==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/google-pubsub-emulator/-/google-pubsub-emulator-7.0.0.tgz", + "integrity": "sha512-hilB3VL4ZJ37fQQv6ZMJ7VutIA+iQaSzb9mKl0Q0LyxoJpegx2zI40I86vhVnvvGJQitckDB3grWqObP12Uz6Q==", "dev": true, "dependencies": { "fs-extra": "^11.1.0", - "get-port": "^6.1.2", + "get-port": "^7.0.0", "node-cleanup": "^2.1.2", "tree-kill": "^1.2.2" }, @@ -13460,13 +13460,13 @@ } }, "node_modules/sinon": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-15.1.0.tgz", - "integrity": "sha512-cS5FgpDdE9/zx7no8bxROHymSlPLZzq0ChbbLk1DrxBfc+eTeBK3y8nIL+nu/0QeYydhhbLIr7ecHJpywjQaoQ==", + "version": "15.1.2", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-15.1.2.tgz", + "integrity": "sha512-uG1pU54Fis4EfYOPoEi13fmRHgZNg/u+3aReSEzHsN52Bpf+bMVfsBQS5MjouI+rTuG6UBIINlpuuO2Epr7SiA==", "dev": true, "dependencies": { "@sinonjs/commons": "^3.0.0", - "@sinonjs/fake-timers": "^10.2.0", + "@sinonjs/fake-timers": "^10.1.0", "@sinonjs/samsam": "^8.0.0", "diff": "^5.1.0", "nise": "^5.1.4", @@ -14353,16 +14353,16 @@ } }, "node_modules/typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz", + "integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=12.20" + "node": ">=14.17" } }, "node_modules/uc.micro": { @@ -15203,13 +15203,13 @@ "optional": true }, "@commitlint/cli": { - "version": "17.6.3", - "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-17.6.3.tgz", - "integrity": "sha512-ItSz2fd4F+CujgIbQOfNNerDF1eFlsBGEfp9QcCb1kxTYMuKTYZzA6Nu1YRRrIaaWwe2E7awUGpIMrPoZkOG3A==", + "version": "17.6.5", + "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-17.6.5.tgz", + "integrity": "sha512-3PQrWr/uo6lzF5k7n5QuosCYnzaxP9qGBp3jhWP0Vmsa7XA6wrl9ccPqfQyXpSbQE3zBROVO3TDqgPKe4tfmLQ==", "dev": true, "requires": { "@commitlint/format": "^17.4.4", - "@commitlint/lint": "^17.6.3", + "@commitlint/lint": "^17.6.5", "@commitlint/load": "^17.5.0", "@commitlint/read": "^17.5.1", "@commitlint/types": "^17.4.4", @@ -15290,9 +15290,9 @@ } }, "@commitlint/config-conventional": { - "version": "17.6.3", - "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-17.6.3.tgz", - "integrity": "sha512-bLyHEjjRWqlLQWIgYFHmUPbEFMOOLXeF3QbUinDIJev/u9e769tkoTH9YPknEywiuIrAgZaVo+OfzAIsJP0fsw==", + "version": "17.6.5", + "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-17.6.5.tgz", + "integrity": "sha512-Xl9H9KLl86NZm5CYNTNF9dcz1xelE/EbvhWIWcYxG/rn3UWYWdWmmnX2q6ZduNdLFSGbOxzUpIx61j5zxbeXxg==", "dev": true, "requires": { "conventional-changelog-conventionalcommits": "^5.0.0" @@ -15390,9 +15390,9 @@ } }, "@commitlint/is-ignored": { - "version": "17.6.3", - "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-17.6.3.tgz", - "integrity": "sha512-LQbNdnPbxrpbcrVKR5yf51SvquqktpyZJwqXx3lUMF6+nT9PHB8xn3wLy8pi2EQv5Zwba484JnUwDE1ygVYNQA==", + "version": "17.6.5", + "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-17.6.5.tgz", + "integrity": "sha512-CQvAPt9gX7cuUbMrIaIMKczfWJqqr6m8IlJs0F2zYwyyMTQ87QMHIj5jJ5HhOaOkaj6dvTMVGx8Dd1I4xgUuoQ==", "dev": true, "requires": { "@commitlint/types": "^17.4.4", @@ -15411,14 +15411,14 @@ } }, "@commitlint/lint": { - "version": "17.6.3", - "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-17.6.3.tgz", - "integrity": "sha512-fBlXwt6SHJFgm3Tz+luuo3DkydAx9HNC5y4eBqcKuDuMVqHd2ugMNr+bQtx6riv9mXFiPoKp7nE4Xn/ls3iVDA==", + "version": "17.6.5", + "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-17.6.5.tgz", + "integrity": "sha512-BSJMwkE4LWXrOsiP9KoHG+/heSDfvOL/Nd16+ojTS/DX8HZr8dNl8l3TfVr/d/9maWD8fSegRGtBtsyGuugFrw==", "dev": true, "requires": { - "@commitlint/is-ignored": "^17.6.3", - "@commitlint/parse": "^17.4.4", - "@commitlint/rules": "^17.6.1", + "@commitlint/is-ignored": "^17.6.5", + "@commitlint/parse": "^17.6.5", + "@commitlint/rules": "^17.6.5", "@commitlint/types": "^17.4.4" } }, @@ -15503,9 +15503,9 @@ "dev": true }, "@commitlint/parse": { - "version": "17.4.4", - "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-17.4.4.tgz", - "integrity": "sha512-EKzz4f49d3/OU0Fplog7nwz/lAfXMaDxtriidyGF9PtR+SRbgv4FhsfF310tKxs6EPj8Y+aWWuX3beN5s+yqGg==", + "version": "17.6.5", + "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-17.6.5.tgz", + "integrity": "sha512-0zle3bcn1Hevw5Jqpz/FzEWNo2KIzUbc1XyGg6WrWEoa6GH3A1pbqNF6MvE6rjuy6OY23c8stWnb4ETRZyN+Yw==", "dev": true, "requires": { "@commitlint/types": "^17.4.4", @@ -15554,9 +15554,9 @@ } }, "@commitlint/rules": { - "version": "17.6.1", - "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-17.6.1.tgz", - "integrity": "sha512-lUdHw6lYQ1RywExXDdLOKxhpp6857/4c95Dc/1BikrHgdysVUXz26yV0vp1GL7Gv+avx9WqZWTIVB7pNouxlfw==", + "version": "17.6.5", + "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-17.6.5.tgz", + "integrity": "sha512-uTB3zSmnPyW2qQQH+Dbq2rekjlWRtyrjDo4aLFe63uteandgkI+cc0NhhbBAzcXShzVk0qqp8SlkQMu0mgHg/A==", "dev": true, "requires": { "@commitlint/ensure": "^17.4.4", @@ -15789,9 +15789,9 @@ } }, "@eslint/js": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.41.0.tgz", - "integrity": "sha512-LxcyMGxwmTh2lY9FwHPGWOHmYFCZvbrFCBZL4FzSSsxsRPuhrYUg/49/0KDfW8tnIEaEHtfmn6+NPN+1DqaNmA==", + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.42.0.tgz", + "integrity": "sha512-6SWlXpWU5AvId8Ac7zjzmIOqMOba/JWY8XZ4A7q7Gn1Vlfg/SFFIlrtHXt9nPn4op9ZPAkl91Jao+QQv3r/ukw==", "dev": true }, "@google-cloud/paginator": { @@ -15826,9 +15826,9 @@ "integrity": "sha512-d4VSA86eL/AFTe5xtyZX+ePUjE8dIFu2T8zmdeNBSa5/kNgXPCx/o/wbFNHAGLJdGnk1vddRuMESD9HbOC8irw==" }, "@google-cloud/pubsub": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@google-cloud/pubsub/-/pubsub-3.6.0.tgz", - "integrity": "sha512-txGVVrQLUZZHh88BTwo2fUodCozbqC9F4YAMm7zZikQ1vlaLKrZtAK5U5QYikQcOtMwrNejFGx2rHegEKEHUuQ==", + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/@google-cloud/pubsub/-/pubsub-3.7.1.tgz", + "integrity": "sha512-J6jzgIubq1sAMafnSF2wGnOn1qkNd0l0Y5ChG33rU27/iDXmxKabaiY/dvFndX3v57TE/QcB9uQt5A6Pek+WrA==", "requires": { "@google-cloud/paginator": "^4.0.0", "@google-cloud/precise-date": "^3.0.0", @@ -15939,9 +15939,9 @@ } }, "@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", + "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", "dev": true, "requires": { "@humanwhocodes/object-schema": "^1.2.1", @@ -16672,9 +16672,9 @@ "dev": true }, "@types/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-rFT3ak0/2trgvp4yYZo5iKFEPsET7vKydKF+VRCxlQ9bpheehyAJH89dAkaLEq/j/RZXJIqcgsmPJKUP1Z28HA==", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.2.tgz", + "integrity": "sha512-kNnC1GFBLuhImSnV7w4njQkUiJi0ZXUycu1rUaouPqiKlXkh77JKgdRnTAp1x5eBwcIwbtI+3otwzuIDEuDoxQ==", "dev": true }, "@typescript-eslint/eslint-plugin": { @@ -18470,16 +18470,16 @@ } }, "eslint": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.41.0.tgz", - "integrity": "sha512-WQDQpzGBOP5IrXPo4Hc0814r4/v2rrIsB0rhT7jtunIalgg6gYXWhRMOejVO8yH21T/FGaxjmFjBMNqcIlmH1Q==", + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.42.0.tgz", + "integrity": "sha512-ulg9Ms6E1WPf67PHaEY4/6E2tEn5/f7FXGzr3t9cBMugOmf1INYvuUwwh1aXQN4MfJ6a5K2iNwP3w4AColvI9A==", "dev": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.4.0", "@eslint/eslintrc": "^2.0.3", - "@eslint/js": "8.41.0", - "@humanwhocodes/config-array": "^0.11.8", + "@eslint/js": "8.42.0", + "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", @@ -19273,9 +19273,9 @@ "dev": true }, "get-port": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/get-port/-/get-port-6.1.2.tgz", - "integrity": "sha512-BrGGraKm2uPqurfGVj/z97/zv8dPleC6x9JBNRTrDNtCkkRF4rPwrQXFgL7+I+q8QSdU4ntLQX2D7KIxSy8nGw==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/get-port/-/get-port-7.0.0.tgz", + "integrity": "sha512-mDHFgApoQd+azgMdwylJrv2DX47ywGq1i5VFJE7fZ0dttNq3iQMfsU4IvEgBHojA3KqEudyu7Vq+oN8kNaNkWw==", "dev": true }, "get-stream": { @@ -19502,13 +19502,13 @@ } }, "google-pubsub-emulator": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/google-pubsub-emulator/-/google-pubsub-emulator-6.0.0.tgz", - "integrity": "sha512-Ziy/jcYluS5+1OMv3ypG2W1/ORUINvK/TZEDLrM3CABxykURvKui1g7rD5F2KpNEslbGvxCIjaiLv1LYUHxYIw==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/google-pubsub-emulator/-/google-pubsub-emulator-7.0.0.tgz", + "integrity": "sha512-hilB3VL4ZJ37fQQv6ZMJ7VutIA+iQaSzb9mKl0Q0LyxoJpegx2zI40I86vhVnvvGJQitckDB3grWqObP12Uz6Q==", "dev": true, "requires": { "fs-extra": "^11.1.0", - "get-port": "^6.1.2", + "get-port": "^7.0.0", "node-cleanup": "^2.1.2", "tree-kill": "^1.2.2" }, @@ -24715,13 +24715,13 @@ } }, "sinon": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-15.1.0.tgz", - "integrity": "sha512-cS5FgpDdE9/zx7no8bxROHymSlPLZzq0ChbbLk1DrxBfc+eTeBK3y8nIL+nu/0QeYydhhbLIr7ecHJpywjQaoQ==", + "version": "15.1.2", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-15.1.2.tgz", + "integrity": "sha512-uG1pU54Fis4EfYOPoEi13fmRHgZNg/u+3aReSEzHsN52Bpf+bMVfsBQS5MjouI+rTuG6UBIINlpuuO2Epr7SiA==", "dev": true, "requires": { "@sinonjs/commons": "^3.0.0", - "@sinonjs/fake-timers": "^10.2.0", + "@sinonjs/fake-timers": "^10.1.0", "@sinonjs/samsam": "^8.0.0", "diff": "^5.1.0", "nise": "^5.1.4", @@ -25407,9 +25407,9 @@ } }, "typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz", + "integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==", "dev": true }, "uc.micro": { diff --git a/package.json b/package.json index 15287959..ebc3dad7 100644 --- a/package.json +++ b/package.json @@ -34,30 +34,30 @@ "@algoan/eslint-config": "^1.1.7", "@amanda-mitchell/semantic-release-npm-multiple": "^3.8.0", "@ava/typescript": "^4.0.0", - "@commitlint/cli": "^17.6.3", - "@commitlint/config-conventional": "^17.6.3", + "@commitlint/cli": "^17.6.5", + "@commitlint/config-conventional": "^17.6.5", "@semantic-release/git": "^10.0.1", "@types/sinon": "^10.0.15", - "@types/uuid": "^9.0.1", + "@types/uuid": "^9.0.2", "@yelloan/tslint": "0.3.0", "ava": "^5.3.0", "commitizen": "^4.3.0", "cz-conventional-changelog": "^3.3.0", - "eslint": "^8.41.0", - "google-pubsub-emulator": "^6.0.0", + "eslint": "^8.42.0", + "google-pubsub-emulator": "^7.0.0", "husky": "^8.0.3", "lint-staged": "^13.2.2", "nyc": "^15.1.0", "prettier": "^2.8.8", "rimraf": "^5.0.1", "semantic-release": "^19.0.5", - "sinon": "^15.1.0", + "sinon": "^15.1.2", "tslint": "^6.1.3", - "typescript": "^5.0.4", + "typescript": "^5.1.3", "uuid": "^9.0.0" }, "dependencies": { - "@google-cloud/pubsub": "^3.6.0", + "@google-cloud/pubsub": "^3.7.1", "pino": "^8.14.1" }, "engines": { diff --git a/src/GoogleCloudPubSub/GoogleCloudPubSub.ts b/src/GoogleCloudPubSub/GoogleCloudPubSub.ts index 277fe7d5..ac585033 100644 --- a/src/GoogleCloudPubSub/GoogleCloudPubSub.ts +++ b/src/GoogleCloudPubSub/GoogleCloudPubSub.ts @@ -119,7 +119,8 @@ export class GoogleCloudPubSub implements GCPubSub { event: string, opts: ListenOptions = { options: { autoAck: true } }, ): Promise { - const topic: Topic = await this.getOrCreateTopic(event, opts.options?.topicOptions); + const topicName: string = opts?.options?.topicName ?? this.getTopicName(event); + const topic: Topic = await this.getOrCreateTopic(topicName, opts.options?.topicOptions); const subscription: Subscription = await this.getOrCreateSubscription( event, topic, @@ -211,21 +212,20 @@ export class GoogleCloudPubSub implements GCPubSub { getTopicOptions?: GetTopicOptions, publishOptions?: PublishOptions, ): Promise { - const topicName: string = this.getTopicName(name); - const cachedTopic: Topic | undefined = this.topics.get(topicName); + const cachedTopic: Topic | undefined = this.topics.get(name); const topicOptions = { autoCreate: true, ...getTopicOptions }; if (cachedTopic !== undefined) { return cachedTopic; } - const [topic]: GetTopicResponse = await this.client.topic(topicName).get(topicOptions); + const [topic]: GetTopicResponse = await this.client.topic(name).get(topicOptions); if (publishOptions) { topic.setPublishOptions(publishOptions); } - this.topics.set(topicName, topic); + this.topics.set(name, topic); return topic; } diff --git a/src/GoogleCloudPubSub/lib.ts b/src/GoogleCloudPubSub/lib.ts index 1b7eb965..dc913776 100644 --- a/src/GoogleCloudPubSub/lib.ts +++ b/src/GoogleCloudPubSub/lib.ts @@ -56,6 +56,8 @@ export interface GCListenOptions { messageOptions?: Omit; /** Topic Publish options */ publishOptions?: PublishOptions; + /** Topic name, if you want a different name than the subscription */ + topicName?: string; } /** diff --git a/test/GoogleCloudPubSub.test.ts b/test/GoogleCloudPubSub.test.ts index d8335abf..09be5d23 100644 --- a/test/GoogleCloudPubSub.test.ts +++ b/test/GoogleCloudPubSub.test.ts @@ -414,3 +414,28 @@ test('GPS009 - should not create a subscription or a topic', async (t: Execution undefined, ); }); + +test('GPS010 - should use another topic name', async (t: ExecutionContext): Promise => { + const subscriptionName: string = generateRandomTopicName(); + const topicName: string = 'generateRandomTopicName'; + const pubsub: GCPubSub = PubSubFactory.create({ + transport: Transport.GOOGLE_PUBSUB, + options: { + projectId, + topicsPrefix: 'algoan', + topicsSeparator: '-', + }, + }); + + await pubsub.listen(subscriptionName, { + options: { + topicName, + }, + }); + + const [isTopicExisting] = await pubsub.client.topic(topicName).exists(); + const [isSubscriptionExisting] = await pubsub.client.topic(topicName).subscription(subscriptionName).exists(); + + t.true(isTopicExisting); + t.true(isSubscriptionExisting); +});