firebase-admin 13.4.0 → 13.6.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 (218) hide show
  1. package/lib/app/core.d.ts +2 -2
  2. package/lib/app/core.js +2 -2
  3. package/lib/app/credential-factory.d.ts +2 -2
  4. package/lib/app/credential-factory.js +2 -2
  5. package/lib/app/credential-internal.d.ts +2 -2
  6. package/lib/app/credential-internal.js +2 -2
  7. package/lib/app/credential.d.ts +2 -2
  8. package/lib/app/credential.js +2 -2
  9. package/lib/app/firebase-app.d.ts +2 -2
  10. package/lib/app/firebase-app.js +24 -3
  11. package/lib/app/firebase-namespace.d.ts +2 -2
  12. package/lib/app/firebase-namespace.js +2 -2
  13. package/lib/app/index.d.ts +2 -2
  14. package/lib/app/index.js +2 -2
  15. package/lib/app/lifecycle.d.ts +58 -2
  16. package/lib/app/lifecycle.js +142 -24
  17. package/lib/app-check/app-check-api-client-internal.d.ts +2 -2
  18. package/lib/app-check/app-check-api-client-internal.js +2 -2
  19. package/lib/app-check/app-check-api.d.ts +2 -2
  20. package/lib/app-check/app-check-api.js +2 -2
  21. package/lib/app-check/app-check-namespace.d.ts +2 -2
  22. package/lib/app-check/app-check-namespace.js +2 -2
  23. package/lib/app-check/app-check.d.ts +2 -2
  24. package/lib/app-check/app-check.js +2 -2
  25. package/lib/app-check/index.d.ts +2 -2
  26. package/lib/app-check/index.js +2 -2
  27. package/lib/app-check/token-generator.d.ts +2 -2
  28. package/lib/app-check/token-generator.js +2 -2
  29. package/lib/app-check/token-verifier.d.ts +2 -2
  30. package/lib/app-check/token-verifier.js +2 -2
  31. package/lib/auth/action-code-settings-builder.d.ts +2 -2
  32. package/lib/auth/action-code-settings-builder.js +2 -2
  33. package/lib/auth/auth-api-request.d.ts +2 -2
  34. package/lib/auth/auth-api-request.js +2 -2
  35. package/lib/auth/auth-config.d.ts +2 -2
  36. package/lib/auth/auth-config.js +2 -2
  37. package/lib/auth/auth-namespace.d.ts +2 -2
  38. package/lib/auth/auth-namespace.js +2 -2
  39. package/lib/auth/auth.d.ts +2 -2
  40. package/lib/auth/auth.js +2 -2
  41. package/lib/auth/base-auth.d.ts +2 -2
  42. package/lib/auth/base-auth.js +2 -2
  43. package/lib/auth/identifier.d.ts +2 -2
  44. package/lib/auth/identifier.js +2 -2
  45. package/lib/auth/index.d.ts +2 -2
  46. package/lib/auth/index.js +2 -2
  47. package/lib/auth/project-config-manager.d.ts +1 -1
  48. package/lib/auth/project-config-manager.js +1 -1
  49. package/lib/auth/project-config.d.ts +1 -1
  50. package/lib/auth/project-config.js +2 -2
  51. package/lib/auth/tenant-manager.d.ts +2 -2
  52. package/lib/auth/tenant-manager.js +2 -2
  53. package/lib/auth/tenant.d.ts +2 -2
  54. package/lib/auth/tenant.js +2 -2
  55. package/lib/auth/token-generator.d.ts +2 -2
  56. package/lib/auth/token-generator.js +2 -2
  57. package/lib/auth/token-verifier.d.ts +2 -2
  58. package/lib/auth/token-verifier.js +2 -2
  59. package/lib/auth/user-import-builder.d.ts +2 -2
  60. package/lib/auth/user-import-builder.js +2 -2
  61. package/lib/auth/user-record.d.ts +2 -2
  62. package/lib/auth/user-record.js +2 -2
  63. package/lib/credential/index.d.ts +2 -2
  64. package/lib/credential/index.js +2 -2
  65. package/lib/data-connect/data-connect-api-client-internal.d.ts +2 -2
  66. package/lib/data-connect/data-connect-api-client-internal.js +181 -52
  67. package/lib/data-connect/data-connect-api.d.ts +30 -5
  68. package/lib/data-connect/data-connect-api.js +2 -2
  69. package/lib/data-connect/data-connect.d.ts +56 -10
  70. package/lib/data-connect/data-connect.js +22 -9
  71. package/lib/data-connect/index.d.ts +3 -18
  72. package/lib/data-connect/index.js +16 -10
  73. package/lib/data-connect/validate-admin-args.d.ts +18 -0
  74. package/lib/data-connect/validate-admin-args.js +79 -0
  75. package/lib/database/database-namespace.d.ts +2 -2
  76. package/lib/database/database-namespace.js +2 -2
  77. package/lib/database/database.d.ts +2 -2
  78. package/lib/database/database.js +2 -2
  79. package/lib/database/index.d.ts +2 -2
  80. package/lib/database/index.js +2 -2
  81. package/lib/default-namespace.d.ts +2 -2
  82. package/lib/default-namespace.js +2 -2
  83. package/lib/esm/data-connect/index.js +1 -0
  84. package/lib/eventarc/cloudevent.d.ts +2 -2
  85. package/lib/eventarc/cloudevent.js +2 -2
  86. package/lib/eventarc/eventarc-client-internal.d.ts +2 -2
  87. package/lib/eventarc/eventarc-client-internal.js +2 -2
  88. package/lib/eventarc/eventarc-utils.d.ts +2 -2
  89. package/lib/eventarc/eventarc-utils.js +2 -2
  90. package/lib/eventarc/eventarc.d.ts +2 -2
  91. package/lib/eventarc/eventarc.js +2 -2
  92. package/lib/eventarc/index.d.ts +2 -2
  93. package/lib/eventarc/index.js +2 -2
  94. package/lib/extensions/extensions-api-client-internal.d.ts +2 -2
  95. package/lib/extensions/extensions-api-client-internal.js +2 -2
  96. package/lib/extensions/extensions-api.d.ts +2 -2
  97. package/lib/extensions/extensions-api.js +2 -2
  98. package/lib/extensions/extensions.d.ts +2 -2
  99. package/lib/extensions/extensions.js +2 -2
  100. package/lib/extensions/index.d.ts +2 -2
  101. package/lib/extensions/index.js +2 -2
  102. package/lib/firebase-namespace-api.d.ts +2 -2
  103. package/lib/firebase-namespace-api.js +2 -2
  104. package/lib/firestore/firestore-internal.d.ts +2 -2
  105. package/lib/firestore/firestore-internal.js +2 -2
  106. package/lib/firestore/firestore-namespace.d.ts +2 -2
  107. package/lib/firestore/firestore-namespace.js +2 -2
  108. package/lib/firestore/index.d.ts +2 -2
  109. package/lib/firestore/index.js +2 -2
  110. package/lib/functions/functions-api-client-internal.d.ts +2 -2
  111. package/lib/functions/functions-api-client-internal.js +2 -2
  112. package/lib/functions/functions-api.d.ts +2 -2
  113. package/lib/functions/functions-api.js +2 -2
  114. package/lib/functions/functions.d.ts +2 -2
  115. package/lib/functions/functions.js +2 -2
  116. package/lib/functions/index.d.ts +2 -2
  117. package/lib/functions/index.js +2 -2
  118. package/lib/index.d.ts +2 -2
  119. package/lib/index.js +2 -2
  120. package/lib/installations/index.d.ts +2 -2
  121. package/lib/installations/index.js +2 -2
  122. package/lib/installations/installations-namespace.d.ts +2 -2
  123. package/lib/installations/installations-namespace.js +2 -2
  124. package/lib/installations/installations-request-handler.d.ts +2 -2
  125. package/lib/installations/installations-request-handler.js +2 -2
  126. package/lib/installations/installations.d.ts +2 -2
  127. package/lib/installations/installations.js +2 -2
  128. package/lib/instance-id/index.d.ts +2 -2
  129. package/lib/instance-id/index.js +2 -2
  130. package/lib/instance-id/instance-id-namespace.d.ts +1 -1
  131. package/lib/instance-id/instance-id-namespace.js +1 -1
  132. package/lib/instance-id/instance-id.d.ts +2 -2
  133. package/lib/instance-id/instance-id.js +2 -2
  134. package/lib/machine-learning/index.d.ts +2 -2
  135. package/lib/machine-learning/index.js +2 -2
  136. package/lib/machine-learning/machine-learning-api-client.d.ts +2 -2
  137. package/lib/machine-learning/machine-learning-api-client.js +2 -2
  138. package/lib/machine-learning/machine-learning-namespace.d.ts +2 -2
  139. package/lib/machine-learning/machine-learning-namespace.js +2 -2
  140. package/lib/machine-learning/machine-learning-utils.d.ts +2 -2
  141. package/lib/machine-learning/machine-learning-utils.js +2 -2
  142. package/lib/machine-learning/machine-learning.d.ts +2 -2
  143. package/lib/machine-learning/machine-learning.js +2 -2
  144. package/lib/messaging/index.d.ts +2 -2
  145. package/lib/messaging/index.js +2 -2
  146. package/lib/messaging/messaging-api-request-internal.d.ts +2 -2
  147. package/lib/messaging/messaging-api-request-internal.js +2 -2
  148. package/lib/messaging/messaging-api.d.ts +6 -2
  149. package/lib/messaging/messaging-api.js +2 -2
  150. package/lib/messaging/messaging-errors-internal.d.ts +2 -2
  151. package/lib/messaging/messaging-errors-internal.js +2 -2
  152. package/lib/messaging/messaging-internal.d.ts +2 -2
  153. package/lib/messaging/messaging-internal.js +18 -2
  154. package/lib/messaging/messaging-namespace.d.ts +2 -2
  155. package/lib/messaging/messaging-namespace.js +2 -2
  156. package/lib/messaging/messaging.d.ts +2 -2
  157. package/lib/messaging/messaging.js +2 -2
  158. package/lib/project-management/android-app.d.ts +2 -2
  159. package/lib/project-management/android-app.js +2 -2
  160. package/lib/project-management/app-metadata.d.ts +2 -2
  161. package/lib/project-management/app-metadata.js +2 -2
  162. package/lib/project-management/index.d.ts +2 -2
  163. package/lib/project-management/index.js +2 -2
  164. package/lib/project-management/ios-app.d.ts +2 -2
  165. package/lib/project-management/ios-app.js +2 -2
  166. package/lib/project-management/project-management-api-request-internal.d.ts +2 -2
  167. package/lib/project-management/project-management-api-request-internal.js +2 -2
  168. package/lib/project-management/project-management-namespace.d.ts +2 -2
  169. package/lib/project-management/project-management-namespace.js +2 -2
  170. package/lib/project-management/project-management.d.ts +2 -2
  171. package/lib/project-management/project-management.js +2 -2
  172. package/lib/remote-config/condition-evaluator-internal.d.ts +2 -2
  173. package/lib/remote-config/condition-evaluator-internal.js +2 -2
  174. package/lib/remote-config/index.d.ts +2 -2
  175. package/lib/remote-config/index.js +2 -2
  176. package/lib/remote-config/internal/value-impl.d.ts +2 -2
  177. package/lib/remote-config/internal/value-impl.js +2 -2
  178. package/lib/remote-config/remote-config-api-client-internal.d.ts +2 -2
  179. package/lib/remote-config/remote-config-api-client-internal.js +2 -2
  180. package/lib/remote-config/remote-config-api.d.ts +2 -2
  181. package/lib/remote-config/remote-config-api.js +2 -2
  182. package/lib/remote-config/remote-config-namespace.d.ts +2 -2
  183. package/lib/remote-config/remote-config-namespace.js +2 -2
  184. package/lib/remote-config/remote-config.d.ts +2 -2
  185. package/lib/remote-config/remote-config.js +2 -2
  186. package/lib/security-rules/index.d.ts +2 -2
  187. package/lib/security-rules/index.js +2 -2
  188. package/lib/security-rules/security-rules-api-client-internal.d.ts +2 -2
  189. package/lib/security-rules/security-rules-api-client-internal.js +2 -2
  190. package/lib/security-rules/security-rules-internal.d.ts +2 -2
  191. package/lib/security-rules/security-rules-internal.js +2 -2
  192. package/lib/security-rules/security-rules-namespace.d.ts +2 -2
  193. package/lib/security-rules/security-rules-namespace.js +2 -2
  194. package/lib/security-rules/security-rules.d.ts +2 -2
  195. package/lib/security-rules/security-rules.js +2 -2
  196. package/lib/storage/index.d.ts +2 -2
  197. package/lib/storage/index.js +2 -2
  198. package/lib/storage/storage-namespace.d.ts +2 -2
  199. package/lib/storage/storage-namespace.js +2 -2
  200. package/lib/storage/storage.d.ts +2 -2
  201. package/lib/storage/storage.js +2 -2
  202. package/lib/storage/utils.d.ts +1 -1
  203. package/lib/storage/utils.js +1 -1
  204. package/lib/utils/api-request.d.ts +2 -2
  205. package/lib/utils/api-request.js +8 -4
  206. package/lib/utils/crypto-signer.d.ts +2 -2
  207. package/lib/utils/crypto-signer.js +2 -2
  208. package/lib/utils/deep-copy.d.ts +2 -2
  209. package/lib/utils/deep-copy.js +2 -2
  210. package/lib/utils/error.d.ts +2 -2
  211. package/lib/utils/error.js +2 -2
  212. package/lib/utils/index.d.ts +2 -2
  213. package/lib/utils/index.js +2 -2
  214. package/lib/utils/jwt.d.ts +2 -2
  215. package/lib/utils/jwt.js +2 -2
  216. package/lib/utils/validator.d.ts +2 -2
  217. package/lib/utils/validator.js +2 -2
  218. package/package.json +8 -5
@@ -1,8 +1,8 @@
1
- /*! firebase-admin v13.4.0 */
1
+ /*! firebase-admin v13.6.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
5
- * Copyright 2024 Google Inc.
5
+ * Copyright 2024 Google LLC
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -23,16 +23,41 @@ const api_request_1 = require("../utils/api-request");
23
23
  const error_1 = require("../utils/error");
24
24
  const utils = require("../utils/index");
25
25
  const validator = require("../utils/validator");
26
- const API_VERSION = 'v1alpha';
27
- /** The Firebase Data Connect backend base URL format. */
28
- const FIREBASE_DATA_CONNECT_BASE_URL_FORMAT = 'https://firebasedataconnect.googleapis.com/{version}/projects/{projectId}/locations/{locationId}/services/{serviceId}:{endpointId}';
29
- /** Firebase Data Connect base URl format when using the Data Connect emultor. */
30
- const FIREBASE_DATA_CONNECT_EMULATOR_BASE_URL_FORMAT = 'http://{host}/{version}/projects/{projectId}/locations/{locationId}/services/{serviceId}:{endpointId}';
26
+ const API_VERSION = 'v1';
27
+ const FIREBASE_DATA_CONNECT_PROD_URL = 'https://firebasedataconnect.googleapis.com';
28
+ /** The Firebase Data Connect backend service URL format. */
29
+ const FIREBASE_DATA_CONNECT_SERVICES_URL_FORMAT = FIREBASE_DATA_CONNECT_PROD_URL +
30
+ '/{version}' +
31
+ '/projects/{projectId}' +
32
+ '/locations/{locationId}' +
33
+ '/services/{serviceId}' +
34
+ ':{endpointId}';
35
+ /** The Firebase Data Connect backend connector URL format. */
36
+ const FIREBASE_DATA_CONNECT_CONNECTORS_URL_FORMAT = FIREBASE_DATA_CONNECT_PROD_URL +
37
+ '/{version}' +
38
+ '/projects/{projectId}' +
39
+ '/locations/{locationId}' +
40
+ '/services/{serviceId}' +
41
+ '/connectors/{connectorId}' +
42
+ ':{endpointId}';
43
+ /** Firebase Data Connect service URL format when using the Data Connect emulator. */
44
+ const FIREBASE_DATA_CONNECT_EMULATOR_SERVICES_URL_FORMAT = 'http://{host}/{version}/projects/{projectId}/locations/{locationId}/services/{serviceId}:{endpointId}';
45
+ /** Firebase Data Connect connector URL format when using the Data Connect emulator. */
46
+ const FIREBASE_DATA_CONNECT_EMULATOR_CONNECTORS_URL_FORMAT = 'http://{host}/{version}/projects/{projectId}/locations/{locationId}/services/{serviceId}/connectors/{connectorId}:{endpointId}';
31
47
  const EXECUTE_GRAPH_QL_ENDPOINT = 'executeGraphql';
32
48
  const EXECUTE_GRAPH_QL_READ_ENDPOINT = 'executeGraphqlRead';
33
- const DATA_CONNECT_CONFIG_HEADERS = {
34
- 'X-Firebase-Client': `fire-admin-node/${utils.getSdkVersion()}`
35
- };
49
+ const IMPERSONATE_QUERY_ENDPOINT = 'impersonateQuery';
50
+ const IMPERSONATE_MUTATION_ENDPOINT = 'impersonateMutation';
51
+ function getHeaders(isUsingGen) {
52
+ const headerValue = {
53
+ 'X-Firebase-Client': `fire-admin-node/${utils.getSdkVersion()}`,
54
+ 'X-Goog-Api-Client': utils.getMetricsHeader(),
55
+ };
56
+ if (isUsingGen) {
57
+ headerValue['X-Goog-Api-Client'] += ' admin-js/gen';
58
+ }
59
+ return headerValue;
60
+ }
36
61
  /**
37
62
  * Class that facilitates sending requests to the Firebase Data Connect backend API.
38
63
  *
@@ -42,11 +67,19 @@ class DataConnectApiClient {
42
67
  constructor(connectorConfig, app) {
43
68
  this.connectorConfig = connectorConfig;
44
69
  this.app = app;
70
+ this.isUsingGen = false;
45
71
  if (!validator.isNonNullObject(app) || !('options' in app)) {
46
72
  throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, 'First argument passed to getDataConnect() must be a valid Firebase app instance.');
47
73
  }
48
74
  this.httpClient = new DataConnectHttpClient(app);
49
75
  }
76
+ /**
77
+ * Update whether the SDK is using a generated one or not.
78
+ * @param isUsingGen
79
+ */
80
+ setIsUsingGen(isUsingGen) {
81
+ this.isUsingGen = isUsingGen;
82
+ }
50
83
  /**
51
84
  * Execute arbitrary GraphQL, including both read and write queries
52
85
  *
@@ -68,6 +101,14 @@ class DataConnectApiClient {
68
101
  async executeGraphqlRead(query, options) {
69
102
  return this.executeGraphqlHelper(query, EXECUTE_GRAPH_QL_READ_ENDPOINT, options);
70
103
  }
104
+ /**
105
+ * A helper function to execute GraphQL queries.
106
+ *
107
+ * @param query - The arbitrary GraphQL query to execute.
108
+ * @param endpoint - The endpoint to call.
109
+ * @param options - The GraphQL options.
110
+ * @returns A promise that fulfills with the GraphQL response, or throws an error.
111
+ */
71
112
  async executeGraphqlHelper(query, endpoint, options) {
72
113
  if (!validator.isNonEmptyString(query)) {
73
114
  throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, '`query` must be a non-empty string.');
@@ -83,51 +124,116 @@ class DataConnectApiClient {
83
124
  ...(options?.operationName && { operationName: options?.operationName }),
84
125
  ...(options?.impersonate && { extensions: { impersonate: options?.impersonate } }),
85
126
  };
86
- return this.getUrl(API_VERSION, this.connectorConfig.location, this.connectorConfig.serviceId, endpoint)
87
- .then(async (url) => {
88
- const request = {
89
- method: 'POST',
90
- url,
91
- headers: DATA_CONNECT_CONFIG_HEADERS,
92
- data,
93
- };
94
- const resp = await this.httpClient.send(request);
95
- if (resp.data.errors && validator.isNonEmptyArray(resp.data.errors)) {
96
- const allMessages = resp.data.errors.map((error) => error.message).join(' ');
97
- throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.QUERY_ERROR, allMessages);
98
- }
99
- return Promise.resolve({
100
- data: resp.data.data,
101
- });
102
- })
103
- .then((resp) => {
127
+ const url = await this.getServicesUrl(API_VERSION, this.connectorConfig.location, this.connectorConfig.serviceId, endpoint);
128
+ try {
129
+ const resp = await this.makeGqlRequest(url, data);
104
130
  return resp;
105
- })
106
- .catch((err) => {
131
+ }
132
+ catch (err) {
107
133
  throw this.toFirebaseError(err);
108
- });
134
+ }
109
135
  }
110
- async getUrl(version, locationId, serviceId, endpointId) {
111
- return this.getProjectId()
112
- .then((projectId) => {
113
- const urlParams = {
114
- version,
115
- projectId,
116
- locationId,
117
- serviceId,
118
- endpointId
119
- };
120
- let urlFormat;
121
- if (useEmulator()) {
122
- urlFormat = utils.formatString(FIREBASE_DATA_CONNECT_EMULATOR_BASE_URL_FORMAT, {
123
- host: emulatorHost()
124
- });
125
- }
126
- else {
127
- urlFormat = FIREBASE_DATA_CONNECT_BASE_URL_FORMAT;
128
- }
129
- return utils.formatString(urlFormat, urlParams);
130
- });
136
+ /**
137
+ * Executes a GraphQL query with impersonation.
138
+ *
139
+ * @param options - The GraphQL options. Must include impersonation details.
140
+ * @returns A promise that fulfills with the GraphQL response.
141
+ */
142
+ async executeQuery(name, variables, options) {
143
+ return this.executeOperationHelper(IMPERSONATE_QUERY_ENDPOINT, name, variables, options);
144
+ }
145
+ /**
146
+ * Executes a GraphQL mutation with impersonation.
147
+ *
148
+ * @param options - The GraphQL options. Must include impersonation details.
149
+ * @returns A promise that fulfills with the GraphQL response.
150
+ */
151
+ async executeMutation(name, variables, options) {
152
+ return this.executeOperationHelper(IMPERSONATE_MUTATION_ENDPOINT, name, variables, options);
153
+ }
154
+ /**
155
+ * A helper function to execute operations by making requests to FDC's impersonate
156
+ * operations endpoints.
157
+ *
158
+ * @param endpoint - The endpoint to call.
159
+ * @param options - The GraphQL options, including impersonation details.
160
+ * @returns A promise that fulfills with the GraphQL response.
161
+ */
162
+ async executeOperationHelper(endpoint, name, variables, options) {
163
+ if (typeof name === 'undefined' ||
164
+ !validator.isNonEmptyString(name)) {
165
+ throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, '`name` must be a non-empty string.');
166
+ }
167
+ if (this.connectorConfig.connector === undefined || this.connectorConfig.connector === '') {
168
+ throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, `The 'connectorConfig.connector' field used to instantiate your Data Connect
169
+ instance must be a non-empty string (the connectorId) when calling executeQuery or executeMutation.`);
170
+ }
171
+ const data = {
172
+ ...(variables && { variables: variables }),
173
+ operationName: name,
174
+ extensions: { impersonate: options?.impersonate },
175
+ };
176
+ const url = await this.getConnectorsUrl(API_VERSION, this.connectorConfig.location, this.connectorConfig.serviceId, this.connectorConfig.connector, endpoint);
177
+ try {
178
+ const resp = await this.makeGqlRequest(url, data);
179
+ return resp;
180
+ }
181
+ catch (err) {
182
+ throw this.toFirebaseError(err);
183
+ }
184
+ }
185
+ /**
186
+ * Constructs the URL for a Data Connect request to a service endpoint.
187
+ *
188
+ * @param version - The API version.
189
+ * @param locationId - The location of the Data Connect service.
190
+ * @param serviceId - The ID of the Data Connect service.
191
+ * @param endpointId - The endpoint to call.
192
+ * @returns A promise which resolves to the formatted URL string.
193
+ */
194
+ async getServicesUrl(version, locationId, serviceId, endpointId) {
195
+ const projectId = await this.getProjectId();
196
+ const params = {
197
+ version,
198
+ projectId,
199
+ locationId,
200
+ serviceId,
201
+ endpointId,
202
+ };
203
+ let urlFormat = FIREBASE_DATA_CONNECT_SERVICES_URL_FORMAT;
204
+ if (useEmulator()) {
205
+ urlFormat = FIREBASE_DATA_CONNECT_EMULATOR_SERVICES_URL_FORMAT;
206
+ params.host = emulatorHost();
207
+ }
208
+ return utils.formatString(urlFormat, params);
209
+ }
210
+ /**
211
+ * Constructs the URL for a Data Connect request to a connector endpoint.
212
+ *
213
+ * @param version - The API version.
214
+ * @param locationId - The location of the Data Connect service.
215
+ * @param serviceId - The ID of the Data Connect service.
216
+ * @param connectorId - The ID of the Connector.
217
+ * @param endpointId - The endpoint to call.
218
+ * @returns A promise which resolves to the formatted URL string.
219
+
220
+ */
221
+ async getConnectorsUrl(version, locationId, serviceId, connectorId, endpointId) {
222
+ const projectId = await this.getProjectId();
223
+ const params = {
224
+ version,
225
+ projectId,
226
+ locationId,
227
+ serviceId,
228
+ connectorId,
229
+ endpointId,
230
+ };
231
+ let urlFormat = FIREBASE_DATA_CONNECT_CONNECTORS_URL_FORMAT;
232
+ if (useEmulator()) {
233
+ urlFormat = FIREBASE_DATA_CONNECT_EMULATOR_CONNECTORS_URL_FORMAT;
234
+ params.host = emulatorHost();
235
+ }
236
+ return utils.formatString(urlFormat, params);
131
237
  }
132
238
  getProjectId() {
133
239
  if (this.projectId) {
@@ -144,6 +250,29 @@ class DataConnectApiClient {
144
250
  return projectId;
145
251
  });
146
252
  }
253
+ /**
254
+ * Makes a GraphQL request to the specified url.
255
+ *
256
+ * @param url - The URL to send the request to.
257
+ * @param data - The GraphQL request payload.
258
+ * @returns A promise that fulfills with the GraphQL response, or throws an error.
259
+ */
260
+ async makeGqlRequest(url, data) {
261
+ const request = {
262
+ method: 'POST',
263
+ url,
264
+ headers: getHeaders(this.isUsingGen),
265
+ data,
266
+ };
267
+ const resp = await this.httpClient.send(request);
268
+ if (resp.data.errors && validator.isNonEmptyArray(resp.data.errors)) {
269
+ const allMessages = resp.data.errors.map((error) => error.message).join(' ');
270
+ throw new FirebaseDataConnectError(exports.DATA_CONNECT_ERROR_CODE_MAPPING.QUERY_ERROR, allMessages);
271
+ }
272
+ return Promise.resolve({
273
+ data: resp.data.data,
274
+ });
275
+ }
147
276
  toFirebaseError(err) {
148
277
  if (err instanceof error_1.PrefixedFirebaseError) {
149
278
  return err;
@@ -1,7 +1,7 @@
1
- /*! firebase-admin v13.4.0 */
1
+ /*! firebase-admin v13.6.0 */
2
2
  /*!
3
3
  * @license
4
- * Copyright 2024 Google Inc.
4
+ * Copyright 2024 Google LLC
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -28,9 +28,13 @@ export interface ConnectorConfig {
28
28
  * Service ID of the Data Connect service.
29
29
  */
30
30
  serviceId: string;
31
+ /**
32
+ * Name of the Data Connect connector.
33
+ */
34
+ connector?: string;
31
35
  }
32
36
  /**
33
- * Interface representing GraphQL response.
37
+ * Interface representing ExecuteGraphQL response.
34
38
  */
35
39
  export interface ExecuteGraphqlResponse<GraphqlResponse> {
36
40
  /**
@@ -39,7 +43,16 @@ export interface ExecuteGraphqlResponse<GraphqlResponse> {
39
43
  data: GraphqlResponse;
40
44
  }
41
45
  /**
42
- * Interface representing GraphQL options.
46
+ * Interface representing ExecuteOperation response.
47
+ */
48
+ export interface ExecuteOperationResponse<GraphqlResponse> {
49
+ /**
50
+ * Data payload of the GraphQL response.
51
+ */
52
+ data: GraphqlResponse;
53
+ }
54
+ /**
55
+ * Interface representing GraphQL options for executing arbitrary GraphQL operations.
43
56
  */
44
57
  export interface GraphqlOptions<Variables> {
45
58
  /**
@@ -47,7 +60,9 @@ export interface GraphqlOptions<Variables> {
47
60
  */
48
61
  variables?: Variables;
49
62
  /**
50
- * The name of the GraphQL operation. Required only if `query` contains multiple operations.
63
+ * The name of the GraphQL operation.
64
+ * Required for operations that interact with services, such as executeGraphql, if
65
+ * `query` contains multiple operations.
51
66
  */
52
67
  operationName?: string;
53
68
  /**
@@ -56,6 +71,16 @@ export interface GraphqlOptions<Variables> {
56
71
  */
57
72
  impersonate?: ImpersonateAuthenticated | ImpersonateUnauthenticated;
58
73
  }
74
+ /**
75
+ * Interface representing options for executing defined operations.
76
+ */
77
+ export interface OperationOptions {
78
+ /**
79
+ * If set, impersonate a request with given Firebase Auth context and evaluate the auth
80
+ * policies on the operation. If omitted, bypass any defined auth policies.
81
+ */
82
+ impersonate?: ImpersonateAuthenticated | ImpersonateUnauthenticated;
83
+ }
59
84
  /**
60
85
  * Type representing the partial claims of a Firebase Auth token used to evaluate the
61
86
  * Data Connect auth policy.
@@ -1,8 +1,8 @@
1
- /*! firebase-admin v13.4.0 */
1
+ /*! firebase-admin v13.6.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
5
- * Copyright 2024 Google Inc.
5
+ * Copyright 2024 Google LLC
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
- /*! firebase-admin v13.4.0 */
1
+ /*! firebase-admin v13.6.0 */
2
2
  /*!
3
3
  * @license
4
- * Copyright 2024 Google Inc.
4
+ * Copyright 2024 Google LLC
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  import { App } from '../app';
19
- import { ConnectorConfig, ExecuteGraphqlResponse, GraphqlOptions } from './data-connect-api';
19
+ import { ConnectorConfig, ExecuteGraphqlResponse, ExecuteOperationResponse, GraphqlOptions, OperationOptions } from './data-connect-api';
20
20
  export declare class DataConnectService {
21
21
  private readonly appInternal;
22
22
  private dataConnectInstances;
@@ -46,13 +46,13 @@ export declare class DataConnect {
46
46
  */
47
47
  executeGraphql<GraphqlResponse, Variables>(query: string, options?: GraphqlOptions<Variables>): Promise<ExecuteGraphqlResponse<GraphqlResponse>>;
48
48
  /**
49
- * Execute an arbitrary read-only GraphQL query
50
- *
51
- * @param query - The GraphQL read-only query.
52
- * @param options - Optional {@link GraphqlOptions} when executing a read-only GraphQL query.
53
- *
54
- * @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
55
- */
49
+ * Execute an arbitrary read-only GraphQL query
50
+ *
51
+ * @param query - The GraphQL read-only query.
52
+ * @param options - Optional {@link GraphqlOptions} when executing a read-only GraphQL query.
53
+ *
54
+ * @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
55
+ */
56
56
  executeGraphqlRead<GraphqlResponse, Variables>(query: string, options?: GraphqlOptions<Variables>): Promise<ExecuteGraphqlResponse<GraphqlResponse>>;
57
57
  /**
58
58
  * Insert a single row into the specified table.
@@ -86,4 +86,50 @@ export declare class DataConnect {
86
86
  * @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
87
87
  */
88
88
  upsertMany<GraphQlResponse, Variables extends Array<unknown>>(tableName: string, variables: Variables): Promise<ExecuteGraphqlResponse<GraphQlResponse>>;
89
+ /**
90
+ * Executes a GraphQL query. The query must be defined in your Data Connect GraphQL files.
91
+ * Optionally, you can provide auth impersonation details. If you don't
92
+ * specify a value for this option, the query will run with admin privileges
93
+ * and will ignore all auth directives.
94
+ *
95
+ * @param name - The name of the defined query to execute.
96
+ * @param options - The GraphQL options, must include operationName and impersonation details.
97
+ * @returns A promise that fulfills with the GraphQL response.
98
+ */
99
+ executeQuery<Data>(name: string, options?: OperationOptions): Promise<ExecuteOperationResponse<Data>>;
100
+ /**
101
+ * Executes a GraphQL query. The query must be defined in your Data Connect GraphQL files.
102
+ * Optionally, you can provide auth impersonation details. If you don't
103
+ * specify a value for this option, the query will run with admin privileges
104
+ * and will ignore all auth directives.
105
+ *
106
+ * @param name - The name of the defined query to execute.
107
+ * @param variables - The variables for the query. May be optional if the query's variables are optional.
108
+ * @param options - The GraphQL options, must include operationName and impersonation details.
109
+ * @returns A promise that fulfills with the GraphQL response.
110
+ */
111
+ executeQuery<Data, Variables>(name: string, variables: Variables, options?: OperationOptions): Promise<ExecuteOperationResponse<Data>>;
112
+ /**
113
+ * Executes a GraphQL mutation. The mutation must be defined in your Data Connect GraphQL files.
114
+ * Optionally, you can provide auth impersonation details. If you don't
115
+ * specify a value for this option, the query will run with admin privileges
116
+ * and will ignore all auth directives.
117
+ *
118
+ * @param name - The name of the defined mutation to execute.
119
+ * @param options - The GraphQL options, must include operationName and impersonation details.
120
+ * @returns A promise that fulfills with the GraphQL response.
121
+ */
122
+ executeMutation<Data>(name: string, options?: OperationOptions): Promise<ExecuteOperationResponse<Data>>;
123
+ /**
124
+ * Executes a GraphQL mutation. The mutation must be defined in your Data Connect GraphQL files.
125
+ * Optionally, you can provide auth impersonation details. If you don't
126
+ * specify a value for this option, the query will run with admin privileges
127
+ * and will ignore all auth directives.
128
+ *
129
+ * @param name - The name of the defined mutation to execute.
130
+ * @param variables - The variables for the mutation. May be optional if the mutation's variables are optional.
131
+ * @param options - The GraphQL options, must include operationName and impersonation details.
132
+ * @returns A promise that fulfills with the GraphQL response.
133
+ */
134
+ executeMutation<Data, Variables>(name: string, variables: Variables, options?: OperationOptions): Promise<ExecuteOperationResponse<Data>>;
89
135
  }
@@ -1,8 +1,8 @@
1
- /*! firebase-admin v13.4.0 */
1
+ /*! firebase-admin v13.6.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
5
- * Copyright 2024 Google Inc.
5
+ * Copyright 2024 Google LLC
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -59,6 +59,13 @@ class DataConnect {
59
59
  this.app = app;
60
60
  this.client = new data_connect_api_client_internal_1.DataConnectApiClient(connectorConfig, app);
61
61
  }
62
+ /**
63
+ * @param isUsingGen
64
+ * @internal
65
+ */
66
+ useGen(isUsingGen) {
67
+ this.client.setIsUsingGen(isUsingGen);
68
+ }
62
69
  /**
63
70
  * Execute an arbitrary GraphQL query or mutation
64
71
  *
@@ -71,13 +78,13 @@ class DataConnect {
71
78
  return this.client.executeGraphql(query, options);
72
79
  }
73
80
  /**
74
- * Execute an arbitrary read-only GraphQL query
75
- *
76
- * @param query - The GraphQL read-only query.
77
- * @param options - Optional {@link GraphqlOptions} when executing a read-only GraphQL query.
78
- *
79
- * @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
80
- */
81
+ * Execute an arbitrary read-only GraphQL query
82
+ *
83
+ * @param query - The GraphQL read-only query.
84
+ * @param options - Optional {@link GraphqlOptions} when executing a read-only GraphQL query.
85
+ *
86
+ * @returns A promise that fulfills with a `ExecuteGraphqlResponse`.
87
+ */
81
88
  executeGraphqlRead(query, options) {
82
89
  return this.client.executeGraphqlRead(query, options);
83
90
  }
@@ -121,5 +128,11 @@ class DataConnect {
121
128
  upsertMany(tableName, variables) {
122
129
  return this.client.upsertMany(tableName, variables);
123
130
  }
131
+ executeQuery(name, variables, options) {
132
+ return this.client.executeQuery(name, variables, options);
133
+ }
134
+ executeMutation(name, variables, options) {
135
+ return this.client.executeMutation(name, variables, options);
136
+ }
124
137
  }
125
138
  exports.DataConnect = DataConnect;
@@ -1,20 +1,4 @@
1
- /*! firebase-admin v13.4.0 */
2
- /*!
3
- * @license
4
- * Copyright 2024 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
- */
1
+ /*! firebase-admin v13.6.0 */
18
2
  /**
19
3
  * Firebase Data Connect service.
20
4
  *
@@ -23,7 +7,7 @@
23
7
  import { App } from '../app';
24
8
  import { DataConnect } from './data-connect';
25
9
  import { ConnectorConfig } from './data-connect-api';
26
- export { GraphqlOptions, ExecuteGraphqlResponse, ConnectorConfig, ImpersonateAuthenticated, ImpersonateUnauthenticated, AuthClaims } from './data-connect-api';
10
+ export { GraphqlOptions, ExecuteGraphqlResponse, ExecuteOperationResponse, ConnectorConfig, ImpersonateAuthenticated, ImpersonateUnauthenticated, AuthClaims, OperationOptions, } from './data-connect-api';
27
11
  export { DataConnect, } from './data-connect';
28
12
  /**
29
13
  * Gets the {@link DataConnect} service with the provided connector configuration
@@ -38,6 +22,7 @@ export { DataConnect, } from './data-connect';
38
22
  * const connectorConfig: ConnectorConfig = {
39
23
  * location: 'us-west2',
40
24
  * serviceId: 'my-service',
25
+ * connectorName: 'my-connector',
41
26
  * };
42
27
  *
43
28
  * // Get the `DataConnect` service for the default app
@@ -1,8 +1,16 @@
1
- /*! firebase-admin v13.4.0 */
1
+ /*! firebase-admin v13.6.0 */
2
2
  "use strict";
3
+ /**
4
+ * Firebase Data Connect service.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.validateAdminArgs = exports.DataConnect = void 0;
10
+ exports.getDataConnect = getDataConnect;
3
11
  /*!
4
12
  * @license
5
- * Copyright 2024 Google Inc.
13
+ * Copyright 2024 Google LLC
6
14
  *
7
15
  * Licensed under the Apache License, Version 2.0 (the "License");
8
16
  * you may not use this file except in compliance with the License.
@@ -16,14 +24,7 @@
16
24
  * See the License for the specific language governing permissions and
17
25
  * limitations under the License.
18
26
  */
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.DataConnect = void 0;
21
- exports.getDataConnect = getDataConnect;
22
- /**
23
- * Firebase Data Connect service.
24
- *
25
- * @packageDocumentation
26
- */
27
+ const validate_admin_args_1 = require("./validate-admin-args");
27
28
  const app_1 = require("../app");
28
29
  const data_connect_1 = require("./data-connect");
29
30
  var data_connect_2 = require("./data-connect");
@@ -41,6 +42,7 @@ Object.defineProperty(exports, "DataConnect", { enumerable: true, get: function
41
42
  * const connectorConfig: ConnectorConfig = {
42
43
  * location: 'us-west2',
43
44
  * serviceId: 'my-service',
45
+ * connectorName: 'my-connector',
44
46
  * };
45
47
  *
46
48
  * // Get the `DataConnect` service for the default app
@@ -69,3 +71,7 @@ function getDataConnect(connectorConfig, app) {
69
71
  const dataConnectService = firebaseApp.getOrInitService('dataConnect', (app) => new data_connect_1.DataConnectService(app));
70
72
  return dataConnectService.getDataConnect(connectorConfig);
71
73
  }
74
+ /**
75
+ * @internal
76
+ */
77
+ exports.validateAdminArgs = validate_admin_args_1._validateAdminArgs;
@@ -0,0 +1,18 @@
1
+ /*! firebase-admin v13.6.0 */
2
+ /*!
3
+ * @license
4
+ * Copyright 2025 Google LLC
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
+ export {};