gcf-common-lib 0.25.37 → 0.25.39

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gcf-common-lib",
3
3
  "description": "",
4
- "version": "0.25.37",
4
+ "version": "0.25.39",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "branches": [
package/src/index.js CHANGED
@@ -68,7 +68,7 @@ class GcfCommon {
68
68
  return __awaiter(this, void 0, void 0, function* () {
69
69
  return Promise.race([(0, utils_1.timeoutAfter)(timeout), (handler !== null && handler !== void 0 ? handler : (() => Promise.resolve(undefined)))(event, context)])
70
70
  .then((res) => __awaiter(this, void 0, void 0, function* () {
71
- // console.log('res:', res);
71
+ console.log('res:', res);
72
72
  yield this.publish(event, context, res);
73
73
  }))
74
74
  .catch((err) => __awaiter(this, void 0, void 0, function* () {
@@ -123,9 +123,11 @@ class GcfCommon {
123
123
  var _a, _b, _c, _d;
124
124
  return __awaiter(this, void 0, void 0, function* () {
125
125
  let metaOrAttr = this.getMetadataOrAttribute(event, context);
126
- const everyPropIsNil = props.map(prop => (0, lodash_1.get)(metaOrAttr, prop)).every(v => (0, lodash_1.isNil)(v));
126
+ // const everyPropIsNil = props.map(prop => get(metaOrAttr, prop)).every(v => isNil(v));
127
+ const someProp = props.map(prop => (0, lodash_1.get)(metaOrAttr, prop)).some(v => !(0, lodash_1.isNil)(v));
127
128
  // if no prop then check file metadata
128
- if (everyPropIsNil && ((_a = context === null || context === void 0 ? void 0 : context.resource) === null || _a === void 0 ? void 0 : _a.type) === 'storage#object') {
129
+ if (!someProp && ((_a = context === null || context === void 0 ? void 0 : context.resource) === null || _a === void 0 ? void 0 : _a.type) === 'storage#object') {
130
+ console.log('get metadata from file');
129
131
  if ((context === null || context === void 0 ? void 0 : context.eventType) === 'google.storage.object.finalize') {
130
132
  const gsEvent = event;
131
133
  const [meta] = yield exports.storage.bucket(gsEvent.bucket).file(gsEvent.name).getMetadata();
package/src/index.ts CHANGED
@@ -48,7 +48,7 @@ export class GcfCommon {
48
48
  ) {
49
49
  return Promise.race([timeoutAfter(timeout), (handler ?? (() => Promise.resolve(undefined)))(event, context)])
50
50
  .then(async (res: T | undefined) => {
51
- // console.log('res:', res);
51
+ console.log('res:', res);
52
52
  await this.publish(event, context, res);
53
53
  })
54
54
  .catch(async (err: Error) => {
@@ -109,10 +109,12 @@ export class GcfCommon {
109
109
 
110
110
  static async safeGetAttributes(event: TEvent, context: TContext, props: string[]) {
111
111
  let metaOrAttr = this.getMetadataOrAttribute(event, context);
112
- const everyPropIsNil = props.map(prop => get(metaOrAttr, prop)).every(v => isNil(v));
112
+ // const everyPropIsNil = props.map(prop => get(metaOrAttr, prop)).every(v => isNil(v));
113
+ const someProp = props.map(prop => get(metaOrAttr, prop)).some(v => !isNil(v));
113
114
 
114
115
  // if no prop then check file metadata
115
- if (everyPropIsNil && context?.resource?.type === 'storage#object') {
116
+ if (!someProp && context?.resource?.type === 'storage#object') {
117
+ console.log('get metadata from file');
116
118
  if (context?.eventType === 'google.storage.object.finalize') {
117
119
  const gsEvent = event as TGSEvent;
118
120
  const [meta] = await storage.bucket(gsEvent.bucket).file(gsEvent.name).getMetadata();