firebase-tools 11.4.1 → 11.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/accountImporter.js +1 -1
- package/lib/auth.js +3 -4
- package/lib/bin/firebase.js +4 -4
- package/lib/command.js +35 -10
- package/lib/commands/apps-android-sha-create.js +1 -1
- package/lib/commands/apps-android-sha-delete.js +1 -1
- package/lib/commands/apps-create.js +1 -1
- package/lib/commands/apps-list.js +1 -1
- package/lib/commands/auth-export.js +1 -1
- package/lib/commands/auth-import.js +1 -1
- package/lib/commands/database-instances-list.js +1 -1
- package/lib/commands/database-push.js +1 -1
- package/lib/commands/database-remove.js +1 -1
- package/lib/commands/database-set.js +1 -1
- package/lib/commands/database-update.js +1 -1
- package/lib/commands/emulators-exec.js +4 -1
- package/lib/commands/emulators-export.js +5 -2
- package/lib/commands/emulators-start.js +24 -18
- package/lib/commands/ext-dev-deprecate.js +1 -1
- package/lib/commands/ext-dev-emulators-exec.js +1 -1
- package/lib/commands/ext-dev-emulators-start.js +1 -1
- package/lib/commands/ext-dev-extension-delete.js +1 -1
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-publish.js +4 -1
- package/lib/commands/ext-dev-register.js +1 -1
- package/lib/commands/ext-dev-undeprecate.js +1 -1
- package/lib/commands/ext-dev-unpublish.js +1 -1
- package/lib/commands/ext-dev-usage.js +1 -1
- package/lib/commands/ext-info.js +1 -1
- package/lib/commands/ext-install.js +2 -2
- package/lib/commands/ext-update.js +1 -1
- package/lib/commands/ext.js +1 -1
- package/lib/commands/firestore-delete.js +2 -2
- package/lib/commands/firestore-indexes-list.js +3 -3
- package/lib/commands/functions-config-clone.js +1 -1
- package/lib/commands/functions-config-export.js +1 -1
- package/lib/commands/functions-config-set.js +1 -1
- package/lib/commands/functions-config-unset.js +1 -1
- package/lib/commands/functions-delete.js +1 -1
- package/lib/commands/functions-secrets-set.js +1 -1
- package/lib/commands/help.js +1 -1
- package/lib/commands/hosting-channel-create.js +5 -5
- package/lib/commands/hosting-channel-delete.js +3 -3
- package/lib/commands/hosting-channel-deploy.js +6 -6
- package/lib/commands/hosting-channel-list.js +2 -2
- package/lib/commands/hosting-channel-open.js +2 -2
- package/lib/commands/hosting-clone.js +8 -8
- package/lib/commands/hosting-disable.js +1 -1
- package/lib/commands/hosting-sites-create.js +4 -4
- package/lib/commands/hosting-sites-delete.js +4 -4
- package/lib/commands/hosting-sites-list.js +2 -2
- package/lib/commands/init.js +5 -5
- package/lib/commands/login-add.js +1 -1
- package/lib/commands/login-ci.js +2 -2
- package/lib/commands/login-list.js +1 -1
- package/lib/commands/login-use.js +1 -1
- package/lib/commands/login.js +3 -3
- package/lib/commands/logout.js +1 -1
- package/lib/commands/open.js +3 -3
- package/lib/commands/projects-list.js +2 -2
- package/lib/commands/serve.js +1 -1
- package/lib/commands/target-apply.js +1 -1
- package/lib/commands/target-clear.js +1 -1
- package/lib/commands/target-remove.js +1 -1
- package/lib/commands/target.js +1 -1
- package/lib/commands/use.js +7 -7
- package/lib/config.js +1 -1
- package/lib/deploy/database/prepare.js +3 -3
- package/lib/deploy/database/release.js +3 -3
- package/lib/deploy/extensions/deploymentSummary.js +1 -1
- package/lib/deploy/extensions/errors.js +1 -1
- package/lib/deploy/extensions/secrets.js +1 -1
- package/lib/deploy/extensions/tasks.js +2 -2
- package/lib/deploy/firestore/deploy.js +2 -2
- package/lib/deploy/firestore/prepare.js +2 -2
- package/lib/deploy/functions/backend.js +7 -5
- package/lib/deploy/functions/build.js +110 -95
- package/lib/deploy/functions/checkIam.js +3 -3
- package/lib/deploy/functions/containerCleaner.js +2 -2
- package/lib/deploy/functions/deploy.js +2 -2
- package/lib/deploy/functions/ensure.js +2 -2
- package/lib/deploy/functions/params.js +5 -2
- package/lib/deploy/functions/prepare.js +4 -4
- package/lib/deploy/functions/prepareFunctionsUpload.js +2 -2
- package/lib/deploy/functions/pricing.js +3 -2
- package/lib/deploy/functions/prompts.js +2 -2
- package/lib/deploy/functions/release/fabricator.js +10 -9
- package/lib/deploy/functions/release/index.js +1 -1
- package/lib/deploy/functions/release/reporter.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/parsing.js +19 -8
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +112 -107
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +1 -1
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +54 -26
- package/lib/deploy/functions/runtimes/node/versioning.js +4 -4
- package/lib/deploy/functions/services/storage.js +6 -0
- package/lib/deploy/functions/validate.js +1 -1
- package/lib/deploy/hosting/convertConfig.js +8 -1
- package/lib/deploy/hosting/deploy.js +10 -9
- package/lib/deploy/hosting/uploader.js +2 -2
- package/lib/deploy/hosting/validate.js +2 -2
- package/lib/deploy/index.js +7 -7
- package/lib/deploy/lifecycleHooks.js +5 -2
- package/lib/deploy/storage/prepare.js +5 -3
- package/lib/deploy/storage/release.js +7 -6
- package/lib/emulator/auth/index.js +7 -2
- package/lib/emulator/auth/operations.js +10 -10
- package/lib/emulator/commandUtils.js +33 -16
- package/lib/emulator/constants.js +14 -6
- package/lib/emulator/controller.js +55 -18
- package/lib/emulator/databaseEmulator.js +1 -1
- package/lib/emulator/downloadableEmulators.js +8 -8
- package/lib/emulator/emulatorLogger.js +1 -1
- package/lib/emulator/eventarcEmulator.js +148 -0
- package/lib/emulator/extensionsEmulator.js +5 -3
- package/lib/emulator/firestoreEmulator.js +1 -1
- package/lib/emulator/functionsEmulator.js +66 -14
- package/lib/emulator/functionsEmulatorShared.js +12 -12
- package/lib/emulator/hub.js +7 -3
- package/lib/emulator/hubClient.js +2 -2
- package/lib/emulator/hubExport.js +22 -2
- package/lib/emulator/loggingEmulator.js +2 -2
- package/lib/emulator/registry.js +1 -0
- package/lib/emulator/storage/apis/firebase.js +13 -1
- package/lib/emulator/storage/apis/gcloud.js +15 -8
- package/lib/emulator/storage/files.js +25 -4
- package/lib/emulator/storage/metadata.js +6 -6
- package/lib/emulator/storage/multipart.js +4 -3
- package/lib/emulator/storage/rules/runtime.js +3 -3
- package/lib/emulator/storage/rules/utils.js +4 -2
- package/lib/emulator/storage/server.js +2 -1
- package/lib/emulator/storage/upload.js +1 -0
- package/lib/emulator/types.js +4 -0
- package/lib/emulator/ui.js +7 -2
- package/lib/ensureApiEnabled.js +7 -7
- package/lib/extensions/askUserForConsent.js +1 -1
- package/lib/extensions/askUserForEventsConfig.js +1 -1
- package/lib/extensions/askUserForParam.js +1 -1
- package/lib/extensions/changelog.js +2 -2
- package/lib/extensions/checkProjectBilling.js +2 -2
- package/lib/extensions/displayExtensionInfo.js +2 -102
- package/lib/extensions/emulator/triggerHelper.js +2 -2
- package/lib/extensions/extensionsApi.js +3 -2
- package/lib/extensions/extensionsHelper.js +30 -2
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/manifest.js +1 -1
- package/lib/extensions/metricsUtils.js +1 -1
- package/lib/extensions/paramHelper.js +1 -1
- package/lib/extensions/updateHelper.js +3 -9
- package/lib/extensions/warnings.js +2 -2
- package/lib/fetchMOTD.js +1 -1
- package/lib/firestore/delete.js +1 -1
- package/lib/firestore/indexes.js +2 -2
- package/lib/firestore/validator.js +1 -1
- package/lib/functional.js +16 -1
- package/lib/functions/env.js +3 -3
- package/lib/functions/runtimeConfigExport.js +1 -1
- package/lib/functionsConfig.js +1 -1
- package/lib/functionsConfigClone.js +1 -1
- package/lib/functionsShellCommandAction.js +1 -1
- package/lib/gcp/cloudfunctions.js +24 -11
- package/lib/gcp/cloudfunctionsv2.js +48 -24
- package/lib/gcp/cloudscheduler.js +58 -22
- package/lib/gcp/cloudtasks.js +21 -4
- package/lib/gcp/proto.js +18 -6
- package/lib/gcp/resourceManager.js +25 -3
- package/lib/gcp/serviceusage.js +2 -2
- package/lib/handlePreviewToggles.js +4 -4
- package/lib/hosting/implicitInit.js +1 -1
- package/lib/hosting/normalizedHostingConfigs.js +3 -3
- package/lib/index.js +2 -2
- package/lib/init/features/database.js +1 -1
- package/lib/init/features/emulators.js +1 -1
- package/lib/init/features/firestore/index.js +2 -2
- package/lib/init/features/firestore/indexes.js +1 -1
- package/lib/init/features/firestore/rules.js +1 -1
- package/lib/init/features/functions/golang.js +1 -1
- package/lib/init/features/functions/index.js +8 -1
- package/lib/init/features/hosting/github.js +9 -9
- package/lib/init/features/hosting/index.js +1 -1
- package/lib/init/features/project.js +1 -1
- package/lib/init/features/remoteconfig.js +1 -1
- package/lib/init/features/storage.js +1 -1
- package/lib/init/index.js +1 -1
- package/lib/logError.js +3 -3
- package/lib/management/projects.js +1 -1
- package/lib/parseBoltRules.js +1 -1
- package/lib/previews.js +1 -1
- package/lib/profileReport.js +2 -2
- package/lib/projectUtils.js +1 -1
- package/lib/rc.js +1 -1
- package/lib/requireAuth.js +1 -1
- package/lib/requireDatabaseInstance.js +2 -2
- package/lib/requirePermissions.js +2 -2
- package/lib/rulesDeploy.js +49 -13
- package/lib/serve/hosting.js +2 -1
- package/lib/serve/index.js +15 -0
- package/lib/track.js +119 -3
- package/lib/utils.js +24 -11
- package/npm-shrinkwrap.json +14 -294
- package/package.json +5 -4
- package/schema/firebase-config.json +12 -0
- package/templates/extensions/CHANGELOG.md +1 -7
- package/templates/hosting/init.js +6 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.exportEmulatorData = exports.startAll = exports.shouldStart = exports.filterEmulatorTargets = exports.cleanShutdown = exports.onExit = exports.exportOnExit =
|
|
4
|
-
const clc = require("
|
|
3
|
+
exports.exportEmulatorData = exports.startAll = exports.shouldStart = exports.filterEmulatorTargets = exports.cleanShutdown = exports.onExit = exports.exportOnExit = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const logger_1 = require("../logger");
|
|
@@ -16,6 +16,7 @@ const auth_1 = require("./auth");
|
|
|
16
16
|
const databaseEmulator_1 = require("./databaseEmulator");
|
|
17
17
|
const firestoreEmulator_1 = require("./firestoreEmulator");
|
|
18
18
|
const hostingEmulator_1 = require("./hostingEmulator");
|
|
19
|
+
const eventarcEmulator_1 = require("./eventarcEmulator");
|
|
19
20
|
const error_1 = require("../error");
|
|
20
21
|
const projectUtils_1 = require("../projectUtils");
|
|
21
22
|
const pubsubEmulator_1 = require("./pubsubEmulator");
|
|
@@ -93,19 +94,13 @@ async function getAndCheckAddress(emulator, options) {
|
|
|
93
94
|
}
|
|
94
95
|
return { host, port };
|
|
95
96
|
}
|
|
96
|
-
async function startEmulator(instance) {
|
|
97
|
-
const name = instance.getName();
|
|
98
|
-
void (0, track_1.track)("Emulator Run", name);
|
|
99
|
-
await registry_1.EmulatorRegistry.start(instance);
|
|
100
|
-
}
|
|
101
|
-
exports.startEmulator = startEmulator;
|
|
102
97
|
async function exportOnExit(options) {
|
|
103
98
|
const exportOnExitDir = options.exportOnExit;
|
|
104
99
|
if (exportOnExitDir) {
|
|
105
100
|
try {
|
|
106
101
|
utils.logBullet(`Automatically exporting data using ${commandUtils_1.FLAG_EXPORT_ON_EXIT_NAME} "${exportOnExitDir}" ` +
|
|
107
102
|
"please wait for the export to finish...");
|
|
108
|
-
await exportEmulatorData(exportOnExitDir, options);
|
|
103
|
+
await exportEmulatorData(exportOnExitDir, options, "exit");
|
|
109
104
|
}
|
|
110
105
|
catch (e) {
|
|
111
106
|
utils.logWarning(e);
|
|
@@ -215,9 +210,8 @@ async function startAll(options, showUI = true) {
|
|
|
215
210
|
if (targets.length === 0) {
|
|
216
211
|
throw new error_1.FirebaseError(`No emulators to start, run ${clc.bold("firebase init emulators")} to get started.`);
|
|
217
212
|
}
|
|
218
|
-
const deprecationNotices = [];
|
|
219
213
|
if (targets.some(downloadableEmulators_1.requiresJava)) {
|
|
220
|
-
if (
|
|
214
|
+
if ((await commandUtils.checkJavaMajorVersion()) < commandUtils_1.MIN_SUPPORTED_JAVA_MAJOR_VERSION) {
|
|
221
215
|
utils.logLabeledError("emulators", commandUtils_1.JAVA_DEPRECATION_WARNING, "warn");
|
|
222
216
|
throw new error_1.FirebaseError(commandUtils_1.JAVA_DEPRECATION_WARNING);
|
|
223
217
|
}
|
|
@@ -225,7 +219,8 @@ async function startAll(options, showUI = true) {
|
|
|
225
219
|
const hubLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.HUB);
|
|
226
220
|
hubLogger.logLabeled("BULLET", "emulators", `Starting emulators: ${targets.join(", ")}`);
|
|
227
221
|
const projectId = (0, projectUtils_1.getProjectId)(options) || "";
|
|
228
|
-
|
|
222
|
+
const isDemoProject = constants_1.Constants.isDemoProject(projectId);
|
|
223
|
+
if (isDemoProject) {
|
|
229
224
|
hubLogger.logLabeled("BULLET", "emulators", `Detected demo project ID "${projectId}", emulated services will use a demo configuration and attempts to access non-emulated services for this project will fail.`);
|
|
230
225
|
}
|
|
231
226
|
const onlyOptions = options.only;
|
|
@@ -249,6 +244,15 @@ async function startAll(options, showUI = true) {
|
|
|
249
244
|
await (0, frameworks_1.prepareFrameworks)(targets, options, options);
|
|
250
245
|
}
|
|
251
246
|
}
|
|
247
|
+
function startEmulator(instance) {
|
|
248
|
+
const name = instance.getName();
|
|
249
|
+
void (0, track_1.track)("Emulator Run", name);
|
|
250
|
+
void (0, track_1.trackEmulator)("emulator_run", {
|
|
251
|
+
emulator_name: name,
|
|
252
|
+
is_demo_project: String(isDemoProject),
|
|
253
|
+
});
|
|
254
|
+
return registry_1.EmulatorRegistry.start(instance);
|
|
255
|
+
}
|
|
252
256
|
if (shouldStart(options, types_1.Emulators.HUB)) {
|
|
253
257
|
const hubAddr = await getAndCheckAddress(types_1.Emulators.HUB, options);
|
|
254
258
|
const hub = new hub_1.EmulatorHub(Object.assign({ projectId }, hubAddr));
|
|
@@ -264,6 +268,10 @@ async function startAll(options, showUI = true) {
|
|
|
264
268
|
const foundMetadata = findExportMetadata(importDir);
|
|
265
269
|
if (foundMetadata) {
|
|
266
270
|
exportMetadata = foundMetadata;
|
|
271
|
+
void (0, track_1.trackEmulator)("emulator_import", {
|
|
272
|
+
initiated_by: "start",
|
|
273
|
+
emulator_name: types_1.Emulators.HUB,
|
|
274
|
+
});
|
|
267
275
|
}
|
|
268
276
|
else {
|
|
269
277
|
hubLogger.logLabeled("WARN", "emulators", `Could not find import/export metadata file, ${clc.bold("skipping data import!")}`);
|
|
@@ -287,7 +295,7 @@ async function startAll(options, showUI = true) {
|
|
|
287
295
|
}
|
|
288
296
|
}
|
|
289
297
|
if (shouldStart(options, types_1.Emulators.EXTENSIONS)) {
|
|
290
|
-
const projectNumber =
|
|
298
|
+
const projectNumber = isDemoProject
|
|
291
299
|
? constants_1.Constants.FAKE_PROJECT_NUMBER
|
|
292
300
|
: await (0, projectUtils_1.needProjectNumber)(options);
|
|
293
301
|
const aliases = (0, projectUtils_1.getAliases)(options, projectId);
|
|
@@ -331,6 +339,17 @@ async function startAll(options, showUI = true) {
|
|
|
331
339
|
});
|
|
332
340
|
await startEmulator(functionsEmulator);
|
|
333
341
|
}
|
|
342
|
+
if (!shouldStart(options, types_1.Emulators.EVENTARC)) {
|
|
343
|
+
if (options.config.src.emulators) {
|
|
344
|
+
options.config.src.emulators.eventarc = { host: constants_1.DEFAULT_HOST, port: constants_1.DEFAULT_PORTS.eventarc };
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
const eventarcAddr = await getAndCheckAddress(types_1.Emulators.EVENTARC, options);
|
|
348
|
+
const eventarcEmulator = new eventarcEmulator_1.EventarcEmulator({
|
|
349
|
+
host: eventarcAddr.host,
|
|
350
|
+
port: eventarcAddr.port,
|
|
351
|
+
});
|
|
352
|
+
await startEmulator(eventarcEmulator);
|
|
334
353
|
if (shouldStart(options, types_1.Emulators.FIRESTORE)) {
|
|
335
354
|
const firestoreLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.FIRESTORE);
|
|
336
355
|
const firestoreAddr = await getAndCheckAddress(types_1.Emulators.FIRESTORE, options);
|
|
@@ -346,6 +365,10 @@ async function startAll(options, showUI = true) {
|
|
|
346
365
|
const exportMetadataFilePath = path.resolve(importDirAbsPath, exportMetadata.firestore.metadata_file);
|
|
347
366
|
firestoreLogger.logLabeled("BULLET", "firestore", `Importing data from ${exportMetadataFilePath}`);
|
|
348
367
|
args.seed_from_export = exportMetadataFilePath;
|
|
368
|
+
void (0, track_1.trackEmulator)("emulator_import", {
|
|
369
|
+
initiated_by: "start",
|
|
370
|
+
emulator_name: types_1.Emulators.FIRESTORE,
|
|
371
|
+
});
|
|
349
372
|
}
|
|
350
373
|
const config = options.config;
|
|
351
374
|
const rulesLocalPath = (_a = config.src.firestore) === null || _a === void 0 ? void 0 : _a.rules;
|
|
@@ -407,6 +430,11 @@ async function startAll(options, showUI = true) {
|
|
|
407
430
|
const importDirAbsPath = path.resolve(options.import);
|
|
408
431
|
const databaseExportDir = path.resolve(importDirAbsPath, exportMetadata.database.path);
|
|
409
432
|
const files = fs.readdirSync(databaseExportDir).filter((f) => f.endsWith(".json"));
|
|
433
|
+
void (0, track_1.trackEmulator)("emulator_import", {
|
|
434
|
+
initiated_by: "start",
|
|
435
|
+
emulator_name: types_1.Emulators.DATABASE,
|
|
436
|
+
count: files.length,
|
|
437
|
+
});
|
|
410
438
|
for (const f of files) {
|
|
411
439
|
const fPath = path.join(databaseExportDir, f);
|
|
412
440
|
const ns = path.basename(f, ".json");
|
|
@@ -429,7 +457,7 @@ async function startAll(options, showUI = true) {
|
|
|
429
457
|
utils.assertIsString(options.import);
|
|
430
458
|
const importDirAbsPath = path.resolve(options.import);
|
|
431
459
|
const authExportDir = path.resolve(importDirAbsPath, exportMetadata.auth.path);
|
|
432
|
-
await authEmulator.importData(authExportDir, projectId);
|
|
460
|
+
await authEmulator.importData(authExportDir, projectId, { initiatedBy: "start" });
|
|
433
461
|
}
|
|
434
462
|
}
|
|
435
463
|
if (shouldStart(options, types_1.Emulators.PUBSUB)) {
|
|
@@ -458,7 +486,7 @@ async function startAll(options, showUI = true) {
|
|
|
458
486
|
utils.assertIsString(options.import);
|
|
459
487
|
const importDirAbsPath = path.resolve(options.import);
|
|
460
488
|
const storageExportDir = path.resolve(importDirAbsPath, exportMetadata.storage.path);
|
|
461
|
-
storageEmulator.storageLayer.import(storageExportDir);
|
|
489
|
+
storageEmulator.storageLayer.import(storageExportDir, { initiatedBy: "start" });
|
|
462
490
|
}
|
|
463
491
|
}
|
|
464
492
|
if (shouldStart(options, types_1.Emulators.HOSTING)) {
|
|
@@ -488,17 +516,26 @@ async function startAll(options, showUI = true) {
|
|
|
488
516
|
const ui = new ui_1.EmulatorUI(Object.assign({ projectId: projectId, auto_download: true }, uiAddr));
|
|
489
517
|
await startEmulator(ui);
|
|
490
518
|
}
|
|
519
|
+
let serviceEmulatorCount = 0;
|
|
491
520
|
const running = registry_1.EmulatorRegistry.listRunning();
|
|
492
521
|
for (const name of running) {
|
|
493
522
|
const instance = registry_1.EmulatorRegistry.get(name);
|
|
494
523
|
if (instance) {
|
|
495
524
|
await instance.connect();
|
|
496
525
|
}
|
|
526
|
+
if (types_1.ALL_SERVICE_EMULATORS.includes(name)) {
|
|
527
|
+
serviceEmulatorCount++;
|
|
528
|
+
}
|
|
497
529
|
}
|
|
498
|
-
|
|
530
|
+
void (0, track_1.trackEmulator)("emulators_started", {
|
|
531
|
+
count: serviceEmulatorCount,
|
|
532
|
+
count_all: running.length,
|
|
533
|
+
is_demo_project: String(isDemoProject),
|
|
534
|
+
});
|
|
535
|
+
return { deprecationNotices: [] };
|
|
499
536
|
}
|
|
500
537
|
exports.startAll = startAll;
|
|
501
|
-
async function exportEmulatorData(exportPath, options) {
|
|
538
|
+
async function exportEmulatorData(exportPath, options, initiatedBy) {
|
|
502
539
|
const projectId = options.project;
|
|
503
540
|
if (!projectId) {
|
|
504
541
|
throw new error_1.FirebaseError("Could not determine project ID, make sure you're running in a Firebase project directory or add the --project flag.", { exit: 1 });
|
|
@@ -536,7 +573,7 @@ async function exportEmulatorData(exportPath, options) {
|
|
|
536
573
|
}
|
|
537
574
|
utils.logBullet(`Exporting data to: ${exportAbsPath}`);
|
|
538
575
|
try {
|
|
539
|
-
await hubClient.postExport(exportAbsPath);
|
|
576
|
+
await hubClient.postExport({ path: exportAbsPath, initiatedBy });
|
|
540
577
|
}
|
|
541
578
|
catch (e) {
|
|
542
579
|
throw new error_1.FirebaseError("Export request failed, see emulator logs for more information.", {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DatabaseEmulator = void 0;
|
|
4
4
|
const chokidar = require("chokidar");
|
|
5
|
-
const clc = require("
|
|
5
|
+
const clc = require("colorette");
|
|
6
6
|
const fs = require("fs");
|
|
7
7
|
const path = require("path");
|
|
8
8
|
const http = require("http");
|
|
@@ -7,7 +7,7 @@ const error_1 = require("../error");
|
|
|
7
7
|
const childProcess = require("child_process");
|
|
8
8
|
const utils = require("../utils");
|
|
9
9
|
const emulatorLogger_1 = require("./emulatorLogger");
|
|
10
|
-
const clc = require("
|
|
10
|
+
const clc = require("colorette");
|
|
11
11
|
const fs = require("fs-extra");
|
|
12
12
|
const path = require("path");
|
|
13
13
|
const os = require("os");
|
|
@@ -67,15 +67,15 @@ exports.DownloadDetails = {
|
|
|
67
67
|
},
|
|
68
68
|
}
|
|
69
69
|
: {
|
|
70
|
-
version: "1.
|
|
71
|
-
downloadPath: path.join(CACHE_DIR, "ui-v1.
|
|
72
|
-
unzipDir: path.join(CACHE_DIR, "ui-v1.
|
|
73
|
-
binaryPath: path.join(CACHE_DIR, "ui-v1.
|
|
70
|
+
version: "1.9.0",
|
|
71
|
+
downloadPath: path.join(CACHE_DIR, "ui-v1.9.0.zip"),
|
|
72
|
+
unzipDir: path.join(CACHE_DIR, "ui-v1.9.0"),
|
|
73
|
+
binaryPath: path.join(CACHE_DIR, "ui-v1.9.0", "server", "server.js"),
|
|
74
74
|
opts: {
|
|
75
75
|
cacheDir: CACHE_DIR,
|
|
76
|
-
remoteUrl: "https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.
|
|
77
|
-
expectedSize:
|
|
78
|
-
expectedChecksum: "
|
|
76
|
+
remoteUrl: "https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.9.0.zip",
|
|
77
|
+
expectedSize: 3062710,
|
|
78
|
+
expectedChecksum: "984597f41d497bd318dac131615eb9d5",
|
|
79
79
|
namePrefix: "ui",
|
|
80
80
|
},
|
|
81
81
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EmulatorLogger = exports.Verbosity = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const utils = require("../utils");
|
|
6
6
|
const logger_1 = require("../logger");
|
|
7
7
|
const utils_1 = require("../utils");
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventarcEmulator = void 0;
|
|
4
|
+
const express = require("express");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const types_1 = require("./types");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const emulatorLogger_1 = require("./emulatorLogger");
|
|
9
|
+
const registry_1 = require("./registry");
|
|
10
|
+
const apiv2_1 = require("../apiv2");
|
|
11
|
+
const error_1 = require("../error");
|
|
12
|
+
class EventarcEmulator {
|
|
13
|
+
constructor(args) {
|
|
14
|
+
this.args = args;
|
|
15
|
+
this.logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.EVENTARC);
|
|
16
|
+
this.customEvents = {};
|
|
17
|
+
}
|
|
18
|
+
createHubServer() {
|
|
19
|
+
const registerTriggerRoute = `/emulator/v1/projects/:project_id/triggers/:trigger_name(*)`;
|
|
20
|
+
const registerTriggerHandler = (req, res) => {
|
|
21
|
+
const projectId = req.params.project_id;
|
|
22
|
+
const triggerName = req.params.trigger_name;
|
|
23
|
+
if (!projectId || !triggerName) {
|
|
24
|
+
const error = "Missing project ID or trigger name.";
|
|
25
|
+
this.logger.log("ERROR", error);
|
|
26
|
+
res.status(400).send({ error });
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const bodyString = req.rawBody.toString();
|
|
30
|
+
const substituted = bodyString.replaceAll("${PROJECT_ID}", projectId);
|
|
31
|
+
const body = JSON.parse(substituted);
|
|
32
|
+
const eventTrigger = body.eventTrigger;
|
|
33
|
+
if (!eventTrigger) {
|
|
34
|
+
const error = `Missing event trigger for ${triggerName}.`;
|
|
35
|
+
this.logger.log("ERROR", error);
|
|
36
|
+
res.status(400).send({ error });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const key = `${eventTrigger.eventType}-${eventTrigger.channel}`;
|
|
40
|
+
this.logger.logLabeled("BULLET", "eventarc", `Registering custom event trigger for ${key} with trigger name ${triggerName}.`);
|
|
41
|
+
const customEventTriggers = this.customEvents[key] || [];
|
|
42
|
+
customEventTriggers.push({ projectId, triggerName, eventTrigger });
|
|
43
|
+
this.customEvents[key] = customEventTriggers;
|
|
44
|
+
res.status(200).send({ res: "OK" });
|
|
45
|
+
};
|
|
46
|
+
const publishEventsRoute = `/projects/:project_id/locations/:location/channels/:channel::publishEvents`;
|
|
47
|
+
const publishEventsHandler = (req, res) => {
|
|
48
|
+
const channel = `projects/${req.params.project_id}/locations/${req.params.location}/channels/${req.params.channel}`;
|
|
49
|
+
const body = JSON.parse(req.rawBody.toString());
|
|
50
|
+
for (const event of body.events) {
|
|
51
|
+
if (!event.type) {
|
|
52
|
+
res.sendStatus(400);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.logger.log("INFO", `Received custom event at channel ${channel}: ${JSON.stringify(event, null, 2)}`);
|
|
56
|
+
this.triggerCustomEventFunction(channel, event);
|
|
57
|
+
}
|
|
58
|
+
res.sendStatus(200);
|
|
59
|
+
};
|
|
60
|
+
const dataMiddleware = (req, _, next) => {
|
|
61
|
+
const chunks = [];
|
|
62
|
+
req.on("data", (chunk) => {
|
|
63
|
+
chunks.push(chunk);
|
|
64
|
+
});
|
|
65
|
+
req.on("end", () => {
|
|
66
|
+
req.rawBody = Buffer.concat(chunks);
|
|
67
|
+
next();
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const hub = express();
|
|
71
|
+
hub.post([registerTriggerRoute], dataMiddleware, registerTriggerHandler);
|
|
72
|
+
hub.post([publishEventsRoute], dataMiddleware, publishEventsHandler);
|
|
73
|
+
hub.all("*", (req, res) => {
|
|
74
|
+
this.logger.log("DEBUG", `Eventarc emulator received unknown request at path ${req.path}`);
|
|
75
|
+
res.sendStatus(404);
|
|
76
|
+
});
|
|
77
|
+
return hub;
|
|
78
|
+
}
|
|
79
|
+
async triggerCustomEventFunction(channel, event) {
|
|
80
|
+
const functionsEmulator = registry_1.EmulatorRegistry.get(types_1.Emulators.FUNCTIONS);
|
|
81
|
+
if (!functionsEmulator) {
|
|
82
|
+
this.logger.log("INFO", "Functions emulator not found. This should not happen.");
|
|
83
|
+
return Promise.reject();
|
|
84
|
+
}
|
|
85
|
+
const key = `${event.type}-${channel}`;
|
|
86
|
+
const triggers = this.customEvents[key] || [];
|
|
87
|
+
const apiClient = new apiv2_1.Client({
|
|
88
|
+
urlPrefix: `http://${registry_1.EmulatorRegistry.getInfoHostString(functionsEmulator.getInfo())}`,
|
|
89
|
+
auth: false,
|
|
90
|
+
});
|
|
91
|
+
return await Promise.all(triggers
|
|
92
|
+
.filter((trigger) => !trigger.eventTrigger.eventFilters ||
|
|
93
|
+
this.matchesAll(event, trigger.eventTrigger.eventFilters))
|
|
94
|
+
.map((trigger) => apiClient
|
|
95
|
+
.request({
|
|
96
|
+
method: "POST",
|
|
97
|
+
path: `/functions/projects/${trigger.projectId}/triggers/${trigger.triggerName}`,
|
|
98
|
+
body: JSON.stringify(event),
|
|
99
|
+
responseType: "stream",
|
|
100
|
+
resolveOnHTTPError: true,
|
|
101
|
+
})
|
|
102
|
+
.then((res) => {
|
|
103
|
+
if (res.status >= 400) {
|
|
104
|
+
throw new error_1.FirebaseError(`Received non-200 status code: ${res.status}`);
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
.catch((err) => {
|
|
108
|
+
this.logger.log("ERROR", `Failed to trigger Functions emulator for ${trigger.triggerName}: ${err}`);
|
|
109
|
+
})));
|
|
110
|
+
}
|
|
111
|
+
matchesAll(event, eventFilters) {
|
|
112
|
+
return Object.entries(eventFilters).every(([key, value]) => {
|
|
113
|
+
var _a, _b;
|
|
114
|
+
let attr = (_a = event[key]) !== null && _a !== void 0 ? _a : event.attributes[key];
|
|
115
|
+
if (typeof attr === "object" && !Array.isArray(attr)) {
|
|
116
|
+
attr = (_b = attr.ceTimestamp) !== null && _b !== void 0 ? _b : attr.ceString;
|
|
117
|
+
}
|
|
118
|
+
return attr === value;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
async start() {
|
|
122
|
+
const { host, port } = this.getInfo();
|
|
123
|
+
const server = this.createHubServer().listen(port, host);
|
|
124
|
+
this.destroyServer = (0, utils_1.createDestroyer)(server);
|
|
125
|
+
return Promise.resolve();
|
|
126
|
+
}
|
|
127
|
+
async connect() {
|
|
128
|
+
return Promise.resolve();
|
|
129
|
+
}
|
|
130
|
+
async stop() {
|
|
131
|
+
if (this.destroyServer) {
|
|
132
|
+
await this.destroyServer();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
getInfo() {
|
|
136
|
+
const host = this.args.host || constants_1.Constants.getDefaultHost();
|
|
137
|
+
const port = this.args.port || constants_1.Constants.getDefaultPort(types_1.Emulators.EVENTARC);
|
|
138
|
+
return {
|
|
139
|
+
name: this.getName(),
|
|
140
|
+
host,
|
|
141
|
+
port,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
getName() {
|
|
145
|
+
return types_1.Emulators.EVENTARC;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.EventarcEmulator = EventarcEmulator;
|
|
@@ -4,7 +4,7 @@ exports.ExtensionsEmulator = void 0;
|
|
|
4
4
|
const fs = require("fs-extra");
|
|
5
5
|
const os = require("os");
|
|
6
6
|
const path = require("path");
|
|
7
|
-
const clc = require("
|
|
7
|
+
const clc = require("colorette");
|
|
8
8
|
const Table = require("cli-table");
|
|
9
9
|
const spawn = require("cross-spawn");
|
|
10
10
|
const planner = require("../deploy/extensions/planner");
|
|
@@ -103,10 +103,11 @@ class ExtensionsEmulator {
|
|
|
103
103
|
for (const requiredFile of requiredFiles) {
|
|
104
104
|
const f = path.join(args.path, requiredFile);
|
|
105
105
|
if (!fs.existsSync(f)) {
|
|
106
|
-
|
|
106
|
+
this.logger.logLabeled("BULLET", "extensions", `Detected invalid source code for ${args.extTarget}, expected to find ${f}`);
|
|
107
107
|
return false;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
+
this.logger.logLabeled("DEBUG", "extensions", `Source code valid for ${args.extTarget}`);
|
|
110
111
|
return true;
|
|
111
112
|
}
|
|
112
113
|
installAndBuildSourceCode(sourceCodePath) {
|
|
@@ -166,6 +167,7 @@ class ExtensionsEmulator {
|
|
|
166
167
|
STORAGE_BUCKET: `${projectId}.appspot.com`,
|
|
167
168
|
ALLOWED_EVENT_TYPES: instance.allowedEventTypes ? instance.allowedEventTypes.join(",") : "",
|
|
168
169
|
EVENTARC_CHANNEL: (_a = instance.eventarcChannel) !== null && _a !== void 0 ? _a : "",
|
|
170
|
+
EVENTARC_CLOUD_EVENT_SOURCE: `projects/${projectId}/instances/${instance.instanceId}`,
|
|
169
171
|
};
|
|
170
172
|
}
|
|
171
173
|
async checkAndWarnAPIs(instances) {
|
|
@@ -186,7 +188,7 @@ class ExtensionsEmulator {
|
|
|
186
188
|
apiToWarn.apiName,
|
|
187
189
|
apiToWarn.instanceIds,
|
|
188
190
|
apiToWarn.enabled ? "Yes" : "No",
|
|
189
|
-
apiToWarn.enabled ? "" : clc.bold.underline(enablementUri),
|
|
191
|
+
apiToWarn.enabled ? "" : clc.bold(clc.underline(enablementUri)),
|
|
190
192
|
]);
|
|
191
193
|
}
|
|
192
194
|
if (constants_1.Constants.isDemoProject(this.args.projectId)) {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FirestoreEmulator = void 0;
|
|
4
4
|
const chokidar = require("chokidar");
|
|
5
5
|
const fs = require("fs");
|
|
6
|
-
const clc = require("
|
|
6
|
+
const clc = require("colorette");
|
|
7
7
|
const path = require("path");
|
|
8
8
|
const utils = require("../utils");
|
|
9
9
|
const downloadableEmulators = require("./downloadableEmulators");
|
|
@@ -4,7 +4,7 @@ exports.FunctionsEmulator = void 0;
|
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const express = require("express");
|
|
7
|
-
const clc = require("
|
|
7
|
+
const clc = require("colorette");
|
|
8
8
|
const http = require("http");
|
|
9
9
|
const jwt = require("jsonwebtoken");
|
|
10
10
|
const cors = require("cors");
|
|
@@ -35,6 +35,7 @@ const v1_1 = require("../functions/events/v1");
|
|
|
35
35
|
const apiv2_1 = require("../apiv2");
|
|
36
36
|
const build_1 = require("../deploy/functions/build");
|
|
37
37
|
const EVENT_INVOKE = "functions:invoke";
|
|
38
|
+
const EVENT_INVOKE_GA4 = "functions_invoke";
|
|
38
39
|
const DATABASE_PATH_PATTERN = new RegExp("^projects/[^/]+/instances/([^/]+)/refs(/.*)$");
|
|
39
40
|
class FunctionsEmulator {
|
|
40
41
|
constructor(args) {
|
|
@@ -89,7 +90,7 @@ class FunctionsEmulator {
|
|
|
89
90
|
next();
|
|
90
91
|
});
|
|
91
92
|
};
|
|
92
|
-
const backgroundFunctionRoute = `/functions/projects/:project_id/triggers/:trigger_name`;
|
|
93
|
+
const backgroundFunctionRoute = `/functions/projects/:project_id/triggers/:trigger_name(*)`;
|
|
93
94
|
const httpsFunctionRoute = `/${this.args.projectId}/:region/:trigger_name`;
|
|
94
95
|
const multicastFunctionRoute = `/functions/projects/:project_id/trigger_multicast`;
|
|
95
96
|
const httpsFunctionRoutes = [httpsFunctionRoute, `${httpsFunctionRoute}/*`];
|
|
@@ -245,15 +246,9 @@ class FunctionsEmulator {
|
|
|
245
246
|
await this.destroyServer();
|
|
246
247
|
}
|
|
247
248
|
}
|
|
248
|
-
async
|
|
249
|
-
this.workerPool.refresh();
|
|
250
|
-
if (!emulatableBackend.nodeBinary) {
|
|
251
|
-
throw new error_1.FirebaseError(`No node binary for ${emulatableBackend.functionsDir}. This should never happen.`);
|
|
252
|
-
}
|
|
253
|
-
this.blockingFunctionsConfig = {};
|
|
254
|
-
let triggerDefinitions;
|
|
249
|
+
async discoverTriggers(emulatableBackend) {
|
|
255
250
|
if (emulatableBackend.predefinedTriggers) {
|
|
256
|
-
|
|
251
|
+
return (0, functionsEmulatorShared_1.emulatedFunctionsByRegion)(emulatableBackend.predefinedTriggers, emulatableBackend.secretEnv);
|
|
257
252
|
}
|
|
258
253
|
else {
|
|
259
254
|
const runtimeConfig = this.getRuntimeConfig(emulatableBackend);
|
|
@@ -284,8 +279,26 @@ class FunctionsEmulator {
|
|
|
284
279
|
for (const e of endpoints) {
|
|
285
280
|
e.codebase = emulatableBackend.codebase;
|
|
286
281
|
}
|
|
287
|
-
|
|
282
|
+
return (0, functionsEmulatorShared_1.emulatedFunctionsFromEndpoints)(endpoints);
|
|
288
283
|
}
|
|
284
|
+
}
|
|
285
|
+
async loadTriggers(emulatableBackend, force = false) {
|
|
286
|
+
if (!emulatableBackend.nodeBinary) {
|
|
287
|
+
throw new error_1.FirebaseError(`No node binary for ${emulatableBackend.functionsDir}. This should never happen.`);
|
|
288
|
+
}
|
|
289
|
+
let triggerDefinitions = [];
|
|
290
|
+
try {
|
|
291
|
+
triggerDefinitions = await this.discoverTriggers(emulatableBackend);
|
|
292
|
+
this.logger.logLabeled("SUCCESS", "functions", `Loaded functions definitions from source: ${triggerDefinitions
|
|
293
|
+
.map((t) => t.entryPoint)
|
|
294
|
+
.join(", ")}.`);
|
|
295
|
+
}
|
|
296
|
+
catch (e) {
|
|
297
|
+
this.logger.logLabeled("ERROR", "functions", `Failed to load function definition from source: ${e}`);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
this.workerPool.refresh();
|
|
301
|
+
this.blockingFunctionsConfig = {};
|
|
289
302
|
const toSetup = triggerDefinitions.filter((definition) => {
|
|
290
303
|
if (force) {
|
|
291
304
|
return true;
|
|
@@ -305,8 +318,7 @@ class FunctionsEmulator {
|
|
|
305
318
|
(0, validate_1.functionIdsAreValid)([Object.assign(Object.assign({}, definition), { id: definition.name })]);
|
|
306
319
|
}
|
|
307
320
|
catch (e) {
|
|
308
|
-
|
|
309
|
-
continue;
|
|
321
|
+
throw new error_1.FirebaseError(`functions[${definition.id}]: Invalid function id: ${e.message}`);
|
|
310
322
|
}
|
|
311
323
|
let added = false;
|
|
312
324
|
let url = undefined;
|
|
@@ -329,6 +341,9 @@ class FunctionsEmulator {
|
|
|
329
341
|
case constants_1.Constants.SERVICE_PUBSUB:
|
|
330
342
|
added = await this.addPubsubTrigger(definition.name, key, definition.eventTrigger, signature, definition.schedule);
|
|
331
343
|
break;
|
|
344
|
+
case constants_1.Constants.SERVICE_EVENTARC:
|
|
345
|
+
added = await this.addEventarcTrigger(this.args.projectId, key, definition.eventTrigger);
|
|
346
|
+
break;
|
|
332
347
|
case constants_1.Constants.SERVICE_AUTH:
|
|
333
348
|
added = this.addAuthTrigger(this.args.projectId, key, definition.eventTrigger);
|
|
334
349
|
break;
|
|
@@ -368,6 +383,27 @@ class FunctionsEmulator {
|
|
|
368
383
|
this.startRuntime(emulatableBackend, { nodeBinary: emulatableBackend.nodeBinary });
|
|
369
384
|
}
|
|
370
385
|
}
|
|
386
|
+
addEventarcTrigger(projectId, key, eventTrigger) {
|
|
387
|
+
const eventarcEmu = registry_1.EmulatorRegistry.get(types_1.Emulators.EVENTARC);
|
|
388
|
+
if (!eventarcEmu) {
|
|
389
|
+
return Promise.resolve(false);
|
|
390
|
+
}
|
|
391
|
+
const bundle = {
|
|
392
|
+
eventTrigger: Object.assign(Object.assign({}, eventTrigger), { service: "eventarc.googleapis.com" }),
|
|
393
|
+
};
|
|
394
|
+
logger_1.logger.debug(`addEventarcTrigger`, JSON.stringify(bundle));
|
|
395
|
+
const client = new apiv2_1.Client({
|
|
396
|
+
urlPrefix: `http://${registry_1.EmulatorRegistry.getInfoHostString(eventarcEmu.getInfo())}`,
|
|
397
|
+
auth: false,
|
|
398
|
+
});
|
|
399
|
+
return client
|
|
400
|
+
.post(`/emulator/v1/projects/${projectId}/triggers/${key}`, bundle)
|
|
401
|
+
.then(() => true)
|
|
402
|
+
.catch((err) => {
|
|
403
|
+
this.logger.log("WARN", "Error adding Eventarc function: " + err);
|
|
404
|
+
return false;
|
|
405
|
+
});
|
|
406
|
+
}
|
|
371
407
|
async performPostLoadOperations() {
|
|
372
408
|
if (!this.blockingFunctionsConfig.triggers &&
|
|
373
409
|
!this.blockingFunctionsConfig.forwardInboundCredentials) {
|
|
@@ -544,7 +580,13 @@ class FunctionsEmulator {
|
|
|
544
580
|
return record;
|
|
545
581
|
}
|
|
546
582
|
getTriggerKey(def) {
|
|
547
|
-
|
|
583
|
+
if (def.eventTrigger) {
|
|
584
|
+
const triggerKey = `${def.id}-${this.triggerGeneration}`;
|
|
585
|
+
return def.eventTrigger.channel ? `${triggerKey}-${def.eventTrigger.channel}` : triggerKey;
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
return def.id;
|
|
589
|
+
}
|
|
548
590
|
}
|
|
549
591
|
getBackendInfo() {
|
|
550
592
|
const cf3Triggers = this.getCF3Triggers();
|
|
@@ -688,6 +730,10 @@ class FunctionsEmulator {
|
|
|
688
730
|
const pubsubHost = (0, functionsEmulatorShared_1.formatHost)(pubsubEmulator);
|
|
689
731
|
process.env.PUBSUB_EMULATOR_HOST = pubsubHost;
|
|
690
732
|
}
|
|
733
|
+
const eventarcEmulator = this.getEmulatorInfo(types_1.Emulators.EVENTARC);
|
|
734
|
+
if (eventarcEmulator) {
|
|
735
|
+
envs[constants_1.Constants.CLOUD_EVENTARC_EMULATOR_HOST] = `http://${(0, functionsEmulatorShared_1.formatHost)(eventarcEmulator)}`;
|
|
736
|
+
}
|
|
691
737
|
if (this.args.debugPort) {
|
|
692
738
|
envs["FUNCTION_DEBUG_MODE"] = "true";
|
|
693
739
|
}
|
|
@@ -884,6 +930,9 @@ class FunctionsEmulator {
|
|
|
884
930
|
}
|
|
885
931
|
});
|
|
886
932
|
void (0, track_1.track)(EVENT_INVOKE, (0, functionsEmulatorShared_1.getFunctionService)(trigger));
|
|
933
|
+
void (0, track_1.trackEmulator)(EVENT_INVOKE_GA4, {
|
|
934
|
+
function_service: (0, functionsEmulatorShared_1.getFunctionService)(trigger),
|
|
935
|
+
});
|
|
887
936
|
worker.waitForDone().then(() => {
|
|
888
937
|
resolve({ status: "acknowledged" });
|
|
889
938
|
});
|
|
@@ -959,6 +1008,9 @@ class FunctionsEmulator {
|
|
|
959
1008
|
});
|
|
960
1009
|
await worker.waitForSocketReady();
|
|
961
1010
|
void (0, track_1.track)(EVENT_INVOKE, "https");
|
|
1011
|
+
void (0, track_1.trackEmulator)(EVENT_INVOKE_GA4, {
|
|
1012
|
+
function_service: "https",
|
|
1013
|
+
});
|
|
962
1014
|
this.logger.log("DEBUG", `[functions] Runtime ready! Sending request!`);
|
|
963
1015
|
const url = new url_1.URL(`${req.protocol}://${req.hostname}${req.url}`);
|
|
964
1016
|
const path = `${url.pathname}${url.search}`.replace(new RegExp(`\/${this.args.projectId}\/[^\/]*\/${triggerName}\/?`), "/");
|
|
@@ -8,20 +8,11 @@ const crypto_1 = require("crypto");
|
|
|
8
8
|
const _ = require("lodash");
|
|
9
9
|
const backend = require("../deploy/functions/backend");
|
|
10
10
|
const constants_1 = require("./constants");
|
|
11
|
-
const proto_1 = require("../gcp/proto");
|
|
12
11
|
const manifest_1 = require("../extensions/manifest");
|
|
13
12
|
const extensionsHelper_1 = require("../extensions/extensionsHelper");
|
|
14
13
|
const postinstall_1 = require("./extensions/postinstall");
|
|
15
14
|
const services_1 = require("../deploy/functions/services");
|
|
16
15
|
const prepare_1 = require("../deploy/functions/prepare");
|
|
17
|
-
const memoryLookup = {
|
|
18
|
-
"128MB": 128,
|
|
19
|
-
"256MB": 256,
|
|
20
|
-
"512MB": 512,
|
|
21
|
-
"1GB": 1024,
|
|
22
|
-
"2GB": 2048,
|
|
23
|
-
"4GB": 4096,
|
|
24
|
-
};
|
|
25
16
|
class HttpConstants {
|
|
26
17
|
}
|
|
27
18
|
exports.HttpConstants = HttpConstants;
|
|
@@ -33,7 +24,7 @@ class EmulatedTrigger {
|
|
|
33
24
|
this.module = module;
|
|
34
25
|
}
|
|
35
26
|
get memoryLimitBytes() {
|
|
36
|
-
return
|
|
27
|
+
return (this.definition.availableMemoryMb || 128) * 1024 * 1024;
|
|
37
28
|
}
|
|
38
29
|
get timeoutMs() {
|
|
39
30
|
return (this.definition.timeoutSeconds || 60) * 1000;
|
|
@@ -69,7 +60,11 @@ function emulatedFunctionsFromEndpoints(endpoints) {
|
|
|
69
60
|
id: `${endpoint.region}-${endpoint.id}`,
|
|
70
61
|
codebase: endpoint.codebase,
|
|
71
62
|
};
|
|
72
|
-
|
|
63
|
+
def.availableMemoryMb = endpoint.availableMemoryMb || 256;
|
|
64
|
+
def.labels = endpoint.labels || {};
|
|
65
|
+
def.timeoutSeconds = endpoint.timeoutSeconds || 60;
|
|
66
|
+
def.secretEnvironmentVariables = endpoint.secretEnvironmentVariables || [];
|
|
67
|
+
def.platform = endpoint.platform;
|
|
73
68
|
if (backend.isHttpsTriggered(endpoint)) {
|
|
74
69
|
def.httpsTrigger = endpoint.httpsTrigger;
|
|
75
70
|
}
|
|
@@ -88,12 +83,14 @@ function emulatedFunctionsFromEndpoints(endpoints) {
|
|
|
88
83
|
else {
|
|
89
84
|
const { resource, topic, bucket } = endpoint.eventTrigger.eventFilters;
|
|
90
85
|
const eventResource = resource || topic || bucket;
|
|
91
|
-
if (!eventResource) {
|
|
86
|
+
if (!eventResource && !eventTrigger.channel) {
|
|
92
87
|
continue;
|
|
93
88
|
}
|
|
94
89
|
def.eventTrigger = {
|
|
95
90
|
eventType: eventTrigger.eventType,
|
|
96
91
|
resource: eventResource,
|
|
92
|
+
channel: eventTrigger.channel,
|
|
93
|
+
eventFilters: eventTrigger.eventFilters,
|
|
97
94
|
};
|
|
98
95
|
}
|
|
99
96
|
}
|
|
@@ -156,6 +153,9 @@ exports.getTemporarySocketPath = getTemporarySocketPath;
|
|
|
156
153
|
function getFunctionService(def) {
|
|
157
154
|
var _a;
|
|
158
155
|
if (def.eventTrigger) {
|
|
156
|
+
if (def.eventTrigger.channel) {
|
|
157
|
+
return constants_1.Constants.SERVICE_EVENTARC;
|
|
158
|
+
}
|
|
159
159
|
return (_a = def.eventTrigger.service) !== null && _a !== void 0 ? _a : getServiceFromEventType(def.eventTrigger.eventType);
|
|
160
160
|
}
|
|
161
161
|
if (def.blockingTrigger) {
|