@anchan828/nest-cloud-run-queue-pubsub-publisher 2.0.5 → 2.0.8
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/publish.service.js +12 -35
- package/package.json +6 -6
package/dist/publish.service.js
CHANGED
|
@@ -11,26 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
24
|
-
var t = {};
|
|
25
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
26
|
-
t[p] = s[p];
|
|
27
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
28
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
29
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
30
|
-
t[p[i]] = s[p[i]];
|
|
31
|
-
}
|
|
32
|
-
return t;
|
|
33
|
-
};
|
|
34
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
15
|
exports.PubSubPublisherService = void 0;
|
|
36
16
|
const pubsub_1 = require("@google-cloud/pubsub");
|
|
@@ -41,23 +21,20 @@ let PubSubPublisherService = class PubSubPublisherService {
|
|
|
41
21
|
this.options = options;
|
|
42
22
|
this.pubsub = pubsub;
|
|
43
23
|
}
|
|
44
|
-
publish(message, options) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
return messageId;
|
|
57
|
-
});
|
|
24
|
+
async publish(message, options) {
|
|
25
|
+
const topicName = this.getTopicName(options);
|
|
26
|
+
const topic = this.pubsub.topic(topicName, Object.assign({}, this.options.publishConfig, options));
|
|
27
|
+
const { attributes, ...json } = this.options.extraConfig?.prePublish
|
|
28
|
+
? await this.options.extraConfig?.prePublish(message)
|
|
29
|
+
: message;
|
|
30
|
+
const messageId = await topic.publishMessage({ attributes, json: json || {} });
|
|
31
|
+
if (this.options.extraConfig?.postPublish) {
|
|
32
|
+
await this.options.extraConfig?.postPublish(message, messageId);
|
|
33
|
+
}
|
|
34
|
+
return messageId;
|
|
58
35
|
}
|
|
59
36
|
getTopicName(options) {
|
|
60
|
-
const topic = this.options.topic ||
|
|
37
|
+
const topic = this.options.topic || options?.topic;
|
|
61
38
|
if (!topic) {
|
|
62
39
|
throw new Error(constants_1.ERROR_TOPIC_NOT_FOUND);
|
|
63
40
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anchan828/nest-cloud-run-queue-pubsub-publisher",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"homepage": "https://github.com/anchan828/nest-cloud-run-queue/tree/master/packages/pubsub-publish#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"watch": "tsc -w"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@anchan828/nest-cloud-run-queue-common": "^2.0.
|
|
37
|
-
"@google-cloud/pubsub": "3.1.0"
|
|
36
|
+
"@anchan828/nest-cloud-run-queue-common": "^2.0.8",
|
|
37
|
+
"@google-cloud/pubsub": "^3.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@nestjs/common": "9.0.
|
|
41
|
-
"rxjs": "7.5.6"
|
|
40
|
+
"@nestjs/common": "^9.0.11",
|
|
41
|
+
"rxjs": "^7.5.6"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@nestjs/common": "^8.0.0 || ^9.0.0"
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "7446ef983035bb5ac35e26cb220da3305a992aad"
|
|
50
50
|
}
|