firebase-tools 9.23.2 → 10.1.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 (222) hide show
  1. package/lib/api.js +1 -1
  2. package/lib/apiv2.js +2 -2
  3. package/lib/appdistribution/client.js +1 -1
  4. package/lib/appdistribution/options-parser-util.js +1 -1
  5. package/lib/auth.js +2 -2
  6. package/lib/command.js +26 -26
  7. package/lib/commands/appdistribution-distribute.js +4 -4
  8. package/lib/commands/appdistribution-testers-add.js +2 -2
  9. package/lib/commands/appdistribution-testers-remove.js +2 -2
  10. package/lib/commands/apps-android-sha-create.js +2 -2
  11. package/lib/commands/apps-android-sha-delete.js +2 -2
  12. package/lib/commands/apps-android-sha-list.js +2 -2
  13. package/lib/commands/apps-create.js +9 -9
  14. package/lib/commands/apps-list.js +3 -3
  15. package/lib/commands/apps-sdkconfig.js +8 -8
  16. package/lib/commands/database-get.js +1 -1
  17. package/lib/commands/database-instances-create.js +4 -4
  18. package/lib/commands/database-instances-list.js +4 -4
  19. package/lib/commands/database-profile.js +1 -1
  20. package/lib/commands/database-push.js +1 -1
  21. package/lib/commands/database-remove.js +4 -4
  22. package/lib/commands/database-set.js +4 -4
  23. package/lib/commands/database-settings-get.js +1 -1
  24. package/lib/commands/database-settings-set.js +1 -1
  25. package/lib/commands/database-update.js +4 -4
  26. package/lib/commands/ext-configure.js +2 -2
  27. package/lib/commands/ext-dev-deprecate.js +4 -4
  28. package/lib/commands/ext-dev-extension-delete.js +3 -3
  29. package/lib/commands/ext-dev-init.js +3 -3
  30. package/lib/commands/ext-dev-list.js +1 -1
  31. package/lib/commands/ext-dev-publish.js +3 -3
  32. package/lib/commands/ext-dev-register.js +5 -5
  33. package/lib/commands/ext-dev-undeprecate.js +4 -4
  34. package/lib/commands/ext-dev-unpublish.js +3 -3
  35. package/lib/commands/ext-dev-usage.js +145 -0
  36. package/lib/commands/ext-export.js +8 -8
  37. package/lib/commands/ext-info.js +4 -4
  38. package/lib/commands/ext-install.js +26 -22
  39. package/lib/commands/ext-list.js +2 -2
  40. package/lib/commands/ext-sources-create.js +2 -2
  41. package/lib/commands/ext-uninstall.js +3 -3
  42. package/lib/commands/ext-update.js +17 -17
  43. package/lib/commands/ext.js +3 -3
  44. package/lib/commands/firestore-delete.js +3 -3
  45. package/lib/commands/functions-config-export.js +11 -11
  46. package/lib/commands/functions-delete.js +3 -3
  47. package/lib/commands/functions-deletegcfartifacts.js +4 -4
  48. package/lib/commands/functions-list.js +1 -1
  49. package/lib/commands/functions-log.js +1 -1
  50. package/lib/commands/hosting-channel-create.js +12 -12
  51. package/lib/commands/hosting-channel-delete.js +9 -9
  52. package/lib/commands/hosting-channel-deploy.js +17 -17
  53. package/lib/commands/hosting-channel-list.js +5 -5
  54. package/lib/commands/hosting-channel-open.js +9 -9
  55. package/lib/commands/hosting-clone.js +15 -15
  56. package/lib/commands/hosting-disable.js +4 -4
  57. package/lib/commands/hosting-sites-create.js +7 -7
  58. package/lib/commands/hosting-sites-delete.js +7 -7
  59. package/lib/commands/hosting-sites-get.js +2 -2
  60. package/lib/commands/hosting-sites-list.js +3 -3
  61. package/lib/commands/index.js +1 -0
  62. package/lib/commands/login.js +2 -2
  63. package/lib/commands/logout.js +1 -1
  64. package/lib/commands/open.js +1 -1
  65. package/lib/commands/projects-addfirebase.js +2 -2
  66. package/lib/commands/projects-create.js +2 -2
  67. package/lib/commands/projects-list.js +1 -1
  68. package/lib/commands/remoteconfig-get.js +3 -3
  69. package/lib/commands/remoteconfig-rollback.js +3 -3
  70. package/lib/commands/remoteconfig-versions-list.js +1 -1
  71. package/lib/commands/setup-emulators-storage.js +1 -1
  72. package/lib/config.js +6 -6
  73. package/lib/database/api.js +2 -2
  74. package/lib/deploy/extensions/deploy.js +4 -4
  75. package/lib/deploy/extensions/deploymentSummary.js +5 -4
  76. package/lib/deploy/extensions/index.js +1 -0
  77. package/lib/deploy/extensions/params.js +1 -1
  78. package/lib/deploy/extensions/planner.js +3 -3
  79. package/lib/deploy/extensions/prepare.js +9 -9
  80. package/lib/deploy/extensions/release.js +1 -1
  81. package/lib/deploy/extensions/secrets.js +7 -7
  82. package/lib/deploy/extensions/validate.js +2 -2
  83. package/lib/deploy/functions/backend.js +6 -4
  84. package/lib/deploy/functions/checkIam.js +7 -7
  85. package/lib/deploy/functions/containerCleaner.js +3 -3
  86. package/lib/deploy/functions/deploy.js +10 -11
  87. package/lib/deploy/functions/ensureCloudBuildEnabled.js +3 -3
  88. package/lib/deploy/functions/index.js +1 -0
  89. package/lib/deploy/functions/prepare.js +13 -13
  90. package/lib/deploy/functions/prompts.js +5 -5
  91. package/lib/deploy/functions/release/executor.js +4 -1
  92. package/lib/deploy/functions/release/fabricator.js +5 -5
  93. package/lib/deploy/functions/release/index.js +3 -3
  94. package/lib/deploy/functions/release/planner.js +6 -6
  95. package/lib/deploy/functions/release/reporter.js +8 -4
  96. package/lib/deploy/functions/runtimes/discovery/index.js +2 -2
  97. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +14 -14
  98. package/lib/deploy/functions/runtimes/golang/index.js +6 -6
  99. package/lib/deploy/functions/runtimes/node/index.js +3 -3
  100. package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +1 -1
  101. package/lib/deploy/functions/runtimes/node/parseTriggers.js +3 -3
  102. package/lib/deploy/functions/services/storage.js +1 -1
  103. package/lib/deploy/functions/triggerRegionHelper.js +1 -1
  104. package/lib/deploy/hosting/deploy.js +7 -7
  105. package/lib/deploy/hosting/uploader.js +1 -1
  106. package/lib/deploy/hosting/validate.js +3 -3
  107. package/lib/deploy/remoteconfig/prepare.js +3 -3
  108. package/lib/deploy/remoteconfig/release.js +3 -3
  109. package/lib/deploy/storage/deploy.js +1 -1
  110. package/lib/deploy/storage/release.js +2 -2
  111. package/lib/detectProjectRoot.js +5 -5
  112. package/lib/emulator/auth/apiSpec.js +13 -7
  113. package/lib/emulator/auth/handlers.js +3 -3
  114. package/lib/emulator/auth/index.js +1 -1
  115. package/lib/emulator/auth/operations.js +256 -248
  116. package/lib/emulator/auth/server.js +11 -8
  117. package/lib/emulator/auth/state.js +12 -12
  118. package/lib/emulator/auth/widget_ui.js +1 -1
  119. package/lib/emulator/commandUtils.js +5 -5
  120. package/lib/emulator/controller.js +16 -11
  121. package/lib/emulator/downloadableEmulators.js +7 -7
  122. package/lib/emulator/emulatorLogger.js +1 -1
  123. package/lib/emulator/functionsEmulator.js +101 -74
  124. package/lib/emulator/functionsEmulatorRuntime.js +33 -18
  125. package/lib/emulator/functionsEmulatorShell.js +3 -2
  126. package/lib/emulator/functionsRuntimeWorker.js +1 -1
  127. package/lib/emulator/hubExport.js +2 -2
  128. package/lib/emulator/storage/apis/firebase.js +2 -2
  129. package/lib/emulator/storage/apis/gcloud.js +2 -2
  130. package/lib/emulator/storage/cloudFunctions.js +1 -1
  131. package/lib/emulator/storage/files.js +14 -14
  132. package/lib/emulator/storage/index.js +2 -2
  133. package/lib/emulator/storage/metadata.js +7 -6
  134. package/lib/emulator/storage/rules/runtime.js +5 -5
  135. package/lib/emulator/storage/server.js +2 -2
  136. package/lib/ensureApiEnabled.js +7 -7
  137. package/lib/error.js +3 -3
  138. package/lib/extensions/askUserForConsent.js +2 -3
  139. package/lib/extensions/askUserForParam.js +10 -10
  140. package/lib/extensions/billingMigrationHelper.js +1 -1
  141. package/lib/extensions/changelog.js +3 -3
  142. package/lib/extensions/displayExtensionInfo.js +5 -5
  143. package/lib/extensions/emulator/optionsHelper.js +1 -1
  144. package/lib/extensions/emulator/specHelper.js +1 -1
  145. package/lib/extensions/emulator/triggerHelper.js +1 -1
  146. package/lib/extensions/export.js +6 -6
  147. package/lib/extensions/extensionsApi.js +14 -1
  148. package/lib/extensions/extensionsHelper.js +38 -29
  149. package/lib/extensions/listExtensions.js +1 -1
  150. package/lib/extensions/localHelper.js +1 -1
  151. package/lib/extensions/metricsTypeDef.js +2 -0
  152. package/lib/extensions/metricsUtils.js +98 -0
  153. package/lib/extensions/paramHelper.js +6 -6
  154. package/lib/extensions/provisioningHelper.js +6 -4
  155. package/lib/extensions/resolveSource.js +1 -1
  156. package/lib/extensions/secretsUtils.js +3 -3
  157. package/lib/extensions/updateHelper.js +9 -9
  158. package/lib/extensions/utils.js +1 -1
  159. package/lib/extensions/warnings.js +10 -9
  160. package/lib/fetchWebSetup.js +2 -2
  161. package/lib/filterTargets.js +2 -2
  162. package/lib/firestore/indexes.js +2 -2
  163. package/lib/fsAsync.js +3 -3
  164. package/lib/fsutils.js +2 -2
  165. package/lib/functional.js +2 -1
  166. package/lib/functions/env.js +1 -1
  167. package/lib/functions/runtimeConfigExport.js +4 -4
  168. package/lib/functionsConfig.js +3 -3
  169. package/lib/functionsShellCommandAction.js +4 -3
  170. package/lib/gcp/cloudmonitoring.js +74 -0
  171. package/lib/gcp/cloudscheduler.js +1 -1
  172. package/lib/gcp/iam.js +2 -2
  173. package/lib/gcp/resourceManager.js +2 -2
  174. package/lib/gcp/secretManager.js +3 -2
  175. package/lib/getDefaultDatabaseInstance.js +1 -1
  176. package/lib/getDefaultHostingSite.js +1 -1
  177. package/lib/getProjectNumber.js +2 -2
  178. package/lib/handlePreviewToggles.js +5 -5
  179. package/lib/hosting/api.js +6 -6
  180. package/lib/hosting/cloudRunProxy.js +6 -6
  181. package/lib/hosting/functionsProxy.js +3 -3
  182. package/lib/hosting/implicitInit.js +2 -2
  183. package/lib/hosting/normalizedHostingConfigs.js +3 -3
  184. package/lib/hosting/proxy.js +2 -2
  185. package/lib/init/features/account.js +7 -7
  186. package/lib/init/features/database.js +9 -9
  187. package/lib/init/features/emulators.js +8 -8
  188. package/lib/init/features/firestore/index.js +3 -3
  189. package/lib/init/features/firestore/indexes.js +2 -2
  190. package/lib/init/features/firestore/rules.js +2 -2
  191. package/lib/init/features/functions/golang.js +4 -4
  192. package/lib/init/features/functions/index.js +4 -4
  193. package/lib/init/features/hosting/github.js +31 -31
  194. package/lib/init/features/project.js +8 -8
  195. package/lib/init/features/remoteconfig.js +2 -2
  196. package/lib/init/features/storage.js +2 -2
  197. package/lib/listFiles.js +1 -1
  198. package/lib/management/apps.js +3 -3
  199. package/lib/management/projects.js +6 -6
  200. package/lib/previews.js +2 -2
  201. package/lib/profiler.js +1 -1
  202. package/lib/projectPath.js +1 -1
  203. package/lib/projectUtils.js +1 -1
  204. package/lib/prompt.js +0 -1
  205. package/lib/rc.js +1 -1
  206. package/lib/requireAuth.js +2 -2
  207. package/lib/requireDatabaseInstance.js +1 -1
  208. package/lib/requireHostingSite.js +1 -1
  209. package/lib/requirePermissions.js +4 -4
  210. package/lib/rulesDeploy.js +2 -2
  211. package/lib/serve/functions.js +14 -7
  212. package/lib/serve/hosting.js +7 -7
  213. package/lib/utils.js +3 -2
  214. package/npm-shrinkwrap.json +24926 -0
  215. package/package.json +24 -24
  216. package/standalone/firepit.js +4 -4
  217. package/templates/init/functions/javascript/package.lint.json +1 -1
  218. package/templates/init/functions/javascript/package.nolint.json +1 -1
  219. package/templates/init/functions/typescript/package.lint.json +1 -1
  220. package/templates/init/functions/typescript/package.nolint.json +1 -1
  221. package/templates/init/hosting/index.html +1 -1
  222. package/CHANGELOG.md +0 -7
@@ -35,7 +35,6 @@ const DATABASE_PATH_PATTERN = new RegExp("^projects/[^/]+/instances/([^/]+)/refs
35
35
  class FunctionsEmulator {
36
36
  constructor(args) {
37
37
  this.args = args;
38
- this.nodeBinary = "";
39
38
  this.triggers = {};
40
39
  this.triggerGeneration = 0;
41
40
  this.logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.FUNCTIONS);
@@ -63,7 +62,7 @@ class FunctionsEmulator {
63
62
  this.logger.logLabeled("WARN", "functions", `Your GOOGLE_APPLICATION_CREDENTIALS environment variable points to ${process.env.GOOGLE_APPLICATION_CREDENTIALS}. Non-emulated services will access production using these credentials. Be careful!`);
64
63
  }
65
64
  else if (this.args.account) {
66
- const defaultCredPath = await defaultCredentials_1.getCredentialPathAsync(this.args.account);
65
+ const defaultCredPath = await (0, defaultCredentials_1.getCredentialPathAsync)(this.args.account);
67
66
  if (defaultCredPath) {
68
67
  this.logger.log("DEBUG", `Setting GAC to ${defaultCredPath}`);
69
68
  credentialEnv.GOOGLE_APPLICATION_CREDENTIALS = defaultCredPath;
@@ -160,58 +159,70 @@ class FunctionsEmulator {
160
159
  });
161
160
  return hub;
162
161
  }
163
- startFunctionRuntime(triggerId, targetName, signatureType, proto, runtimeOpts) {
164
- const bundleTemplate = this.getBaseBundle();
162
+ startFunctionRuntime(backend, triggerId, targetName, signatureType, proto, runtimeOpts) {
163
+ const bundleTemplate = this.getBaseBundle(backend);
165
164
  const runtimeBundle = Object.assign(Object.assign({}, bundleTemplate), { emulators: {
166
165
  firestore: this.getEmulatorInfo(types_1.Emulators.FIRESTORE),
167
166
  database: this.getEmulatorInfo(types_1.Emulators.DATABASE),
168
167
  pubsub: this.getEmulatorInfo(types_1.Emulators.PUBSUB),
169
168
  auth: this.getEmulatorInfo(types_1.Emulators.AUTH),
170
169
  storage: this.getEmulatorInfo(types_1.Emulators.STORAGE),
171
- }, nodeMajorVersion: this.args.nodeMajorVersion, proto,
170
+ }, nodeMajorVersion: backend.nodeMajorVersion, proto,
172
171
  triggerId,
173
172
  targetName });
173
+ if (!backend.nodeBinary) {
174
+ throw new error_1.FirebaseError(`No node binary for ${triggerId}. This should never happen.`);
175
+ }
174
176
  const opts = runtimeOpts || {
175
- nodeBinary: this.nodeBinary,
176
- extensionTriggers: this.args.predefinedTriggers,
177
+ nodeBinary: backend.nodeBinary,
178
+ extensionTriggers: backend.predefinedTriggers,
177
179
  };
178
- const worker = this.invokeRuntime(runtimeBundle, opts, this.getRuntimeEnvs({ targetName, signatureType }));
180
+ const worker = this.invokeRuntime(runtimeBundle, opts, this.getRuntimeEnvs(backend, { targetName, signatureType }));
179
181
  return worker;
180
182
  }
181
183
  async start() {
182
- this.nodeBinary = this.askInstallNodeVersion(this.args.functionsDir, this.args.nodeMajorVersion);
184
+ for (const backend of this.args.emulatableBackends) {
185
+ backend.nodeBinary = this.getNodeBinary(backend);
186
+ }
183
187
  const credentialEnv = await this.getCredentialsEnvironment();
184
- this.args.env = Object.assign(Object.assign({}, credentialEnv), this.args.env);
185
- const adminSdkConfig = await adminSdkConfig_1.getProjectAdminSdkConfigOrCached(this.args.projectId);
188
+ for (const e of this.args.emulatableBackends) {
189
+ e.env = Object.assign(Object.assign({}, credentialEnv), e.env);
190
+ }
191
+ const adminSdkConfig = await (0, adminSdkConfig_1.getProjectAdminSdkConfigOrCached)(this.args.projectId);
186
192
  if (adminSdkConfig) {
187
193
  this.adminSdkConfig = adminSdkConfig;
188
194
  }
189
195
  else {
190
196
  this.logger.logLabeled("WARN", "functions", "Unable to fetch project Admin SDK configuration, Admin SDK behavior in Cloud Functions emulator may be incorrect.");
191
- this.adminSdkConfig = adminSdkConfig_1.constructDefaultAdminSdkConfig(this.args.projectId);
197
+ this.adminSdkConfig = (0, adminSdkConfig_1.constructDefaultAdminSdkConfig)(this.args.projectId);
192
198
  }
193
199
  const { host, port } = this.getInfo();
194
200
  this.workQueue.start();
195
201
  const server = this.createHubServer().listen(port, host);
196
- this.destroyServer = utils_1.createDestroyer(server);
202
+ this.destroyServer = (0, utils_1.createDestroyer)(server);
197
203
  return Promise.resolve();
198
204
  }
199
205
  async connect() {
200
- this.logger.logLabeled("BULLET", "functions", `Watching "${this.args.functionsDir}" for Cloud Functions...`);
201
- const watcher = chokidar.watch(this.args.functionsDir, {
202
- ignored: [
203
- /.+?[\\\/]node_modules[\\\/].+?/,
204
- /(^|[\/\\])\../,
205
- /.+\.log/,
206
- ],
207
- persistent: true,
208
- });
209
- const debouncedLoadTriggers = _.debounce(() => this.loadTriggers(), 1000);
210
- watcher.on("change", (filePath) => {
211
- this.logger.log("DEBUG", `File ${filePath} changed, reloading triggers`);
212
- return debouncedLoadTriggers();
213
- });
214
- return this.loadTriggers(true);
206
+ const loadTriggerPromises = [];
207
+ for (const backend of this.args.emulatableBackends) {
208
+ this.logger.logLabeled("BULLET", "functions", `Watching "${backend.functionsDir}" for Cloud Functions...`);
209
+ const watcher = chokidar.watch(backend.functionsDir, {
210
+ ignored: [
211
+ /.+?[\\\/]node_modules[\\\/].+?/,
212
+ /(^|[\/\\])\../,
213
+ /.+\.log/,
214
+ ],
215
+ persistent: true,
216
+ });
217
+ const debouncedLoadTriggers = _.debounce(() => this.loadTriggers(backend), 1000);
218
+ watcher.on("change", (filePath) => {
219
+ this.logger.log("DEBUG", `File ${filePath} changed, reloading triggers`);
220
+ return debouncedLoadTriggers();
221
+ });
222
+ loadTriggerPromises.push(this.loadTriggers(backend, true));
223
+ }
224
+ await Promise.all(loadTriggerPromises);
225
+ return;
215
226
  }
216
227
  async stop() {
217
228
  try {
@@ -226,16 +237,19 @@ class FunctionsEmulator {
226
237
  await this.destroyServer();
227
238
  }
228
239
  }
229
- async loadTriggers(force = false) {
240
+ async loadTriggers(emulatableBackend, force = false) {
230
241
  this.workerPool.refresh();
231
- const worker = this.invokeRuntime(this.getBaseBundle(), {
232
- nodeBinary: this.nodeBinary,
233
- extensionTriggers: this.args.predefinedTriggers,
234
- }, Object.assign(Object.assign(Object.assign(Object.assign({}, this.getSystemEnvs()), this.getEmulatorEnvs()), { FIREBASE_CONFIG: this.getFirebaseConfig() }), this.args.env));
242
+ if (!emulatableBackend.nodeBinary) {
243
+ throw new error_1.FirebaseError(`No node binary for ${emulatableBackend.functionsDir}. This should never happen.`);
244
+ }
245
+ const worker = this.invokeRuntime(this.getBaseBundle(emulatableBackend), {
246
+ nodeBinary: emulatableBackend.nodeBinary,
247
+ extensionTriggers: emulatableBackend.predefinedTriggers,
248
+ }, Object.assign(Object.assign(Object.assign(Object.assign({}, this.getSystemEnvs()), this.getEmulatorEnvs()), { FIREBASE_CONFIG: this.getFirebaseConfig() }), emulatableBackend.env));
235
249
  const triggerParseEvent = await types_1.EmulatorLog.waitForLog(worker.runtime.events, "SYSTEM", "triggers-parsed");
236
250
  const parsedDefinitions = triggerParseEvent.data
237
251
  .triggerDefinitions;
238
- const triggerDefinitions = functionsEmulatorShared_1.emulatedFunctionsByRegion(parsedDefinitions);
252
+ const triggerDefinitions = (0, functionsEmulatorShared_1.emulatedFunctionsByRegion)(parsedDefinitions);
239
253
  const toSetup = triggerDefinitions.filter((definition) => {
240
254
  if (force) {
241
255
  return true;
@@ -252,7 +266,7 @@ class FunctionsEmulator {
252
266
  });
253
267
  for (const definition of toSetup) {
254
268
  try {
255
- validate_1.functionIdsAreValid([definition]);
269
+ (0, validate_1.functionIdsAreValid)([definition]);
256
270
  }
257
271
  catch (e) {
258
272
  this.logger.logLabeled("WARN", `functions[${definition.id}]`, `Invalid function id: ${e.message}`);
@@ -266,9 +280,9 @@ class FunctionsEmulator {
266
280
  url = FunctionsEmulator.getHttpFunctionUrl(host, port, this.args.projectId, definition.name, definition.region);
267
281
  }
268
282
  else if (definition.eventTrigger) {
269
- const service = functionsEmulatorShared_1.getFunctionService(definition);
283
+ const service = (0, functionsEmulatorShared_1.getFunctionService)(definition);
270
284
  const key = this.getTriggerKey(definition);
271
- const signature = functionsEmulatorShared_1.getSignatureType(definition);
285
+ const signature = (0, functionsEmulatorShared_1.getSignatureType)(definition);
272
286
  switch (service) {
273
287
  case constants_1.Constants.SERVICE_FIRESTORE:
274
288
  added = await this.addFirestoreTrigger(this.args.projectId, key, definition.eventTrigger);
@@ -294,10 +308,10 @@ class FunctionsEmulator {
294
308
  this.logger.log("WARN", `Trigger trigger "${definition.name}" has has neither "httpsTrigger" or "eventTrigger" member`);
295
309
  }
296
310
  const ignored = !added;
297
- this.addTriggerRecord(definition, { ignored, url });
311
+ this.addTriggerRecord(definition, { backend: emulatableBackend, ignored, url });
298
312
  const type = definition.httpsTrigger
299
313
  ? "http"
300
- : constants_1.Constants.getServiceName(functionsEmulatorShared_1.getFunctionService(definition));
314
+ : constants_1.Constants.getServiceName((0, functionsEmulatorShared_1.getFunctionService)(definition));
301
315
  if (ignored) {
302
316
  const msg = `function ignored because the ${type} emulator does not exist or is not running.`;
303
317
  this.logger.logLabeled("BULLET", `functions[${definition.id}]`, msg);
@@ -434,27 +448,36 @@ class FunctionsEmulator {
434
448
  getTriggerDefinitions() {
435
449
  return Object.values(this.triggers).map((record) => record.def);
436
450
  }
437
- getTriggerDefinitionByKey(triggerKey) {
451
+ getTriggerRecordByKey(triggerKey) {
438
452
  const record = this.triggers[triggerKey];
439
453
  if (!record) {
440
454
  logger_1.logger.debug(`Could not find key=${triggerKey} in ${JSON.stringify(this.triggers)}`);
441
455
  throw new error_1.FirebaseError(`No trigger with key ${triggerKey}`);
442
456
  }
443
- return record.def;
457
+ return record;
444
458
  }
445
459
  getTriggerKey(def) {
446
460
  return def.eventTrigger ? `${def.id}-${this.triggerGeneration}` : def.id;
447
461
  }
462
+ getBackends() {
463
+ return this.args.emulatableBackends;
464
+ }
448
465
  addTriggerRecord(def, opts) {
449
466
  const key = this.getTriggerKey(def);
450
- this.triggers[key] = { def, enabled: true, ignored: opts.ignored, url: opts.url };
467
+ this.triggers[key] = {
468
+ def,
469
+ enabled: true,
470
+ backend: opts.backend,
471
+ ignored: opts.ignored,
472
+ url: opts.url,
473
+ };
451
474
  }
452
- setTriggersForTesting(triggers) {
453
- triggers.forEach((def) => this.addTriggerRecord(def, { ignored: false }));
475
+ setTriggersForTesting(triggers, backend) {
476
+ triggers.forEach((def) => this.addTriggerRecord(def, { backend, ignored: false }));
454
477
  }
455
- getBaseBundle() {
478
+ getBaseBundle(backend) {
456
479
  return {
457
- cwd: this.args.functionsDir,
480
+ cwd: backend.functionsDir,
458
481
  projectId: this.args.projectId,
459
482
  triggerId: "",
460
483
  targetName: "",
@@ -476,21 +499,21 @@ class FunctionsEmulator {
476
499
  const pkg = require(path.join(frb.cwd, "package.json"));
477
500
  return frb.nodeMajorVersion || (pkg.engines && pkg.engines.node);
478
501
  }
479
- askInstallNodeVersion(cwd, nodeMajorVersion) {
480
- const pkg = require(path.join(cwd, "package.json"));
481
- if ((!pkg.engines || !pkg.engines.node) && !nodeMajorVersion) {
482
- this.logger.log("WARN", "Your functions directory does not specify a Node version.\n " +
502
+ getNodeBinary(backend) {
503
+ const pkg = require(path.join(backend.functionsDir, "package.json"));
504
+ if ((!pkg.engines || !pkg.engines.node) && !backend.nodeMajorVersion) {
505
+ this.logger.log("WARN", `Your functions directory ${backend.functionsDir} does not specify a Node version.\n ` +
483
506
  "- Learn more at https://firebase.google.com/docs/functions/manage-functions#set_runtime_options");
484
507
  return process.execPath;
485
508
  }
486
509
  const hostMajorVersion = process.versions.node.split(".")[0];
487
- const requestedMajorVersion = nodeMajorVersion
488
- ? `${nodeMajorVersion}`
510
+ const requestedMajorVersion = backend.nodeMajorVersion
511
+ ? `${backend.nodeMajorVersion}`
489
512
  : pkg.engines.node;
490
513
  let localMajorVersion = "0";
491
- const localNodePath = path.join(cwd, "node_modules/.bin/node");
514
+ const localNodePath = path.join(backend.functionsDir, "node_modules/.bin/node");
492
515
  try {
493
- const localNodeOutput = child_process_1.spawnSync(localNodePath, ["--version"]).stdout.toString();
516
+ const localNodeOutput = (0, child_process_1.spawnSync)(localNodePath, ["--version"]).stdout.toString();
494
517
  localMajorVersion = localNodeOutput.slice(1).split(".")[0];
495
518
  }
496
519
  catch (err) {
@@ -501,14 +524,13 @@ class FunctionsEmulator {
501
524
  }
502
525
  if (requestedMajorVersion === hostMajorVersion) {
503
526
  this.logger.logLabeled("SUCCESS", "functions", `Using node@${requestedMajorVersion} from host.`);
504
- return process.execPath;
505
527
  }
506
528
  this.logger.log("WARN", `Your requested "node" version "${requestedMajorVersion}" doesn't match your global version "${hostMajorVersion}"`);
507
529
  return process.execPath;
508
530
  }
509
- getUserEnvs() {
531
+ getUserEnvs(backend) {
510
532
  const projectInfo = {
511
- functionsSource: this.args.functionsDir,
533
+ functionsSource: backend.functionsDir,
512
534
  projectId: this.args.projectId,
513
535
  isEmulator: true,
514
536
  };
@@ -544,24 +566,24 @@ class FunctionsEmulator {
544
566
  envs.FIREBASE_DEBUG_FEATURES = JSON.stringify({ skipTokenVerification: true });
545
567
  const firestoreEmulator = this.getEmulatorInfo(types_1.Emulators.FIRESTORE);
546
568
  if (firestoreEmulator != null) {
547
- envs[constants_1.Constants.FIRESTORE_EMULATOR_HOST] = functionsEmulatorShared_1.formatHost(firestoreEmulator);
569
+ envs[constants_1.Constants.FIRESTORE_EMULATOR_HOST] = (0, functionsEmulatorShared_1.formatHost)(firestoreEmulator);
548
570
  }
549
571
  const databaseEmulator = this.getEmulatorInfo(types_1.Emulators.DATABASE);
550
572
  if (databaseEmulator) {
551
- envs[constants_1.Constants.FIREBASE_DATABASE_EMULATOR_HOST] = functionsEmulatorShared_1.formatHost(databaseEmulator);
573
+ envs[constants_1.Constants.FIREBASE_DATABASE_EMULATOR_HOST] = (0, functionsEmulatorShared_1.formatHost)(databaseEmulator);
552
574
  }
553
575
  const authEmulator = this.getEmulatorInfo(types_1.Emulators.AUTH);
554
576
  if (authEmulator) {
555
- envs[constants_1.Constants.FIREBASE_AUTH_EMULATOR_HOST] = functionsEmulatorShared_1.formatHost(authEmulator);
577
+ envs[constants_1.Constants.FIREBASE_AUTH_EMULATOR_HOST] = (0, functionsEmulatorShared_1.formatHost)(authEmulator);
556
578
  }
557
579
  const storageEmulator = this.getEmulatorInfo(types_1.Emulators.STORAGE);
558
580
  if (storageEmulator) {
559
- envs[constants_1.Constants.FIREBASE_STORAGE_EMULATOR_HOST] = functionsEmulatorShared_1.formatHost(storageEmulator);
560
- envs[constants_1.Constants.CLOUD_STORAGE_EMULATOR_HOST] = `http://${functionsEmulatorShared_1.formatHost(storageEmulator)}`;
581
+ envs[constants_1.Constants.FIREBASE_STORAGE_EMULATOR_HOST] = (0, functionsEmulatorShared_1.formatHost)(storageEmulator);
582
+ envs[constants_1.Constants.CLOUD_STORAGE_EMULATOR_HOST] = `http://${(0, functionsEmulatorShared_1.formatHost)(storageEmulator)}`;
561
583
  }
562
584
  const pubsubEmulator = this.getEmulatorInfo(types_1.Emulators.PUBSUB);
563
585
  if (pubsubEmulator) {
564
- const pubsubHost = functionsEmulatorShared_1.formatHost(pubsubEmulator);
586
+ const pubsubHost = (0, functionsEmulatorShared_1.formatHost)(pubsubEmulator);
565
587
  process.env.PUBSUB_EMULATOR_HOST = pubsubHost;
566
588
  }
567
589
  return envs;
@@ -575,7 +597,7 @@ class FunctionsEmulator {
575
597
  const asUrl = new url_1.URL(this.adminSdkConfig.databaseURL);
576
598
  ns = asUrl.hostname.split(".")[0];
577
599
  }
578
- emulatedDatabaseURL = `http://${functionsEmulatorShared_1.formatHost(databaseEmulator)}/?ns=${ns}`;
600
+ emulatedDatabaseURL = `http://${(0, functionsEmulatorShared_1.formatHost)(databaseEmulator)}/?ns=${ns}`;
579
601
  }
580
602
  return JSON.stringify({
581
603
  storageBucket: this.adminSdkConfig.storageBucket,
@@ -583,8 +605,8 @@ class FunctionsEmulator {
583
605
  projectId: this.args.projectId,
584
606
  });
585
607
  }
586
- getRuntimeEnvs(triggerDef) {
587
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, this.getUserEnvs()), this.getSystemEnvs(triggerDef)), this.getEmulatorEnvs()), { FIREBASE_CONFIG: this.getFirebaseConfig() }), this.args.env);
608
+ getRuntimeEnvs(backend, triggerDef) {
609
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, this.getUserEnvs(backend)), this.getSystemEnvs(triggerDef)), this.getEmulatorEnvs()), { FIREBASE_CONFIG: this.getFirebaseConfig() }), backend.env);
588
610
  }
589
611
  invokeRuntime(frb, opts, runtimeEnv) {
590
612
  if (this.workerPool.readyForWork(frb.triggerId)) {
@@ -663,16 +685,20 @@ class FunctionsEmulator {
663
685
  }
664
686
  async reloadTriggers() {
665
687
  this.triggerGeneration++;
666
- return this.loadTriggers();
688
+ const loadTriggerPromises = [];
689
+ for (const backend of this.args.emulatableBackends) {
690
+ loadTriggerPromises.push(this.loadTriggers(backend));
691
+ }
692
+ return Promise.all(loadTriggerPromises);
667
693
  }
668
694
  async handleBackgroundTrigger(projectId, triggerKey, proto) {
669
- const record = this.triggers[triggerKey];
695
+ const record = this.getTriggerRecordByKey(triggerKey);
670
696
  if (record && !record.enabled) {
671
697
  return Promise.reject({ code: 204, body: "Background triggers are curently disabled." });
672
698
  }
673
- const trigger = this.getTriggerDefinitionByKey(triggerKey);
674
- const service = functionsEmulatorShared_1.getFunctionService(trigger);
675
- const worker = this.startFunctionRuntime(trigger.id, trigger.name, functionsEmulatorShared_1.getSignatureType(trigger), proto);
699
+ const trigger = record.def;
700
+ const service = (0, functionsEmulatorShared_1.getFunctionService)(trigger);
701
+ const worker = this.startFunctionRuntime(record.backend, trigger.id, trigger.name, (0, functionsEmulatorShared_1.getSignatureType)(trigger), proto);
676
702
  return new Promise((resolve, reject) => {
677
703
  if (projectId !== this.args.projectId) {
678
704
  if (service !== constants_1.Constants.SERVICE_REALTIME_DATABASE) {
@@ -691,7 +717,7 @@ class FunctionsEmulator {
691
717
  reject({ code: 500, body: el.text });
692
718
  }
693
719
  });
694
- track(EVENT_INVOKE, functionsEmulatorShared_1.getFunctionService(trigger));
720
+ track(EVENT_INVOKE, (0, functionsEmulatorShared_1.getFunctionService)(trigger));
695
721
  worker.waitForDone().then(() => {
696
722
  resolve({ status: "acknowledged" });
697
723
  });
@@ -741,7 +767,8 @@ class FunctionsEmulator {
741
767
  .send(`Function ${triggerId} does not exist, valid triggers are: ${Object.keys(this.triggers).join(", ")}`);
742
768
  return;
743
769
  }
744
- const trigger = this.getTriggerDefinitionByKey(triggerId);
770
+ const record = this.getTriggerRecordByKey(triggerId);
771
+ const trigger = record.def;
745
772
  logger_1.logger.debug(`Accepted request ${method} ${req.url} --> ${triggerId}`);
746
773
  const reqBody = req.rawBody;
747
774
  const isCallable = trigger.labels && trigger.labels["deployment-callable"] === "true";
@@ -758,7 +785,7 @@ class FunctionsEmulator {
758
785
  req.headers[functionsEmulatorShared_1.HttpConstants.CALLABLE_AUTH_HEADER] = encodeURIComponent(JSON.stringify(contextAuth));
759
786
  }
760
787
  }
761
- const worker = this.startFunctionRuntime(trigger.id, trigger.name, "http", undefined);
788
+ const worker = this.startFunctionRuntime(record.backend, trigger.id, trigger.name, "http", undefined);
762
789
  worker.onLogs((el) => {
763
790
  if (el.level === "FATAL") {
764
791
  res.status(500).send(el.text);
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fs = require("fs");
3
4
  const types_1 = require("./types");
4
5
  const functionsEmulatorShared_1 = require("./functionsEmulatorShared");
5
6
  const functionsEmulatorUtils_1 = require("./functionsEmulatorUtils");
@@ -54,7 +55,7 @@ class Proxied {
54
55
  },
55
56
  apply: (target, thisArg, argArray) => {
56
57
  if (this.appliedValue) {
57
- return this.appliedValue.apply(thisArg, argArray);
58
+ return this.appliedValue.apply(thisArg);
58
59
  }
59
60
  else {
60
61
  return Proxied.applyOriginal(target, thisArg, argArray);
@@ -115,7 +116,7 @@ async function resolveDeveloperNodeModule(frb, name) {
115
116
  if (!resolveResult) {
116
117
  return { declared: true, installed: false };
117
118
  }
118
- const modPackageJSON = require(path.join(functionsEmulatorShared_1.findModuleRoot(name, resolveResult), "package.json"));
119
+ const modPackageJSON = require(path.join((0, functionsEmulatorShared_1.findModuleRoot)(name, resolveResult), "package.json"));
119
120
  const moduleResolution = {
120
121
  declared: true,
121
122
  installed: true,
@@ -135,7 +136,7 @@ async function assertResolveDeveloperNodeModule(frb, name) {
135
136
  async function verifyDeveloperNodeModules(frb) {
136
137
  const modBundles = [
137
138
  { name: "firebase-admin", isDev: false, minVersion: "8.9.0" },
138
- { name: "firebase-functions", isDev: false, minVersion: "3.3.0" },
139
+ { name: "firebase-functions", isDev: false, minVersion: "3.13.1" },
139
140
  ];
140
141
  for (const modBundle of modBundles) {
141
142
  const resolution = await resolveDeveloperNodeModule(frb, modBundle.name);
@@ -147,7 +148,7 @@ async function verifyDeveloperNodeModules(frb) {
147
148
  new types_1.EmulatorLog("SYSTEM", "uninstalled-module", "", modBundle).log();
148
149
  return false;
149
150
  }
150
- if (functionsEmulatorUtils_1.compareVersionStrings(resolution.version, modBundle.minVersion) < 0) {
151
+ if ((0, functionsEmulatorUtils_1.compareVersionStrings)(resolution.version, modBundle.minVersion) < 0) {
151
152
  new types_1.EmulatorLog("SYSTEM", "out-of-date-module", "", modBundle).log();
152
153
  return false;
153
154
  }
@@ -237,7 +238,7 @@ function initializeNetworkFiltering(frb) {
237
238
  }
238
239
  async function initializeFirebaseFunctionsStubs(frb) {
239
240
  const firebaseFunctionsResolution = await assertResolveDeveloperNodeModule(frb, "firebase-functions");
240
- const firebaseFunctionsRoot = functionsEmulatorShared_1.findModuleRoot("firebase-functions", firebaseFunctionsResolution.resolution);
241
+ const firebaseFunctionsRoot = (0, functionsEmulatorShared_1.findModuleRoot)("firebase-functions", firebaseFunctionsResolution.resolution);
241
242
  const httpsProviderResolution = path.join(firebaseFunctionsRoot, "lib/providers/https");
242
243
  const httpsProviderV1Resolution = path.join(firebaseFunctionsRoot, "lib/v1/providers/https");
243
244
  let httpsProvider;
@@ -318,6 +319,26 @@ function wrapCallableHandler(handler) {
318
319
  function getDefaultConfig() {
319
320
  return JSON.parse(process.env.FIREBASE_CONFIG || "{}");
320
321
  }
322
+ function initializeRuntimeConfig(frb) {
323
+ if (!process.env.CLOUD_RUNTIME_CONFIG) {
324
+ const configPath = `${frb.cwd}/.runtimeconfig.json`;
325
+ try {
326
+ const configContent = fs.readFileSync(configPath, "utf8");
327
+ if (configContent) {
328
+ try {
329
+ JSON.parse(configContent.toString());
330
+ logDebug(`Found local functions config: ${configPath}`);
331
+ process.env.CLOUD_RUNTIME_CONFIG = configContent.toString();
332
+ }
333
+ catch (e) {
334
+ new types_1.EmulatorLog("SYSTEM", "function-runtimeconfig-json-invalid", "").log();
335
+ }
336
+ }
337
+ }
338
+ catch (e) {
339
+ }
340
+ }
341
+ }
321
342
  async function initializeFirebaseAdminStubs(frb) {
322
343
  const adminResolution = await assertResolveDeveloperNodeModule(frb, "firebase-admin");
323
344
  const localAdminModule = require(adminResolution.resolution);
@@ -339,10 +360,10 @@ async function initializeFirebaseAdminStubs(frb) {
339
360
  logDebug("initializeApp(DEFAULT)", defaultAppOptions);
340
361
  localFunctionsModule.app.setEmulatedAdminApp(defaultApp);
341
362
  if (frb.emulators.auth) {
342
- if (functionsEmulatorUtils_1.compareVersionStrings(adminResolution.version, "9.3.0") < 0) {
363
+ if ((0, functionsEmulatorUtils_1.compareVersionStrings)(adminResolution.version, "9.3.0") < 0) {
343
364
  new types_1.EmulatorLog("WARN_ONCE", "runtime-status", "The Firebase Authentication emulator is running, but your 'firebase-admin' dependency is below version 9.3.0, so calls to Firebase Authentication will affect production.").log();
344
365
  }
345
- else if (functionsEmulatorUtils_1.compareVersionStrings(adminResolution.version, "9.4.2") <= 0) {
366
+ else if ((0, functionsEmulatorUtils_1.compareVersionStrings)(adminResolution.version, "9.4.2") <= 0) {
346
367
  const auth = defaultApp.auth();
347
368
  if (typeof auth.setJwtVerificationEnabled === "function") {
348
369
  logDebug("auth.setJwtVerificationEnabled(false)", {});
@@ -443,13 +464,6 @@ async function initializeFunctionsConfigHelper(frb) {
443
464
  functionsResolution,
444
465
  });
445
466
  }
446
- function setNode10EnvVars(target, mode, service) {
447
- process.env.FUNCTION_TARGET = target;
448
- process.env.FUNCTION_SIGNATURE_TYPE = mode;
449
- process.env.K_SERVICE = service;
450
- process.env.K_REVISION = "1";
451
- process.env.PORT = "80";
452
- }
453
467
  function rawBodySaver(req, res, buf) {
454
468
  req.rawBody = buf;
455
469
  }
@@ -590,7 +604,7 @@ async function invokeTrigger(frb, triggers) {
590
604
  }).log();
591
605
  const trigger = triggers[frb.triggerId];
592
606
  logDebug("triggerDefinition", trigger.definition);
593
- const signature = functionsEmulatorShared_1.getSignatureType(trigger.definition);
607
+ const signature = (0, functionsEmulatorShared_1.getSignatureType)(trigger.definition);
594
608
  logDebug(`Running ${frb.triggerId} in signature ${signature}`);
595
609
  let seconds = 0;
596
610
  const timerId = setInterval(() => {
@@ -626,6 +640,7 @@ async function initializeRuntime(frb, serializedFunctionTrigger, extensionTrigge
626
640
  new types_1.EmulatorLog("INFO", "runtime-status", `Your functions could not be parsed due to an issue with your node_modules (see above)`).log();
627
641
  return;
628
642
  }
643
+ initializeRuntimeConfig(frb);
629
644
  initializeNetworkFiltering(frb);
630
645
  await initializeFunctionsConfigHelper(frb);
631
646
  await initializeFirebaseFunctionsStubs(frb);
@@ -645,7 +660,7 @@ async function initializeRuntime(frb, serializedFunctionTrigger, extensionTrigge
645
660
  return;
646
661
  }
647
662
  const modulePath = require.resolve(frb.cwd);
648
- const moduleURL = url_1.pathToFileURL(modulePath).href;
663
+ const moduleURL = (0, url_1.pathToFileURL)(modulePath).href;
649
664
  triggerModule = await dynamicImport(moduleURL);
650
665
  }
651
666
  }
@@ -655,8 +670,8 @@ async function initializeRuntime(frb, serializedFunctionTrigger, extensionTrigge
655
670
  else {
656
671
  require("../deploy/functions/runtimes/node/extractTriggers")(triggerModule, parsedDefinitions);
657
672
  }
658
- const triggerDefinitions = functionsEmulatorShared_1.emulatedFunctionsByRegion(parsedDefinitions);
659
- const triggers = functionsEmulatorShared_1.getEmulatedTriggersFromDefinitions(triggerDefinitions, triggerModule);
673
+ const triggerDefinitions = (0, functionsEmulatorShared_1.emulatedFunctionsByRegion)(parsedDefinitions);
674
+ const triggers = (0, functionsEmulatorShared_1.getEmulatedTriggersFromDefinitions)(triggerDefinitions, triggerModule);
660
675
  new types_1.EmulatorLog("SYSTEM", "triggers-parsed", "", { triggers, triggerDefinitions }).log();
661
676
  return triggers;
662
677
  }
@@ -8,8 +8,9 @@ const utils = require("../utils");
8
8
  const logger_1 = require("../logger");
9
9
  const error_1 = require("../error");
10
10
  class FunctionsEmulatorShell {
11
- constructor(emu) {
11
+ constructor(emu, backend) {
12
12
  this.emu = emu;
13
+ this.backend = backend;
13
14
  this.urls = {};
14
15
  this.triggers = emu.getTriggerDefinitions();
15
16
  this.emulatedFunctions = this.triggers.map((t) => t.id);
@@ -42,7 +43,7 @@ class FunctionsEmulatorShell {
42
43
  auth: opts.auth,
43
44
  data,
44
45
  };
45
- this.emu.startFunctionRuntime(trigger.id, trigger.name, functionsEmulatorShared_1.getSignatureType(trigger), proto);
46
+ this.emu.startFunctionRuntime(this.backend, trigger.id, trigger.name, (0, functionsEmulatorShared_1.getSignatureType)(trigger), proto);
46
47
  }
47
48
  getTrigger(name) {
48
49
  const result = this.triggers.find((trigger) => {
@@ -43,7 +43,7 @@ class RuntimeWorker {
43
43
  execute(frb, opts) {
44
44
  const execFrb = Object.assign({}, frb);
45
45
  if (!execFrb.socketPath) {
46
- execFrb.socketPath = functionsEmulatorShared_1.getTemporarySocketPath(this.runtime.pid, execFrb.cwd);
46
+ execFrb.socketPath = (0, functionsEmulatorShared_1.getTemporarySocketPath)(this.runtime.pid, execFrb.cwd);
47
47
  this.log(`Assigning socketPath: ${execFrb.socketPath}`);
48
48
  }
49
49
  const args = { frb: execFrb, opts };
@@ -36,7 +36,7 @@ class HubExport {
36
36
  };
37
37
  if (shouldExport(types_1.Emulators.FIRESTORE)) {
38
38
  metadata.firestore = {
39
- version: downloadableEmulators_1.getDownloadDetails(types_1.Emulators.FIRESTORE).version,
39
+ version: (0, downloadableEmulators_1.getDownloadDetails)(types_1.Emulators.FIRESTORE).version,
40
40
  path: "firestore_export",
41
41
  metadata_file: "firestore_export/firestore_export.overall_export_metadata",
42
42
  };
@@ -44,7 +44,7 @@ class HubExport {
44
44
  }
45
45
  if (shouldExport(types_1.Emulators.DATABASE)) {
46
46
  metadata.database = {
47
- version: downloadableEmulators_1.getDownloadDetails(types_1.Emulators.DATABASE).version,
47
+ version: (0, downloadableEmulators_1.getDownloadDetails)(types_1.Emulators.DATABASE).version,
48
48
  path: "database_export",
49
49
  };
50
50
  await this.exportDatabase(metadata);
@@ -31,7 +31,7 @@ async function isPermitted(opts) {
31
31
  return !!permitted;
32
32
  }
33
33
  function createFirebaseEndpoints(emulator) {
34
- const firebaseStorageAPI = express_1.Router();
34
+ const firebaseStorageAPI = (0, express_1.Router)();
35
35
  const { storageLayer } = emulator;
36
36
  if (process.env.STORAGE_EMULATOR_DEBUG) {
37
37
  firebaseStorageAPI.use((req, res, next) => {
@@ -124,7 +124,7 @@ function createFirebaseEndpoints(emulator) {
124
124
  return;
125
125
  }
126
126
  if (isGZipped) {
127
- data = zlib_1.gunzipSync(data);
127
+ data = (0, zlib_1.gunzipSync)(data);
128
128
  }
129
129
  res.setHeader("Accept-Ranges", "bytes");
130
130
  res.setHeader("Content-Type", md.contentType);
@@ -8,7 +8,7 @@ const metadata_1 = require("../metadata");
8
8
  const registry_1 = require("../../registry");
9
9
  const emulatorLogger_1 = require("../../emulatorLogger");
10
10
  function createCloudEndpoints(emulator) {
11
- const gcloudStorageAPI = express_1.Router();
11
+ const gcloudStorageAPI = (0, express_1.Router)();
12
12
  const { storageLayer } = emulator;
13
13
  gcloudStorageAPI.use(/.*\/b\/(.+?)\/.*/, (req, res, next) => {
14
14
  storageLayer.createBucket(req.params[0]);
@@ -204,7 +204,7 @@ function sendFileBytes(md, storageLayer, req, res) {
204
204
  }
205
205
  const isGZipped = md.contentEncoding == "gzip";
206
206
  if (isGZipped) {
207
- data = zlib_1.gunzipSync(data);
207
+ data = (0, zlib_1.gunzipSync)(data);
208
208
  }
209
209
  res.setHeader("Accept-Ranges", "bytes");
210
210
  res.setHeader("Content-Type", md.contentType);
@@ -60,7 +60,7 @@ class StorageCloudFunctions {
60
60
  const timestamp = new Date();
61
61
  return {
62
62
  eventId: `${timestamp.getTime()}`,
63
- timestamp: metadata_1.toSerializedDate(timestamp),
63
+ timestamp: (0, metadata_1.toSerializedDate)(timestamp),
64
64
  eventType: `google.storage.object.${action}`,
65
65
  resource: {
66
66
  service: "storage.googleapis.com",