gcf-common-lib 0.5.5 → 0.5.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/index.js +25 -0
- package/index.ts +16 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -148,6 +148,31 @@ var GcfCommon = /** @class */ (function () {
|
|
|
148
148
|
});
|
|
149
149
|
});
|
|
150
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
*
|
|
153
|
+
* @param {!Object} event Event payload.
|
|
154
|
+
* @param {!Object} context Metadata for the event.
|
|
155
|
+
*/
|
|
156
|
+
GcfCommon.getOptions = function (event, context) {
|
|
157
|
+
var _a, _b, _c, _d, _e;
|
|
158
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
159
|
+
var storage, file, meta;
|
|
160
|
+
return __generator(this, function (_f) {
|
|
161
|
+
switch (_f.label) {
|
|
162
|
+
case 0:
|
|
163
|
+
if (!((_a = event === null || event === void 0 ? void 0 : event.metadata) === null || _a === void 0 ? void 0 : _a.options)) return [3 /*break*/, 1];
|
|
164
|
+
return [2 /*return*/, JSON.parse((_c = (_b = event === null || event === void 0 ? void 0 : event.metadata) === null || _b === void 0 ? void 0 : _b.options) !== null && _c !== void 0 ? _c : '{}')];
|
|
165
|
+
case 1:
|
|
166
|
+
storage = new storage_1.Storage();
|
|
167
|
+
file = storage.bucket(event.bucket).file(event.name);
|
|
168
|
+
return [4 /*yield*/, file.getMetadata()];
|
|
169
|
+
case 2:
|
|
170
|
+
meta = (_f.sent())[0];
|
|
171
|
+
return [2 /*return*/, JSON.parse((_e = (_d = meta === null || meta === void 0 ? void 0 : meta.metadata) === null || _d === void 0 ? void 0 : _d.options) !== null && _e !== void 0 ? _e : '{}')];
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
};
|
|
151
176
|
/**
|
|
152
177
|
*
|
|
153
178
|
* @param s Google function time limit (max: 9 min)
|
package/index.ts
CHANGED
|
@@ -67,6 +67,22 @@ export class GcfCommon {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @param {!Object} event Event payload.
|
|
73
|
+
* @param {!Object} context Metadata for the event.
|
|
74
|
+
*/
|
|
75
|
+
static async getOptions(event, context) {
|
|
76
|
+
if (event?.metadata?.options) {
|
|
77
|
+
return JSON.parse(event?.metadata?.options ?? '{}');
|
|
78
|
+
} else {
|
|
79
|
+
const storage = new Storage();
|
|
80
|
+
const file: File = storage.bucket(event.bucket).file(event.name);
|
|
81
|
+
const [meta] = await file.getMetadata();
|
|
82
|
+
return JSON.parse(meta?.metadata?.options ?? '{}');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
70
86
|
/**
|
|
71
87
|
*
|
|
72
88
|
* @param s Google function time limit (max: 9 min)
|