firebase-functions 3.24.0 → 4.0.0-rc.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 (130) hide show
  1. package/README.md +7 -9
  2. package/lib/bin/firebase-functions.js +13 -15
  3. package/lib/common/app.d.ts +14 -0
  4. package/lib/common/app.js +62 -0
  5. package/lib/common/change.d.ts +0 -5
  6. package/lib/common/change.js +5 -7
  7. package/lib/common/config.d.ts +6 -0
  8. package/lib/common/config.js +49 -0
  9. package/lib/common/debug.js +2 -2
  10. package/lib/common/encoding.d.ts +0 -8
  11. package/lib/common/encoding.js +6 -29
  12. package/lib/common/options.d.ts +14 -0
  13. package/lib/common/options.js +44 -0
  14. package/lib/common/params.d.ts +32 -0
  15. package/lib/common/params.js +23 -0
  16. package/lib/common/providers/database.d.ts +17 -19
  17. package/lib/common/providers/database.js +68 -39
  18. package/lib/common/providers/https.d.ts +11 -52
  19. package/lib/common/providers/https.js +115 -110
  20. package/lib/common/providers/identity.d.ts +8 -8
  21. package/lib/common/providers/identity.js +71 -79
  22. package/lib/common/providers/tasks.d.ts +11 -10
  23. package/lib/common/providers/tasks.js +10 -9
  24. package/lib/common/timezone.js +538 -538
  25. package/lib/common/trace.d.ts +14 -0
  26. package/lib/common/trace.js +69 -0
  27. package/lib/{encoder.d.ts → common/utilities/encoder.d.ts} +0 -0
  28. package/lib/{encoder.js → common/utilities/encoder.js} +1 -1
  29. package/lib/{utilities → common/utilities}/path-pattern.d.ts +0 -0
  30. package/lib/{utilities → common/utilities}/path-pattern.js +17 -16
  31. package/lib/{utilities → common/utilities}/path.d.ts +0 -0
  32. package/lib/{utilities → common/utilities}/path.js +5 -7
  33. package/lib/{utils.d.ts → common/utilities/utils.d.ts} +1 -1
  34. package/lib/{utils.js → common/utilities/utils.js} +18 -12
  35. package/lib/logger/common.d.ts +1 -3
  36. package/lib/logger/common.js +9 -14
  37. package/lib/logger/compat.js +9 -9
  38. package/lib/logger/index.d.ts +1 -1
  39. package/lib/logger/index.js +24 -30
  40. package/lib/{v2/params → params}/index.d.ts +22 -9
  41. package/lib/{v2/params → params}/index.js +22 -14
  42. package/lib/params/types.d.ts +180 -0
  43. package/lib/params/types.js +289 -0
  44. package/lib/runtime/loader.js +12 -14
  45. package/lib/runtime/manifest.d.ts +56 -24
  46. package/lib/runtime/manifest.js +114 -4
  47. package/lib/v1/cloud-functions.d.ts +232 -0
  48. package/lib/v1/cloud-functions.js +205 -0
  49. package/lib/v1/config.d.ts +8 -0
  50. package/lib/v1/config.js +75 -0
  51. package/lib/{function-builder.d.ts → v1/function-builder.d.ts} +16 -16
  52. package/lib/{function-builder.js → v1/function-builder.js} +56 -46
  53. package/lib/v1/function-configuration.d.ts +197 -0
  54. package/lib/v1/function-configuration.js +70 -0
  55. package/lib/v1/index.d.ts +20 -0
  56. package/lib/{index.js → v1/index.js} +5 -10
  57. package/lib/{providers → v1/providers}/analytics.d.ts +5 -11
  58. package/lib/{providers → v1/providers}/analytics.js +49 -43
  59. package/lib/{providers → v1/providers}/auth.d.ts +28 -18
  60. package/lib/{providers → v1/providers}/auth.js +45 -34
  61. package/lib/{providers → v1/providers}/database.d.ts +25 -42
  62. package/lib/{providers → v1/providers}/database.js +46 -46
  63. package/lib/{providers → v1/providers}/firestore.d.ts +15 -33
  64. package/lib/{providers → v1/providers}/firestore.js +40 -44
  65. package/lib/{providers → v1/providers}/https.d.ts +3 -8
  66. package/lib/{providers → v1/providers}/https.js +14 -22
  67. package/lib/{providers → v1/providers}/pubsub.d.ts +8 -16
  68. package/lib/{providers → v1/providers}/pubsub.js +22 -26
  69. package/lib/{providers → v1/providers}/remoteConfig.d.ts +2 -11
  70. package/lib/{providers → v1/providers}/remoteConfig.js +9 -9
  71. package/lib/{providers → v1/providers}/storage.d.ts +11 -26
  72. package/lib/{providers → v1/providers}/storage.js +24 -29
  73. package/lib/{providers → v1/providers}/tasks.d.ts +6 -8
  74. package/lib/{providers → v1/providers}/tasks.js +12 -17
  75. package/lib/{providers → v1/providers}/testLab.d.ts +86 -46
  76. package/lib/{providers → v1/providers}/testLab.js +14 -14
  77. package/lib/v2/core.d.ts +4 -5
  78. package/lib/v2/index.d.ts +16 -14
  79. package/lib/v2/index.js +5 -1
  80. package/lib/v2/options.d.ts +52 -32
  81. package/lib/v2/options.js +32 -47
  82. package/lib/v2/providers/alerts/alerts.d.ts +20 -18
  83. package/lib/v2/providers/alerts/alerts.js +9 -6
  84. package/lib/v2/providers/alerts/appDistribution.d.ts +36 -26
  85. package/lib/v2/providers/alerts/appDistribution.js +10 -7
  86. package/lib/v2/providers/alerts/billing.d.ts +5 -5
  87. package/lib/v2/providers/alerts/billing.js +5 -4
  88. package/lib/v2/providers/alerts/crashlytics.d.ts +32 -30
  89. package/lib/v2/providers/alerts/crashlytics.js +10 -9
  90. package/lib/v2/providers/alerts/index.d.ts +5 -5
  91. package/lib/v2/providers/alerts/performance.d.ts +15 -3
  92. package/lib/v2/providers/alerts/performance.js +5 -7
  93. package/lib/v2/providers/database.d.ts +41 -38
  94. package/lib/v2/providers/database.js +22 -17
  95. package/lib/v2/providers/eventarc.d.ts +25 -23
  96. package/lib/v2/providers/eventarc.js +10 -7
  97. package/lib/v2/providers/https.d.ts +43 -33
  98. package/lib/v2/providers/https.js +18 -56
  99. package/lib/v2/providers/identity.d.ts +25 -23
  100. package/lib/v2/providers/identity.js +10 -7
  101. package/lib/v2/providers/pubsub.d.ts +25 -23
  102. package/lib/v2/providers/pubsub.js +11 -27
  103. package/lib/v2/providers/remoteConfig.d.ts +63 -0
  104. package/lib/v2/providers/remoteConfig.js +65 -0
  105. package/lib/v2/providers/scheduler.d.ts +14 -12
  106. package/lib/v2/providers/scheduler.js +16 -14
  107. package/lib/v2/providers/storage.d.ts +32 -30
  108. package/lib/v2/providers/storage.js +16 -32
  109. package/lib/v2/providers/tasks.d.ts +30 -26
  110. package/lib/v2/providers/tasks.js +14 -31
  111. package/lib/v2/providers/testLab.d.ts +110 -0
  112. package/lib/v2/providers/testLab.js +65 -0
  113. package/lib/v2/trace.d.ts +4 -0
  114. package/lib/v2/trace.js +21 -0
  115. package/package.json +62 -67
  116. package/lib/apps.d.ts +0 -35
  117. package/lib/apps.js +0 -112
  118. package/lib/cloud-functions.d.ts +0 -231
  119. package/lib/cloud-functions.js +0 -251
  120. package/lib/config.d.ts +0 -24
  121. package/lib/config.js +0 -117
  122. package/lib/function-configuration.d.ts +0 -108
  123. package/lib/function-configuration.js +0 -71
  124. package/lib/handler-builder.d.ts +0 -256
  125. package/lib/handler-builder.js +0 -349
  126. package/lib/index.d.ts +0 -19
  127. package/lib/setup.d.ts +0 -1
  128. package/lib/setup.js +0 -60
  129. package/lib/v2/params/types.d.ts +0 -118
  130. package/lib/v2/params/types.js +0 -196
@@ -1,16 +1,16 @@
1
- import * as express from 'express';
2
- import { CloudFunction, EventContext } from './cloud-functions';
3
- import { DeploymentOptions, RuntimeOptions, SUPPORTED_REGIONS } from './function-configuration';
4
- import * as analytics from './providers/analytics';
5
- import * as auth from './providers/auth';
6
- import * as database from './providers/database';
7
- import * as firestore from './providers/firestore';
8
- import * as https from './providers/https';
9
- import * as pubsub from './providers/pubsub';
10
- import * as remoteConfig from './providers/remoteConfig';
11
- import * as storage from './providers/storage';
12
- import * as tasks from './providers/tasks';
13
- import * as testLab from './providers/testLab';
1
+ import * as express from "express";
2
+ import { EventContext } from "./cloud-functions";
3
+ import { DeploymentOptions, RuntimeOptions, SUPPORTED_REGIONS } from "./function-configuration";
4
+ import * as analytics from "./providers/analytics";
5
+ import * as auth from "./providers/auth";
6
+ import * as database from "./providers/database";
7
+ import * as firestore from "./providers/firestore";
8
+ import * as https from "./providers/https";
9
+ import * as pubsub from "./providers/pubsub";
10
+ import * as remoteConfig from "./providers/remoteConfig";
11
+ import * as storage from "./providers/storage";
12
+ import * as tasks from "./providers/tasks";
13
+ import * as testLab from "./providers/testLab";
14
14
  /**
15
15
  * Configure the regions that the function is deployed to.
16
16
  * @param regions One of more region strings.
@@ -120,7 +120,7 @@ export declare class FunctionBuilder {
120
120
  * information about the user who triggered the Cloud Function.
121
121
  * @param ref Path of the database to listen to.
122
122
  */
123
- ref: (path: string) => database.RefBuilder;
123
+ ref: <Ref extends string>(path: Ref) => database.RefBuilder<Ref>;
124
124
  };
125
125
  get firestore(): {
126
126
  /**
@@ -130,7 +130,7 @@ export declare class FunctionBuilder {
130
130
  * collection is named "users" and the document is named "Ada", then the
131
131
  * path is "/users/Ada".
132
132
  */
133
- document: (path: string) => firestore.DocumentBuilder;
133
+ document: <Path extends string>(path: Path) => firestore.DocumentBuilder<Path>;
134
134
  /** @hidden */
135
135
  namespace: (namespace: string) => firestore.NamespaceBuilder;
136
136
  /** @hidden */
@@ -150,7 +150,7 @@ export declare class FunctionBuilder {
150
150
  * @param handler A function that takes the updated Remote Config template
151
151
  * version metadata as an argument.
152
152
  */
153
- onUpdate: (handler: (version: remoteConfig.TemplateVersion, context: EventContext) => PromiseLike<any> | any) => CloudFunction<remoteConfig.TemplateVersion>;
153
+ onUpdate: (handler: (version: remoteConfig.TemplateVersion, context: EventContext) => PromiseLike<any> | any) => import("./cloud-functions").CloudFunction<remoteConfig.TemplateVersion>;
154
154
  };
155
155
  get storage(): {
156
156
  /**
@@ -22,7 +22,8 @@
22
22
  // SOFTWARE.
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.FunctionBuilder = exports.runWith = exports.region = void 0;
25
- const _ = require("lodash");
25
+ const options_1 = require("../common/options");
26
+ const types_1 = require("../params/types");
26
27
  const function_configuration_1 = require("./function-configuration");
27
28
  const analytics = require("./providers/analytics");
28
29
  const auth = require("./providers/auth");
@@ -40,37 +41,29 @@ const testLab = require("./providers/testLab");
40
41
  * @throws { Error } Memory and TimeoutSeconds values must be valid.
41
42
  */
42
43
  function assertRuntimeOptionsValid(runtimeOptions) {
43
- if (runtimeOptions.memory &&
44
- !_.includes(function_configuration_1.VALID_MEMORY_OPTIONS, runtimeOptions.memory)) {
45
- throw new Error(`The only valid memory allocation values are: ${function_configuration_1.VALID_MEMORY_OPTIONS.join(', ')}`);
44
+ const mem = runtimeOptions.memory;
45
+ if (mem && typeof mem !== "object" && !function_configuration_1.VALID_MEMORY_OPTIONS.includes(mem)) {
46
+ throw new Error(`The only valid memory allocation values are: ${function_configuration_1.VALID_MEMORY_OPTIONS.join(", ")}`);
46
47
  }
47
- if (runtimeOptions.timeoutSeconds > function_configuration_1.MAX_TIMEOUT_SECONDS ||
48
- runtimeOptions.timeoutSeconds < 0) {
48
+ if (runtimeOptions.timeoutSeconds > function_configuration_1.MAX_TIMEOUT_SECONDS || runtimeOptions.timeoutSeconds < 0) {
49
49
  throw new Error(`TimeoutSeconds must be between 0 and ${function_configuration_1.MAX_TIMEOUT_SECONDS}`);
50
50
  }
51
51
  if (runtimeOptions.ingressSettings &&
52
- !_.includes(function_configuration_1.INGRESS_SETTINGS_OPTIONS, runtimeOptions.ingressSettings)) {
53
- throw new Error(`The only valid ingressSettings values are: ${function_configuration_1.INGRESS_SETTINGS_OPTIONS.join(',')}`);
52
+ !(runtimeOptions.ingressSettings instanceof options_1.ResetValue) &&
53
+ !function_configuration_1.INGRESS_SETTINGS_OPTIONS.includes(runtimeOptions.ingressSettings)) {
54
+ throw new Error(`The only valid ingressSettings values are: ${function_configuration_1.INGRESS_SETTINGS_OPTIONS.join(",")}`);
54
55
  }
55
56
  if (runtimeOptions.vpcConnectorEgressSettings &&
56
- !_.includes(function_configuration_1.VPC_EGRESS_SETTINGS_OPTIONS, runtimeOptions.vpcConnectorEgressSettings)) {
57
- throw new Error(`The only valid vpcConnectorEgressSettings values are: ${function_configuration_1.VPC_EGRESS_SETTINGS_OPTIONS.join(',')}`);
57
+ !(runtimeOptions.vpcConnectorEgressSettings instanceof options_1.ResetValue) &&
58
+ !function_configuration_1.VPC_EGRESS_SETTINGS_OPTIONS.includes(runtimeOptions.vpcConnectorEgressSettings)) {
59
+ throw new Error(`The only valid vpcConnectorEgressSettings values are: ${function_configuration_1.VPC_EGRESS_SETTINGS_OPTIONS.join(",")}`);
58
60
  }
59
- if (runtimeOptions.failurePolicy !== undefined) {
60
- if (_.isBoolean(runtimeOptions.failurePolicy) === false &&
61
- _.isObjectLike(runtimeOptions.failurePolicy) === false) {
62
- throw new Error(`failurePolicy must be a boolean or an object.`);
63
- }
64
- if (typeof runtimeOptions.failurePolicy === 'object') {
65
- if (_.isObjectLike(runtimeOptions.failurePolicy.retry) === false ||
66
- _.isEmpty(runtimeOptions.failurePolicy.retry) === false) {
67
- throw new Error('failurePolicy.retry must be an empty object.');
68
- }
69
- }
70
- }
71
- if (runtimeOptions.serviceAccount &&
72
- runtimeOptions.serviceAccount !== 'default' &&
73
- !_.includes(runtimeOptions.serviceAccount, '@')) {
61
+ validateFailurePolicy(runtimeOptions.failurePolicy);
62
+ const serviceAccount = runtimeOptions.serviceAccount;
63
+ if (serviceAccount &&
64
+ serviceAccount !== "default" &&
65
+ !(serviceAccount instanceof options_1.ResetValue) &&
66
+ !serviceAccount.includes("@")) {
74
67
  throw new Error(`serviceAccount must be set to 'default', a service account email, or '{serviceAccountName}@'`);
75
68
  }
76
69
  if (runtimeOptions.labels) {
@@ -80,61 +73,75 @@ function assertRuntimeOptionsValid(runtimeOptions) {
80
73
  throw new Error(`A function must not have more than ${function_configuration_1.MAX_NUMBER_USER_LABELS} user-defined labels.`);
81
74
  }
82
75
  // We reserve the 'deployment' and 'firebase' namespaces for future feature development.
83
- const reservedKeys = Object.keys(runtimeOptions.labels).filter((key) => key.startsWith('deployment') || key.startsWith('firebase'));
76
+ const reservedKeys = Object.keys(runtimeOptions.labels).filter((key) => key.startsWith("deployment") || key.startsWith("firebase"));
84
77
  if (reservedKeys.length) {
85
- throw new Error(`Invalid labels: ${reservedKeys.join(', ')}. Labels may not start with reserved names 'deployment' or 'firebase'`);
78
+ throw new Error(`Invalid labels: ${reservedKeys.join(", ")}. Labels may not start with reserved names 'deployment' or 'firebase'`);
86
79
  }
87
80
  const invalidLengthKeys = Object.keys(runtimeOptions.labels).filter((key) => key.length < 1 || key.length > 63);
88
81
  if (invalidLengthKeys.length > 0) {
89
- throw new Error(`Invalid labels: ${invalidLengthKeys.join(', ')}. Label keys must be between 1 and 63 characters in length.`);
82
+ throw new Error(`Invalid labels: ${invalidLengthKeys.join(", ")}. Label keys must be between 1 and 63 characters in length.`);
90
83
  }
91
84
  const invalidLengthValues = Object.values(runtimeOptions.labels).filter((value) => value.length > 63);
92
85
  if (invalidLengthValues.length > 0) {
93
- throw new Error(`Invalid labels: ${invalidLengthValues.join(', ')}. Label values must be less than 64 charcters.`);
86
+ throw new Error(`Invalid labels: ${invalidLengthValues.join(", ")}. Label values must be less than 64 charcters.`);
94
87
  }
95
88
  // Keys can contain lowercase letters, foreign characters, numbers, _ or -. They must start with a letter.
96
89
  const validKeyPattern = /^[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}$/u;
97
90
  const invalidKeys = Object.keys(runtimeOptions.labels).filter((key) => !validKeyPattern.test(key));
98
91
  if (invalidKeys.length > 0) {
99
- throw new Error(`Invalid labels: ${invalidKeys.join(', ')}. Label keys can only contain lowercase letters, international characters, numbers, _ or -, and must start with a letter.`);
92
+ throw new Error(`Invalid labels: ${invalidKeys.join(", ")}. Label keys can only contain lowercase letters, international characters, numbers, _ or -, and must start with a letter.`);
100
93
  }
101
94
  // Values can contain lowercase letters, foreign characters, numbers, _ or -.
102
95
  const validValuePattern = /^[\p{Ll}\p{Lo}\p{N}_-]{0,63}$/u;
103
96
  const invalidValues = Object.values(runtimeOptions.labels).filter((value) => !validValuePattern.test(value));
104
97
  if (invalidValues.length > 0) {
105
- throw new Error(`Invalid labels: ${invalidValues.join(', ')}. Label values can only contain lowercase letters, international characters, numbers, _ or -.`);
98
+ throw new Error(`Invalid labels: ${invalidValues.join(", ")}. Label values can only contain lowercase letters, international characters, numbers, _ or -.`);
106
99
  }
107
100
  }
108
- if (typeof runtimeOptions.invoker === 'string' &&
109
- runtimeOptions.invoker.length === 0) {
110
- throw new Error('Invalid service account for function invoker, must be a non-empty string');
101
+ if (typeof runtimeOptions.invoker === "string" && runtimeOptions.invoker.length === 0) {
102
+ throw new Error("Invalid service account for function invoker, must be a non-empty string");
111
103
  }
112
- if (runtimeOptions.invoker !== undefined &&
113
- Array.isArray(runtimeOptions.invoker)) {
104
+ if (runtimeOptions.invoker !== undefined && Array.isArray(runtimeOptions.invoker)) {
114
105
  if (runtimeOptions.invoker.length === 0) {
115
- throw new Error('Invalid invoker array, must contain at least 1 service account entry');
106
+ throw new Error("Invalid invoker array, must contain at least 1 service account entry");
116
107
  }
117
108
  for (const serviceAccount of runtimeOptions.invoker) {
118
109
  if (serviceAccount.length === 0) {
119
- throw new Error('Invalid invoker array, a service account must be a non-empty string');
110
+ throw new Error("Invalid invoker array, a service account must be a non-empty string");
120
111
  }
121
- if (serviceAccount === 'public') {
112
+ if (serviceAccount === "public") {
122
113
  throw new Error("Invalid invoker array, a service account cannot be set to the 'public' identifier");
123
114
  }
124
- if (serviceAccount === 'private') {
115
+ if (serviceAccount === "private") {
125
116
  throw new Error("Invalid invoker array, a service account cannot be set to the 'private' identifier");
126
117
  }
127
118
  }
128
119
  }
129
120
  if (runtimeOptions.secrets !== undefined) {
130
- const invalidSecrets = runtimeOptions.secrets.filter((s) => !/^[A-Za-z\d\-_]+$/.test(s));
121
+ const invalidSecrets = runtimeOptions.secrets.filter((s) => !/^[A-Za-z\d\-_]+$/.test(s instanceof types_1.SecretParam ? s.name : s));
131
122
  if (invalidSecrets.length > 0) {
132
- throw new Error(`Invalid secrets: ${invalidSecrets.join(',')}. ` +
133
- 'Secret must be configured using the resource id (e.g. API_KEY)');
123
+ throw new Error(`Invalid secrets: ${invalidSecrets.join(",")}. ` +
124
+ "Secret must be configured using the resource id (e.g. API_KEY)");
134
125
  }
135
126
  }
127
+ if ("allowInvalidAppCheckToken" in runtimeOptions) {
128
+ throw new Error('runWith option "allowInvalidAppCheckToken" has been inverted and ' +
129
+ 'renamed "enforceAppCheck"');
130
+ }
136
131
  return true;
137
132
  }
133
+ function validateFailurePolicy(policy) {
134
+ if (typeof policy === "boolean" || typeof policy === "undefined") {
135
+ return;
136
+ }
137
+ if (typeof policy !== "object") {
138
+ throw new Error(`failurePolicy must be a boolean or an object.`);
139
+ }
140
+ const retry = policy.retry;
141
+ if (typeof retry !== "object" || Object.keys(retry).length) {
142
+ throw new Error("failurePolicy.retry must be an empty object.");
143
+ }
144
+ }
138
145
  /**
139
146
  * Assert regions specified are valid.
140
147
  * @param regions list of regions.
@@ -142,7 +149,7 @@ function assertRuntimeOptionsValid(runtimeOptions) {
142
149
  */
143
150
  function assertRegionsAreValid(regions) {
144
151
  if (!regions.length) {
145
- throw new Error('You must specify at least one region');
152
+ throw new Error("You must specify at least one region");
146
153
  }
147
154
  return true;
148
155
  }
@@ -219,13 +226,16 @@ class FunctionBuilder {
219
226
  */
220
227
  runWith(runtimeOptions) {
221
228
  if (assertRuntimeOptionsValid(runtimeOptions)) {
222
- this.options = _.assign(this.options, runtimeOptions);
229
+ this.options = {
230
+ ...this.options,
231
+ ...runtimeOptions,
232
+ };
223
233
  return this;
224
234
  }
225
235
  }
226
236
  get https() {
227
237
  if (this.options.failurePolicy !== undefined) {
228
- console.warn('RuntimeOptions.failurePolicy is not supported in https functions.');
238
+ console.warn("RuntimeOptions.failurePolicy is not supported in https functions.");
229
239
  }
230
240
  return {
231
241
  /**
@@ -0,0 +1,197 @@
1
+ import { Expression } from "../params";
2
+ import { ResetValue } from "../common/options";
3
+ import { SecretParam } from "../params/types";
4
+ export { RESET_VALUE } from "../common/options";
5
+ /**
6
+ * List of all regions supported by Cloud Functions.
7
+ */
8
+ export declare const SUPPORTED_REGIONS: readonly ["us-central1", "us-east1", "us-east4", "us-west2", "us-west3", "us-west4", "europe-central2", "europe-west1", "europe-west2", "europe-west3", "europe-west6", "asia-east1", "asia-east2", "asia-northeast1", "asia-northeast2", "asia-northeast3", "asia-south1", "asia-southeast1", "asia-southeast2", "northamerica-northeast1", "southamerica-east1", "australia-southeast1"];
9
+ /**
10
+ * Cloud Functions min timeout value.
11
+ */
12
+ export declare const MIN_TIMEOUT_SECONDS = 0;
13
+ /**
14
+ * Cloud Functions max timeout value.
15
+ */
16
+ export declare const MAX_TIMEOUT_SECONDS = 540;
17
+ /**
18
+ * List of available memory options supported by Cloud Functions.
19
+ */
20
+ export declare const VALID_MEMORY_OPTIONS: readonly ["128MB", "256MB", "512MB", "1GB", "2GB", "4GB", "8GB"];
21
+ /**
22
+ * List of available options for VpcConnectorEgressSettings.
23
+ */
24
+ export declare const VPC_EGRESS_SETTINGS_OPTIONS: readonly ["VPC_CONNECTOR_EGRESS_SETTINGS_UNSPECIFIED", "PRIVATE_RANGES_ONLY", "ALL_TRAFFIC"];
25
+ /**
26
+ * List of available options for IngressSettings.
27
+ */
28
+ export declare const INGRESS_SETTINGS_OPTIONS: readonly ["INGRESS_SETTINGS_UNSPECIFIED", "ALLOW_ALL", "ALLOW_INTERNAL_ONLY", "ALLOW_INTERNAL_AND_GCLB"];
29
+ /**
30
+ * Scheduler retry options. Applies only to scheduled functions.
31
+ */
32
+ export interface ScheduleRetryConfig {
33
+ /**
34
+ * The number of attempts that the system will make to run a job using the exponential backoff procedure described by {@link ScheduleRetryConfig.maxDoublings}.
35
+ *
36
+ * @defaultValue 0 (infinite retry)
37
+ */
38
+ retryCount?: number | Expression<number> | ResetValue;
39
+ /**
40
+ * The time limit for retrying a failed job, measured from time when an execution was first attempted.
41
+ *
42
+ * If specified with {@link ScheduleRetryConfig.retryCount}, the job will be retried until both limits are reached.
43
+ *
44
+ * @defaultValue 0
45
+ */
46
+ maxRetryDuration?: string | Expression<string> | ResetValue;
47
+ /**
48
+ * The minimum amount of time to wait before retrying a job after it fails.
49
+ *
50
+ * @defaultValue 5 seconds
51
+ */
52
+ minBackoffDuration?: string | Expression<string> | ResetValue;
53
+ /**
54
+ * The maximum amount of time to wait before retrying a job after it fails.
55
+ *
56
+ * @defaultValue 1 hour
57
+ */
58
+ maxBackoffDuration?: string | Expression<string> | ResetValue;
59
+ /**
60
+ * The max number of backoff doubling applied at each retry.
61
+ *
62
+ * @defaultValue 5
63
+ */
64
+ maxDoublings?: number | Expression<number> | ResetValue;
65
+ }
66
+ /**
67
+ * Configuration options for scheduled functions.
68
+ */
69
+ export interface Schedule {
70
+ /**
71
+ * Describes the schedule on which the job will be executed.
72
+ *
73
+ * The schedule can be either of the following types:
74
+ *
75
+ * 1. {@link https://en.wikipedia.org/wiki/Cron#Overview | Crontab}
76
+ *
77
+ * 2. English-like {@link https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules | schedule}
78
+ *
79
+ * @example
80
+ * ```
81
+ * // Crontab schedule
82
+ * schedule: "0 9 * * 1"` // Every Monday at 09:00 AM
83
+ *
84
+ * // English-like schedule
85
+ * schedule: "every 5 minutes"
86
+ * ```
87
+ */
88
+ schedule: string;
89
+ /**
90
+ * Specifies the time zone to be used in interpreting {@link Schedule.schedule}.
91
+ *
92
+ * The value of this field must be a time zone name from the tz database.
93
+ */
94
+ timeZone?: string | ResetValue;
95
+ /**
96
+ * Settings that determine the retry behavior.
97
+ */
98
+ retryConfig?: ScheduleRetryConfig;
99
+ }
100
+ /**
101
+ * Configuration option for failure policy on background functions.
102
+ */
103
+ export interface FailurePolicy {
104
+ /**
105
+ * Retry configuration. Must be an empty object.
106
+ *
107
+ */
108
+ retry: Record<string, never>;
109
+ }
110
+ export declare const MAX_NUMBER_USER_LABELS = 58;
111
+ /**
112
+ * Configuration options for a function that applicable at runtime.
113
+ */
114
+ export interface RuntimeOptions {
115
+ /**
116
+ * Failure policy of the function, with boolean `true` being equivalent to
117
+ * providing an empty retry object.
118
+ */
119
+ failurePolicy?: FailurePolicy | boolean;
120
+ /**
121
+ * Amount of memory to allocate to the function.
122
+ */
123
+ memory?: typeof VALID_MEMORY_OPTIONS[number] | Expression<number> | ResetValue;
124
+ /**
125
+ * Timeout for the function in seconds, possible values are 0 to 540.
126
+ */
127
+ timeoutSeconds?: number | Expression<number> | ResetValue;
128
+ /**
129
+ * Min number of actual instances to be running at a given time.
130
+ *
131
+ * @remarks
132
+ * Instances will be billed for memory allocation and 10% of CPU allocation
133
+ * while idle.
134
+ */
135
+ minInstances?: number | Expression<number> | ResetValue;
136
+ /**
137
+ * Max number of actual instances allowed to be running in parallel.
138
+ */
139
+ maxInstances?: number | Expression<number> | ResetValue;
140
+ /**
141
+ * Connect cloud function to specified VPC connector.
142
+ */
143
+ vpcConnector?: string | ResetValue;
144
+ /**
145
+ * Egress settings for VPC connector.
146
+ */
147
+ vpcConnectorEgressSettings?: typeof VPC_EGRESS_SETTINGS_OPTIONS[number] | ResetValue;
148
+ /**
149
+ * Specific service account for the function to run as.
150
+ */
151
+ serviceAccount?: "default" | string | ResetValue;
152
+ /**
153
+ * Ingress settings which control where this function can be called from.
154
+ */
155
+ ingressSettings?: typeof INGRESS_SETTINGS_OPTIONS[number] | ResetValue;
156
+ /**
157
+ * User labels to set on the function.
158
+ */
159
+ labels?: Record<string, string>;
160
+ /**
161
+ * Invoker to set access control on https functions.
162
+ */
163
+ invoker?: "public" | "private" | string | string[];
164
+ secrets?: (string | SecretParam)[];
165
+ /**
166
+ * Determines whether Firebase AppCheck is enforced.
167
+ *
168
+ * @remarks
169
+ * When true, requests with invalid tokens autorespond with a 401
170
+ * (Unauthorized) error.
171
+ * When false, requests with invalid tokens set context.app to undefiend.
172
+ */
173
+ enforceAppCheck?: boolean;
174
+ }
175
+ /**
176
+ * Configuration options for a function that applies during function deployment.
177
+ */
178
+ export interface DeploymentOptions extends RuntimeOptions {
179
+ /**
180
+ * Regions where function should be deployed.
181
+ */
182
+ regions?: Array<typeof SUPPORTED_REGIONS[number] | string>;
183
+ /**
184
+ * Schedule for the scheduled function.
185
+ */
186
+ schedule?: Schedule;
187
+ /**
188
+ * Controls whether function configuration modified outside of function source is preserved. Defaults to false.
189
+ *
190
+ * @remarks
191
+ * When setting configuration available in the underlying platform that is not yet available in the Firebase Functions
192
+ * SDK, we highly recommend setting `preserveExternalChanges` to `true`. Otherwise, when the Firebase Functions SDK releases
193
+ * a new version of the SDK with support for the missing configuration, your function's manually configured setting
194
+ * may inadvertently be wiped out.
195
+ */
196
+ preserveExternalChanges?: boolean;
197
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_NUMBER_USER_LABELS = exports.INGRESS_SETTINGS_OPTIONS = exports.VPC_EGRESS_SETTINGS_OPTIONS = exports.VALID_MEMORY_OPTIONS = exports.MAX_TIMEOUT_SECONDS = exports.MIN_TIMEOUT_SECONDS = exports.SUPPORTED_REGIONS = exports.RESET_VALUE = void 0;
4
+ var options_1 = require("../common/options");
5
+ Object.defineProperty(exports, "RESET_VALUE", { enumerable: true, get: function () { return options_1.RESET_VALUE; } });
6
+ /**
7
+ * List of all regions supported by Cloud Functions.
8
+ */
9
+ exports.SUPPORTED_REGIONS = [
10
+ "us-central1",
11
+ "us-east1",
12
+ "us-east4",
13
+ "us-west2",
14
+ "us-west3",
15
+ "us-west4",
16
+ "europe-central2",
17
+ "europe-west1",
18
+ "europe-west2",
19
+ "europe-west3",
20
+ "europe-west6",
21
+ "asia-east1",
22
+ "asia-east2",
23
+ "asia-northeast1",
24
+ "asia-northeast2",
25
+ "asia-northeast3",
26
+ "asia-south1",
27
+ "asia-southeast1",
28
+ "asia-southeast2",
29
+ "northamerica-northeast1",
30
+ "southamerica-east1",
31
+ "australia-southeast1",
32
+ ];
33
+ /**
34
+ * Cloud Functions min timeout value.
35
+ */
36
+ exports.MIN_TIMEOUT_SECONDS = 0;
37
+ /**
38
+ * Cloud Functions max timeout value.
39
+ */
40
+ exports.MAX_TIMEOUT_SECONDS = 540;
41
+ /**
42
+ * List of available memory options supported by Cloud Functions.
43
+ */
44
+ exports.VALID_MEMORY_OPTIONS = [
45
+ "128MB",
46
+ "256MB",
47
+ "512MB",
48
+ "1GB",
49
+ "2GB",
50
+ "4GB",
51
+ "8GB",
52
+ ];
53
+ /**
54
+ * List of available options for VpcConnectorEgressSettings.
55
+ */
56
+ exports.VPC_EGRESS_SETTINGS_OPTIONS = [
57
+ "VPC_CONNECTOR_EGRESS_SETTINGS_UNSPECIFIED",
58
+ "PRIVATE_RANGES_ONLY",
59
+ "ALL_TRAFFIC",
60
+ ];
61
+ /**
62
+ * List of available options for IngressSettings.
63
+ */
64
+ exports.INGRESS_SETTINGS_OPTIONS = [
65
+ "INGRESS_SETTINGS_UNSPECIFIED",
66
+ "ALLOW_ALL",
67
+ "ALLOW_INTERNAL_ONLY",
68
+ "ALLOW_INTERNAL_AND_GCLB",
69
+ ];
70
+ exports.MAX_NUMBER_USER_LABELS = 58;
@@ -0,0 +1,20 @@
1
+ import * as logger from "../logger";
2
+ import * as analytics from "./providers/analytics";
3
+ import * as auth from "./providers/auth";
4
+ import * as database from "./providers/database";
5
+ import * as firestore from "./providers/firestore";
6
+ import * as https from "./providers/https";
7
+ import * as pubsub from "./providers/pubsub";
8
+ import * as remoteConfig from "./providers/remoteConfig";
9
+ import * as storage from "./providers/storage";
10
+ import * as tasks from "./providers/tasks";
11
+ import * as testLab from "./providers/testLab";
12
+ import { setApp as setEmulatedAdminApp } from "../common/app";
13
+ export { analytics, auth, database, firestore, https, pubsub, remoteConfig, storage, tasks, testLab, logger, };
14
+ export declare const app: {
15
+ setEmulatedAdminApp: typeof setEmulatedAdminApp;
16
+ };
17
+ export * from "./cloud-functions";
18
+ export * from "./config";
19
+ export * from "./function-builder";
20
+ export * from "./function-configuration";
@@ -35,8 +35,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
35
35
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.logger = exports.testLab = exports.tasks = exports.storage = exports.remoteConfig = exports.pubsub = exports.https = exports.handler = exports.firestore = exports.database = exports.auth = exports.app = exports.analytics = void 0;
38
+ exports.app = exports.logger = exports.testLab = exports.tasks = exports.storage = exports.remoteConfig = exports.pubsub = exports.https = exports.firestore = exports.database = exports.auth = exports.analytics = void 0;
39
39
  // Providers:
40
+ const logger = require("../logger");
41
+ exports.logger = logger;
40
42
  const analytics = require("./providers/analytics");
41
43
  exports.analytics = analytics;
42
44
  const auth = require("./providers/auth");
@@ -57,17 +59,10 @@ const tasks = require("./providers/tasks");
57
59
  exports.tasks = tasks;
58
60
  const testLab = require("./providers/testLab");
59
61
  exports.testLab = testLab;
60
- const apps = require("./apps");
61
- const handler_builder_1 = require("./handler-builder");
62
- Object.defineProperty(exports, "handler", { enumerable: true, get: function () { return handler_builder_1.handler; } });
63
- const logger = require("./logger");
64
- exports.logger = logger;
65
- const setup_1 = require("./setup");
66
- const app = apps.apps();
67
- exports.app = app;
62
+ const app_1 = require("../common/app");
63
+ exports.app = { setEmulatedAdminApp: app_1.setApp };
68
64
  // Exported root types:
69
65
  __exportStar(require("./cloud-functions"), exports);
70
66
  __exportStar(require("./config"), exports);
71
67
  __exportStar(require("./function-builder"), exports);
72
68
  __exportStar(require("./function-configuration"), exports);
73
- (0, setup_1.setup)();
@@ -1,24 +1,18 @@
1
- import { CloudFunction, EventContext } from '../cloud-functions';
2
- import { DeploymentOptions } from '../function-configuration';
3
- /** @hidden */
4
- export declare const provider = "google.analytics";
5
- /** @hidden */
6
- export declare const service = "app-measurement.com";
1
+ import { CloudFunction, EventContext } from "../cloud-functions";
2
+ import { DeploymentOptions } from "../function-configuration";
7
3
  /**
8
4
  * Registers a function to handle analytics events.
9
5
  *
10
6
  * @param analyticsEventType Name of the analytics event type to which
11
7
  * this Cloud Function is scoped.
12
8
  *
13
- * @return Analytics event builder interface.
9
+ * @returns Analytics event builder interface.
14
10
  */
15
11
  export declare function event(analyticsEventType: string): AnalyticsEventBuilder;
16
- /** @hidden */
17
- export declare function _eventWithOptions(analyticsEventType: string, options: DeploymentOptions): AnalyticsEventBuilder;
18
12
  /**
19
13
  * The Firebase Analytics event builder interface.
20
14
  *
21
- * Access via [`functions.analytics.event()`](functions.analytics#.event).
15
+ * Access via `functions.analytics.event()`.
22
16
  */
23
17
  export declare class AnalyticsEventBuilder {
24
18
  private triggerResource;
@@ -31,7 +25,7 @@ export declare class AnalyticsEventBuilder {
31
25
  * @param handler Event handler that fires every time a Firebase Analytics event
32
26
  * occurs.
33
27
  *
34
- * @return A function that you can export and deploy.
28
+ * @returns A function that you can export and deploy.
35
29
  */
36
30
  onLog(handler: (event: AnalyticsEvent, context: EventContext) => PromiseLike<any> | any): CloudFunction<AnalyticsEvent>;
37
31
  }