firebase-tools-with-isolate 15.35.0 → 15.37.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 (143) hide show
  1. package/lib/accountExporter.js +1 -1
  2. package/lib/accountImporter.js +7 -6
  3. package/lib/apiv2.js +0 -1
  4. package/lib/appcheck/debugTokens.js +293 -0
  5. package/lib/appcheck/localConfig.js +191 -0
  6. package/lib/appdistribution/options-parser-util.js +1 -1
  7. package/lib/apphosting/githubConnections.js +1 -1
  8. package/lib/apptesting/parseTestFiles.js +1 -1
  9. package/lib/auth.js +9 -3
  10. package/lib/bin/progressiveHelp.js +1 -1
  11. package/lib/command.js +1 -2
  12. package/lib/commands/appcheck-debugtokens-create.js +60 -35
  13. package/lib/commands/appcheck-debugtokens-delete.js +21 -7
  14. package/lib/commands/appcheck-debugtokens-list.js +37 -8
  15. package/lib/commands/appcheck-debugtokens-prune.js +59 -0
  16. package/lib/commands/crashlytics-events-get.js +48 -0
  17. package/lib/commands/crashlytics-events-list.js +70 -0
  18. package/lib/commands/crashlytics-heapdumps-enable.js +3 -4
  19. package/lib/commands/crashlytics-heapdumps-status.js +5 -3
  20. package/lib/commands/crashlytics-issues-get.js +61 -0
  21. package/lib/commands/crashlytics-reports-get.js +179 -0
  22. package/lib/commands/crashlytics-reports-list.js +42 -0
  23. package/lib/commands/dataconnect-services-list.js +8 -2
  24. package/lib/commands/deploy.js +1 -3
  25. package/lib/commands/ext-dev-init.js +1 -1
  26. package/lib/commands/hosting-channel-create.js +1 -3
  27. package/lib/commands/hosting-channel-delete.js +1 -3
  28. package/lib/commands/hosting-channel-deploy.js +1 -3
  29. package/lib/commands/hosting-channel-list.js +1 -3
  30. package/lib/commands/hosting-channel-open.js +5 -4
  31. package/lib/commands/hosting-clone.js +3 -5
  32. package/lib/commands/hosting-disable.js +2 -2
  33. package/lib/commands/hosting-sites-create.js +1 -3
  34. package/lib/commands/hosting-sites-delete.js +1 -3
  35. package/lib/commands/hosting-sites-get.js +1 -3
  36. package/lib/commands/hosting-sites-list.js +1 -3
  37. package/lib/commands/index.js +11 -0
  38. package/lib/commands/open.js +3 -1
  39. package/lib/commands/serve.js +1 -1
  40. package/lib/commands/use.js +1 -1
  41. package/lib/config.js +1 -1
  42. package/lib/crashlytics/commandUtils.js +194 -0
  43. package/lib/crashlytics/events.js +122 -1
  44. package/lib/crashlytics/filters.js +12 -6
  45. package/lib/crashlytics/profilingManager.js +77 -50
  46. package/lib/crashlytics/reports.js +5 -1
  47. package/lib/crashlytics/utils.js +14 -0
  48. package/lib/database/import.js +5 -4
  49. package/lib/dataconnect/client.js +14 -8
  50. package/lib/dataconnect/names.js +3 -3
  51. package/lib/dataconnect/schemaMigration.js +1 -1
  52. package/lib/deploy/dataconnect/release.js +2 -2
  53. package/lib/deploy/firestore/prepare.js +21 -3
  54. package/lib/deploy/functions/backend.js +0 -10
  55. package/lib/deploy/functions/cel.js +2 -2
  56. package/lib/deploy/functions/deploy.js +2 -1
  57. package/lib/deploy/functions/prepare.js +28 -0
  58. package/lib/deploy/functions/release/fabricator.js +27 -3
  59. package/lib/deploy/functions/release/planner.js +3 -0
  60. package/lib/deploy/functions/release/reporter.js +0 -26
  61. package/lib/deploy/functions/runtimes/discovery/index.js +4 -1
  62. package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
  63. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +1 -1
  64. package/lib/deploy/functions/runtimes/supported/index.js +10 -4
  65. package/lib/deploy/functions/runtimes/supported/types.js +7 -1
  66. package/lib/deploy/functions/services/index.js +13 -11
  67. package/lib/deploy/hosting/prepare.js +1 -3
  68. package/lib/deploy/lifecycleHooks.js +1 -1
  69. package/lib/emulator/auth/operations.js +2 -2
  70. package/lib/emulator/auth/server.js +4 -2
  71. package/lib/emulator/auth/widget_ui.js +1 -1
  72. package/lib/emulator/commandUtils.js +4 -1
  73. package/lib/emulator/databaseEmulator.js +16 -11
  74. package/lib/emulator/dataconnect/pgliteServer.js +30 -24
  75. package/lib/emulator/downloadableEmulatorInfo.json +31 -31
  76. package/lib/emulator/downloadableEmulators.js +2 -2
  77. package/lib/emulator/extensions/postinstall.js +6 -6
  78. package/lib/emulator/firestoreEmulator.js +21 -15
  79. package/lib/emulator/functionsEmulator.js +84 -8
  80. package/lib/emulator/functionsEmulatorRuntime.js +9 -4
  81. package/lib/emulator/hub.js +12 -8
  82. package/lib/emulator/shared/express.js +30 -0
  83. package/lib/emulator/storage/apis/firebase.js +11 -10
  84. package/lib/emulator/storage/apis/gcloud.js +21 -20
  85. package/lib/emulator/storage/files.js +1 -1
  86. package/lib/emulator/storage/rules/manager.js +15 -12
  87. package/lib/emulator/storage/server.js +10 -5
  88. package/lib/experiments.js +5 -0
  89. package/lib/extensions/extensionsHelper.js +2 -2
  90. package/lib/extensions/listExtensions.js +1 -1
  91. package/lib/extensions/paramHelper.js +1 -1
  92. package/lib/extensions/provisioningHelper.js +1 -6
  93. package/lib/firestore/delete.js +2 -3
  94. package/lib/firestore/util.js +3 -3
  95. package/lib/frameworks/angular/utils.js +1 -1
  96. package/lib/frameworks/next/constants.js +17 -14
  97. package/lib/frameworks/next/index.js +25 -3
  98. package/lib/frameworks/next/utils.js +7 -9
  99. package/lib/functions/kits/install.js +221 -316
  100. package/lib/functions/kits/sources/directory.js +32 -0
  101. package/lib/functions/kits/sources/npm.js +55 -5
  102. package/lib/functionsConfig.js +0 -4
  103. package/lib/functionsShellCommandAction.js +1 -1
  104. package/lib/gcp/cloudbilling.js +2 -2
  105. package/lib/gcp/cloudbuild.js +0 -77
  106. package/lib/gcp/cloudfunctionsv2.js +0 -6
  107. package/lib/gcp/cloudscheduler.js +12 -0
  108. package/lib/gcp/cloudtasks.js +0 -4
  109. package/lib/gcp/devConnect.js +2 -8
  110. package/lib/gcp/iam.js +15 -1
  111. package/lib/gcp/resourceManager.js +1 -14
  112. package/lib/gcp/storage.js +87 -4
  113. package/lib/hosting/api.js +79 -7
  114. package/lib/hosting/implicitInit.js +1 -1
  115. package/lib/hosting/proxy.js +5 -2
  116. package/lib/init/features/firestore/rules.js +1 -1
  117. package/lib/init/features/functions/index.js +2 -2
  118. package/lib/init/features/functions/npm-dependencies.js +1 -1
  119. package/lib/init/features/hosting/github.js +6 -4
  120. package/lib/init/features/hosting/index.js +4 -0
  121. package/lib/init/features/storage/rules.js +1 -1
  122. package/lib/localFunction.js +3 -3
  123. package/lib/management/database.js +1 -1
  124. package/lib/mcp/apps/init/mcp-app.js +5 -2
  125. package/lib/mcp/apps/update_environment/mcp-app.js +1 -1
  126. package/lib/mcp/index.js +14 -4
  127. package/lib/mcp/prompts/apptesting/run_test.js +3 -3
  128. package/lib/mcp/prompts/core/deploy.js +3 -3
  129. package/lib/mcp/resources/guides/init_ai.js +10 -10
  130. package/lib/mcp/tools/crashlytics/events.js +18 -93
  131. package/lib/mcp/tools/crashlytics/index.js +2 -0
  132. package/lib/mcp/tools/crashlytics/reports.js +3 -3
  133. package/lib/mcp/tools/crashlytics/setup.js +392 -0
  134. package/lib/mcp/util/dataconnect/converter.js +1 -1
  135. package/lib/profileReport.js +1 -1
  136. package/lib/profiler.js +1 -1
  137. package/lib/rulesDeploy.js +0 -1
  138. package/lib/throttler/throttler.js +1 -1
  139. package/lib/tsconfig.publish.tsbuildinfo +1 -1
  140. package/lib/utils.js +5 -11
  141. package/package.json +16 -14
  142. package/schema/firebase-config.json +3 -0
  143. package/lib/functions/kits/sources/index.js +0 -19
@@ -2,10 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PLATFORM_PATH = exports.CRASHLYTICS_API_CLIENT = exports.TIMEOUT = void 0;
4
4
  exports.parseProjectNumber = parseProjectNumber;
5
+ exports.parseAppPlatform = parseAppPlatform;
5
6
  exports.parsePlatform = parsePlatform;
6
7
  const error_1 = require("../error");
7
8
  const apiv2_1 = require("../apiv2");
8
9
  const api_1 = require("../api");
10
+ const apps_1 = require("../management/apps");
9
11
  exports.TIMEOUT = 10000;
10
12
  exports.CRASHLYTICS_API_CLIENT = new apiv2_1.Client({
11
13
  urlPrefix: (0, api_1.crashlyticsApiOrigin)(),
@@ -23,6 +25,18 @@ function parseProjectNumber(appId) {
23
25
  }
24
26
  throw new error_1.FirebaseError("Unable to get the projectId from the AppId.");
25
27
  }
28
+ function parseAppPlatform(appId) {
29
+ const platformSegment = appId?.split(":")[2];
30
+ if (!platformSegment) {
31
+ return undefined;
32
+ }
33
+ try {
34
+ return (0, apps_1.getAppPlatform)(platformSegment);
35
+ }
36
+ catch {
37
+ return undefined;
38
+ }
39
+ }
26
40
  function parsePlatform(appId) {
27
41
  const appIdParts = appId.split(":");
28
42
  if (appIdParts.length < 3) {
@@ -124,10 +124,11 @@ class DatabaseImporter {
124
124
  done();
125
125
  };
126
126
  const writeBatch = new stream.Transform({ objectMode: true });
127
- writeBatch._transform = async function (batch, _, done) {
128
- const res = await doWriteBatch(batch);
129
- this.push(res);
130
- done();
127
+ writeBatch._transform = function (batch, _, done) {
128
+ void doWriteBatch(batch).then((res) => {
129
+ this.push(res);
130
+ done();
131
+ }, (err) => done(err));
131
132
  };
132
133
  return new Promise((resolve, reject) => {
133
134
  const responses = [];
@@ -29,8 +29,10 @@ async function listLocations(projectId) {
29
29
  const res = await dataconnectClient().get(`/projects/${projectId}/locations`);
30
30
  return res.body?.locations?.map((l) => l.locationId) ?? [];
31
31
  }
32
- async function getService(serviceName) {
33
- const res = await dataconnectClient().get(serviceName);
32
+ async function getService(serviceName, fields = []) {
33
+ const res = await dataconnectClient().get(serviceName, {
34
+ queryParams: fields.length ? { fields: fields.join(",") } : undefined,
35
+ });
34
36
  return res.body;
35
37
  }
36
38
  async function listAllServices(projectId) {
@@ -71,9 +73,11 @@ async function deleteService(serviceName) {
71
73
  });
72
74
  return pollRes;
73
75
  }
74
- async function getSchema(serviceName, schemaId = types.MAIN_SCHEMA_ID) {
76
+ async function getSchema(serviceName, schemaId = types.MAIN_SCHEMA_ID, fields = []) {
75
77
  try {
76
- const res = await dataconnectClient().get(`${serviceName}/schemas/${schemaId}`);
78
+ const res = await dataconnectClient().get(`${serviceName}/schemas/${schemaId}`, {
79
+ queryParams: fields.length ? { fields: fields.join(",") } : undefined,
80
+ });
77
81
  return res.body;
78
82
  }
79
83
  catch (err) {
@@ -90,7 +94,7 @@ async function listSchemas(serviceName, fields = []) {
90
94
  queryParams: {
91
95
  pageSize: PAGE_SIZE_MAX,
92
96
  pageToken,
93
- fields: fields.join(","),
97
+ ...(fields.length ? { fields: fields.join(",") } : {}),
94
98
  },
95
99
  });
96
100
  schemas.push(...(res.body.schemas || []));
@@ -127,8 +131,10 @@ async function deleteSchema(name) {
127
131
  });
128
132
  return;
129
133
  }
130
- async function getConnector(name) {
131
- const res = await dataconnectClient().get(name);
134
+ async function getConnector(name, fields = []) {
135
+ const res = await dataconnectClient().get(name, {
136
+ queryParams: fields.length ? { fields: fields.join(",") } : undefined,
137
+ });
132
138
  return res.body;
133
139
  }
134
140
  async function deleteConnector(name) {
@@ -147,7 +153,7 @@ async function listConnectors(serviceName, fields = []) {
147
153
  queryParams: {
148
154
  pageSize: PAGE_SIZE_MAX,
149
155
  pageToken,
150
- fields: fields.join(","),
156
+ ...(fields.length ? { fields: fields.join(",") } : {}),
151
157
  },
152
158
  });
153
159
  connectors.push(...(res.body.connectors || []));
@@ -5,7 +5,7 @@ exports.parseConnectorName = parseConnectorName;
5
5
  exports.parseCloudSQLInstanceName = parseCloudSQLInstanceName;
6
6
  exports.isGraphqlName = isGraphqlName;
7
7
  const error_1 = require("../error");
8
- const serviceNameRegex = /projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/services\/(?<serviceId>[^\/]+)/;
8
+ const serviceNameRegex = /projects\/(?<projectId>[^/]+)\/locations\/(?<location>[^/]+)\/services\/(?<serviceId>[^/]+)/;
9
9
  function parseServiceName(serviceName) {
10
10
  const res = serviceNameRegex.exec(serviceName);
11
11
  const projectId = res?.groups?.projectId;
@@ -24,7 +24,7 @@ function parseServiceName(serviceName) {
24
24
  toString,
25
25
  };
26
26
  }
27
- const connectorNameRegex = /projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/services\/(?<serviceId>[^\/]+)\/connectors\/(?<connectorId>[^\/]+)/;
27
+ const connectorNameRegex = /projects\/(?<projectId>[^/]+)\/locations\/(?<location>[^/]+)\/services\/(?<serviceId>[^/]+)\/connectors\/(?<connectorId>[^/]+)/;
28
28
  function parseConnectorName(connectorName) {
29
29
  const res = connectorNameRegex.exec(connectorName);
30
30
  const projectId = res?.groups?.projectId;
@@ -45,7 +45,7 @@ function parseConnectorName(connectorName) {
45
45
  toString,
46
46
  };
47
47
  }
48
- const cloudSQLInstanceNameRegex = /projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/instances\/(?<instanceId>[^\/]+)/;
48
+ const cloudSQLInstanceNameRegex = /projects\/(?<projectId>[^/]+)\/locations\/(?<location>[^/]+)\/instances\/(?<instanceId>[^/]+)/;
49
49
  function parseCloudSQLInstanceName(cloudSQLInstanceName) {
50
50
  const res = cloudSQLInstanceNameRegex.exec(cloudSQLInstanceName);
51
51
  const projectId = res?.groups?.projectId;
@@ -576,5 +576,5 @@ function diffsToString(diffs) {
576
576
  return diffs.map(diffToString).join("\n\n");
577
577
  }
578
578
  function diffToString(diff) {
579
- return `\/** ${diff.destructive ? clc.red("Destructive: ") : ""}${diff.description}*\/\n${(0, sql_formatter_1.format)(diff.sql, { language: "postgresql" })}`;
579
+ return `/** ${diff.destructive ? clc.red("Destructive: ") : ""}${diff.description}*/\n${(0, sql_formatter_1.format)(diff.sql, { language: "postgresql" })}`;
580
580
  }
@@ -109,11 +109,11 @@ async function default_1(context, options) {
109
109
  async function deployedConnectors(serviceInfos) {
110
110
  let connectors = [];
111
111
  for (const si of serviceInfos) {
112
- connectors = connectors.concat(await (0, client_1.listConnectors)(si.serviceName));
112
+ connectors = connectors.concat(await (0, client_1.listConnectors)(si.serviceName, ["connectors.name", "nextPageToken"]));
113
113
  }
114
114
  return connectors;
115
115
  }
116
116
  async function deployedSchemas(serviceInfos) {
117
- const schemasPerService = await Promise.all(serviceInfos.map((si) => (0, client_1.listSchemas)(si.serviceName)));
117
+ const schemasPerService = await Promise.all(serviceInfos.map((si) => (0, client_1.listSchemas)(si.serviceName, ["schemas.name", "nextPageToken"])));
118
118
  return schemasPerService.flat();
119
119
  }
@@ -12,6 +12,7 @@ const api_1 = require("../../api");
12
12
  const error_1 = require("../../error");
13
13
  const types = require("../../firestore/api-types");
14
14
  const api_2 = require("../../firestore/api");
15
+ const DEFAULT_FIRESTORE_LOCATION = "nam5";
15
16
  function prepareRules(context, rulesDeploy, databaseId, rulesFile) {
16
17
  rulesDeploy.addFile(rulesFile, databaseId);
17
18
  context.firestore.rules.push({
@@ -73,11 +74,18 @@ async function createDatabase(context, options) {
73
74
  }
74
75
  catch (e) {
75
76
  if (e.status === 404) {
77
+ const locationId = firestoreCfg.location || DEFAULT_FIRESTORE_LOCATION;
78
+ if (options.dryRun) {
79
+ utils.logLabeledWarning("firestore", `Database ${clc.bold(firestoreCfg.database)} does not exist. A deploy would create it in ` +
80
+ `${clc.bold(locationId)}${firestoreCfg.location ? "" : " (the default, because firebase.json sets no location)"}. ` +
81
+ "Skipping database creation because this is a dry run.");
82
+ return true;
83
+ }
76
84
  utils.logLabeledBullet("firestore", `Creating the new Firestore database ${firestoreCfg.database}...`);
77
85
  const createDatabaseReq = {
78
86
  project: options.projectId,
79
87
  databaseId: firestoreCfg.database,
80
- locationId: firestoreCfg.location || "nam5",
88
+ locationId,
81
89
  type: types.DatabaseType.FIRESTORE_NATIVE,
82
90
  databaseEdition: edition,
83
91
  deleteProtectionState: types.DatabaseDeleteProtectionState.DISABLED,
@@ -88,6 +96,7 @@ async function createDatabase(context, options) {
88
96
  await api.createDatabase(createDatabaseReq);
89
97
  }
90
98
  }
99
+ return false;
91
100
  }
92
101
  async function default_1(context, options) {
93
102
  await (0, ensureApiEnabled_1.ensure)(context.projectId, (0, api_1.firestoreOrigin)(), "firestore");
@@ -115,7 +124,7 @@ async function default_1(context, options) {
115
124
  context.firestore.rules = [];
116
125
  const rulesDeploy = new rulesDeploy_1.RulesDeploy(options, rulesDeploy_1.RulesetServiceType.CLOUD_FIRESTORE);
117
126
  context.firestore.rulesDeploy = rulesDeploy;
118
- await createDatabase(context, options);
127
+ const skippedDatabaseCreation = await createDatabase(context, options);
119
128
  for (const firestoreConfig of firestoreConfigs) {
120
129
  if (firestoreConfig.indexes) {
121
130
  prepareIndexes(context, options, firestoreConfig.database, firestoreConfig.indexes);
@@ -125,7 +134,16 @@ async function default_1(context, options) {
125
134
  }
126
135
  }
127
136
  if (context.firestore.rules.length > 0) {
128
- await rulesDeploy.compile();
137
+ try {
138
+ await rulesDeploy.compile();
139
+ }
140
+ catch (err) {
141
+ if (!skippedDatabaseCreation || (0, error_1.getErrStatus)(err) !== 403) {
142
+ throw err;
143
+ }
144
+ utils.logLabeledWarning("firestore", "Could not check the rules for compilation errors (HTTP 403), most likely because the " +
145
+ "project has no Firestore database yet. A deploy creates the database before it checks the rules.");
146
+ }
129
147
  }
130
148
  const rulesContext = context?.firestore?.rules;
131
149
  for (const ruleContext of rulesContext) {
@@ -18,7 +18,6 @@ exports.isBlockingTriggered = isBlockingTriggered;
18
18
  exports.empty = empty;
19
19
  exports.of = of;
20
20
  exports.merge = merge;
21
- exports.isEmptyBackend = isEmptyBackend;
22
21
  exports.functionName = functionName;
23
22
  exports.scheduleIdForFunction = scheduleIdForFunction;
24
23
  exports.existingBackend = existingBackend;
@@ -27,7 +26,6 @@ exports.allEndpoints = allEndpoints;
27
26
  exports.someEndpoint = someEndpoint;
28
27
  exports.findEndpoint = findEndpoint;
29
28
  exports.matchingBackend = matchingBackend;
30
- exports.regionalEndpoints = regionalEndpoints;
31
29
  exports.compareFunctions = compareFunctions;
32
30
  exports.maybeDeterministicCloudRunUri = maybeDeterministicCloudRunUri;
33
31
  const gcf = require("../../gcp/cloudfunctions");
@@ -192,11 +190,6 @@ function merge(...backends) {
192
190
  }
193
191
  return merged;
194
192
  }
195
- function isEmptyBackend(backend) {
196
- return (Object.keys(backend.requiredAPIs).length === 0 &&
197
- Object.keys(backend.endpoints).length === 0 &&
198
- Object.keys(backend.lifecycleHooks || {}).length === 0);
199
- }
200
193
  function functionName(cloudFunction) {
201
194
  return `projects/${cloudFunction.project}/locations/${cloudFunction.region}/functions/${cloudFunction.id}`;
202
195
  }
@@ -345,9 +338,6 @@ function matchingBackend(backend, predicate) {
345
338
  }
346
339
  return filtered;
347
340
  }
348
- function regionalEndpoints(backend, region) {
349
- return backend.endpoints[region] ? Object.values(backend.endpoints[region]) : [];
350
- }
351
341
  const hasEndpoint = (backend) => (endpoint) => {
352
342
  return (!!backend.endpoints[endpoint.region] && !!backend.endpoints[endpoint.region][endpoint.id]);
353
343
  };
@@ -100,12 +100,12 @@ function resolveExpression(wantType, expr, params) {
100
100
  return resolveComparison(expr, params);
101
101
  }
102
102
  else {
103
- throw new ExprParseError("CEL expression '" + expr + "' is of an unsupported form");
103
+ throw new ExprParseError(`CEL expression '${String(expr)}' is of an unsupported form`);
104
104
  }
105
105
  }
106
106
  function preprocessLists(wantType, expr, params) {
107
107
  let rv = expr;
108
- const listMatcher = /\[[^\[\]]*\]/g;
108
+ const listMatcher = /\[[^[\]]*\]/g;
109
109
  let match;
110
110
  while ((match = listMatcher.exec(expr)) != null) {
111
111
  const list = match[0];
@@ -18,6 +18,7 @@ const experiments = require("../../experiments");
18
18
  const supported = require("./runtimes/supported");
19
19
  const backend_1 = require("./backend");
20
20
  const extensions_1 = require("../extensions");
21
+ const error_1 = require("../../error");
21
22
  const getProjectNumber_1 = require("../../getProjectNumber");
22
23
  const path = require("path");
23
24
  (0, tmp_1.setGracefulCleanup)();
@@ -115,7 +116,7 @@ async function uploadCodebase(context, projectNumber, codebase, wantBackend) {
115
116
  }
116
117
  }
117
118
  catch (err) {
118
- (0, utils_1.logWarning)(clc.yellow("functions:") + " Upload Error: " + err.message);
119
+ (0, utils_1.logWarning)(`${clc.yellow("functions:")} Upload Error: ${(0, error_1.getErrMsg)(err)}`);
119
120
  throw err;
120
121
  }
121
122
  }
@@ -10,6 +10,7 @@ exports.inferBlockingDetails = inferBlockingDetails;
10
10
  exports.resolveCpuAndConcurrency = resolveCpuAndConcurrency;
11
11
  exports.resolveDefaultTimeout = resolveDefaultTimeout;
12
12
  exports.loadCodebases = loadCodebases;
13
+ exports.ensureScheduleRegionsSupported = ensureScheduleRegionsSupported;
13
14
  exports.getExecutablePaths = getExecutablePaths;
14
15
  exports.stripStaleDartBuildIgnore = stripStaleDartBuildIgnore;
15
16
  exports.warnIfNewGenkitFunctionIsMissingSecrets = warnIfNewGenkitFunctionIsMissingSecrets;
@@ -51,6 +52,7 @@ const functional_1 = require("../../functional");
51
52
  const prepare_1 = require("../extensions/prepare");
52
53
  const prompt = require("../../prompt");
53
54
  const iam = require("../../gcp/iam");
55
+ const scheduler = require("../../gcp/cloudscheduler");
54
56
  const resourcemanager = require("../../gcp/resourceManager");
55
57
  exports.EVENTARC_SOURCE_ENV = "EVENTARC_CLOUD_EVENT_SOURCE";
56
58
  exports.DECLARATIVE_SECURITY_ETAG_LABEL = "firebase-declarative-security-etag";
@@ -342,6 +344,7 @@ async function prepare(context, options, payload) {
342
344
  const matchingBackend = backend.matchingBackend(wantBackend, (endpoint) => {
343
345
  return (0, functionsDeployHelper_1.endpointMatchesAnyFilter)(endpoint, context.filters);
344
346
  });
347
+ await ensureScheduleRegionsSupported(projectId, matchingBackend);
345
348
  await (0, prompts_1.promptForFailurePolicies)(options, matchingBackend, haveBackend);
346
349
  await (0, prompts_1.promptForMinInstances)(options, matchingBackend, haveBackend);
347
350
  await backend.checkAvailability(context, matchingBackend);
@@ -568,6 +571,31 @@ async function loadCodebases(config, options, firebaseConfig, runtimeConfig, fil
568
571
  }
569
572
  return wantBuilds;
570
573
  }
574
+ async function ensureScheduleRegionsSupported(projectId, want) {
575
+ const scheduled = backend
576
+ .allEndpoints(want)
577
+ .filter((ep) => backend.isScheduleTriggered(ep) && ep.platform === "gcfv2");
578
+ if (scheduled.length === 0) {
579
+ return;
580
+ }
581
+ let supported;
582
+ try {
583
+ supported = await scheduler.listLocations(projectId);
584
+ }
585
+ catch (err) {
586
+ logger_1.logger.debug(`Failed to list Cloud Scheduler locations: ${(0, error_1.getErrMsg)(err)}`);
587
+ return;
588
+ }
589
+ if (supported.length === 0) {
590
+ return;
591
+ }
592
+ const unsupported = scheduled.filter((ep) => !supported.includes(ep.region));
593
+ if (unsupported.length > 0) {
594
+ const fns = unsupported.map((ep) => `${ep.id}(${ep.region})`).join(", ");
595
+ throw new error_1.FirebaseError(`Cloud Scheduler is not available in the region of these scheduled functions: ${fns}. ` +
596
+ `Deploy them to a region that supports Cloud Scheduler: ${[...supported].sort().join(", ")}.`);
597
+ }
598
+ }
571
599
  function warnIfDartBackendHasUnsupportedTriggers(want) {
572
600
  const dartEndpoints = backend.allEndpoints(want).filter(triggerSupport_1.isDartEndpoint);
573
601
  if (dartEndpoints.length === 0) {
@@ -321,7 +321,7 @@ class Fabricator {
321
321
  await this.updateV1Function(update.endpoint, scraperV1);
322
322
  }
323
323
  else if (update.endpoint.platform === "gcfv2") {
324
- await this.updateV2Function(update.endpoint, scraperV2);
324
+ await this.updateV2Function(update.endpoint, scraperV2, update.failedCreate);
325
325
  }
326
326
  else if (update.endpoint.platform === "run") {
327
327
  await this.updateRunFunction(update);
@@ -496,6 +496,9 @@ class Fabricator {
496
496
  utils.logLabeledWarning("functions", "Updated function is not associated with a service. This deployment is in an unexpected state - please re-deploy your functions.");
497
497
  return;
498
498
  }
499
+ await this.setV2InvokerCreate(endpoint, serviceName);
500
+ }
501
+ async setV2InvokerCreate(endpoint, serviceName) {
499
502
  if (backend.isHttpsTriggered(endpoint)) {
500
503
  const invoker = endpoint.httpsTrigger.invoker || ["public"];
501
504
  if (!invoker.includes("private")) {
@@ -584,7 +587,7 @@ class Fabricator {
584
587
  .catch(rethrowAs(endpoint, "set invoker"));
585
588
  }
586
589
  }
587
- async updateV2Function(endpoint, scraper) {
590
+ async updateV2Function(endpoint, scraper, failedCreate = false) {
588
591
  const storageSource = this.sources[endpoint.codebase]?.storage;
589
592
  if (!storageSource) {
590
593
  logger_1.logger.debug("Precondition failed. Cannot update a GCFv2 function without storage");
@@ -628,6 +631,10 @@ class Fabricator {
628
631
  utils.logLabeledWarning("functions", "Updated function is not associated with a service. This deployment is in an unexpected state - please re-deploy your functions.");
629
632
  return;
630
633
  }
634
+ if (failedCreate) {
635
+ await this.setV2InvokerCreate(endpoint, serviceName);
636
+ return;
637
+ }
631
638
  let invoker;
632
639
  if (backend.isHttpsTriggered(endpoint)) {
633
640
  invoker = endpoint.httpsTrigger.invoker === null ? ["public"] : endpoint.httpsTrigger.invoker;
@@ -901,7 +908,24 @@ class Fabricator {
901
908
  const jobName = scheduler.jobNameForEndpoint(endpoint, endpoint.region);
902
909
  await this.executor
903
910
  .run(() => scheduler.deleteJob(jobName))
904
- .catch(rethrowAsUnlessNotFound(endpoint, "delete schedule"));
911
+ .catch(async (err) => {
912
+ if ((0, executor_1.parseErrorCode)(err) === 400 &&
913
+ !(await this.schedulerSupportsRegion(endpoint.project, endpoint.region))) {
914
+ logger_1.logger.debug(`Cloud Scheduler does not support ${endpoint.region}; no schedule to delete for ${endpoint.id}.`);
915
+ return;
916
+ }
917
+ return rethrowAsUnlessNotFound(endpoint, "delete schedule")(err);
918
+ });
919
+ }
920
+ async schedulerSupportsRegion(projectId, region) {
921
+ try {
922
+ const regions = await scheduler.listLocations(projectId);
923
+ return regions.length === 0 || regions.includes(region);
924
+ }
925
+ catch (err) {
926
+ logger_1.logger.debug(`Failed to list Cloud Scheduler locations: ${(0, error_1.getErrMsg)(err)}`);
927
+ return true;
928
+ }
905
929
  }
906
930
  async disableTaskQueue(endpoint) {
907
931
  await this.executor
@@ -74,6 +74,9 @@ function calculateUpdate(want, have) {
74
74
  if (needsDelete) {
75
75
  update.deleteAndRecreate = have;
76
76
  }
77
+ else if (have.platform === "gcfv2" && have.state === "FAILED" && !have.runServiceId) {
78
+ update.failedCreate = true;
79
+ }
77
80
  return update;
78
81
  }
79
82
  async function createDeploymentPlan(args) {
@@ -4,7 +4,6 @@ exports.AbortedDeploymentError = exports.DeploymentError = void 0;
4
4
  exports.logAndTrackDeployStats = logAndTrackDeployStats;
5
5
  exports.printErrors = printErrors;
6
6
  exports.printAbortedErrors = printAbortedErrors;
7
- exports.triggerTag = triggerTag;
8
7
  const backend = require("../backend");
9
8
  const clc = require("colorette");
10
9
  const logger_1 = require("../../../logger");
@@ -170,28 +169,3 @@ function printAbortedErrors(results) {
170
169
  aborted.map((result) => `\n\t${(0, functionsDeployHelper_1.getFunctionLabel)(result.endpoint)}`).join(""));
171
170
  logger_1.logger.info(`To delete these, use ${clc.bold("firebase functions:delete")}`);
172
171
  }
173
- function triggerTag(endpoint) {
174
- const prefix = endpoint.platform === "gcfv1" ? "v1" : "v2";
175
- if (backend.isScheduleTriggered(endpoint)) {
176
- return `${prefix}.scheduled`;
177
- }
178
- if (backend.isTaskQueueTriggered(endpoint)) {
179
- return `${prefix}.taskQueue`;
180
- }
181
- if (backend.isCallableTriggered(endpoint)) {
182
- return `${prefix}.callable`;
183
- }
184
- if (backend.isHttpsTriggered(endpoint)) {
185
- if (endpoint.labels?.["deployment-callable"]) {
186
- return `${prefix}.callable`;
187
- }
188
- return `${prefix}.https`;
189
- }
190
- if (backend.isDataConnectGraphqlTriggered(endpoint)) {
191
- return `${prefix}.dataConnectGraphql`;
192
- }
193
- if (backend.isBlockingTriggered(endpoint)) {
194
- return `${prefix}.blocking`;
195
- }
196
- return endpoint.eventTrigger.eventType;
197
- }
@@ -109,7 +109,7 @@ async function detectFromOutputPath(childProcess, manifestPath, project, runtime
109
109
  childProcess.stderr?.on("data", (chunk) => {
110
110
  stderrBuffer += chunk.toString();
111
111
  });
112
- childProcess.on("exit", async (code) => {
112
+ const onExit = async (code) => {
113
113
  if (!resolved) {
114
114
  clearTimeout(timer);
115
115
  resolved = true;
@@ -133,6 +133,9 @@ async function detectFromOutputPath(childProcess, manifestPath, project, runtime
133
133
  }
134
134
  }
135
135
  }
136
+ };
137
+ childProcess.on("exit", (code) => {
138
+ void onExit(code);
136
139
  });
137
140
  childProcess.on("error", (err) => {
138
141
  if (!resolved) {
@@ -88,7 +88,7 @@ function assertKeyTypes(prefix, yaml, schema) {
88
88
  }
89
89
  }
90
90
  else {
91
- throw new error_1.FirebaseError("YAML validation is missing a handled type " + schema[key]);
91
+ throw new error_1.FirebaseError(`YAML validation is missing a handled type ${String(schema[key])}`);
92
92
  }
93
93
  }
94
94
  }
@@ -80,7 +80,7 @@ function buildFromV1Alpha1(yaml, project, region, runtime) {
80
80
  }
81
81
  return bd;
82
82
  }
83
- const ROLE_REGEX = /^(roles\/[a-zA-Z0-9_\.\-]+|projects\/[a-zA-Z0-9\-]+\/roles\/[a-zA-Z0-9_\.\-]+|organizations\/[0-9]+\/roles\/[a-zA-Z0-9_\.\-]+)$/;
83
+ const ROLE_REGEX = /^(roles\/[a-zA-Z0-9_.-]+|projects\/[a-zA-Z0-9-]+\/roles\/[a-zA-Z0-9_.-]+|organizations\/[0-9]+\/roles\/[a-zA-Z0-9_.-]+)$/;
84
84
  function parseRequiredRoles(manifest) {
85
85
  const roles = manifest.requiredRoles || [];
86
86
  for (const role of roles) {
@@ -29,8 +29,8 @@ function isRuntime(maybe) {
29
29
  function runtimeIsLanguage(runtime, language) {
30
30
  return !!runtime && runtime.startsWith(language);
31
31
  }
32
- function latest(language, runtimes = Object.keys(types_1.RUNTIMES)) {
33
- const sorted = runtimes
32
+ function latest(language, runtimes) {
33
+ const sorted = (runtimes ?? Object.keys(types_1.RUNTIMES))
34
34
  .filter((s) => runtimeIsLanguage(s, language))
35
35
  .sort((left, right) => {
36
36
  const leftVersion = +left.substring(language.length);
@@ -42,7 +42,8 @@ function latest(language, runtimes = Object.keys(types_1.RUNTIMES)) {
42
42
  }
43
43
  return leftVersion - rightVersion;
44
44
  });
45
- const latest = utils.last(sorted);
45
+ const ga = runtimes ? [] : sorted.filter((r) => types_1.RUNTIMES[r]?.status === "GA");
46
+ const latest = utils.last(ga.length ? ga : sorted);
46
47
  if (!latest) {
47
48
  throw new error_1.FirebaseError(`Internal error trying to find the latest supported runtime for ${language}`, { exit: 1 });
48
49
  }
@@ -53,12 +54,17 @@ function isDecommissioned(runtime, now = new Date()) {
53
54
  return cutoff < now;
54
55
  }
55
56
  function guardVersionSupport(runtime, now = new Date()) {
56
- const { deprecationDate, decommissionDate } = types_1.RUNTIMES[runtime];
57
+ const { friendly, status, deprecationDate, decommissionDate } = types_1.RUNTIMES[runtime];
57
58
  const decommission = new Date(decommissionDate);
58
59
  if (now >= decommission) {
59
60
  throw new error_1.FirebaseError(`Runtime ${types_1.RUNTIMES[runtime].friendly} was decommissioned on ${decommissionDate}. To deploy ` +
60
61
  "you must first upgrade your runtime version.", { exit: 1 });
61
62
  }
63
+ if (status === "beta") {
64
+ utils.logLabeledWarning("functions", `Runtime ${friendly} is in Preview. Preview runtimes may change and are not recommended ` +
65
+ "for production workloads. See https://cloud.google.com/functions/docs/runtime-support " +
66
+ "for details.");
67
+ }
62
68
  const deprecation = new Date(deprecationDate);
63
69
  if (now >= deprecation) {
64
70
  utils.logLabeledWarning("functions", `Runtime ${types_1.RUNTIMES[runtime].friendly} was deprecated on ${deprecationDate} and will be ` +
@@ -57,7 +57,7 @@ exports.RUNTIMES = runtimes({
57
57
  friendly: "Node.js 22",
58
58
  status: "GA",
59
59
  deprecationDate: "2027-04-30",
60
- decommissionDate: "2028-10-31",
60
+ decommissionDate: "2027-10-31",
61
61
  },
62
62
  nodejs24: {
63
63
  friendly: "Node.js 24",
@@ -65,6 +65,12 @@ exports.RUNTIMES = runtimes({
65
65
  deprecationDate: "2028-04-30",
66
66
  decommissionDate: "2028-10-31",
67
67
  },
68
+ nodejs26: {
69
+ friendly: "Node.js 26",
70
+ status: "beta",
71
+ deprecationDate: "2029-04-30",
72
+ decommissionDate: "2029-10-31",
73
+ },
68
74
  python310: {
69
75
  friendly: "Python 3.10",
70
76
  status: "GA",