firebase-tools 12.5.0 → 12.5.2
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.
|
@@ -130,7 +130,7 @@ function of(...endpoints) {
|
|
|
130
130
|
for (const endpoint of endpoints) {
|
|
131
131
|
bkend.endpoints[endpoint.region] = bkend.endpoints[endpoint.region] || {};
|
|
132
132
|
if (bkend.endpoints[endpoint.region][endpoint.id]) {
|
|
133
|
-
throw new Error("Trying to create a backend with the same
|
|
133
|
+
throw new Error("Trying to create a backend with the same endpoint twice");
|
|
134
134
|
}
|
|
135
135
|
bkend.endpoints[endpoint.region][endpoint.id] = endpoint;
|
|
136
136
|
}
|
|
@@ -132,7 +132,7 @@ class Fabricator {
|
|
|
132
132
|
await this.createV1Function(endpoint, scraper);
|
|
133
133
|
}
|
|
134
134
|
else if (endpoint.platform === "gcfv2") {
|
|
135
|
-
await this.createV2Function(endpoint
|
|
135
|
+
await this.createV2Function(endpoint);
|
|
136
136
|
}
|
|
137
137
|
else {
|
|
138
138
|
(0, functional_1.assertExhaustive)(endpoint.platform);
|
|
@@ -150,7 +150,7 @@ class Fabricator {
|
|
|
150
150
|
await this.updateV1Function(update.endpoint, scraper);
|
|
151
151
|
}
|
|
152
152
|
else if (update.endpoint.platform === "gcfv2") {
|
|
153
|
-
await this.updateV2Function(update.endpoint
|
|
153
|
+
await this.updateV2Function(update.endpoint);
|
|
154
154
|
}
|
|
155
155
|
else {
|
|
156
156
|
(0, functional_1.assertExhaustive)(update.endpoint.platform);
|
|
@@ -221,7 +221,7 @@ class Fabricator {
|
|
|
221
221
|
.catch(rethrowAs(endpoint, "set invoker"));
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
async createV2Function(endpoint
|
|
224
|
+
async createV2Function(endpoint) {
|
|
225
225
|
var _a, _b, _c, _d, _e;
|
|
226
226
|
const storageSource = (_a = this.sources[endpoint.codebase]) === null || _a === void 0 ? void 0 : _a.storage;
|
|
227
227
|
if (!storageSource) {
|
|
@@ -275,9 +275,8 @@ class Fabricator {
|
|
|
275
275
|
while (!resultFunction) {
|
|
276
276
|
resultFunction = await this.functionExecutor
|
|
277
277
|
.run(async () => {
|
|
278
|
-
apiFunction.buildConfig.sourceToken = await scraper.getToken();
|
|
279
278
|
const op = await gcfV2.createFunction(apiFunction);
|
|
280
|
-
return await poller.pollOperation(Object.assign(Object.assign({}, gcfV2PollerOptions), { pollerName: `create-${endpoint.codebase}-${endpoint.region}-${endpoint.id}`, operationResourceName: op.name
|
|
279
|
+
return await poller.pollOperation(Object.assign(Object.assign({}, gcfV2PollerOptions), { pollerName: `create-${endpoint.codebase}-${endpoint.region}-${endpoint.id}`, operationResourceName: op.name }));
|
|
281
280
|
})
|
|
282
281
|
.catch(async (err) => {
|
|
283
282
|
if (err.code === CLOUD_RUN_RESOURCE_EXHAUSTED_CODE) {
|
|
@@ -367,7 +366,7 @@ class Fabricator {
|
|
|
367
366
|
.catch(rethrowAs(endpoint, "set invoker"));
|
|
368
367
|
}
|
|
369
368
|
}
|
|
370
|
-
async updateV2Function(endpoint
|
|
369
|
+
async updateV2Function(endpoint) {
|
|
371
370
|
var _a, _b, _c, _d;
|
|
372
371
|
const storageSource = (_a = this.sources[endpoint.codebase]) === null || _a === void 0 ? void 0 : _a.storage;
|
|
373
372
|
if (!storageSource) {
|
|
@@ -380,9 +379,8 @@ class Fabricator {
|
|
|
380
379
|
}
|
|
381
380
|
const resultFunction = await this.functionExecutor
|
|
382
381
|
.run(async () => {
|
|
383
|
-
apiFunction.buildConfig.sourceToken = await scraper.getToken();
|
|
384
382
|
const op = await gcfV2.updateFunction(apiFunction);
|
|
385
|
-
return await poller.pollOperation(Object.assign(Object.assign({}, gcfV2PollerOptions), { pollerName: `update-${endpoint.codebase}-${endpoint.region}-${endpoint.id}`, operationResourceName: op.name
|
|
383
|
+
return await poller.pollOperation(Object.assign(Object.assign({}, gcfV2PollerOptions), { pollerName: `update-${endpoint.codebase}-${endpoint.region}-${endpoint.id}`, operationResourceName: op.name }));
|
|
386
384
|
}, { retryCodes: [...executor_1.DEFAULT_RETRY_CODES, CLOUD_RUN_RESOURCE_EXHAUSTED_CODE] })
|
|
387
385
|
.catch(rethrowAs(endpoint, "update"));
|
|
388
386
|
endpoint.uri = (_c = resultFunction.serviceConfig) === null || _c === void 0 ? void 0 : _c.uri;
|
|
@@ -5,9 +5,8 @@ const error_1 = require("../../../error");
|
|
|
5
5
|
const functional_1 = require("../../../functional");
|
|
6
6
|
const logger_1 = require("../../../logger");
|
|
7
7
|
class SourceTokenScraper {
|
|
8
|
-
constructor(validDurationMs = 1500000
|
|
8
|
+
constructor(validDurationMs = 1500000) {
|
|
9
9
|
this.tokenValidDurationMs = validDurationMs;
|
|
10
|
-
this.fetchTimeoutMs = fetchTimeoutMs;
|
|
11
10
|
this.promise = new Promise((resolve) => (this.resolve = resolve));
|
|
12
11
|
this.fetchState = "NONE";
|
|
13
12
|
}
|
|
@@ -17,13 +16,7 @@ class SourceTokenScraper {
|
|
|
17
16
|
return undefined;
|
|
18
17
|
}
|
|
19
18
|
else if (this.fetchState === "FETCHING") {
|
|
20
|
-
|
|
21
|
-
setTimeout(() => {
|
|
22
|
-
this.fetchState = "NONE";
|
|
23
|
-
resolve(undefined);
|
|
24
|
-
}, this.fetchTimeoutMs);
|
|
25
|
-
});
|
|
26
|
-
return Promise.race([this.promise, timeout]);
|
|
19
|
+
return this.promise;
|
|
27
20
|
}
|
|
28
21
|
else if (this.fetchState === "VALID") {
|
|
29
22
|
if (this.isTokenExpired()) {
|