firebase-functions 3.21.1 → 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.
Files changed (49) hide show
  1. package/lib/bin/firebase-functions.js +2 -1
  2. package/lib/cloud-functions.d.ts +1 -48
  3. package/lib/cloud-functions.js +2 -59
  4. package/lib/common/change.d.ts +46 -0
  5. package/lib/common/change.js +82 -0
  6. package/lib/common/providers/database.d.ts +145 -0
  7. package/lib/common/providers/database.js +271 -0
  8. package/lib/common/providers/identity.js +12 -7
  9. package/lib/common/providers/tasks.d.ts +8 -7
  10. package/lib/common/providers/tasks.js +13 -12
  11. package/lib/common/timezone.d.ts +2 -0
  12. package/lib/common/timezone.js +543 -0
  13. package/lib/function-builder.d.ts +2 -2
  14. package/lib/function-builder.js +2 -2
  15. package/lib/function-configuration.d.ts +6 -5
  16. package/lib/providers/database.d.ts +4 -146
  17. package/lib/providers/database.js +7 -251
  18. package/lib/providers/firestore.d.ts +2 -1
  19. package/lib/providers/firestore.js +2 -1
  20. package/lib/runtime/loader.js +6 -1
  21. package/lib/runtime/manifest.d.ts +19 -16
  22. package/lib/runtime/manifest.js +24 -0
  23. package/lib/utilities/path-pattern.d.ts +1 -0
  24. package/lib/utilities/path-pattern.js +142 -0
  25. package/lib/v2/core.d.ts +2 -0
  26. package/lib/v2/core.js +7 -0
  27. package/lib/v2/index.d.ts +4 -1
  28. package/lib/v2/index.js +7 -1
  29. package/lib/v2/options.d.ts +16 -6
  30. package/lib/v2/options.js +2 -2
  31. package/lib/v2/params/index.d.ts +14 -12
  32. package/lib/v2/params/index.js +25 -15
  33. package/lib/v2/params/types.d.ts +97 -24
  34. package/lib/v2/params/types.js +127 -67
  35. package/lib/v2/providers/alerts/alerts.d.ts +7 -6
  36. package/lib/v2/providers/alerts/appDistribution.d.ts +50 -5
  37. package/lib/v2/providers/alerts/appDistribution.js +23 -1
  38. package/lib/v2/providers/alerts/crashlytics.d.ts +6 -5
  39. package/lib/v2/providers/database.d.ts +183 -0
  40. package/lib/v2/providers/database.js +204 -0
  41. package/lib/v2/providers/eventarc.d.ts +6 -5
  42. package/lib/v2/providers/https.d.ts +6 -5
  43. package/lib/v2/providers/identity.d.ts +8 -7
  44. package/lib/v2/providers/pubsub.d.ts +6 -5
  45. package/lib/v2/providers/scheduler.d.ts +63 -0
  46. package/lib/v2/providers/scheduler.js +98 -0
  47. package/lib/v2/providers/storage.d.ts +6 -5
  48. package/lib/v2/providers/tasks.d.ts +7 -6
  49. package/package.json +18 -8
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ // The MIT License (MIT)
3
+ //
4
+ // Copyright (c) 2022 Firebase
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to deal
8
+ // in the Software without restriction, including without limitation the rights
9
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ // copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in all
14
+ // copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ // SOFTWARE.
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.PathPattern = exports.trimParam = void 0;
25
+ const path_1 = require("./path");
26
+ /** https://cloud.google.com/eventarc/docs/path-patterns */
27
+ /** @hidden */
28
+ const WILDCARD_CAPTURE_REGEX = new RegExp('{[^/{}]+}', 'g');
29
+ /** @internal */
30
+ function trimParam(param) {
31
+ const paramNoBraces = param.slice(1, -1);
32
+ if (paramNoBraces.includes('=')) {
33
+ return paramNoBraces.slice(0, paramNoBraces.indexOf('='));
34
+ }
35
+ return paramNoBraces;
36
+ }
37
+ exports.trimParam = trimParam;
38
+ /** @hidden */
39
+ class Segment {
40
+ constructor(value) {
41
+ this.value = value;
42
+ this.name = 'segment';
43
+ this.trimmed = value;
44
+ }
45
+ isSingleSegmentWildcard() {
46
+ return this.value.includes('*') && !this.isMultiSegmentWildcard();
47
+ }
48
+ isMultiSegmentWildcard() {
49
+ return this.value.includes('**');
50
+ }
51
+ }
52
+ /** @hidden */
53
+ class SingleCaptureSegment {
54
+ constructor(value) {
55
+ this.value = value;
56
+ this.name = 'single-capture';
57
+ this.trimmed = trimParam(value);
58
+ }
59
+ isSingleSegmentWildcard() {
60
+ return true;
61
+ }
62
+ isMultiSegmentWildcard() {
63
+ return false;
64
+ }
65
+ }
66
+ /** @hidden */
67
+ class MultiCaptureSegment {
68
+ constructor(value) {
69
+ this.value = value;
70
+ this.name = 'multi-capture';
71
+ this.trimmed = trimParam(value);
72
+ }
73
+ isSingleSegmentWildcard() {
74
+ return false;
75
+ }
76
+ isMultiSegmentWildcard() {
77
+ return true;
78
+ }
79
+ }
80
+ /**
81
+ * Implements Eventarc's path pattern from the spec https://cloud.google.com/eventarc/docs/path-patterns
82
+ * @internal
83
+ */
84
+ class PathPattern {
85
+ constructor(raw) {
86
+ this.raw = raw;
87
+ this.segments = [];
88
+ this.initPathSegments(raw);
89
+ }
90
+ /** @throws on validation error */
91
+ static compile(rawPath) { }
92
+ getValue() {
93
+ return this.raw;
94
+ }
95
+ // If false, we don't need to use pathPattern as our eventarc match type.
96
+ hasWildcards() {
97
+ return this.segments.some((segment) => segment.isSingleSegmentWildcard() || segment.isMultiSegmentWildcard());
98
+ }
99
+ hasCaptures() {
100
+ return this.segments.some((segment) => segment.name == 'single-capture' || segment.name === 'multi-capture');
101
+ }
102
+ extractMatches(path) {
103
+ const matches = {};
104
+ if (!this.hasCaptures()) {
105
+ return matches;
106
+ }
107
+ const pathSegments = (0, path_1.pathParts)(path);
108
+ let pathNdx = 0;
109
+ for (let segmentNdx = 0; segmentNdx < this.segments.length && pathNdx < pathSegments.length; segmentNdx++) {
110
+ const segment = this.segments[segmentNdx];
111
+ const remainingSegments = this.segments.length - 1 - segmentNdx;
112
+ const nextPathNdx = pathSegments.length - remainingSegments;
113
+ if (segment.name === 'single-capture') {
114
+ matches[segment.trimmed] = pathSegments[pathNdx];
115
+ }
116
+ else if (segment.name === 'multi-capture') {
117
+ matches[segment.trimmed] = pathSegments
118
+ .slice(pathNdx, nextPathNdx)
119
+ .join('/');
120
+ }
121
+ pathNdx = segment.isMultiSegmentWildcard() ? nextPathNdx : pathNdx + 1;
122
+ }
123
+ return matches;
124
+ }
125
+ initPathSegments(raw) {
126
+ const parts = (0, path_1.pathParts)(raw);
127
+ for (const part of parts) {
128
+ let segment;
129
+ const capture = part.match(WILDCARD_CAPTURE_REGEX);
130
+ if (capture && capture.length === 1) {
131
+ segment = part.includes('**')
132
+ ? new MultiCaptureSegment(part)
133
+ : new SingleCaptureSegment(part);
134
+ }
135
+ else {
136
+ segment = new Segment(part);
137
+ }
138
+ this.segments.push(segment);
139
+ }
140
+ }
141
+ }
142
+ exports.PathPattern = PathPattern;
package/lib/v2/core.d.ts CHANGED
@@ -2,7 +2,9 @@
2
2
  * Core functionality of the Firebase Functions v2 SDK.
3
3
  * @packageDocumentation
4
4
  */
5
+ import { Change } from '../common/change';
5
6
  import { ManifestEndpoint } from '../runtime/manifest';
7
+ export { Change };
6
8
  /**
7
9
  * A CloudEventBase is the base of a cross-platform format for encoding a serverless event.
8
10
  * More information can be found in https://github.com/cloudevents/spec
package/lib/v2/core.js CHANGED
@@ -21,3 +21,10 @@
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 = void 0;
25
+ /**
26
+ * Core functionality of the Firebase Functions v2 SDK.
27
+ * @packageDocumentation
28
+ */
29
+ const change_1 = require("../common/change");
30
+ Object.defineProperty(exports, "Change", { enumerable: true, get: function () { return change_1.Change; } });
package/lib/v2/index.d.ts CHANGED
@@ -7,12 +7,15 @@
7
7
  */
8
8
  import * as logger from '../logger';
9
9
  import * as alerts from './providers/alerts';
10
+ import * as database from './providers/database';
10
11
  import * as eventarc from './providers/eventarc';
11
12
  import * as https from './providers/https';
12
13
  import * as identity from './providers/identity';
13
14
  import * as pubsub from './providers/pubsub';
15
+ import * as scheduler from './providers/scheduler';
14
16
  import * as storage from './providers/storage';
15
17
  import * as tasks from './providers/tasks';
16
- export { alerts, storage, https, identity, pubsub, logger, tasks, eventarc };
18
+ export { alerts, database, storage, https, identity, pubsub, logger, tasks, eventarc, scheduler, };
17
19
  export { setGlobalOptions, GlobalOptions, SupportedRegion, MemoryOption, VpcEgressSetting, IngressSetting, EventHandlerOptions, } from './options';
20
+ export { Change } from '../common/change';
18
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.setGlobalOptions = exports.eventarc = exports.tasks = exports.logger = exports.pubsub = exports.identity = exports.https = exports.storage = 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
@@ -33,6 +33,8 @@ const logger = require("../logger");
33
33
  exports.logger = logger;
34
34
  const alerts = require("./providers/alerts");
35
35
  exports.alerts = alerts;
36
+ const database = require("./providers/database");
37
+ exports.database = database;
36
38
  const eventarc = require("./providers/eventarc");
37
39
  exports.eventarc = eventarc;
38
40
  const https = require("./providers/https");
@@ -41,9 +43,13 @@ const identity = require("./providers/identity");
41
43
  exports.identity = identity;
42
44
  const pubsub = require("./providers/pubsub");
43
45
  exports.pubsub = pubsub;
46
+ const scheduler = require("./providers/scheduler");
47
+ exports.scheduler = scheduler;
44
48
  const storage = require("./providers/storage");
45
49
  exports.storage = storage;
46
50
  const tasks = require("./providers/tasks");
47
51
  exports.tasks = tasks;
48
52
  var options_1 = require("./options");
49
53
  Object.defineProperty(exports, "setGlobalOptions", { enumerable: true, get: function () { return options_1.setGlobalOptions; } });
54
+ var change_1 = require("../common/change");
55
+ Object.defineProperty(exports, "Change", { enumerable: true, get: function () { return change_1.Change; } });
@@ -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') {
@@ -2,9 +2,20 @@
2
2
  * @hidden
3
3
  * @alpha
4
4
  */
5
- import { BooleanParam, FloatParam, IntParam, JSONParam, ListParam, Param, ParamOptions, StringParam } from './types';
6
- export { ParamOptions };
7
- export declare const declaredParams: Param[];
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;
@@ -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.defineJSON = exports.defineList = exports.defineFloat = exports.defineInt = exports.defineBoolean = exports.defineString = exports.declaredParams = void 0;
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;
@@ -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' | 'json';
3
- export interface ParamSpec<T = unknown> {
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
- valueType?: ParamValueType;
9
- }
10
- export declare type ParamOptions<T = unknown> = Omit<ParamSpec<T>, 'name' | 'valueType'>;
11
- export declare class Param<T = unknown> {
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 valueType: ParamValueType;
82
+ static type: ParamValueType;
15
83
  constructor(name: string, options?: ParamOptions<T>);
16
- get rawValue(): string | undefined;
17
- get value(): any;
84
+ value(): T;
85
+ cmp(cmp: '==' | '>' | '>=' | '<' | '<=', rhs: T): CompareExpression<T>;
86
+ equals(rhs: T): CompareExpression<T>;
18
87
  toString(): string;
19
- toJSON(): string;
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 valueType: ParamValueType;
26
- get value(): number;
101
+ static type: ParamValueType;
102
+ value(): number;
27
103
  }
28
104
  export declare class FloatParam extends Param<number> {
29
- static valueType: ParamValueType;
30
- get value(): number;
105
+ static type: ParamValueType;
106
+ value(): number;
31
107
  }
32
- export declare class BooleanParam extends Param {
33
- static valueType: ParamValueType;
34
- get value(): boolean;
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 valueType: ParamValueType;
38
- get value(): string[];
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 {};