firebase-functions 3.21.0 → 3.22.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 (66) hide show
  1. package/lib/bin/firebase-functions.js +21 -0
  2. package/lib/cloud-functions.d.ts +54 -88
  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/encoding.js +21 -1
  7. package/lib/common/providers/database.d.ts +145 -0
  8. package/lib/common/providers/database.js +271 -0
  9. package/lib/common/providers/https.d.ts +37 -17
  10. package/lib/common/providers/https.js +3 -0
  11. package/lib/common/providers/identity.d.ts +5 -1
  12. package/lib/common/providers/identity.js +12 -4
  13. package/lib/common/providers/tasks.d.ts +9 -0
  14. package/lib/common/providers/tasks.js +13 -12
  15. package/lib/function-builder.d.ts +3 -3
  16. package/lib/function-builder.js +2 -2
  17. package/lib/logger/common.js +21 -0
  18. package/lib/logger/compat.js +21 -0
  19. package/lib/logger/index.d.ts +14 -6
  20. package/lib/logger/index.js +33 -6
  21. package/lib/providers/auth.d.ts +26 -5
  22. package/lib/providers/auth.js +18 -4
  23. package/lib/providers/database.d.ts +4 -146
  24. package/lib/providers/database.js +7 -251
  25. package/lib/providers/firestore.d.ts +2 -1
  26. package/lib/providers/firestore.js +2 -1
  27. package/lib/providers/pubsub.d.ts +6 -6
  28. package/lib/providers/pubsub.js +6 -6
  29. package/lib/providers/tasks.d.ts +29 -14
  30. package/lib/providers/tasks.js +10 -3
  31. package/lib/utilities/path-pattern.d.ts +1 -0
  32. package/lib/utilities/path-pattern.js +142 -0
  33. package/lib/v2/core.d.ts +25 -1
  34. package/lib/v2/core.js +7 -0
  35. package/lib/v2/index.d.ts +11 -3
  36. package/lib/v2/index.js +12 -3
  37. package/lib/v2/options.d.ts +13 -34
  38. package/lib/v2/options.js +6 -58
  39. package/lib/v2/params/index.d.ts +4 -1
  40. package/lib/v2/params/index.js +25 -1
  41. package/lib/v2/params/types.js +21 -0
  42. package/lib/v2/providers/alerts/alerts.d.ts +94 -3
  43. package/lib/v2/providers/alerts/alerts.js +23 -7
  44. package/lib/v2/providers/alerts/appDistribution.d.ts +101 -1
  45. package/lib/v2/providers/alerts/appDistribution.js +28 -1
  46. package/lib/v2/providers/alerts/billing.d.ts +23 -2
  47. package/lib/v2/providers/alerts/billing.js +37 -0
  48. package/lib/v2/providers/alerts/crashlytics.d.ts +193 -18
  49. package/lib/v2/providers/alerts/crashlytics.js +62 -1
  50. package/lib/v2/providers/alerts/index.d.ts +6 -0
  51. package/lib/v2/providers/alerts/index.js +27 -0
  52. package/lib/v2/providers/database.d.ts +182 -0
  53. package/lib/v2/providers/database.js +204 -0
  54. package/lib/v2/providers/eventarc.d.ts +89 -5
  55. package/lib/v2/providers/eventarc.js +4 -0
  56. package/lib/v2/providers/https.d.ts +123 -2
  57. package/lib/v2/providers/https.js +13 -3
  58. package/lib/v2/providers/identity.d.ts +108 -4
  59. package/lib/v2/providers/identity.js +33 -2
  60. package/lib/v2/providers/pubsub.d.ts +122 -5
  61. package/lib/v2/providers/pubsub.js +58 -2
  62. package/lib/v2/providers/storage.d.ts +192 -4
  63. package/lib/v2/providers/storage.js +52 -9
  64. package/lib/v2/providers/tasks.d.ts +106 -6
  65. package/lib/v2/providers/tasks.js +4 -0
  66. package/package.json +12 -6
@@ -1,22 +1,122 @@
1
1
  import { AuthData, RateLimits, Request, RetryConfig } from '../../common/providers/tasks';
2
2
  import * as options from '../options';
3
3
  import { HttpsFunction } from './https';
4
- export { AuthData, RateLimits, Request, RetryConfig as RetryPolicy };
5
- export interface TaskQueueOptions extends options.GlobalOptions {
4
+ export { AuthData, RateLimits, Request, RetryConfig };
5
+ export interface TaskQueueOptions extends options.EventHandlerOptions {
6
+ /** How a task should be retried in the event of a non-2xx return. */
6
7
  retryConfig?: RetryConfig;
8
+ /** How congestion control should be applied to the function. */
7
9
  rateLimits?: RateLimits;
8
10
  /**
9
11
  * Who can enqueue tasks for this function.
10
12
  * If left unspecified, only service accounts which have
11
- * roles/cloudtasks.enqueuer and roles/cloudfunctions.invoker
13
+ * `roles/cloudtasks.enqueuer` and `roles/cloudfunctions.invoker`
12
14
  * will have permissions.
13
15
  */
14
16
  invoker?: 'private' | string | string[];
17
+ /**
18
+ * Region where functions should be deployed.
19
+ */
20
+ region?: options.SupportedRegion | string;
21
+ /**
22
+ * Amount of memory to allocate to a function.
23
+ * A value of null restores the defaults of 256MB.
24
+ */
25
+ memory?: options.MemoryOption | null;
26
+ /**
27
+ * Timeout for the function in sections, possible values are 0 to 540.
28
+ * HTTPS functions can specify a higher timeout.
29
+ * A value of null restores the default of 60s
30
+ * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
31
+ * function depends on the type of function: Event handling functions have a
32
+ * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
33
+ * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
34
+ * timeout of 1,800s (30 minutes)
35
+ */
36
+ timeoutSeconds?: number | null;
37
+ /**
38
+ * Min number of actual instances to be running at a given time.
39
+ * Instances will be billed for memory allocation and 10% of CPU allocation
40
+ * while idle.
41
+ * A value of null restores the default min instances.
42
+ */
43
+ minInstances?: number | null;
44
+ /**
45
+ * Max number of instances to be running in parallel.
46
+ * A value of null restores the default max instances.
47
+ */
48
+ maxInstances?: number | null;
49
+ /**
50
+ * Number of requests a function can serve at once.
51
+ * Can only be applied to functions running on Cloud Functions v2.
52
+ * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
53
+ * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
54
+ * The maximum value for concurrency is 1,000.
55
+ */
56
+ concurrency?: number | null;
57
+ /**
58
+ * Fractional number of CPUs to allocate to a function.
59
+ * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
60
+ * This is different from the defaults when using the gcloud utility and is different from
61
+ * the fixed amount assigned in Google Cloud Functions generation 1.
62
+ * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
63
+ * to the value "gcf_gen1"
64
+ */
65
+ cpu?: number | 'gcf_gen1';
66
+ /**
67
+ * Connect cloud function to specified VPC connector.
68
+ * A value of null removes the VPC connector
69
+ */
70
+ vpcConnector?: string | null;
71
+ /**
72
+ * Egress settings for VPC connector.
73
+ * A value of null turns off VPC connector egress settings
74
+ */
75
+ vpcConnectorEgressSettings?: options.VpcEgressSetting | null;
76
+ /**
77
+ * Specific service account for the function to run as.
78
+ * A value of null restores the default service account.
79
+ */
80
+ serviceAccount?: string | null;
81
+ /**
82
+ * Ingress settings which control where this function can be called from.
83
+ * A value of null turns off ingress settings.
84
+ */
85
+ ingressSettings?: options.IngressSetting | null;
86
+ /**
87
+ * User labels to set on the function.
88
+ */
89
+ labels?: Record<string, string>;
90
+ secrets?: string[];
91
+ /** Whether failed executions should be delivered again. */
92
+ retry?: boolean;
15
93
  }
94
+ /**
95
+ * A handler for tasks.
96
+ * @typeParam T - The task data interface. Task data is unmarshaled from JSON.
97
+ */
16
98
  export interface TaskQueueFunction<T = any> extends HttpsFunction {
17
- run(data: Request<T>): void | Promise<void>;
99
+ /**
100
+ * The callback passed to the `TaskQueueFunction` constructor.
101
+ * @param request - A TaskRequest containing data and auth information.
102
+ * @returns Any return value. Google Cloud Functions will await any promise
103
+ * before shutting down your function. Resolved return values
104
+ * are only used for unit testing purposes.
105
+ */
106
+ run(request: Request<T>): void | Promise<void>;
18
107
  }
19
- /** Handle a request sent to a Cloud Tasks queue. */
108
+ /**
109
+ * Creates a handler for tasks sent to a Google Cloud Tasks queue.
110
+ * @param handler - A callback to handle task requests.
111
+ * @typeParam Args - The interface for the request's `data` field.
112
+ * @returns A Cloud Function you can export and deploy.
113
+ */
20
114
  export declare function onTaskDispatched<Args = any>(handler: (request: Request<Args>) => void | Promise<void>): TaskQueueFunction<Args>;
21
- /** Handle a request sent to a Cloud Tasks queue. */
115
+ /**
116
+ * Creates a handler for tasks sent to a Google Cloud Tasks queue.
117
+ * @param options - Configuration for the task queue or Cloud Function.
118
+ * @param handler - A callback to handle task requests.
119
+ * @typeParam Args - The interface for the request's `data` field.
120
+ * @returns A Cloud Function you can export and deploy.
121
+ */
22
122
  export declare function onTaskDispatched<Args = any>(options: TaskQueueOptions, handler: (request: Request<Args>) => void | Promise<void>): TaskQueueFunction<Args>;
@@ -22,6 +22,10 @@
22
22
  // SOFTWARE.
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.onTaskDispatched = void 0;
25
+ /**
26
+ * Cloud functions to handle Tasks enqueued with Google Cloud Tasks.
27
+ * @packageDocumentation
28
+ */
25
29
  const encoding_1 = require("../../common/encoding");
26
30
  const tasks_1 = require("../../common/providers/tasks");
27
31
  const options = require("../options");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-functions",
3
- "version": "3.21.0",
3
+ "version": "3.22.0",
4
4
  "description": "Firebase SDK for Cloud Functions",
5
5
  "keywords": [
6
6
  "firebase",
@@ -65,7 +65,8 @@
65
65
  "./v2/alerts/billing": "./lib/v2/providers/alerts/billing.js",
66
66
  "./v2/alerts/crashlytics": "./lib/v2/providers/alerts/crashlytics.js",
67
67
  "./v2/eventarc": "./lib/v2/providers/eventarc.js",
68
- "./v2/identity": "./lib/v2/providers/identity.js"
68
+ "./v2/identity": "./lib/v2/providers/identity.js",
69
+ "./v2/database": "./lib/v2/providers/database.js"
69
70
  },
70
71
  "typesVersions": {
71
72
  "*": {
@@ -126,6 +127,9 @@
126
127
  "v2/base": [
127
128
  "lib/v2/base"
128
129
  ],
130
+ "v2/database": [
131
+ "lib/v2/providers/database"
132
+ ],
129
133
  "v2/eventarc": [
130
134
  "lib/v2/providers/eventarc"
131
135
  ],
@@ -159,10 +163,11 @@
159
163
  "apidocs": "node docgen/generate-docs.js",
160
164
  "docgen:v1:extract": "api-extractor run -c docgen/api-extractor.v1.json --local",
161
165
  "docgen:v1:gen": "api-documenter-fire markdown -i docgen/v1 -o docgen/v1/markdown && api-documenter-fire toc -i docgen/v1 -o docgen/v1/markdown/toc -p /docs/reference/functions",
162
- "docgen:v1": "npm run docgen:v1:extract && npm run docgen:v1:gen",
166
+ "docgen:v1": "npm run build && npm run docgen:v1:extract && npm run docgen:v1:gen",
163
167
  "docgen:v2:extract": "api-extractor run -c docgen/api-extractor.v2.json --local",
164
- "docgen:v2:gen": "api-documenter-fire markdown -i docgen/v2 -o docgen/v2/markdown && api-documenter-fire toc -i docgen/v2 -o docgen/v2/markdown/toc -p /docs/reference/functions/v2",
165
- "docgen:v2": "npm run docgen:v2:extract && npm run docgen:v2:gen",
168
+ "docgen:v2:toc": "ts-node docgen/toc.ts --input docgen/v2/markdown --output docgen/v2/markdown/toc --path /docs/functions/beta/reference",
169
+ "docgen:v2:gen": "api-documenter-fire markdown -i docgen/v2 -o docgen/v2/markdown && npm run docgen:v2:toc",
170
+ "docgen:v2": "npm run build && npm run docgen:v2:extract && npm run docgen:v2:gen",
166
171
  "build:pack": "rm -rf lib && npm install && tsc -p tsconfig.release.json && npm pack",
167
172
  "build:release": "npm ci --production && npm install --no-save typescript firebase-admin && tsc -p tsconfig.release.json",
168
173
  "build": "tsc -p tsconfig.release.json",
@@ -196,6 +201,7 @@
196
201
  "@types/node": "^8.10.50",
197
202
  "@types/node-fetch": "^3.0.3",
198
203
  "@types/sinon": "^7.0.13",
204
+ "api-extractor-model-me": "^0.1.1",
199
205
  "chai": "^4.2.0",
200
206
  "chai-as-promised": "^7.1.1",
201
207
  "child-process-promise": "^2.2.1",
@@ -223,7 +229,7 @@
223
229
  "yargs": "^15.3.1"
224
230
  },
225
231
  "peerDependencies": {
226
- "firebase-admin": "^8.0.0 || ^9.0.0 || ^10.0.0"
232
+ "firebase-admin": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0"
227
233
  },
228
234
  "engines": {
229
235
  "node": "^8.13.0 || >=10.10.0"