firebase-tools 10.0.0 → 10.1.2

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 (244) hide show
  1. package/lib/accountExporter.js +9 -8
  2. package/lib/accountImporter.js +10 -8
  3. package/lib/api.js +1 -0
  4. package/lib/apiv2.js +2 -2
  5. package/lib/appdistribution/client.js +1 -1
  6. package/lib/appdistribution/options-parser-util.js +1 -1
  7. package/lib/auth.js +2 -2
  8. package/lib/bin/firebase.js +1 -1
  9. package/lib/command.js +26 -26
  10. package/lib/commands/appdistribution-distribute.js +4 -4
  11. package/lib/commands/appdistribution-testers-add.js +2 -2
  12. package/lib/commands/appdistribution-testers-remove.js +2 -2
  13. package/lib/commands/apps-android-sha-create.js +2 -2
  14. package/lib/commands/apps-android-sha-delete.js +2 -2
  15. package/lib/commands/apps-android-sha-list.js +2 -2
  16. package/lib/commands/apps-create.js +9 -9
  17. package/lib/commands/apps-list.js +3 -3
  18. package/lib/commands/apps-sdkconfig.js +8 -8
  19. package/lib/commands/auth-export.js +26 -25
  20. package/lib/commands/auth-import.js +88 -78
  21. package/lib/commands/database-get.js +1 -1
  22. package/lib/commands/database-instances-create.js +4 -4
  23. package/lib/commands/database-instances-list.js +4 -4
  24. package/lib/commands/database-profile.js +1 -1
  25. package/lib/commands/database-push.js +1 -1
  26. package/lib/commands/database-remove.js +2 -2
  27. package/lib/commands/database-set.js +2 -2
  28. package/lib/commands/database-settings-get.js +1 -1
  29. package/lib/commands/database-settings-set.js +1 -1
  30. package/lib/commands/database-update.js +2 -2
  31. package/lib/commands/ext-configure.js +3 -3
  32. package/lib/commands/ext-dev-deprecate.js +4 -4
  33. package/lib/commands/ext-dev-extension-delete.js +3 -3
  34. package/lib/commands/ext-dev-init.js +4 -4
  35. package/lib/commands/ext-dev-list.js +1 -1
  36. package/lib/commands/ext-dev-publish.js +4 -4
  37. package/lib/commands/ext-dev-register.js +6 -6
  38. package/lib/commands/ext-dev-undeprecate.js +4 -4
  39. package/lib/commands/ext-dev-unpublish.js +3 -3
  40. package/lib/commands/ext-dev-usage.js +145 -0
  41. package/lib/commands/ext-export.js +8 -8
  42. package/lib/commands/ext-info.js +5 -5
  43. package/lib/commands/ext-install.js +27 -23
  44. package/lib/commands/ext-list.js +2 -2
  45. package/lib/commands/ext-sources-create.js +2 -2
  46. package/lib/commands/ext-uninstall.js +4 -4
  47. package/lib/commands/ext-update.js +18 -18
  48. package/lib/commands/ext.js +3 -3
  49. package/lib/commands/firestore-delete.js +1 -1
  50. package/lib/commands/functions-config-clone.js +22 -23
  51. package/lib/commands/functions-config-export.js +11 -11
  52. package/lib/commands/functions-config-get.js +22 -22
  53. package/lib/commands/functions-config-set.js +24 -22
  54. package/lib/commands/functions-config-unset.js +20 -22
  55. package/lib/commands/functions-delete.js +3 -3
  56. package/lib/commands/functions-deletegcfartifacts.js +4 -4
  57. package/lib/commands/functions-list.js +1 -1
  58. package/lib/commands/functions-log.js +1 -1
  59. package/lib/commands/help.js +12 -12
  60. package/lib/commands/hosting-channel-create.js +13 -13
  61. package/lib/commands/hosting-channel-delete.js +10 -10
  62. package/lib/commands/hosting-channel-deploy.js +18 -18
  63. package/lib/commands/hosting-channel-list.js +5 -5
  64. package/lib/commands/hosting-channel-open.js +9 -9
  65. package/lib/commands/hosting-clone.js +16 -16
  66. package/lib/commands/hosting-disable.js +1 -1
  67. package/lib/commands/hosting-sites-create.js +7 -7
  68. package/lib/commands/hosting-sites-delete.js +7 -7
  69. package/lib/commands/hosting-sites-get.js +2 -2
  70. package/lib/commands/hosting-sites-list.js +3 -3
  71. package/lib/commands/index.js +1 -0
  72. package/lib/commands/login-ci.js +10 -10
  73. package/lib/commands/login.js +2 -2
  74. package/lib/commands/logout.js +1 -1
  75. package/lib/commands/open.js +1 -1
  76. package/lib/commands/projects-addfirebase.js +2 -2
  77. package/lib/commands/projects-create.js +2 -2
  78. package/lib/commands/projects-list.js +1 -1
  79. package/lib/commands/remoteconfig-get.js +3 -3
  80. package/lib/commands/remoteconfig-rollback.js +3 -3
  81. package/lib/commands/remoteconfig-versions-list.js +7 -2
  82. package/lib/commands/setup-emulators-database.js +8 -7
  83. package/lib/commands/setup-emulators-firestore.js +8 -7
  84. package/lib/commands/setup-emulators-pubsub.js +5 -4
  85. package/lib/commands/setup-emulators-storage.js +4 -3
  86. package/lib/commands/setup-emulators-ui.js +8 -7
  87. package/lib/commands/target-apply.js +17 -16
  88. package/lib/commands/target-clear.js +11 -10
  89. package/lib/commands/target-remove.js +10 -9
  90. package/lib/commands/target.js +20 -20
  91. package/lib/config.js +6 -6
  92. package/lib/database/api.js +2 -2
  93. package/lib/defaultCredentials.js +3 -3
  94. package/lib/deploy/extensions/deploy.js +4 -4
  95. package/lib/deploy/extensions/deploymentSummary.js +5 -4
  96. package/lib/deploy/extensions/index.js +1 -0
  97. package/lib/deploy/extensions/params.js +1 -1
  98. package/lib/deploy/extensions/planner.js +3 -3
  99. package/lib/deploy/extensions/prepare.js +9 -9
  100. package/lib/deploy/extensions/release.js +1 -1
  101. package/lib/deploy/extensions/secrets.js +7 -7
  102. package/lib/deploy/extensions/validate.js +2 -2
  103. package/lib/deploy/functions/backend.js +6 -4
  104. package/lib/deploy/functions/checkIam.js +7 -7
  105. package/lib/deploy/functions/containerCleaner.js +3 -3
  106. package/lib/deploy/functions/deploy.js +4 -4
  107. package/lib/deploy/functions/ensureCloudBuildEnabled.js +3 -3
  108. package/lib/deploy/functions/index.js +1 -0
  109. package/lib/deploy/functions/prepare.js +27 -21
  110. package/lib/deploy/functions/prompts.js +5 -5
  111. package/lib/deploy/functions/release/executor.js +4 -1
  112. package/lib/deploy/functions/release/fabricator.js +5 -5
  113. package/lib/deploy/functions/release/index.js +2 -2
  114. package/lib/deploy/functions/release/planner.js +6 -6
  115. package/lib/deploy/functions/release/reporter.js +8 -4
  116. package/lib/deploy/functions/runtimes/discovery/index.js +2 -2
  117. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +14 -14
  118. package/lib/deploy/functions/runtimes/golang/index.js +11 -14
  119. package/lib/deploy/functions/runtimes/index.js +6 -10
  120. package/lib/deploy/functions/runtimes/node/index.js +6 -10
  121. package/lib/deploy/functions/runtimes/node/parseTriggers.js +3 -3
  122. package/lib/deploy/functions/runtimes/node/validate.js +2 -1
  123. package/lib/deploy/functions/services/storage.js +1 -1
  124. package/lib/deploy/functions/triggerRegionHelper.js +1 -1
  125. package/lib/deploy/functions/validate.js +4 -3
  126. package/lib/deploy/hosting/deploy.js +7 -7
  127. package/lib/deploy/hosting/uploader.js +1 -1
  128. package/lib/deploy/hosting/validate.js +3 -3
  129. package/lib/deploy/remoteconfig/prepare.js +3 -3
  130. package/lib/deploy/remoteconfig/release.js +3 -3
  131. package/lib/deploy/storage/deploy.js +1 -1
  132. package/lib/deploy/storage/release.js +2 -2
  133. package/lib/detectProjectRoot.js +5 -5
  134. package/lib/emulator/auth/apiSpec.js +13 -7
  135. package/lib/emulator/auth/handlers.js +3 -3
  136. package/lib/emulator/auth/index.js +1 -1
  137. package/lib/emulator/auth/operations.js +256 -248
  138. package/lib/emulator/auth/server.js +11 -8
  139. package/lib/emulator/auth/state.js +12 -12
  140. package/lib/emulator/commandUtils.js +5 -5
  141. package/lib/emulator/controller.js +16 -11
  142. package/lib/emulator/downloadableEmulators.js +10 -9
  143. package/lib/emulator/emulatorLogger.js +1 -1
  144. package/lib/emulator/functionsEmulator.js +107 -74
  145. package/lib/emulator/functionsEmulatorRuntime.js +36 -21
  146. package/lib/emulator/functionsEmulatorShell.js +3 -2
  147. package/lib/emulator/functionsRuntimeWorker.js +1 -1
  148. package/lib/emulator/hubExport.js +2 -2
  149. package/lib/emulator/storage/apis/firebase.js +2 -2
  150. package/lib/emulator/storage/apis/gcloud.js +2 -2
  151. package/lib/emulator/storage/cloudFunctions.js +1 -1
  152. package/lib/emulator/storage/files.js +14 -14
  153. package/lib/emulator/storage/index.js +2 -2
  154. package/lib/emulator/storage/metadata.js +7 -6
  155. package/lib/emulator/storage/rules/runtime.js +10 -9
  156. package/lib/emulator/storage/server.js +2 -2
  157. package/lib/ensureApiEnabled.js +7 -7
  158. package/lib/error.js +3 -3
  159. package/lib/extensions/askUserForConsent.js +3 -4
  160. package/lib/extensions/askUserForParam.js +11 -11
  161. package/lib/extensions/billingMigrationHelper.js +2 -2
  162. package/lib/extensions/changelog.js +4 -4
  163. package/lib/extensions/displayExtensionInfo.js +6 -6
  164. package/lib/extensions/emulator/optionsHelper.js +1 -1
  165. package/lib/extensions/emulator/specHelper.js +1 -1
  166. package/lib/extensions/emulator/triggerHelper.js +1 -1
  167. package/lib/extensions/export.js +6 -6
  168. package/lib/extensions/extensionsApi.js +69 -110
  169. package/lib/extensions/extensionsHelper.js +56 -43
  170. package/lib/extensions/listExtensions.js +1 -1
  171. package/lib/extensions/localHelper.js +1 -1
  172. package/lib/extensions/metricsTypeDef.js +2 -0
  173. package/lib/extensions/metricsUtils.js +98 -0
  174. package/lib/extensions/paramHelper.js +6 -6
  175. package/lib/extensions/provisioningHelper.js +13 -14
  176. package/lib/extensions/resolveSource.js +6 -6
  177. package/lib/extensions/secretsUtils.js +3 -3
  178. package/lib/extensions/updateHelper.js +10 -10
  179. package/lib/extensions/utils.js +1 -1
  180. package/lib/extensions/warnings.js +11 -10
  181. package/lib/fetchWebSetup.js +2 -2
  182. package/lib/filterTargets.js +2 -2
  183. package/lib/firestore/indexes.js +2 -2
  184. package/lib/fsAsync.js +3 -3
  185. package/lib/fsutils.js +2 -2
  186. package/lib/functional.js +2 -1
  187. package/lib/functions/env.js +1 -1
  188. package/lib/functions/runtimeConfigExport.js +4 -4
  189. package/lib/functionsConfig.js +7 -8
  190. package/lib/functionsShellCommandAction.js +4 -3
  191. package/lib/gcp/cloudmonitoring.js +74 -0
  192. package/lib/gcp/cloudscheduler.js +1 -1
  193. package/lib/gcp/iam.js +2 -2
  194. package/lib/gcp/resourceManager.js +2 -2
  195. package/lib/gcp/rules.js +18 -41
  196. package/lib/gcp/secretManager.js +3 -2
  197. package/lib/getDefaultDatabaseInstance.js +1 -1
  198. package/lib/getDefaultHostingSite.js +1 -1
  199. package/lib/getProjectNumber.js +2 -2
  200. package/lib/handlePreviewToggles.js +5 -5
  201. package/lib/hosting/api.js +6 -6
  202. package/lib/hosting/cloudRunProxy.js +6 -6
  203. package/lib/hosting/functionsProxy.js +3 -3
  204. package/lib/hosting/implicitInit.js +2 -2
  205. package/lib/hosting/normalizedHostingConfigs.js +3 -3
  206. package/lib/hosting/proxy.js +2 -2
  207. package/lib/init/features/account.js +7 -7
  208. package/lib/init/features/database.js +9 -9
  209. package/lib/init/features/emulators.js +8 -8
  210. package/lib/init/features/firestore/index.js +3 -3
  211. package/lib/init/features/firestore/indexes.js +2 -2
  212. package/lib/init/features/firestore/rules.js +2 -2
  213. package/lib/init/features/functions/golang.js +4 -4
  214. package/lib/init/features/functions/index.js +4 -4
  215. package/lib/init/features/hosting/github.js +31 -31
  216. package/lib/init/features/project.js +8 -8
  217. package/lib/init/features/remoteconfig.js +2 -2
  218. package/lib/init/features/storage.js +2 -2
  219. package/lib/listFiles.js +1 -1
  220. package/lib/management/apps.js +3 -3
  221. package/lib/management/projects.js +6 -6
  222. package/lib/previews.js +2 -2
  223. package/lib/profiler.js +1 -1
  224. package/lib/projectPath.js +1 -1
  225. package/lib/projectUtils.js +2 -2
  226. package/lib/prompt.js +0 -1
  227. package/lib/rc.js +1 -1
  228. package/lib/remoteconfig/get.js +14 -8
  229. package/lib/remoteconfig/rollback.js +13 -6
  230. package/lib/remoteconfig/versionslist.js +13 -7
  231. package/lib/requireAuth.js +2 -2
  232. package/lib/requireDatabaseInstance.js +1 -1
  233. package/lib/requireHostingSite.js +1 -1
  234. package/lib/requirePermissions.js +4 -4
  235. package/lib/rulesDeploy.js +2 -2
  236. package/lib/serve/functions.js +14 -7
  237. package/lib/serve/hosting.js +7 -7
  238. package/lib/utils.js +3 -2
  239. package/npm-shrinkwrap.json +24095 -0
  240. package/package.json +33 -30
  241. package/templates/init/hosting/index.html +1 -1
  242. package/CHANGELOG.md +0 -5
  243. package/lib/commands/functions-config-legacy.js +0 -45
  244. package/lib/prepareFirebaseRules.js +0 -58
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildMetricsTableRow = exports.parseBucket = exports.parseTimeseriesResponse = void 0;
4
+ const semver = require("semver");
5
+ const clc = require("cli-color");
6
+ function parseTimeseriesResponse(series) {
7
+ const ret = [];
8
+ for (const s of series) {
9
+ const ref = buildRef(s);
10
+ if (ref == undefined) {
11
+ continue;
12
+ }
13
+ let valueToday;
14
+ let value7dAgo;
15
+ let value28dAgo;
16
+ if (s.points.length >= 28 && s.points[27].value.int64Value != undefined) {
17
+ value28dAgo = parseBucket(s.points[27].value.int64Value);
18
+ }
19
+ if (s.points.length >= 7 && s.points[6].value.int64Value != undefined) {
20
+ value7dAgo = parseBucket(s.points[6].value.int64Value);
21
+ }
22
+ if (s.points.length >= 1 && s.points[0].value.int64Value != undefined) {
23
+ valueToday = parseBucket(s.points[0].value.int64Value);
24
+ }
25
+ ret.push({
26
+ ref,
27
+ valueToday,
28
+ value7dAgo,
29
+ value28dAgo,
30
+ });
31
+ }
32
+ ret.sort((a, b) => {
33
+ if (a.ref.version === "all") {
34
+ return 1;
35
+ }
36
+ if (b.ref.version === "all") {
37
+ return -1;
38
+ }
39
+ return semver.lt(a.ref.version, b.ref.version) ? 1 : -1;
40
+ });
41
+ return ret;
42
+ }
43
+ exports.parseTimeseriesResponse = parseTimeseriesResponse;
44
+ function parseBucket(value) {
45
+ const v = Number(value);
46
+ if (v >= 200) {
47
+ return { low: v - 100, high: v };
48
+ }
49
+ if (v >= 10) {
50
+ return { low: v - 10, high: v };
51
+ }
52
+ return { low: 0, high: 0 };
53
+ }
54
+ exports.parseBucket = parseBucket;
55
+ function buildMetricsTableRow(metric) {
56
+ const ret = [metric.ref.version];
57
+ if (metric.valueToday) {
58
+ ret.push(`${metric.valueToday.low} - ${metric.valueToday.high}`);
59
+ }
60
+ else {
61
+ ret.push("Insufficient data");
62
+ }
63
+ ret.push(renderChangeCell(metric.value7dAgo, metric.valueToday));
64
+ ret.push(renderChangeCell(metric.value28dAgo, metric.valueToday));
65
+ return ret;
66
+ }
67
+ exports.buildMetricsTableRow = buildMetricsTableRow;
68
+ function renderChangeCell(before, after) {
69
+ if (!(before && after)) {
70
+ return "Insufficient data";
71
+ }
72
+ if (before.high === after.high) {
73
+ return "-";
74
+ }
75
+ if (before.high > after.high) {
76
+ const diff = before.high - after.high;
77
+ const tolerance = diff < 100 ? 10 : 100;
78
+ return clc.red("▼ ") + `-${diff} (±${tolerance})`;
79
+ }
80
+ else {
81
+ const diff = after.high - before.high;
82
+ const tolerance = diff < 100 ? 10 : 100;
83
+ return clc.green("▲ ") + `${diff} (±${tolerance})`;
84
+ }
85
+ }
86
+ function buildRef(ts) {
87
+ const publisherId = ts.resource.labels["publisher"];
88
+ const extensionId = ts.resource.labels["extension"];
89
+ const version = ts.resource.labels["version"];
90
+ if (!(publisherId && extensionId && version)) {
91
+ return undefined;
92
+ }
93
+ return {
94
+ publisherId,
95
+ extensionId,
96
+ version,
97
+ };
98
+ }
@@ -46,7 +46,7 @@ async function getParams(args) {
46
46
  });
47
47
  }
48
48
  else {
49
- const firebaseProjectParams = await extensionsHelper_1.getFirebaseProjectParams(args.projectId);
49
+ const firebaseProjectParams = await (0, extensionsHelper_1.getFirebaseProjectParams)(args.projectId);
50
50
  params = await askUserForParam.ask(args.projectId, args.instanceId, args.paramSpecs, firebaseProjectParams, !!args.reconfiguring);
51
51
  }
52
52
  track("Extension Params", _.isEmpty(params) ? "Not Present" : "Present", _.size(params));
@@ -87,14 +87,14 @@ async function getParamsForUpdate(args) {
87
87
  }
88
88
  exports.getParamsForUpdate = getParamsForUpdate;
89
89
  async function promptForNewParams(args) {
90
- const firebaseProjectParams = await extensionsHelper_1.getFirebaseProjectParams(args.projectId);
90
+ const firebaseProjectParams = await (0, extensionsHelper_1.getFirebaseProjectParams)(args.projectId);
91
91
  const comparer = (param1, param2) => {
92
92
  return param1.type === param2.type && param1.param === param2.param;
93
93
  };
94
94
  let paramsDiffDeletions = _.differenceWith(args.spec.params, _.get(args.newSpec, "params", []), comparer);
95
- paramsDiffDeletions = extensionsHelper_1.substituteParams(paramsDiffDeletions, firebaseProjectParams);
95
+ paramsDiffDeletions = (0, extensionsHelper_1.substituteParams)(paramsDiffDeletions, firebaseProjectParams);
96
96
  let paramsDiffAdditions = _.differenceWith(args.newSpec.params, _.get(args.spec, "params", []), comparer);
97
- paramsDiffAdditions = extensionsHelper_1.substituteParams(paramsDiffAdditions, firebaseProjectParams);
97
+ paramsDiffAdditions = (0, extensionsHelper_1.substituteParams)(paramsDiffAdditions, firebaseProjectParams);
98
98
  if (paramsDiffDeletions.length) {
99
99
  logger_1.logger.info("The following params will no longer be used:");
100
100
  paramsDiffDeletions.forEach((param) => {
@@ -122,8 +122,8 @@ function getParamsFromFile(args) {
122
122
  track("Extension Env File", "Invalid");
123
123
  throw new error_1.FirebaseError(`Error reading env file: ${err.message}\n`, { original: err });
124
124
  }
125
- const params = extensionsHelper_1.populateDefaultParams(envParams, args.paramSpecs);
126
- extensionsHelper_1.validateCommandLineParams(params, args.paramSpecs);
125
+ const params = (0, extensionsHelper_1.populateDefaultParams)(envParams, args.paramSpecs);
126
+ (0, extensionsHelper_1.validateCommandLineParams)(params, args.paramSpecs);
127
127
  logger_1.logger.info(`Using param values from ${args.paramsEnvPath}`);
128
128
  return params;
129
129
  }
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getUsedProducts = exports.bulkCheckProductsProvisioned = exports.checkProductsProvisioned = exports.DeferredProduct = void 0;
4
- const marked = require("marked");
5
- const api = require("../api");
4
+ const { marked } = require("marked");
5
+ const api_1 = require("../api");
6
+ const apiv2_1 = require("../apiv2");
6
7
  const functional_1 = require("../functional");
7
8
  const error_1 = require("../error");
8
9
  const planner_1 = require("../deploy/extensions/planner");
@@ -18,10 +19,10 @@ async function checkProductsProvisioned(projectId, spec) {
18
19
  exports.checkProductsProvisioned = checkProductsProvisioned;
19
20
  async function bulkCheckProductsProvisioned(projectId, instanceSpecs) {
20
21
  const usedProducts = await Promise.all(instanceSpecs.map(async (i) => {
21
- const extensionVersion = await planner_1.getExtensionVersion(i);
22
+ const extensionVersion = await (0, planner_1.getExtensionVersion)(i);
22
23
  return getUsedProducts(extensionVersion.spec);
23
24
  }));
24
- await checkProducts(projectId, [...functional_1.flattenArray(usedProducts)]);
25
+ await checkProducts(projectId, [...(0, functional_1.flattenArray)(usedProducts)]);
25
26
  }
26
27
  exports.bulkCheckProductsProvisioned = bulkCheckProductsProvisioned;
27
28
  async function checkProducts(projectId, usedProducts) {
@@ -66,11 +67,13 @@ function getUsedProducts(spec) {
66
67
  const usedApis = (_a = spec.apis) === null || _a === void 0 ? void 0 : _a.map((api) => api.apiName);
67
68
  const usedRoles = (_b = spec.roles) === null || _b === void 0 ? void 0 : _b.map((r) => r.role.split(".")[0]);
68
69
  const usedTriggers = spec.resources.map((r) => getTriggerType(r.propertiesYaml));
69
- if ((usedApis === null || usedApis === void 0 ? void 0 : usedApis.includes("storage-component.googleapis.com")) || (usedRoles === null || usedRoles === void 0 ? void 0 : usedRoles.includes("storage")) ||
70
+ if ((usedApis === null || usedApis === void 0 ? void 0 : usedApis.includes("storage-component.googleapis.com")) ||
71
+ (usedRoles === null || usedRoles === void 0 ? void 0 : usedRoles.includes("storage")) ||
70
72
  usedTriggers.find((t) => t === null || t === void 0 ? void 0 : t.startsWith("google.storage."))) {
71
73
  usedProducts.push(DeferredProduct.STORAGE);
72
74
  }
73
- if ((usedApis === null || usedApis === void 0 ? void 0 : usedApis.includes("identitytoolkit.googleapis.com")) || (usedRoles === null || usedRoles === void 0 ? void 0 : usedRoles.includes("firebaseauth")) ||
75
+ if ((usedApis === null || usedApis === void 0 ? void 0 : usedApis.includes("identitytoolkit.googleapis.com")) ||
76
+ (usedRoles === null || usedRoles === void 0 ? void 0 : usedRoles.includes("firebaseauth")) ||
74
77
  usedTriggers.find((t) => t === null || t === void 0 ? void 0 : t.startsWith("providers/firebase.auth/"))) {
75
78
  usedProducts.push(DeferredProduct.AUTH);
76
79
  }
@@ -83,10 +86,8 @@ function getTriggerType(propertiesYaml) {
83
86
  }
84
87
  async function isStorageProvisioned(projectId) {
85
88
  var _a, _b;
86
- const resp = await api.request("GET", `/v1beta/projects/${projectId}/buckets`, {
87
- auth: true,
88
- origin: api.firebaseStorageOrigin,
89
- });
89
+ const client = new apiv2_1.Client({ urlPrefix: api_1.firebaseStorageOrigin, apiVersion: "v1beta" });
90
+ const resp = await client.get(`/projects/${projectId}/buckets`);
90
91
  return !!((_b = (_a = resp.body) === null || _a === void 0 ? void 0 : _a.buckets) === null || _b === void 0 ? void 0 : _b.find((bucket) => {
91
92
  const bucketResourceName = bucket.name;
92
93
  const bucketResourceNameTokens = bucketResourceName.split("/");
@@ -96,9 +97,7 @@ async function isStorageProvisioned(projectId) {
96
97
  }
97
98
  async function isAuthProvisioned(projectId) {
98
99
  var _a, _b;
99
- const resp = await api.request("GET", `/v1/projects/${projectId}/products`, {
100
- auth: true,
101
- origin: api.firedataOrigin,
102
- });
100
+ const client = new apiv2_1.Client({ urlPrefix: api_1.firedataOrigin, apiVersion: "v1" });
101
+ const resp = await client.get(`/projects/${projectId}/products`);
103
102
  return !!((_b = (_a = resp.body) === null || _a === void 0 ? void 0 : _a.activation) === null || _b === void 0 ? void 0 : _b.map((a) => a.service).includes("FIREBASE_AUTH"));
104
103
  }
@@ -3,18 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTrustedPublishers = exports.getExtensionRegistry = exports.getMinRequiredVersion = exports.getTargetVersion = exports.resolveRegistryEntry = exports.isOfficialSource = exports.resolveSourceUrl = exports.confirmUpdateWarning = void 0;
4
4
  const _ = require("lodash");
5
5
  const clc = require("cli-color");
6
- const marked = require("marked");
7
- const api = require("../api");
6
+ const { marked } = require("marked");
8
7
  const error_1 = require("../error");
9
8
  const logger_1 = require("../logger");
10
9
  const prompt_1 = require("../prompt");
10
+ const apiv2_1 = require("../apiv2");
11
+ const api_1 = require("../api");
11
12
  const EXTENSIONS_REGISTRY_ENDPOINT = "/extensions.json";
12
13
  async function confirmUpdateWarning(updateWarning) {
13
14
  logger_1.logger.info(marked(updateWarning.description));
14
15
  if (updateWarning.action) {
15
16
  logger_1.logger.info(marked(updateWarning.action));
16
17
  }
17
- const continueUpdate = await prompt_1.promptOnce({
18
+ const continueUpdate = await (0, prompt_1.promptOnce)({
18
19
  type: "confirm",
19
20
  message: "Do you wish to continue with this update?",
20
21
  default: false,
@@ -58,9 +59,8 @@ function getMinRequiredVersion(registryEntry) {
58
59
  }
59
60
  exports.getMinRequiredVersion = getMinRequiredVersion;
60
61
  async function getExtensionRegistry(onlyFeatured) {
61
- const res = await api.request("GET", EXTENSIONS_REGISTRY_ENDPOINT, {
62
- origin: api.firebaseExtensionsRegistryOrigin,
63
- });
62
+ const client = new apiv2_1.Client({ urlPrefix: api_1.firebaseExtensionsRegistryOrigin });
63
+ const res = await client.get(EXTENSIONS_REGISTRY_ENDPOINT);
64
64
  const extensions = _.get(res, "body.mods");
65
65
  if (onlyFeatured) {
66
66
  const featuredList = _.get(res, "body.featured.discover");
@@ -10,8 +10,8 @@ const secretManagerApi = require("../gcp/secretManager");
10
10
  const logger_1 = require("../logger");
11
11
  exports.SECRET_LABEL = "firebase-extensions-managed";
12
12
  async function ensureSecretManagerApiEnabled(options) {
13
- const projectId = projectUtils_1.needProjectId(options);
14
- return await ensureApiEnabled_1.ensure(projectId, "secretmanager.googleapis.com", "extensions", options.markdown);
13
+ const projectId = (0, projectUtils_1.needProjectId)(options);
14
+ return await (0, ensureApiEnabled_1.ensure)(projectId, "secretmanager.googleapis.com", "extensions", options.markdown);
15
15
  }
16
16
  exports.ensureSecretManagerApiEnabled = ensureSecretManagerApiEnabled;
17
17
  function usesSecrets(spec) {
@@ -19,7 +19,7 @@ function usesSecrets(spec) {
19
19
  }
20
20
  exports.usesSecrets = usesSecrets;
21
21
  async function grantFirexServiceAgentSecretAdminRole(secret) {
22
- const projectNumber = await getProjectNumber_1.getProjectNumber({ projectId: secret.projectId });
22
+ const projectNumber = await (0, getProjectNumber_1.getProjectNumber)({ projectId: secret.projectId });
23
23
  const firexSaProjectId = utils.envOverride("FIREBASE_EXTENSIONS_SA_PROJECT_ID", "gcp-sa-firebasemods");
24
24
  const saEmail = `service-${projectNumber}@${firexSaProjectId}.iam.gserviceaccount.com`;
25
25
  return secretManagerApi.grantServiceAgentRole(secret, saEmail, "roles/secretmanager.admin");
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.inferUpdateSource = exports.updateFromPublisherSource = exports.updateToVersionFromPublisherSource = exports.updateFromUrlSource = exports.updateFromLocalSource = exports.update = exports.displayChanges = exports.warningUpdateToOtherSource = exports.getExistingSourceOrigin = void 0;
4
4
  const clc = require("cli-color");
5
5
  const semver = require("semver");
6
- const marked = require("marked");
6
+ const { marked } = require("marked");
7
7
  const error_1 = require("../error");
8
8
  const logger_1 = require("../logger");
9
9
  const resolveSource = require("./resolveSource");
@@ -55,8 +55,8 @@ function warningUpdateToOtherSource(sourceOrigin) {
55
55
  exports.warningUpdateToOtherSource = warningUpdateToOtherSource;
56
56
  async function displayChanges(args) {
57
57
  utils.logLabeledBullet("extensions", "This update contains the following changes:");
58
- displayExtensionInfo_1.displayUpdateChangesNoInput(args.spec, args.newSpec);
59
- await displayExtensionInfo_1.displayUpdateChangesRequiringConfirmation(args);
58
+ (0, displayExtensionInfo_1.displayUpdateChangesNoInput)(args.spec, args.newSpec);
59
+ await (0, displayExtensionInfo_1.displayUpdateChangesRequiringConfirmation)(args);
60
60
  }
61
61
  exports.displayChanges = displayChanges;
62
62
  async function update(updateOptions) {
@@ -81,10 +81,10 @@ async function update(updateOptions) {
81
81
  }
82
82
  exports.update = update;
83
83
  async function updateFromLocalSource(projectId, instanceId, localSource, existingSpec) {
84
- displayExtensionInfo_1.displayExtInfo(instanceId, "", existingSpec, false);
84
+ (0, displayExtensionInfo_1.displayExtInfo)(instanceId, "", existingSpec, false);
85
85
  let source;
86
86
  try {
87
- source = await extensionsHelper_1.createSourceFromLocation(projectId, localSource);
87
+ source = await (0, extensionsHelper_1.createSourceFromLocation)(projectId, localSource);
88
88
  }
89
89
  catch (err) {
90
90
  throw new error_1.FirebaseError(invalidSourceErrMsgTemplate(instanceId, localSource));
@@ -96,10 +96,10 @@ async function updateFromLocalSource(projectId, instanceId, localSource, existin
96
96
  }
97
97
  exports.updateFromLocalSource = updateFromLocalSource;
98
98
  async function updateFromUrlSource(projectId, instanceId, urlSource, existingSpec) {
99
- displayExtensionInfo_1.displayExtInfo(instanceId, "", existingSpec, false);
99
+ (0, displayExtensionInfo_1.displayExtInfo)(instanceId, "", existingSpec, false);
100
100
  let source;
101
101
  try {
102
- source = await extensionsHelper_1.createSourceFromLocation(projectId, urlSource);
102
+ source = await (0, extensionsHelper_1.createSourceFromLocation)(projectId, urlSource);
103
103
  }
104
104
  catch (err) {
105
105
  throw new error_1.FirebaseError(invalidSourceErrMsgTemplate(instanceId, urlSource));
@@ -115,7 +115,7 @@ async function updateToVersionFromPublisherSource(projectId, instanceId, extVers
115
115
  const ref = refs.parse(extVersionRef);
116
116
  const version = ref.version;
117
117
  const extensionRef = refs.toExtensionRef(ref);
118
- displayExtensionInfo_1.displayExtInfo(instanceId, ref.publisherId, existingSpec, true);
118
+ (0, displayExtensionInfo_1.displayExtInfo)(instanceId, ref.publisherId, existingSpec, true);
119
119
  const extension = await extensionsApi.getExtension(extensionRef);
120
120
  try {
121
121
  source = await extensionsApi.getExtensionVersion(extVersionRef);
@@ -160,12 +160,12 @@ function inferUpdateSource(updateSource, existingRef) {
160
160
  if (semver.valid(updateSource)) {
161
161
  return `${existingRef}@${updateSource}`;
162
162
  }
163
- if (!extensionsHelper_1.isLocalOrURLPath(updateSource) && updateSource.split("/").length < 2) {
163
+ if (!(0, extensionsHelper_1.isLocalOrURLPath)(updateSource) && updateSource.split("/").length < 2) {
164
164
  return updateSource.includes("@")
165
165
  ? `firebase/${updateSource}`
166
166
  : `firebase/${updateSource}@latest`;
167
167
  }
168
- if (!extensionsHelper_1.isLocalOrURLPath(updateSource) && !updateSource.includes("@")) {
168
+ if (!(0, extensionsHelper_1.isLocalOrURLPath)(updateSource) && !updateSource.includes("@")) {
169
169
  return `${updateSource}@latest`;
170
170
  }
171
171
  return updateSource;
@@ -4,7 +4,7 @@ exports.formatTimestamp = exports.getRandomString = exports.convertOfficialExten
4
4
  const _ = require("lodash");
5
5
  const prompt_1 = require("../prompt");
6
6
  async function onceWithJoin(question) {
7
- const response = await prompt_1.promptOnce(question);
7
+ const response = await (0, prompt_1.promptOnce)(question);
8
8
  if (Array.isArray(response)) {
9
9
  return response.join(",");
10
10
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.displayWarningsForDeploy = exports.displayWarningPrompts = void 0;
4
- const marked = require("marked");
4
+ const { marked } = require("marked");
5
5
  const clc = require("cli-color");
6
6
  const extensionsApi_1 = require("./extensionsApi");
7
7
  const displayExtensionInfo_1 = require("./displayExtensionInfo");
@@ -16,13 +16,13 @@ function displayEAPWarning({ publisherId, sourceDownloadUri, githubLink, }) {
16
16
  const warningMsg = `This extension is in preview and is built by a developer in the [Extensions Publisher Early Access Program](http://bit.ly/firex-provider). Its functionality might change in backward-incompatible ways. Since this extension isn't built by Firebase, reach out to ${publisherNameLink} with questions about this extension.`;
17
17
  const legalMsg = "\n\nIt is provided “AS IS”, without any warranty, express or implied, from Google. Google disclaims all liability for any damages, direct or indirect, resulting from the use of the extension, and its functionality might change in backward - incompatible ways.";
18
18
  utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked(warningMsg + legalMsg));
19
- displayExtensionInfo_1.printSourceDownloadLink(sourceDownloadUri);
19
+ (0, displayExtensionInfo_1.printSourceDownloadLink)(sourceDownloadUri);
20
20
  }
21
21
  function displayExperimentalWarning() {
22
22
  utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked(`${clc.yellow.bold("Important")}: This extension is ${clc.bold("experimental")} and may not be production-ready. Its functionality might change in backward-incompatible ways before its official release, or it may be discontinued.`));
23
23
  }
24
24
  async function displayWarningPrompts(publisherId, launchStage, extensionVersion) {
25
- const trustedPublishers = await resolveSource_1.getTrustedPublishers();
25
+ const trustedPublishers = await (0, resolveSource_1.getTrustedPublishers)();
26
26
  if (!trustedPublishers.includes(publisherId)) {
27
27
  displayEAPWarning({
28
28
  publisherId,
@@ -40,22 +40,23 @@ async function displayWarningPrompts(publisherId, launchStage, extensionVersion)
40
40
  exports.displayWarningPrompts = displayWarningPrompts;
41
41
  const toListEntry = (i) => {
42
42
  var _a, _b, _c, _d;
43
- const idAndRef = deploymentSummary_1.humanReadable(i);
43
+ const idAndRef = (0, deploymentSummary_1.humanReadable)(i);
44
44
  const sourceCodeLink = `\n\t[Source Code](${(_a = i.extensionVersion) === null || _a === void 0 ? void 0 : _a.sourceDownloadUri})`;
45
- const githubLink = ((_c = (_b = i.extensionVersion) === null || _b === void 0 ? void 0 : _b.spec) === null || _c === void 0 ? void 0 : _c.sourceUrl) ? `\n\t[Publisher Contact](${(_d = i.extensionVersion) === null || _d === void 0 ? void 0 : _d.spec.sourceUrl})`
45
+ const githubLink = ((_c = (_b = i.extensionVersion) === null || _b === void 0 ? void 0 : _b.spec) === null || _c === void 0 ? void 0 : _c.sourceUrl)
46
+ ? `\n\t[Publisher Contact](${(_d = i.extensionVersion) === null || _d === void 0 ? void 0 : _d.spec.sourceUrl})`
46
47
  : "";
47
48
  return `${idAndRef}${sourceCodeLink}${githubLink}`;
48
49
  };
49
50
  async function displayWarningsForDeploy(instancesToCreate) {
50
- const trustedPublishers = await resolveSource_1.getTrustedPublishers();
51
+ const trustedPublishers = await (0, resolveSource_1.getTrustedPublishers)();
51
52
  for (const i of instancesToCreate) {
52
- await planner_1.getExtension(i);
53
- await planner_1.getExtensionVersion(i);
53
+ await (0, planner_1.getExtension)(i);
54
+ await (0, planner_1.getExtensionVersion)(i);
54
55
  }
55
- const [eapExtensions, nonEapExtensions] = functional_1.partition(instancesToCreate, (i) => { var _a, _b; return !trustedPublishers.includes((_b = (_a = i.ref) === null || _a === void 0 ? void 0 : _a.publisherId) !== null && _b !== void 0 ? _b : ""); });
56
+ const [eapExtensions, nonEapExtensions] = (0, functional_1.partition)(instancesToCreate, (i) => { var _a, _b; return !trustedPublishers.includes((_b = (_a = i.ref) === null || _a === void 0 ? void 0 : _a.publisherId) !== null && _b !== void 0 ? _b : ""); });
56
57
  const experimental = nonEapExtensions.filter((i) => i.extension.registryLaunchStage === extensionsApi_1.RegistryLaunchStage.EXPERIMENTAL);
57
58
  if (experimental.length) {
58
- const humanReadableList = experimental.map((i) => `\t${deploymentSummary_1.humanReadable(i)}`).join("\n");
59
+ const humanReadableList = experimental.map((i) => `\t${(0, deploymentSummary_1.humanReadable)(i)}`).join("\n");
59
60
  utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked(`The following are instances of ${clc.bold("experimental")} extensions.They may not be production-ready. Their functionality may change in backward-incompatible ways before their official release, or they may be discontinued.\n${humanReadableList}\n`));
60
61
  }
61
62
  if (eapExtensions.length) {
@@ -20,7 +20,7 @@ function setCachedWebSetup(projectId, config) {
20
20
  configstore_1.configstore.set(CONFIGSTORE_KEY, allConfigs);
21
21
  }
22
22
  function getCachedWebSetup(options) {
23
- const projectId = projectUtils_1.needProjectId(options);
23
+ const projectId = (0, projectUtils_1.needProjectId)(options);
24
24
  const allConfigs = configstore_1.configstore.get(CONFIGSTORE_KEY) || {};
25
25
  return allConfigs[projectId];
26
26
  }
@@ -47,7 +47,7 @@ function constructDefaultWebSetup(projectId) {
47
47
  };
48
48
  }
49
49
  async function fetchWebSetup(options) {
50
- const projectId = projectUtils_1.needProjectId(options);
50
+ const projectId = (0, projectUtils_1.needProjectId)(options);
51
51
  if (constants_1.Constants.isDemoProject(projectId)) {
52
52
  return constructDefaultWebSetup(projectId);
53
53
  }
@@ -8,12 +8,12 @@ function filterTargets(options, validTargets) {
8
8
  return options.config.has(t);
9
9
  });
10
10
  if (options.only) {
11
- targets = lodash_1.intersection(targets, options.only.split(",").map((opt) => {
11
+ targets = (0, lodash_1.intersection)(targets, options.only.split(",").map((opt) => {
12
12
  return opt.split(":")[0];
13
13
  }));
14
14
  }
15
15
  else if (options.except) {
16
- targets = lodash_1.difference(targets, options.except.split(","));
16
+ targets = (0, lodash_1.difference)(targets, options.except.split(","));
17
17
  }
18
18
  if (targets.length === 0) {
19
19
  let msg = "Cannot understand what targets to deploy/serve.";
@@ -49,7 +49,7 @@ class FirestoreIndexes {
49
49
  utils.logLabeledBullet("firestore", `The following indexes are defined in your project but are not present in your firestore indexes file:\n\t${indexesString}`);
50
50
  }
51
51
  if (!shouldDeleteIndexes) {
52
- shouldDeleteIndexes = await prompt_1.promptOnce({
52
+ shouldDeleteIndexes = await (0, prompt_1.promptOnce)({
53
53
  type: "confirm",
54
54
  name: "confirm",
55
55
  default: false,
@@ -86,7 +86,7 @@ class FirestoreIndexes {
86
86
  utils.logLabeledBullet("firestore", `The following field overrides are defined in your project but are not present in your firestore indexes file:\n\t${indexesString}`);
87
87
  }
88
88
  if (!shouldDeleteFields) {
89
- shouldDeleteFields = await prompt_1.promptOnce({
89
+ shouldDeleteFields = await (0, prompt_1.promptOnce)({
90
90
  type: "confirm",
91
91
  name: "confirm",
92
92
  default: false,
package/lib/fsAsync.js CHANGED
@@ -6,12 +6,12 @@ const fs_extra_1 = require("fs-extra");
6
6
  const _ = require("lodash");
7
7
  const minimatch = require("minimatch");
8
8
  async function readdirRecursiveHelper(options) {
9
- const dirContents = fs_extra_1.readdirSync(options.path);
10
- const fullPaths = dirContents.map((n) => path_1.join(options.path, n));
9
+ const dirContents = (0, fs_extra_1.readdirSync)(options.path);
10
+ const fullPaths = dirContents.map((n) => (0, path_1.join)(options.path, n));
11
11
  const filteredPaths = _.reject(fullPaths, options.filter);
12
12
  const filePromises = [];
13
13
  for (const p of filteredPaths) {
14
- const fstat = fs_extra_1.statSync(p);
14
+ const fstat = (0, fs_extra_1.statSync)(p);
15
15
  if (fstat.isFile()) {
16
16
  filePromises.push(Promise.resolve({ name: p, mode: fstat.mode }));
17
17
  }
package/lib/fsutils.js CHANGED
@@ -4,7 +4,7 @@ exports.dirExistsSync = exports.fileExistsSync = void 0;
4
4
  const fs_1 = require("fs");
5
5
  function fileExistsSync(path) {
6
6
  try {
7
- return fs_1.statSync(path).isFile();
7
+ return (0, fs_1.statSync)(path).isFile();
8
8
  }
9
9
  catch (e) {
10
10
  return false;
@@ -13,7 +13,7 @@ function fileExistsSync(path) {
13
13
  exports.fileExistsSync = fileExistsSync;
14
14
  function dirExistsSync(path) {
15
15
  try {
16
- return fs_1.statSync(path).isDirectory();
16
+ return (0, fs_1.statSync)(path).isDirectory();
17
17
  }
18
18
  catch (e) {
19
19
  return false;
package/lib/functional.js CHANGED
@@ -48,9 +48,10 @@ function* zip(left, right) {
48
48
  }
49
49
  }
50
50
  exports.zip = zip;
51
- exports.zipIn = (other) => (elem, ndx) => {
51
+ const zipIn = (other) => (elem, ndx) => {
52
52
  return [elem, other[ndx]];
53
53
  };
54
+ exports.zipIn = zipIn;
54
55
  function assertExhaustive(val) {
55
56
  throw new Error(`Never has a value (${val}). This should be impossible`);
56
57
  }
@@ -165,7 +165,7 @@ function loadUserEnvs({ functionsSource, projectId, projectAlias, isEmulator, })
165
165
  });
166
166
  }
167
167
  }
168
- utils_1.logBullet(clc.cyan.bold("functions: ") + `Loaded environment variables from ${envFiles.join(", ")}.`);
168
+ (0, utils_1.logBullet)(clc.cyan.bold("functions: ") + `Loaded environment variables from ${envFiles.join(", ")}.`);
169
169
  return envs;
170
170
  }
171
171
  exports.loadUserEnvs = loadUserEnvs;
@@ -12,18 +12,18 @@ const utils_1 = require("../utils");
12
12
  const functional_1 = require("../functional");
13
13
  function getProjectInfos(options) {
14
14
  const result = {};
15
- const rc = rc_1.loadRC(options);
15
+ const rc = (0, rc_1.loadRC)(options);
16
16
  if (rc.projects) {
17
17
  for (const [alias, projectId] of Object.entries(rc.projects)) {
18
18
  if (Object.keys(result).includes(projectId)) {
19
- utils_1.logWarning(`Multiple aliases found for ${clc.bold(projectId)}. ` +
19
+ (0, utils_1.logWarning)(`Multiple aliases found for ${clc.bold(projectId)}. ` +
20
20
  `Preferring alias (${clc.bold(result[projectId])}) over (${clc.bold(alias)}).`);
21
21
  continue;
22
22
  }
23
23
  result[projectId] = alias;
24
24
  }
25
25
  }
26
- const projectId = projectUtils_1.getProjectId(options);
26
+ const projectId = (0, projectUtils_1.getProjectId)(options);
27
27
  if (projectId && !Object.keys(result).includes(projectId)) {
28
28
  result[projectId] = projectId;
29
29
  }
@@ -72,7 +72,7 @@ exports.convertKey = convertKey;
72
72
  function configToEnv(configs, prefix) {
73
73
  const success = [];
74
74
  const errors = [];
75
- for (const [configKey, value] of functional_1.flatten(configs)) {
75
+ for (const [configKey, value] of (0, functional_1.flatten)(configs)) {
76
76
  try {
77
77
  const envKey = convertKey(configKey, prefix);
78
78
  success.push({ origKey: configKey, newKey: envKey, value: value });
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseUnsetArgs = exports.parseSetArgs = exports.materializeAll = exports.materializeConfig = exports.setVariablesRecursive = exports.getFirebaseConfig = exports.getAppEngineLocation = exports.idsToVarName = exports.varNameToIds = exports.ensureApi = exports.RESERVED_NAMESPACES = void 0;
4
4
  const _ = require("lodash");
5
5
  const clc = require("cli-color");
6
- const api = require("./api");
6
+ const api_1 = require("./api");
7
+ const apiv2_1 = require("./apiv2");
7
8
  const ensureApiEnabled_1 = require("./ensureApiEnabled");
8
9
  const error_1 = require("./error");
9
10
  const projectUtils_1 = require("./projectUtils");
10
11
  const runtimeconfig = require("./gcp/runtimeconfig");
11
12
  exports.RESERVED_NAMESPACES = ["firebase"];
13
+ const apiClient = new apiv2_1.Client({ urlPrefix: api_1.firebaseApiOrigin });
12
14
  function keyToIds(key) {
13
15
  const keyParts = key.split(".");
14
16
  const variable = keyParts.slice(1).join("/");
@@ -30,8 +32,8 @@ function isReservedNamespace(id) {
30
32
  });
31
33
  }
32
34
  async function ensureApi(options) {
33
- const projectId = projectUtils_1.needProjectId(options);
34
- return ensureApiEnabled_1.ensure(projectId, "runtimeconfig.googleapis.com", "runtimeconfig", true);
35
+ const projectId = (0, projectUtils_1.needProjectId)(options);
36
+ return (0, ensureApiEnabled_1.ensure)(projectId, "runtimeconfig.googleapis.com", "runtimeconfig", true);
35
37
  }
36
38
  exports.ensureApi = ensureApi;
37
39
  function varNameToIds(varName) {
@@ -54,11 +56,8 @@ function getAppEngineLocation(config) {
54
56
  }
55
57
  exports.getAppEngineLocation = getAppEngineLocation;
56
58
  async function getFirebaseConfig(options) {
57
- const projectId = projectUtils_1.needProjectId(options);
58
- const response = await api.request("GET", "/v1beta1/projects/" + projectId + "/adminSdkConfig", {
59
- auth: true,
60
- origin: api.firebaseApiOrigin,
61
- });
59
+ const projectId = (0, projectUtils_1.needProjectId)(options);
60
+ const response = await apiClient.get(`/v1beta1/projects/${projectId}/adminSdkConfig`);
62
61
  return response.body;
63
62
  }
64
63
  exports.getFirebaseConfig = getFirebaseConfig;
@@ -16,7 +16,7 @@ const types_1 = require("./emulator/types");
16
16
  const hubClient_1 = require("./emulator/hubClient");
17
17
  const portUtils_1 = require("./emulator/portUtils");
18
18
  const serveFunctions = new functions_1.FunctionsServer();
19
- exports.actionFunction = async (options) => {
19
+ const actionFunction = async (options) => {
20
20
  var _a, _b;
21
21
  if (typeof options.port === "string") {
22
22
  options.port = parseInt(options.port, 10);
@@ -42,7 +42,7 @@ exports.actionFunction = async (options) => {
42
42
  options.port = (_b = (_a = options.config.src.emulators) === null || _a === void 0 ? void 0 : _a.functions) === null || _b === void 0 ? void 0 : _b.port;
43
43
  }
44
44
  if (!options.port) {
45
- options.port = await portUtils_1.findAvailablePort("localhost", 5000);
45
+ options.port = await (0, portUtils_1.findAvailablePort)("localhost", 5000);
46
46
  }
47
47
  return serveFunctions
48
48
  .start(options, {
@@ -55,7 +55,7 @@ exports.actionFunction = async (options) => {
55
55
  })
56
56
  .then(() => {
57
57
  const instance = serveFunctions.get();
58
- const emulator = new shell.FunctionsEmulatorShell(instance);
58
+ const emulator = new shell.FunctionsEmulatorShell(instance, serveFunctions.getBackend());
59
59
  if (emulator.emulatedFunctions && emulator.emulatedFunctions.length === 0) {
60
60
  logger_1.logger.info("No functions emulated.");
61
61
  process.exit();
@@ -98,3 +98,4 @@ exports.actionFunction = async (options) => {
98
98
  });
99
99
  });
100
100
  };
101
+ exports.actionFunction = actionFunction;