gcf-common-lib 0.26.58 → 0.26.60
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 +12 -13
- package/src/index.js +13 -16
- package/src/index.ts +12 -15
- package/tsconfig.json +1 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gcf-common-lib",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.26.
|
|
4
|
+
"version": "0.26.60",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"branches": [
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
]
|
|
10
10
|
},
|
|
11
11
|
"engines": {
|
|
12
|
-
"node": "16"
|
|
13
|
-
"npm": "8"
|
|
12
|
+
"node": ">=16"
|
|
14
13
|
},
|
|
15
14
|
"main": "src/index",
|
|
16
15
|
"scripts": {
|
|
@@ -21,13 +20,13 @@
|
|
|
21
20
|
"url": "https://github.com/TopTechnologies/gcf-common.git"
|
|
22
21
|
},
|
|
23
22
|
"dependencies": {
|
|
24
|
-
"@types/amqplib": "^0.10.
|
|
25
|
-
"@types/bluebird": "^3.5.
|
|
26
|
-
"@types/lodash": "^4.14.
|
|
27
|
-
"@types/node": "^16.18.
|
|
28
|
-
"@google-cloud/pubsub": "^4.0.
|
|
23
|
+
"@types/amqplib": "^0.10.4",
|
|
24
|
+
"@types/bluebird": "^3.5.42",
|
|
25
|
+
"@types/lodash": "^4.14.201",
|
|
26
|
+
"@types/node": "^16.18.61",
|
|
27
|
+
"@google-cloud/pubsub": "^4.0.7",
|
|
29
28
|
"@google-cloud/secret-manager": "^5.0.1",
|
|
30
|
-
"@google-cloud/storage": "^7.
|
|
29
|
+
"@google-cloud/storage": "^7.6.0",
|
|
31
30
|
"amqplib": "^0.10.3",
|
|
32
31
|
"bluebird": "^3.7.2",
|
|
33
32
|
"lodash": "^4.17.21",
|
|
@@ -36,16 +35,16 @@
|
|
|
36
35
|
"rxjs": "^7.8.1"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
40
|
-
"@typescript-eslint/parser": "^6.
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^6.10.0",
|
|
39
|
+
"@typescript-eslint/parser": "^6.10.0",
|
|
41
40
|
"@tsconfig/node16": "^16.1.1",
|
|
42
|
-
"eslint": "^8.
|
|
41
|
+
"eslint": "^8.53.0",
|
|
43
42
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
44
43
|
"eslint-plugin-import": "^2.29.0",
|
|
45
44
|
"eslint-plugin-lodash": "^7.4.0",
|
|
46
45
|
"eslint-plugin-promise": "^6.1.1",
|
|
47
46
|
"eslint-plugin-rxjs": "^5.0.3",
|
|
48
|
-
"eslint-plugin-unicorn": "^
|
|
47
|
+
"eslint-plugin-unicorn": "^49.0.0"
|
|
49
48
|
},
|
|
50
49
|
"author": "alert83@gmail.com",
|
|
51
50
|
"license": ""
|
package/src/index.js
CHANGED
|
@@ -29,18 +29,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.GcfCommon = exports.secretClient = exports.
|
|
32
|
+
exports.GcfCommon = exports.secretClient = exports.pubSub = exports.MongoDb = exports.RxJs = exports.SecretManager = exports.PubSub = void 0;
|
|
33
33
|
const pubsub_1 = require("@google-cloud/pubsub");
|
|
34
34
|
const secret_manager_1 = require("@google-cloud/secret-manager");
|
|
35
|
-
const storage_1 = require("@google-cloud/storage");
|
|
36
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
37
35
|
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
38
|
-
const isNil_1 = __importDefault(require("lodash/isNil"));
|
|
39
36
|
const mapValues_1 = __importDefault(require("lodash/mapValues"));
|
|
40
37
|
const noop_1 = __importDefault(require("lodash/noop"));
|
|
41
38
|
const rxjs_1 = require("rxjs");
|
|
42
39
|
const utils_1 = require("./utils");
|
|
43
|
-
|
|
40
|
+
// export * as Storage from '@google-cloud/storage';
|
|
44
41
|
exports.PubSub = __importStar(require("@google-cloud/pubsub"));
|
|
45
42
|
exports.SecretManager = __importStar(require("@google-cloud/secret-manager"));
|
|
46
43
|
exports.RxJs = __importStar(require("rxjs"));
|
|
@@ -48,7 +45,7 @@ exports.MongoDb = __importStar(require("mongodb"));
|
|
|
48
45
|
__exportStar(require("./types"), exports);
|
|
49
46
|
__exportStar(require("./utils"), exports);
|
|
50
47
|
exports.pubSub = new pubsub_1.PubSub();
|
|
51
|
-
|
|
48
|
+
// export const storage = new Storage();
|
|
52
49
|
exports.secretClient = new secret_manager_1.SecretManagerServiceClient();
|
|
53
50
|
class GcfCommon {
|
|
54
51
|
constructor() { }
|
|
@@ -124,16 +121,16 @@ class GcfCommon {
|
|
|
124
121
|
static async safeGetAttributes(event, context, props) {
|
|
125
122
|
let metaOrAttr = this.getMetadataOrAttribute(event, context);
|
|
126
123
|
// const everyPropIsNil = props.map(prop => get(metaOrAttr, prop)).every(v => isNil(v));
|
|
127
|
-
const someProp = props.map(prop => (
|
|
128
|
-
// if no prop then check file metadata
|
|
129
|
-
if (!someProp && context?.resource?.type === 'storage#object') {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
124
|
+
// const someProp = props.map(prop => get(metaOrAttr, prop)).some(v => !isNil(v));
|
|
125
|
+
// // if no prop then check file metadata
|
|
126
|
+
// if (!someProp && context?.resource?.type === 'storage#object') {
|
|
127
|
+
// console.log('get metadata from file');
|
|
128
|
+
// if (context?.eventType === 'google.storage.object.finalize') {
|
|
129
|
+
// const gsEvent = event as TGSEvent;
|
|
130
|
+
// const [meta] = await new Storage().bucket(gsEvent.bucket).file(gsEvent.name).getMetadata();
|
|
131
|
+
// metaOrAttr = meta?.metadata ?? {};
|
|
132
|
+
// }
|
|
133
|
+
// }
|
|
137
134
|
return {
|
|
138
135
|
...metaOrAttr,
|
|
139
136
|
app_id: metaOrAttr.app_id,
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { PubSub } from '@google-cloud/pubsub';
|
|
2
2
|
import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
|
|
3
|
-
import { Storage } from '@google-cloud/storage';
|
|
4
3
|
import { Options } from 'amqplib';
|
|
5
|
-
import get from 'lodash/get';
|
|
6
4
|
import isEmpty from 'lodash/isEmpty';
|
|
7
|
-
import isNil from 'lodash/isNil';
|
|
8
5
|
import mapValues from 'lodash/mapValues';
|
|
9
6
|
import noop from 'lodash/noop';
|
|
10
7
|
import { identity } from 'rxjs';
|
|
@@ -12,7 +9,7 @@ import { TContext, TEvent, TGSEvent, TMetadataOrAttributes, TPSEvent, TResponse
|
|
|
12
9
|
import { ms, publishAmqp, timeoutAfter, withAmqpCh } from './utils';
|
|
13
10
|
import Dict = NodeJS.Dict;
|
|
14
11
|
|
|
15
|
-
export * as Storage from '@google-cloud/storage';
|
|
12
|
+
// export * as Storage from '@google-cloud/storage';
|
|
16
13
|
export * as PubSub from '@google-cloud/pubsub';
|
|
17
14
|
export * as SecretManager from '@google-cloud/secret-manager';
|
|
18
15
|
export * as RxJs from 'rxjs';
|
|
@@ -21,7 +18,7 @@ export * from './types';
|
|
|
21
18
|
export * from './utils';
|
|
22
19
|
|
|
23
20
|
export const pubSub = new PubSub();
|
|
24
|
-
export const storage = new Storage();
|
|
21
|
+
// export const storage = new Storage();
|
|
25
22
|
export const secretClient = new SecretManagerServiceClient();
|
|
26
23
|
|
|
27
24
|
export class GcfCommon {
|
|
@@ -128,17 +125,17 @@ export class GcfCommon {
|
|
|
128
125
|
static async safeGetAttributes<E = TEvent>(event: E, context: TContext, props: string[]) {
|
|
129
126
|
let metaOrAttr = this.getMetadataOrAttribute(event, context);
|
|
130
127
|
// const everyPropIsNil = props.map(prop => get(metaOrAttr, prop)).every(v => isNil(v));
|
|
131
|
-
const someProp = props.map(prop => get(metaOrAttr, prop)).some(v => !isNil(v));
|
|
132
128
|
|
|
133
|
-
//
|
|
134
|
-
if
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
129
|
+
// const someProp = props.map(prop => get(metaOrAttr, prop)).some(v => !isNil(v));
|
|
130
|
+
// // if no prop then check file metadata
|
|
131
|
+
// if (!someProp && context?.resource?.type === 'storage#object') {
|
|
132
|
+
// console.log('get metadata from file');
|
|
133
|
+
// if (context?.eventType === 'google.storage.object.finalize') {
|
|
134
|
+
// const gsEvent = event as TGSEvent;
|
|
135
|
+
// const [meta] = await new Storage().bucket(gsEvent.bucket).file(gsEvent.name).getMetadata();
|
|
136
|
+
// metaOrAttr = meta?.metadata ?? {};
|
|
137
|
+
// }
|
|
138
|
+
// }
|
|
142
139
|
|
|
143
140
|
return {
|
|
144
141
|
...metaOrAttr,
|
package/tsconfig.json
CHANGED