firebase-tools 11.30.0 → 12.0.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 (56) hide show
  1. package/lib/api.js +4 -2
  2. package/lib/commands/ext-configure.js +2 -1
  3. package/lib/commands/ext-dev-deprecate.js +24 -20
  4. package/lib/commands/ext-dev-list.js +12 -11
  5. package/lib/commands/ext-dev-publish.js +13 -47
  6. package/lib/commands/ext-dev-register.js +8 -5
  7. package/lib/commands/ext-dev-undeprecate.js +4 -4
  8. package/lib/commands/ext-dev-upload.js +88 -0
  9. package/lib/commands/ext-dev-usage.js +3 -3
  10. package/lib/commands/ext-install.js +5 -10
  11. package/lib/commands/ext-uninstall.js +0 -1
  12. package/lib/commands/ext-update.js +4 -10
  13. package/lib/commands/index.js +9 -19
  14. package/lib/deploy/extensions/planner.js +13 -7
  15. package/lib/deploy/extensions/prepare.js +16 -32
  16. package/lib/emulator/eventarcEmulatorUtils.js +4 -2
  17. package/lib/emulator/storage/rules/config.js +17 -7
  18. package/lib/experiments.js +7 -6
  19. package/lib/extensions/extensionsApi.js +24 -151
  20. package/lib/extensions/extensionsHelper.js +282 -145
  21. package/lib/extensions/manifest.js +1 -8
  22. package/lib/extensions/publisherApi.js +215 -0
  23. package/lib/extensions/refs.js +1 -1
  24. package/lib/extensions/resolveSource.js +1 -18
  25. package/lib/extensions/tos.js +78 -0
  26. package/lib/extensions/warnings.js +21 -41
  27. package/lib/frameworks/angular/index.js +67 -185
  28. package/lib/frameworks/angular/interfaces.js +2 -0
  29. package/lib/frameworks/angular/utils.js +274 -0
  30. package/lib/frameworks/constants.js +5 -2
  31. package/lib/frameworks/index.js +60 -28
  32. package/lib/frameworks/next/index.js +86 -40
  33. package/lib/frameworks/next/utils.js +29 -12
  34. package/lib/frameworks/utils.js +11 -4
  35. package/lib/functions/python.js +2 -2
  36. package/lib/hosting/api.js +32 -1
  37. package/package.json +2 -2
  38. package/templates/extensions/POSTINSTALL.md +2 -2
  39. package/templates/extensions/PREINSTALL.md +1 -1
  40. package/templates/extensions/extension.yaml +10 -6
  41. package/templates/extensions/javascript/WELCOME.md +1 -1
  42. package/templates/extensions/typescript/WELCOME.md +1 -1
  43. package/templates/extensions/typescript/index.ts +1 -1
  44. package/templates/init/functions/javascript/index.js +16 -6
  45. package/templates/init/functions/javascript/package.lint.json +4 -4
  46. package/templates/init/functions/javascript/package.nolint.json +4 -4
  47. package/templates/init/functions/typescript/index.ts +16 -6
  48. package/templates/init/functions/typescript/package.lint.json +4 -4
  49. package/templates/init/functions/typescript/package.nolint.json +4 -4
  50. package/lib/commands/ext-dev-emulators-exec.js +0 -27
  51. package/lib/commands/ext-dev-emulators-start.js +0 -24
  52. package/lib/commands/ext-dev-extension-delete.js +0 -45
  53. package/lib/commands/ext-dev-unpublish.js +0 -49
  54. package/lib/commands/ext-sources-create.js +0 -24
  55. package/lib/extensions/askUserForConsent.js +0 -33
  56. package/npm-shrinkwrap.json +0 -12368
@@ -15,6 +15,7 @@ const secrets_1 = require("./secrets");
15
15
  const warnings_1 = require("../../extensions/warnings");
16
16
  const etags_1 = require("../../extensions/etags");
17
17
  const v2FunctionHelper_1 = require("./v2FunctionHelper");
18
+ const tos_1 = require("../../extensions/tos");
18
19
  async function prepare(context, options, payload) {
19
20
  var _a, _b;
20
21
  const projectId = (0, projectUtils_1.needProjectId)(options);
@@ -33,16 +34,10 @@ async function prepare(context, options, payload) {
33
34
  const etagsChanged = (0, etags_1.detectEtagChanges)(options.rc, projectId, context.have);
34
35
  if (etagsChanged.length) {
35
36
  (0, warnings_1.outOfBandChangesWarning)(etagsChanged);
36
- if (!options.force && options.nonInteractive) {
37
- throw new error_1.FirebaseError("Pass the --force flag to overwrite out of band changes in non-interactive mode");
38
- }
39
- else if (!options.force &&
40
- !options.nonInteractive &&
41
- !(await prompt.promptOnce({
42
- type: "confirm",
43
- message: `Do you wish to continue deploying these extension instances?`,
44
- default: false,
45
- }))) {
37
+ if (!(await prompt.confirm({
38
+ message: `Do you wish to continue deploying these extension instances?`,
39
+ default: false,
40
+ }))) {
46
41
  throw new error_1.FirebaseError("Deployment cancelled");
47
42
  }
48
43
  }
@@ -59,16 +54,10 @@ async function prepare(context, options, payload) {
59
54
  payload.instancesToUpdate = context.want.filter((i) => { var _a; return (_a = context.have) === null || _a === void 0 ? void 0 : _a.some(isUpdate(i)); });
60
55
  payload.instancesToDelete = context.have.filter((i) => { var _a; return !((_a = context.want) === null || _a === void 0 ? void 0 : _a.some(matchesInstanceId(i))); });
61
56
  if (await (0, warnings_1.displayWarningsForDeploy)(payload.instancesToCreate)) {
62
- if (!options.force && options.nonInteractive) {
63
- throw new error_1.FirebaseError("Pass the --force flag to acknowledge these terms in non-interactive mode");
64
- }
65
- else if (!options.force &&
66
- !options.nonInteractive &&
67
- !(await prompt.promptOnce({
68
- type: "confirm",
69
- message: `Do you wish to continue deploying these extension instances?`,
70
- default: true,
71
- }))) {
57
+ if (!(await prompt.confirm({
58
+ message: `Do you wish to continue deploying these extension instances?`,
59
+ default: true,
60
+ }))) {
72
61
  throw new error_1.FirebaseError("Deployment cancelled");
73
62
  }
74
63
  }
@@ -87,18 +76,12 @@ async function prepare(context, options, payload) {
87
76
  }
88
77
  if (payload.instancesToDelete.length) {
89
78
  logger_1.logger.info(deploymentSummary.deletesSummary(payload.instancesToDelete));
90
- if (!options.force && options.nonInteractive) {
91
- throw new error_1.FirebaseError("Pass the --force flag to use this command in non-interactive mode");
92
- }
93
- else if (!options.force &&
94
- !options.nonInteractive &&
95
- !(await prompt.promptOnce({
96
- type: "confirm",
97
- message: `Would you like to delete ${payload.instancesToDelete
98
- .map((i) => i.instanceId)
99
- .join(", ")}?`,
100
- default: false,
101
- }))) {
79
+ if (!(await prompt.confirm({
80
+ message: `Would you like to delete ${payload.instancesToDelete
81
+ .map((i) => i.instanceId)
82
+ .join(", ")}?`,
83
+ default: false,
84
+ }))) {
102
85
  payload.instancesToDelete = [];
103
86
  }
104
87
  else {
@@ -106,6 +89,7 @@ async function prepare(context, options, payload) {
106
89
  }
107
90
  }
108
91
  await (0, requirePermissions_1.requirePermissions)(options, permissionsNeeded);
92
+ await (0, tos_1.acceptLatestAppDeveloperTOS)(options, projectId, context.want.map((i) => i.instanceId));
109
93
  }
110
94
  exports.prepare = prepare;
111
95
  const matchesInstanceId = (dep) => (test) => {
@@ -36,10 +36,12 @@ function cloudEventFromProtoToJson(ce) {
36
36
  }
37
37
  exports.cloudEventFromProtoToJson = cloudEventFromProtoToJson;
38
38
  function getOptionalAttribute(ce, attr, type) {
39
- return ce["attributes"][attr][type];
39
+ var _a, _b;
40
+ return (_b = (_a = ce === null || ce === void 0 ? void 0 : ce["attributes"]) === null || _a === void 0 ? void 0 : _a[attr]) === null || _b === void 0 ? void 0 : _b[type];
40
41
  }
41
42
  function getRequiredAttribute(ce, attr, type) {
42
- const val = ce["attributes"][attr][type];
43
+ var _a, _b;
44
+ const val = (_b = (_a = ce === null || ce === void 0 ? void 0 : ce["attributes"]) === null || _a === void 0 ? void 0 : _a[attr]) === null || _b === void 0 ? void 0 : _b[type];
43
45
  if (val === undefined) {
44
46
  throw new error_1.FirebaseError("CloudEvent must contain " + attr + " attribute");
45
47
  }
@@ -12,12 +12,11 @@ function getSourceFile(rules, options) {
12
12
  }
13
13
  function getStorageRulesConfig(projectId, options) {
14
14
  const storageConfig = options.config.data.storage;
15
+ const storageLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.STORAGE);
15
16
  if (!storageConfig) {
16
17
  if (constants_1.Constants.isDemoProject(projectId)) {
17
- const storageLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.STORAGE);
18
18
  storageLogger.logLabeled("BULLET", "storage", `Detected demo project ID "${projectId}", using a default (open) rules configuration.`);
19
- const path = __dirname + "/../../../../templates/emulators/default_storage.rules";
20
- return { name: path, content: (0, fsutils_1.readFile)(path) };
19
+ return defaultStorageRules();
21
20
  }
22
21
  throw new error_1.FirebaseError("Cannot start the Storage emulator without rules file specified in firebase.json: run 'firebase init' and set up your Storage configuration");
23
22
  }
@@ -33,11 +32,22 @@ function getStorageRulesConfig(projectId, options) {
33
32
  if (!targetConfig.target) {
34
33
  throw new error_1.FirebaseError("Must supply 'target' in Storage configuration");
35
34
  }
36
- rc.requireTarget(projectId, "storage", targetConfig.target);
37
- rc.target(projectId, "storage", targetConfig.target).forEach((resource) => {
38
- results.push({ resource, rules: getSourceFile(targetConfig.rules, options) });
39
- });
35
+ const targets = rc.target(projectId, "storage", targetConfig.target);
36
+ if (targets.length === 0) {
37
+ if (constants_1.Constants.isDemoProject(projectId)) {
38
+ storageLogger.logLabeled("BULLET", "storage", `Detected demo project ID "${projectId}", using a default (open) rules configuration. Storage targets in firebase.json will be ignored.`);
39
+ return defaultStorageRules();
40
+ }
41
+ rc.requireTarget(projectId, "storage", targetConfig.target);
42
+ }
43
+ results.push(...rc.target(projectId, "storage", targetConfig.target).map((resource) => {
44
+ return { resource, rules: getSourceFile(targetConfig.rules, options) };
45
+ }));
40
46
  }
41
47
  return results;
42
48
  }
43
49
  exports.getStorageRulesConfig = getStorageRulesConfig;
50
+ function defaultStorageRules() {
51
+ const path = __dirname + "/../../../../templates/emulators/default_storage.rules";
52
+ return { name: path, content: (0, fsutils_1.readFile)(path) };
53
+ }
@@ -20,12 +20,11 @@ exports.ALL_EXPERIMENTS = experiments({
20
20
  rtdbmanagement: {
21
21
  shortDescription: "Use new endpoint to administer realtime database instances",
22
22
  },
23
- ext: {
24
- shortDescription: `Enables the ${(0, colorette_1.bold)("ext:sources:create")} command`,
25
- },
26
- extdev: {
27
- shortDescription: `Enables the ${(0, colorette_1.bold)("ext:dev")} family of commands`,
28
- docsUri: "https://firebase.google.com/docs/extensions/alpha/overview-build-extensions",
23
+ pythonfunctions: {
24
+ shortDescription: "Python support for Cloud Functions for Firebase",
25
+ fullDescription: "Adds the ability to initializea and deploy Cloud " +
26
+ "Functions for Firebase in Python. While this feature is experimental " +
27
+ "breaking API changes are allowed in MINOR API revisions",
29
28
  },
30
29
  deletegcfartifacts: {
31
30
  shortDescription: `Add the ${(0, colorette_1.bold)("functions:deletegcfartifacts")} command to purge docker build images`,
@@ -61,6 +60,8 @@ exports.ALL_EXPERIMENTS = experiments({
61
60
  "exist per region. firebase-tools aggressively garbage collects tags it creates " +
62
61
  "if any service exceeds 500 tags, but it is theoretically possible that a project " +
63
62
  "exceeds the region-wide limit of tags and an old site version fails",
63
+ public: true,
64
+ default: true,
64
65
  },
65
66
  crossservicerules: {
66
67
  shortDescription: "Allow Firebase Rules to reference resources in other services",
@@ -1,20 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getExtension = exports.deleteExtension = exports.unpublishExtension = exports.publishExtensionVersion = exports.undeprecateExtensionVersion = exports.deprecateExtensionVersion = exports.registerPublisherProfile = exports.getPublisherProfile = exports.listExtensionVersions = exports.listExtensions = exports.getExtensionVersion = exports.getSource = exports.createSource = exports.updateInstanceFromRegistry = exports.updateInstance = exports.configureInstance = exports.listInstances = exports.getInstance = exports.deleteInstance = exports.createInstance = void 0;
3
+ exports.refNotFoundError = exports.getExtension = exports.listExtensionVersions = exports.listExtensions = exports.getExtensionVersion = exports.getSource = exports.createSource = exports.populateSpec = exports.updateInstanceFromRegistry = exports.updateInstance = exports.configureInstance = exports.listInstances = exports.getInstance = exports.deleteInstance = exports.createInstance = void 0;
4
4
  const yaml = require("js-yaml");
5
5
  const clc = require("colorette");
6
- const marked_1 = require("marked");
7
6
  const apiv2_1 = require("../apiv2");
8
7
  const api_1 = require("../api");
9
8
  const error_1 = require("../error");
10
9
  const logger_1 = require("../logger");
11
10
  const operationPoller = require("../operation-poller");
12
11
  const refs = require("./refs");
13
- const VERSION = "v1beta";
12
+ const EXTENSIONS_API_VERSION = "v1beta";
14
13
  const PAGE_SIZE_MAX = 100;
15
- const apiClient = new apiv2_1.Client({ urlPrefix: api_1.extensionsOrigin, apiVersion: VERSION });
14
+ const extensionsApiClient = new apiv2_1.Client({
15
+ urlPrefix: api_1.extensionsOrigin,
16
+ apiVersion: EXTENSIONS_API_VERSION,
17
+ });
16
18
  async function createInstanceHelper(projectId, instanceId, config, validateOnly = false) {
17
- const createRes = await apiClient.post(`/projects/${projectId}/instances/`, {
19
+ const createRes = await extensionsApiClient.post(`/projects/${projectId}/instances/`, {
18
20
  name: `projects/${projectId}/instances/${instanceId}`,
19
21
  config,
20
22
  }, {
@@ -27,7 +29,7 @@ async function createInstanceHelper(projectId, instanceId, config, validateOnly
27
29
  }
28
30
  const pollRes = await operationPoller.pollOperation({
29
31
  apiOrigin: api_1.extensionsOrigin,
30
- apiVersion: VERSION,
32
+ apiVersion: EXTENSIONS_API_VERSION,
31
33
  operationResourceName: createRes.body.name,
32
34
  masterTimeout: 600000,
33
35
  });
@@ -65,10 +67,10 @@ async function createInstance(args) {
65
67
  }
66
68
  exports.createInstance = createInstance;
67
69
  async function deleteInstance(projectId, instanceId) {
68
- const deleteRes = await apiClient.delete(`/projects/${projectId}/instances/${instanceId}`);
70
+ const deleteRes = await extensionsApiClient.delete(`/projects/${projectId}/instances/${instanceId}`);
69
71
  const pollRes = await operationPoller.pollOperation({
70
72
  apiOrigin: api_1.extensionsOrigin,
71
- apiVersion: VERSION,
73
+ apiVersion: EXTENSIONS_API_VERSION,
72
74
  operationResourceName: deleteRes.body.name,
73
75
  masterTimeout: 600000,
74
76
  });
@@ -77,7 +79,7 @@ async function deleteInstance(projectId, instanceId) {
77
79
  exports.deleteInstance = deleteInstance;
78
80
  async function getInstance(projectId, instanceId) {
79
81
  try {
80
- const res = await apiClient.get(`/projects/${projectId}/instances/${instanceId}`);
82
+ const res = await extensionsApiClient.get(`/projects/${projectId}/instances/${instanceId}`);
81
83
  return res.body;
82
84
  }
83
85
  catch (err) {
@@ -91,7 +93,7 @@ exports.getInstance = getInstance;
91
93
  async function listInstances(projectId) {
92
94
  const instances = [];
93
95
  const getNextPage = async (pageToken = "") => {
94
- const res = await apiClient.get(`/projects/${projectId}/instances`, {
96
+ const res = await extensionsApiClient.get(`/projects/${projectId}/instances`, {
95
97
  queryParams: {
96
98
  pageSize: PAGE_SIZE_MAX,
97
99
  pageToken,
@@ -205,7 +207,7 @@ async function updateInstanceFromRegistry(args) {
205
207
  }
206
208
  exports.updateInstanceFromRegistry = updateInstanceFromRegistry;
207
209
  async function patchInstance(args) {
208
- const updateRes = await apiClient.patch(`/projects/${args.projectId}/instances/${args.instanceId}`, args.data, {
210
+ const updateRes = await extensionsApiClient.patch(`/projects/${args.projectId}/instances/${args.instanceId}`, args.data, {
209
211
  queryParams: {
210
212
  updateMask: args.updateMask,
211
213
  validateOnly: args.validateOnly ? "true" : "false",
@@ -216,7 +218,7 @@ async function patchInstance(args) {
216
218
  }
217
219
  const pollRes = await operationPoller.pollOperation({
218
220
  apiOrigin: api_1.extensionsOrigin,
219
- apiVersion: VERSION,
221
+ apiVersion: EXTENSIONS_API_VERSION,
220
222
  operationResourceName: updateRes.body.name,
221
223
  masterTimeout: 600000,
222
224
  });
@@ -239,14 +241,15 @@ function populateSpec(spec) {
239
241
  spec.systemParams = (_b = spec.systemParams) !== null && _b !== void 0 ? _b : [];
240
242
  }
241
243
  }
244
+ exports.populateSpec = populateSpec;
242
245
  async function createSource(projectId, packageUri, extensionRoot) {
243
- const createRes = await apiClient.post(`/projects/${projectId}/sources/`, {
246
+ const createRes = await extensionsApiClient.post(`/projects/${projectId}/sources/`, {
244
247
  packageUri,
245
248
  extensionRoot,
246
249
  });
247
250
  const pollRes = await operationPoller.pollOperation({
248
251
  apiOrigin: api_1.extensionsOrigin,
249
- apiVersion: VERSION,
252
+ apiVersion: EXTENSIONS_API_VERSION,
250
253
  operationResourceName: createRes.body.name,
251
254
  masterTimeout: 600000,
252
255
  });
@@ -257,7 +260,7 @@ async function createSource(projectId, packageUri, extensionRoot) {
257
260
  }
258
261
  exports.createSource = createSource;
259
262
  async function getSource(sourceName) {
260
- const res = await apiClient.get(`/${sourceName}`);
263
+ const res = await extensionsApiClient.get(`/${sourceName}`);
261
264
  if (res.body.spec) {
262
265
  populateSpec(res.body.spec);
263
266
  }
@@ -270,7 +273,7 @@ async function getExtensionVersion(extensionVersionRef) {
270
273
  throw new error_1.FirebaseError(`ExtensionVersion ref "${extensionVersionRef}" must supply a version.`);
271
274
  }
272
275
  try {
273
- const res = await apiClient.get(`/${refs.toExtensionVersionName(ref)}`);
276
+ const res = await extensionsApiClient.get(`/${refs.toExtensionVersionName(ref)}`);
274
277
  if (res.body.spec) {
275
278
  populateSpec(res.body.spec);
276
279
  }
@@ -290,7 +293,7 @@ exports.getExtensionVersion = getExtensionVersion;
290
293
  async function listExtensions(publisherId) {
291
294
  const extensions = [];
292
295
  const getNextPage = async (pageToken = "") => {
293
- const res = await apiClient.get(`/publishers/${publisherId}/extensions`, {
296
+ const res = await extensionsApiClient.get(`/publishers/${publisherId}/extensions`, {
294
297
  queryParams: {
295
298
  pageSize: PAGE_SIZE_MAX,
296
299
  pageToken,
@@ -311,7 +314,7 @@ async function listExtensionVersions(ref, filter = "", showPrereleases = false)
311
314
  const { publisherId, extensionId } = refs.parse(ref);
312
315
  const extensionVersions = [];
313
316
  const getNextPage = async (pageToken = "") => {
314
- const res = await apiClient.get(`/publishers/${publisherId}/extensions/${extensionId}/versions`, {
317
+ const res = await extensionsApiClient.get(`/publishers/${publisherId}/extensions/${extensionId}/versions`, {
315
318
  queryParams: {
316
319
  filter,
317
320
  showPrereleases: String(showPrereleases),
@@ -330,141 +333,10 @@ async function listExtensionVersions(ref, filter = "", showPrereleases = false)
330
333
  return extensionVersions;
331
334
  }
332
335
  exports.listExtensionVersions = listExtensionVersions;
333
- async function getPublisherProfile(projectId, publisherId) {
334
- const res = await apiClient.get(`/projects/${projectId}/publisherProfile`, {
335
- queryParams: publisherId === undefined
336
- ? undefined
337
- : {
338
- publisherId,
339
- },
340
- });
341
- return res.body;
342
- }
343
- exports.getPublisherProfile = getPublisherProfile;
344
- async function registerPublisherProfile(projectId, publisherId) {
345
- const res = await apiClient.post(`/projects/${projectId}/publisherProfile:register`, {
346
- publisherId,
347
- });
348
- return res.body;
349
- }
350
- exports.registerPublisherProfile = registerPublisherProfile;
351
- async function deprecateExtensionVersion(extensionRef, deprecationMessage) {
352
- const ref = refs.parse(extensionRef);
353
- try {
354
- const res = await apiClient.post(`/${refs.toExtensionVersionName(ref)}:deprecate`, {
355
- deprecationMessage,
356
- });
357
- return res.body;
358
- }
359
- catch (err) {
360
- if (err.status === 403) {
361
- throw new error_1.FirebaseError(`You are not the owner of extension '${clc.bold(extensionRef)}' and don’t have the correct permissions to deprecate this extension version.` + err, { status: err.status });
362
- }
363
- else if (err.status === 404) {
364
- throw new error_1.FirebaseError(`Extension version ${clc.bold(extensionRef)} was not found.`);
365
- }
366
- else if (err instanceof error_1.FirebaseError) {
367
- throw err;
368
- }
369
- throw new error_1.FirebaseError(`Error occurred deprecating extension version '${extensionRef}': ${err}`, {
370
- status: err.status,
371
- });
372
- }
373
- }
374
- exports.deprecateExtensionVersion = deprecateExtensionVersion;
375
- async function undeprecateExtensionVersion(extensionRef) {
376
- const ref = refs.parse(extensionRef);
377
- try {
378
- const res = await apiClient.post(`/${refs.toExtensionVersionName(ref)}:undeprecate`);
379
- return res.body;
380
- }
381
- catch (err) {
382
- if (err.status === 403) {
383
- throw new error_1.FirebaseError(`You are not the owner of extension '${clc.bold(extensionRef)}' and don’t have the correct permissions to undeprecate this extension version.`, { status: err.status });
384
- }
385
- else if (err.status === 404) {
386
- throw new error_1.FirebaseError(`Extension version ${clc.bold(extensionRef)} was not found.`);
387
- }
388
- else if (err instanceof error_1.FirebaseError) {
389
- throw err;
390
- }
391
- throw new error_1.FirebaseError(`Error occurred undeprecating extension version '${extensionRef}': ${err}`, {
392
- status: err.status,
393
- });
394
- }
395
- }
396
- exports.undeprecateExtensionVersion = undeprecateExtensionVersion;
397
- async function publishExtensionVersion(args) {
398
- var _a, _b, _c, _d;
399
- const ref = refs.parse(args.extensionVersionRef);
400
- if (!ref.version) {
401
- throw new error_1.FirebaseError(`ExtensionVersion ref "${args.extensionVersionRef}" must supply a version.`);
402
- }
403
- const publishRes = await apiClient.post(`/${refs.toExtensionName(ref)}/versions:publish`, {
404
- versionId: ref.version,
405
- packageUri: (_a = args.packageUri) !== null && _a !== void 0 ? _a : "",
406
- extensionRoot: (_b = args.extensionRoot) !== null && _b !== void 0 ? _b : "/",
407
- repoUri: (_c = args.repoUri) !== null && _c !== void 0 ? _c : "",
408
- sourceRef: (_d = args.sourceRef) !== null && _d !== void 0 ? _d : "",
409
- });
410
- const pollRes = await operationPoller.pollOperation({
411
- apiOrigin: api_1.extensionsOrigin,
412
- apiVersion: VERSION,
413
- operationResourceName: publishRes.body.name,
414
- masterTimeout: 600000,
415
- });
416
- return pollRes;
417
- }
418
- exports.publishExtensionVersion = publishExtensionVersion;
419
- async function unpublishExtension(extensionRef) {
420
- const ref = refs.parse(extensionRef);
421
- if (ref.version) {
422
- throw new error_1.FirebaseError(`Extension reference "${extensionRef}" must not contain a version.`);
423
- }
424
- try {
425
- await apiClient.post(`/${refs.toExtensionName(ref)}:unpublish`);
426
- }
427
- catch (err) {
428
- if (err.status === 403) {
429
- throw new error_1.FirebaseError(`You are not the owner of extension '${clc.bold(extensionRef)}' and don’t have the correct permissions to unpublish this extension.`, { status: err.status });
430
- }
431
- else if (err instanceof error_1.FirebaseError) {
432
- throw err;
433
- }
434
- throw new error_1.FirebaseError(`Error occurred unpublishing extension '${extensionRef}': ${err}`, {
435
- status: err.status,
436
- });
437
- }
438
- }
439
- exports.unpublishExtension = unpublishExtension;
440
- async function deleteExtension(extensionRef) {
441
- const ref = refs.parse(extensionRef);
442
- if (ref.version) {
443
- throw new error_1.FirebaseError(`Extension reference "${extensionRef}" must not contain a version.`);
444
- }
445
- try {
446
- await apiClient.delete(`/${refs.toExtensionName(ref)}`);
447
- }
448
- catch (err) {
449
- if (err.status === 403) {
450
- throw new error_1.FirebaseError(`You are not the owner of extension '${clc.bold(extensionRef)}' and don’t have the correct permissions to delete this extension.`, { status: err.status });
451
- }
452
- else if (err.status === 404) {
453
- throw new error_1.FirebaseError(`Extension ${clc.bold(extensionRef)} was not found.`);
454
- }
455
- else if (err instanceof error_1.FirebaseError) {
456
- throw err;
457
- }
458
- throw new error_1.FirebaseError(`Error occurred delete extension '${extensionRef}': ${err}`, {
459
- status: err.status,
460
- });
461
- }
462
- }
463
- exports.deleteExtension = deleteExtension;
464
336
  async function getExtension(extensionRef) {
465
337
  const ref = refs.parse(extensionRef);
466
338
  try {
467
- const res = await apiClient.get(`/${refs.toExtensionName(ref)}`);
339
+ const res = await extensionsApiClient.get(`/${refs.toExtensionName(ref)}`);
468
340
  return res.body;
469
341
  }
470
342
  catch (err) {
@@ -484,5 +356,6 @@ function refNotFoundError(ref) {
484
356
  return new error_1.FirebaseError(`The extension reference '${clc.bold(ref.version ? refs.toExtensionVersionRef(ref) : refs.toExtensionRef(ref))}' doesn't exist. This could happen for two reasons:\n` +
485
357
  ` -The publisher ID '${clc.bold(ref.publisherId)}' doesn't exist or could be misspelled\n` +
486
358
  ` -The name of the ${ref.version ? "extension version" : "extension"} '${clc.bold(ref.version ? `${ref.extensionId}@${ref.version}` : ref.extensionId)}' doesn't exist or could be misspelled\n\n` +
487
- `Please correct the extension reference and try again. If you meant to install an extension from a local source, please provide a relative path prefixed with '${clc.bold("./")}', '${clc.bold("../")}', or '${clc.bold("~/")}'. Learn more about local extension installation at ${(0, marked_1.marked)("[https://firebase.google.com/docs/extensions/alpha/install-extensions_community#install](https://firebase.google.com/docs/extensions/alpha/install-extensions_community#install).")}`, { status: 404 });
359
+ `Please correct the extension reference and try again. If you meant to install an extension from a local source, please provide a relative path prefixed with '${clc.bold("./")}', '${clc.bold("../")}', or '${clc.bold("~/")}'.}`, { status: 404 });
488
360
  }
361
+ exports.refNotFoundError = refNotFoundError;