gcf-common-lib 0.25.52 → 0.25.53
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/package.json +8 -8
- package/src/index.js +3 -5
- package/src/index.ts +10 -7
- package/src/types.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gcf-common-lib",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.25.
|
|
4
|
+
"version": "0.25.53",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"branches": [
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"url": "https://github.com/TopTechnologies/gcf-common.git"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@google-cloud/pubsub": "^4.0.
|
|
25
|
-
"@google-cloud/secret-manager": "^5.0.
|
|
26
|
-
"@google-cloud/storage": "^7.
|
|
24
|
+
"@google-cloud/pubsub": "^4.0.6",
|
|
25
|
+
"@google-cloud/secret-manager": "^5.0.1",
|
|
26
|
+
"@google-cloud/storage": "^7.3.1",
|
|
27
27
|
"amqplib": "^0.10.3",
|
|
28
28
|
"bluebird": "^3.7.2",
|
|
29
29
|
"lodash": "^4.17.21",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@tsconfig/node14": "^14.1.0",
|
|
36
|
-
"@types/amqplib": "^0.10.
|
|
37
|
-
"@types/bluebird": "^3.5.
|
|
38
|
-
"@types/lodash": "^4.14.
|
|
39
|
-
"@types/node": "^14.18.
|
|
36
|
+
"@types/amqplib": "^0.10.3",
|
|
37
|
+
"@types/bluebird": "^3.5.41",
|
|
38
|
+
"@types/lodash": "^4.14.200",
|
|
39
|
+
"@types/node": "^14.18.63"
|
|
40
40
|
},
|
|
41
41
|
"author": "alert83@gmail.com",
|
|
42
42
|
"license": ""
|
package/src/index.js
CHANGED
|
@@ -98,23 +98,21 @@ class GcfCommon {
|
|
|
98
98
|
console.log('send:', topic, appId, env, json, attributes);
|
|
99
99
|
yield exports.pubSub.topic(topic).publishMessage({
|
|
100
100
|
json: json !== null && json !== void 0 ? json : {},
|
|
101
|
-
attributes: Object.assign(Object.assign({}, (0, lodash_1.mapValues)(attributes !== null && attributes !== void 0 ? attributes : {}, v => '' + v)), { '
|
|
102
|
-
//
|
|
103
|
-
type: 'response', response: '1' }),
|
|
101
|
+
attributes: Object.assign(Object.assign({}, (0, lodash_1.mapValues)(attributes !== null && attributes !== void 0 ? attributes : {}, v => '' + v)), { 'request-id': requestId !== null && requestId !== void 0 ? requestId : '', requestId: requestId !== null && requestId !== void 0 ? requestId : '', 'app-id': appId !== null && appId !== void 0 ? appId : '', appId: appId !== null && appId !== void 0 ? appId : '', env: env !== null && env !== void 0 ? env : '' }),
|
|
104
102
|
});
|
|
105
103
|
}
|
|
106
104
|
if (exchange && !(0, isEmpty_1.default)(exchange)) {
|
|
107
105
|
console.log('send:', exchange, queue, appId, env, json, attributes);
|
|
108
106
|
yield (0, utils_1.withAmqpCh)((ch) => __awaiter(this, void 0, void 0, function* () {
|
|
109
107
|
yield ch.assertExchange(exchange, 'direct', this.amqpOptions.assertExchange);
|
|
110
|
-
yield (0, utils_1.publishAmqp)(ch, exchange, queue !== null && queue !== void 0 ? queue : '', json !== null && json !== void 0 ? json : {}, this.amqpOptions.publishOptions);
|
|
108
|
+
yield (0, utils_1.publishAmqp)(ch, exchange, queue !== null && queue !== void 0 ? queue : '', json !== null && json !== void 0 ? json : {}, Object.assign(Object.assign({}, this.amqpOptions.publishOptions), { correlationId: requestId }));
|
|
111
109
|
}), this.amqpOptions.url);
|
|
112
110
|
}
|
|
113
111
|
else if (queue && !(0, isEmpty_1.default)(queue)) {
|
|
114
112
|
console.log('send:', queue, appId, env, json, attributes);
|
|
115
113
|
yield (0, utils_1.withAmqpCh)((ch) => __awaiter(this, void 0, void 0, function* () {
|
|
116
114
|
yield ch.assertQueue(queue, this.amqpOptions.assertOptions);
|
|
117
|
-
yield (0, utils_1.publishAmqp)(ch, undefined, queue, json !== null && json !== void 0 ? json : {}, this.amqpOptions.publishOptions);
|
|
115
|
+
yield (0, utils_1.publishAmqp)(ch, undefined, queue, json !== null && json !== void 0 ? json : {}, Object.assign(Object.assign({}, this.amqpOptions.publishOptions), { correlationId: requestId }));
|
|
118
116
|
}), this.amqpOptions.url);
|
|
119
117
|
}
|
|
120
118
|
console.timeEnd('publish');
|
package/src/index.ts
CHANGED
|
@@ -91,14 +91,11 @@ export class GcfCommon {
|
|
|
91
91
|
json: json ?? {},
|
|
92
92
|
attributes: {
|
|
93
93
|
...mapValues(attributes ?? {}, v => '' + v),
|
|
94
|
-
'app-id': appId ?? '',
|
|
95
|
-
appId: appId ?? '',
|
|
96
94
|
'request-id': requestId ?? '',
|
|
97
95
|
requestId: requestId ?? '',
|
|
96
|
+
'app-id': appId ?? '',
|
|
97
|
+
appId: appId ?? '',
|
|
98
98
|
env: env ?? '',
|
|
99
|
-
//
|
|
100
|
-
type: 'response',
|
|
101
|
-
response: '1',
|
|
102
99
|
} as TMetadataOrAttributes,
|
|
103
100
|
});
|
|
104
101
|
}
|
|
@@ -107,13 +104,19 @@ export class GcfCommon {
|
|
|
107
104
|
console.log('send:', exchange, queue, appId, env, json, attributes);
|
|
108
105
|
await withAmqpCh(async ch => {
|
|
109
106
|
await ch.assertExchange(exchange, 'direct', this.amqpOptions.assertExchange);
|
|
110
|
-
await publishAmqp(ch, exchange, queue ?? '', json ?? {},
|
|
107
|
+
await publishAmqp(ch, exchange, queue ?? '', json ?? {}, {
|
|
108
|
+
...this.amqpOptions.publishOptions,
|
|
109
|
+
correlationId: requestId,
|
|
110
|
+
});
|
|
111
111
|
}, this.amqpOptions.url as string);
|
|
112
112
|
} else if (queue && !isEmpty(queue)) {
|
|
113
113
|
console.log('send:', queue, appId, env, json, attributes);
|
|
114
114
|
await withAmqpCh(async ch => {
|
|
115
115
|
await ch.assertQueue(queue, this.amqpOptions.assertOptions);
|
|
116
|
-
await publishAmqp(ch, undefined, queue, json ?? {},
|
|
116
|
+
await publishAmqp(ch, undefined, queue, json ?? {}, {
|
|
117
|
+
...this.amqpOptions.publishOptions,
|
|
118
|
+
correlationId: requestId,
|
|
119
|
+
});
|
|
117
120
|
}, this.amqpOptions.url as string);
|
|
118
121
|
}
|
|
119
122
|
|
package/src/types.ts
CHANGED
|
@@ -31,6 +31,7 @@ export type TPSEvent<A = TMetadataOrAttributes> = {
|
|
|
31
31
|
export type TEvent = TGSEvent | TPSEvent;
|
|
32
32
|
|
|
33
33
|
export type TMetadataOrAttributes = {
|
|
34
|
+
'request-id'?: string; // for rpc response [GUID]
|
|
34
35
|
topic?: string; // response PubSub topic [t_{GUID}__{YYYY-MM-DD}]
|
|
35
36
|
exchange?: string; // response amqp exchange
|
|
36
37
|
queue?: string; // response amqp queue
|
|
@@ -50,7 +51,6 @@ export type TMetadataOrAttributes = {
|
|
|
50
51
|
'tenant-id'?: string;
|
|
51
52
|
//
|
|
52
53
|
'app-id'?: string; // app id
|
|
53
|
-
'request-id'?: string; // for rpc response [GUID]
|
|
54
54
|
env?: string; // app environment
|
|
55
55
|
};
|
|
56
56
|
|