@quatrain/queue-gcp 1.1.15 → 1.1.17

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.
@@ -0,0 +1,6 @@
1
+ import { AbstractQueueAdapter, QueueParameters } from '@quatrain/queue';
2
+ export declare class PubSubQueueAdapter extends AbstractQueueAdapter {
3
+ constructor(params: QueueParameters);
4
+ send(data: any, topic: string): Promise<string>;
5
+ listen(topic: string): any;
6
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PubSubQueueAdapter = void 0;
13
+ const core_1 = require("@quatrain/core");
14
+ const queue_1 = require("@quatrain/queue");
15
+ const pubsub_1 = require("@google-cloud/pubsub");
16
+ class PubSubQueueAdapter extends queue_1.AbstractQueueAdapter {
17
+ constructor(params) {
18
+ super(params);
19
+ const { projectId, keyFilename } = params.config || {};
20
+ this._client = new pubsub_1.PubSub({
21
+ projectId,
22
+ keyFilename,
23
+ });
24
+ }
25
+ send(data, topic) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const dataBuffer = Buffer.from(JSON.stringify(data));
28
+ const messageId = yield this._client.topic(topic).publish(dataBuffer);
29
+ core_1.Core.log(`[Pubsub] Sending message to ${topic}`);
30
+ return messageId;
31
+ });
32
+ }
33
+ listen(topic) {
34
+ return this._client.topic(topic).onPublish();
35
+ }
36
+ }
37
+ exports.PubSubQueueAdapter = PubSubQueueAdapter;
package/package.json CHANGED
@@ -1,40 +1,40 @@
1
1
  {
2
- "name": "@quatrain/queue-gcp",
3
- "version": "1.1.15",
4
- "description": "Queue adapter for Google Cloud Platform PubSub",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "bun": "src/index.ts",
8
- "files": [
9
- "LICENSE.md",
10
- "src/",
11
- "lib/",
12
- "README.md"
13
- ],
14
- "author": "Quatrain Développement SAS <developers@quatrain.com>",
15
- "license": "AGPL-3.0-only",
16
- "devDependencies": {
17
- "@tsconfig/recommended": "^1.0.1",
18
- "@types/fs-extra": "^11.0.4",
19
- "@types/jest": "^27.0.3",
20
- "@types/node": "^22.10.1",
21
- "@types/object-hash": "^3.0.6",
22
- "jest": "^30.2.0",
23
- "jest-node-exports-resolver": "^1.1.6",
24
- "trace-unhandled": "^2.0.1",
25
- "ts-jest": "^27.1.2",
26
- "ts-node": "^10.4.0",
27
- "typescript": "^5.1.5"
28
- },
29
- "dependencies": {
30
- "@google-cloud/pubsub": "^4.7.0",
31
- "@quatrain/core": "^1.1.43",
32
- "@quatrain/queue": "^1.1.22"
33
- },
34
- "scripts": {
35
- "test-ci": "jest --runInBand",
36
- "build": "tsc",
37
- "wbuild": "tsc --watch",
38
- "bump-to": "yarn version"
39
- }
40
- }
2
+ "name": "@quatrain/queue-gcp",
3
+ "version": "1.1.17",
4
+ "description": "Queue adapter for Google Cloud Platform PubSub",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bun": "src/index.ts",
8
+ "files": [
9
+ "LICENSE.md",
10
+ "src/",
11
+ "dist/",
12
+ "README.md"
13
+ ],
14
+ "author": "Quatrain Développement SAS <developers@quatrain.com>",
15
+ "license": "AGPL-3.0-only",
16
+ "devDependencies": {
17
+ "@tsconfig/recommended": "^1.0.1",
18
+ "@types/fs-extra": "^11.0.4",
19
+ "@types/jest": "^27.0.3",
20
+ "@types/node": "^22.10.1",
21
+ "@types/object-hash": "^3.0.6",
22
+ "jest": "^30.2.0",
23
+ "jest-node-exports-resolver": "^1.1.6",
24
+ "trace-unhandled": "^2.0.1",
25
+ "ts-jest": "^27.1.2",
26
+ "ts-node": "^10.4.0",
27
+ "typescript": "^5.1.5"
28
+ },
29
+ "dependencies": {
30
+ "@google-cloud/pubsub": "^4.7.0",
31
+ "@quatrain/core": "^1.1.46",
32
+ "@quatrain/queue": "^1.1.24"
33
+ },
34
+ "scripts": {
35
+ "test-ci": "jest --runInBand",
36
+ "build": "tsc",
37
+ "wbuild": "tsc --watch",
38
+ "bump-to": "yarn version"
39
+ }
40
+ }