firebase-tools 11.6.0 → 11.8.1

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 (52) hide show
  1. package/lib/auth.js +1 -1
  2. package/lib/commands/crashlytics-mappingfile-generateid.js +26 -0
  3. package/lib/commands/crashlytics-mappingfile-upload.js +46 -0
  4. package/lib/commands/crashlytics-symbols-upload.js +18 -87
  5. package/lib/commands/functions-delete.js +2 -0
  6. package/lib/commands/functions-secrets-get.js +2 -0
  7. package/lib/commands/index.js +3 -0
  8. package/lib/crashlytics/buildToolsJarHelper.js +51 -0
  9. package/lib/deploy/functions/backend.js +4 -4
  10. package/lib/deploy/functions/build.js +98 -17
  11. package/lib/deploy/functions/cache/applyHash.js +29 -0
  12. package/lib/deploy/functions/cache/hash.js +30 -0
  13. package/lib/deploy/functions/cel.js +249 -0
  14. package/lib/deploy/functions/checkIam.js +6 -5
  15. package/lib/deploy/functions/functionsDeployHelper.js +12 -1
  16. package/lib/deploy/functions/params.js +262 -105
  17. package/lib/deploy/functions/prepare.js +34 -4
  18. package/lib/deploy/functions/prepareFunctionsUpload.js +12 -4
  19. package/lib/deploy/functions/release/fabricator.js +39 -6
  20. package/lib/deploy/functions/release/index.js +2 -0
  21. package/lib/deploy/functions/release/planner.js +17 -0
  22. package/lib/deploy/functions/runtimes/discovery/index.js +1 -16
  23. package/lib/deploy/functions/runtimes/discovery/parsing.js +16 -0
  24. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +59 -131
  25. package/lib/deploy/functions/runtimes/node/parseTriggers.js +10 -1
  26. package/lib/emulator/constants.js +1 -1
  27. package/lib/emulator/controller.js +6 -11
  28. package/lib/emulator/extensionsEmulator.js +1 -0
  29. package/lib/emulator/functionsEmulator.js +18 -59
  30. package/lib/emulator/functionsEmulatorRuntime.js +12 -23
  31. package/lib/emulator/functionsRuntimeWorker.js +38 -7
  32. package/lib/emulator/storage/apis/firebase.js +145 -129
  33. package/lib/emulator/storage/apis/gcloud.js +102 -42
  34. package/lib/emulator/storage/files.js +25 -15
  35. package/lib/emulator/storage/metadata.js +86 -56
  36. package/lib/emulator/storage/multipart.js +2 -2
  37. package/lib/emulator/storage/rules/runtime.js +10 -2
  38. package/lib/emulator/storage/upload.js +45 -9
  39. package/lib/extensions/extensionsHelper.js +1 -1
  40. package/lib/functions/constants.js +14 -0
  41. package/lib/functions/env.js +9 -9
  42. package/lib/functions/secrets.js +8 -1
  43. package/lib/gcp/cloudfunctions.js +15 -18
  44. package/lib/gcp/cloudfunctionsv2.js +15 -18
  45. package/lib/gcp/cloudscheduler.js +32 -14
  46. package/lib/gcp/secretManager.js +15 -1
  47. package/lib/gcp/storage.js +15 -1
  48. package/lib/previews.js +1 -1
  49. package/lib/track.js +3 -0
  50. package/npm-shrinkwrap.json +563 -30
  51. package/package.json +7 -5
  52. package/templates/init/storage/storage.rules +1 -1
@@ -161,9 +161,11 @@ function writeUserEnvs(toWrite, envOpts) {
161
161
  return;
162
162
  }
163
163
  const { functionsSource, projectId, projectAlias, isEmulator } = envOpts;
164
- let envFiles = findEnvfiles(functionsSource, projectId, projectAlias, isEmulator);
165
- if (envFiles.length === 0) {
166
- envFiles = [createEnvFile(envOpts)];
164
+ const envFiles = findEnvfiles(functionsSource, projectId, projectAlias, isEmulator);
165
+ const projectScopedFileName = `.env.${projectId}`;
166
+ const projectScopedFileExists = envFiles.includes(projectScopedFileName);
167
+ if (!projectScopedFileExists) {
168
+ createEnvFile(envOpts);
167
169
  }
168
170
  const currentEnvs = loadUserEnvs(envOpts);
169
171
  for (const k of Object.keys(toWrite)) {
@@ -172,17 +174,15 @@ function writeUserEnvs(toWrite, envOpts) {
172
174
  throw new error_1.FirebaseError(`Attempted to write param-defined key ${k} to .env files, but it was already defined.`);
173
175
  }
174
176
  }
175
- const mostSpecificEnv = path.join(functionsSource, envFiles[envFiles.length - 1]);
176
- (0, utils_1.logBullet)(clc.cyan(clc.bold("functions: ")) + `Writing new parameter values to disk: ${mostSpecificEnv}`);
177
+ (0, utils_1.logBullet)(clc.cyan(clc.bold("functions: ")) +
178
+ `Writing new parameter values to disk: ${projectScopedFileName}`);
177
179
  for (const k of Object.keys(toWrite)) {
178
- fs.appendFileSync(mostSpecificEnv, formatUserEnvForWrite(k, toWrite[k]));
180
+ fs.appendFileSync(path.join(functionsSource, projectScopedFileName), formatUserEnvForWrite(k, toWrite[k]));
179
181
  }
180
182
  }
181
183
  exports.writeUserEnvs = writeUserEnvs;
182
184
  function createEnvFile(envOpts) {
183
- const fileToWrite = envOpts.isEmulator
184
- ? FUNCTIONS_EMULATOR_DOTENV
185
- : `.env.${envOpts.projectAlias || envOpts.projectId}`;
185
+ const fileToWrite = envOpts.isEmulator ? FUNCTIONS_EMULATOR_DOTENV : `.env.${envOpts.projectId}`;
186
186
  logger_1.logger.debug(`Creating ${fileToWrite}...`);
187
187
  fs.writeFileSync(path.join(envOpts.functionsSource, fileToWrite), "", { flag: "wx" });
188
188
  return fileToWrite;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateEndpointSecret = exports.pruneAndDestroySecrets = exports.pruneSecrets = exports.inUse = exports.of = exports.ensureSecret = exports.ensureValidKey = exports.labels = exports.isFirebaseManaged = void 0;
3
+ exports.updateEndpointSecret = exports.pruneAndDestroySecrets = exports.pruneSecrets = exports.inUse = exports.getSecretVersions = exports.of = exports.ensureSecret = exports.ensureValidKey = exports.labels = exports.isFirebaseManaged = void 0;
4
4
  const utils = require("../utils");
5
5
  const poller = require("../operation-poller");
6
6
  const gcf = require("../gcp/cloudfunctions");
@@ -85,6 +85,13 @@ function of(endpoints) {
85
85
  return endpoints.reduce((envs, endpoint) => [...envs, ...(endpoint.secretEnvironmentVariables || [])], []);
86
86
  }
87
87
  exports.of = of;
88
+ function getSecretVersions(endpoint) {
89
+ return (endpoint.secretEnvironmentVariables || []).reduce((memo, { secret, version }) => {
90
+ memo[secret] = version || "";
91
+ return memo;
92
+ }, {});
93
+ }
94
+ exports.getSecretVersions = getSecretVersions;
88
95
  function inUse(projectInfo, secret, endpoint) {
89
96
  const { projectId, projectNumber } = projectInfo;
90
97
  for (const sev of of([endpoint])) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.functionFromEndpoint = exports.endpointFromFunction = exports.listAllFunctions = exports.listFunctions = exports.deleteFunction = exports.updateFunction = exports.setInvokerUpdate = exports.setInvokerCreate = exports.getIamPolicy = exports.setIamPolicy = exports.createFunction = exports.generateUploadUrl = exports.BLOCKING_LABEL = exports.CODEBASE_LABEL = exports.API_VERSION = void 0;
3
+ exports.functionFromEndpoint = exports.endpointFromFunction = exports.listAllFunctions = exports.listFunctions = exports.deleteFunction = exports.updateFunction = exports.setInvokerUpdate = exports.setInvokerCreate = exports.getIamPolicy = exports.setIamPolicy = exports.createFunction = exports.generateUploadUrl = exports.API_VERSION = void 0;
4
4
  const clc = require("colorette");
5
5
  const error_1 = require("../error");
6
6
  const logger_1 = require("../logger");
@@ -11,18 +11,9 @@ const runtimes = require("../deploy/functions/runtimes");
11
11
  const projectConfig = require("../functions/projectConfig");
12
12
  const apiv2_1 = require("../apiv2");
13
13
  const api_1 = require("../api");
14
+ const constants_1 = require("../functions/constants");
14
15
  exports.API_VERSION = "v1";
15
- exports.CODEBASE_LABEL = "firebase-functions-codebase";
16
16
  const client = new apiv2_1.Client({ urlPrefix: api_1.functionsOrigin, apiVersion: exports.API_VERSION });
17
- exports.BLOCKING_LABEL = "deployment-blocking";
18
- const BLOCKING_LABEL_KEY_TO_EVENT = {
19
- "before-create": "providers/cloud.auth/eventTypes/user.beforeCreate",
20
- "before-sign-in": "providers/cloud.auth/eventTypes/user.beforeSignIn",
21
- };
22
- const BLOCKING_EVENT_TO_LABEL_KEY = {
23
- "providers/cloud.auth/eventTypes/user.beforeCreate": "before-create",
24
- "providers/cloud.auth/eventTypes/user.beforeSignIn": "before-sign-in",
25
- };
26
17
  function functionsOpLogReject(funcName, type, err) {
27
18
  var _a, _b;
28
19
  if (((_b = (_a = err === null || err === void 0 ? void 0 : err.context) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.statusCode) === 429) {
@@ -199,7 +190,7 @@ async function listAllFunctions(projectId) {
199
190
  }
200
191
  exports.listAllFunctions = listAllFunctions;
201
192
  function endpointFromFunction(gcfFunction) {
202
- var _a, _b, _c, _d, _e, _f, _g;
193
+ var _a, _b, _c, _d, _e, _f, _g, _h;
203
194
  const [, project, , region, , id] = gcfFunction.name.split("/");
204
195
  let trigger;
205
196
  let uri;
@@ -220,10 +211,10 @@ function endpointFromFunction(gcfFunction) {
220
211
  callableTrigger: {},
221
212
  };
222
213
  }
223
- else if ((_e = gcfFunction.labels) === null || _e === void 0 ? void 0 : _e[exports.BLOCKING_LABEL]) {
214
+ else if ((_e = gcfFunction.labels) === null || _e === void 0 ? void 0 : _e[constants_1.BLOCKING_LABEL]) {
224
215
  trigger = {
225
216
  blockingTrigger: {
226
- eventType: BLOCKING_LABEL_KEY_TO_EVENT[gcfFunction.labels[exports.BLOCKING_LABEL]],
217
+ eventType: constants_1.BLOCKING_LABEL_KEY_TO_EVENT[gcfFunction.labels[constants_1.BLOCKING_LABEL]],
227
218
  },
228
219
  };
229
220
  }
@@ -263,7 +254,10 @@ function endpointFromFunction(gcfFunction) {
263
254
  endpoint.vpc = { connector: gcfFunction.vpcConnector };
264
255
  proto.convertIfPresent(endpoint.vpc, gcfFunction, "egressSettings", "vpcConnectorEgressSettings", (raw) => raw);
265
256
  }
266
- endpoint.codebase = ((_g = gcfFunction.labels) === null || _g === void 0 ? void 0 : _g[exports.CODEBASE_LABEL]) || projectConfig.DEFAULT_CODEBASE;
257
+ endpoint.codebase = ((_g = gcfFunction.labels) === null || _g === void 0 ? void 0 : _g[constants_1.CODEBASE_LABEL]) || projectConfig.DEFAULT_CODEBASE;
258
+ if ((_h = gcfFunction.labels) === null || _h === void 0 ? void 0 : _h[constants_1.HASH_LABEL]) {
259
+ endpoint.hash = gcfFunction.labels[constants_1.HASH_LABEL];
260
+ }
267
261
  return endpoint;
268
262
  }
269
263
  exports.endpointFromFunction = endpointFromFunction;
@@ -312,7 +306,7 @@ function functionFromEndpoint(endpoint, sourceUploadUrl) {
312
306
  }
313
307
  else if (backend.isBlockingTriggered(endpoint)) {
314
308
  gcfFunction.httpsTrigger = {};
315
- gcfFunction.labels = Object.assign(Object.assign({}, gcfFunction.labels), { [exports.BLOCKING_LABEL]: BLOCKING_EVENT_TO_LABEL_KEY[endpoint.blockingTrigger.eventType] });
309
+ gcfFunction.labels = Object.assign(Object.assign({}, gcfFunction.labels), { [constants_1.BLOCKING_LABEL]: constants_1.BLOCKING_EVENT_TO_LABEL_KEY[endpoint.blockingTrigger.eventType] });
316
310
  }
317
311
  else {
318
312
  gcfFunction.httpsTrigger = {};
@@ -337,10 +331,13 @@ function functionFromEndpoint(endpoint, sourceUploadUrl) {
337
331
  }
338
332
  const codebase = endpoint.codebase || projectConfig.DEFAULT_CODEBASE;
339
333
  if (codebase !== projectConfig.DEFAULT_CODEBASE) {
340
- gcfFunction.labels = Object.assign(Object.assign({}, gcfFunction.labels), { [exports.CODEBASE_LABEL]: codebase });
334
+ gcfFunction.labels = Object.assign(Object.assign({}, gcfFunction.labels), { [constants_1.CODEBASE_LABEL]: codebase });
341
335
  }
342
336
  else {
343
- (_b = gcfFunction.labels) === null || _b === void 0 ? true : delete _b[exports.CODEBASE_LABEL];
337
+ (_b = gcfFunction.labels) === null || _b === void 0 ? true : delete _b[constants_1.CODEBASE_LABEL];
338
+ }
339
+ if (endpoint.hash) {
340
+ gcfFunction.labels = Object.assign(Object.assign({}, gcfFunction.labels), { [constants_1.HASH_LABEL]: endpoint.hash });
344
341
  }
345
342
  return gcfFunction;
346
343
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.endpointFromFunction = exports.functionFromEndpoint = exports.deleteFunction = exports.updateFunction = exports.listAllFunctions = exports.listFunctions = exports.getFunction = exports.createFunction = exports.generateUploadUrl = exports.mebibytes = exports.BLOCKING_LABEL = exports.CODEBASE_LABEL = exports.API_VERSION = void 0;
3
+ exports.endpointFromFunction = exports.functionFromEndpoint = exports.deleteFunction = exports.updateFunction = exports.listAllFunctions = exports.listFunctions = exports.getFunction = exports.createFunction = exports.generateUploadUrl = exports.mebibytes = exports.API_VERSION = void 0;
4
4
  const clc = require("colorette");
5
5
  const apiv2_1 = require("../apiv2");
6
6
  const error_1 = require("../error");
@@ -12,22 +12,13 @@ const runtimes = require("../deploy/functions/runtimes");
12
12
  const proto = require("./proto");
13
13
  const utils = require("../utils");
14
14
  const projectConfig = require("../functions/projectConfig");
15
+ const constants_1 = require("../functions/constants");
15
16
  exports.API_VERSION = "v2alpha";
16
- exports.CODEBASE_LABEL = "firebase-functions-codebase";
17
17
  const client = new apiv2_1.Client({
18
18
  urlPrefix: api_1.functionsV2Origin,
19
19
  auth: true,
20
20
  apiVersion: exports.API_VERSION,
21
21
  });
22
- exports.BLOCKING_LABEL = "deployment-blocking";
23
- const BLOCKING_LABEL_KEY_TO_EVENT = {
24
- "before-create": "providers/cloud.auth/eventTypes/user.beforeCreate",
25
- "before-sign-in": "providers/cloud.auth/eventTypes/user.beforeSignIn",
26
- };
27
- const BLOCKING_EVENT_TO_LABEL_KEY = {
28
- "providers/cloud.auth/eventTypes/user.beforeCreate": "before-create",
29
- "providers/cloud.auth/eventTypes/user.beforeSignIn": "before-sign-in",
30
- };
31
22
  const BYTES_PER_UNIT = {
32
23
  "": 1,
33
24
  k: 1e3,
@@ -243,20 +234,23 @@ function functionFromEndpoint(endpoint, source) {
243
234
  gcfFunction.labels = Object.assign(Object.assign({}, gcfFunction.labels), { "deployment-callable": "true" });
244
235
  }
245
236
  else if (backend.isBlockingTriggered(endpoint)) {
246
- gcfFunction.labels = Object.assign(Object.assign({}, gcfFunction.labels), { [exports.BLOCKING_LABEL]: BLOCKING_EVENT_TO_LABEL_KEY[endpoint.blockingTrigger.eventType] });
237
+ gcfFunction.labels = Object.assign(Object.assign({}, gcfFunction.labels), { [constants_1.BLOCKING_LABEL]: constants_1.BLOCKING_EVENT_TO_LABEL_KEY[endpoint.blockingTrigger.eventType] });
247
238
  }
248
239
  const codebase = endpoint.codebase || projectConfig.DEFAULT_CODEBASE;
249
240
  if (codebase !== projectConfig.DEFAULT_CODEBASE) {
250
- gcfFunction.labels = Object.assign(Object.assign({}, gcfFunction.labels), { [exports.CODEBASE_LABEL]: codebase });
241
+ gcfFunction.labels = Object.assign(Object.assign({}, gcfFunction.labels), { [constants_1.CODEBASE_LABEL]: codebase });
251
242
  }
252
243
  else {
253
- (_b = gcfFunction.labels) === null || _b === void 0 ? true : delete _b[exports.CODEBASE_LABEL];
244
+ (_b = gcfFunction.labels) === null || _b === void 0 ? true : delete _b[constants_1.CODEBASE_LABEL];
245
+ }
246
+ if (endpoint.hash) {
247
+ gcfFunction.labels = Object.assign(Object.assign({}, gcfFunction.labels), { [constants_1.HASH_LABEL]: endpoint.hash });
254
248
  }
255
249
  return gcfFunction;
256
250
  }
257
251
  exports.functionFromEndpoint = functionFromEndpoint;
258
252
  function endpointFromFunction(gcfFunction) {
259
- var _a, _b, _c, _d, _e;
253
+ var _a, _b, _c, _d, _e, _f;
260
254
  const [, project, , region, , id] = gcfFunction.name.split("/");
261
255
  let trigger;
262
256
  if (((_a = gcfFunction.labels) === null || _a === void 0 ? void 0 : _a["deployment-scheduled"]) === "true") {
@@ -274,10 +268,10 @@ function endpointFromFunction(gcfFunction) {
274
268
  callableTrigger: {},
275
269
  };
276
270
  }
277
- else if ((_d = gcfFunction.labels) === null || _d === void 0 ? void 0 : _d[exports.BLOCKING_LABEL]) {
271
+ else if ((_d = gcfFunction.labels) === null || _d === void 0 ? void 0 : _d[constants_1.BLOCKING_LABEL]) {
278
272
  trigger = {
279
273
  blockingTrigger: {
280
- eventType: BLOCKING_LABEL_KEY_TO_EVENT[gcfFunction.labels[exports.BLOCKING_LABEL]],
274
+ eventType: constants_1.BLOCKING_LABEL_KEY_TO_EVENT[gcfFunction.labels[constants_1.BLOCKING_LABEL]],
281
275
  },
282
276
  };
283
277
  }
@@ -341,7 +335,10 @@ function endpointFromFunction(gcfFunction) {
341
335
  endpoint.vpc = { connector: gcfFunction.serviceConfig.vpcConnector };
342
336
  proto.renameIfPresent(endpoint.vpc, gcfFunction.serviceConfig, "egressSettings", "vpcConnectorEgressSettings");
343
337
  }
344
- endpoint.codebase = ((_e = gcfFunction.labels) === null || _e === void 0 ? void 0 : _e[exports.CODEBASE_LABEL]) || projectConfig.DEFAULT_CODEBASE;
338
+ endpoint.codebase = ((_e = gcfFunction.labels) === null || _e === void 0 ? void 0 : _e[constants_1.CODEBASE_LABEL]) || projectConfig.DEFAULT_CODEBASE;
339
+ if ((_f = gcfFunction.labels) === null || _f === void 0 ? void 0 : _f[constants_1.HASH_LABEL]) {
340
+ endpoint.hash = gcfFunction.labels[constants_1.HASH_LABEL];
341
+ }
345
342
  return endpoint;
346
343
  }
347
344
  exports.endpointFromFunction = endpointFromFunction;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jobFromEndpoint = exports.topicNameForEndpoint = exports.jobNameForEndpoint = exports.createOrReplaceJob = exports.updateJob = exports.getJob = exports.deleteJob = exports.createJob = void 0;
3
+ exports.jobFromEndpoint = exports.topicNameForEndpoint = exports.jobNameForEndpoint = exports.createOrReplaceJob = exports.getJob = exports.deleteJob = void 0;
4
4
  const _ = require("lodash");
5
5
  const error_1 = require("../error");
6
6
  const logger_1 = require("../logger");
@@ -8,15 +8,18 @@ const api_1 = require("../api");
8
8
  const apiv2_1 = require("../apiv2");
9
9
  const backend = require("../deploy/functions/backend");
10
10
  const proto = require("./proto");
11
+ const checkIam_1 = require("../deploy/functions/checkIam");
11
12
  const functional_1 = require("../functional");
12
13
  const VERSION = "v1";
13
- const DEFAULT_TIME_ZONE = "America/Los_Angeles";
14
+ const DEFAULT_TIME_ZONE_V1 = "America/Los_Angeles";
15
+ const DEFAULT_TIME_ZONE_V2 = "UTC";
14
16
  const apiClient = new apiv2_1.Client({ urlPrefix: api_1.cloudschedulerOrigin, apiVersion: VERSION });
15
17
  function createJob(job) {
16
18
  const strippedName = job.name.substring(0, job.name.lastIndexOf("/"));
17
- return apiClient.post(`/${strippedName}`, Object.assign({ timeZone: DEFAULT_TIME_ZONE }, job));
19
+ const json = job.pubsubTarget
20
+ ? Object.assign({ timeZone: DEFAULT_TIME_ZONE_V1 }, job) : Object.assign({ timeZone: DEFAULT_TIME_ZONE_V2 }, job);
21
+ return apiClient.post(`/${strippedName}`, json);
18
22
  }
19
- exports.createJob = createJob;
20
23
  function deleteJob(name) {
21
24
  return apiClient.delete(`/${name}`);
22
25
  }
@@ -28,14 +31,22 @@ function getJob(name) {
28
31
  }
29
32
  exports.getJob = getJob;
30
33
  function updateJob(job) {
31
- const fieldMasks = proto.fieldMasks(job, "pubsubTarget");
32
- return apiClient.patch(`/${job.name}`, Object.assign({ timeZone: DEFAULT_TIME_ZONE }, job), {
34
+ let fieldMasks;
35
+ let json;
36
+ if (job.pubsubTarget) {
37
+ fieldMasks = proto.fieldMasks(job, "pubsubTarget");
38
+ json = Object.assign({ timeZone: DEFAULT_TIME_ZONE_V1 }, job);
39
+ }
40
+ else {
41
+ fieldMasks = proto.fieldMasks(job, "httpTarget");
42
+ json = Object.assign({ timeZone: DEFAULT_TIME_ZONE_V2 }, job);
43
+ }
44
+ return apiClient.patch(`/${job.name}`, json, {
33
45
  queryParams: {
34
46
  updateMask: fieldMasks.join(","),
35
47
  },
36
48
  });
37
49
  }
38
- exports.updateJob = updateJob;
39
50
  async function createOrReplaceJob(job) {
40
51
  var _a, _b;
41
52
  const jobName = job.name.split("/").pop();
@@ -56,7 +67,7 @@ async function createOrReplaceJob(job) {
56
67
  return newJob;
57
68
  }
58
69
  if (!job.timeZone) {
59
- job.timeZone = DEFAULT_TIME_ZONE;
70
+ job.timeZone = job.pubsubTarget ? DEFAULT_TIME_ZONE_V1 : DEFAULT_TIME_ZONE_V2;
60
71
  }
61
72
  if (!needUpdate(existingJob.body, job)) {
62
73
  logger_1.logger.debug(`scheduler job ${jobName} is up to date, no changes required`);
@@ -90,9 +101,9 @@ function needUpdate(existingJob, newJob) {
90
101
  }
91
102
  return false;
92
103
  }
93
- function jobNameForEndpoint(endpoint, appEngineLocation) {
104
+ function jobNameForEndpoint(endpoint, location) {
94
105
  const id = backend.scheduleIdForFunction(endpoint);
95
- return `projects/${endpoint.project}/locations/${appEngineLocation}/jobs/${id}`;
106
+ return `projects/${endpoint.project}/locations/${location}/jobs/${id}`;
96
107
  }
97
108
  exports.jobNameForEndpoint = jobNameForEndpoint;
98
109
  function topicNameForEndpoint(endpoint) {
@@ -100,10 +111,11 @@ function topicNameForEndpoint(endpoint) {
100
111
  return `projects/${endpoint.project}/topics/${id}`;
101
112
  }
102
113
  exports.topicNameForEndpoint = topicNameForEndpoint;
103
- function jobFromEndpoint(endpoint, appEngineLocation) {
114
+ function jobFromEndpoint(endpoint, location, projectNumber) {
104
115
  const job = {};
116
+ job.name = jobNameForEndpoint(endpoint, location);
105
117
  if (endpoint.platform === "gcfv1") {
106
- job.name = jobNameForEndpoint(endpoint, appEngineLocation);
118
+ job.timeZone = endpoint.scheduleTrigger.timeZone || DEFAULT_TIME_ZONE_V1;
107
119
  job.pubsubTarget = {
108
120
  topicName: topicNameForEndpoint(endpoint),
109
121
  attributes: {
@@ -112,7 +124,14 @@ function jobFromEndpoint(endpoint, appEngineLocation) {
112
124
  };
113
125
  }
114
126
  else if (endpoint.platform === "gcfv2") {
115
- throw new error_1.FirebaseError("Do not know how to create a scheduled GCFv2 function");
127
+ job.timeZone = endpoint.scheduleTrigger.timeZone || DEFAULT_TIME_ZONE_V2;
128
+ job.httpTarget = {
129
+ uri: endpoint.uri,
130
+ httpMethod: "POST",
131
+ oidcToken: {
132
+ serviceAccountEmail: (0, checkIam_1.getDefaultComputeServiceAgent)(projectNumber),
133
+ },
134
+ };
116
135
  }
117
136
  else {
118
137
  (0, functional_1.assertExhaustive)(endpoint.platform);
@@ -121,7 +140,6 @@ function jobFromEndpoint(endpoint, appEngineLocation) {
121
140
  throw new error_1.FirebaseError("Cannot create a scheduler job without a schedule:" + JSON.stringify(endpoint));
122
141
  }
123
142
  job.schedule = endpoint.scheduleTrigger.schedule;
124
- job.timeZone = endpoint.scheduleTrigger.timeZone || DEFAULT_TIME_ZONE;
125
143
  if (endpoint.scheduleTrigger.retryConfig) {
126
144
  job.retryConfig = {};
127
145
  proto.copyIfPresent(job.retryConfig, endpoint.scheduleTrigger.retryConfig, "maxDoublings", "retryCount");
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureServiceAgentRole = exports.setIamPolicy = exports.getIamPolicy = exports.addVersion = exports.deleteSecret = exports.patchSecret = exports.createSecret = exports.toSecretVersionResourceName = exports.parseSecretVersionResourceName = exports.parseSecretResourceName = exports.secretExists = exports.destroySecretVersion = exports.accessSecretVersion = exports.getSecretVersion = exports.listSecretVersions = exports.listSecrets = exports.getSecret = exports.secretManagerConsoleUri = void 0;
3
+ exports.ensureServiceAgentRole = exports.setIamPolicy = exports.getIamPolicy = exports.addVersion = exports.deleteSecret = exports.patchSecret = exports.createSecret = exports.toSecretVersionResourceName = exports.parseSecretVersionResourceName = exports.parseSecretResourceName = exports.secretExists = exports.destroySecretVersion = exports.accessSecretVersion = exports.getSecretVersion = exports.listSecretVersions = exports.getSecretMetadata = exports.listSecrets = exports.getSecret = exports.secretManagerConsoleUri = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  const error_1 = require("../error");
6
6
  const apiv2_1 = require("../apiv2");
@@ -44,6 +44,20 @@ async function listSecrets(projectId, filter) {
44
44
  return secrets;
45
45
  }
46
46
  exports.listSecrets = listSecrets;
47
+ async function getSecretMetadata(projectId, secretName, version) {
48
+ const secretInfo = {};
49
+ try {
50
+ secretInfo.secret = await getSecret(projectId, secretName);
51
+ secretInfo.secretVersion = getSecretVersion(projectId, secretName, version);
52
+ }
53
+ catch (err) {
54
+ if (err.status !== 404) {
55
+ throw err;
56
+ }
57
+ }
58
+ return secretInfo;
59
+ }
60
+ exports.getSecretMetadata = getSecretMetadata;
47
61
  async function listSecretVersions(projectId, name, filter) {
48
62
  const secrets = [];
49
63
  const path = `projects/${projectId}/secrets/${name}/versions`;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getServiceAccount = exports.getBucket = exports.deleteObject = exports.uploadObject = exports.upload = exports.getDefaultBucket = void 0;
3
+ exports.getServiceAccount = exports.listBuckets = exports.getBucket = exports.deleteObject = exports.uploadObject = exports.upload = exports.getDefaultBucket = void 0;
4
4
  const path = require("path");
5
5
  const api_1 = require("../api");
6
6
  const apiv2_1 = require("../apiv2");
@@ -80,6 +80,20 @@ async function getBucket(bucketName) {
80
80
  }
81
81
  }
82
82
  exports.getBucket = getBucket;
83
+ async function listBuckets(projectId) {
84
+ try {
85
+ const localAPIClient = new apiv2_1.Client({ urlPrefix: api_1.storageOrigin });
86
+ const result = await localAPIClient.get(`/storage/v1/b?project=${projectId}`);
87
+ return result.body.items.map((bucket) => bucket.name);
88
+ }
89
+ catch (err) {
90
+ logger_1.logger.debug(err);
91
+ throw new error_1.FirebaseError("Failed to read the storage buckets", {
92
+ original: err,
93
+ });
94
+ }
95
+ }
96
+ exports.listBuckets = listBuckets;
83
97
  async function getServiceAccount(projectId) {
84
98
  try {
85
99
  const localAPIClient = new apiv2_1.Client({ urlPrefix: api_1.storageOrigin });
package/lib/previews.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.previews = void 0;
4
4
  const lodash_1 = require("lodash");
5
5
  const configstore_1 = require("./configstore");
6
- exports.previews = Object.assign({ rtdbrules: false, ext: false, extdev: false, rtdbmanagement: false, golang: false, deletegcfartifacts: false, emulatoruisnapshot: false, frameworkawareness: false, functionsparams: false, crossservicerules: false }, configstore_1.configstore.get("previews"));
6
+ exports.previews = Object.assign({ rtdbrules: false, ext: false, extdev: false, rtdbmanagement: false, golang: false, deletegcfartifacts: false, emulatoruisnapshot: false, frameworkawareness: false, functionsparams: false, crossservicerules: false, skipdeployingnoopfunctions: false }, configstore_1.configstore.get("previews"));
7
7
  if (process.env.FIREBASE_CLI_PREVIEWS) {
8
8
  process.env.FIREBASE_CLI_PREVIEWS.split(",").forEach((feature) => {
9
9
  if ((0, lodash_1.has)(exports.previews, feature)) {
package/lib/track.js CHANGED
@@ -47,6 +47,9 @@ const EMULATOR_GA4_USER_PROPS = {
47
47
  node_version: {
48
48
  value: process.version,
49
49
  },
50
+ cli_version: {
51
+ value: pkg.version,
52
+ },
50
53
  firepit_version: {
51
54
  value: process.env.FIREPIT_VERSION || "none",
52
55
  },