firebase-tools 13.11.1 → 13.11.2

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.
@@ -20,6 +20,17 @@ exports.command = new command_1.Command("dataconnect:sdk:generate")
20
20
  configDir = path.resolve(path.join(cwd), configDir);
21
21
  }
22
22
  const serviceInfo = await (0, load_1.load)(projectId, service.location, configDir);
23
+ const hasGeneratables = serviceInfo.connectorInfo.some((c) => {
24
+ var _a, _b, _c;
25
+ return (((_a = c.connectorYaml.generate) === null || _a === void 0 ? void 0 : _a.javascriptSdk) ||
26
+ ((_b = c.connectorYaml.generate) === null || _b === void 0 ? void 0 : _b.kotlinSdk) ||
27
+ ((_c = c.connectorYaml.generate) === null || _c === void 0 ? void 0 : _c.swiftSdk));
28
+ });
29
+ if (!hasGeneratables) {
30
+ logger_1.logger.warn("No generated SDKs have been declared in connector.yaml files.");
31
+ logger_1.logger.warn("See https://firebase.google.com/docs/data-connect/quickstart#configure-sdk-outputs for examples of how to configure generated SDKs.");
32
+ return;
33
+ }
23
34
  for (const conn of serviceInfo.connectorInfo) {
24
35
  const output = await dataconnectEmulator_1.DataConnectEmulator.generate({
25
36
  configDir,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseConnectorName = exports.parseServiceName = void 0;
3
+ exports.parseCloudSQLInstanceName = exports.parseConnectorName = exports.parseServiceName = void 0;
4
4
  const error_1 = require("../error");
5
5
  const serviceNameRegex = /projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/services\/(?<serviceId>[^\/]+)/;
6
6
  function parseServiceName(serviceName) {
@@ -46,3 +46,24 @@ function parseConnectorName(connectorName) {
46
46
  };
47
47
  }
48
48
  exports.parseConnectorName = parseConnectorName;
49
+ const cloudSQLInstanceNameRegex = /projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/instances\/(?<instanceId>[^\/]+)/;
50
+ function parseCloudSQLInstanceName(cloudSQLInstanceName) {
51
+ var _a, _b, _c;
52
+ const res = cloudSQLInstanceNameRegex.exec(cloudSQLInstanceName);
53
+ const projectId = (_a = res === null || res === void 0 ? void 0 : res.groups) === null || _a === void 0 ? void 0 : _a.projectId;
54
+ const location = (_b = res === null || res === void 0 ? void 0 : res.groups) === null || _b === void 0 ? void 0 : _b.location;
55
+ const instanceId = (_c = res === null || res === void 0 ? void 0 : res.groups) === null || _c === void 0 ? void 0 : _c.instanceId;
56
+ if (!projectId || !location || !instanceId) {
57
+ throw new error_1.FirebaseError(`${cloudSQLInstanceName} is not a valid cloudSQL instance name`);
58
+ }
59
+ const toString = () => {
60
+ return `projects/${projectId}/locations/${location}/services/${instanceId}`;
61
+ };
62
+ return {
63
+ projectId,
64
+ location,
65
+ instanceId,
66
+ toString,
67
+ };
68
+ }
69
+ exports.parseCloudSQLInstanceName = parseCloudSQLInstanceName;
@@ -47,6 +47,10 @@ async function doSetup(setup, config) {
47
47
  const dir = config.get("dataconnect.source") || "dataconnect";
48
48
  const subbedDataconnectYaml = subValues(DATACONNECT_YAML_TEMPLATE, info);
49
49
  const subbedConnectorYaml = subValues(CONNECTOR_YAML_TEMPLATE, info);
50
+ if (!config.has("dataconnect")) {
51
+ config.set("dataconnect.source", dir);
52
+ config.set("dataconnect.location", info.locationId);
53
+ }
50
54
  await config.askWriteProjectFile((0, path_1.join)(dir, "dataconnect.yaml"), subbedDataconnectYaml);
51
55
  await config.askWriteProjectFile((0, path_1.join)(dir, "schema", "schema.gql"), SCHEMA_TEMPLATE);
52
56
  await config.askWriteProjectFile((0, path_1.join)(dir, info.connectorId, "connector.yaml"), subbedConnectorYaml);
@@ -116,8 +120,10 @@ async function promptForService(setup, info) {
116
120
  info.serviceId = serviceName.serviceId;
117
121
  info.locationId = serviceName.location;
118
122
  if (choice.schema) {
119
- info.cloudSqlInstanceId =
120
- (_b = (_a = choice.schema.primaryDatasource.postgresql) === null || _a === void 0 ? void 0 : _a.cloudSql.instance) !== null && _b !== void 0 ? _b : "";
123
+ if ((_a = choice.schema.primaryDatasource.postgresql) === null || _a === void 0 ? void 0 : _a.cloudSql.instance) {
124
+ const instanceName = (0, names_1.parseCloudSQLInstanceName)((_b = choice.schema.primaryDatasource.postgresql) === null || _b === void 0 ? void 0 : _b.cloudSql.instance);
125
+ info.cloudSqlInstanceId = instanceName.instanceId;
126
+ }
121
127
  info.cloudSqlDatabase = (_d = (_c = choice.schema.primaryDatasource.postgresql) === null || _c === void 0 ? void 0 : _c.database) !== null && _d !== void 0 ? _d : "";
122
128
  }
123
129
  }
@@ -149,7 +155,9 @@ async function promptForCloudSQLInstance(setup, info) {
149
155
  type: "list",
150
156
  choices,
151
157
  });
152
- info.locationId = choices.find((c) => c.value === info.cloudSqlInstanceId).location;
158
+ if (info.cloudSqlInstanceId !== "") {
159
+ info.locationId = choices.find((c) => c.value === info.cloudSqlInstanceId).location;
160
+ }
153
161
  }
154
162
  }
155
163
  if (info.cloudSqlInstanceId === "") {
@@ -191,11 +199,6 @@ async function locationChoices(setup) {
191
199
  }
192
200
  }
193
201
  async function promptForDatabase(setup, config, info) {
194
- const dir = config.get("dataconnect.source") || "dataconnect";
195
- if (!config.has("dataconnect")) {
196
- config.set("dataconnect.source", dir);
197
- config.set("dataconnect.location", info.locationId);
198
- }
199
202
  if (!info.isNewInstance && setup.projectId) {
200
203
  try {
201
204
  const dbs = await cloudsql.listDatabases(setup.projectId, info.cloudSqlInstanceId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-tools",
3
- "version": "13.11.1",
3
+ "version": "13.11.2",
4
4
  "description": "Command-Line Interface for Firebase",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {