firebase-tools 11.0.1 → 11.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 (156) hide show
  1. package/lib/accountImporter.js +92 -93
  2. package/lib/api.js +77 -218
  3. package/lib/apiv2.js +5 -4
  4. package/lib/auth.js +69 -47
  5. package/lib/bin/firebase.js +42 -47
  6. package/lib/checkValidTargetFilters.js +13 -12
  7. package/lib/commands/appdistribution-distribute.js +2 -1
  8. package/lib/commands/appdistribution-testers-add.js +2 -1
  9. package/lib/commands/appdistribution-testers-remove.js +2 -1
  10. package/lib/commands/apps-android-sha-create.js +2 -1
  11. package/lib/commands/apps-android-sha-delete.js +2 -1
  12. package/lib/commands/apps-android-sha-list.js +2 -1
  13. package/lib/commands/apps-create.js +2 -1
  14. package/lib/commands/apps-list.js +2 -1
  15. package/lib/commands/apps-sdkconfig.js +2 -1
  16. package/lib/commands/auth-export.js +2 -1
  17. package/lib/commands/auth-import.js +7 -10
  18. package/lib/commands/crashlytics-symbols-upload.js +2 -1
  19. package/lib/commands/database-get.js +4 -3
  20. package/lib/commands/database-instances-create.js +2 -1
  21. package/lib/commands/database-instances-list.js +3 -3
  22. package/lib/commands/database-profile.js +2 -1
  23. package/lib/commands/database-push.js +2 -1
  24. package/lib/commands/database-remove.js +2 -1
  25. package/lib/commands/database-rules-canary.js +2 -1
  26. package/lib/commands/database-rules-get.js +2 -1
  27. package/lib/commands/database-rules-list.js +2 -1
  28. package/lib/commands/database-rules-release.js +2 -1
  29. package/lib/commands/database-rules-stage.js +2 -1
  30. package/lib/commands/database-set.js +2 -1
  31. package/lib/commands/database-settings-get.js +2 -1
  32. package/lib/commands/database-settings-set.js +2 -1
  33. package/lib/commands/database-update.js +2 -1
  34. package/lib/commands/deploy.js +23 -21
  35. package/lib/commands/emulators-exec.js +2 -1
  36. package/lib/commands/emulators-export.js +2 -1
  37. package/lib/commands/emulators-start.js +2 -1
  38. package/lib/commands/experimental-functions-shell.js +10 -8
  39. package/lib/commands/ext-configure.js +2 -1
  40. package/lib/commands/ext-dev-deprecate.js +2 -1
  41. package/lib/commands/ext-dev-emulators-exec.js +2 -1
  42. package/lib/commands/ext-dev-emulators-start.js +2 -1
  43. package/lib/commands/ext-dev-extension-delete.js +2 -1
  44. package/lib/commands/ext-dev-init.js +2 -1
  45. package/lib/commands/ext-dev-list.js +2 -1
  46. package/lib/commands/ext-dev-publish.js +2 -1
  47. package/lib/commands/ext-dev-register.js +2 -1
  48. package/lib/commands/ext-dev-undeprecate.js +2 -1
  49. package/lib/commands/ext-dev-unpublish.js +2 -1
  50. package/lib/commands/ext-dev-usage.js +2 -1
  51. package/lib/commands/ext-export.js +2 -1
  52. package/lib/commands/ext-info.js +2 -1
  53. package/lib/commands/ext-install.js +2 -1
  54. package/lib/commands/ext-list.js +2 -1
  55. package/lib/commands/ext-sources-create.js +2 -1
  56. package/lib/commands/ext-uninstall.js +2 -1
  57. package/lib/commands/ext-update.js +2 -1
  58. package/lib/commands/ext.js +2 -1
  59. package/lib/commands/firestore-delete.js +2 -1
  60. package/lib/commands/firestore-indexes-list.js +2 -1
  61. package/lib/commands/functions-config-clone.js +4 -3
  62. package/lib/commands/functions-config-export.js +2 -1
  63. package/lib/commands/functions-config-get.js +2 -1
  64. package/lib/commands/functions-config-set.js +2 -1
  65. package/lib/commands/functions-config-unset.js +2 -1
  66. package/lib/commands/functions-delete.js +2 -1
  67. package/lib/commands/functions-deletegcfartifacts.js +2 -1
  68. package/lib/commands/functions-list.js +2 -1
  69. package/lib/commands/functions-log.js +2 -1
  70. package/lib/commands/functions-secrets-access.js +2 -1
  71. package/lib/commands/functions-secrets-destroy.js +2 -1
  72. package/lib/commands/functions-secrets-get.js +2 -1
  73. package/lib/commands/functions-secrets-prune.js +2 -1
  74. package/lib/commands/functions-secrets-set.js +2 -1
  75. package/lib/commands/functions-shell.js +12 -10
  76. package/lib/commands/help.js +2 -1
  77. package/lib/commands/hosting-channel-create.js +2 -1
  78. package/lib/commands/hosting-channel-delete.js +2 -1
  79. package/lib/commands/hosting-channel-deploy.js +2 -1
  80. package/lib/commands/hosting-channel-list.js +2 -1
  81. package/lib/commands/hosting-channel-open.js +2 -1
  82. package/lib/commands/hosting-clone.js +2 -1
  83. package/lib/commands/hosting-disable.js +2 -1
  84. package/lib/commands/hosting-sites-create.js +2 -1
  85. package/lib/commands/hosting-sites-delete.js +2 -1
  86. package/lib/commands/hosting-sites-get.js +2 -1
  87. package/lib/commands/hosting-sites-list.js +2 -1
  88. package/lib/commands/index.js +23 -13
  89. package/lib/commands/init.js +47 -43
  90. package/lib/commands/login-add.js +2 -1
  91. package/lib/commands/login-ci.js +2 -1
  92. package/lib/commands/login-list.js +2 -1
  93. package/lib/commands/login-use.js +2 -1
  94. package/lib/commands/login.js +2 -1
  95. package/lib/commands/logout.js +2 -1
  96. package/lib/commands/open.js +2 -1
  97. package/lib/commands/projects-addfirebase.js +2 -1
  98. package/lib/commands/projects-create.js +2 -1
  99. package/lib/commands/projects-list.js +2 -1
  100. package/lib/commands/remoteconfig-get.js +2 -1
  101. package/lib/commands/remoteconfig-rollback.js +2 -1
  102. package/lib/commands/remoteconfig-versions-list.js +2 -1
  103. package/lib/commands/serve.js +29 -27
  104. package/lib/commands/setup-emulators-database.js +2 -1
  105. package/lib/commands/setup-emulators-firestore.js +2 -1
  106. package/lib/commands/setup-emulators-pubsub.js +2 -1
  107. package/lib/commands/setup-emulators-storage.js +2 -1
  108. package/lib/commands/setup-emulators-ui.js +2 -1
  109. package/lib/commands/target-apply.js +2 -1
  110. package/lib/commands/target-clear.js +2 -1
  111. package/lib/commands/target-remove.js +2 -1
  112. package/lib/commands/target.js +2 -1
  113. package/lib/commands/use.js +54 -52
  114. package/lib/config.js +3 -3
  115. package/lib/deploy/database/deploy.js +3 -2
  116. package/lib/deploy/database/index.js +8 -5
  117. package/lib/deploy/database/prepare.js +22 -19
  118. package/lib/deploy/database/release.js +12 -9
  119. package/lib/deploy/firestore/prepare.js +2 -2
  120. package/lib/deploy/functions/build.js +32 -20
  121. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +187 -54
  122. package/lib/deploy/functions/runtimes/node/parseTriggers.js +14 -2
  123. package/lib/deploy/functions/services/database.js +14 -0
  124. package/lib/deploy/functions/services/index.js +14 -0
  125. package/lib/deploy/index.js +3 -3
  126. package/lib/deploy/lifecycleHooks.js +23 -20
  127. package/lib/deploy/remoteconfig/prepare.js +2 -2
  128. package/lib/emulator/auth/apiSpec.js +14 -46
  129. package/lib/emulator/auth/operations.js +6 -29
  130. package/lib/emulator/auth/state.js +2 -25
  131. package/lib/emulator/controller.js +1 -1
  132. package/lib/emulator/databaseEmulator.js +2 -2
  133. package/lib/errorOut.js +2 -2
  134. package/lib/functions/events/v2.js +7 -1
  135. package/lib/functionsConfigClone.js +43 -41
  136. package/lib/gcp/cloudfunctionsv2.js +17 -2
  137. package/lib/gcp/iam.js +1 -1
  138. package/lib/gcp/index.js +10 -10
  139. package/lib/gcp/runtimeconfig.js +45 -47
  140. package/lib/index.js +29 -28
  141. package/lib/init/features/database.js +10 -2
  142. package/lib/init/features/functions/index.js +1 -1
  143. package/lib/init/features/functions/javascript.js +23 -20
  144. package/lib/init/features/functions/npm-dependencies.js +17 -14
  145. package/lib/init/features/functions/typescript.js +27 -24
  146. package/lib/init/features/hosting/github.js +5 -4
  147. package/lib/loadCJSON.js +9 -6
  148. package/lib/logError.js +15 -12
  149. package/lib/parseBoltRules.js +15 -14
  150. package/lib/profileReport.js +503 -511
  151. package/lib/profiler.js +4 -4
  152. package/lib/requireAuth.js +0 -1
  153. package/lib/responseToError.js +8 -5
  154. package/lib/scopes.js +9 -9
  155. package/npm-shrinkwrap.json +537 -193
  156. package/package.json +8 -6
@@ -1,43 +1,45 @@
1
1
  "use strict";
2
- var _ = require("lodash");
3
- var clc = require("cli-color");
4
- var { Command } = require("../command");
5
- var { getFirebaseProject, listFirebaseProjects } = require("../management/projects");
6
- var { prompt } = require("../prompt");
7
- var { requireAuth } = require("../requireAuth");
8
- var { validateProjectId } = require("../command");
9
- const { logger } = require("../logger");
10
- var utils = require("../utils");
11
- var listAliases = function (options) {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const _ = require("lodash");
5
+ const clc = require("cli-color");
6
+ const command_1 = require("../command");
7
+ const projects_1 = require("../management/projects");
8
+ const logger_1 = require("../logger");
9
+ const prompt_1 = require("../prompt");
10
+ const requireAuth_1 = require("../requireAuth");
11
+ const command_2 = require("../command");
12
+ const utils = require("../utils");
13
+ function listAliases(options) {
12
14
  if (options.rc.hasProjects) {
13
- logger.info("Project aliases for", clc.bold(options.projectRoot) + ":");
14
- logger.info();
15
- _.forEach(options.rc.projects, function (projectId, alias) {
16
- var listing = alias + " (" + projectId + ")";
15
+ logger_1.logger.info("Project aliases for", clc.bold(options.projectRoot) + ":");
16
+ logger_1.logger.info();
17
+ _.forEach(options.rc.projects, (projectId, alias) => {
18
+ const listing = alias + " (" + projectId + ")";
17
19
  if (options.project === projectId || options.projectAlias === alias) {
18
- logger.info(clc.cyan.bold("* " + listing));
20
+ logger_1.logger.info(clc.cyan.bold("* " + listing));
19
21
  }
20
22
  else {
21
- logger.info(" " + listing);
23
+ logger_1.logger.info(" " + listing);
22
24
  }
23
25
  });
24
- logger.info();
26
+ logger_1.logger.info();
25
27
  }
26
- logger.info("Run", clc.bold("firebase use --add"), "to define a new project alias.");
27
- };
28
- var verifyMessage = function (name) {
28
+ logger_1.logger.info("Run", clc.bold("firebase use --add"), "to define a new project alias.");
29
+ }
30
+ function verifyMessage(name) {
29
31
  return "please verify project " + clc.bold(name) + " exists and you have access.";
30
- };
31
- module.exports = new Command("use [alias_or_project_id]")
32
+ }
33
+ exports.command = new command_1.Command("use [alias_or_project_id]")
32
34
  .description("set an active Firebase project for your working directory")
33
35
  .option("--add", "create a new project alias interactively")
34
36
  .option("--alias <name>", "create a new alias for the provided project id")
35
37
  .option("--unalias <name>", "remove an already created project alias")
36
38
  .option("--clear", "clear the active project selection")
37
- .before(requireAuth)
38
- .action(function (newActive, options) {
39
- var aliasOpt;
40
- var i = process.argv.indexOf("--alias");
39
+ .before(requireAuth_1.requireAuth)
40
+ .action((newActive, options) => {
41
+ let aliasOpt;
42
+ const i = process.argv.indexOf("--alias");
41
43
  if (i >= 0 && process.argv.length > i + 1) {
42
44
  aliasOpt = process.argv[i + 1];
43
45
  }
@@ -48,11 +50,11 @@ module.exports = new Command("use [alias_or_project_id]")
48
50
  " to start a project directory in the current folder.");
49
51
  }
50
52
  if (newActive) {
51
- var project = null;
53
+ let project;
52
54
  const hasAlias = options.rc.hasProjectAlias(newActive);
53
55
  const resolvedProject = options.rc.resolveAlias(newActive);
54
- validateProjectId(resolvedProject);
55
- return getFirebaseProject(resolvedProject)
56
+ (0, command_2.validateProjectId)(resolvedProject);
57
+ return (0, projects_1.getFirebaseProject)(resolvedProject)
56
58
  .then((foundProject) => {
57
59
  project = foundProject;
58
60
  })
@@ -65,18 +67,18 @@ module.exports = new Command("use [alias_or_project_id]")
65
67
  return utils.reject("Cannot create alias " + clc.bold(aliasOpt) + ", " + verifyMessage(newActive));
66
68
  }
67
69
  options.rc.addProjectAlias(aliasOpt, newActive);
68
- logger.info("Created alias", clc.bold(aliasOpt), "for", resolvedProject + ".");
70
+ logger_1.logger.info("Created alias", clc.bold(aliasOpt), "for", resolvedProject + ".");
69
71
  }
70
72
  if (hasAlias) {
71
73
  if (!project) {
72
74
  return utils.reject("Unable to use alias " + clc.bold(newActive) + ", " + verifyMessage(resolvedProject));
73
75
  }
74
76
  utils.makeActiveProject(options.projectRoot, newActive);
75
- logger.info("Now using alias", clc.bold(newActive), "(" + resolvedProject + ")");
77
+ logger_1.logger.info("Now using alias", clc.bold(newActive), "(" + resolvedProject + ")");
76
78
  }
77
79
  else if (project) {
78
80
  utils.makeActiveProject(options.projectRoot, newActive);
79
- logger.info("Now using project", clc.bold(newActive));
81
+ logger_1.logger.info("Now using project", clc.bold(newActive));
80
82
  }
81
83
  else {
82
84
  return utils.reject("Invalid project selection, " + verifyMessage(newActive));
@@ -86,8 +88,8 @@ module.exports = new Command("use [alias_or_project_id]")
86
88
  else if (options.unalias) {
87
89
  if (options.rc.hasProjectAlias(options.unalias)) {
88
90
  options.rc.removeProjectAlias(options.unalias);
89
- logger.info("Removed alias", clc.bold(options.unalias));
90
- logger.info();
91
+ logger_1.logger.info("Removed alias", clc.bold(options.unalias));
92
+ logger_1.logger.info();
91
93
  listAliases(options);
92
94
  }
93
95
  }
@@ -99,9 +101,9 @@ module.exports = new Command("use [alias_or_project_id]")
99
101
  clc.bold("firebase use <project_id> --alias <alias>") +
100
102
  " instead.");
101
103
  }
102
- return listFirebaseProjects().then(function (projects) {
103
- var results = {};
104
- return prompt(results, [
104
+ return (0, projects_1.listFirebaseProjects)().then((projects) => {
105
+ const results = {};
106
+ return (0, prompt_1.prompt)(results, [
105
107
  {
106
108
  type: "list",
107
109
  name: "project",
@@ -112,49 +114,49 @@ module.exports = new Command("use [alias_or_project_id]")
112
114
  type: "input",
113
115
  name: "alias",
114
116
  message: "What alias do you want to use for this project? (e.g. staging)",
115
- validate: function (input) {
117
+ validate: (input) => {
116
118
  return input && input.length > 0;
117
119
  },
118
120
  },
119
- ]).then(function () {
121
+ ]).then(() => {
120
122
  options.rc.addProjectAlias(results.alias, results.project);
121
123
  utils.makeActiveProject(options.projectRoot, results.alias);
122
- logger.info();
123
- logger.info("Created alias", clc.bold(results.alias), "for", results.project + ".");
124
- logger.info("Now using alias", clc.bold(results.alias) + " (" + results.project + ")");
124
+ logger_1.logger.info();
125
+ logger_1.logger.info("Created alias", clc.bold(results.alias), "for", results.project + ".");
126
+ logger_1.logger.info("Now using alias", clc.bold(results.alias) + " (" + results.project + ")");
125
127
  });
126
128
  });
127
129
  }
128
130
  else if (options.clear) {
129
- utils.makeActiveProject(options.projectRoot, null);
131
+ utils.makeActiveProject(options.projectRoot, undefined);
130
132
  options.projectAlias = null;
131
133
  options.project = null;
132
- logger.info("Cleared active project.");
133
- logger.info();
134
+ logger_1.logger.info("Cleared active project.");
135
+ logger_1.logger.info();
134
136
  listAliases(options);
135
137
  }
136
138
  else {
137
139
  if (options.nonInteractive || !process.stdout.isTTY) {
138
140
  if (options.project) {
139
- logger.info(options.project);
141
+ logger_1.logger.info(options.project);
140
142
  return options.project;
141
143
  }
142
- return utils.reject("No active project", { exit: 1 });
144
+ return utils.reject("No active project");
143
145
  }
144
146
  if (options.projectAlias) {
145
- logger.info("Active Project:", clc.bold.cyan(options.projectAlias + " (" + options.project + ")"));
147
+ logger_1.logger.info("Active Project:", clc.bold.cyan(options.projectAlias + " (" + options.project + ")"));
146
148
  }
147
149
  else if (options.project) {
148
- logger.info("Active Project:", clc.bold.cyan(options.project));
150
+ logger_1.logger.info("Active Project:", clc.bold.cyan(options.project));
149
151
  }
150
152
  else {
151
- var msg = "No project is currently active";
153
+ let msg = "No project is currently active";
152
154
  if (options.rc.hasProjects) {
153
155
  msg += ", and no aliases have been created.";
154
156
  }
155
- logger.info(msg + ".");
157
+ logger_1.logger.info(msg + ".");
156
158
  }
157
- logger.info();
159
+ logger_1.logger.info();
158
160
  listAliases(options);
159
161
  return options.project;
160
162
  }
package/lib/config.js CHANGED
@@ -14,7 +14,7 @@ const projectPath_1 = require("./projectPath");
14
14
  const utils = require("./utils");
15
15
  const firebaseConfigValidate_1 = require("./firebaseConfigValidate");
16
16
  const logger_1 = require("./logger");
17
- const loadCJSON = require("./loadCJSON");
17
+ const loadCJSON_1 = require("./loadCJSON");
18
18
  const parseBoltRules = require("./parseBoltRules");
19
19
  class Config {
20
20
  constructor(src, options = {}) {
@@ -95,7 +95,7 @@ class Config {
95
95
  throw e;
96
96
  }
97
97
  }
98
- return loadCJSON(fullPath);
98
+ return (0, loadCJSON_1.loadCJSON)(fullPath);
99
99
  case ".bolt":
100
100
  if (target === "database") {
101
101
  this.notes.databaseRules = "bolt";
@@ -125,7 +125,7 @@ class Config {
125
125
  }
126
126
  return outPath;
127
127
  }
128
- readProjectFile(p, options) {
128
+ readProjectFile(p, options = {}) {
129
129
  options = options || {};
130
130
  try {
131
131
  const content = fs.readFileSync(this.path(p), "utf8");
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- async function default_1() { }
4
- exports.default = default_1;
3
+ exports.deploy = void 0;
4
+ async function deploy() { }
5
+ exports.deploy = deploy;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
- module.exports = {
3
- prepare: require("./prepare"),
4
- release: require("./release"),
5
- deploy: require("./deploy").default,
6
- };
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.release = exports.deploy = exports.prepare = void 0;
4
+ var prepare_1 = require("./prepare");
5
+ Object.defineProperty(exports, "prepare", { enumerable: true, get: function () { return prepare_1.prepare; } });
6
+ var deploy_1 = require("./deploy");
7
+ Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return deploy_1.deploy; } });
8
+ var release_1 = require("./release");
9
+ Object.defineProperty(exports, "release", { enumerable: true, get: function () { return release_1.release; } });
@@ -1,37 +1,39 @@
1
1
  "use strict";
2
- var _ = require("lodash");
3
- var clc = require("cli-color");
4
- var path = require("path");
5
- var { FirebaseError } = require("../../error");
6
- var parseBoltRules = require("../../parseBoltRules");
7
- var rtdb = require("../../rtdb");
8
- var utils = require("../../utils");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepare = void 0;
4
+ const _ = require("lodash");
5
+ const clc = require("cli-color");
6
+ const path = require("path");
7
+ const error_1 = require("../../error");
8
+ const parseBoltRules_1 = require("../../parseBoltRules");
9
+ const rtdb = require("../../rtdb");
10
+ const utils = require("../../utils");
9
11
  const dbRulesConfig = require("../../database/rulesConfig");
10
- module.exports = function (context, options) {
11
- var rulesConfig = dbRulesConfig.getRulesConfig(context.projectId, options);
12
- var next = Promise.resolve();
12
+ function prepare(context, options) {
13
+ const rulesConfig = dbRulesConfig.getRulesConfig(context.projectId, options);
14
+ const next = Promise.resolve();
13
15
  if (!rulesConfig || rulesConfig.length === 0) {
14
16
  return next;
15
17
  }
16
- var ruleFiles = {};
17
- var deploys = [];
18
- rulesConfig.forEach(function (ruleConfig) {
18
+ const ruleFiles = {};
19
+ const deploys = [];
20
+ rulesConfig.forEach((ruleConfig) => {
19
21
  if (!ruleConfig.rules) {
20
22
  return;
21
23
  }
22
24
  ruleFiles[ruleConfig.rules] = null;
23
25
  deploys.push(ruleConfig);
24
26
  });
25
- _.forEach(ruleFiles, function (v, file) {
27
+ _.forEach(ruleFiles, (v, file) => {
26
28
  switch (path.extname(file)) {
27
29
  case ".json":
28
30
  ruleFiles[file] = options.config.readProjectFile(file);
29
31
  break;
30
32
  case ".bolt":
31
- ruleFiles[file] = parseBoltRules(file);
33
+ ruleFiles[file] = (0, parseBoltRules_1.parseBoltRules)(file);
32
34
  break;
33
35
  default:
34
- throw new FirebaseError("Unexpected rules format " + path.extname(file));
36
+ throw new error_1.FirebaseError("Unexpected rules format " + path.extname(file));
35
37
  }
36
38
  });
37
39
  context.database = {
@@ -39,14 +41,15 @@ module.exports = function (context, options) {
39
41
  ruleFiles: ruleFiles,
40
42
  };
41
43
  utils.logBullet(clc.bold.cyan("database: ") + "checking rules syntax...");
42
- return Promise.all(deploys.map(function (deploy) {
44
+ return Promise.all(deploys.map((deploy) => {
43
45
  return rtdb
44
46
  .updateRules(context.projectId, deploy.instance, ruleFiles[deploy.rules], { dryRun: true })
45
- .then(function () {
47
+ .then(() => {
46
48
  utils.logSuccess(clc.bold.green("database: ") +
47
49
  "rules syntax for database " +
48
50
  clc.bold(deploy.instance) +
49
51
  " is valid");
50
52
  });
51
53
  }));
52
- };
54
+ }
55
+ exports.prepare = prepare;
@@ -1,27 +1,30 @@
1
1
  "use strict";
2
- var clc = require("cli-color");
3
- var rtdb = require("../../rtdb");
4
- var utils = require("../../utils");
5
- module.exports = function (context) {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.release = void 0;
4
+ const clc = require("cli-color");
5
+ const rtdb = require("../../rtdb");
6
+ const utils = require("../../utils");
7
+ function release(context) {
6
8
  if (!context.projectId ||
7
9
  !context.database ||
8
10
  !context.database.deploys ||
9
11
  !context.database.ruleFiles) {
10
12
  return Promise.resolve();
11
13
  }
12
- var deploys = context.database.deploys;
13
- var ruleFiles = context.database.ruleFiles;
14
+ const deploys = context.database.deploys;
15
+ const ruleFiles = context.database.ruleFiles;
14
16
  utils.logBullet(clc.bold.cyan("database: ") + "releasing rules...");
15
- return Promise.all(deploys.map(function (deploy) {
17
+ return Promise.all(deploys.map((deploy) => {
16
18
  return rtdb
17
19
  .updateRules(context.projectId, deploy.instance, ruleFiles[deploy.rules], {
18
20
  dryRun: false,
19
21
  })
20
- .then(function () {
22
+ .then(() => {
21
23
  utils.logSuccess(clc.bold.green("database: ") +
22
24
  "rules for database " +
23
25
  clc.bold(deploy.instance) +
24
26
  " released successfully");
25
27
  });
26
28
  }));
27
- };
29
+ }
30
+ exports.release = release;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const _ = require("lodash");
4
4
  const clc = require("cli-color");
5
- const loadCJSON = require("../../loadCJSON");
5
+ const loadCJSON_1 = require("../../loadCJSON");
6
6
  const rulesDeploy_1 = require("../../rulesDeploy");
7
7
  const utils = require("../../utils");
8
8
  async function prepareRules(context, options) {
@@ -22,7 +22,7 @@ function prepareIndexes(context, options) {
22
22
  }
23
23
  const indexesFileName = options.config.src.firestore.indexes;
24
24
  const indexesPath = options.config.path(indexesFileName);
25
- const parsedSrc = loadCJSON(indexesPath);
25
+ const parsedSrc = (0, loadCJSON_1.loadCJSON)(indexesPath);
26
26
  utils.logBullet(`${clc.bold.cyan("firestore:")} reading indexes from ${clc.bold(indexesFileName)}...`);
27
27
  context.firestore = context.firestore || {};
28
28
  context.firestore.indexes = {
@@ -56,44 +56,45 @@ function resolveBackend(build, userEnvs) {
56
56
  if (!userEnvs.hasOwnProperty(expectedEnv)) {
57
57
  throw new error_1.FirebaseError("Build specified parameter " +
58
58
  expectedEnv +
59
- " but it was not present in the user dotenv files");
59
+ " but it was not present in the user dotenv files or Cloud Secret Manager");
60
60
  }
61
61
  }
62
62
  const bkEndpoints = [];
63
63
  for (const endpointId of Object.keys(build.endpoints)) {
64
- const endpoint = build.endpoints[endpointId];
65
- let regions = endpoint.region;
64
+ const bdEndpoint = build.endpoints[endpointId];
65
+ let regions = bdEndpoint.region;
66
66
  if (typeof regions === "undefined") {
67
67
  regions = [api.functionsDefaultRegion];
68
68
  }
69
69
  for (const region of regions) {
70
- const trigger = discoverTrigger(endpoint);
71
- if (typeof endpoint.platform === "undefined") {
70
+ const trigger = discoverTrigger(bdEndpoint);
71
+ if (typeof bdEndpoint.platform === "undefined") {
72
72
  throw new error_1.FirebaseError("platform can't be undefined");
73
73
  }
74
- if (!isMemoryOption(endpoint.availableMemoryMb)) {
74
+ if (!isMemoryOption(bdEndpoint.availableMemoryMb)) {
75
75
  throw new error_1.FirebaseError("available memory must be a supported value, if present");
76
76
  }
77
77
  let timeout;
78
- if (endpoint.timeoutSeconds) {
79
- timeout = resolveInt(endpoint.timeoutSeconds);
78
+ if (bdEndpoint.timeoutSeconds) {
79
+ timeout = resolveInt(bdEndpoint.timeoutSeconds);
80
80
  }
81
81
  else {
82
82
  timeout = 60;
83
83
  }
84
- const bkEndpoint = Object.assign({ id: endpointId, project: endpoint.project, region: region, entryPoint: endpoint.entryPoint, platform: endpoint.platform, runtime: endpoint.runtime, timeoutSeconds: timeout }, trigger);
85
- proto.renameIfPresent(bkEndpoint, endpoint, "maxInstances", "maxInstances", resolveInt);
86
- proto.renameIfPresent(bkEndpoint, endpoint, "minInstances", "minInstances", resolveInt);
87
- proto.renameIfPresent(bkEndpoint, endpoint, "concurrency", "concurrency", resolveInt);
88
- proto.copyIfPresent(bkEndpoint, endpoint, "ingressSettings", "availableMemoryMb", "environmentVariables", "labels");
89
- if (endpoint.vpc) {
84
+ const bkEndpoint = Object.assign({ id: endpointId, project: bdEndpoint.project, region: region, entryPoint: bdEndpoint.entryPoint, platform: bdEndpoint.platform, runtime: bdEndpoint.runtime, timeoutSeconds: timeout }, trigger);
85
+ proto.renameIfPresent(bkEndpoint, bdEndpoint, "maxInstances", "maxInstances", resolveInt);
86
+ proto.renameIfPresent(bkEndpoint, bdEndpoint, "minInstances", "minInstances", resolveInt);
87
+ proto.renameIfPresent(bkEndpoint, bdEndpoint, "concurrency", "concurrency", resolveInt);
88
+ proto.copyIfPresent(bkEndpoint, bdEndpoint, "ingressSettings", "availableMemoryMb", "environmentVariables", "labels");
89
+ proto.copyIfPresent(bkEndpoint, bdEndpoint, "secretEnvironmentVariables");
90
+ if (bdEndpoint.vpc) {
90
91
  bkEndpoint.vpc = {
91
- connector: resolveString(endpoint.vpc.connector).replace("$REGION", region),
92
+ connector: resolveString(bdEndpoint.vpc.connector).replace("$REGION", region),
92
93
  };
93
- proto.copyIfPresent(bkEndpoint.vpc, endpoint.vpc, "egressSettings");
94
+ proto.copyIfPresent(bkEndpoint.vpc, bdEndpoint.vpc, "egressSettings");
94
95
  }
95
- if (endpoint.serviceAccount) {
96
- bkEndpoint.serviceAccountEmail = endpoint.serviceAccount;
96
+ if (bdEndpoint.serviceAccount) {
97
+ bkEndpoint.serviceAccountEmail = bdEndpoint.serviceAccount;
97
98
  }
98
99
  bkEndpoints.push(bkEndpoint);
99
100
  }
@@ -116,7 +117,7 @@ function discoverTrigger(endpoint) {
116
117
  trigger = { callableTrigger: {} };
117
118
  }
118
119
  else if ("blockingTrigger" in endpoint) {
119
- throw new error_1.FirebaseError("blocking triggers not supported");
120
+ trigger = { blockingTrigger: endpoint.blockingTrigger };
120
121
  }
121
122
  else if ("eventTrigger" in endpoint) {
122
123
  const bkEventFilters = {};
@@ -143,7 +144,18 @@ function discoverTrigger(endpoint) {
143
144
  schedule: resolveString(endpoint.scheduleTrigger.schedule),
144
145
  timeZone: resolveString(endpoint.scheduleTrigger.timeZone),
145
146
  };
146
- proto.renameIfPresent(bkSchedule, endpoint.scheduleTrigger, "retryConfig", "retryConfig", resolveInt);
147
+ const bkRetry = {};
148
+ if (endpoint.scheduleTrigger.retryConfig.maxBackoffSeconds) {
149
+ bkRetry.maxBackoffDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.maxBackoffSeconds));
150
+ }
151
+ if (endpoint.scheduleTrigger.retryConfig.minBackoffSeconds) {
152
+ bkRetry.minBackoffDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.minBackoffSeconds));
153
+ }
154
+ if (endpoint.scheduleTrigger.retryConfig.maxRetrySeconds) {
155
+ bkRetry.maxRetryDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.maxRetrySeconds));
156
+ }
157
+ proto.copyIfPresent(bkRetry, endpoint.scheduleTrigger.retryConfig, "retryCount", "maxDoublings");
158
+ bkSchedule.retryConfig = bkRetry;
147
159
  trigger = { scheduleTrigger: bkSchedule };
148
160
  }
149
161
  else if ("taskQueueTrigger" in endpoint) {