firebase-functions 3.22.0 → 3.23.0
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 +2 -1
- package/lib/common/providers/identity.js +0 -3
- package/lib/common/providers/tasks.d.ts +8 -7
- package/lib/common/timezone.d.ts +2 -0
- package/lib/common/timezone.js +543 -0
- package/lib/function-configuration.d.ts +6 -5
- package/lib/runtime/loader.js +6 -1
- package/lib/runtime/manifest.d.ts +19 -16
- package/lib/runtime/manifest.js +24 -0
- package/lib/v2/index.d.ts +2 -1
- package/lib/v2/index.js +3 -1
- package/lib/v2/options.d.ts +16 -6
- package/lib/v2/options.js +2 -2
- package/lib/v2/params/index.d.ts +14 -12
- package/lib/v2/params/index.js +25 -15
- package/lib/v2/params/types.d.ts +97 -24
- package/lib/v2/params/types.js +127 -67
- package/lib/v2/providers/alerts/alerts.d.ts +7 -6
- package/lib/v2/providers/alerts/appDistribution.d.ts +50 -5
- package/lib/v2/providers/alerts/appDistribution.js +23 -1
- package/lib/v2/providers/alerts/crashlytics.d.ts +6 -5
- package/lib/v2/providers/database.d.ts +7 -6
- package/lib/v2/providers/eventarc.d.ts +6 -5
- package/lib/v2/providers/https.d.ts +6 -5
- package/lib/v2/providers/identity.d.ts +8 -7
- package/lib/v2/providers/pubsub.d.ts +6 -5
- package/lib/v2/providers/scheduler.d.ts +63 -0
- package/lib/v2/providers/scheduler.js +98 -0
- package/lib/v2/providers/storage.d.ts +6 -5
- package/lib/v2/providers/tasks.d.ts +7 -6
- package/package.json +13 -7
package/lib/runtime/loader.js
CHANGED
|
@@ -24,6 +24,7 @@ exports.loadStack = exports.mergeRequiredAPIs = exports.extractStack = void 0;
|
|
|
24
24
|
// SOFTWARE.
|
|
25
25
|
const path = require("path");
|
|
26
26
|
const url = require("url");
|
|
27
|
+
const params = require("../v2/params");
|
|
27
28
|
/**
|
|
28
29
|
* Dynamically load import function to prevent TypeScript from
|
|
29
30
|
* transpiling into a require.
|
|
@@ -93,10 +94,14 @@ async function loadStack(functionsDir) {
|
|
|
93
94
|
const requiredAPIs = [];
|
|
94
95
|
const mod = await loadModule(functionsDir);
|
|
95
96
|
extractStack(mod, endpoints, requiredAPIs);
|
|
96
|
-
|
|
97
|
+
const stack = {
|
|
97
98
|
endpoints,
|
|
98
99
|
specVersion: 'v1alpha1',
|
|
99
100
|
requiredAPIs: mergeRequiredAPIs(requiredAPIs),
|
|
100
101
|
};
|
|
102
|
+
if (params.declaredParams.length > 0) {
|
|
103
|
+
stack.params = params.declaredParams.map((p) => p.toSpec());
|
|
104
|
+
}
|
|
105
|
+
return stack;
|
|
101
106
|
}
|
|
102
107
|
exports.loadStack = loadStack;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Expression } from '../v2/params';
|
|
2
|
+
import { ParamSpec } from '../v2/params/types';
|
|
1
3
|
/**
|
|
2
4
|
* An definition of a function as appears in the Manifest.
|
|
3
5
|
*/
|
|
@@ -5,15 +7,15 @@ export interface ManifestEndpoint {
|
|
|
5
7
|
entryPoint?: string;
|
|
6
8
|
region?: string[];
|
|
7
9
|
platform?: string;
|
|
8
|
-
availableMemoryMb?: number
|
|
9
|
-
maxInstances?: number
|
|
10
|
-
minInstances?: number
|
|
11
|
-
concurrency?: number
|
|
10
|
+
availableMemoryMb?: number | Expression<number>;
|
|
11
|
+
maxInstances?: number | Expression<number>;
|
|
12
|
+
minInstances?: number | Expression<number>;
|
|
13
|
+
concurrency?: number | Expression<number>;
|
|
12
14
|
serviceAccountEmail?: string;
|
|
13
|
-
timeoutSeconds?: number
|
|
15
|
+
timeoutSeconds?: number | Expression<number>;
|
|
14
16
|
cpu?: number | 'gcf_gen1';
|
|
15
17
|
vpc?: {
|
|
16
|
-
connector: string
|
|
18
|
+
connector: string | Expression<string>;
|
|
17
19
|
egressSettings?: string;
|
|
18
20
|
};
|
|
19
21
|
labels?: Record<string, string>;
|
|
@@ -28,23 +30,23 @@ export interface ManifestEndpoint {
|
|
|
28
30
|
};
|
|
29
31
|
callableTrigger?: {};
|
|
30
32
|
eventTrigger?: {
|
|
31
|
-
eventFilters: Record<string, string
|
|
32
|
-
eventFilterPathPatterns?: Record<string, string
|
|
33
|
+
eventFilters: Record<string, string | Expression<string>>;
|
|
34
|
+
eventFilterPathPatterns?: Record<string, string | Expression<string>>;
|
|
33
35
|
channel?: string;
|
|
34
36
|
eventType: string;
|
|
35
|
-
retry: boolean
|
|
37
|
+
retry: boolean | Expression<boolean>;
|
|
36
38
|
region?: string;
|
|
37
39
|
serviceAccountEmail?: string;
|
|
38
40
|
};
|
|
39
41
|
scheduleTrigger?: {
|
|
40
|
-
schedule?: string
|
|
41
|
-
|
|
42
|
+
schedule?: string | Expression<string>;
|
|
43
|
+
timeZone?: string | Expression<string>;
|
|
42
44
|
retryConfig?: {
|
|
43
|
-
retryCount?: number
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
maxDoublings?: number
|
|
45
|
+
retryCount?: number | Expression<number>;
|
|
46
|
+
maxRetrySeconds?: string | Expression<string>;
|
|
47
|
+
minBackoffSeconds?: string | Expression<string>;
|
|
48
|
+
maxBackoffSeconds?: string | Expression<string>;
|
|
49
|
+
maxDoublings?: number | Expression<number>;
|
|
48
50
|
};
|
|
49
51
|
};
|
|
50
52
|
blockingTrigger?: {
|
|
@@ -61,6 +63,7 @@ export interface ManifestRequiredAPI {
|
|
|
61
63
|
*/
|
|
62
64
|
export interface ManifestStack {
|
|
63
65
|
specVersion: 'v1alpha1';
|
|
66
|
+
params?: ParamSpec[];
|
|
64
67
|
requiredAPIs: ManifestRequiredAPI[];
|
|
65
68
|
endpoints: Record<string, ManifestEndpoint>;
|
|
66
69
|
}
|
package/lib/runtime/manifest.js
CHANGED
|
@@ -21,3 +21,27 @@
|
|
|
21
21
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.stackToWire = void 0;
|
|
25
|
+
const params_1 = require("../v2/params");
|
|
26
|
+
/**
|
|
27
|
+
* Returns the JSON representation of a ManifestStack, which has CEL
|
|
28
|
+
* expressions in its options as object types, with its expressions
|
|
29
|
+
* transformed into the actual CEL strings.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
function stackToWire(stack) {
|
|
33
|
+
let wireStack = stack;
|
|
34
|
+
let traverse = function traverse(obj) {
|
|
35
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
36
|
+
if (val instanceof params_1.Expression) {
|
|
37
|
+
obj[key] = val.toCEL();
|
|
38
|
+
}
|
|
39
|
+
else if (typeof val === 'object') {
|
|
40
|
+
traverse(val);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
traverse(wireStack.endpoints);
|
|
45
|
+
return wireStack;
|
|
46
|
+
}
|
|
47
|
+
exports.stackToWire = stackToWire;
|
package/lib/v2/index.d.ts
CHANGED
|
@@ -12,9 +12,10 @@ import * as eventarc from './providers/eventarc';
|
|
|
12
12
|
import * as https from './providers/https';
|
|
13
13
|
import * as identity from './providers/identity';
|
|
14
14
|
import * as pubsub from './providers/pubsub';
|
|
15
|
+
import * as scheduler from './providers/scheduler';
|
|
15
16
|
import * as storage from './providers/storage';
|
|
16
17
|
import * as tasks from './providers/tasks';
|
|
17
|
-
export { alerts, database, storage, https, identity, pubsub, logger, tasks, eventarc, };
|
|
18
|
+
export { alerts, database, storage, https, identity, pubsub, logger, tasks, eventarc, scheduler, };
|
|
18
19
|
export { setGlobalOptions, GlobalOptions, SupportedRegion, MemoryOption, VpcEgressSetting, IngressSetting, EventHandlerOptions, } from './options';
|
|
19
20
|
export { Change } from '../common/change';
|
|
20
21
|
export { CloudFunction, CloudEvent } from './core';
|
package/lib/v2/index.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.Change = exports.setGlobalOptions = exports.eventarc = exports.tasks = exports.logger = exports.pubsub = exports.identity = exports.https = exports.storage = exports.database = exports.alerts = void 0;
|
|
24
|
+
exports.Change = exports.setGlobalOptions = exports.scheduler = exports.eventarc = exports.tasks = exports.logger = exports.pubsub = exports.identity = exports.https = exports.storage = exports.database = exports.alerts = void 0;
|
|
25
25
|
/**
|
|
26
26
|
* The V2 API for Cloud Functions for Firebase.
|
|
27
27
|
* This SDK also supports deep imports. For example, the namespace
|
|
@@ -43,6 +43,8 @@ const identity = require("./providers/identity");
|
|
|
43
43
|
exports.identity = identity;
|
|
44
44
|
const pubsub = require("./providers/pubsub");
|
|
45
45
|
exports.pubsub = pubsub;
|
|
46
|
+
const scheduler = require("./providers/scheduler");
|
|
47
|
+
exports.scheduler = scheduler;
|
|
46
48
|
const storage = require("./providers/storage");
|
|
47
49
|
exports.storage = storage;
|
|
48
50
|
const tasks = require("./providers/tasks");
|
package/lib/v2/options.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Expression } from './params';
|
|
1
2
|
import { ParamSpec } from './params/types';
|
|
2
3
|
/**
|
|
3
4
|
* List of all regions supported by Cloud Functions v2
|
|
@@ -29,7 +30,7 @@ export interface GlobalOptions {
|
|
|
29
30
|
* Amount of memory to allocate to a function.
|
|
30
31
|
* A value of null restores the defaults of 256MB.
|
|
31
32
|
*/
|
|
32
|
-
memory?: MemoryOption | null;
|
|
33
|
+
memory?: MemoryOption | Expression<number> | null;
|
|
33
34
|
/**
|
|
34
35
|
* Timeout for the function in sections, possible values are 0 to 540.
|
|
35
36
|
* HTTPS functions can specify a higher timeout.
|
|
@@ -40,19 +41,19 @@ export interface GlobalOptions {
|
|
|
40
41
|
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
|
|
41
42
|
* timeout of 1,800s (30 minutes)
|
|
42
43
|
*/
|
|
43
|
-
timeoutSeconds?: number | null;
|
|
44
|
+
timeoutSeconds?: number | Expression<number> | null;
|
|
44
45
|
/**
|
|
45
46
|
* Min number of actual instances to be running at a given time.
|
|
46
47
|
* Instances will be billed for memory allocation and 10% of CPU allocation
|
|
47
48
|
* while idle.
|
|
48
49
|
* A value of null restores the default min instances.
|
|
49
50
|
*/
|
|
50
|
-
minInstances?: number | null;
|
|
51
|
+
minInstances?: number | Expression<number> | null;
|
|
51
52
|
/**
|
|
52
53
|
* Max number of instances to be running in parallel.
|
|
53
54
|
* A value of null restores the default max instances.
|
|
54
55
|
*/
|
|
55
|
-
maxInstances?: number | null;
|
|
56
|
+
maxInstances?: number | Expression<number> | null;
|
|
56
57
|
/**
|
|
57
58
|
* Number of requests a function can serve at once.
|
|
58
59
|
* Can only be applied to functions running on Cloud Functions v2.
|
|
@@ -60,7 +61,7 @@ export interface GlobalOptions {
|
|
|
60
61
|
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
|
61
62
|
* The maximum value for concurrency is 1,000.
|
|
62
63
|
*/
|
|
63
|
-
concurrency?: number | null;
|
|
64
|
+
concurrency?: number | Expression<number> | null;
|
|
64
65
|
/**
|
|
65
66
|
* Fractional number of CPUs to allocate to a function.
|
|
66
67
|
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
|
@@ -109,8 +110,17 @@ export declare function setGlobalOptions(options: GlobalOptions): void;
|
|
|
109
110
|
* Additional fields that can be set on any event-handling Cloud Function.
|
|
110
111
|
*/
|
|
111
112
|
export interface EventHandlerOptions extends GlobalOptions {
|
|
113
|
+
eventType?: string;
|
|
114
|
+
eventFilters?: Record<string, string | Expression<string>>;
|
|
115
|
+
eventFilterPathPatterns?: Record<string, string | Expression<string>>;
|
|
112
116
|
/** Whether failed executions should be delivered again. */
|
|
113
|
-
retry?: boolean;
|
|
117
|
+
retry?: boolean | Expression<boolean> | null;
|
|
118
|
+
/** Region of the EventArc trigger. */
|
|
119
|
+
region?: string;
|
|
120
|
+
/** The service account that EventArc should use to invoke this function. Requires the P4SA to have ActAs permission on this service account. */
|
|
121
|
+
serviceAccount?: string | null;
|
|
122
|
+
/** The name of the channel where the function receives events. */
|
|
123
|
+
channel?: string;
|
|
114
124
|
}
|
|
115
125
|
/**
|
|
116
126
|
* @hidden
|
package/lib/v2/options.js
CHANGED
|
@@ -69,7 +69,7 @@ function optionsToTriggerAnnotations(opts) {
|
|
|
69
69
|
const annotation = {};
|
|
70
70
|
(0, encoding_1.copyIfPresent)(annotation, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'vpcConnector', 'vpcConnectorEgressSettings', 'secrets');
|
|
71
71
|
(0, encoding_1.convertIfPresent)(annotation, opts, 'availableMemoryMb', 'memory', (mem) => {
|
|
72
|
-
return MemoryOptionToMB[mem];
|
|
72
|
+
return typeof mem === 'object' ? mem : MemoryOptionToMB[mem];
|
|
73
73
|
});
|
|
74
74
|
(0, encoding_1.convertIfPresent)(annotation, opts, 'regions', 'region', (region) => {
|
|
75
75
|
if (typeof region === 'string') {
|
|
@@ -99,7 +99,7 @@ function optionsToEndpoint(opts) {
|
|
|
99
99
|
endpoint.vpc = vpc;
|
|
100
100
|
}
|
|
101
101
|
(0, encoding_1.convertIfPresent)(endpoint, opts, 'availableMemoryMb', 'memory', (mem) => {
|
|
102
|
-
return MemoryOptionToMB[mem];
|
|
102
|
+
return typeof mem === 'object' ? mem : MemoryOptionToMB[mem];
|
|
103
103
|
});
|
|
104
104
|
(0, encoding_1.convertIfPresent)(endpoint, opts, 'region', 'region', (region) => {
|
|
105
105
|
if (typeof region === 'string') {
|
package/lib/v2/params/index.d.ts
CHANGED
|
@@ -2,9 +2,20 @@
|
|
|
2
2
|
* @hidden
|
|
3
3
|
* @alpha
|
|
4
4
|
*/
|
|
5
|
-
import { BooleanParam, FloatParam, IntParam,
|
|
6
|
-
export { ParamOptions };
|
|
7
|
-
|
|
5
|
+
import { BooleanParam, FloatParam, IntParam, ListParam, Param, ParamOptions, StringParam, SecretParam, Expression } from './types';
|
|
6
|
+
export { ParamOptions, Expression };
|
|
7
|
+
declare type SecretOrExpr = Param<any> | SecretParam;
|
|
8
|
+
export declare const declaredParams: SecretOrExpr[];
|
|
9
|
+
/**
|
|
10
|
+
* Declares a secret param, that will persist values only in Cloud Secret Manager.
|
|
11
|
+
* Secrets are stored interally as bytestrings. Use ParamOptions.`as` to provide type
|
|
12
|
+
* hinting during parameter resolution.
|
|
13
|
+
*
|
|
14
|
+
* @param name The name of the environment variable to use to load the param.
|
|
15
|
+
* @param options Configuration options for the param.
|
|
16
|
+
* @returns A Param with a `string` return type for `.value`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function defineSecret(name: string): SecretParam;
|
|
8
19
|
/**
|
|
9
20
|
* Declare a string param.
|
|
10
21
|
*
|
|
@@ -45,12 +56,3 @@ export declare function defineFloat(name: string, options?: ParamOptions<number>
|
|
|
45
56
|
* @returns A Param with a `string[]` return type for `.value`.
|
|
46
57
|
*/
|
|
47
58
|
export declare function defineList(name: string, options?: ParamOptions<string[]>): ListParam;
|
|
48
|
-
/**
|
|
49
|
-
* Declare a JSON param. The associated environment variable will be treated
|
|
50
|
-
* as a JSON string when loading its value.
|
|
51
|
-
*
|
|
52
|
-
* @param name The name of the environment variable to use to load the param.
|
|
53
|
-
* @param options Configuration options for the param.
|
|
54
|
-
* @returns A Param with a specifiable return type for `.value`.
|
|
55
|
-
*/
|
|
56
|
-
export declare function defineJSON<T = any>(name: string, options?: ParamOptions<T>): JSONParam;
|
package/lib/v2/params/index.js
CHANGED
|
@@ -21,12 +21,13 @@
|
|
|
21
21
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.
|
|
24
|
+
exports.defineList = exports.defineFloat = exports.defineInt = exports.defineBoolean = exports.defineString = exports.defineSecret = exports.clearParams = exports.declaredParams = exports.Expression = void 0;
|
|
25
25
|
/**
|
|
26
26
|
* @hidden
|
|
27
27
|
* @alpha
|
|
28
28
|
*/
|
|
29
29
|
const types_1 = require("./types");
|
|
30
|
+
Object.defineProperty(exports, "Expression", { enumerable: true, get: function () { return types_1.Expression; } });
|
|
30
31
|
exports.declaredParams = [];
|
|
31
32
|
/**
|
|
32
33
|
* Use a helper to manage the list such that params are uniquely
|
|
@@ -41,6 +42,29 @@ function registerParam(param) {
|
|
|
41
42
|
}
|
|
42
43
|
exports.declaredParams.push(param);
|
|
43
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* For testing.
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
function clearParams() {
|
|
50
|
+
exports.declaredParams.splice(0, exports.declaredParams.length);
|
|
51
|
+
}
|
|
52
|
+
exports.clearParams = clearParams;
|
|
53
|
+
/**
|
|
54
|
+
* Declares a secret param, that will persist values only in Cloud Secret Manager.
|
|
55
|
+
* Secrets are stored interally as bytestrings. Use ParamOptions.`as` to provide type
|
|
56
|
+
* hinting during parameter resolution.
|
|
57
|
+
*
|
|
58
|
+
* @param name The name of the environment variable to use to load the param.
|
|
59
|
+
* @param options Configuration options for the param.
|
|
60
|
+
* @returns A Param with a `string` return type for `.value`.
|
|
61
|
+
*/
|
|
62
|
+
function defineSecret(name) {
|
|
63
|
+
const param = new types_1.SecretParam(name);
|
|
64
|
+
registerParam(param);
|
|
65
|
+
return param;
|
|
66
|
+
}
|
|
67
|
+
exports.defineSecret = defineSecret;
|
|
44
68
|
/**
|
|
45
69
|
* Declare a string param.
|
|
46
70
|
*
|
|
@@ -106,17 +130,3 @@ function defineList(name, options = {}) {
|
|
|
106
130
|
return param;
|
|
107
131
|
}
|
|
108
132
|
exports.defineList = defineList;
|
|
109
|
-
/**
|
|
110
|
-
* Declare a JSON param. The associated environment variable will be treated
|
|
111
|
-
* as a JSON string when loading its value.
|
|
112
|
-
*
|
|
113
|
-
* @param name The name of the environment variable to use to load the param.
|
|
114
|
-
* @param options Configuration options for the param.
|
|
115
|
-
* @returns A Param with a specifiable return type for `.value`.
|
|
116
|
-
*/
|
|
117
|
-
function defineJSON(name, options = {}) {
|
|
118
|
-
const param = new types_1.JSONParam(name, options);
|
|
119
|
-
registerParam(param);
|
|
120
|
-
return param;
|
|
121
|
-
}
|
|
122
|
-
exports.defineJSON = defineJSON;
|
package/lib/v2/params/types.d.ts
CHANGED
|
@@ -1,45 +1,118 @@
|
|
|
1
|
+
export declare abstract class Expression<T extends string | number | boolean | string[]> {
|
|
2
|
+
value(): T;
|
|
3
|
+
toCEL(): string;
|
|
4
|
+
toJSON(): string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A CEL expression corresponding to a ternary operator, e.g {{ cond ? ifTrue : ifFalse }}
|
|
8
|
+
*/
|
|
9
|
+
export declare class TernaryExpression<T extends string | number | boolean | string[]> extends Expression<T> {
|
|
10
|
+
private readonly test;
|
|
11
|
+
private readonly ifTrue;
|
|
12
|
+
private readonly ifFalse;
|
|
13
|
+
constructor(test: Expression<boolean>, ifTrue: T, ifFalse: T);
|
|
14
|
+
value(): T;
|
|
15
|
+
toString(): string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A CEL expression that evaluates to boolean true or false based on a comparison
|
|
19
|
+
* between the value of another expression and a literal of that same type.
|
|
20
|
+
*/
|
|
21
|
+
export declare class CompareExpression<T extends string | number | boolean | string[]> extends Expression<boolean> {
|
|
22
|
+
cmp: '==' | '>' | '>=' | '<' | '<=';
|
|
23
|
+
lhs: Expression<T>;
|
|
24
|
+
rhs: T;
|
|
25
|
+
constructor(cmp: '==' | '>' | '>=' | '<' | '<=', lhs: Expression<T>, rhs: T);
|
|
26
|
+
value(): boolean;
|
|
27
|
+
toString(): string;
|
|
28
|
+
then(ifTrue: T, ifFalse: T): TernaryExpression<T>;
|
|
29
|
+
}
|
|
1
30
|
/** @hidden */
|
|
2
|
-
declare type ParamValueType = 'string' | 'list' | 'boolean' | 'int' | 'float' | '
|
|
3
|
-
|
|
31
|
+
declare type ParamValueType = 'string' | 'list' | 'boolean' | 'int' | 'float' | 'secret';
|
|
32
|
+
declare type ParamInput<T> = {
|
|
33
|
+
text: TextInput<T>;
|
|
34
|
+
} | {
|
|
35
|
+
select: SelectInput<T>;
|
|
36
|
+
} | {
|
|
37
|
+
resource: ResourceInput;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Specifies that a Param's value should be determined by prompting the user
|
|
41
|
+
* to type it in interactively at deploy-time. Input that does not match the
|
|
42
|
+
* provided validationRegex, if present, will be retried.
|
|
43
|
+
*/
|
|
44
|
+
export interface TextInput<T = unknown> {
|
|
45
|
+
example?: string;
|
|
46
|
+
validationRegex?: string;
|
|
47
|
+
validationErrorMessage?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Specifies that a Param's value should be determined by having the user
|
|
51
|
+
* select from a list containing all the project's resources of a certain
|
|
52
|
+
* type. Currently, only type:"storage.googleapis.com/Bucket" is supported.
|
|
53
|
+
*/
|
|
54
|
+
export interface ResourceInput {
|
|
55
|
+
resource: {
|
|
56
|
+
type: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Specifies that a Param's value should be determined by having the user select
|
|
61
|
+
* from a list of pre-canned options interactively at deploy-time.
|
|
62
|
+
*/
|
|
63
|
+
export interface SelectInput<T = unknown> {
|
|
64
|
+
options: Array<SelectOptions<T>>;
|
|
65
|
+
}
|
|
66
|
+
export interface SelectOptions<T = unknown> {
|
|
67
|
+
label?: string;
|
|
68
|
+
value: T;
|
|
69
|
+
}
|
|
70
|
+
export declare type ParamSpec<T = unknown> = {
|
|
4
71
|
name: string;
|
|
5
72
|
default?: T;
|
|
6
73
|
label?: string;
|
|
7
74
|
description?: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare
|
|
75
|
+
type: ParamValueType;
|
|
76
|
+
input?: ParamInput<T>;
|
|
77
|
+
};
|
|
78
|
+
export declare type ParamOptions<T = unknown> = Omit<ParamSpec<T>, 'name' | 'type'>;
|
|
79
|
+
export declare abstract class Param<T extends string | number | boolean | string[]> extends Expression<T> {
|
|
12
80
|
readonly name: string;
|
|
13
81
|
readonly options: ParamOptions<T>;
|
|
14
|
-
static
|
|
82
|
+
static type: ParamValueType;
|
|
15
83
|
constructor(name: string, options?: ParamOptions<T>);
|
|
16
|
-
|
|
17
|
-
|
|
84
|
+
value(): T;
|
|
85
|
+
cmp(cmp: '==' | '>' | '>=' | '<' | '<=', rhs: T): CompareExpression<T>;
|
|
86
|
+
equals(rhs: T): CompareExpression<T>;
|
|
18
87
|
toString(): string;
|
|
19
|
-
|
|
88
|
+
toSpec(): ParamSpec<T>;
|
|
89
|
+
}
|
|
90
|
+
export declare class SecretParam {
|
|
91
|
+
name: string;
|
|
92
|
+
static type: ParamValueType;
|
|
93
|
+
constructor(name: string);
|
|
94
|
+
value(): string;
|
|
20
95
|
toSpec(): ParamSpec<string>;
|
|
21
96
|
}
|
|
22
97
|
export declare class StringParam extends Param<string> {
|
|
98
|
+
value(): string;
|
|
23
99
|
}
|
|
24
100
|
export declare class IntParam extends Param<number> {
|
|
25
|
-
static
|
|
26
|
-
|
|
101
|
+
static type: ParamValueType;
|
|
102
|
+
value(): number;
|
|
27
103
|
}
|
|
28
104
|
export declare class FloatParam extends Param<number> {
|
|
29
|
-
static
|
|
30
|
-
|
|
105
|
+
static type: ParamValueType;
|
|
106
|
+
value(): number;
|
|
31
107
|
}
|
|
32
|
-
export declare class BooleanParam extends Param {
|
|
33
|
-
static
|
|
34
|
-
|
|
108
|
+
export declare class BooleanParam extends Param<boolean> {
|
|
109
|
+
static type: ParamValueType;
|
|
110
|
+
value(): boolean;
|
|
111
|
+
then<T extends string | number | boolean>(ifTrue: T, ifFalse: T): TernaryExpression<T>;
|
|
35
112
|
}
|
|
36
113
|
export declare class ListParam extends Param<string[]> {
|
|
37
|
-
static
|
|
38
|
-
|
|
39
|
-
toSpec(): ParamSpec<string>;
|
|
40
|
-
}
|
|
41
|
-
export declare class JSONParam<T = any> extends Param<T> {
|
|
42
|
-
static valueType: ParamValueType;
|
|
43
|
-
get value(): T;
|
|
114
|
+
static type: ParamValueType;
|
|
115
|
+
value(): string[];
|
|
116
|
+
toSpec(): ParamSpec<string[]>;
|
|
44
117
|
}
|
|
45
118
|
export {};
|