firebase-tools-with-isolate 13.4.0 → 13.6.1-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +6 -6
@@ -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, api_1.secretManagerOrigin, "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("/");
@@ -11,7 +11,7 @@ const error_1 = require("../error");
11
11
  const metaprogramming_1 = require("../metaprogramming");
12
12
  exports.API_VERSION = "v1alpha";
13
13
  exports.client = new apiv2_1.Client({
14
- urlPrefix: api_1.apphostingOrigin,
14
+ urlPrefix: (0, api_1.apphostingOrigin)(),
15
15
  auth: true,
16
16
  apiVersion: exports.API_VERSION,
17
17
  });
@@ -142,7 +142,7 @@ async function listLocations(projectId) {
142
142
  exports.listLocations = listLocations;
143
143
  async function ensureApiEnabled(options) {
144
144
  const projectId = (0, projectUtils_1.needProjectId)(options);
145
- return await (0, ensureApiEnabled_1.ensure)(projectId, api_1.apphostingOrigin, "app hosting", true);
145
+ return await (0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.apphostingOrigin)(), "app hosting", true);
146
146
  }
147
147
  exports.ensureApiEnabled = ensureApiEnabled;
148
148
  async function getNextRolloutId(projectId, location, backendId, counter) {
@@ -153,22 +153,28 @@ async function getNextRolloutId(projectId, location, backendId, counter) {
153
153
  if (counter) {
154
154
  return `build-${year}-${month}-${day}-${String(counter).padStart(3, "0")}`;
155
155
  }
156
- const builds = await exports.listRollouts(projectId, location, backendId);
157
- 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)) {
158
160
  throw new error_1.FirebaseError(`Firebase App Hosting is currently unreachable in location ${location}`);
159
161
  }
160
- let highest = 0;
161
- const test = new RegExp(`projects/${projectId}/locations/${location}/backends/${backendId}/rollouts/build-${year}-${month}-${day}-(\\d+)`);
162
- for (const rollout of builds.rollouts) {
163
- const match = rollout.name.match(test);
164
- if (!match) {
165
- 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
+ }
166
174
  }
167
- const n = Number(match[1]);
168
- if (n > highest) {
169
- highest = n;
170
- }
171
- }
175
+ return highest;
176
+ };
177
+ const highest = Math.max(highestId(builds.builds), highestId(rollouts.rollouts));
172
178
  return `build-${year}-${month}-${day}-${String(highest + 1).padStart(3, "0")}`;
173
179
  }
174
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,7 +3,7 @@ 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
8
  const res = await apiClient.get(`/admin/v2/projects/${project}/config`, { headers: { "x-goog-user-project": project } });
9
9
  return res.body.authorizedDomains;
@@ -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
  });
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serviceAgentEmail = exports.getGitRepositoryLink = exports.createGitRepositoryLink = exports.listAllLinkableGitRepositories = exports.listAllConnections = exports.getConnection = exports.createConnection = exports.client = void 0;
4
+ const apiv2_1 = require("../apiv2");
5
+ const api_1 = require("../api");
6
+ const PAGE_SIZE_MAX = 1000;
7
+ exports.client = new apiv2_1.Client({
8
+ urlPrefix: (0, api_1.developerConnectOrigin)(),
9
+ auth: true,
10
+ apiVersion: "v1",
11
+ });
12
+ async function createConnection(projectId, location, connectionId, githubConfig) {
13
+ const config = {
14
+ ...githubConfig,
15
+ githubApp: "FIREBASE",
16
+ };
17
+ const res = await exports.client.post(`projects/${projectId}/locations/${location}/connections`, {
18
+ githubConfig: config,
19
+ }, { queryParams: { connectionId } });
20
+ return res.body;
21
+ }
22
+ exports.createConnection = createConnection;
23
+ async function getConnection(projectId, location, connectionId) {
24
+ const name = `projects/${projectId}/locations/${location}/connections/${connectionId}`;
25
+ const res = await exports.client.get(name);
26
+ return res.body;
27
+ }
28
+ exports.getConnection = getConnection;
29
+ async function listAllConnections(projectId, location) {
30
+ const conns = [];
31
+ const getNextPage = async (pageToken = "") => {
32
+ const res = await exports.client.get(`/projects/${projectId}/locations/${location}/connections`, {
33
+ queryParams: {
34
+ pageSize: PAGE_SIZE_MAX,
35
+ pageToken,
36
+ },
37
+ });
38
+ if (Array.isArray(res.body.connections)) {
39
+ conns.push(...res.body.connections);
40
+ }
41
+ if (res.body.nextPageToken) {
42
+ await getNextPage(res.body.nextPageToken);
43
+ }
44
+ };
45
+ await getNextPage();
46
+ return conns;
47
+ }
48
+ exports.listAllConnections = listAllConnections;
49
+ async function listAllLinkableGitRepositories(projectId, location, connectionId) {
50
+ const name = `projects/${projectId}/locations/${location}/connections/${connectionId}:fetchLinkableRepositories`;
51
+ const repos = [];
52
+ const getNextPage = async (pageToken = "") => {
53
+ const res = await exports.client.get(name, {
54
+ queryParams: {
55
+ PAGE_SIZE_MAX,
56
+ pageToken,
57
+ },
58
+ });
59
+ if (Array.isArray(res.body.repositories)) {
60
+ repos.push(...res.body.repositories);
61
+ }
62
+ if (res.body.nextPageToken) {
63
+ await getNextPage(res.body.nextPageToken);
64
+ }
65
+ };
66
+ await getNextPage();
67
+ return repos;
68
+ }
69
+ exports.listAllLinkableGitRepositories = listAllLinkableGitRepositories;
70
+ async function createGitRepositoryLink(projectId, location, connectionId, gitRepositoryLinkId, cloneUri) {
71
+ const res = await exports.client.post(`projects/${projectId}/locations/${location}/connections/${connectionId}/gitRepositoryLinks`, { cloneUri }, { queryParams: { gitRepositoryLinkId } });
72
+ return res.body;
73
+ }
74
+ exports.createGitRepositoryLink = createGitRepositoryLink;
75
+ async function getGitRepositoryLink(projectId, location, connectionId, gitRepositoryLinkId) {
76
+ const name = `projects/${projectId}/locations/${location}/connections/${connectionId}/gitRepositoryLinks/${gitRepositoryLinkId}`;
77
+ const res = await exports.client.get(name);
78
+ return res.body;
79
+ }
80
+ exports.getGitRepositoryLink = getGitRepositoryLink;
81
+ function serviceAgentEmail(projectNumber) {
82
+ return `service-${projectNumber}@${(0, api_1.developerConnectP4SAOrigin)()}`;
83
+ }
84
+ exports.serviceAgentEmail = serviceAgentEmail;
@@ -7,7 +7,7 @@ const lodash_1 = require("lodash");
7
7
  const proto_1 = require("./proto");
8
8
  exports.API_VERSION = "v1";
9
9
  const client = new apiv2_1.Client({
10
- urlPrefix: api_1.eventarcOrigin,
10
+ urlPrefix: (0, api_1.eventarcOrigin)(),
11
11
  auth: true,
12
12
  apiVersion: exports.API_VERSION,
13
13
  });
@@ -9,12 +9,12 @@ const error_1 = require("../error");
9
9
  const prodOnlyClient = new apiv2_1.Client({
10
10
  auth: true,
11
11
  apiVersion: "v1",
12
- urlPrefix: api_1.firestoreOrigin,
12
+ urlPrefix: (0, api_1.firestoreOrigin)(),
13
13
  });
14
14
  const emuOrProdClient = new apiv2_1.Client({
15
15
  auth: true,
16
16
  apiVersion: "v1",
17
- urlPrefix: api_1.firestoreOriginOrEmulator,
17
+ urlPrefix: (0, api_1.firestoreOriginOrEmulator)(),
18
18
  });
19
19
  var DayOfWeek;
20
20
  (function (DayOfWeek) {
package/lib/gcp/iam.js CHANGED
@@ -4,7 +4,7 @@ exports.testIamPermissions = exports.testResourceIamPermissions = exports.getRol
4
4
  const api_1 = require("../api");
5
5
  const logger_1 = require("../logger");
6
6
  const apiv2_1 = require("../apiv2");
7
- const apiClient = new apiv2_1.Client({ urlPrefix: api_1.iamOrigin, apiVersion: "v1" });
7
+ const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.iamOrigin)(), apiVersion: "v1" });
8
8
  async function createServiceAccount(projectId, accountId, description, displayName) {
9
9
  const response = await apiClient.post(`/projects/${projectId}/serviceAccounts`, {
10
10
  accountId,
@@ -71,6 +71,6 @@ async function testResourceIamPermissions(origin, apiVersion, resourceName, perm
71
71
  }
72
72
  exports.testResourceIamPermissions = testResourceIamPermissions;
73
73
  async function testIamPermissions(projectId, permissions) {
74
- return testResourceIamPermissions(api_1.resourceManagerOrigin, "v1", `projects/${projectId}`, permissions, `projects/${projectId}`);
74
+ return testResourceIamPermissions((0, api_1.resourceManagerOrigin)(), "v1", `projects/${projectId}`, permissions, `projects/${projectId}`);
75
75
  }
76
76
  exports.testIamPermissions = testIamPermissions;
@@ -6,7 +6,7 @@ const api_1 = require("../api");
6
6
  const apiv2_1 = require("../apiv2");
7
7
  const API_VERSION = "v2";
8
8
  const adminApiClient = new apiv2_1.Client({
9
- urlPrefix: api_1.identityOrigin + "/admin",
9
+ urlPrefix: (0, api_1.identityOrigin)() + "/admin",
10
10
  apiVersion: API_VERSION,
11
11
  });
12
12
  async function getBlockingFunctionsConfig(project) {
package/lib/gcp/pubsub.js CHANGED
@@ -6,7 +6,7 @@ const api_1 = require("../api");
6
6
  const proto = require("./proto");
7
7
  const API_VERSION = "v1";
8
8
  const client = new apiv2_1.Client({
9
- urlPrefix: api_1.pubsubOrigin,
9
+ urlPrefix: (0, api_1.pubsubOrigin)(),
10
10
  auth: true,
11
11
  apiVersion: API_VERSION,
12
12
  });
@@ -6,13 +6,14 @@ const api_1 = require("../api");
6
6
  const apiv2_1 = require("../apiv2");
7
7
  const iam_1 = require("./iam");
8
8
  const API_VERSION = "v1";
9
- const apiClient = new apiv2_1.Client({ urlPrefix: api_1.resourceManagerOrigin, apiVersion: API_VERSION });
9
+ const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.resourceManagerOrigin)(), apiVersion: API_VERSION });
10
10
  exports.firebaseRoles = {
11
11
  apiKeysViewer: "roles/serviceusage.apiKeysViewer",
12
12
  authAdmin: "roles/firebaseauth.admin",
13
13
  functionsDeveloper: "roles/cloudfunctions.developer",
14
14
  hostingAdmin: "roles/firebasehosting.admin",
15
15
  runViewer: "roles/run.viewer",
16
+ serviceUsageConsumer: "roles/serviceusage.serviceUsageConsumer",
16
17
  };
17
18
  async function getIamPolicy(projectIdOrNumber) {
18
19
  const response = await apiClient.post(`/projects/${projectIdOrNumber}:getIamPolicy`);
package/lib/gcp/rules.js CHANGED
@@ -6,7 +6,7 @@ const apiv2_1 = require("../apiv2");
6
6
  const logger_1 = require("../logger");
7
7
  const utils = require("../utils");
8
8
  const API_VERSION = "v1";
9
- const apiClient = new apiv2_1.Client({ urlPrefix: api_1.rulesOrigin, apiVersion: API_VERSION });
9
+ const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.rulesOrigin)(), apiVersion: API_VERSION });
10
10
  function _handleErrorResponse(response) {
11
11
  if (response.body && response.body.error) {
12
12
  return utils.reject(response.body.error, { code: 2 });
package/lib/gcp/run.js CHANGED
@@ -9,7 +9,7 @@ const throttler_1 = require("../throttler/throttler");
9
9
  const logger_1 = require("../logger");
10
10
  const API_VERSION = "v1";
11
11
  const client = new apiv2_1.Client({
12
- urlPrefix: api_1.runOrigin,
12
+ urlPrefix: (0, api_1.runOrigin)(),
13
13
  auth: true,
14
14
  apiVersion: API_VERSION,
15
15
  });
@@ -6,7 +6,7 @@ const api_1 = require("../api");
6
6
  const apiv2_1 = require("../apiv2");
7
7
  const logger_1 = require("../logger");
8
8
  const API_VERSION = "v1beta1";
9
- const apiClient = new apiv2_1.Client({ urlPrefix: api_1.runtimeconfigOrigin, apiVersion: API_VERSION });
9
+ const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.runtimeconfigOrigin)(), apiVersion: API_VERSION });
10
10
  function listConfigs(projectId) {
11
11
  return apiClient
12
12
  .get(`/projects/${projectId}/configs`, {
@@ -13,7 +13,7 @@ const SECRET_VERSION_NAME_REGEX = new RegExp(SECRET_NAME_REGEX.source + "\\/vers
13
13
  const secretManagerConsoleUri = (projectId) => `https://console.cloud.google.com/security/secret-manager?project=${projectId}`;
14
14
  exports.secretManagerConsoleUri = secretManagerConsoleUri;
15
15
  const API_VERSION = "v1";
16
- const client = new apiv2_1.Client({ urlPrefix: api_1.secretManagerOrigin, apiVersion: API_VERSION });
16
+ const client = new apiv2_1.Client({ urlPrefix: (0, api_1.secretManagerOrigin)(), apiVersion: API_VERSION });
17
17
  async function getSecret(projectId, name) {
18
18
  const getRes = await client.get(`projects/${projectId}/secrets/${name}`);
19
19
  const secret = parseSecretResourceName(getRes.body.name);
@@ -7,7 +7,7 @@ const apiv2_1 = require("../apiv2");
7
7
  const error_1 = require("../error");
8
8
  const utils = require("../utils");
9
9
  const apiClient = new apiv2_1.Client({
10
- urlPrefix: api_1.serviceUsageOrigin,
10
+ urlPrefix: (0, api_1.serviceUsageOrigin)(),
11
11
  apiVersion: "v1beta1",
12
12
  });
13
13
  async function generateServiceIdentity(projectNumber, service, prefix) {