firebase-functions 3.17.0 → 3.18.1
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/lib/bin/firebase-functions.js +16 -14
- package/lib/cloud-functions.d.ts +2 -1
- package/lib/cloud-functions.js +2 -1
- package/lib/function-builder.js +7 -0
- package/lib/function-configuration.d.ts +1 -0
- package/lib/providers/https.d.ts +1 -1
- package/lib/runtime/loader.js +1 -2
- package/lib/runtime/manifest.d.ts +59 -1
- package/package.json +1 -1
- package/lib/common/manifest.d.ts +0 -1
- package/lib/common/manifest.js +0 -2
|
@@ -28,21 +28,23 @@ async function handleQuitquitquit(req, res) {
|
|
|
28
28
|
}
|
|
29
29
|
app.get('/__/quitquitquit', handleQuitquitquit);
|
|
30
30
|
app.post('/__/quitquitquit', handleQuitquitquit);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
31
|
+
if (process.env.FUNCTIONS_CONTROL_API === 'true') {
|
|
32
|
+
app.get('/__/functions.yaml', async (req, res) => {
|
|
33
|
+
try {
|
|
34
|
+
const stack = await (0, loader_1.loadStack)(functionsDir);
|
|
35
|
+
res.setHeader('content-type', 'text/yaml');
|
|
36
|
+
res.send(JSON.stringify(stack));
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
res
|
|
40
|
+
.status(400)
|
|
41
|
+
.send(`Failed to generate manifest from function source: ${e}`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
43
45
|
let port = 8080;
|
|
44
|
-
if (process.env.
|
|
45
|
-
port = Number.parseInt(process.env.
|
|
46
|
+
if (process.env.PORT) {
|
|
47
|
+
port = Number.parseInt(process.env.PORT);
|
|
46
48
|
}
|
|
47
49
|
console.log('Serving at port', port);
|
|
48
50
|
server = app.listen(port);
|
package/lib/cloud-functions.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Request, Response } from 'express';
|
|
|
2
2
|
import { DeploymentOptions, FailurePolicy, Schedule } from './function-configuration';
|
|
3
3
|
export { Request, Response };
|
|
4
4
|
import { Duration } from './common/encoding';
|
|
5
|
-
import { ManifestEndpoint, ManifestRequiredAPI } from './
|
|
5
|
+
import { ManifestEndpoint, ManifestRequiredAPI } from './runtime/manifest';
|
|
6
6
|
/**
|
|
7
7
|
* @hidden
|
|
8
8
|
*
|
|
@@ -199,6 +199,7 @@ export interface TriggerAnnotated {
|
|
|
199
199
|
vpcConnectorEgressSettings?: string;
|
|
200
200
|
serviceAccountEmail?: string;
|
|
201
201
|
ingressSettings?: string;
|
|
202
|
+
secrets?: string[];
|
|
202
203
|
};
|
|
203
204
|
}
|
|
204
205
|
/**
|
package/lib/cloud-functions.js
CHANGED
|
@@ -252,7 +252,7 @@ function _detectAuthType(event) {
|
|
|
252
252
|
/** @hidden */
|
|
253
253
|
function optionsToTrigger(options) {
|
|
254
254
|
const trigger = {};
|
|
255
|
-
(0, encoding_1.copyIfPresent)(trigger, options, 'regions', 'schedule', 'minInstances', 'maxInstances', 'ingressSettings', 'vpcConnectorEgressSettings', 'vpcConnector', 'labels');
|
|
255
|
+
(0, encoding_1.copyIfPresent)(trigger, options, 'regions', 'schedule', 'minInstances', 'maxInstances', 'ingressSettings', 'vpcConnectorEgressSettings', 'vpcConnector', 'labels', 'secrets');
|
|
256
256
|
(0, encoding_1.convertIfPresent)(trigger, options, 'failurePolicy', 'failurePolicy', (policy) => {
|
|
257
257
|
if (policy === false) {
|
|
258
258
|
return undefined;
|
|
@@ -286,6 +286,7 @@ function optionsToEndpoint(options) {
|
|
|
286
286
|
(0, encoding_1.copyIfPresent)(endpoint, options, 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'timeoutSeconds');
|
|
287
287
|
(0, encoding_1.convertIfPresent)(endpoint, options, 'region', 'regions');
|
|
288
288
|
(0, encoding_1.convertIfPresent)(endpoint, options, 'serviceAccountEmail', 'serviceAccount', (sa) => sa);
|
|
289
|
+
(0, encoding_1.convertIfPresent)(endpoint, options, 'secretEnvironmentVariables', 'secrets', (secrets) => secrets.map((secret) => ({ secret, key: secret })));
|
|
289
290
|
if (options === null || options === void 0 ? void 0 : options.vpcConnector) {
|
|
290
291
|
endpoint.vpc = { connector: options.vpcConnector };
|
|
291
292
|
(0, encoding_1.convertIfPresent)(endpoint.vpc, options, 'egressSettings', 'vpcConnectorEgressSettings');
|
package/lib/function-builder.js
CHANGED
|
@@ -125,6 +125,13 @@ function assertRuntimeOptionsValid(runtimeOptions) {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
+
if (runtimeOptions.secrets !== undefined) {
|
|
129
|
+
const invalidSecrets = runtimeOptions.secrets.filter((s) => !/^[A-Za-z\d\-_]+$/.test(s));
|
|
130
|
+
if (invalidSecrets.length > 0) {
|
|
131
|
+
throw new Error(`Invalid secrets: ${invalidSecrets.join(',')}. ` +
|
|
132
|
+
'Secret must be configured using the resource id (e.g. API_KEY)');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
128
135
|
return true;
|
|
129
136
|
}
|
|
130
137
|
/**
|
|
@@ -99,6 +99,7 @@ export interface RuntimeOptions {
|
|
|
99
99
|
*/
|
|
100
100
|
invoker?: 'public' | 'private' | string | string[];
|
|
101
101
|
allowInvalidAppCheckToken?: boolean;
|
|
102
|
+
secrets?: string[];
|
|
102
103
|
}
|
|
103
104
|
export interface DeploymentOptions extends RuntimeOptions {
|
|
104
105
|
regions?: Array<typeof SUPPORTED_REGIONS[number] | string>;
|
package/lib/providers/https.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as express from 'express';
|
|
2
2
|
import { HttpsFunction, Runnable } from '../cloud-functions';
|
|
3
|
-
import { ManifestEndpoint, ManifestRequiredAPI } from '../
|
|
3
|
+
import { ManifestEndpoint, ManifestRequiredAPI } from '../runtime/manifest';
|
|
4
4
|
import { CallableContext, FunctionsErrorCode, HttpsError, Request, TaskContext, TaskRateLimits, TaskRetryConfig } from '../common/providers/https';
|
|
5
5
|
import { DeploymentOptions } from '../function-configuration';
|
|
6
6
|
export { Request, CallableContext, FunctionsErrorCode, HttpsError,
|
package/lib/runtime/loader.js
CHANGED
|
@@ -91,11 +91,10 @@ async function loadStack(functionsDir) {
|
|
|
91
91
|
const requiredAPIs = [];
|
|
92
92
|
const mod = await loadModule(functionsDir);
|
|
93
93
|
extractStack(mod, endpoints, requiredAPIs);
|
|
94
|
-
|
|
94
|
+
return {
|
|
95
95
|
endpoints,
|
|
96
96
|
specVersion: 'v1alpha1',
|
|
97
97
|
requiredAPIs: mergeRequiredAPIs(requiredAPIs),
|
|
98
98
|
};
|
|
99
|
-
return stack;
|
|
100
99
|
}
|
|
101
100
|
exports.loadStack = loadStack;
|
|
@@ -1 +1,59 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* An definition of a function as appears in the Manifest.
|
|
3
|
+
*/
|
|
4
|
+
export interface ManifestEndpoint {
|
|
5
|
+
entryPoint?: string;
|
|
6
|
+
region?: string[];
|
|
7
|
+
platform?: string;
|
|
8
|
+
availableMemoryMb?: number;
|
|
9
|
+
maxInstances?: number;
|
|
10
|
+
minInstances?: number;
|
|
11
|
+
concurrency?: number;
|
|
12
|
+
serviceAccountEmail?: string;
|
|
13
|
+
timeoutSeconds?: number;
|
|
14
|
+
vpc?: {
|
|
15
|
+
connector: string;
|
|
16
|
+
egressSettings?: string;
|
|
17
|
+
};
|
|
18
|
+
labels?: Record<string, string>;
|
|
19
|
+
ingressSettings?: string;
|
|
20
|
+
environmentVariables?: Record<string, string>;
|
|
21
|
+
secretEnvironmentVariables?: {
|
|
22
|
+
key: string;
|
|
23
|
+
secret?: string;
|
|
24
|
+
}[];
|
|
25
|
+
httpsTrigger?: {
|
|
26
|
+
invoker?: string[];
|
|
27
|
+
};
|
|
28
|
+
callableTrigger?: {};
|
|
29
|
+
eventTrigger?: {
|
|
30
|
+
eventFilters: Record<string, string>;
|
|
31
|
+
eventType: string;
|
|
32
|
+
retry: boolean;
|
|
33
|
+
region?: string;
|
|
34
|
+
serviceAccountEmail?: string;
|
|
35
|
+
};
|
|
36
|
+
scheduleTrigger?: {
|
|
37
|
+
schedule?: string;
|
|
38
|
+
timezone?: string;
|
|
39
|
+
retryConfig?: {
|
|
40
|
+
retryCount?: number;
|
|
41
|
+
maxRetryDuration?: string;
|
|
42
|
+
minBackoffDuration?: string;
|
|
43
|
+
maxBackoffDuration?: string;
|
|
44
|
+
maxDoublings?: number;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface ManifestRequiredAPI {
|
|
49
|
+
api: string;
|
|
50
|
+
reason: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* An definition of a function deployment as appears in the Manifest.
|
|
54
|
+
**/
|
|
55
|
+
export interface ManifestStack {
|
|
56
|
+
specVersion: 'v1alpha1';
|
|
57
|
+
requiredAPIs: ManifestRequiredAPI[];
|
|
58
|
+
endpoints: Record<string, ManifestEndpoint>;
|
|
59
|
+
}
|
package/package.json
CHANGED
package/lib/common/manifest.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/common/manifest.js
DELETED