functions.d.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*! firebase-admin v12.1.1 */
  2. /*!
  3. * @license
  4. * Copyright 2021 Google Inc.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. import { App } from '../app';
  19. import { TaskOptions } from './functions-api';
  20. /**
  21. * The Firebase `Functions` service interface.
  22. */
  23. export declare class Functions {
  24. readonly app: App;
  25. private readonly client;
  26. /**
  27. * Creates a reference to a {@link TaskQueue} for a given function name.
  28. * The function name can be either:
  29. *
  30. * 1) A fully qualified function resource name:
  31. * `projects/{project}/locations/{location}/functions/{functionName}`
  32. *
  33. * 2) A partial resource name with location and function name, in which case
  34. * the runtime project ID is used:
  35. * `locations/{location}/functions/{functionName}`
  36. *
  37. * 3) A partial function name, in which case the runtime project ID and the default location,
  38. * `us-central1`, is used:
  39. * `{functionName}`
  40. *
  41. * @param functionName - The name of the function.
  42. * @param extensionId - Optional Firebase extension ID.
  43. * @returns A promise that fulfills with a `TaskQueue`.
  44. */
  45. taskQueue<Args = Record<string, any>>(functionName: string, extensionId?: string): TaskQueue<Args>;
  46. }
  47. /**
  48. * The `TaskQueue` interface.
  49. */
  50. export declare class TaskQueue<Args = Record<string, any>> {
  51. private readonly functionName;
  52. private readonly client;
  53. private readonly extensionId?;
  54. /**
  55. * Creates a task and adds it to the queue. Tasks cannot be updated after creation.
  56. * This action requires `cloudtasks.tasks.create` IAM permission on the service account.
  57. *
  58. * @param data - The data payload of the task.
  59. * @param opts - Optional options when enqueuing a new task.
  60. * @returns A promise that resolves when the task has successfully been added to the queue.
  61. */
  62. enqueue(data: Args, opts?: TaskOptions): Promise<void>;
  63. /**
  64. * Deletes an enqueued task if it has not yet completed.
  65. * @param id - the ID of the task, relative to this queue.
  66. * @returns A promise that resolves when the task has been deleted.
  67. */
  68. delete(id: string): Promise<void>;
  69. }