firebase-tools-with-isolate 13.11.2 → 13.16.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 (134) hide show
  1. package/lib/api.js +4 -2
  2. package/lib/apphosting/githubConnections.js +125 -37
  3. package/lib/apphosting/index.js +3 -8
  4. package/lib/auth.js +14 -15
  5. package/lib/bin/firebase.js +7 -5
  6. package/lib/commands/dataconnect-sdk-generate.js +5 -9
  7. package/lib/commands/dataconnect-services-list.js +1 -1
  8. package/lib/commands/deploy.js +10 -2
  9. package/lib/commands/ext-configure.js +1 -6
  10. package/lib/commands/ext-dev-init.js +27 -30
  11. package/lib/commands/ext-dev-upload.js +4 -6
  12. package/lib/commands/ext-info.js +3 -5
  13. package/lib/commands/ext-install.js +0 -5
  14. package/lib/commands/ext-uninstall.js +0 -5
  15. package/lib/commands/ext-update.js +0 -5
  16. package/lib/commands/firestore-backups-schedules-create.js +11 -14
  17. package/lib/commands/firestore-backups-schedules-list.js +1 -1
  18. package/lib/commands/firestore-backups-schedules-update.js +4 -3
  19. package/lib/commands/firestore-databases-create.js +24 -7
  20. package/lib/commands/firestore-databases-restore.js +4 -4
  21. package/lib/commands/firestore-databases-update.js +5 -6
  22. package/lib/commands/functions-secrets-set.js +9 -6
  23. package/lib/commands/help.js +2 -0
  24. package/lib/commands/hosting-channel-create.js +1 -1
  25. package/lib/commands/hosting-channel-delete.js +1 -1
  26. package/lib/commands/hosting-channel-deploy.js +1 -1
  27. package/lib/commands/hosting-clone.js +1 -2
  28. package/lib/commands/index.js +9 -11
  29. package/lib/commands/init.js +16 -12
  30. package/lib/commands/login.js +1 -2
  31. package/lib/commands/setup-emulators-dataconnect.js +22 -3
  32. package/lib/config.js +5 -0
  33. package/lib/crashlytics/buildToolsJarHelper.js +1 -1
  34. package/lib/dataconnect/client.js +57 -9
  35. package/lib/dataconnect/fileUtils.js +71 -7
  36. package/lib/dataconnect/filters.js +12 -1
  37. package/lib/dataconnect/load.js +9 -7
  38. package/lib/dataconnect/provisionCloudSql.js +5 -1
  39. package/lib/dataconnect/schemaMigration.js +21 -0
  40. package/lib/dataconnect/types.js +8 -1
  41. package/lib/deploy/dataconnect/prepare.js +16 -2
  42. package/lib/deploy/extensions/planner.js +52 -1
  43. package/lib/deploy/extensions/prepare.js +98 -23
  44. package/lib/deploy/extensions/release.js +6 -0
  45. package/lib/deploy/functions/build.js +15 -6
  46. package/lib/deploy/functions/deploy.js +12 -12
  47. package/lib/deploy/functions/params.js +5 -3
  48. package/lib/deploy/functions/prepare.js +8 -1
  49. package/lib/deploy/functions/release/index.js +4 -0
  50. package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
  51. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +46 -0
  52. package/lib/emulator/adminSdkConfig.test.js +16 -0
  53. package/lib/emulator/constants.js +8 -0
  54. package/lib/emulator/controller.js +14 -10
  55. package/lib/emulator/dataconnectEmulator.js +122 -18
  56. package/lib/emulator/downloadableEmulators.js +24 -25
  57. package/lib/emulator/env.js +3 -0
  58. package/lib/emulator/eventarcEmulator.js +68 -18
  59. package/lib/emulator/functionsEmulator.js +119 -1
  60. package/lib/emulator/functionsEmulatorShared.js +20 -0
  61. package/lib/emulator/hub.js +1 -1
  62. package/lib/emulator/portUtils.js +10 -0
  63. package/lib/emulator/pubsubEmulator.js +1 -1
  64. package/lib/emulator/registry.js +2 -1
  65. package/lib/emulator/storage/apis/shared.js +2 -1
  66. package/lib/emulator/storage/persistence.js +5 -13
  67. package/lib/emulator/storage/rfc.js +9 -0
  68. package/lib/emulator/storage/rules/config.js +4 -2
  69. package/lib/emulator/taskQueue.js +348 -0
  70. package/lib/emulator/tasksEmulator.js +237 -0
  71. package/lib/emulator/types.js +3 -0
  72. package/lib/experiments.js +8 -3
  73. package/lib/extensions/askUserForEventsConfig.js +18 -8
  74. package/lib/extensions/askUserForParam.js +3 -2
  75. package/lib/extensions/change-log.js +2 -4
  76. package/lib/extensions/displayExtensionInfo.js +5 -10
  77. package/lib/extensions/extensionsApi.js +1 -1
  78. package/lib/extensions/extensionsHelper.js +30 -10
  79. package/lib/extensions/localHelper.js +1 -1
  80. package/lib/extensions/provisioningHelper.js +1 -1
  81. package/lib/extensions/refs.js +26 -11
  82. package/lib/extensions/runtimes/common.js +75 -0
  83. package/lib/extensions/types.js +56 -1
  84. package/lib/extensions/updateHelper.js +1 -2
  85. package/lib/extensions/warnings.js +2 -7
  86. package/lib/firestore/api-sort.test.js +74 -0
  87. package/lib/firestore/api.js +8 -7
  88. package/lib/firestore/backupUtils.test.js +18 -0
  89. package/lib/firestore/pretty-print.js +21 -1
  90. package/lib/firestore/pretty-print.test.js +61 -0
  91. package/lib/firestore/util.test.js +42 -0
  92. package/lib/frameworks/angular/utils.js +13 -5
  93. package/lib/frameworks/compose/discover/mockFileSystem.js +36 -0
  94. package/lib/frameworks/constants.js +1 -1
  95. package/lib/frameworks/index.js +2 -6
  96. package/lib/frameworks/next/constants.js +1 -1
  97. package/lib/frameworks/next/index.js +35 -15
  98. package/lib/frameworks/next/utils.js +53 -9
  99. package/lib/frameworks/nuxt/index.js +3 -3
  100. package/lib/functions/events/v2.js +2 -1
  101. package/lib/gcp/cloudsql/cloudsqladmin.js +6 -1
  102. package/lib/gcp/devConnect.js +36 -1
  103. package/lib/hosting/implicitInit.js +2 -2
  104. package/lib/init/features/dataconnect/index.js +104 -32
  105. package/lib/init/features/dataconnect/sdk.js +147 -0
  106. package/lib/init/features/firestore/indexes.js +2 -2
  107. package/lib/init/features/firestore/rules.js +2 -2
  108. package/lib/init/features/functions/javascript.js +6 -8
  109. package/lib/init/features/functions/python.js +4 -6
  110. package/lib/init/features/functions/typescript.js +8 -10
  111. package/lib/init/features/hosting/github.js +43 -21
  112. package/lib/init/features/hosting/index.js +3 -3
  113. package/lib/init/features/index.js +3 -1
  114. package/lib/init/features/storage.js +2 -2
  115. package/lib/init/index.js +1 -0
  116. package/lib/listFiles.js +1 -1
  117. package/lib/management/apps.js +2 -2
  118. package/lib/prompt.js +22 -1
  119. package/lib/rc.js +1 -0
  120. package/lib/requireAuth.js +8 -3
  121. package/lib/rulesDeploy.js +14 -12
  122. package/lib/templates.js +23 -0
  123. package/lib/utils.js +2 -2
  124. package/package.json +25 -24
  125. package/schema/connector-yaml.json +36 -4
  126. package/schema/dataconnect-yaml.json +4 -0
  127. package/schema/firebase-config.json +12 -8
  128. package/templates/_gitignore +3 -0
  129. package/templates/init/dataconnect/connector.yaml +15 -2
  130. package/templates/init/dataconnect/dataconnect.yaml +5 -4
  131. package/templates/init/dataconnect/mutations.gql +45 -25
  132. package/templates/init/dataconnect/queries.gql +69 -36
  133. package/templates/init/dataconnect/schema.gql +38 -21
  134. package/lib/extensions/billingMigrationHelper.js +0 -61
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractExtensionsFromBuilds = exports.extractAllDynamicExtensions = void 0;
4
+ const projectConfig_1 = require("../../functions/projectConfig");
5
+ const prepare_1 = require("../../deploy/functions/prepare");
6
+ const functionsConfig_1 = require("../../functionsConfig");
7
+ const functionsDeployHelper_1 = require("../../deploy/functions/functionsDeployHelper");
8
+ const logger_1 = require("../../logger");
9
+ const savedLoggerSilent = logger_1.logger.silent;
10
+ function silenceLogging() {
11
+ logger_1.logger.silent = true;
12
+ }
13
+ function resumeLogging() {
14
+ logger_1.logger.silent = savedLoggerSilent;
15
+ }
16
+ async function extractAllDynamicExtensions(options) {
17
+ const firebaseConfig = await (0, functionsConfig_1.getFirebaseConfig)(options);
18
+ const runtimeConfig = { firebase: firebaseConfig };
19
+ const functionsConfig = (0, projectConfig_1.normalizeAndValidate)(options.config.src.functions);
20
+ let functionsBuilds = {};
21
+ const codebases = (0, functionsDeployHelper_1.targetCodebases)(functionsConfig);
22
+ silenceLogging();
23
+ for (const codebase of codebases) {
24
+ try {
25
+ const filters = [{ codebase: `${codebase}` }];
26
+ const builds = await (0, prepare_1.loadCodebases)(functionsConfig, options, firebaseConfig, runtimeConfig, filters);
27
+ functionsBuilds = { ...functionsBuilds, ...builds };
28
+ }
29
+ catch (err) {
30
+ }
31
+ }
32
+ resumeLogging();
33
+ return extractExtensionsFromBuilds(functionsBuilds);
34
+ }
35
+ exports.extractAllDynamicExtensions = extractAllDynamicExtensions;
36
+ function extractExtensionsFromBuilds(builds, filters) {
37
+ const extRecords = {};
38
+ for (const [codebase, build] of Object.entries(builds)) {
39
+ if (build.extensions) {
40
+ for (const [id, ext] of Object.entries(build.extensions)) {
41
+ if (extensionMatchesAnyFilter(codebase, id, filters)) {
42
+ extRecords[id] = ext;
43
+ }
44
+ }
45
+ }
46
+ }
47
+ return extRecords;
48
+ }
49
+ exports.extractExtensionsFromBuilds = extractExtensionsFromBuilds;
50
+ function extensionMatchesAnyFilter(codebase, extensionId, filters) {
51
+ if (!filters) {
52
+ return true;
53
+ }
54
+ return filters.some((f) => extensionMatchesFilter(codebase, extensionId, f));
55
+ }
56
+ function extensionMatchesFilter(codebase, extensionId, filter) {
57
+ if (codebase && filter.codebase) {
58
+ if (codebase !== filter.codebase) {
59
+ return false;
60
+ }
61
+ }
62
+ if (!filter.idChunks) {
63
+ return true;
64
+ }
65
+ const idChunks = extensionId.split("-");
66
+ if (idChunks.length < filter.idChunks.length) {
67
+ return false;
68
+ }
69
+ for (let i = 0; i < filter.idChunks.length; i++) {
70
+ if (idChunks[i] !== filter.idChunks[i]) {
71
+ return false;
72
+ }
73
+ }
74
+ return true;
75
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParamType = exports.FUNCTIONS_V2_RESOURCE_TYPE = exports.FUNCTIONS_RESOURCE_TYPE = exports.Visibility = exports.RegistryLaunchStage = void 0;
3
+ exports.isExtensionSpec = exports.isResource = exports.isParam = exports.ParamType = exports.FUNCTIONS_V2_RESOURCE_TYPE = exports.FUNCTIONS_RESOURCE_TYPE = exports.Visibility = exports.RegistryLaunchStage = void 0;
4
4
  var RegistryLaunchStage;
5
5
  (function (RegistryLaunchStage) {
6
6
  RegistryLaunchStage["EXPERIMENTAL"] = "EXPERIMENTAL";
@@ -21,5 +21,60 @@ var ParamType;
21
21
  ParamType["STRING"] = "STRING";
22
22
  ParamType["SELECT"] = "SELECT";
23
23
  ParamType["MULTISELECT"] = "MULTISELECT";
24
+ ParamType["SELECT_RESOURCE"] = "SELECT_RESOURCE";
24
25
  ParamType["SECRET"] = "SECRET";
25
26
  })(ParamType = exports.ParamType || (exports.ParamType = {}));
27
+ function isObject(value) {
28
+ return typeof value === "object" && value !== null;
29
+ }
30
+ const isParam = (param) => {
31
+ return (isObject(param) && typeof param["param"] === "string" && typeof param["label"] === "string");
32
+ };
33
+ exports.isParam = isParam;
34
+ const isResource = (res) => {
35
+ return isObject(res) && typeof res["name"] === "string";
36
+ };
37
+ exports.isResource = isResource;
38
+ const isExtensionSpec = (spec) => {
39
+ if (!isObject(spec) || typeof spec.name !== "string" || typeof spec.version !== "string") {
40
+ return false;
41
+ }
42
+ let validResources = true;
43
+ if (spec.resources && Array.isArray(spec.resources)) {
44
+ for (const res of spec.resources) {
45
+ validResources = validResources && (0, exports.isResource)(res);
46
+ if (!validResources) {
47
+ break;
48
+ }
49
+ }
50
+ }
51
+ else {
52
+ return false;
53
+ }
54
+ let validParams = true;
55
+ if (spec.params && Array.isArray(spec.params)) {
56
+ for (const param of spec.params) {
57
+ validParams = validParams && (0, exports.isParam)(param);
58
+ if (!validParams) {
59
+ break;
60
+ }
61
+ }
62
+ }
63
+ else {
64
+ return false;
65
+ }
66
+ let validSysParams = true;
67
+ if (spec.systemParams && Array.isArray(spec.systemParams)) {
68
+ for (const param of spec.systemParams) {
69
+ validSysParams = validSysParams && (0, exports.isParam)(param);
70
+ if (!validSysParams) {
71
+ break;
72
+ }
73
+ }
74
+ }
75
+ else {
76
+ return false;
77
+ }
78
+ return true;
79
+ };
80
+ exports.isExtensionSpec = isExtensionSpec;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.inferUpdateSource = exports.updateFromUrlSource = exports.updateFromLocalSource = exports.update = exports.warningUpdateToOtherSource = exports.getExistingSourceOrigin = void 0;
4
4
  const clc = require("colorette");
5
5
  const semver = require("semver");
6
- const marked_1 = require("marked");
7
6
  const error_1 = require("../error");
8
7
  const logger_1 = require("../logger");
9
8
  const extensionsApi = require("./extensionsApi");
@@ -47,7 +46,7 @@ function warningUpdateToOtherSource(sourceOrigin) {
47
46
  targetText = "URL";
48
47
  }
49
48
  const warning = `All the instance's resources and logic will be overwritten to use the source code and files from the ${targetText}.\n`;
50
- logger_1.logger.info((0, marked_1.marked)(warning));
49
+ logger_1.logger.info(warning);
51
50
  }
52
51
  exports.warningUpdateToOtherSource = warningUpdateToOtherSource;
53
52
  async function update(updateOptions) {
@@ -2,11 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.outOfBandChangesWarning = exports.displayWarningsForDeploy = void 0;
4
4
  const clc = require("colorette");
5
- const TerminalRenderer = require("marked-terminal");
6
- const marked_1 = require("marked");
7
- marked_1.marked.setOptions({
8
- renderer: new TerminalRenderer(),
9
- });
10
5
  const extensionsHelper_1 = require("./extensionsHelper");
11
6
  const deploymentSummary_1 = require("../deploy/extensions/deploymentSummary");
12
7
  const planner_1 = require("../deploy/extensions/planner");
@@ -28,9 +23,9 @@ async function displayWarningsForDeploy(instancesToCreate) {
28
23
  const unpublishedExtensions = uploadedExtensionInstances.filter((i) => i.extensionVersion?.listing?.state !== "APPROVED");
29
24
  if (unpublishedExtensions.length) {
30
25
  const humanReadableList = unpublishedExtensions.map(toListEntry).join("\n");
31
- utils.logLabeledBullet(extensionsHelper_1.logPrefix, (0, marked_1.marked)(`The following extension versions have not been published to the Firebase Extensions Hub:\n${humanReadableList}\n.` +
26
+ utils.logLabeledBullet(extensionsHelper_1.logPrefix, `The following extension versions have not been published to the Firebase Extensions Hub:\n${humanReadableList}\n.` +
32
27
  "Unpublished extensions have not been reviewed by " +
33
- "Firebase. Please make sure you trust the extension publisher before installing this extension.", { gfm: false }));
28
+ "Firebase. Please make sure you trust the extension publisher before installing this extension.");
34
29
  }
35
30
  return unpublishedExtensions.length > 0;
36
31
  }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ const firestore_1 = require("../gcp/firestore");
5
+ const proto_1 = require("../gcp/proto");
6
+ const sort = require("./api-sort");
7
+ describe("compareApiBackup", () => {
8
+ it("should compare backups by location", () => {
9
+ const nam5Backup = {
10
+ name: "projects/example/locations/nam5/backups/backupid",
11
+ };
12
+ const usWest1Backup = {
13
+ name: "projects/example/locations/us-west1/backups/backupid",
14
+ };
15
+ (0, chai_1.expect)(sort.compareApiBackup(usWest1Backup, nam5Backup)).to.greaterThanOrEqual(1);
16
+ (0, chai_1.expect)(sort.compareApiBackup(nam5Backup, usWest1Backup)).to.lessThanOrEqual(-1);
17
+ });
18
+ it("should compare backups by snapshotTime (descending) if location is the same", () => {
19
+ const earlierBackup = {
20
+ name: "projects/example/locations/nam5/backups/backupid",
21
+ snapshotTime: "2024-01-01T00:00:00.000000Z",
22
+ };
23
+ const laterBackup = {
24
+ name: "projects/example/locations/nam5/backups/backupid",
25
+ snapshotTime: "2024-02-02T00:00:00.000000Z",
26
+ };
27
+ (0, chai_1.expect)(sort.compareApiBackup(earlierBackup, laterBackup)).to.greaterThanOrEqual(1);
28
+ (0, chai_1.expect)(sort.compareApiBackup(laterBackup, earlierBackup)).to.lessThanOrEqual(-1);
29
+ });
30
+ it("should compare backups by full name if location and snapshotTime are the same", () => {
31
+ const nam5Backup1 = {
32
+ name: "projects/example/locations/nam5/backups/earlier-backupid",
33
+ snapshotTime: "2024-01-01T00:00:00.000000Z",
34
+ };
35
+ const nam5Backup2 = {
36
+ name: "projects/example/locations/nam5/backups/later-backupid",
37
+ snapshotTime: "2024-01-01T00:00:00.000000Z",
38
+ };
39
+ (0, chai_1.expect)(sort.compareApiBackup(nam5Backup2, nam5Backup1)).to.greaterThanOrEqual(1);
40
+ (0, chai_1.expect)(sort.compareApiBackup(nam5Backup1, nam5Backup2)).to.lessThanOrEqual(-1);
41
+ });
42
+ });
43
+ describe("compareApiBackupSchedule", () => {
44
+ it("daily schedules should precede weekly ones", () => {
45
+ const dailySchedule = {
46
+ name: "projects/example/databases/mydatabase/backupSchedules/schedule",
47
+ dailyRecurrence: {},
48
+ retention: (0, proto_1.durationFromSeconds)(60 * 60 * 24),
49
+ };
50
+ const weeklySchedule = {
51
+ name: "projects/example/databases/mydatabase/backupSchedules/schedule",
52
+ weeklyRecurrence: {
53
+ day: firestore_1.DayOfWeek.FRIDAY,
54
+ },
55
+ retention: (0, proto_1.durationFromSeconds)(60 * 60 * 24 * 7),
56
+ };
57
+ (0, chai_1.expect)(sort.compareApiBackupSchedule(weeklySchedule, dailySchedule)).to.greaterThanOrEqual(1);
58
+ (0, chai_1.expect)(sort.compareApiBackup(dailySchedule, weeklySchedule)).to.lessThanOrEqual(-1);
59
+ });
60
+ it("should compare schedules with the same recurrence by name", () => {
61
+ const dailySchedule1 = {
62
+ name: "projects/example/databases/mydatabase/backupSchedules/schedule1",
63
+ dailyRecurrence: {},
64
+ retention: (0, proto_1.durationFromSeconds)(60 * 60 * 24),
65
+ };
66
+ const dailySchedule2 = {
67
+ name: "projects/example/databases/mydatabase/backupSchedules/schedule2",
68
+ dailyRecurrence: {},
69
+ retention: (0, proto_1.durationFromSeconds)(60 * 60 * 24),
70
+ };
71
+ (0, chai_1.expect)(sort.compareApiBackupSchedule(dailySchedule1, dailySchedule2)).to.lessThanOrEqual(-1);
72
+ (0, chai_1.expect)(sort.compareApiBackup(dailySchedule2, dailySchedule1)).to.greaterThanOrEqual(1);
73
+ });
74
+ });
@@ -420,15 +420,16 @@ class FirestoreApi {
420
420
  }
421
421
  return database;
422
422
  }
423
- async createDatabase(project, databaseId, locationId, type, deleteProtectionState, pointInTimeRecoveryEnablement) {
424
- const url = `/projects/${project}/databases`;
423
+ async createDatabase(req) {
424
+ const url = `/projects/${req.project}/databases`;
425
425
  const payload = {
426
- type,
427
- locationId,
428
- deleteProtectionState,
429
- pointInTimeRecoveryEnablement,
426
+ locationId: req.locationId,
427
+ type: req.type,
428
+ deleteProtectionState: req.deleteProtectionState,
429
+ pointInTimeRecoveryEnablement: req.pointInTimeRecoveryEnablement,
430
+ cmekConfig: req.cmekConfig,
430
431
  };
431
- const options = { queryParams: { databaseId: databaseId } };
432
+ const options = { queryParams: { databaseId: req.databaseId } };
432
433
  const res = await this.apiClient.post(url, payload, options);
433
434
  const database = res.body.response;
434
435
  if (!database) {
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ const backupUtils_1 = require("./backupUtils");
5
+ describe("calculateRetention", () => {
6
+ it("should accept minutes", () => {
7
+ (0, chai_1.expect)((0, backupUtils_1.calculateRetention)("5m")).to.eq(300);
8
+ });
9
+ it("should accept hours", () => {
10
+ (0, chai_1.expect)((0, backupUtils_1.calculateRetention)("3h")).to.eq(10800);
11
+ });
12
+ it("should accept days", () => {
13
+ (0, chai_1.expect)((0, backupUtils_1.calculateRetention)("2d")).to.eq(172800);
14
+ });
15
+ it("should accept weeks", () => {
16
+ (0, chai_1.expect)((0, backupUtils_1.calculateRetention)("3w")).to.eq(1814400);
17
+ });
18
+ });
@@ -33,13 +33,33 @@ class PrettyPrint {
33
33
  logger_1.logger.info(table.toString());
34
34
  }
35
35
  prettyPrintDatabase(database) {
36
+ let colValueWidth = Math.max(50, 5 + database.name.length);
37
+ if (database.cmekConfig) {
38
+ colValueWidth = Math.max(140, 20 + database.cmekConfig.kmsKeyName.length);
39
+ }
36
40
  const table = new Table({
37
41
  head: ["Field", "Value"],
38
- colWidths: [25, Math.max(50, 5 + database.name.length)],
42
+ colWidths: [30, colValueWidth],
39
43
  });
40
44
  table.push(["Name", clc.yellow(database.name)], ["Create Time", clc.yellow(database.createTime)], ["Last Update Time", clc.yellow(database.updateTime)], ["Type", clc.yellow(database.type)], ["Location", clc.yellow(database.locationId)], ["Delete Protection State", clc.yellow(database.deleteProtectionState)], ["Point In Time Recovery", clc.yellow(database.pointInTimeRecoveryEnablement)], ["Earliest Version Time", clc.yellow(database.earliestVersionTime)], ["Version Retention Period", clc.yellow(database.versionRetentionPeriod)]);
45
+ if (database.cmekConfig) {
46
+ table.push(["KMS Key Name", clc.yellow(database.cmekConfig.kmsKeyName)]);
47
+ if (database.cmekConfig.activeKeyVersion) {
48
+ table.push([
49
+ "Active Key Versions",
50
+ clc.yellow(this.prettyStringArray(database.cmekConfig.activeKeyVersion)),
51
+ ]);
52
+ }
53
+ }
41
54
  logger_1.logger.info(table.toString());
42
55
  }
56
+ prettyStringArray(stringArray) {
57
+ let result = "";
58
+ stringArray.forEach((str) => {
59
+ result += `${str}\n`;
60
+ });
61
+ return result;
62
+ }
43
63
  prettyPrintBackups(backups) {
44
64
  if (backups.length === 0) {
45
65
  logger_1.logger.info("No backups found.");
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ const API = require("./api-types");
5
+ const pretty_print_1 = require("./pretty-print");
6
+ const printer = new pretty_print_1.PrettyPrint();
7
+ describe("prettyIndexString", () => {
8
+ it("should correctly print an order type Index", () => {
9
+ (0, chai_1.expect)(printer.prettyIndexString({
10
+ name: "/projects/project/databases/(default)/collectionGroups/collectionB/indexes/a",
11
+ queryScope: API.QueryScope.COLLECTION,
12
+ fields: [
13
+ { fieldPath: "foo", order: API.Order.ASCENDING },
14
+ { fieldPath: "bar", order: API.Order.DESCENDING },
15
+ ],
16
+ }, false)).to.contain("(foo,ASCENDING) (bar,DESCENDING) ");
17
+ });
18
+ it("should correctly print a contains type Index", () => {
19
+ (0, chai_1.expect)(printer.prettyIndexString({
20
+ name: "/projects/project/databases/(default)/collectionGroups/collectionB/indexes/a",
21
+ queryScope: API.QueryScope.COLLECTION,
22
+ fields: [
23
+ { fieldPath: "foo", order: API.Order.ASCENDING },
24
+ { fieldPath: "baz", arrayConfig: API.ArrayConfig.CONTAINS },
25
+ ],
26
+ }, false)).to.contain("(foo,ASCENDING) (baz,CONTAINS) ");
27
+ });
28
+ it("should correctly print a vector type Index", () => {
29
+ (0, chai_1.expect)(printer.prettyIndexString({
30
+ name: "/projects/project/databases/(default)/collectionGroups/collectionB/indexes/a",
31
+ queryScope: API.QueryScope.COLLECTION,
32
+ fields: [{ fieldPath: "foo", vectorConfig: { dimension: 100, flat: {} } }],
33
+ }, false)).to.contain("(foo,VECTOR<100>) ");
34
+ });
35
+ it("should correctly print a vector type Index with other fields", () => {
36
+ (0, chai_1.expect)(printer.prettyIndexString({
37
+ name: "/projects/project/databases/(default)/collectionGroups/collectionB/indexes/a",
38
+ queryScope: API.QueryScope.COLLECTION,
39
+ fields: [
40
+ { fieldPath: "foo", order: API.Order.ASCENDING },
41
+ { fieldPath: "bar", vectorConfig: { dimension: 200, flat: {} } },
42
+ ],
43
+ }, false)).to.contain("(foo,ASCENDING) (bar,VECTOR<200>) ");
44
+ });
45
+ });
46
+ describe("firebaseConsoleDatabaseUrl", () => {
47
+ it("should provide a console link", () => {
48
+ (0, chai_1.expect)(printer.firebaseConsoleDatabaseUrl("example-project", "example-db")).to.equal("https://console.firebase.google.com/project/example-project/firestore/databases/example-db/data");
49
+ });
50
+ it("should convert (default) to -default-", () => {
51
+ (0, chai_1.expect)(printer.firebaseConsoleDatabaseUrl("example-project", "(default)")).to.equal("https://console.firebase.google.com/project/example-project/firestore/databases/-default-/data");
52
+ });
53
+ });
54
+ describe("prettyStringArray", () => {
55
+ it("should correctly print an array of strings", () => {
56
+ (0, chai_1.expect)(printer.prettyStringArray(["kms-key-1", "kms-key-2"])).to.equal("kms-key-1\nkms-key-2\n");
57
+ });
58
+ it("should print nothing if the array is empty", () => {
59
+ (0, chai_1.expect)(printer.prettyStringArray([])).to.equal("");
60
+ });
61
+ });
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ const util = require("./util");
5
+ describe("IndexNameParsing", () => {
6
+ it("should parse an index name correctly", () => {
7
+ const name = "/projects/myproject/databases/(default)/collectionGroups/collection/indexes/abc123/";
8
+ (0, chai_1.expect)(util.parseIndexName(name)).to.eql({
9
+ projectId: "myproject",
10
+ databaseId: "(default)",
11
+ collectionGroupId: "collection",
12
+ indexId: "abc123",
13
+ });
14
+ });
15
+ it("should parse a field name correctly", () => {
16
+ const name = "/projects/myproject/databases/(default)/collectionGroups/collection/fields/abc123/";
17
+ (0, chai_1.expect)(util.parseFieldName(name)).to.eql({
18
+ projectId: "myproject",
19
+ databaseId: "(default)",
20
+ collectionGroupId: "collection",
21
+ fieldPath: "abc123",
22
+ });
23
+ });
24
+ it("should parse an index name from a named database correctly", () => {
25
+ const name = "/projects/myproject/databases/named-db/collectionGroups/collection/indexes/abc123/";
26
+ (0, chai_1.expect)(util.parseIndexName(name)).to.eql({
27
+ projectId: "myproject",
28
+ databaseId: "named-db",
29
+ collectionGroupId: "collection",
30
+ indexId: "abc123",
31
+ });
32
+ });
33
+ it("should parse a field name from a named database correctly", () => {
34
+ const name = "/projects/myproject/databases/named-db/collectionGroups/collection/fields/abc123/";
35
+ (0, chai_1.expect)(util.parseFieldName(name)).to.eql({
36
+ projectId: "myproject",
37
+ databaseId: "named-db",
38
+ collectionGroupId: "collection",
39
+ fieldPath: "abc123",
40
+ });
41
+ });
42
+ });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAngularVersion = exports.getBuildConfig = exports.getServerConfig = exports.getBrowserConfig = exports.getContext = exports.getAllTargets = void 0;
3
+ exports.tryToGetOptionsForTarget = exports.getAngularVersion = exports.getBuildConfig = exports.getServerConfig = exports.getBrowserConfig = exports.getContext = exports.getAllTargets = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  const error_1 = require("../../error");
6
6
  const path_1 = require("path");
@@ -143,8 +143,9 @@ async function getContext(dir, targetOrConfiguration) {
143
143
  if (apps.length === 1)
144
144
  project = apps[0];
145
145
  }
146
- if (!project)
147
- throw new error_1.FirebaseError("Unable to determine the application to deploy, specify a target via the FIREBASE_FRAMEWORKS_BUILD_TARGET environment variable");
146
+ if (!project) {
147
+ throwCannotDetermineTarget();
148
+ }
148
149
  const workspaceProject = workspace.projects.get(project);
149
150
  if (!workspaceProject)
150
151
  throw new error_1.FirebaseError(`No project ${project} found.`);
@@ -334,14 +335,14 @@ async function getContext(dir, targetOrConfiguration) {
334
335
  if (!buildOrBrowserTarget) {
335
336
  throw new error_1.FirebaseError(`No build target on ${project}`);
336
337
  }
337
- const browserTargetOptions = await architectHost.getOptionsForTarget(buildOrBrowserTarget);
338
+ const browserTargetOptions = await tryToGetOptionsForTarget(architectHost, buildOrBrowserTarget);
338
339
  if (!browserTargetOptions) {
339
340
  const targetString = targetStringFromTarget(buildOrBrowserTarget);
340
341
  throw new error_1.FirebaseError(`Couldn't find options for ${targetString}.`);
341
342
  }
342
343
  const baseHref = browserTargetOptions.baseHref || "/";
343
344
  (0, utils_2.assertIsString)(baseHref);
344
- const buildTargetOptions = buildTarget && (await architectHost.getOptionsForTarget(buildTarget));
345
+ const buildTargetOptions = buildTarget && (await tryToGetOptionsForTarget(architectHost, buildTarget));
345
346
  const ssr = buildTarget ? !!buildTargetOptions?.ssr : !!serverTarget;
346
347
  return {
347
348
  architect,
@@ -465,3 +466,10 @@ function getAngularVersion(cwd) {
465
466
  return angularVersionSemver.toString();
466
467
  }
467
468
  exports.getAngularVersion = getAngularVersion;
469
+ async function tryToGetOptionsForTarget(architectHost, target) {
470
+ return await architectHost.getOptionsForTarget(target).catch(throwCannotDetermineTarget);
471
+ }
472
+ exports.tryToGetOptionsForTarget = tryToGetOptionsForTarget;
473
+ function throwCannotDetermineTarget(error) {
474
+ throw new error_1.FirebaseError(`Unable to determine the application to deploy, specify a target via the FIREBASE_FRAMEWORKS_BUILD_TARGET environment variable.`, { original: error });
475
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MockFileSystem = void 0;
4
+ class MockFileSystem {
5
+ constructor(fileSys) {
6
+ this.fileSys = fileSys;
7
+ this.existsCache = {};
8
+ this.contentCache = {};
9
+ }
10
+ exists(path) {
11
+ if (!(path in this.existsCache)) {
12
+ this.existsCache[path] = path in this.fileSys;
13
+ }
14
+ return Promise.resolve(this.existsCache[path]);
15
+ }
16
+ read(path) {
17
+ if (!(path in this.contentCache)) {
18
+ if (!(path in this.fileSys)) {
19
+ const err = new Error("File path not found");
20
+ err.cause = "ENOENT";
21
+ throw err;
22
+ }
23
+ else {
24
+ this.contentCache[path] = this.fileSys[path];
25
+ }
26
+ }
27
+ return Promise.resolve(this.contentCache[path]);
28
+ }
29
+ getContentCache(path) {
30
+ return this.contentCache[path];
31
+ }
32
+ getExistsCache(path) {
33
+ return this.existsCache[path];
34
+ }
35
+ }
36
+ exports.MockFileSystem = MockFileSystem;
@@ -20,7 +20,7 @@ exports.FIREBASE_FRAMEWORKS_VERSION = (experiments.isEnabled("internaltesting")
20
20
  DEFAULT_FIREBASE_FRAMEWORKS_VERSION;
21
21
  exports.FIREBASE_FUNCTIONS_VERSION = "^4.5.0";
22
22
  exports.FIREBASE_ADMIN_VERSION = "^11.11.1";
23
- exports.SHARP_VERSION = "^0.32.1";
23
+ exports.SHARP_VERSION = "^0.32 || ^0.33";
24
24
  exports.NODE_VERSION = parseInt(process.versions.node, 10);
25
25
  exports.VALID_ENGINES = { node: [16, 18, 20] };
26
26
  exports.VALID_LOCALE_FORMATS = [/^ALL_[a-z]+$/, /^[a-z]+_ALL$/, /^[a-z]+(_[a-z]+)?$/];
@@ -7,8 +7,8 @@ const child_process_1 = require("child_process");
7
7
  const cross_spawn_1 = require("cross-spawn");
8
8
  const promises_1 = require("fs/promises");
9
9
  const fs_extra_1 = require("fs-extra");
10
+ const glob_1 = require("glob");
10
11
  const process = require("node:process");
11
- const glob = require("glob");
12
12
  const projectUtils_1 = require("../projectUtils");
13
13
  const config_1 = require("../hosting/config");
14
14
  const api_1 = require("../hosting/api");
@@ -365,11 +365,7 @@ async function prepareFrameworks(purpose, targetNames, context, options, emulato
365
365
  await (0, promises_1.writeFile)((0, path_1.join)(functionsDist, ".env"), `${dotEnvContents}
366
366
  __FIREBASE_FRAMEWORKS_ENTRY__=${frameworksEntry}
367
367
  ${firebaseDefaults ? `__FIREBASE_DEFAULTS__=${JSON.stringify(firebaseDefaults)}\n` : ""}`.trimStart());
368
- const envs = await new Promise((resolve, reject) => glob(getProjectPath(".env.*"), (err, matches) => {
369
- if (err)
370
- reject(err);
371
- resolve(matches);
372
- }));
368
+ const envs = await (0, glob_1.glob)(getProjectPath(".env.*"));
373
369
  await Promise.all(envs.map((path) => (0, promises_1.copyFile)(path, (0, path_1.join)(functionsDist, (0, path_1.basename)(path)))));
374
370
  (0, child_process_1.execSync)(`npm i --omit dev --no-audit`, {
375
371
  cwd: functionsDist,
@@ -11,7 +11,7 @@ exports.ROUTES_MANIFEST = "routes-manifest.json";
11
11
  exports.APP_PATHS_MANIFEST = "app-paths-manifest.json";
12
12
  exports.SERVER_REFERENCE_MANIFEST = "server-reference-manifest.json";
13
13
  exports.CONFIG_FILES = ["next.config.js", "next.config.mjs"];
14
- exports.ESBUILD_VERSION = "0.19.2";
14
+ exports.ESBUILD_VERSION = "^0.19.2";
15
15
  const WEBPACK_LAYERS_NAMES = {
16
16
  shared: "shared",
17
17
  reactServerComponents: "rsc",