@anchan828/nest-cloud-run-queue-tasks-publisher 2.0.5 → 2.0.6
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 +27 -31
- package/package.json +4 -4
package/dist/publish.service.js
CHANGED
|
@@ -11,15 +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
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
15
|
exports.TasksPublisherService = void 0;
|
|
25
16
|
const tasks_1 = require("@google-cloud/tasks");
|
|
@@ -30,29 +21,34 @@ let TasksPublisherService = class TasksPublisherService {
|
|
|
30
21
|
this.options = options;
|
|
31
22
|
this.client = client;
|
|
32
23
|
}
|
|
33
|
-
publish(message, options) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
24
|
+
async publish(message, options) {
|
|
25
|
+
const taskMessage = this.options.extraConfig?.prePublish
|
|
26
|
+
? await this.options.extraConfig?.prePublish(message)
|
|
27
|
+
: message;
|
|
28
|
+
const [task] = await this.client.createTask({
|
|
29
|
+
parent: options?.queue || this.options.queue,
|
|
30
|
+
task: {
|
|
31
|
+
...this.options.publishConfig,
|
|
32
|
+
...options,
|
|
33
|
+
httpRequest: {
|
|
34
|
+
body: Buffer.from(JSON.stringify({ message: taskMessage || {} })).toString("base64"),
|
|
35
|
+
headers: {
|
|
36
|
+
"content-type": "application/json",
|
|
37
|
+
...options?.httpRequest?.headers,
|
|
38
|
+
...this.options.publishConfig?.httpRequest?.headers,
|
|
39
|
+
},
|
|
40
|
+
httpMethod: options?.httpRequest?.httpMethod || this.options.publishConfig?.httpRequest?.httpMethod || "POST",
|
|
41
|
+
oauthToken: options?.httpRequest?.oauthToken || this.options.publishConfig?.httpRequest?.oauthToken,
|
|
42
|
+
oidcToken: options?.httpRequest?.oidcToken || this.options.publishConfig?.httpRequest?.oidcToken,
|
|
43
|
+
url: options?.httpRequest?.url || this.options.publishConfig?.httpRequest?.url,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
55
46
|
});
|
|
47
|
+
const taskName = task?.name || "";
|
|
48
|
+
if (this.options.extraConfig?.postPublish) {
|
|
49
|
+
await this.options.extraConfig?.postPublish(taskMessage, taskName);
|
|
50
|
+
}
|
|
51
|
+
return taskName;
|
|
56
52
|
}
|
|
57
53
|
};
|
|
58
54
|
TasksPublisherService = __decorate([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anchan828/nest-cloud-run-queue-tasks-publisher",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
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,11 +33,11 @@
|
|
|
33
33
|
"watch": "tsc -w"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@anchan828/nest-cloud-run-queue-common": "^2.0.
|
|
36
|
+
"@anchan828/nest-cloud-run-queue-common": "^2.0.6",
|
|
37
37
|
"@google-cloud/tasks": "3.0.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@nestjs/common": "9.0.
|
|
40
|
+
"@nestjs/common": "9.0.9",
|
|
41
41
|
"rxjs": "7.5.6"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "dd78c2585bf3dcbf0dfda20310e98323b6de80f6"
|
|
50
50
|
}
|