firebase-admin 10.1.0 → 11.0.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 (194) hide show
  1. package/README.md +1 -1
  2. package/lib/app/core.d.ts +1 -1
  3. package/lib/app/core.js +1 -1
  4. package/lib/app/credential-factory.d.ts +1 -1
  5. package/lib/app/credential-factory.js +8 -8
  6. package/lib/app/credential-internal.d.ts +3 -1
  7. package/lib/app/credential-internal.js +103 -95
  8. package/lib/app/credential.d.ts +1 -1
  9. package/lib/app/credential.js +1 -1
  10. package/lib/app/firebase-app.d.ts +1 -1
  11. package/lib/app/firebase-app.js +76 -91
  12. package/lib/app/firebase-namespace.d.ts +1 -1
  13. package/lib/app/firebase-namespace.js +209 -279
  14. package/lib/app/index.d.ts +1 -1
  15. package/lib/app/index.js +4 -4
  16. package/lib/app/lifecycle.d.ts +1 -1
  17. package/lib/app/lifecycle.js +37 -43
  18. package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
  19. package/lib/app-check/app-check-api-client-internal.js +54 -73
  20. package/lib/app-check/app-check-api.d.ts +1 -1
  21. package/lib/app-check/app-check-api.js +1 -1
  22. package/lib/app-check/app-check-namespace.d.ts +1 -1
  23. package/lib/app-check/app-check-namespace.js +1 -1
  24. package/lib/app-check/app-check.d.ts +1 -1
  25. package/lib/app-check/app-check.js +17 -19
  26. package/lib/app-check/index.d.ts +1 -1
  27. package/lib/app-check/index.js +7 -7
  28. package/lib/app-check/token-generator.d.ts +1 -1
  29. package/lib/app-check/token-generator.js +47 -52
  30. package/lib/app-check/token-verifier.d.ts +1 -1
  31. package/lib/app-check/token-verifier.js +46 -50
  32. package/lib/auth/action-code-settings-builder.d.ts +1 -1
  33. package/lib/auth/action-code-settings-builder.js +10 -11
  34. package/lib/auth/auth-api-request.d.ts +1 -1
  35. package/lib/auth/auth-api-request.js +355 -382
  36. package/lib/auth/auth-config.d.ts +1 -1
  37. package/lib/auth/auth-config.js +95 -106
  38. package/lib/auth/auth-namespace.d.ts +1 -1
  39. package/lib/auth/auth-namespace.js +1 -1
  40. package/lib/auth/auth.d.ts +1 -1
  41. package/lib/auth/auth.js +20 -40
  42. package/lib/auth/base-auth.d.ts +26 -1
  43. package/lib/auth/base-auth.js +162 -142
  44. package/lib/auth/identifier.d.ts +1 -1
  45. package/lib/auth/identifier.js +2 -2
  46. package/lib/auth/index.d.ts +1 -1
  47. package/lib/auth/index.js +7 -7
  48. package/lib/auth/tenant-manager.d.ts +1 -1
  49. package/lib/auth/tenant-manager.js +49 -71
  50. package/lib/auth/tenant.d.ts +1 -1
  51. package/lib/auth/tenant.js +44 -55
  52. package/lib/auth/token-generator.d.ts +1 -1
  53. package/lib/auth/token-generator.js +49 -53
  54. package/lib/auth/token-verifier.d.ts +1 -1
  55. package/lib/auth/token-verifier.js +83 -91
  56. package/lib/auth/user-import-builder.d.ts +1 -1
  57. package/lib/auth/user-import-builder.js +70 -73
  58. package/lib/auth/user-record.d.ts +1 -1
  59. package/lib/auth/user-record.js +61 -84
  60. package/lib/credential/index.d.ts +1 -1
  61. package/lib/credential/index.js +2 -2
  62. package/lib/database/database-namespace.d.ts +1 -1
  63. package/lib/database/database-namespace.js +1 -1
  64. package/lib/database/database.d.ts +1 -1
  65. package/lib/database/database.js +92 -108
  66. package/lib/database/index.d.ts +1 -1
  67. package/lib/database/index.js +10 -10
  68. package/lib/default-namespace.d.ts +1 -1
  69. package/lib/default-namespace.js +2 -2
  70. package/lib/esm/eventarc/index.js +5 -0
  71. package/lib/esm/functions/index.js +5 -0
  72. package/lib/eventarc/cloudevent.d.ts +84 -0
  73. package/lib/eventarc/cloudevent.js +19 -0
  74. package/lib/eventarc/eventarc-client-internal.d.ts +18 -0
  75. package/lib/eventarc/eventarc-client-internal.js +139 -0
  76. package/lib/eventarc/eventarc-utils.d.ts +31 -0
  77. package/lib/eventarc/eventarc-utils.js +125 -0
  78. package/lib/eventarc/eventarc.d.ts +107 -0
  79. package/lib/eventarc/eventarc.js +125 -0
  80. package/lib/eventarc/index.d.ts +53 -0
  81. package/lib/eventarc/index.js +64 -0
  82. package/lib/firebase-namespace-api.d.ts +1 -1
  83. package/lib/firebase-namespace-api.js +8 -3
  84. package/lib/firestore/firestore-internal.d.ts +1 -1
  85. package/lib/firestore/firestore-internal.js +28 -37
  86. package/lib/firestore/firestore-namespace.d.ts +9 -1
  87. package/lib/firestore/firestore-namespace.js +2 -2
  88. package/lib/firestore/index.d.ts +2 -2
  89. package/lib/firestore/index.js +7 -7
  90. package/lib/functions/functions-api-client-internal.d.ts +32 -0
  91. package/lib/functions/functions-api-client-internal.js +257 -0
  92. package/lib/functions/functions-api.d.ts +67 -0
  93. package/lib/functions/functions-api.js +19 -0
  94. package/lib/functions/functions.d.ts +63 -0
  95. package/lib/functions/functions.js +97 -0
  96. package/lib/functions/index.d.ts +53 -0
  97. package/lib/functions/index.js +64 -0
  98. package/lib/index.d.ts +1 -1
  99. package/lib/index.js +14 -4
  100. package/lib/installations/index.d.ts +1 -1
  101. package/lib/installations/index.js +6 -6
  102. package/lib/installations/installations-namespace.d.ts +1 -1
  103. package/lib/installations/installations-namespace.js +1 -1
  104. package/lib/installations/installations-request-handler.d.ts +1 -1
  105. package/lib/installations/installations-request-handler.js +33 -36
  106. package/lib/installations/installations.d.ts +1 -1
  107. package/lib/installations/installations.js +17 -22
  108. package/lib/instance-id/index.d.ts +1 -1
  109. package/lib/instance-id/index.js +6 -6
  110. package/lib/instance-id/instance-id-namespace.d.ts +1 -1
  111. package/lib/instance-id/instance-id-namespace.js +1 -1
  112. package/lib/instance-id/instance-id.d.ts +1 -1
  113. package/lib/instance-id/instance-id.js +21 -26
  114. package/lib/machine-learning/index.d.ts +1 -1
  115. package/lib/machine-learning/index.js +7 -7
  116. package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
  117. package/lib/machine-learning/machine-learning-api-client.js +110 -124
  118. package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
  119. package/lib/machine-learning/machine-learning-namespace.js +1 -1
  120. package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
  121. package/lib/machine-learning/machine-learning-utils.js +9 -24
  122. package/lib/machine-learning/machine-learning.d.ts +1 -1
  123. package/lib/machine-learning/machine-learning.js +146 -207
  124. package/lib/messaging/batch-request-internal.d.ts +1 -1
  125. package/lib/messaging/batch-request-internal.js +33 -35
  126. package/lib/messaging/index.d.ts +1 -1
  127. package/lib/messaging/index.js +7 -7
  128. package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
  129. package/lib/messaging/messaging-api-request-internal.js +38 -40
  130. package/lib/messaging/messaging-api.d.ts +1 -1
  131. package/lib/messaging/messaging-api.js +1 -1
  132. package/lib/messaging/messaging-errors-internal.d.ts +1 -1
  133. package/lib/messaging/messaging-errors-internal.js +12 -13
  134. package/lib/messaging/messaging-internal.d.ts +1 -1
  135. package/lib/messaging/messaging-internal.js +51 -51
  136. package/lib/messaging/messaging-namespace.d.ts +1 -1
  137. package/lib/messaging/messaging-namespace.js +1 -1
  138. package/lib/messaging/messaging.d.ts +1 -1
  139. package/lib/messaging/messaging.js +184 -208
  140. package/lib/project-management/android-app.d.ts +1 -1
  141. package/lib/project-management/android-app.js +41 -43
  142. package/lib/project-management/app-metadata.d.ts +1 -1
  143. package/lib/project-management/app-metadata.js +1 -1
  144. package/lib/project-management/index.d.ts +1 -1
  145. package/lib/project-management/index.js +7 -7
  146. package/lib/project-management/ios-app.d.ts +1 -1
  147. package/lib/project-management/ios-app.js +25 -26
  148. package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
  149. package/lib/project-management/project-management-api-request-internal.js +84 -89
  150. package/lib/project-management/project-management-namespace.d.ts +1 -1
  151. package/lib/project-management/project-management-namespace.js +1 -1
  152. package/lib/project-management/project-management.d.ts +1 -1
  153. package/lib/project-management/project-management.js +80 -87
  154. package/lib/remote-config/index.d.ts +1 -1
  155. package/lib/remote-config/index.js +7 -7
  156. package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
  157. package/lib/remote-config/remote-config-api-client-internal.js +116 -154
  158. package/lib/remote-config/remote-config-api.d.ts +1 -1
  159. package/lib/remote-config/remote-config-api.js +1 -1
  160. package/lib/remote-config/remote-config-namespace.d.ts +1 -1
  161. package/lib/remote-config/remote-config-namespace.js +1 -1
  162. package/lib/remote-config/remote-config.d.ts +1 -1
  163. package/lib/remote-config/remote-config.js +51 -59
  164. package/lib/security-rules/index.d.ts +1 -1
  165. package/lib/security-rules/index.js +7 -7
  166. package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
  167. package/lib/security-rules/security-rules-api-client-internal.js +95 -107
  168. package/lib/security-rules/security-rules-internal.d.ts +1 -1
  169. package/lib/security-rules/security-rules-internal.js +6 -21
  170. package/lib/security-rules/security-rules-namespace.d.ts +1 -1
  171. package/lib/security-rules/security-rules-namespace.js +1 -1
  172. package/lib/security-rules/security-rules.d.ts +1 -1
  173. package/lib/security-rules/security-rules.js +82 -91
  174. package/lib/storage/index.d.ts +1 -1
  175. package/lib/storage/index.js +7 -7
  176. package/lib/storage/storage-namespace.d.ts +1 -1
  177. package/lib/storage/storage-namespace.js +1 -1
  178. package/lib/storage/storage.d.ts +1 -1
  179. package/lib/storage/storage.js +25 -30
  180. package/lib/utils/api-request.d.ts +3 -1
  181. package/lib/utils/api-request.js +278 -356
  182. package/lib/utils/crypto-signer.d.ts +1 -1
  183. package/lib/utils/crypto-signer.js +58 -93
  184. package/lib/utils/deep-copy.d.ts +1 -1
  185. package/lib/utils/deep-copy.js +3 -3
  186. package/lib/utils/error.d.ts +5 -1
  187. package/lib/utils/error.js +613 -677
  188. package/lib/utils/index.d.ts +43 -1
  189. package/lib/utils/index.js +99 -34
  190. package/lib/utils/jwt.d.ts +1 -1
  191. package/lib/utils/jwt.js +97 -123
  192. package/lib/utils/validator.d.ts +1 -1
  193. package/lib/utils/validator.js +13 -13
  194. package/package.json +43 -11
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -16,14 +16,14 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.getMachineLearning = void 0;
19
+ exports.getMachineLearning = exports.Model = exports.MachineLearning = void 0;
20
20
  /**
21
21
  * Firebase Machine Learning.
22
22
  *
23
23
  * @packageDocumentation
24
24
  */
25
- var app_1 = require("../app");
26
- var machine_learning_1 = require("./machine-learning");
25
+ const app_1 = require("../app");
26
+ const machine_learning_1 = require("./machine-learning");
27
27
  var machine_learning_2 = require("./machine-learning");
28
28
  Object.defineProperty(exports, "MachineLearning", { enumerable: true, get: function () { return machine_learning_2.MachineLearning; } });
29
29
  Object.defineProperty(exports, "Model", { enumerable: true, get: function () { return machine_learning_2.Model; } });
@@ -55,9 +55,9 @@ Object.defineProperty(exports, "Model", { enumerable: true, get: function () { r
55
55
  */
56
56
  function getMachineLearning(app) {
57
57
  if (typeof app === 'undefined') {
58
- app = app_1.getApp();
58
+ app = (0, app_1.getApp)();
59
59
  }
60
- var firebaseApp = app;
61
- return firebaseApp.getOrInitService('machineLearning', function (app) { return new machine_learning_1.MachineLearning(app); });
60
+ const firebaseApp = app;
61
+ return firebaseApp.getOrInitService('machineLearning', (app) => new machine_learning_1.MachineLearning(app));
62
62
  }
63
63
  exports.getMachineLearning = getMachineLearning;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -17,22 +17,21 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.MachineLearningApiClient = exports.isGcsTfliteModelOptions = void 0;
20
- var api_request_1 = require("../utils/api-request");
21
- var error_1 = require("../utils/error");
22
- var utils = require("../utils/index");
23
- var validator = require("../utils/validator");
24
- var machine_learning_utils_1 = require("./machine-learning-utils");
25
- var ML_V1BETA2_API = 'https://firebaseml.googleapis.com/v1beta2';
26
- var FIREBASE_VERSION_HEADER = {
27
- 'X-Firebase-Client': "fire-admin-node/" + utils.getSdkVersion(),
20
+ const api_request_1 = require("../utils/api-request");
21
+ const error_1 = require("../utils/error");
22
+ const utils = require("../utils/index");
23
+ const validator = require("../utils/validator");
24
+ const machine_learning_utils_1 = require("./machine-learning-utils");
25
+ const ML_V1BETA2_API = 'https://firebaseml.googleapis.com/v1beta2';
26
+ const FIREBASE_VERSION_HEADER = {
27
+ 'X-Firebase-Client': `fire-admin-node/${utils.getSdkVersion()}`,
28
28
  };
29
29
  // Operation polling defaults
30
- var POLL_DEFAULT_MAX_TIME_MILLISECONDS = 120000; // Maximum overall 2 minutes
31
- var POLL_BASE_WAIT_TIME_MILLISECONDS = 3000; // Start with 3 second delay
32
- var POLL_MAX_WAIT_TIME_MILLISECONDS = 30000; // Maximum 30 second delay
30
+ const POLL_DEFAULT_MAX_TIME_MILLISECONDS = 120000; // Maximum overall 2 minutes
31
+ const POLL_BASE_WAIT_TIME_MILLISECONDS = 3000; // Start with 3 second delay
32
+ const POLL_MAX_WAIT_TIME_MILLISECONDS = 30000; // Maximum 30 second delay
33
33
  function isGcsTfliteModelOptions(options) {
34
- var _a, _b;
35
- var gcsUri = (_b = (_a = options) === null || _a === void 0 ? void 0 : _a.tfliteModel) === null || _b === void 0 ? void 0 : _b.gcsTfliteUri;
34
+ const gcsUri = options?.tfliteModel?.gcsTfliteUri;
36
35
  return typeof gcsUri !== 'undefined';
37
36
  }
38
37
  exports.isGcsTfliteModelOptions = isGcsTfliteModelOptions;
@@ -41,8 +40,8 @@ exports.isGcsTfliteModelOptions = isGcsTfliteModelOptions;
41
40
  *
42
41
  * @internal
43
42
  */
44
- var MachineLearningApiClient = /** @class */ (function () {
45
- function MachineLearningApiClient(app) {
43
+ class MachineLearningApiClient {
44
+ constructor(app) {
46
45
  this.app = app;
47
46
  if (!validator.isNonNullObject(app) || !('options' in app)) {
48
47
  throw new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'First argument passed to admin.machineLearning() must be a valid '
@@ -50,156 +49,147 @@ var MachineLearningApiClient = /** @class */ (function () {
50
49
  }
51
50
  this.httpClient = new api_request_1.AuthorizedHttpClient(app);
52
51
  }
53
- MachineLearningApiClient.prototype.createModel = function (model) {
54
- var _this = this;
52
+ createModel(model) {
55
53
  if (!validator.isNonNullObject(model) ||
56
54
  !validator.isNonEmptyString(model.displayName)) {
57
- var err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Invalid model content.');
55
+ const err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Invalid model content.');
58
56
  return Promise.reject(err);
59
57
  }
60
58
  return this.getProjectUrl()
61
- .then(function (url) {
62
- var request = {
59
+ .then((url) => {
60
+ const request = {
63
61
  method: 'POST',
64
- url: url + "/models",
62
+ url: `${url}/models`,
65
63
  data: model,
66
64
  };
67
- return _this.sendRequest(request);
65
+ return this.sendRequest(request);
68
66
  });
69
- };
70
- MachineLearningApiClient.prototype.updateModel = function (modelId, model, updateMask) {
71
- var _this = this;
67
+ }
68
+ updateModel(modelId, model, updateMask) {
72
69
  if (!validator.isNonEmptyString(modelId) ||
73
70
  !validator.isNonNullObject(model) ||
74
71
  !validator.isNonEmptyArray(updateMask)) {
75
- var err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Invalid model or mask content.');
72
+ const err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Invalid model or mask content.');
76
73
  return Promise.reject(err);
77
74
  }
78
75
  return this.getProjectUrl()
79
- .then(function (url) {
80
- var request = {
76
+ .then((url) => {
77
+ const request = {
81
78
  method: 'PATCH',
82
- url: url + "/models/" + modelId + "?updateMask=" + updateMask.join(),
79
+ url: `${url}/models/${modelId}?updateMask=${updateMask.join()}`,
83
80
  data: model,
84
81
  };
85
- return _this.sendRequest(request);
82
+ return this.sendRequest(request);
86
83
  });
87
- };
88
- MachineLearningApiClient.prototype.getModel = function (modelId) {
89
- var _this = this;
84
+ }
85
+ getModel(modelId) {
90
86
  return Promise.resolve()
91
- .then(function () {
92
- return _this.getModelName(modelId);
87
+ .then(() => {
88
+ return this.getModelName(modelId);
93
89
  })
94
- .then(function (modelName) {
95
- return _this.getResourceWithShortName(modelName);
90
+ .then((modelName) => {
91
+ return this.getResourceWithShortName(modelName);
96
92
  });
97
- };
98
- MachineLearningApiClient.prototype.getOperation = function (operationName) {
99
- var _this = this;
93
+ }
94
+ getOperation(operationName) {
100
95
  return Promise.resolve()
101
- .then(function () {
102
- return _this.getResourceWithFullName(operationName);
96
+ .then(() => {
97
+ return this.getResourceWithFullName(operationName);
103
98
  });
104
- };
105
- MachineLearningApiClient.prototype.listModels = function (options) {
106
- var _this = this;
107
- if (options === void 0) { options = {}; }
99
+ }
100
+ listModels(options = {}) {
108
101
  if (!validator.isNonNullObject(options)) {
109
- var err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Invalid ListModelsOptions');
102
+ const err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Invalid ListModelsOptions');
110
103
  return Promise.reject(err);
111
104
  }
112
105
  if (typeof options.filter !== 'undefined' && !validator.isNonEmptyString(options.filter)) {
113
- var err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Invalid list filter.');
106
+ const err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Invalid list filter.');
114
107
  return Promise.reject(err);
115
108
  }
116
109
  if (typeof options.pageSize !== 'undefined') {
117
110
  if (!validator.isNumber(options.pageSize)) {
118
- var err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Invalid page size.');
111
+ const err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Invalid page size.');
119
112
  return Promise.reject(err);
120
113
  }
121
114
  if (options.pageSize < 1 || options.pageSize > 100) {
122
- var err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Page size must be between 1 and 100.');
115
+ const err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Page size must be between 1 and 100.');
123
116
  return Promise.reject(err);
124
117
  }
125
118
  }
126
119
  if (typeof options.pageToken !== 'undefined' && !validator.isNonEmptyString(options.pageToken)) {
127
- var err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Next page token must be a non-empty string.');
120
+ const err = new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Next page token must be a non-empty string.');
128
121
  return Promise.reject(err);
129
122
  }
130
123
  return this.getProjectUrl()
131
- .then(function (url) {
132
- var request = {
124
+ .then((url) => {
125
+ const request = {
133
126
  method: 'GET',
134
- url: url + "/models",
127
+ url: `${url}/models`,
135
128
  data: options,
136
129
  };
137
- return _this.sendRequest(request);
130
+ return this.sendRequest(request);
138
131
  });
139
- };
140
- MachineLearningApiClient.prototype.deleteModel = function (modelId) {
141
- var _this = this;
132
+ }
133
+ deleteModel(modelId) {
142
134
  return this.getProjectUrl()
143
- .then(function (url) {
144
- var modelName = _this.getModelName(modelId);
145
- var request = {
135
+ .then((url) => {
136
+ const modelName = this.getModelName(modelId);
137
+ const request = {
146
138
  method: 'DELETE',
147
- url: url + "/" + modelName,
139
+ url: `${url}/${modelName}`,
148
140
  };
149
- return _this.sendRequest(request);
141
+ return this.sendRequest(request);
150
142
  });
151
- };
143
+ }
152
144
  /**
153
145
  * Handles a Long Running Operation coming back from the server.
154
146
  *
155
147
  * @param op - The operation to handle
156
148
  * @param options - The options for polling
157
149
  */
158
- MachineLearningApiClient.prototype.handleOperation = function (op, options) {
150
+ handleOperation(op, options) {
159
151
  if (op.done) {
160
152
  if (op.response) {
161
153
  return Promise.resolve(op.response);
162
154
  }
163
155
  else if (op.error) {
164
- var err = machine_learning_utils_1.FirebaseMachineLearningError.fromOperationError(op.error.code, op.error.message);
156
+ const err = machine_learning_utils_1.FirebaseMachineLearningError.fromOperationError(op.error.code, op.error.message);
165
157
  return Promise.reject(err);
166
158
  }
167
159
  // Done operations must have either a response or an error.
168
160
  throw new machine_learning_utils_1.FirebaseMachineLearningError('invalid-server-response', 'Invalid operation response.');
169
161
  }
170
162
  // Operation is not done
171
- if (options === null || options === void 0 ? void 0 : options.wait) {
163
+ if (options?.wait) {
172
164
  return this.pollOperationWithExponentialBackoff(op.name, options);
173
165
  }
174
- var metadata = op.metadata || {};
175
- var metadataType = metadata['@type'] || '';
166
+ const metadata = op.metadata || {};
167
+ const metadataType = metadata['@type'] || '';
176
168
  if (!metadataType.includes('ModelOperationMetadata')) {
177
- throw new machine_learning_utils_1.FirebaseMachineLearningError('invalid-server-response', "Unknown Metadata type: " + JSON.stringify(metadata));
169
+ throw new machine_learning_utils_1.FirebaseMachineLearningError('invalid-server-response', `Unknown Metadata type: ${JSON.stringify(metadata)}`);
178
170
  }
179
171
  return this.getModel(extractModelId(metadata.name));
180
- };
172
+ }
181
173
  // baseWaitMillis and maxWaitMillis should only ever be modified by unit tests to run faster.
182
- MachineLearningApiClient.prototype.pollOperationWithExponentialBackoff = function (opName, options) {
183
- var _this = this;
184
- var _a, _b, _c;
185
- var maxTimeMilliseconds = (_a = options === null || options === void 0 ? void 0 : options.maxTimeMillis) !== null && _a !== void 0 ? _a : POLL_DEFAULT_MAX_TIME_MILLISECONDS;
186
- var baseWaitMillis = (_b = options === null || options === void 0 ? void 0 : options.baseWaitMillis) !== null && _b !== void 0 ? _b : POLL_BASE_WAIT_TIME_MILLISECONDS;
187
- var maxWaitMillis = (_c = options === null || options === void 0 ? void 0 : options.maxWaitMillis) !== null && _c !== void 0 ? _c : POLL_MAX_WAIT_TIME_MILLISECONDS;
188
- var poller = new api_request_1.ExponentialBackoffPoller(baseWaitMillis, maxWaitMillis, maxTimeMilliseconds);
189
- return poller.poll(function () {
190
- return _this.getOperation(opName)
191
- .then(function (responseData) {
174
+ pollOperationWithExponentialBackoff(opName, options) {
175
+ const maxTimeMilliseconds = options?.maxTimeMillis ?? POLL_DEFAULT_MAX_TIME_MILLISECONDS;
176
+ const baseWaitMillis = options?.baseWaitMillis ?? POLL_BASE_WAIT_TIME_MILLISECONDS;
177
+ const maxWaitMillis = options?.maxWaitMillis ?? POLL_MAX_WAIT_TIME_MILLISECONDS;
178
+ const poller = new api_request_1.ExponentialBackoffPoller(baseWaitMillis, maxWaitMillis, maxTimeMilliseconds);
179
+ return poller.poll(() => {
180
+ return this.getOperation(opName)
181
+ .then((responseData) => {
192
182
  if (!responseData.done) {
193
183
  return null;
194
184
  }
195
185
  if (responseData.error) {
196
- var err = machine_learning_utils_1.FirebaseMachineLearningError.fromOperationError(responseData.error.code, responseData.error.message);
186
+ const err = machine_learning_utils_1.FirebaseMachineLearningError.fromOperationError(responseData.error.code, responseData.error.message);
197
187
  throw err;
198
188
  }
199
189
  return responseData.response;
200
190
  });
201
191
  });
202
- };
192
+ }
203
193
  /**
204
194
  * Gets the specified resource from the ML API. Resource names must be the short names without project
205
195
  * ID prefix (e.g. `models/123456789`).
@@ -207,92 +197,88 @@ var MachineLearningApiClient = /** @class */ (function () {
207
197
  * @param {string} name Short name of the resource to get. e.g. 'models/12345'
208
198
  * @returns {Promise<T>} A promise that fulfills with the resource.
209
199
  */
210
- MachineLearningApiClient.prototype.getResourceWithShortName = function (name) {
211
- var _this = this;
200
+ getResourceWithShortName(name) {
212
201
  return this.getProjectUrl()
213
- .then(function (url) {
214
- var request = {
202
+ .then((url) => {
203
+ const request = {
215
204
  method: 'GET',
216
- url: url + "/" + name,
205
+ url: `${url}/${name}`,
217
206
  };
218
- return _this.sendRequest(request);
207
+ return this.sendRequest(request);
219
208
  });
220
- };
209
+ }
221
210
  /**
222
211
  * Gets the specified resource from the ML API. Resource names must be the full names including project
223
212
  * number prefix.
224
213
  * @param fullName - Full resource name of the resource to get. e.g. projects/123465/operations/987654
225
214
  * @returns {Promise<T>} A promise that fulfulls with the resource.
226
215
  */
227
- MachineLearningApiClient.prototype.getResourceWithFullName = function (fullName) {
228
- var request = {
216
+ getResourceWithFullName(fullName) {
217
+ const request = {
229
218
  method: 'GET',
230
- url: ML_V1BETA2_API + "/" + fullName
219
+ url: `${ML_V1BETA2_API}/${fullName}`
231
220
  };
232
221
  return this.sendRequest(request);
233
- };
234
- MachineLearningApiClient.prototype.sendRequest = function (request) {
235
- var _this = this;
222
+ }
223
+ sendRequest(request) {
236
224
  request.headers = FIREBASE_VERSION_HEADER;
237
225
  return this.httpClient.send(request)
238
- .then(function (resp) {
226
+ .then((resp) => {
239
227
  return resp.data;
240
228
  })
241
- .catch(function (err) {
242
- throw _this.toFirebaseError(err);
229
+ .catch((err) => {
230
+ throw this.toFirebaseError(err);
243
231
  });
244
- };
245
- MachineLearningApiClient.prototype.toFirebaseError = function (err) {
232
+ }
233
+ toFirebaseError(err) {
246
234
  if (err instanceof error_1.PrefixedFirebaseError) {
247
235
  return err;
248
236
  }
249
- var response = err.response;
237
+ const response = err.response;
250
238
  if (!response.isJson()) {
251
- return new machine_learning_utils_1.FirebaseMachineLearningError('unknown-error', "Unexpected response with status: " + response.status + " and body: " + response.text);
239
+ return new machine_learning_utils_1.FirebaseMachineLearningError('unknown-error', `Unexpected response with status: ${response.status} and body: ${response.text}`);
252
240
  }
253
- var error = response.data.error || {};
254
- var code = 'unknown-error';
241
+ const error = response.data.error || {};
242
+ let code = 'unknown-error';
255
243
  if (error.status && error.status in ERROR_CODE_MAPPING) {
256
244
  code = ERROR_CODE_MAPPING[error.status];
257
245
  }
258
- var message = error.message || "Unknown server error: " + response.text;
246
+ const message = error.message || `Unknown server error: ${response.text}`;
259
247
  return new machine_learning_utils_1.FirebaseMachineLearningError(code, message);
260
- };
261
- MachineLearningApiClient.prototype.getProjectUrl = function () {
248
+ }
249
+ getProjectUrl() {
262
250
  return this.getProjectIdPrefix()
263
- .then(function (projectIdPrefix) {
264
- return ML_V1BETA2_API + "/" + projectIdPrefix;
251
+ .then((projectIdPrefix) => {
252
+ return `${ML_V1BETA2_API}/${projectIdPrefix}`;
265
253
  });
266
- };
267
- MachineLearningApiClient.prototype.getProjectIdPrefix = function () {
268
- var _this = this;
254
+ }
255
+ getProjectIdPrefix() {
269
256
  if (this.projectIdPrefix) {
270
257
  return Promise.resolve(this.projectIdPrefix);
271
258
  }
272
259
  return utils.findProjectId(this.app)
273
- .then(function (projectId) {
260
+ .then((projectId) => {
274
261
  if (!validator.isNonEmptyString(projectId)) {
275
262
  throw new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Failed to determine project ID. Initialize the SDK with service account credentials, or '
276
263
  + 'set project ID as an app option. Alternatively, set the GOOGLE_CLOUD_PROJECT '
277
264
  + 'environment variable.');
278
265
  }
279
- _this.projectIdPrefix = "projects/" + projectId;
280
- return _this.projectIdPrefix;
266
+ this.projectIdPrefix = `projects/${projectId}`;
267
+ return this.projectIdPrefix;
281
268
  });
282
- };
283
- MachineLearningApiClient.prototype.getModelName = function (modelId) {
269
+ }
270
+ getModelName(modelId) {
284
271
  if (!validator.isNonEmptyString(modelId)) {
285
272
  throw new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Model ID must be a non-empty string.');
286
273
  }
287
274
  if (modelId.indexOf('/') !== -1) {
288
275
  throw new machine_learning_utils_1.FirebaseMachineLearningError('invalid-argument', 'Model ID must not contain any "/" characters.');
289
276
  }
290
- return "models/" + modelId;
291
- };
292
- return MachineLearningApiClient;
293
- }());
277
+ return `models/${modelId}`;
278
+ }
279
+ }
294
280
  exports.MachineLearningApiClient = MachineLearningApiClient;
295
- var ERROR_CODE_MAPPING = {
281
+ const ERROR_CODE_MAPPING = {
296
282
  INVALID_ARGUMENT: 'invalid-argument',
297
283
  NOT_FOUND: 'not-found',
298
284
  RESOURCE_EXHAUSTED: 'resource-exhausted',
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -15,28 +15,11 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- var __extends = (this && this.__extends) || (function () {
19
- var extendStatics = function (d, b) {
20
- extendStatics = Object.setPrototypeOf ||
21
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23
- return extendStatics(d, b);
24
- };
25
- return function (d, b) {
26
- extendStatics(d, b);
27
- function __() { this.constructor = d; }
28
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29
- };
30
- })();
31
18
  Object.defineProperty(exports, "__esModule", { value: true });
32
19
  exports.FirebaseMachineLearningError = void 0;
33
- var error_1 = require("../utils/error");
34
- var FirebaseMachineLearningError = /** @class */ (function (_super) {
35
- __extends(FirebaseMachineLearningError, _super);
36
- function FirebaseMachineLearningError(code, message) {
37
- return _super.call(this, 'machine-learning', code, message) || this;
38
- }
39
- FirebaseMachineLearningError.fromOperationError = function (code, message) {
20
+ const error_1 = require("../utils/error");
21
+ class FirebaseMachineLearningError extends error_1.PrefixedFirebaseError {
22
+ static fromOperationError(code, message) {
40
23
  switch (code) {
41
24
  case 1: return new FirebaseMachineLearningError('cancelled', message);
42
25
  case 2: return new FirebaseMachineLearningError('unknown-error', message);
@@ -56,7 +39,9 @@ var FirebaseMachineLearningError = /** @class */ (function (_super) {
56
39
  default:
57
40
  return new FirebaseMachineLearningError('unknown-error', message);
58
41
  }
59
- };
60
- return FirebaseMachineLearningError;
61
- }(error_1.PrefixedFirebaseError));
42
+ }
43
+ constructor(code, message) {
44
+ super('machine-learning', code, message);
45
+ }
46
+ }
62
47
  exports.FirebaseMachineLearningError = FirebaseMachineLearningError;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *