firebase-tools-with-isolate 13.3.1 → 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 (96) hide show
  1. package/lib/accountExporter.js +1 -1
  2. package/lib/accountImporter.js +1 -1
  3. package/lib/api.js +112 -55
  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/apphosting-backends-delete.js +3 -38
  8. package/lib/commands/apphosting-backends-get.js +2 -32
  9. package/lib/commands/apphosting-backends-list.js +12 -5
  10. package/lib/commands/hosting-disable.js +1 -1
  11. package/lib/commands/open.js +1 -1
  12. package/lib/database/metadata.js +3 -3
  13. package/lib/defaultCredentials.js +2 -2
  14. package/lib/deploy/extensions/v2FunctionHelper.js +2 -1
  15. package/lib/deploy/functions/backend.js +5 -1
  16. package/lib/deploy/functions/build.js +10 -7
  17. package/lib/deploy/functions/containerCleaner.js +4 -4
  18. package/lib/deploy/functions/deploy.js +8 -2
  19. package/lib/deploy/functions/ensure.js +2 -2
  20. package/lib/deploy/functions/prepare.js +6 -9
  21. package/lib/deploy/functions/release/fabricator.js +9 -5
  22. package/lib/deploy/functions/runtimes/discovery/index.js +2 -2
  23. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +2 -1
  24. package/lib/deploy/functions/runtimes/node/parseTriggers.js +2 -2
  25. package/lib/deploy/hosting/uploader.js +1 -1
  26. package/lib/deploy/index.js +1 -1
  27. package/lib/deploy/remoteconfig/functions.js +1 -1
  28. package/lib/emulator/adminSdkConfig.js +1 -1
  29. package/lib/emulator/commandUtils.js +7 -4
  30. package/lib/emulator/controller.js +3 -4
  31. package/lib/emulator/downloadableEmulators.js +10 -10
  32. package/lib/emulator/functionsEmulator.js +21 -1
  33. package/lib/ensureApiEnabled.js +9 -7
  34. package/lib/extensions/extensionsApi.js +5 -5
  35. package/lib/extensions/extensionsHelper.js +4 -4
  36. package/lib/extensions/provisioningHelper.js +2 -2
  37. package/lib/extensions/publishHelpers.js +1 -1
  38. package/lib/extensions/publisherApi.js +3 -3
  39. package/lib/extensions/resolveSource.js +1 -1
  40. package/lib/extensions/secretsUtils.js +2 -1
  41. package/lib/extensions/tos.js +1 -1
  42. package/lib/fetchMOTD.js +1 -1
  43. package/lib/fetchWebSetup.js +4 -3
  44. package/lib/firestore/api-sort.js +17 -0
  45. package/lib/firestore/api.js +9 -2
  46. package/lib/firestore/checkDatabaseType.js +1 -1
  47. package/lib/firestore/delete.js +1 -1
  48. package/lib/firestore/pretty-print.js +11 -2
  49. package/lib/frameworks/index.js +6 -2
  50. package/lib/frameworks/next/constants.js +38 -1
  51. package/lib/frameworks/next/index.js +25 -3
  52. package/lib/frameworks/next/utils.js +20 -1
  53. package/lib/functions/secrets.js +3 -3
  54. package/lib/functionsConfig.js +1 -1
  55. package/lib/gcp/apphosting.js +22 -17
  56. package/lib/gcp/artifactregistry.js +1 -1
  57. package/lib/gcp/auth.js +6 -3
  58. package/lib/gcp/cloudbilling.js +1 -1
  59. package/lib/gcp/cloudbuild.js +1 -1
  60. package/lib/gcp/cloudfunctions.js +1 -1
  61. package/lib/gcp/cloudfunctionsv2.js +4 -1
  62. package/lib/gcp/cloudlogging.js +1 -1
  63. package/lib/gcp/cloudmonitoring.js +1 -1
  64. package/lib/gcp/cloudscheduler.js +2 -2
  65. package/lib/gcp/cloudtasks.js +1 -1
  66. package/lib/gcp/devConnect.js +84 -0
  67. package/lib/gcp/eventarc.js +1 -1
  68. package/lib/gcp/firestore.js +2 -2
  69. package/lib/gcp/iam.js +2 -2
  70. package/lib/gcp/identityPlatform.js +1 -1
  71. package/lib/gcp/pubsub.js +1 -1
  72. package/lib/gcp/resourceManager.js +2 -1
  73. package/lib/gcp/rules.js +1 -1
  74. package/lib/gcp/run.js +1 -1
  75. package/lib/gcp/runtimeconfig.js +1 -1
  76. package/lib/gcp/secretManager.js +1 -1
  77. package/lib/gcp/serviceusage.js +1 -1
  78. package/lib/gcp/storage.js +12 -8
  79. package/lib/hosting/api.js +14 -3
  80. package/lib/hosting/cloudRunProxy.js +1 -1
  81. package/lib/init/features/apphosting/index.js +5 -5
  82. package/lib/init/features/apphosting/repo.js +84 -99
  83. package/lib/init/features/database.js +2 -1
  84. package/lib/init/features/extensions/index.js +2 -1
  85. package/lib/init/features/functions/index.js +3 -2
  86. package/lib/init/features/hosting/github.js +4 -3
  87. package/lib/management/apps.js +4 -4
  88. package/lib/management/database.js +1 -1
  89. package/lib/management/projects.js +4 -4
  90. package/lib/remoteconfig/get.js +1 -1
  91. package/lib/remoteconfig/rollback.js +1 -1
  92. package/lib/remoteconfig/versionslist.js +1 -1
  93. package/lib/serve/functions.js +2 -0
  94. package/lib/shortenUrl.js +2 -2
  95. package/lib/utils.js +1 -1
  96. package/package.json +5 -5
@@ -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) {
@@ -8,11 +8,12 @@ const projectUtils_1 = require("../projectUtils");
8
8
  const types_1 = require("./types");
9
9
  const secretManagerApi = require("../gcp/secretManager");
10
10
  const logger_1 = require("../logger");
11
+ const api_1 = require("../api");
11
12
  exports.SECRET_LABEL = "firebase-extensions-managed";
12
13
  exports.SECRET_ROLE = "secretmanager.secretAccessor";
13
14
  async function ensureSecretManagerApiEnabled(options) {
14
15
  const projectId = (0, projectUtils_1.needProjectId)(options);
15
- return await (0, ensureApiEnabled_1.ensure)(projectId, "secretmanager.googleapis.com", "extensions", options.markdown);
16
+ return await (0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.secretManagerOrigin)(), "extensions", options.markdown);
16
17
  }
17
18
  exports.ensureSecretManagerApiEnabled = ensureSecretManagerApiEnabled;
18
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
  }
@@ -32,6 +32,7 @@ const projectPath_1 = require("../projectPath");
32
32
  const logger_1 = require("../logger");
33
33
  const frameworks_1 = require("./frameworks");
34
34
  Object.defineProperty(exports, "WebFrameworks", { enumerable: true, get: function () { return frameworks_1.WebFrameworks; } });
35
+ const fetchWebSetup_1 = require("../fetchWebSetup");
35
36
  async function discover(dir, warn = true) {
36
37
  const allFrameworkTypes = [
37
38
  ...new Set(Object.values(frameworks_1.WebFrameworks).map(({ type }) => type)),
@@ -148,12 +149,15 @@ async function prepareFrameworks(purpose, targetNames, context, options, emulato
148
149
  });
149
150
  let firebaseConfig = null;
150
151
  if (usesFirebaseJsSdk) {
151
- const sites = await (0, api_1.listSites)(project);
152
+ const isDemoProject = constants_1.Constants.isDemoProject(project);
153
+ const sites = isDemoProject ? (0, api_1.listDemoSites)(project) : await (0, api_1.listSites)(project);
152
154
  const selectedSite = sites.find((it) => it.name && it.name.split("/").pop() === site);
153
155
  if (selectedSite) {
154
156
  const { appId } = selectedSite;
155
157
  if (appId) {
156
- firebaseConfig = await (0, apps_1.getAppConfig)(appId, apps_1.AppPlatform.WEB);
158
+ firebaseConfig = isDemoProject
159
+ ? (0, fetchWebSetup_1.constructDefaultWebSetup)(project)
160
+ : await (0, apps_1.getAppConfig)(appId, apps_1.AppPlatform.WEB);
157
161
  firebaseDefaults || (firebaseDefaults = {});
158
162
  firebaseDefaults.config = firebaseConfig;
159
163
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ESBUILD_VERSION = exports.APP_PATHS_MANIFEST = exports.ROUTES_MANIFEST = exports.PRERENDER_MANIFEST = exports.PAGES_MANIFEST = exports.MIDDLEWARE_MANIFEST = exports.IMAGES_MANIFEST = exports.EXPORT_MARKER = exports.APP_PATH_ROUTES_MANIFEST = void 0;
3
+ exports.WEBPACK_LAYERS = exports.ESBUILD_VERSION = exports.SERVER_REFERENCE_MANIFEST = exports.APP_PATHS_MANIFEST = exports.ROUTES_MANIFEST = exports.PRERENDER_MANIFEST = exports.PAGES_MANIFEST = exports.MIDDLEWARE_MANIFEST = exports.IMAGES_MANIFEST = exports.EXPORT_MARKER = exports.APP_PATH_ROUTES_MANIFEST = void 0;
4
4
  exports.APP_PATH_ROUTES_MANIFEST = "app-path-routes-manifest.json";
5
5
  exports.EXPORT_MARKER = "export-marker.json";
6
6
  exports.IMAGES_MANIFEST = "images-manifest.json";
@@ -9,4 +9,41 @@ exports.PAGES_MANIFEST = "pages-manifest.json";
9
9
  exports.PRERENDER_MANIFEST = "prerender-manifest.json";
10
10
  exports.ROUTES_MANIFEST = "routes-manifest.json";
11
11
  exports.APP_PATHS_MANIFEST = "app-paths-manifest.json";
12
+ exports.SERVER_REFERENCE_MANIFEST = "server-reference-manifest.json";
12
13
  exports.ESBUILD_VERSION = "0.19.2";
14
+ const WEBPACK_LAYERS_NAMES = {
15
+ shared: "shared",
16
+ reactServerComponents: "rsc",
17
+ serverSideRendering: "ssr",
18
+ actionBrowser: "action-browser",
19
+ api: "api",
20
+ middleware: "middleware",
21
+ edgeAsset: "edge-asset",
22
+ appPagesBrowser: "app-pages-browser",
23
+ appMetadataRoute: "app-metadata-route",
24
+ appRouteHandler: "app-route-handler",
25
+ };
26
+ exports.WEBPACK_LAYERS = {
27
+ ...WEBPACK_LAYERS_NAMES,
28
+ GROUP: {
29
+ server: [
30
+ WEBPACK_LAYERS_NAMES.reactServerComponents,
31
+ WEBPACK_LAYERS_NAMES.actionBrowser,
32
+ WEBPACK_LAYERS_NAMES.appMetadataRoute,
33
+ WEBPACK_LAYERS_NAMES.appRouteHandler,
34
+ ],
35
+ nonClientServerTarget: [
36
+ WEBPACK_LAYERS_NAMES.middleware,
37
+ WEBPACK_LAYERS_NAMES.api,
38
+ ],
39
+ app: [
40
+ WEBPACK_LAYERS_NAMES.reactServerComponents,
41
+ WEBPACK_LAYERS_NAMES.actionBrowser,
42
+ WEBPACK_LAYERS_NAMES.appMetadataRoute,
43
+ WEBPACK_LAYERS_NAMES.appRouteHandler,
44
+ WEBPACK_LAYERS_NAMES.serverSideRendering,
45
+ WEBPACK_LAYERS_NAMES.appPagesBrowser,
46
+ WEBPACK_LAYERS_NAMES.shared,
47
+ ],
48
+ },
49
+ };
@@ -111,9 +111,10 @@ async function build(dir, target, context) {
111
111
  source: (0, utils_2.cleanEscapedChars)(source),
112
112
  headers,
113
113
  }));
114
- const [appPathsManifest, appPathRoutesManifest] = await Promise.all([
114
+ const [appPathsManifest, appPathRoutesManifest, serverReferenceManifest] = await Promise.all([
115
115
  (0, utils_1.readJSON)((0, path_1.join)(dir, distDir, "server", constants_2.APP_PATHS_MANIFEST)).catch(() => undefined),
116
116
  (0, utils_1.readJSON)((0, path_1.join)(dir, distDir, constants_2.APP_PATH_ROUTES_MANIFEST)).catch(() => undefined),
117
+ (0, utils_1.readJSON)((0, path_1.join)(dir, distDir, "server", constants_2.SERVER_REFERENCE_MANIFEST)).catch(() => undefined),
117
118
  ]);
118
119
  if (appPathRoutesManifest) {
119
120
  const headersFromMetaFiles = await (0, utils_2.getHeadersFromMetaFiles)(dir, distDir, baseUrl, appPathRoutesManifest);
@@ -128,6 +129,12 @@ async function build(dir, target, context) {
128
129
  reasonsForBackend.add(`non-static component ${key}`);
129
130
  }
130
131
  }
132
+ if (serverReferenceManifest) {
133
+ const routesWithServerAction = (0, utils_2.getRoutesWithServerAction)(serverReferenceManifest, appPathRoutesManifest);
134
+ for (const key of routesWithServerAction) {
135
+ reasonsForBackend.add(`route with server action ${key}`);
136
+ }
137
+ }
131
138
  }
132
139
  const isEveryRedirectSupported = nextJsRedirects
133
140
  .filter((it) => !it.internal)
@@ -209,12 +216,13 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir, _, context) {
209
216
  await (0, fs_extra_1.copy)(publicPath, (0, path_1.join)(destDir, basePath));
210
217
  }
211
218
  await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, distDir, "static"), (0, path_1.join)(destDir, basePath, "_next", "static"));
212
- const [middlewareManifest, prerenderManifest, routesManifest, pagesManifest, appPathRoutesManifest,] = await Promise.all([
219
+ const [middlewareManifest, prerenderManifest, routesManifest, pagesManifest, appPathRoutesManifest, serverReferenceManifest,] = await Promise.all([
213
220
  (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, "server", constants_2.MIDDLEWARE_MANIFEST)),
214
221
  (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, constants_2.PRERENDER_MANIFEST)),
215
222
  (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, constants_2.ROUTES_MANIFEST)),
216
223
  (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, "server", constants_2.PAGES_MANIFEST)),
217
224
  (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, constants_2.APP_PATH_ROUTES_MANIFEST)).catch(() => ({})),
225
+ (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, "server", constants_2.SERVER_REFERENCE_MANIFEST)).catch(() => ({ node: {}, edge: {}, encryptionKey: "" })),
218
226
  ]);
219
227
  const appPathRoutesEntries = Object.entries(appPathRoutesManifest);
220
228
  const middlewareMatcherRegexes = (0, utils_2.getMiddlewareMatcherRegexes)(middlewareManifest);
@@ -237,10 +245,20 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir, _, context) {
237
245
  ...redirectsRegexesNotSupportedByHosting,
238
246
  ...headersRegexesNotSupportedByHosting,
239
247
  ];
248
+ const staticRoutesUsingServerActions = (0, utils_2.getRoutesWithServerAction)(serverReferenceManifest, appPathRoutesManifest);
240
249
  const pagesManifestLikePrerender = Object.fromEntries(Object.entries(pagesManifest)
241
250
  .filter(([, srcRoute]) => srcRoute.endsWith(".html"))
242
251
  .map(([path]) => {
243
- return [path, { srcRoute: null, initialRevalidateSeconds: false, dataRoute: "" }];
252
+ return [
253
+ path,
254
+ {
255
+ srcRoute: null,
256
+ initialRevalidateSeconds: false,
257
+ dataRoute: "",
258
+ experimentalPPR: false,
259
+ prefetchDataRoute: "",
260
+ },
261
+ ];
244
262
  }));
245
263
  const routesToCopy = {
246
264
  ...prerenderManifest.routes,
@@ -255,6 +273,10 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir, _, context) {
255
273
  logger_1.logger.debug(`skipping ${path} due to it matching an unsupported rewrite/redirect/header or middlware`);
256
274
  return;
257
275
  }
276
+ if (staticRoutesUsingServerActions.some((it) => path === it)) {
277
+ logger_1.logger.debug(`skipping ${path} due to server action`);
278
+ return;
279
+ }
258
280
  const appPathRoute = route.srcRoute && appPathRoutesEntries.find(([, it]) => it === route.srcRoute)?.[0];
259
281
  const contentDist = (0, path_1.join)(sourceDir, distDir, "server", appPathRoute ? "app" : "pages");
260
282
  const sourceParts = path.split("/").filter((it) => !!it);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasStaticAppNotFoundComponent = exports.getNextVersion = exports.getBuildId = exports.getHeadersFromMetaFiles = exports.getNonStaticServerComponents = exports.getNonStaticRoutes = exports.getMiddlewareMatcherRegexes = exports.allDependencyNames = exports.isUsingAppDirectory = exports.isUsingNextImageInAppDirectory = exports.isUsingImageOptimization = exports.isUsingMiddleware = exports.hasUnoptimizedImage = exports.usesNextImage = exports.usesAppDirRouter = exports.getNextjsRewritesToUse = exports.isHeaderSupportedByHosting = exports.isRedirectSupportedByHosting = exports.isRewriteSupportedByHosting = exports.cleanI18n = exports.cleanCustomRouteI18n = exports.cleanEscapedChars = exports.I18N_SOURCE = void 0;
3
+ exports.getRoutesWithServerAction = exports.hasStaticAppNotFoundComponent = exports.getNextVersion = exports.getBuildId = exports.getHeadersFromMetaFiles = exports.getNonStaticServerComponents = exports.getNonStaticRoutes = exports.getMiddlewareMatcherRegexes = exports.allDependencyNames = exports.isUsingAppDirectory = exports.isUsingNextImageInAppDirectory = exports.isUsingImageOptimization = exports.isUsingMiddleware = exports.hasUnoptimizedImage = exports.usesNextImage = exports.usesAppDirRouter = exports.getNextjsRewritesToUse = exports.isHeaderSupportedByHosting = exports.isRedirectSupportedByHosting = exports.isRewriteSupportedByHosting = exports.cleanI18n = exports.cleanCustomRouteI18n = exports.cleanEscapedChars = exports.I18N_SOURCE = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const fs_extra_1 = require("fs-extra");
6
6
  const path_1 = require("path");
@@ -202,3 +202,22 @@ async function hasStaticAppNotFoundComponent(sourceDir, distDir) {
202
202
  return (0, fs_extra_1.pathExists)((0, path_1.join)(sourceDir, distDir, "server", "app", "_not-found.html"));
203
203
  }
204
204
  exports.hasStaticAppNotFoundComponent = hasStaticAppNotFoundComponent;
205
+ function getRoutesWithServerAction(serverReferenceManifest, appPathRoutesManifest) {
206
+ const routesWithServerAction = new Set();
207
+ for (const key of Object.keys(serverReferenceManifest)) {
208
+ if (key !== "edge" && key !== "node")
209
+ continue;
210
+ const edgeOrNode = serverReferenceManifest[key];
211
+ for (const actionId of Object.keys(edgeOrNode)) {
212
+ if (!edgeOrNode[actionId].layer)
213
+ continue;
214
+ for (const [route, type] of Object.entries(edgeOrNode[actionId].layer)) {
215
+ if (type === constants_1.WEBPACK_LAYERS.actionBrowser) {
216
+ routesWithServerAction.add(appPathRoutesManifest[route.replace("app", "")]);
217
+ }
218
+ }
219
+ }
220
+ }
221
+ return Array.from(routesWithServerAction);
222
+ }
223
+ exports.getRoutesWithServerAction = getRoutesWithServerAction;
@@ -17,13 +17,13 @@ const functional_1 = require("../functional");
17
17
  const projectUtils_1 = require("../projectUtils");
18
18
  const FIREBASE_MANAGED = "firebase-managed";
19
19
  const gcfV1PollerOptions = {
20
- apiOrigin: api_1.functionsOrigin,
20
+ apiOrigin: (0, api_1.functionsOrigin)(),
21
21
  apiVersion: "v1",
22
22
  masterTimeout: 25 * 60 * 1000,
23
23
  maxBackoff: 10000,
24
24
  };
25
25
  const gcfV2PollerOptions = {
26
- apiOrigin: api_1.functionsV2Origin,
26
+ apiOrigin: (0, api_1.functionsV2Origin)(),
27
27
  apiVersion: "v2",
28
28
  masterTimeout: 25 * 60 * 1000,
29
29
  maxBackoff: 10000,
@@ -44,7 +44,7 @@ function toUpperSnakeCase(key) {
44
44
  }
45
45
  function ensureApi(options) {
46
46
  const projectId = (0, projectUtils_1.needProjectId)(options);
47
- return ensureApiEnabled.ensure(projectId, "secretmanager.googleapis.com", "secretmanager", true);
47
+ return ensureApiEnabled.ensure(projectId, (0, api_1.secretManagerOrigin)(), "secretmanager", true);
48
48
  }
49
49
  exports.ensureApi = ensureApi;
50
50
  async function ensureValidKey(key, options) {
@@ -10,7 +10,7 @@ const error_1 = require("./error");
10
10
  const projectUtils_1 = require("./projectUtils");
11
11
  const runtimeconfig = require("./gcp/runtimeconfig");
12
12
  exports.RESERVED_NAMESPACES = ["firebase"];
13
- const apiClient = new apiv2_1.Client({ urlPrefix: api_1.firebaseApiOrigin });
13
+ const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.firebaseApiOrigin)() });
14
14
  function keyToIds(key) {
15
15
  const keyParts = key.split(".");
16
16
  const variable = keyParts.slice(1).join("/");
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNextRolloutId = exports.ensureApiEnabled = exports.listLocations = exports.updateTraffic = exports.listRollouts = exports.createRollout = exports.createBuild = exports.listBuilds = exports.getBuild = exports.deleteBackend = exports.listBackends = exports.getBackend = exports.createBackend = exports.client = exports.API_VERSION = exports.API_HOST = void 0;
3
+ exports.getNextRolloutId = exports.ensureApiEnabled = exports.listLocations = exports.updateTraffic = exports.listRollouts = exports.createRollout = exports.createBuild = exports.listBuilds = exports.getBuild = exports.deleteBackend = exports.listBackends = exports.getBackend = exports.createBackend = exports.client = exports.API_VERSION = void 0;
4
4
  const proto = require("../gcp/proto");
5
5
  const apiv2_1 = require("../apiv2");
6
6
  const projectUtils_1 = require("../projectUtils");
@@ -9,10 +9,9 @@ const ensureApiEnabled_1 = require("../ensureApiEnabled");
9
9
  const deploymentTool = require("../deploymentTool");
10
10
  const error_1 = require("../error");
11
11
  const metaprogramming_1 = require("../metaprogramming");
12
- exports.API_HOST = new URL(api_1.apphostingOrigin).host;
13
12
  exports.API_VERSION = "v1alpha";
14
13
  exports.client = new apiv2_1.Client({
15
- urlPrefix: api_1.apphostingOrigin,
14
+ urlPrefix: (0, api_1.apphostingOrigin)(),
16
15
  auth: true,
17
16
  apiVersion: exports.API_VERSION,
18
17
  });
@@ -143,7 +142,7 @@ async function listLocations(projectId) {
143
142
  exports.listLocations = listLocations;
144
143
  async function ensureApiEnabled(options) {
145
144
  const projectId = (0, projectUtils_1.needProjectId)(options);
146
- return await (0, ensureApiEnabled_1.ensure)(projectId, exports.API_HOST, "app hosting", true);
145
+ return await (0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.apphostingOrigin)(), "app hosting", true);
147
146
  }
148
147
  exports.ensureApiEnabled = ensureApiEnabled;
149
148
  async function getNextRolloutId(projectId, location, backendId, counter) {
@@ -154,22 +153,28 @@ async function getNextRolloutId(projectId, location, backendId, counter) {
154
153
  if (counter) {
155
154
  return `build-${year}-${month}-${day}-${String(counter).padStart(3, "0")}`;
156
155
  }
157
- const builds = await exports.listRollouts(projectId, location, backendId);
158
- if (builds.unreachable?.includes(location)) {
156
+ const rolloutsPromise = exports.listRollouts(projectId, location, backendId);
157
+ const buildsPromise = exports.listBuilds(projectId, location, backendId);
158
+ const [rollouts, builds] = await Promise.all([rolloutsPromise, buildsPromise]);
159
+ if (builds.unreachable?.includes(location) || rollouts.unreachable?.includes(location)) {
159
160
  throw new error_1.FirebaseError(`Firebase App Hosting is currently unreachable in location ${location}`);
160
161
  }
161
- let highest = 0;
162
- const test = new RegExp(`projects/${projectId}/locations/${location}/backends/${backendId}/rollouts/build-${year}-${month}-${day}-(\\d+)`);
163
- for (const rollout of builds.rollouts) {
164
- const match = rollout.name.match(test);
165
- if (!match) {
166
- continue;
162
+ const test = new RegExp(`projects/${projectId}/locations/${location}/backends/${backendId}/(rollouts|builds)/build-${year}-${month}-${day}-(\\d+)`);
163
+ const highestId = (input) => {
164
+ let highest = 0;
165
+ for (const i of input) {
166
+ const match = i.name.match(test);
167
+ if (!match) {
168
+ continue;
169
+ }
170
+ const n = Number(match[2]);
171
+ if (n > highest) {
172
+ highest = n;
173
+ }
167
174
  }
168
- const n = Number(match[1]);
169
- if (n > highest) {
170
- highest = n;
171
- }
172
- }
175
+ return highest;
176
+ };
177
+ const highest = Math.max(highestId(builds.builds), highestId(rollouts.rollouts));
173
178
  return `build-${year}-${month}-${day}-${String(highest + 1).padStart(3, "0")}`;
174
179
  }
175
180
  exports.getNextRolloutId = getNextRolloutId;
@@ -5,7 +5,7 @@ const apiv2_1 = require("../apiv2");
5
5
  const api_1 = require("../api");
6
6
  exports.API_VERSION = "v1beta2";
7
7
  const client = new apiv2_1.Client({
8
- urlPrefix: api_1.artifactRegistryDomain,
8
+ urlPrefix: (0, api_1.artifactRegistryDomain)(),
9
9
  auth: true,
10
10
  apiVersion: exports.API_VERSION,
11
11
  });
package/lib/gcp/auth.js CHANGED
@@ -3,14 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateAuthDomains = exports.getAuthDomains = void 0;
4
4
  const apiv2_1 = require("../apiv2");
5
5
  const api_1 = require("../api");
6
- const apiClient = new apiv2_1.Client({ urlPrefix: api_1.identityOrigin, auth: true });
6
+ const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.identityOrigin)(), auth: true });
7
7
  async function getAuthDomains(project) {
8
- const res = await apiClient.get(`/admin/v2/projects/${project}/config`);
8
+ const res = await apiClient.get(`/admin/v2/projects/${project}/config`, { headers: { "x-goog-user-project": project } });
9
9
  return res.body.authorizedDomains;
10
10
  }
11
11
  exports.getAuthDomains = getAuthDomains;
12
12
  async function updateAuthDomains(project, authDomains) {
13
- const res = await apiClient.patch(`/admin/v2/projects/${project}/config`, { authorizedDomains: authDomains }, { queryParams: { update_mask: "authorizedDomains" } });
13
+ const res = await apiClient.patch(`/admin/v2/projects/${project}/config`, { authorizedDomains: authDomains }, {
14
+ queryParams: { update_mask: "authorizedDomains" },
15
+ headers: { "x-goog-user-project": project },
16
+ });
14
17
  return res.body.authorizedDomains;
15
18
  }
16
19
  exports.updateAuthDomains = updateAuthDomains;
@@ -5,7 +5,7 @@ const api_1 = require("../api");
5
5
  const apiv2_1 = require("../apiv2");
6
6
  const utils = require("../utils");
7
7
  const API_VERSION = "v1";
8
- const client = new apiv2_1.Client({ urlPrefix: api_1.cloudbillingOrigin, apiVersion: API_VERSION });
8
+ const client = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudbillingOrigin)(), apiVersion: API_VERSION });
9
9
  async function checkBillingEnabled(projectId) {
10
10
  const res = await client.get(utils.endpoint(["projects", projectId, "billingInfo"]), { retryCodes: [500, 503] });
11
11
  return res.body.billingEnabled;
@@ -5,7 +5,7 @@ const apiv2_1 = require("../apiv2");
5
5
  const api_1 = require("../api");
6
6
  const PAGE_SIZE_MAX = 100;
7
7
  const client = new apiv2_1.Client({
8
- urlPrefix: api_1.cloudbuildOrigin,
8
+ urlPrefix: (0, api_1.cloudbuildOrigin)(),
9
9
  auth: true,
10
10
  apiVersion: "v2",
11
11
  });
@@ -13,7 +13,7 @@ const apiv2_1 = require("../apiv2");
13
13
  const api_1 = require("../api");
14
14
  const constants_1 = require("../functions/constants");
15
15
  exports.API_VERSION = "v1";
16
- const client = new apiv2_1.Client({ urlPrefix: api_1.functionsOrigin, apiVersion: exports.API_VERSION });
16
+ const client = new apiv2_1.Client({ urlPrefix: (0, api_1.functionsOrigin)(), apiVersion: exports.API_VERSION });
17
17
  function functionsOpLogReject(funcName, type, err) {
18
18
  if (err?.context?.response?.statusCode === 429) {
19
19
  utils.logWarning(`${clc.bold(clc.yellow("functions:"))} got "Quota Exceeded" error while trying to ${type} ${funcName}. Waiting to retry...`);
@@ -15,7 +15,7 @@ const constants_1 = require("../functions/constants");
15
15
  exports.API_VERSION = "v2";
16
16
  const DEFAULT_MAX_INSTANCE_COUNT = 100;
17
17
  const client = new apiv2_1.Client({
18
- urlPrefix: api_1.functionsV2Origin,
18
+ urlPrefix: (0, api_1.functionsV2Origin)(),
19
19
  auth: true,
20
20
  apiVersion: exports.API_VERSION,
21
21
  });
@@ -225,6 +225,9 @@ function functionFromEndpoint(endpoint) {
225
225
  eventType: endpoint.eventTrigger.eventType,
226
226
  retryPolicy: "RETRY_POLICY_UNSPECIFIED",
227
227
  };
228
+ if (endpoint.serviceAccount) {
229
+ gcfFunction.eventTrigger.serviceAccountEmail = endpoint.serviceAccount;
230
+ }
228
231
  if (gcfFunction.eventTrigger.eventType === v2_1.PUBSUB_PUBLISH_EVENT) {
229
232
  if (!endpoint.eventTrigger.eventFilters?.topic) {
230
233
  throw new error_1.FirebaseError("Error: Pub/Sub event trigger is missing topic: " +
@@ -6,7 +6,7 @@ const apiv2_1 = require("../apiv2");
6
6
  const error_1 = require("../error");
7
7
  const API_VERSION = "v2";
8
8
  async function listEntries(projectId, filter, pageSize, order) {
9
- const client = new apiv2_1.Client({ urlPrefix: api_1.cloudloggingOrigin, apiVersion: API_VERSION });
9
+ const client = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudloggingOrigin)(), apiVersion: API_VERSION });
10
10
  try {
11
11
  const result = await client.post("/entries:list", {
12
12
  resourceNames: [`projects/${projectId}`],
@@ -59,7 +59,7 @@ var ValueType;
59
59
  })(ValueType = exports.ValueType || (exports.ValueType = {}));
60
60
  async function queryTimeSeries(query, projectNumber) {
61
61
  const client = new apiv2_1.Client({
62
- urlPrefix: api_1.cloudMonitoringOrigin,
62
+ urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
63
63
  apiVersion: exports.CLOUD_MONITORING_VERSION,
64
64
  });
65
65
  try {
@@ -13,7 +13,7 @@ const functional_1 = require("../functional");
13
13
  const VERSION = "v1";
14
14
  const DEFAULT_TIME_ZONE_V1 = "America/Los_Angeles";
15
15
  const DEFAULT_TIME_ZONE_V2 = "UTC";
16
- const apiClient = new apiv2_1.Client({ urlPrefix: api_1.cloudschedulerOrigin, apiVersion: VERSION });
16
+ const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudschedulerOrigin)(), apiVersion: VERSION });
17
17
  function createJob(job) {
18
18
  const strippedName = job.name.substring(0, job.name.lastIndexOf("/"));
19
19
  const json = job.pubsubTarget
@@ -129,7 +129,7 @@ function jobFromEndpoint(endpoint, location, projectNumber) {
129
129
  uri: endpoint.uri,
130
130
  httpMethod: "POST",
131
131
  oidcToken: {
132
- serviceAccountEmail: (0, checkIam_1.getDefaultComputeServiceAgent)(projectNumber),
132
+ serviceAccountEmail: endpoint.serviceAccount ?? (0, checkIam_1.getDefaultComputeServiceAgent)(projectNumber),
133
133
  },
134
134
  };
135
135
  }
@@ -7,7 +7,7 @@ const api_1 = require("../api");
7
7
  const functional_1 = require("../functional");
8
8
  const API_VERSION = "v2";
9
9
  const client = new apiv2_1.Client({
10
- urlPrefix: api_1.cloudTasksOrigin,
10
+ urlPrefix: (0, api_1.cloudTasksOrigin)(),
11
11
  auth: true,
12
12
  apiVersion: API_VERSION,
13
13
  });