cloudevent.d.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*! firebase-admin v12.1.1 */
  2. /*!
  3. * @license
  4. * Copyright 2022 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. /**
  19. * A CloudEvent version.
  20. */
  21. export type CloudEventVersion = '1.0';
  22. /**
  23. * A CloudEvent describes event data.
  24. *
  25. * @see https://github.com/cloudevents/spec/blob/v1.0/spec.md
  26. */
  27. export interface CloudEvent {
  28. /**
  29. * Identifier for the event. If not provided, it is auto-populated with a UUID.
  30. *
  31. * @see https://github.com/cloudevents/spec/blob/v1.0/spec.md#id
  32. */
  33. id?: string;
  34. /**
  35. * Identifies the context in which an event happened. If not provided, the value of `EVENTARC_CLOUD_EVENT_SOURCE`
  36. * environment variable is used and if that is not set, a validation error is thrown.
  37. *
  38. * @see https://github.com/cloudevents/spec/blob/v1.0/spec.md#source-1
  39. */
  40. source?: string;
  41. /**
  42. * The version of the CloudEvents specification which the event uses. If not provided, is set to `1.0` --
  43. * the only supported value.
  44. *
  45. * @see https://github.com/cloudevents/spec/blob/v1.0/spec.md#specversion
  46. */
  47. specversion?: CloudEventVersion;
  48. /**
  49. * Type of the event. Should be prefixed with a reverse-DNS name (`com.my-org.v1.something.happended`).
  50. *
  51. * @see https://github.com/cloudevents/spec/blob/v1.0/spec.md#type
  52. */
  53. type: string;
  54. /**
  55. * Subject (context) of the event in the context of the event producer.
  56. *
  57. * @see https://github.com/cloudevents/spec/blob/v1.0/spec.md#subject
  58. */
  59. subject?: string;
  60. /**
  61. * MIME type of the data being sent with the event in the `data` field. Only `application/json` and `text/plain`
  62. * are currently supported. If not specified, it is automatically inferred from the type of provided data.
  63. *
  64. * @see https://github.com/cloudevents/spec/blob/v1.0/spec.md#datacontenttype
  65. */
  66. datacontenttype?: string;
  67. /**
  68. * Timestamp of the event. Must be in ISO time format. If not specified, current time (at the moment of publishing)
  69. * is used.
  70. *
  71. * @see https://github.com/cloudevents/spec/blob/v1.0/spec.md#time
  72. */
  73. time?: string;
  74. /**
  75. * Data payload of the event. Objects are stringified with JSON and strings are be passed along as-is.
  76. */
  77. data?: object | string;
  78. /**
  79. * Custom attributes/extensions. Must be strings. Added to the event as is.
  80. *
  81. * @see https://github.com/cloudevents/spec/blob/v1.0/spec.md#extension-context-attributes
  82. */
  83. [key: string]: any;
  84. }