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.
- package/lib/api.js +1 -1
- package/lib/apiv2.js +2 -2
- package/lib/appdistribution/client.js +1 -1
- package/lib/appdistribution/options-parser-util.js +1 -1
- package/lib/auth.js +2 -2
- package/lib/command.js +26 -26
- package/lib/commands/appdistribution-distribute.js +4 -4
- package/lib/commands/appdistribution-testers-add.js +2 -2
- package/lib/commands/appdistribution-testers-remove.js +2 -2
- package/lib/commands/apps-android-sha-create.js +2 -2
- package/lib/commands/apps-android-sha-delete.js +2 -2
- package/lib/commands/apps-android-sha-list.js +2 -2
- package/lib/commands/apps-create.js +9 -9
- package/lib/commands/apps-list.js +3 -3
- package/lib/commands/apps-sdkconfig.js +8 -8
- package/lib/commands/database-get.js +1 -1
- package/lib/commands/database-instances-create.js +4 -4
- package/lib/commands/database-instances-list.js +4 -4
- package/lib/commands/database-profile.js +1 -1
- package/lib/commands/database-push.js +1 -1
- package/lib/commands/database-remove.js +4 -4
- package/lib/commands/database-set.js +4 -4
- package/lib/commands/database-settings-get.js +1 -1
- package/lib/commands/database-settings-set.js +1 -1
- package/lib/commands/database-update.js +4 -4
- package/lib/commands/ext-configure.js +2 -2
- package/lib/commands/ext-dev-deprecate.js +4 -4
- package/lib/commands/ext-dev-extension-delete.js +3 -3
- package/lib/commands/ext-dev-init.js +3 -3
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-publish.js +3 -3
- package/lib/commands/ext-dev-register.js +5 -5
- package/lib/commands/ext-dev-undeprecate.js +4 -4
- package/lib/commands/ext-dev-unpublish.js +3 -3
- package/lib/commands/ext-dev-usage.js +145 -0
- package/lib/commands/ext-export.js +8 -8
- package/lib/commands/ext-info.js +4 -4
- package/lib/commands/ext-install.js +26 -22
- package/lib/commands/ext-list.js +2 -2
- package/lib/commands/ext-sources-create.js +2 -2
- package/lib/commands/ext-uninstall.js +3 -3
- package/lib/commands/ext-update.js +17 -17
- package/lib/commands/ext.js +3 -3
- package/lib/commands/firestore-delete.js +3 -3
- package/lib/commands/functions-config-export.js +11 -11
- package/lib/commands/functions-delete.js +3 -3
- package/lib/commands/functions-deletegcfartifacts.js +4 -4
- package/lib/commands/functions-list.js +1 -1
- package/lib/commands/functions-log.js +1 -1
- package/lib/commands/hosting-channel-create.js +12 -12
- package/lib/commands/hosting-channel-delete.js +9 -9
- package/lib/commands/hosting-channel-deploy.js +17 -17
- package/lib/commands/hosting-channel-list.js +5 -5
- package/lib/commands/hosting-channel-open.js +9 -9
- package/lib/commands/hosting-clone.js +15 -15
- package/lib/commands/hosting-disable.js +4 -4
- package/lib/commands/hosting-sites-create.js +7 -7
- package/lib/commands/hosting-sites-delete.js +7 -7
- package/lib/commands/hosting-sites-get.js +2 -2
- package/lib/commands/hosting-sites-list.js +3 -3
- package/lib/commands/index.js +1 -0
- package/lib/commands/login.js +2 -2
- package/lib/commands/logout.js +1 -1
- package/lib/commands/open.js +1 -1
- package/lib/commands/projects-addfirebase.js +2 -2
- package/lib/commands/projects-create.js +2 -2
- package/lib/commands/projects-list.js +1 -1
- package/lib/commands/remoteconfig-get.js +3 -3
- package/lib/commands/remoteconfig-rollback.js +3 -3
- package/lib/commands/remoteconfig-versions-list.js +1 -1
- package/lib/commands/setup-emulators-storage.js +1 -1
- package/lib/config.js +6 -6
- package/lib/database/api.js +2 -2
- package/lib/deploy/extensions/deploy.js +4 -4
- package/lib/deploy/extensions/deploymentSummary.js +5 -4
- package/lib/deploy/extensions/index.js +1 -0
- package/lib/deploy/extensions/params.js +1 -1
- package/lib/deploy/extensions/planner.js +3 -3
- package/lib/deploy/extensions/prepare.js +9 -9
- package/lib/deploy/extensions/release.js +1 -1
- package/lib/deploy/extensions/secrets.js +7 -7
- package/lib/deploy/extensions/validate.js +2 -2
- package/lib/deploy/functions/backend.js +6 -4
- package/lib/deploy/functions/checkIam.js +7 -7
- package/lib/deploy/functions/containerCleaner.js +3 -3
- package/lib/deploy/functions/deploy.js +10 -11
- package/lib/deploy/functions/ensureCloudBuildEnabled.js +3 -3
- package/lib/deploy/functions/index.js +1 -0
- package/lib/deploy/functions/prepare.js +13 -13
- package/lib/deploy/functions/prompts.js +5 -5
- package/lib/deploy/functions/release/executor.js +4 -1
- package/lib/deploy/functions/release/fabricator.js +5 -5
- package/lib/deploy/functions/release/index.js +3 -3
- package/lib/deploy/functions/release/planner.js +6 -6
- package/lib/deploy/functions/release/reporter.js +8 -4
- package/lib/deploy/functions/runtimes/discovery/index.js +2 -2
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +14 -14
- package/lib/deploy/functions/runtimes/golang/index.js +6 -6
- package/lib/deploy/functions/runtimes/node/index.js +3 -3
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +1 -1
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +3 -3
- package/lib/deploy/functions/services/storage.js +1 -1
- package/lib/deploy/functions/triggerRegionHelper.js +1 -1
- package/lib/deploy/hosting/deploy.js +7 -7
- package/lib/deploy/hosting/uploader.js +1 -1
- package/lib/deploy/hosting/validate.js +3 -3
- package/lib/deploy/remoteconfig/prepare.js +3 -3
- package/lib/deploy/remoteconfig/release.js +3 -3
- package/lib/deploy/storage/deploy.js +1 -1
- package/lib/deploy/storage/release.js +2 -2
- package/lib/detectProjectRoot.js +5 -5
- package/lib/emulator/auth/apiSpec.js +13 -7
- package/lib/emulator/auth/handlers.js +3 -3
- package/lib/emulator/auth/index.js +1 -1
- package/lib/emulator/auth/operations.js +256 -248
- package/lib/emulator/auth/server.js +11 -8
- package/lib/emulator/auth/state.js +12 -12
- package/lib/emulator/auth/widget_ui.js +1 -1
- package/lib/emulator/commandUtils.js +5 -5
- package/lib/emulator/controller.js +16 -11
- package/lib/emulator/downloadableEmulators.js +7 -7
- package/lib/emulator/emulatorLogger.js +1 -1
- package/lib/emulator/functionsEmulator.js +101 -74
- package/lib/emulator/functionsEmulatorRuntime.js +33 -18
- package/lib/emulator/functionsEmulatorShell.js +3 -2
- package/lib/emulator/functionsRuntimeWorker.js +1 -1
- package/lib/emulator/hubExport.js +2 -2
- package/lib/emulator/storage/apis/firebase.js +2 -2
- package/lib/emulator/storage/apis/gcloud.js +2 -2
- package/lib/emulator/storage/cloudFunctions.js +1 -1
- package/lib/emulator/storage/files.js +14 -14
- package/lib/emulator/storage/index.js +2 -2
- package/lib/emulator/storage/metadata.js +7 -6
- package/lib/emulator/storage/rules/runtime.js +5 -5
- package/lib/emulator/storage/server.js +2 -2
- package/lib/ensureApiEnabled.js +7 -7
- package/lib/error.js +3 -3
- package/lib/extensions/askUserForConsent.js +2 -3
- package/lib/extensions/askUserForParam.js +10 -10
- package/lib/extensions/billingMigrationHelper.js +1 -1
- package/lib/extensions/changelog.js +3 -3
- package/lib/extensions/displayExtensionInfo.js +5 -5
- package/lib/extensions/emulator/optionsHelper.js +1 -1
- package/lib/extensions/emulator/specHelper.js +1 -1
- package/lib/extensions/emulator/triggerHelper.js +1 -1
- package/lib/extensions/export.js +6 -6
- package/lib/extensions/extensionsApi.js +14 -1
- package/lib/extensions/extensionsHelper.js +38 -29
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/localHelper.js +1 -1
- package/lib/extensions/metricsTypeDef.js +2 -0
- package/lib/extensions/metricsUtils.js +98 -0
- package/lib/extensions/paramHelper.js +6 -6
- package/lib/extensions/provisioningHelper.js +6 -4
- package/lib/extensions/resolveSource.js +1 -1
- package/lib/extensions/secretsUtils.js +3 -3
- package/lib/extensions/updateHelper.js +9 -9
- package/lib/extensions/utils.js +1 -1
- package/lib/extensions/warnings.js +10 -9
- package/lib/fetchWebSetup.js +2 -2
- package/lib/filterTargets.js +2 -2
- package/lib/firestore/indexes.js +2 -2
- package/lib/fsAsync.js +3 -3
- package/lib/fsutils.js +2 -2
- package/lib/functional.js +2 -1
- package/lib/functions/env.js +1 -1
- package/lib/functions/runtimeConfigExport.js +4 -4
- package/lib/functionsConfig.js +3 -3
- package/lib/functionsShellCommandAction.js +4 -3
- package/lib/gcp/cloudmonitoring.js +74 -0
- package/lib/gcp/cloudscheduler.js +1 -1
- package/lib/gcp/iam.js +2 -2
- package/lib/gcp/resourceManager.js +2 -2
- package/lib/gcp/secretManager.js +3 -2
- package/lib/getDefaultDatabaseInstance.js +1 -1
- package/lib/getDefaultHostingSite.js +1 -1
- package/lib/getProjectNumber.js +2 -2
- package/lib/handlePreviewToggles.js +5 -5
- package/lib/hosting/api.js +6 -6
- package/lib/hosting/cloudRunProxy.js +6 -6
- package/lib/hosting/functionsProxy.js +3 -3
- package/lib/hosting/implicitInit.js +2 -2
- package/lib/hosting/normalizedHostingConfigs.js +3 -3
- package/lib/hosting/proxy.js +2 -2
- package/lib/init/features/account.js +7 -7
- package/lib/init/features/database.js +9 -9
- package/lib/init/features/emulators.js +8 -8
- package/lib/init/features/firestore/index.js +3 -3
- package/lib/init/features/firestore/indexes.js +2 -2
- package/lib/init/features/firestore/rules.js +2 -2
- package/lib/init/features/functions/golang.js +4 -4
- package/lib/init/features/functions/index.js +4 -4
- package/lib/init/features/hosting/github.js +31 -31
- package/lib/init/features/project.js +8 -8
- package/lib/init/features/remoteconfig.js +2 -2
- package/lib/init/features/storage.js +2 -2
- package/lib/listFiles.js +1 -1
- package/lib/management/apps.js +3 -3
- package/lib/management/projects.js +6 -6
- package/lib/previews.js +2 -2
- package/lib/profiler.js +1 -1
- package/lib/projectPath.js +1 -1
- package/lib/projectUtils.js +1 -1
- package/lib/prompt.js +0 -1
- package/lib/rc.js +1 -1
- package/lib/requireAuth.js +2 -2
- package/lib/requireDatabaseInstance.js +1 -1
- package/lib/requireHostingSite.js +1 -1
- package/lib/requirePermissions.js +4 -4
- package/lib/rulesDeploy.js +2 -2
- package/lib/serve/functions.js +14 -7
- package/lib/serve/hosting.js +7 -7
- package/lib/utils.js +3 -2
- package/npm-shrinkwrap.json +24926 -0
- package/package.json +24 -24
- package/standalone/firepit.js +4 -4
- package/templates/init/functions/javascript/package.lint.json +1 -1
- package/templates/init/functions/javascript/package.nolint.json +1 -1
- package/templates/init/functions/typescript/package.lint.json +1 -1
- package/templates/init/functions/typescript/package.nolint.json +1 -1
- package/templates/init/hosting/index.html +1 -1
- 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:
|
|
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:
|
|
176
|
-
extensionTriggers:
|
|
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
|
-
|
|
184
|
+
for (const backend of this.args.emulatableBackends) {
|
|
185
|
+
backend.nodeBinary = this.getNodeBinary(backend);
|
|
186
|
+
}
|
|
183
187
|
const credentialEnv = await this.getCredentialsEnvironment();
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
-
|
|
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
|
|
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] = {
|
|
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:
|
|
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
|
-
|
|
480
|
-
const pkg = require(path.join(
|
|
481
|
-
if ((!pkg.engines || !pkg.engines.node) && !nodeMajorVersion) {
|
|
482
|
-
this.logger.log("WARN",
|
|
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(
|
|
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:
|
|
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() }),
|
|
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
|
-
|
|
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.
|
|
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 =
|
|
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
|
|
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
|
|
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.
|
|
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",
|