firebase-functions 7.2.2 → 7.2.4

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 (44) hide show
  1. package/lib/common/providers/tasks.js +1 -0
  2. package/lib/common/utilities/path-pattern.js +12 -3
  3. package/lib/esm/common/providers/tasks.mjs +1 -0
  4. package/lib/esm/common/utilities/path-pattern.mjs +11 -3
  5. package/lib/esm/v2/compat.mjs +19 -59
  6. package/lib/esm/v2/index.doc.mjs +1 -1
  7. package/lib/esm/v2/index.mjs +2 -2
  8. package/lib/esm/v2/providers/ai/index.mjs +187 -0
  9. package/lib/esm/v2/providers/ai/types/gemini/v1beta/index.mjs +6 -0
  10. package/lib/esm/v2/providers/ai/types/vertex/v1beta1/index.mjs +6 -0
  11. package/lib/esm/v2/providers/database.mjs +35 -2
  12. package/lib/esm/v2/providers/firestore.mjs +38 -6
  13. package/lib/esm/v2/providers/https.mjs +10 -2
  14. package/lib/esm/v2/providers/pubsub.mjs +42 -2
  15. package/lib/esm/v2/providers/remoteConfig.mjs +18 -1
  16. package/lib/esm/v2/providers/scheduler.mjs +12 -0
  17. package/lib/esm/v2/providers/storage.mjs +24 -1
  18. package/lib/v2/compat.d.ts +14 -12
  19. package/lib/v2/compat.js +19 -58
  20. package/lib/v2/index.d.ts +0 -1
  21. package/lib/v2/index.doc.js +1 -1
  22. package/lib/v2/index.js +2 -2
  23. package/lib/v2/providers/ai/index.d.ts +53 -0
  24. package/lib/v2/providers/ai/index.js +198 -0
  25. package/lib/v2/providers/ai/types/gemini/v1beta/index.d.ts +817 -0
  26. package/lib/v2/providers/ai/types/gemini/v1beta/index.js +8 -0
  27. package/lib/v2/providers/ai/types/vertex/v1beta1/index.d.ts +850 -0
  28. package/lib/v2/providers/ai/types/vertex/v1beta1/index.js +8 -0
  29. package/lib/v2/providers/database.d.ts +61 -4
  30. package/lib/v2/providers/database.js +35 -2
  31. package/lib/v2/providers/firestore.d.ts +127 -0
  32. package/lib/v2/providers/firestore.js +38 -5
  33. package/lib/v2/providers/https.d.ts +2 -2
  34. package/lib/v2/providers/https.js +10 -2
  35. package/lib/v2/providers/pubsub.d.ts +18 -4
  36. package/lib/v2/providers/pubsub.js +42 -2
  37. package/lib/v2/providers/remoteConfig.d.ts +16 -0
  38. package/lib/v2/providers/remoteConfig.js +18 -1
  39. package/lib/v2/providers/scheduler.d.ts +21 -0
  40. package/lib/v2/providers/scheduler.js +12 -0
  41. package/lib/v2/providers/storage.d.ts +127 -0
  42. package/lib/v2/providers/storage.js +24 -1
  43. package/lib/v2/providers/tasks.d.ts +20 -1
  44. package/package.json +1 -1
@@ -3,8 +3,8 @@ const require_runtime_manifest = require('../../runtime/manifest.js');
3
3
  const require_common_encoding = require('../../common/encoding.js');
4
4
  const require_common_onInit = require('../../common/onInit.js');
5
5
  const require_v2_trace = require('../trace.js');
6
- const require_v2_options = require('../options.js');
7
6
  const require_v2_compat = require('../compat.js');
7
+ const require_v2_options = require('../options.js');
8
8
 
9
9
  //#region src/v2/providers/pubsub.ts
10
10
  var pubsub_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
@@ -99,7 +99,47 @@ function onMessagePublished(topicOrOptions, handler) {
99
99
  delete opts.topic;
100
100
  }
101
101
  const func = (raw) => {
102
- const event = require_v2_compat.patchV1Compat(raw);
102
+ const pubsubEvent = raw;
103
+ const pubsubData = pubsubEvent.data;
104
+ let v2Message;
105
+ if (pubsubData && pubsubData.message) {
106
+ v2Message = pubsubData.message instanceof Message ? pubsubData.message : new Message(pubsubData.message);
107
+ pubsubData.message = v2Message;
108
+ } else {
109
+ throw new Error("Malformed Pub/Sub event: missing 'message' property.");
110
+ }
111
+ const event = require_v2_compat.addV1Compat(pubsubEvent, {
112
+ context: () => {
113
+ const service = "pubsub.googleapis.com";
114
+ const sourcePrefix = `//${service}/`;
115
+ return {
116
+ eventId: v2Message.messageId,
117
+ timestamp: v2Message.publishTime,
118
+ eventType: "google.pubsub.topic.publish",
119
+ resource: {
120
+ service,
121
+ name: raw.source?.startsWith(sourcePrefix) ? raw.source.substring(sourcePrefix.length) : raw.source || ""
122
+ },
123
+ params: {}
124
+ };
125
+ },
126
+ message: () => {
127
+ const baseV1Message = {
128
+ data: v2Message.data,
129
+ messageId: v2Message.messageId,
130
+ publishTime: v2Message.publishTime,
131
+ attributes: v2Message.attributes,
132
+ ...v2Message.orderingKey && { orderingKey: v2Message.orderingKey }
133
+ };
134
+ return {
135
+ ...baseV1Message,
136
+ get json() {
137
+ return v2Message.json;
138
+ },
139
+ toJSON: () => baseV1Message
140
+ };
141
+ }
142
+ });
103
143
  return require_v2_trace.wrapTraceContext(require_common_onInit.withInit(handler))(event);
104
144
  };
105
145
  func.run = handler;
@@ -1,5 +1,6 @@
1
1
  import { CloudEvent, CloudFunction } from "../core";
2
2
  import { EventHandlerOptions } from "../options";
3
+ import { V1Compat } from "../compat";
3
4
  /** All the fields associated with the person/service account that wrote a Remote Config template. */
4
5
  export interface ConfigUser {
5
6
  /** Display name. */
@@ -46,6 +47,13 @@ export interface ConfigUpdateData {
46
47
  /** Only present if this version is the result of a rollback, and will be the version number of the Remote Config template that was rolled-back to. */
47
48
  rollbackSource: number;
48
49
  }
50
+ /**
51
+ * Event handler which triggers when data is updated in a Remote Config.
52
+ *
53
+ * @param handler - Event handler which is run every time a Remote Config update occurs.
54
+ * @returns A function that you can export and deploy.
55
+ */
56
+ export declare function onConfigUpdated(handler: (event: CloudEvent<ConfigUpdateData> & V1Compat<"version", ConfigUpdateData>) => any | Promise<any>): CloudFunction<CloudEvent<ConfigUpdateData>>;
49
57
  /**
50
58
  * Event handler which triggers when data is updated in a Remote Config.
51
59
  *
@@ -53,6 +61,14 @@ export interface ConfigUpdateData {
53
61
  * @returns A function that you can export and deploy.
54
62
  */
55
63
  export declare function onConfigUpdated(handler: (event: CloudEvent<ConfigUpdateData>) => any | Promise<any>): CloudFunction<CloudEvent<ConfigUpdateData>>;
64
+ /**
65
+ * Event handler which triggers when data is updated in a Remote Config.
66
+ *
67
+ * @param opts - Options that can be set on an individual event-handling function.
68
+ * @param handler - Event handler which is run every time a Remote Config update occurs.
69
+ * @returns A function that you can export and deploy.
70
+ */
71
+ export declare function onConfigUpdated(opts: EventHandlerOptions, handler: (event: CloudEvent<ConfigUpdateData> & V1Compat<"version", ConfigUpdateData>) => any | Promise<any>): CloudFunction<CloudEvent<ConfigUpdateData>>;
56
72
  /**
57
73
  * Event handler which triggers when data is updated in a Remote Config.
58
74
  *
@@ -2,6 +2,7 @@ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.js');
2
2
  const require_runtime_manifest = require('../../runtime/manifest.js');
3
3
  const require_common_onInit = require('../../common/onInit.js');
4
4
  const require_v2_trace = require('../trace.js');
5
+ const require_v2_compat = require('../compat.js');
5
6
  const require_v2_options = require('../options.js');
6
7
 
7
8
  //#region src/v2/providers/remoteConfig.ts
@@ -26,7 +27,23 @@ function onConfigUpdated(optsOrHandler, handler) {
26
27
  const baseOpts = require_v2_options.optionsToEndpoint(require_v2_options.getGlobalOptions());
27
28
  const specificOpts = require_v2_options.optionsToEndpoint(optsOrHandler);
28
29
  const func = require_v2_trace.wrapTraceContext(require_common_onInit.withInit((raw) => {
29
- return handler(raw);
30
+ const event = raw;
31
+ const patchedEvent = require_v2_compat.addV1Compat(event, {
32
+ context: () => {
33
+ return {
34
+ eventId: event.id,
35
+ timestamp: event.time,
36
+ eventType: "google.firebase.remoteconfig.update",
37
+ resource: {
38
+ service: "firebaseremoteconfig.googleapis.com",
39
+ name: event.subject || ""
40
+ },
41
+ params: {}
42
+ };
43
+ },
44
+ version: () => event.data
45
+ });
46
+ return handler(patchedEvent);
30
47
  }));
31
48
  func.run = handler;
32
49
  const ep = {
@@ -4,6 +4,7 @@ import { ManifestRequiredAPI } from "../../runtime/manifest";
4
4
  import { HttpsFunction } from "./https";
5
5
  import { Expression } from "../../params";
6
6
  import * as options from "../options";
7
+ import { EventContext } from "../../v1/cloud-functions";
7
8
  /**
8
9
  * Interface representing a ScheduleEvent that is passed to the function handler.
9
10
  */
@@ -47,6 +48,16 @@ export interface ScheduleOptions extends options.GlobalOptions {
47
48
  /** The time between will double max doublings times. */
48
49
  maxDoublings?: number | Expression<number> | ResetValue;
49
50
  }
51
+ /**
52
+ * Handler for scheduled functions. Triggered whenever the associated
53
+ * scheduler job sends a http request.
54
+ * @param schedule - The schedule, in Unix Crontab or AppEngine syntax.
55
+ * @param handler - A function to execute when triggered.
56
+ * @returns A function that you can export and deploy.
57
+ */
58
+ export declare function onSchedule(schedule: string, handler: (event: ScheduledEvent & {
59
+ context: EventContext;
60
+ }) => void | Promise<void>): ScheduleFunction;
50
61
  /**
51
62
  * Handler for scheduled functions. Triggered whenever the associated
52
63
  * scheduler job sends a http request.
@@ -55,6 +66,16 @@ export interface ScheduleOptions extends options.GlobalOptions {
55
66
  * @returns A function that you can export and deploy.
56
67
  */
57
68
  export declare function onSchedule(schedule: string, handler: (event: ScheduledEvent) => void | Promise<void>): ScheduleFunction;
69
+ /**
70
+ * Handler for scheduled functions. Triggered whenever the associated
71
+ * scheduler job sends a http request.
72
+ * @param options - Options to set on scheduled functions.
73
+ * @param handler - A function to execute when triggered.
74
+ * @returns A function that you can export and deploy.
75
+ */
76
+ export declare function onSchedule(options: ScheduleOptions, handler: (event: ScheduledEvent & {
77
+ context: EventContext;
78
+ }) => void | Promise<void>): ScheduleFunction;
58
79
  /**
59
80
  * Handler for scheduled functions. Triggered whenever the associated
60
81
  * scheduler job sends a http request.
@@ -46,6 +46,18 @@ function onSchedule(args, handler) {
46
46
  jobName: req.header("X-CloudScheduler-JobName") || undefined,
47
47
  scheduleTime: req.header("X-CloudScheduler-ScheduleTime") || new Date().toISOString()
48
48
  };
49
+ const jobName = event.jobName || "unknown-job";
50
+ const v1Context = {
51
+ eventId: jobName,
52
+ timestamp: event.scheduleTime,
53
+ eventType: "google.pubsub.topic.publish",
54
+ resource: {
55
+ service: "pubsub.googleapis.com",
56
+ name: `projects/${process.env.GCLOUD_PROJECT}/topics/${jobName}`
57
+ },
58
+ params: {}
59
+ };
60
+ Object.defineProperty(event, "context", { get: () => v1Context });
49
61
  try {
50
62
  await handler(event);
51
63
  res.status(200).send();
@@ -3,6 +3,7 @@ import { CloudEvent, CloudFunction } from "../core";
3
3
  import { Expression } from "../../params";
4
4
  import * as options from "../options";
5
5
  import { SupportedSecretParam } from "../../params/types";
6
+ import { V1Compat } from "../compat";
6
7
  /**
7
8
  * An object within Google Cloud Storage.
8
9
  * Ref: https://github.com/googleapis/google-cloudevents-nodejs/blob/main/cloud/storage/v1/StorageObjectData.ts
@@ -241,6 +242,15 @@ export interface StorageOptions extends options.EventHandlerOptions {
241
242
  /** Whether failed executions should be delivered again. */
242
243
  retry?: boolean | Expression<boolean> | ResetValue;
243
244
  }
245
+ /**
246
+ * Event handler sent only when a bucket has enabled object versioning.
247
+ * This event indicates that the live version of an object has become an
248
+ * archived version, either because it was archived or because it was
249
+ * overwritten by the upload of an object of the same name.
250
+ *
251
+ * @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
252
+ */
253
+ export declare function onObjectArchived(handler: (event: StorageEvent & V1Compat<"object", StorageObjectData>) => any | Promise<any>): CloudFunction<StorageEvent>;
244
254
  /**
245
255
  * Event handler sent only when a bucket has enabled object versioning.
246
256
  * This event indicates that the live version of an object has become an
@@ -250,6 +260,16 @@ export interface StorageOptions extends options.EventHandlerOptions {
250
260
  * @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
251
261
  */
252
262
  export declare function onObjectArchived(handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
263
+ /**
264
+ * Event handler sent only when a bucket has enabled object versioning.
265
+ * This event indicates that the live version of an object has become an
266
+ * archived version, either because it was archived or because it was
267
+ * overwritten by the upload of an object of the same name.
268
+ *
269
+ * @param bucket - The name of the bucket containing this object.
270
+ * @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
271
+ */
272
+ export declare function onObjectArchived(bucket: string | Expression<string>, handler: (event: StorageEvent & V1Compat<"object", StorageObjectData>) => any | Promise<any>): CloudFunction<StorageEvent>;
253
273
  /**
254
274
  * Event handler sent only when a bucket has enabled object versioning.
255
275
  * This event indicates that the live version of an object has become an
@@ -260,6 +280,16 @@ export declare function onObjectArchived(handler: (event: StorageEvent) => any |
260
280
  * @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
261
281
  */
262
282
  export declare function onObjectArchived(bucket: string | Expression<string>, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
283
+ /**
284
+ * Event handler sent only when a bucket has enabled object versioning.
285
+ * This event indicates that the live version of an object has become an
286
+ * archived version, either because it was archived or because it was
287
+ * overwritten by the upload of an object of the same name.
288
+ *
289
+ * @param opts - Options that can be set on an individual event-handling function.
290
+ * @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
291
+ */
292
+ export declare function onObjectArchived(opts: StorageOptions, handler: (event: StorageEvent & V1Compat<"object", StorageObjectData>) => any | Promise<any>): CloudFunction<StorageEvent>;
263
293
  /**
264
294
  * Event handler sent only when a bucket has enabled object versioning.
265
295
  * This event indicates that the live version of an object has become an
@@ -270,6 +300,17 @@ export declare function onObjectArchived(bucket: string | Expression<string>, ha
270
300
  * @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
271
301
  */
272
302
  export declare function onObjectArchived(opts: StorageOptions, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
303
+ /**
304
+ * Event handler which fires every time a Google Cloud Storage object
305
+ * creation occurs.
306
+ *
307
+ * Sent when a new object (or a new generation of an existing object)
308
+ * is successfully created in the bucket. This includes copying or rewriting
309
+ * an existing object. A failed upload does not trigger this event.
310
+ *
311
+ * @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
312
+ */
313
+ export declare function onObjectFinalized(handler: (event: StorageEvent & V1Compat<"object", StorageObjectData>) => any | Promise<any>): CloudFunction<StorageEvent>;
273
314
  /**
274
315
  * Event handler which fires every time a Google Cloud Storage object
275
316
  * creation occurs.
@@ -281,6 +322,18 @@ export declare function onObjectArchived(opts: StorageOptions, handler: (event:
281
322
  * @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
282
323
  */
283
324
  export declare function onObjectFinalized(handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
325
+ /**
326
+ * Event handler which fires every time a Google Cloud Storage object
327
+ * creation occurs.
328
+ *
329
+ * Sent when a new object (or a new generation of an existing object)
330
+ * is successfully created in the bucket. This includes copying or rewriting
331
+ * an existing object. A failed upload does not trigger this event.
332
+ *
333
+ * @param bucket - The name of the bucket containing this object.
334
+ * @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
335
+ */
336
+ export declare function onObjectFinalized(bucket: string | Expression<string>, handler: (event: StorageEvent & V1Compat<"object", StorageObjectData>) => any | Promise<any>): CloudFunction<StorageEvent>;
284
337
  /**
285
338
  * Event handler which fires every time a Google Cloud Storage object
286
339
  * creation occurs.
@@ -293,6 +346,18 @@ export declare function onObjectFinalized(handler: (event: StorageEvent) => any
293
346
  * @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
294
347
  */
295
348
  export declare function onObjectFinalized(bucket: string | Expression<string>, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
349
+ /**
350
+ * Event handler which fires every time a Google Cloud Storage object
351
+ * creation occurs.
352
+ *
353
+ * Sent when a new object (or a new generation of an existing object)
354
+ * is successfully created in the bucket. This includes copying or rewriting
355
+ * an existing object. A failed upload does not trigger this event.
356
+ *
357
+ * @param opts - Options that can be set on an individual event-handling function.
358
+ * @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
359
+ */
360
+ export declare function onObjectFinalized(opts: StorageOptions, handler: (event: StorageEvent & V1Compat<"object", StorageObjectData>) => any | Promise<any>): CloudFunction<StorageEvent>;
296
361
  /**
297
362
  * Event handler which fires every time a Google Cloud Storage object
298
363
  * creation occurs.
@@ -305,6 +370,18 @@ export declare function onObjectFinalized(bucket: string | Expression<string>, h
305
370
  * @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
306
371
  */
307
372
  export declare function onObjectFinalized(opts: StorageOptions, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
373
+ /**
374
+ * Event handler which fires every time a Google Cloud Storage deletion occurs.
375
+ *
376
+ * Sent when an object has been permanently deleted. This includes objects
377
+ * that are overwritten or are deleted as part of the bucket's lifecycle
378
+ * configuration. For buckets with object versioning enabled, this is not
379
+ * sent when an object is archived, even if archival occurs
380
+ * via the `storage.objects.delete` method.
381
+ *
382
+ * @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
383
+ */
384
+ export declare function onObjectDeleted(handler: (event: StorageEvent & V1Compat<"object", StorageObjectData>) => any | Promise<any>): CloudFunction<StorageEvent>;
308
385
  /**
309
386
  * Event handler which fires every time a Google Cloud Storage deletion occurs.
310
387
  *
@@ -317,6 +394,19 @@ export declare function onObjectFinalized(opts: StorageOptions, handler: (event:
317
394
  * @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
318
395
  */
319
396
  export declare function onObjectDeleted(handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
397
+ /**
398
+ * Event handler which fires every time a Google Cloud Storage deletion occurs.
399
+ *
400
+ * Sent when an object has been permanently deleted. This includes objects
401
+ * that are overwritten or are deleted as part of the bucket's lifecycle
402
+ * configuration. For buckets with object versioning enabled, this is not
403
+ * sent when an object is archived, even if archival occurs
404
+ * via the `storage.objects.delete` method.
405
+ *
406
+ * @param bucket - The name of the bucket containing this object.
407
+ * @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
408
+ */
409
+ export declare function onObjectDeleted(bucket: string | Expression<string>, handler: (event: StorageEvent & V1Compat<"object", StorageObjectData>) => any | Promise<any>): CloudFunction<StorageEvent>;
320
410
  /**
321
411
  * Event handler which fires every time a Google Cloud Storage deletion occurs.
322
412
  *
@@ -330,6 +420,19 @@ export declare function onObjectDeleted(handler: (event: StorageEvent) => any |
330
420
  * @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
331
421
  */
332
422
  export declare function onObjectDeleted(bucket: string | Expression<string>, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
423
+ /**
424
+ * Event handler which fires every time a Google Cloud Storage deletion occurs.
425
+ *
426
+ * Sent when an object has been permanently deleted. This includes objects
427
+ * that are overwritten or are deleted as part of the bucket's lifecycle
428
+ * configuration. For buckets with object versioning enabled, this is not
429
+ * sent when an object is archived, even if archival occurs
430
+ * via the `storage.objects.delete` method.
431
+ *
432
+ * @param opts - Options that can be set on an individual event-handling function.
433
+ * @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
434
+ */
435
+ export declare function onObjectDeleted(opts: StorageOptions, handler: (event: StorageEvent & V1Compat<"object", StorageObjectData>) => any | Promise<any>): CloudFunction<StorageEvent>;
333
436
  /**
334
437
  * Event handler which fires every time a Google Cloud Storage deletion occurs.
335
438
  *
@@ -343,6 +446,14 @@ export declare function onObjectDeleted(bucket: string | Expression<string>, han
343
446
  * @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
344
447
  */
345
448
  export declare function onObjectDeleted(opts: StorageOptions, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
449
+ /**
450
+ * Event handler which fires every time the metadata of an existing object
451
+ * changes.
452
+ *
453
+ * @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
454
+ * @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
455
+ */
456
+ export declare function onObjectMetadataUpdated(handler: (event: StorageEvent & V1Compat<"object", StorageObjectData>) => any | Promise<any>): CloudFunction<StorageEvent>;
346
457
  /**
347
458
  * Event handler which fires every time the metadata of an existing object
348
459
  * changes.
@@ -351,6 +462,14 @@ export declare function onObjectDeleted(opts: StorageOptions, handler: (event: S
351
462
  * @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
352
463
  */
353
464
  export declare function onObjectMetadataUpdated(handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
465
+ /**
466
+ * Event handler which fires every time the metadata of an existing object
467
+ * changes.
468
+ *
469
+ * @param bucket - The name of the bucket containing this object.
470
+ * @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
471
+ */
472
+ export declare function onObjectMetadataUpdated(bucket: string | Expression<string>, handler: (event: StorageEvent & V1Compat<"object", StorageObjectData>) => any | Promise<any>): CloudFunction<StorageEvent>;
354
473
  /**
355
474
  * Event handler which fires every time the metadata of an existing object
356
475
  * changes.
@@ -359,6 +478,14 @@ export declare function onObjectMetadataUpdated(handler: (event: StorageEvent) =
359
478
  * @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
360
479
  */
361
480
  export declare function onObjectMetadataUpdated(bucket: string | Expression<string>, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
481
+ /**
482
+ * Event handler which fires every time the metadata of an existing object
483
+ * changes.
484
+ *
485
+ * @param opts - Options that can be set on an individual event-handling function.
486
+ * @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
487
+ */
488
+ export declare function onObjectMetadataUpdated(opts: StorageOptions, handler: (event: StorageEvent & V1Compat<"object", StorageObjectData>) => any | Promise<any>): CloudFunction<StorageEvent>;
362
489
  /**
363
490
  * Event handler which fires every time the metadata of an existing object
364
491
  * changes.
@@ -4,6 +4,7 @@ const require_common_config = require('../../common/config.js');
4
4
  const require_common_encoding = require('../../common/encoding.js');
5
5
  const require_common_onInit = require('../../common/onInit.js');
6
6
  const require_v2_trace = require('../trace.js');
7
+ const require_v2_compat = require('../compat.js');
7
8
  const require_v2_options = require('../options.js');
8
9
 
9
10
  //#region src/v2/providers/storage.ts
@@ -86,7 +87,29 @@ function onOperation(eventType, bucketOrOptsOrHandler, handler) {
86
87
  }
87
88
  const [opts, bucket] = getOptsAndBucket(bucketOrOptsOrHandler);
88
89
  const func = (raw) => {
89
- return require_v2_trace.wrapTraceContext(require_common_onInit.withInit(handler))(raw);
90
+ const storageEvent = raw;
91
+ const event = require_v2_compat.addV1Compat(storageEvent, {
92
+ context: () => {
93
+ const bucketName = storageEvent.bucket;
94
+ return {
95
+ eventId: storageEvent.id,
96
+ timestamp: storageEvent.time,
97
+ eventType: {
98
+ [archivedEvent]: "google.storage.object.archive",
99
+ [finalizedEvent]: "google.storage.object.finalize",
100
+ [deletedEvent]: "google.storage.object.delete",
101
+ [metadataUpdatedEvent]: "google.storage.object.metadataUpdate"
102
+ }[eventType] || eventType,
103
+ resource: {
104
+ service: "storage.googleapis.com",
105
+ name: `projects/_/buckets/${bucketName}/objects/${storageEvent.data.name}#${storageEvent.data.generation}`
106
+ },
107
+ params: {}
108
+ };
109
+ },
110
+ object: () => storageEvent.data
111
+ });
112
+ return require_v2_trace.wrapTraceContext(require_common_onInit.withInit(handler))(event);
90
113
  };
91
114
  func.run = handler;
92
115
  Object.defineProperty(func, "__trigger", { get: () => {
@@ -1,5 +1,5 @@
1
1
  import { ResetValue } from "../../common/options";
2
- import { AuthData, RateLimits, Request, RetryConfig } from "../../common/providers/tasks";
2
+ import { AuthData, RateLimits, Request, RetryConfig, TaskContext } from "../../common/providers/tasks";
3
3
  import * as options from "../options";
4
4
  import { HttpsFunction } from "./https";
5
5
  import { Expression } from "../../params";
@@ -114,6 +114,15 @@ export interface TaskQueueFunction<T = any> extends HttpsFunction {
114
114
  */
115
115
  run(request: Request<T>): void | Promise<void>;
116
116
  }
117
+ /**
118
+ * Creates a handler for tasks sent to a Google Cloud Tasks queue.
119
+ * @param handler - A callback to handle task requests.
120
+ * @typeParam Args - The interface for the request's `data` field.
121
+ * @returns A function you can export and deploy.
122
+ */
123
+ export declare function onTaskDispatched<Args = any>(handler: (request: Request<Args> & {
124
+ context: TaskContext;
125
+ }) => void | Promise<void>): TaskQueueFunction<Args>;
117
126
  /**
118
127
  * Creates a handler for tasks sent to a Google Cloud Tasks queue.
119
128
  * @param handler - A callback to handle task requests.
@@ -121,6 +130,16 @@ export interface TaskQueueFunction<T = any> extends HttpsFunction {
121
130
  * @returns A function you can export and deploy.
122
131
  */
123
132
  export declare function onTaskDispatched<Args = any>(handler: (request: Request<Args>) => void | Promise<void>): TaskQueueFunction<Args>;
133
+ /**
134
+ * Creates a handler for tasks sent to a Google Cloud Tasks queue.
135
+ * @param options - Configuration for the task queue or Cloud Function.
136
+ * @param handler - A callback to handle task requests.
137
+ * @typeParam Args - The interface for the request's `data` field.
138
+ * @returns A function you can export and deploy.
139
+ */
140
+ export declare function onTaskDispatched<Args = any>(options: TaskQueueOptions, handler: (request: Request<Args> & {
141
+ context: TaskContext;
142
+ }) => void | Promise<void>): TaskQueueFunction<Args>;
124
143
  /**
125
144
  * Creates a handler for tasks sent to a Google Cloud Tasks queue.
126
145
  * @param options - Configuration for the task queue or Cloud Function.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-functions",
3
- "version": "7.2.2",
3
+ "version": "7.2.4",
4
4
  "description": "Firebase SDK for Cloud Functions",
5
5
  "keywords": [
6
6
  "firebase",