firebase-tools-with-isolate 13.4.0 → 13.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.
Files changed (93) hide show
  1. package/lib/accountExporter.js +1 -1
  2. package/lib/accountImporter.js +1 -1
  3. package/lib/api.js +112 -56
  4. package/lib/apiv2.js +10 -3
  5. package/lib/appdistribution/client.js +4 -4
  6. package/lib/auth.js +17 -17
  7. package/lib/commands/hosting-disable.js +1 -1
  8. package/lib/commands/open.js +1 -1
  9. package/lib/database/metadata.js +3 -3
  10. package/lib/defaultCredentials.js +2 -2
  11. package/lib/deploy/extensions/v2FunctionHelper.js +1 -1
  12. package/lib/deploy/functions/backend.js +5 -1
  13. package/lib/deploy/functions/build.js +10 -7
  14. package/lib/deploy/functions/containerCleaner.js +4 -4
  15. package/lib/deploy/functions/deploy.js +8 -2
  16. package/lib/deploy/functions/ensure.js +1 -1
  17. package/lib/deploy/functions/prepare.js +5 -4
  18. package/lib/deploy/functions/release/fabricator.js +9 -5
  19. package/lib/deploy/functions/runtimes/discovery/index.js +2 -2
  20. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +2 -1
  21. package/lib/deploy/functions/runtimes/node/parseTriggers.js +2 -2
  22. package/lib/deploy/hosting/uploader.js +1 -1
  23. package/lib/deploy/index.js +1 -1
  24. package/lib/deploy/remoteconfig/functions.js +1 -1
  25. package/lib/emulator/adminSdkConfig.js +1 -1
  26. package/lib/emulator/commandUtils.js +7 -4
  27. package/lib/emulator/controller.js +3 -4
  28. package/lib/emulator/downloadableEmulators.js +10 -10
  29. package/lib/emulator/functionsEmulator.js +21 -1
  30. package/lib/ensureApiEnabled.js +1 -1
  31. package/lib/extensions/extensionsApi.js +5 -5
  32. package/lib/extensions/extensionsHelper.js +4 -4
  33. package/lib/extensions/provisioningHelper.js +2 -2
  34. package/lib/extensions/publishHelpers.js +1 -1
  35. package/lib/extensions/publisherApi.js +3 -3
  36. package/lib/extensions/resolveSource.js +1 -1
  37. package/lib/extensions/secretsUtils.js +1 -1
  38. package/lib/extensions/tos.js +1 -1
  39. package/lib/fetchMOTD.js +1 -1
  40. package/lib/fetchWebSetup.js +4 -3
  41. package/lib/firestore/api-sort.js +17 -0
  42. package/lib/firestore/api.js +9 -2
  43. package/lib/firestore/checkDatabaseType.js +1 -1
  44. package/lib/firestore/delete.js +1 -1
  45. package/lib/firestore/pretty-print.js +11 -2
  46. package/lib/frameworks/index.js +6 -2
  47. package/lib/frameworks/next/constants.js +38 -1
  48. package/lib/frameworks/next/index.js +25 -3
  49. package/lib/frameworks/next/utils.js +20 -1
  50. package/lib/functions/secrets.js +3 -3
  51. package/lib/functionsConfig.js +1 -1
  52. package/lib/gcp/apphosting.js +21 -15
  53. package/lib/gcp/artifactregistry.js +1 -1
  54. package/lib/gcp/auth.js +1 -1
  55. package/lib/gcp/cloudbilling.js +1 -1
  56. package/lib/gcp/cloudbuild.js +1 -1
  57. package/lib/gcp/cloudfunctions.js +1 -1
  58. package/lib/gcp/cloudfunctionsv2.js +4 -1
  59. package/lib/gcp/cloudlogging.js +1 -1
  60. package/lib/gcp/cloudmonitoring.js +1 -1
  61. package/lib/gcp/cloudscheduler.js +2 -2
  62. package/lib/gcp/cloudtasks.js +1 -1
  63. package/lib/gcp/devConnect.js +84 -0
  64. package/lib/gcp/eventarc.js +1 -1
  65. package/lib/gcp/firestore.js +2 -2
  66. package/lib/gcp/iam.js +2 -2
  67. package/lib/gcp/identityPlatform.js +1 -1
  68. package/lib/gcp/pubsub.js +1 -1
  69. package/lib/gcp/resourceManager.js +2 -1
  70. package/lib/gcp/rules.js +1 -1
  71. package/lib/gcp/run.js +1 -1
  72. package/lib/gcp/runtimeconfig.js +1 -1
  73. package/lib/gcp/secretManager.js +1 -1
  74. package/lib/gcp/serviceusage.js +1 -1
  75. package/lib/gcp/storage.js +12 -8
  76. package/lib/hosting/api.js +14 -3
  77. package/lib/hosting/cloudRunProxy.js +1 -1
  78. package/lib/init/features/apphosting/index.js +5 -5
  79. package/lib/init/features/apphosting/repo.js +84 -99
  80. package/lib/init/features/database.js +1 -1
  81. package/lib/init/features/extensions/index.js +1 -1
  82. package/lib/init/features/functions/index.js +2 -2
  83. package/lib/init/features/hosting/github.js +4 -3
  84. package/lib/management/apps.js +4 -4
  85. package/lib/management/database.js +1 -1
  86. package/lib/management/projects.js +4 -4
  87. package/lib/remoteconfig/get.js +1 -1
  88. package/lib/remoteconfig/rollback.js +1 -1
  89. package/lib/remoteconfig/versionslist.js +1 -1
  90. package/lib/serve/functions.js +2 -0
  91. package/lib/shortenUrl.js +2 -2
  92. package/lib/utils.js +1 -1
  93. package/package.json +5 -5
@@ -40,10 +40,10 @@ async function prepare(context, options, payload) {
40
40
  (0, utils_1.logLabeledBullet)("functions", `preparing codebase ${clc.bold(codebase)} for deployment`);
41
41
  }
42
42
  const checkAPIsEnabled = await Promise.all([
43
- ensureApiEnabled.ensure(projectId, api_1.functionsOrigin, "functions"),
44
- ensureApiEnabled.check(projectId, api_1.runtimeconfigOrigin, "runtimeconfig", true),
43
+ ensureApiEnabled.ensure(projectId, (0, api_1.functionsOrigin)(), "functions"),
44
+ ensureApiEnabled.check(projectId, (0, api_1.runtimeconfigOrigin)(), "runtimeconfig", true),
45
45
  ensure.cloudBuildEnabled(projectId),
46
- ensureApiEnabled.ensure(projectId, api_1.artifactRegistryDomain, "artifactregistry"),
46
+ ensureApiEnabled.ensure(projectId, (0, api_1.artifactRegistryDomain)(), "artifactregistry"),
47
47
  ]);
48
48
  const firebaseConfig = await functionsConfig.getFirebaseConfig(options);
49
49
  context.firebaseConfig = firebaseConfig;
@@ -157,7 +157,7 @@ async function prepare(context, options, payload) {
157
157
  return ensureApiEnabled.ensure(projectId, api, "functions", false);
158
158
  }));
159
159
  if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv2")) {
160
- const V2_APIS = [api_1.cloudRunApiOrigin, api_1.eventarcOrigin, api_1.pubsubOrigin, api_1.storageOrigin];
160
+ const V2_APIS = [(0, api_1.cloudRunApiOrigin)(), (0, api_1.eventarcOrigin)(), (0, api_1.pubsubOrigin)(), (0, api_1.storageOrigin)()];
161
161
  const enablements = V2_APIS.map((api) => {
162
162
  return ensureApiEnabled.ensure(context.projectId, api, "functions");
163
163
  });
@@ -187,6 +187,7 @@ function inferDetailsFromExisting(want, have, usedDotenv) {
187
187
  if (!haveE) {
188
188
  continue;
189
189
  }
190
+ wantE.runServiceId = haveE.runServiceId;
190
191
  if (!usedDotenv) {
191
192
  wantE.environmentVariables = {
192
193
  ...haveE.environmentVariables,
@@ -28,19 +28,19 @@ const v1_1 = require("../../../functions/events/v1");
28
28
  const checkIam_1 = require("../checkIam");
29
29
  const functionsDeployHelper_1 = require("../functionsDeployHelper");
30
30
  const gcfV1PollerOptions = {
31
- apiOrigin: api_1.functionsOrigin,
31
+ apiOrigin: (0, api_1.functionsOrigin)(),
32
32
  apiVersion: gcf.API_VERSION,
33
33
  masterTimeout: 25 * 60 * 1000,
34
34
  maxBackoff: 10000,
35
35
  };
36
36
  const gcfV2PollerOptions = {
37
- apiOrigin: api_1.functionsV2Origin,
37
+ apiOrigin: (0, api_1.functionsV2Origin)(),
38
38
  apiVersion: gcfV2.API_VERSION,
39
39
  masterTimeout: 25 * 60 * 1000,
40
40
  maxBackoff: 10000,
41
41
  };
42
42
  const eventarcPollerOptions = {
43
- apiOrigin: api_1.eventarcOrigin,
43
+ apiOrigin: (0, api_1.eventarcOrigin)(),
44
44
  apiVersion: "v1",
45
45
  masterTimeout: 25 * 60 * 1000,
46
46
  maxBackoff: 10000,
@@ -342,7 +342,9 @@ class Fabricator {
342
342
  .catch(rethrowAs(endpoint, "set invoker"));
343
343
  }
344
344
  else if (backend.isScheduleTriggered(endpoint)) {
345
- const invoker = [(0, checkIam_1.getDefaultComputeServiceAgent)(this.projectNumber)];
345
+ const invoker = endpoint.serviceAccount
346
+ ? [endpoint.serviceAccount]
347
+ : [(0, checkIam_1.getDefaultComputeServiceAgent)(this.projectNumber)];
346
348
  await this.executor
347
349
  .run(() => run.setInvokerCreate(endpoint.project, serviceName, invoker))
348
350
  .catch(rethrowAs(endpoint, "set invoker"));
@@ -431,7 +433,9 @@ class Fabricator {
431
433
  invoker = ["public"];
432
434
  }
433
435
  else if (backend.isScheduleTriggered(endpoint)) {
434
- invoker = [(0, checkIam_1.getDefaultComputeServiceAgent)(this.projectNumber)];
436
+ invoker = endpoint.serviceAccount
437
+ ? [endpoint.serviceAccount]
438
+ : [(0, checkIam_1.getDefaultComputeServiceAgent)(this.projectNumber)];
435
439
  }
436
440
  if (invoker) {
437
441
  await this.executor
@@ -42,7 +42,7 @@ async function detectFromYaml(directory, project, runtime) {
42
42
  }
43
43
  logger_1.logger.debug("Found functions.yaml. Got spec:", text);
44
44
  const parsed = yaml.load(text);
45
- return yamlToBuild(parsed, project, api.functionsDefaultRegion, runtime);
45
+ return yamlToBuild(parsed, project, api.functionsDefaultRegion(), runtime);
46
46
  }
47
47
  exports.detectFromYaml = detectFromYaml;
48
48
  async function detectFromPort(port, project, runtime, timeout = 10000) {
@@ -80,6 +80,6 @@ async function detectFromPort(port, project, runtime, timeout = 10000) {
80
80
  logger_1.logger.debug("Failed to parse functions.yaml", err);
81
81
  throw new error_1.FirebaseError(`Failed to load function definition from source: ${text}`);
82
82
  }
83
- return yamlToBuild(parsed, project, api.functionsDefaultRegion, runtime);
83
+ return yamlToBuild(parsed, project, api.functionsDefaultRegion(), runtime);
84
84
  }
85
85
  exports.detectFromPort = detectFromPort;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildFromV1Alpha1 = void 0;
4
4
  const build = require("../../build");
5
+ const backend = require("../../backend");
5
6
  const proto_1 = require("../../../../gcp/proto");
6
7
  const parsing_1 = require("./parsing");
7
8
  const error_1 = require("../../../../error");
@@ -52,7 +53,7 @@ function assertBuildEndpoint(ep, id) {
52
53
  platform: (platform) => build.AllFunctionsPlatforms.includes(platform),
53
54
  entryPoint: "string",
54
55
  omit: "Field<boolean>?",
55
- availableMemoryMb: (mem) => mem === null || isCEL(mem) || build.isValidMemoryOption(mem),
56
+ availableMemoryMb: (mem) => mem === null || isCEL(mem) || backend.isValidMemoryOption(mem),
56
57
  maxInstances: "Field<number>?",
57
58
  minInstances: "Field<number>?",
58
59
  concurrency: "Field<number>?",
@@ -91,7 +91,7 @@ exports.mergeRequiredAPIs = mergeRequiredAPIs;
91
91
  function addResourcesToBuild(projectId, runtime, annotation, want) {
92
92
  Object.freeze(annotation);
93
93
  const toSeconds = (0, functional_1.nullsafeVisitor)(proto.secondsFromDuration);
94
- const regions = annotation.regions || [api.functionsDefaultRegion];
94
+ const regions = annotation.regions || [api.functionsDefaultRegion()];
95
95
  let triggered;
96
96
  const triggerCount = +!!annotation.httpsTrigger +
97
97
  +!!annotation.eventTrigger +
@@ -219,7 +219,7 @@ function addResourcesToBuild(projectId, runtime, annotation, want) {
219
219
  exports.addResourcesToBuild = addResourcesToBuild;
220
220
  function addResourcesToBackend(projectId, runtime, annotation, want) {
221
221
  Object.freeze(annotation);
222
- for (const region of annotation.regions || [api.functionsDefaultRegion]) {
222
+ for (const region of annotation.regions || [api.functionsDefaultRegion()]) {
223
223
  let triggered;
224
224
  const triggerCount = +!!annotation.httpsTrigger +
225
225
  +!!annotation.eventTrigger +
@@ -24,7 +24,7 @@ function progressMessage(message, current, total) {
24
24
  class Uploader {
25
25
  constructor(options) {
26
26
  this.hashClient = new apiv2_1.Client({
27
- urlPrefix: api_1.hostingApiOrigin,
27
+ urlPrefix: (0, api_1.hostingApiOrigin)(),
28
28
  auth: true,
29
29
  apiVersion: "v1beta1",
30
30
  });
@@ -115,7 +115,7 @@ const deploy = async function (targetNames, options, customContext = {}) {
115
115
  logger_1.logger.info((0, colorette_1.bold)("Project Console:"), (0, utils_1.consoleUrl)(options.project, "/overview"));
116
116
  if (deployedHosting) {
117
117
  (0, lodash_1.each)(context.hosting.deploys, (deploy) => {
118
- logger_1.logger.info((0, colorette_1.bold)("Hosting URL:"), (0, utils_1.addSubdomain)(api_1.hostingOrigin, deploy.config.site));
118
+ logger_1.logger.info((0, colorette_1.bold)("Hosting URL:"), (0, utils_1.addSubdomain)((0, api_1.hostingOrigin)(), deploy.config.site));
119
119
  });
120
120
  const versionNames = context.hosting.deploys.map((deploy) => deploy.version);
121
121
  return { hosting: versionNames.length === 1 ? versionNames[0] : versionNames };
@@ -5,7 +5,7 @@ const api_1 = require("../../api");
5
5
  const apiv2_1 = require("../../apiv2");
6
6
  const error_1 = require("../../error");
7
7
  const TIMEOUT = 30000;
8
- const client = new apiv2_1.Client({ urlPrefix: api_1.remoteConfigApiOrigin, apiVersion: "v1" });
8
+ const client = new apiv2_1.Client({ urlPrefix: (0, api_1.remoteConfigApiOrigin)(), apiVersion: "v1" });
9
9
  async function getEtag(projectNumber, versionNumber) {
10
10
  const reqPath = `/projects/${projectNumber}/remoteConfig`;
11
11
  const queryParams = {};
@@ -35,7 +35,7 @@ async function getProjectAdminSdkConfig(projectId) {
35
35
  const apiClient = new apiv2.Client({
36
36
  auth: true,
37
37
  apiVersion: "v1beta1",
38
- urlPrefix: api_1.firebaseApiOrigin,
38
+ urlPrefix: (0, api_1.firebaseApiOrigin)(),
39
39
  });
40
40
  if (projectId.startsWith("demo-")) {
41
41
  logger_1.logger.debug(`Detected demo- project: ${projectId}. Using default adminSdkConfig instead of calling firebase API.`);
@@ -120,13 +120,16 @@ async function beforeEmulatorCommand(options) {
120
120
  }
121
121
  exports.beforeEmulatorCommand = beforeEmulatorCommand;
122
122
  function parseInspectionPort(options) {
123
- let port = options.inspectFunctions;
124
- if (port === true) {
125
- port = "9229";
123
+ const port = options.inspectFunctions;
124
+ if (typeof port === "undefined") {
125
+ return false;
126
+ }
127
+ else if (typeof port === "boolean") {
128
+ return port;
126
129
  }
127
130
  const parsed = Number(port);
128
131
  if (isNaN(parsed) || parsed < 1024 || parsed > 65535) {
129
- throw new error_1.FirebaseError(`"${port}" is not a valid port for debugging, please pass an integer between 1024 and 65535.`);
132
+ throw new error_1.FirebaseError(`"${port}" is not a valid port for debugging, please pass an integer between 1024 and 65535 or true for a dynamic port.`);
130
133
  }
131
134
  return parsed;
132
135
  }
@@ -336,10 +336,9 @@ async function startAll(options, showUI = true, runningTestScript = false) {
336
336
  const functionsLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.FUNCTIONS);
337
337
  const functionsAddr = legacyGetFirstAddr(types_1.Emulators.FUNCTIONS);
338
338
  const projectId = (0, projectUtils_1.needProjectId)(options);
339
- let inspectFunctions;
340
- if (options.inspectFunctions) {
341
- inspectFunctions = commandUtils.parseInspectionPort(options);
342
- functionsLogger.logLabeled("WARN", "functions", `You are running the Functions emulator in debug mode (port=${inspectFunctions}). This means that functions will execute in sequence rather than in parallel.`);
339
+ const inspectFunctions = commandUtils.parseInspectionPort(options);
340
+ if (inspectFunctions) {
341
+ functionsLogger.logLabeled("WARN", "functions", `You are running the Functions emulator in debug mode. This means that functions will execute in sequence rather than in parallel.`);
343
342
  }
344
343
  const emulatorsNotRunning = types_1.ALL_SERVICE_EMULATORS.filter((e) => {
345
344
  return e !== types_1.Emulators.FUNCTIONS && !listenForEmulator[e];
@@ -23,9 +23,9 @@ const EMULATOR_UPDATE_DETAILS = {
23
23
  expectedChecksum: "2fd771101c0e1f7898c04c9204f2ce63",
24
24
  },
25
25
  firestore: {
26
- version: "1.19.1",
27
- expectedSize: 67187672,
28
- expectedChecksum: "859b1ac2a6040cccddd993c43586347c",
26
+ version: "1.19.4",
27
+ expectedSize: 65913000,
28
+ expectedChecksum: "a861bfa9d12ef69645b41e2f3bd8db8d",
29
29
  },
30
30
  storage: {
31
31
  version: "1.1.3",
@@ -35,14 +35,14 @@ const EMULATOR_UPDATE_DETAILS = {
35
35
  ui: experiments.isEnabled("emulatoruisnapshot")
36
36
  ? { version: "SNAPSHOT", expectedSize: -1, expectedChecksum: "" }
37
37
  : {
38
- version: "1.11.7",
39
- expectedSize: 3064105,
40
- expectedChecksum: "bd2bcc331cbf613a5b3b55a1ce08998b",
38
+ version: "1.11.8",
39
+ expectedSize: 3523907,
40
+ expectedChecksum: "49f6dc1911dda9d10df62a6c09aaf9a0",
41
41
  },
42
42
  pubsub: {
43
- version: "0.7.1",
44
- expectedSize: 65137179,
45
- expectedChecksum: "b59a6e705031a54a69e5e1dced7ca9bf",
43
+ version: "0.8.2",
44
+ expectedSize: 65611398,
45
+ expectedChecksum: "70bb840321423e6ae621a3ae2f314903",
46
46
  },
47
47
  };
48
48
  exports.DownloadDetails = {
@@ -83,7 +83,7 @@ exports.DownloadDetails = {
83
83
  version: EMULATOR_UPDATE_DETAILS.ui.version,
84
84
  downloadPath: path.join(CACHE_DIR, `ui-v${EMULATOR_UPDATE_DETAILS.ui.version}.zip`),
85
85
  unzipDir: path.join(CACHE_DIR, `ui-v${EMULATOR_UPDATE_DETAILS.ui.version}`),
86
- binaryPath: path.join(CACHE_DIR, `ui-v${EMULATOR_UPDATE_DETAILS.ui.version}`, "server", "server.js"),
86
+ binaryPath: path.join(CACHE_DIR, `ui-v${EMULATOR_UPDATE_DETAILS.ui.version}`, "server", "server.mjs"),
87
87
  opts: {
88
88
  cacheDir: CACHE_DIR,
89
89
  remoteUrl: `https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v${EMULATOR_UPDATE_DETAILS.ui.version}.zip`,
@@ -84,6 +84,11 @@ class FunctionsEmulator {
84
84
  this.debugMode = false;
85
85
  emulatorLogger_1.EmulatorLogger.setVerbosity(this.args.verbosity ? emulatorLogger_1.Verbosity[this.args.verbosity] : emulatorLogger_1.Verbosity["DEBUG"]);
86
86
  if (this.args.debugPort) {
87
+ const maybeNodeCodebases = this.args.emulatableBackends.filter((b) => !b.runtime || b.runtime.startsWith("node"));
88
+ if (maybeNodeCodebases.length > 1 && typeof this.args.debugPort === "number") {
89
+ throw new error_1.FirebaseError("Cannot debug on a single port with multiple codebases. " +
90
+ "Use --inspect-functions=true to assign dynamic ports to each codebase");
91
+ }
87
92
  this.args.disabledRuntimeFeatures = this.args.disabledRuntimeFeatures || {};
88
93
  this.args.disabledRuntimeFeatures.timeout = true;
89
94
  this.debugMode = true;
@@ -869,8 +874,22 @@ class FunctionsEmulator {
869
874
  this.logger.log("WARN", `To enable function inspection, please run "npm i node@${semver.coerce(backend.runtime || "18.0.0")} --save-dev" in your functions directory`);
870
875
  }
871
876
  else {
877
+ let port;
878
+ if (typeof this.args.debugPort === "number") {
879
+ port = this.args.debugPort;
880
+ }
881
+ else {
882
+ port = await portfinder.getPortPromise({ port: 9229 });
883
+ if (port === 9229) {
884
+ this.logger.logLabeled("SUCCESS", "functions", `Using debug port 9229 for functions codebase ${backend.codebase}`);
885
+ }
886
+ else {
887
+ this.logger.logLabeled("SUCCESS", "functions", `Using debug port ${port} for functions codebase ${backend.codebase}. ` +
888
+ "You may need to add manually add this port to your inspector.");
889
+ }
890
+ }
872
891
  const { host } = this.getInfo();
873
- args.unshift(`--inspect=${(0, utils_1.connectableHostname)(host)}:${this.args.debugPort}`);
892
+ args.unshift(`--inspect=${(0, utils_1.connectableHostname)(host)}:${port}`);
874
893
  }
875
894
  }
876
895
  const pnpPath = path.join(backend.functionsDir, ".pnp.js");
@@ -889,6 +908,7 @@ class FunctionsEmulator {
889
908
  cwd: backend.functionsDir,
890
909
  env: {
891
910
  node: backend.bin,
911
+ METADATA_SERVER_DETECTION: "none",
892
912
  ...process.env,
893
913
  ...envs,
894
914
  PORT: socketPath,
@@ -12,7 +12,7 @@ exports.POLL_SETTINGS = {
12
12
  pollsBeforeRetry: 12,
13
13
  };
14
14
  const apiClient = new apiv2_1.Client({
15
- urlPrefix: api_1.serviceUsageOrigin,
15
+ urlPrefix: (0, api_1.serviceUsageOrigin)(),
16
16
  apiVersion: "v1",
17
17
  });
18
18
  async function check(projectId, apiUri, prefix, silent = false) {
@@ -12,7 +12,7 @@ const refs = require("./refs");
12
12
  const EXTENSIONS_API_VERSION = "v1beta";
13
13
  const PAGE_SIZE_MAX = 100;
14
14
  const extensionsApiClient = new apiv2_1.Client({
15
- urlPrefix: api_1.extensionsOrigin,
15
+ urlPrefix: (0, api_1.extensionsOrigin)(),
16
16
  apiVersion: EXTENSIONS_API_VERSION,
17
17
  });
18
18
  async function createInstanceHelper(projectId, instanceId, config, validateOnly = false) {
@@ -28,7 +28,7 @@ async function createInstanceHelper(projectId, instanceId, config, validateOnly
28
28
  return createRes.body;
29
29
  }
30
30
  const pollRes = await operationPoller.pollOperation({
31
- apiOrigin: api_1.extensionsOrigin,
31
+ apiOrigin: (0, api_1.extensionsOrigin)(),
32
32
  apiVersion: EXTENSIONS_API_VERSION,
33
33
  operationResourceName: createRes.body.name,
34
34
  masterTimeout: 3600000,
@@ -68,7 +68,7 @@ exports.createInstance = createInstance;
68
68
  async function deleteInstance(projectId, instanceId) {
69
69
  const deleteRes = await extensionsApiClient.delete(`/projects/${projectId}/instances/${instanceId}`);
70
70
  const pollRes = await operationPoller.pollOperation({
71
- apiOrigin: api_1.extensionsOrigin,
71
+ apiOrigin: (0, api_1.extensionsOrigin)(),
72
72
  apiVersion: EXTENSIONS_API_VERSION,
73
73
  operationResourceName: deleteRes.body.name,
74
74
  masterTimeout: 600000,
@@ -213,7 +213,7 @@ async function patchInstance(args) {
213
213
  return updateRes;
214
214
  }
215
215
  const pollRes = await operationPoller.pollOperation({
216
- apiOrigin: api_1.extensionsOrigin,
216
+ apiOrigin: (0, api_1.extensionsOrigin)(),
217
217
  apiVersion: EXTENSIONS_API_VERSION,
218
218
  operationResourceName: updateRes.body.name,
219
219
  masterTimeout: 600000,
@@ -243,7 +243,7 @@ async function createSource(projectId, packageUri, extensionRoot) {
243
243
  extensionRoot,
244
244
  });
245
245
  const pollRes = await operationPoller.pollOperation({
246
- apiOrigin: api_1.extensionsOrigin,
246
+ apiOrigin: (0, api_1.extensionsOrigin)(),
247
247
  apiVersion: EXTENSIONS_API_VERSION,
248
248
  operationResourceName: createRes.body.name,
249
249
  masterTimeout: 600000,
@@ -352,7 +352,7 @@ async function ensureExtensionsApiEnabled(options) {
352
352
  if (!projectId) {
353
353
  return;
354
354
  }
355
- return await (0, ensureApiEnabled_1.ensure)(projectId, api_1.extensionsOrigin, "extensions", options.markdown);
355
+ return await (0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.extensionsOrigin)(), "extensions", options.markdown);
356
356
  }
357
357
  exports.ensureExtensionsApiEnabled = ensureExtensionsApiEnabled;
358
358
  async function ensureExtensionsPublisherApiEnabled(options) {
@@ -360,7 +360,7 @@ async function ensureExtensionsPublisherApiEnabled(options) {
360
360
  if (!projectId) {
361
361
  return;
362
362
  }
363
- return await (0, ensureApiEnabled_1.ensure)(projectId, api_1.extensionsPublisherOrigin, "extensions", options.markdown);
363
+ return await (0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.extensionsPublisherOrigin)(), "extensions", options.markdown);
364
364
  }
365
365
  exports.ensureExtensionsPublisherApiEnabled = ensureExtensionsPublisherApiEnabled;
366
366
  async function archiveAndUploadSource(extPath, bucketName) {
@@ -671,7 +671,7 @@ async function uploadExtensionVersionFromLocalSource(args) {
671
671
  uploadSpinner.start();
672
672
  objectPath = await archiveAndUploadSource(args.rootDirectory, exports.EXTENSIONS_BUCKET_NAME);
673
673
  uploadSpinner.succeed("Uploaded extension source code");
674
- packageUri = api_1.storageOrigin + objectPath + "?alt=media";
674
+ packageUri = (0, api_1.storageOrigin)() + objectPath + "?alt=media";
675
675
  }
676
676
  catch (err) {
677
677
  uploadSpinner.fail();
@@ -710,7 +710,7 @@ async function createSourceFromLocation(projectId, sourceUri) {
710
710
  spinner.start();
711
711
  objectPath = await archiveAndUploadSource(sourceUri, exports.EXTENSIONS_BUCKET_NAME);
712
712
  spinner.succeed(" Uploaded extension source code");
713
- packageUri = api_1.storageOrigin + objectPath + "?alt=media";
713
+ packageUri = (0, api_1.storageOrigin)() + objectPath + "?alt=media";
714
714
  const res = await (0, extensionsApi_1.createSource)(projectId, packageUri, extensionRoot);
715
715
  logger_1.logger.debug("Created new Extension Source %s", res.name);
716
716
  await deleteUploadedSource(objectPath);
@@ -89,7 +89,7 @@ function getTriggerType(propertiesYaml) {
89
89
  return propertiesYaml?.match(/eventType:\ ([\S]+)/)?.[1];
90
90
  }
91
91
  async function isStorageProvisioned(projectId) {
92
- const client = new apiv2_1.Client({ urlPrefix: api_1.firebaseStorageOrigin, apiVersion: "v1beta" });
92
+ const client = new apiv2_1.Client({ urlPrefix: (0, api_1.firebaseStorageOrigin)(), apiVersion: "v1beta" });
93
93
  const resp = await client.get(`/projects/${projectId}/buckets`);
94
94
  return !!resp.body?.buckets?.find((bucket) => {
95
95
  const bucketResourceName = bucket.name;
@@ -99,7 +99,7 @@ async function isStorageProvisioned(projectId) {
99
99
  });
100
100
  }
101
101
  async function isAuthProvisioned(projectId) {
102
- const client = new apiv2_1.Client({ urlPrefix: api_1.firedataOrigin, apiVersion: "v1" });
102
+ const client = new apiv2_1.Client({ urlPrefix: (0, api_1.firedataOrigin)(), apiVersion: "v1" });
103
103
  const resp = await client.get(`/projects/${projectId}/products`);
104
104
  return !!resp.body?.activation?.map((a) => a.service).includes("FIREBASE_AUTH");
105
105
  }
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.consoleInstallLink = void 0;
4
4
  const api_1 = require("../api");
5
5
  function consoleInstallLink(extVersionRef) {
6
- return `${api_1.consoleOrigin}/project/_/extensions/install?ref=${extVersionRef}`;
6
+ return `${(0, api_1.consoleOrigin)()}/project/_/extensions/install?ref=${extVersionRef}`;
7
7
  }
8
8
  exports.consoleInstallLink = consoleInstallLink;
@@ -11,7 +11,7 @@ const extensionsApi_1 = require("./extensionsApi");
11
11
  const PUBLISHER_API_VERSION = "v1beta";
12
12
  const PAGE_SIZE_MAX = 100;
13
13
  const extensionsPublisherApiClient = new apiv2_1.Client({
14
- urlPrefix: api_1.extensionsPublisherOrigin,
14
+ urlPrefix: (0, api_1.extensionsPublisherOrigin)(),
15
15
  apiVersion: PUBLISHER_API_VERSION,
16
16
  });
17
17
  async function getPublisherProfile(projectId, publisherId) {
@@ -96,7 +96,7 @@ async function createExtensionVersionFromLocalSource(args) {
96
96
  },
97
97
  });
98
98
  const pollRes = await operationPoller.pollOperation({
99
- apiOrigin: api_1.extensionsPublisherOrigin,
99
+ apiOrigin: (0, api_1.extensionsPublisherOrigin)(),
100
100
  apiVersion: PUBLISHER_API_VERSION,
101
101
  operationResourceName: uploadRes.body.name,
102
102
  masterTimeout: 600000,
@@ -118,7 +118,7 @@ async function createExtensionVersionFromGitHubSource(args) {
118
118
  },
119
119
  });
120
120
  const pollRes = await operationPoller.pollOperation({
121
- apiOrigin: api_1.extensionsPublisherOrigin,
121
+ apiOrigin: (0, api_1.extensionsPublisherOrigin)(),
122
122
  apiVersion: PUBLISHER_API_VERSION,
123
123
  operationResourceName: uploadRes.body.name,
124
124
  masterTimeout: 600000,
@@ -5,7 +5,7 @@ const apiv2_1 = require("../apiv2");
5
5
  const api_1 = require("../api");
6
6
  const EXTENSIONS_REGISTRY_ENDPOINT = "/extensions.json";
7
7
  async function getExtensionRegistry(onlyFeatured = false) {
8
- const client = new apiv2_1.Client({ urlPrefix: api_1.firebaseExtensionsRegistryOrigin });
8
+ const client = new apiv2_1.Client({ urlPrefix: (0, api_1.firebaseExtensionsRegistryOrigin)() });
9
9
  const res = await client.get(EXTENSIONS_REGISTRY_ENDPOINT);
10
10
  const extensions = res.body.mods || {};
11
11
  if (onlyFeatured) {
@@ -13,7 +13,7 @@ exports.SECRET_LABEL = "firebase-extensions-managed";
13
13
  exports.SECRET_ROLE = "secretmanager.secretAccessor";
14
14
  async function ensureSecretManagerApiEnabled(options) {
15
15
  const projectId = (0, projectUtils_1.needProjectId)(options);
16
- return await (0, ensureApiEnabled_1.ensure)(projectId, api_1.secretManagerOrigin, "extensions", options.markdown);
16
+ return await (0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.secretManagerOrigin)(), "extensions", options.markdown);
17
17
  }
18
18
  exports.ensureSecretManagerApiEnabled = ensureSecretManagerApiEnabled;
19
19
  function usesSecrets(spec) {
@@ -10,7 +10,7 @@ const extensionsHelper_1 = require("./extensionsHelper");
10
10
  const utils = require("../utils");
11
11
  const VERSION = "v1";
12
12
  const extensionsTosUrl = (tos) => `https://firebase.google.com/terms/extensions/${tos}`;
13
- const apiClient = new apiv2_1.Client({ urlPrefix: api_1.extensionsTOSOrigin, apiVersion: VERSION });
13
+ const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.extensionsTOSOrigin)(), apiVersion: VERSION });
14
14
  async function getAppDeveloperTOSStatus(projectId) {
15
15
  const res = await apiClient.get(`/projects/${projectId}/appdevtos`);
16
16
  return res.body;
package/lib/fetchMOTD.js CHANGED
@@ -29,7 +29,7 @@ function fetchMOTD() {
29
29
  }
30
30
  }
31
31
  else {
32
- const origin = utils.addSubdomain(api_1.realtimeOrigin, "firebase-public");
32
+ const origin = utils.addSubdomain((0, api_1.realtimeOrigin)(), "firebase-public");
33
33
  const c = new apiv2_1.Client({ urlPrefix: origin, auth: false });
34
34
  c.get("/cli.json")
35
35
  .then((res) => {
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchWebSetup = exports.getCachedWebSetup = void 0;
3
+ exports.fetchWebSetup = exports.constructDefaultWebSetup = exports.getCachedWebSetup = void 0;
4
4
  const apiv2_1 = require("./apiv2");
5
5
  const configstore_1 = require("./configstore");
6
6
  const api_1 = require("./api");
7
7
  const projectUtils_1 = require("./projectUtils");
8
8
  const logger_1 = require("./logger");
9
9
  const constants_1 = require("./emulator/constants");
10
- const apiClient = new apiv2_1.Client({ urlPrefix: api_1.firebaseApiOrigin, auth: true, apiVersion: "v1beta1" });
10
+ const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.firebaseApiOrigin)(), auth: true, apiVersion: "v1beta1" });
11
11
  const hostingApiClient = new apiv2_1.Client({
12
- urlPrefix: api_1.hostingApiOrigin,
12
+ urlPrefix: (0, api_1.hostingApiOrigin)(),
13
13
  auth: true,
14
14
  apiVersion: "v1beta1",
15
15
  });
@@ -46,6 +46,7 @@ function constructDefaultWebSetup(projectId) {
46
46
  authDomain: `${projectId}.firebaseapp.com`,
47
47
  };
48
48
  }
49
+ exports.constructDefaultWebSetup = constructDefaultWebSetup;
49
50
  async function fetchWebSetup(options) {
50
51
  const projectId = (0, projectUtils_1.needProjectId)(options);
51
52
  if (constants_1.Constants.isDemoProject(projectId)) {
@@ -100,6 +100,9 @@ function compareIndexField(a, b) {
100
100
  if (a.arrayConfig !== b.arrayConfig) {
101
101
  return compareArrayConfig(a.arrayConfig, b.arrayConfig);
102
102
  }
103
+ if (a.vectorConfig !== b.vectorConfig) {
104
+ return compareVectorConfig(a.vectorConfig, b.vectorConfig);
105
+ }
103
106
  return 0;
104
107
  }
105
108
  function compareFieldIndex(a, b) {
@@ -123,6 +126,20 @@ function compareOrder(a, b) {
123
126
  function compareArrayConfig(a, b) {
124
127
  return ARRAY_CONFIG_SEQUENCE.indexOf(a) - ARRAY_CONFIG_SEQUENCE.indexOf(b);
125
128
  }
129
+ function compareVectorConfig(a, b) {
130
+ if (!a) {
131
+ if (!b) {
132
+ return 0;
133
+ }
134
+ else {
135
+ return 1;
136
+ }
137
+ }
138
+ else if (!b) {
139
+ return -1;
140
+ }
141
+ return a.dimension - b.dimension;
142
+ }
126
143
  function compareArrays(a, b, fn) {
127
144
  const minFields = Math.min(a.length, b.length);
128
145
  for (let i = 0; i < minFields; i++) {
@@ -15,7 +15,7 @@ const apiv2_1 = require("../apiv2");
15
15
  const pretty_print_1 = require("./pretty-print");
16
16
  class FirestoreApi {
17
17
  constructor() {
18
- this.apiClient = new apiv2_1.Client({ urlPrefix: api_1.firestoreOrigin, apiVersion: "v1" });
18
+ this.apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.firestoreOrigin)(), apiVersion: "v1" });
19
19
  this.printer = new pretty_print_1.PrettyPrint();
20
20
  }
21
21
  async deploy(options, indexes, fieldOverrides, databaseId = "(default)") {
@@ -204,13 +204,17 @@ class FirestoreApi {
204
204
  validator.assertHas(index, "fields");
205
205
  index.fields.forEach((field) => {
206
206
  validator.assertHas(field, "fieldPath");
207
- validator.assertHasOneOf(field, ["order", "arrayConfig"]);
207
+ validator.assertHasOneOf(field, ["order", "arrayConfig", "vectorConfig"]);
208
208
  if (field.order) {
209
209
  validator.assertEnum(field, "order", Object.keys(types.Order));
210
210
  }
211
211
  if (field.arrayConfig) {
212
212
  validator.assertEnum(field, "arrayConfig", Object.keys(types.ArrayConfig));
213
213
  }
214
+ if (field.vectorConfig) {
215
+ validator.assertType("vectorConfig.dimension", field.vectorConfig.dimension, "number");
216
+ validator.assertHas(field.vectorConfig, "flat");
217
+ }
214
218
  });
215
219
  }
216
220
  validateField(field) {
@@ -373,6 +377,9 @@ class FirestoreApi {
373
377
  else if (field.arrayConfig) {
374
378
  f.arrayConfig = field.arrayConfig;
375
379
  }
380
+ else if (field.vectorConfig) {
381
+ f.vectorConfig = field.vectorConfig;
382
+ }
376
383
  else if (field.mode === types.Mode.ARRAY_CONTAINS) {
377
384
  f.arrayConfig = types.ArrayConfig.CONTAINS;
378
385
  }
@@ -6,7 +6,7 @@ const apiv2_1 = require("../apiv2");
6
6
  const logger_1 = require("../logger");
7
7
  async function checkDatabaseType(projectId) {
8
8
  try {
9
- const client = new apiv2_1.Client({ urlPrefix: api_1.firestoreOrigin, apiVersion: "v1" });
9
+ const client = new apiv2_1.Client({ urlPrefix: (0, api_1.firestoreOrigin)(), apiVersion: "v1" });
10
10
  const resp = await client.get(`/projects/${projectId}/databases/(default)`);
11
11
  return resp.body.type;
12
12
  }
@@ -41,7 +41,7 @@ class FirestoreDelete {
41
41
  this.apiClient = new apiv2.Client({
42
42
  auth: true,
43
43
  apiVersion: "v1",
44
- urlPrefix: api_1.firestoreOriginOrEmulator,
44
+ urlPrefix: (0, api_1.firestoreOriginOrEmulator)(),
45
45
  });
46
46
  }
47
47
  setDeleteBatchSize(size) {
@@ -140,8 +140,17 @@ class PrettyPrint {
140
140
  if (field.fieldPath === "__name__") {
141
141
  return;
142
142
  }
143
- const orderOrArrayConfig = field.order ? field.order : field.arrayConfig;
144
- result += `(${field.fieldPath},${orderOrArrayConfig}) `;
143
+ let configString;
144
+ if (field.order) {
145
+ configString = field.order;
146
+ }
147
+ else if (field.arrayConfig) {
148
+ configString = field.arrayConfig;
149
+ }
150
+ else if (field.vectorConfig) {
151
+ configString = `VECTOR<${field.vectorConfig.dimension}>`;
152
+ }
153
+ result += `(${field.fieldPath},${configString}) `;
145
154
  });
146
155
  return result;
147
156
  }