firebase-tools-with-isolate 13.11.2 → 13.15.0-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.
- package/lib/api.js +4 -2
- package/lib/apphosting/githubConnections.js +125 -37
- package/lib/apphosting/index.js +3 -8
- package/lib/auth.js +14 -15
- package/lib/bin/firebase.js +7 -5
- package/lib/commands/dataconnect-sdk-generate.js +5 -9
- package/lib/commands/dataconnect-services-list.js +1 -1
- package/lib/commands/deploy.js +7 -1
- package/lib/commands/ext-configure.js +1 -6
- package/lib/commands/ext-dev-init.js +27 -30
- package/lib/commands/ext-dev-upload.js +4 -6
- package/lib/commands/ext-info.js +3 -5
- package/lib/commands/ext-install.js +0 -5
- package/lib/commands/ext-uninstall.js +0 -5
- package/lib/commands/ext-update.js +0 -5
- package/lib/commands/firestore-backups-schedules-create.js +11 -14
- package/lib/commands/firestore-backups-schedules-list.js +1 -1
- package/lib/commands/firestore-backups-schedules-update.js +4 -3
- package/lib/commands/firestore-databases-create.js +24 -7
- package/lib/commands/firestore-databases-restore.js +4 -4
- package/lib/commands/firestore-databases-update.js +5 -6
- package/lib/commands/functions-secrets-set.js +9 -6
- package/lib/commands/help.js +2 -0
- package/lib/commands/hosting-channel-create.js +1 -1
- package/lib/commands/hosting-channel-delete.js +1 -1
- package/lib/commands/hosting-channel-deploy.js +1 -1
- package/lib/commands/hosting-clone.js +1 -2
- package/lib/commands/index.js +9 -11
- package/lib/commands/init.js +16 -12
- package/lib/commands/login.js +1 -2
- package/lib/commands/setup-emulators-dataconnect.js +22 -3
- package/lib/config.js +5 -0
- package/lib/crashlytics/buildToolsJarHelper.js +1 -1
- package/lib/dataconnect/client.js +55 -8
- package/lib/dataconnect/fileUtils.js +30 -7
- package/lib/dataconnect/filters.js +12 -1
- package/lib/dataconnect/load.js +9 -7
- package/lib/dataconnect/schemaMigration.js +21 -0
- package/lib/dataconnect/types.js +8 -1
- package/lib/deploy/dataconnect/prepare.js +16 -2
- package/lib/deploy/functions/build.js +10 -1
- package/lib/emulator/adminSdkConfig.test.js +16 -0
- package/lib/emulator/constants.js +1 -0
- package/lib/emulator/controller.js +3 -9
- package/lib/emulator/dataconnectEmulator.js +122 -18
- package/lib/emulator/downloadableEmulators.js +21 -22
- package/lib/emulator/eventarcEmulator.js +68 -18
- package/lib/emulator/functionsEmulator.js +89 -0
- package/lib/emulator/functionsEmulatorShared.js +4 -0
- package/lib/emulator/hub.js +1 -1
- package/lib/emulator/portUtils.js +9 -0
- package/lib/emulator/pubsubEmulator.js +1 -1
- package/lib/emulator/registry.js +1 -1
- package/lib/emulator/storage/apis/shared.js +2 -1
- package/lib/emulator/storage/persistence.js +5 -13
- package/lib/emulator/storage/rfc.js +9 -0
- package/lib/emulator/storage/rules/config.js +4 -2
- package/lib/experiments.js +8 -3
- package/lib/extensions/askUserForParam.js +1 -1
- package/lib/extensions/change-log.js +2 -4
- package/lib/extensions/displayExtensionInfo.js +0 -5
- package/lib/extensions/extensionsHelper.js +5 -7
- package/lib/extensions/provisioningHelper.js +1 -1
- package/lib/extensions/updateHelper.js +1 -2
- package/lib/extensions/warnings.js +2 -7
- package/lib/firestore/api-sort.test.js +74 -0
- package/lib/firestore/api.js +8 -7
- package/lib/firestore/backupUtils.test.js +18 -0
- package/lib/firestore/pretty-print.js +21 -1
- package/lib/firestore/pretty-print.test.js +61 -0
- package/lib/firestore/util.test.js +42 -0
- package/lib/frameworks/angular/utils.js +13 -5
- package/lib/frameworks/compose/discover/mockFileSystem.js +36 -0
- package/lib/frameworks/index.js +2 -6
- package/lib/frameworks/next/utils.js +2 -8
- package/lib/frameworks/nuxt/index.js +3 -3
- package/lib/functions/events/v2.js +2 -1
- package/lib/gcp/cloudsql/cloudsqladmin.js +6 -1
- package/lib/gcp/devConnect.js +36 -1
- package/lib/hosting/implicitInit.js +2 -2
- package/lib/init/features/dataconnect/index.js +97 -31
- package/lib/init/features/dataconnect/sdk.js +131 -0
- package/lib/init/features/firestore/indexes.js +2 -2
- package/lib/init/features/firestore/rules.js +2 -2
- package/lib/init/features/functions/javascript.js +6 -8
- package/lib/init/features/functions/python.js +4 -6
- package/lib/init/features/functions/typescript.js +8 -10
- package/lib/init/features/hosting/github.js +43 -21
- package/lib/init/features/hosting/index.js +3 -3
- package/lib/init/features/index.js +3 -1
- package/lib/init/features/storage.js +2 -2
- package/lib/init/index.js +1 -0
- package/lib/listFiles.js +1 -1
- package/lib/management/apps.js +2 -2
- package/lib/rc.js +1 -0
- package/lib/requireAuth.js +8 -3
- package/lib/rulesDeploy.js +14 -12
- package/lib/templates.js +23 -0
- package/lib/utils.js +2 -2
- package/package.json +25 -24
- package/schema/connector-yaml.json +36 -4
- package/schema/dataconnect-yaml.json +4 -0
- package/schema/firebase-config.json +0 -8
- package/templates/_gitignore +3 -0
- package/templates/init/dataconnect/connector.yaml +11 -0
- package/templates/init/dataconnect/dataconnect.yaml +2 -1
- package/templates/init/dataconnect/mutations.gql +19 -14
- package/templates/init/dataconnect/queries.gql +28 -23
- package/templates/init/dataconnect/schema.gql +1 -1
- package/lib/extensions/billingMigrationHelper.js +0 -61
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.upsertConnector = exports.listConnectors = exports.deleteConnector = exports.getConnector = exports.upsertSchema = exports.getSchema = exports.
|
|
3
|
+
exports.upsertConnector = exports.listConnectors = exports.deleteConnector = exports.getConnector = exports.deleteSchema = exports.upsertSchema = exports.getSchema = exports.deleteServiceAndChildResources = exports.createService = exports.listAllServices = exports.getService = exports.listLocations = void 0;
|
|
4
4
|
const api_1 = require("../api");
|
|
5
5
|
const apiv2_1 = require("../apiv2");
|
|
6
6
|
const operationPoller = require("../operation-poller");
|
|
7
7
|
const types = require("./types");
|
|
8
8
|
const DATACONNECT_API_VERSION = "v1alpha";
|
|
9
|
+
const PAGE_SIZE_MAX = 100;
|
|
9
10
|
const dataconnectClient = () => new apiv2_1.Client({
|
|
10
11
|
urlPrefix: (0, api_1.dataconnectOrigin)(),
|
|
11
12
|
apiVersion: DATACONNECT_API_VERSION,
|
|
@@ -16,6 +17,11 @@ async function listLocations(projectId) {
|
|
|
16
17
|
return res.body?.locations?.map((l) => l.locationId) ?? [];
|
|
17
18
|
}
|
|
18
19
|
exports.listLocations = listLocations;
|
|
20
|
+
async function getService(serviceName) {
|
|
21
|
+
const res = await dataconnectClient().get(serviceName);
|
|
22
|
+
return res.body;
|
|
23
|
+
}
|
|
24
|
+
exports.getService = getService;
|
|
19
25
|
async function listAllServices(projectId) {
|
|
20
26
|
const res = await dataconnectClient().get(`/projects/${projectId}/locations/-/services`);
|
|
21
27
|
return res.body.services ?? [];
|
|
@@ -37,8 +43,8 @@ async function createService(projectId, locationId, serviceId) {
|
|
|
37
43
|
return pollRes;
|
|
38
44
|
}
|
|
39
45
|
exports.createService = createService;
|
|
40
|
-
async function deleteService(
|
|
41
|
-
const op = await dataconnectClient().delete(
|
|
46
|
+
async function deleteService(serviceName) {
|
|
47
|
+
const op = await dataconnectClient().delete(serviceName);
|
|
42
48
|
const pollRes = await operationPoller.pollOperation({
|
|
43
49
|
apiOrigin: (0, api_1.dataconnectOrigin)(),
|
|
44
50
|
apiVersion: DATACONNECT_API_VERSION,
|
|
@@ -46,7 +52,20 @@ async function deleteService(projectId, locationId, serviceId) {
|
|
|
46
52
|
});
|
|
47
53
|
return pollRes;
|
|
48
54
|
}
|
|
49
|
-
|
|
55
|
+
async function deleteServiceAndChildResources(serviceName) {
|
|
56
|
+
const connectors = await listConnectors(serviceName);
|
|
57
|
+
await Promise.all(connectors.map(async (c) => deleteConnector(c.name)));
|
|
58
|
+
try {
|
|
59
|
+
await deleteSchema(serviceName);
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
if (err.status !== 404) {
|
|
63
|
+
throw err;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
await deleteService(serviceName);
|
|
67
|
+
}
|
|
68
|
+
exports.deleteServiceAndChildResources = deleteServiceAndChildResources;
|
|
50
69
|
async function getSchema(serviceName) {
|
|
51
70
|
try {
|
|
52
71
|
const res = await dataconnectClient().get(`${serviceName}/schemas/${types.SCHEMA_ID}`);
|
|
@@ -77,19 +96,47 @@ async function upsertSchema(schema, validateOnly = false) {
|
|
|
77
96
|
});
|
|
78
97
|
}
|
|
79
98
|
exports.upsertSchema = upsertSchema;
|
|
99
|
+
async function deleteSchema(serviceName) {
|
|
100
|
+
const op = await dataconnectClient().delete(`${serviceName}/schemas/${types.SCHEMA_ID}`);
|
|
101
|
+
await operationPoller.pollOperation({
|
|
102
|
+
apiOrigin: (0, api_1.dataconnectOrigin)(),
|
|
103
|
+
apiVersion: DATACONNECT_API_VERSION,
|
|
104
|
+
operationResourceName: op.body.name,
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
exports.deleteSchema = deleteSchema;
|
|
80
109
|
async function getConnector(name) {
|
|
81
110
|
const res = await dataconnectClient().get(name);
|
|
82
111
|
return res.body;
|
|
83
112
|
}
|
|
84
113
|
exports.getConnector = getConnector;
|
|
85
114
|
async function deleteConnector(name) {
|
|
86
|
-
const
|
|
87
|
-
|
|
115
|
+
const op = await dataconnectClient().delete(name);
|
|
116
|
+
await operationPoller.pollOperation({
|
|
117
|
+
apiOrigin: (0, api_1.dataconnectOrigin)(),
|
|
118
|
+
apiVersion: DATACONNECT_API_VERSION,
|
|
119
|
+
operationResourceName: op.body.name,
|
|
120
|
+
});
|
|
121
|
+
return;
|
|
88
122
|
}
|
|
89
123
|
exports.deleteConnector = deleteConnector;
|
|
90
124
|
async function listConnectors(serviceName) {
|
|
91
|
-
const
|
|
92
|
-
|
|
125
|
+
const connectors = [];
|
|
126
|
+
const getNextPage = async (pageToken = "") => {
|
|
127
|
+
const res = await dataconnectClient().get(`${serviceName}/connectors`, {
|
|
128
|
+
queryParams: {
|
|
129
|
+
pageSize: PAGE_SIZE_MAX,
|
|
130
|
+
pageToken,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
connectors.push(...(res.body.connectors || []));
|
|
134
|
+
if (res.body.nextPageToken) {
|
|
135
|
+
await getNextPage(res.body.nextPageToken);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
await getNextPage();
|
|
139
|
+
return connectors;
|
|
93
140
|
}
|
|
94
141
|
exports.listConnectors = listConnectors;
|
|
95
142
|
async function upsertConnector(connector) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pickService = exports.readGQLFiles = exports.readConnectorYaml = exports.readDataConnectYaml = exports.readFirebaseJson = void 0;
|
|
3
|
+
exports.getPlatformFromFolder = exports.pickService = exports.readGQLFiles = exports.readConnectorYaml = exports.readDataConnectYaml = exports.readFirebaseJson = void 0;
|
|
4
4
|
const fs = require("fs-extra");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const error_1 = require("../error");
|
|
7
|
+
const types_1 = require("./types");
|
|
7
8
|
const utils_1 = require("../utils");
|
|
8
9
|
const load_1 = require("./load");
|
|
9
10
|
function readFirebaseJson(config) {
|
|
@@ -11,12 +12,11 @@ function readFirebaseJson(config) {
|
|
|
11
12
|
return [];
|
|
12
13
|
}
|
|
13
14
|
const validator = (cfg) => {
|
|
14
|
-
if (!cfg["source"]
|
|
15
|
-
throw new error_1.FirebaseError("Invalid firebase.json: DataConnect requires `source`
|
|
15
|
+
if (!cfg["source"]) {
|
|
16
|
+
throw new error_1.FirebaseError("Invalid firebase.json: DataConnect requires `source`");
|
|
16
17
|
}
|
|
17
18
|
return {
|
|
18
19
|
source: cfg["source"],
|
|
19
|
-
location: cfg["location"],
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
const configs = config.get("dataconnect");
|
|
@@ -27,7 +27,7 @@ function readFirebaseJson(config) {
|
|
|
27
27
|
return configs.map(validator);
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
throw new error_1.FirebaseError("Invalid firebase.json: dataconnect should be of the form { source: string
|
|
30
|
+
throw new error_1.FirebaseError("Invalid firebase.json: dataconnect should be of the form { source: string }");
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
exports.readFirebaseJson = readFirebaseJson;
|
|
@@ -38,6 +38,9 @@ async function readDataConnectYaml(sourceDirectory) {
|
|
|
38
38
|
}
|
|
39
39
|
exports.readDataConnectYaml = readDataConnectYaml;
|
|
40
40
|
function validateDataConnectYaml(unvalidated) {
|
|
41
|
+
if (!unvalidated["location"]) {
|
|
42
|
+
throw new error_1.FirebaseError("Missing required field 'location' in dataconnect.yaml");
|
|
43
|
+
}
|
|
41
44
|
return unvalidated;
|
|
42
45
|
}
|
|
43
46
|
async function readConnectorYaml(sourceDirectory) {
|
|
@@ -74,13 +77,13 @@ async function pickService(projectId, config, serviceId) {
|
|
|
74
77
|
throw new error_1.FirebaseError("No Data Connect services found in firebase.json.");
|
|
75
78
|
}
|
|
76
79
|
else if (serviceCfgs.length === 1) {
|
|
77
|
-
serviceInfo = await (0, load_1.load)(projectId,
|
|
80
|
+
serviceInfo = await (0, load_1.load)(projectId, config, serviceCfgs[0].source);
|
|
78
81
|
}
|
|
79
82
|
else {
|
|
80
83
|
if (!serviceId) {
|
|
81
84
|
throw new error_1.FirebaseError("Multiple Data Connect services found in firebase.json. Please specify a service ID to use.");
|
|
82
85
|
}
|
|
83
|
-
const infos = await Promise.all(serviceCfgs.map((c) => (0, load_1.load)(projectId,
|
|
86
|
+
const infos = await Promise.all(serviceCfgs.map((c) => (0, load_1.load)(projectId, config, c.source)));
|
|
84
87
|
const maybe = infos.find((i) => i.dataConnectYaml.serviceId === serviceId);
|
|
85
88
|
if (!maybe) {
|
|
86
89
|
throw new error_1.FirebaseError(`No service named ${serviceId} declared in firebase.json.`);
|
|
@@ -90,3 +93,23 @@ async function pickService(projectId, config, serviceId) {
|
|
|
90
93
|
return serviceInfo;
|
|
91
94
|
}
|
|
92
95
|
exports.pickService = pickService;
|
|
96
|
+
const WEB_INDICATORS = ["package.json", "package-lock.json", "node_modules"];
|
|
97
|
+
const IOS_INDICATORS = ["info.plist", "podfile", "package.swift"];
|
|
98
|
+
const ANDROID_INDICATORS = ["androidmanifest.xml", "build.gradle"];
|
|
99
|
+
const IOS_INDICATORS_2 = [".xcworkspace", ".xcodeproj"];
|
|
100
|
+
async function getPlatformFromFolder(dirPath) {
|
|
101
|
+
const fileNames = await fs.readdir(dirPath);
|
|
102
|
+
for (const fileName of fileNames) {
|
|
103
|
+
const cleanedFileName = fileName.toLowerCase();
|
|
104
|
+
if (WEB_INDICATORS.some((indicator) => indicator === cleanedFileName))
|
|
105
|
+
return types_1.Platform.WEB;
|
|
106
|
+
if (ANDROID_INDICATORS.some((indicator) => indicator === cleanedFileName))
|
|
107
|
+
return types_1.Platform.ANDROID;
|
|
108
|
+
if (IOS_INDICATORS.some((indicator) => indicator === cleanedFileName))
|
|
109
|
+
return types_1.Platform.IOS;
|
|
110
|
+
if (IOS_INDICATORS_2.some((indicator) => cleanedFileName.endsWith(indicator)))
|
|
111
|
+
return types_1.Platform.IOS;
|
|
112
|
+
}
|
|
113
|
+
return types_1.Platform.UNDETERMINED;
|
|
114
|
+
}
|
|
115
|
+
exports.getPlatformFromFolder = getPlatformFromFolder;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getResourceFilters = void 0;
|
|
3
|
+
exports.toString = exports.getResourceFilters = void 0;
|
|
4
4
|
const error_1 = require("../error");
|
|
5
5
|
function getResourceFilters(options) {
|
|
6
6
|
if (!options.only) {
|
|
@@ -43,3 +43,14 @@ function parseSelector(selector) {
|
|
|
43
43
|
}
|
|
44
44
|
return filter;
|
|
45
45
|
}
|
|
46
|
+
function toString(rf) {
|
|
47
|
+
const base = `dataconnect:${rf.serviceId}`;
|
|
48
|
+
if (rf.connectorId) {
|
|
49
|
+
return `${base}:${rf.connectorId}`;
|
|
50
|
+
}
|
|
51
|
+
if (rf.schemaOnly) {
|
|
52
|
+
return `${base}:schema`;
|
|
53
|
+
}
|
|
54
|
+
return base;
|
|
55
|
+
}
|
|
56
|
+
exports.toString = toString;
|
package/lib/dataconnect/load.js
CHANGED
|
@@ -4,16 +4,18 @@ exports.load = void 0;
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const fileUtils = require("./fileUtils");
|
|
6
6
|
const types_1 = require("./types");
|
|
7
|
-
async function load(projectId,
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
7
|
+
async function load(projectId, config, sourceDirectory) {
|
|
8
|
+
const resolvedDir = config.path(sourceDirectory);
|
|
9
|
+
const dataConnectYaml = await fileUtils.readDataConnectYaml(resolvedDir);
|
|
10
|
+
const serviceName = `projects/${projectId}/locations/${dataConnectYaml.location}/services/${dataConnectYaml.serviceId}`;
|
|
11
|
+
const schemaDir = path.join(resolvedDir, dataConnectYaml.schema.source);
|
|
11
12
|
const schemaGQLs = await fileUtils.readGQLFiles(schemaDir);
|
|
12
13
|
const connectorInfo = await Promise.all(dataConnectYaml.connectorDirs.map(async (dir) => {
|
|
13
|
-
const connectorDir = path.join(
|
|
14
|
+
const connectorDir = path.join(resolvedDir, dir);
|
|
14
15
|
const connectorYaml = await fileUtils.readConnectorYaml(connectorDir);
|
|
15
16
|
const connectorGqls = await fileUtils.readGQLFiles(connectorDir);
|
|
16
17
|
return {
|
|
18
|
+
directory: connectorDir,
|
|
17
19
|
connectorYaml,
|
|
18
20
|
connector: {
|
|
19
21
|
name: `${serviceName}/connectors/${connectorYaml.connectorId}`,
|
|
@@ -25,10 +27,10 @@ async function load(projectId, locationId, sourceDirectory) {
|
|
|
25
27
|
}));
|
|
26
28
|
return {
|
|
27
29
|
serviceName,
|
|
28
|
-
sourceDirectory,
|
|
30
|
+
sourceDirectory: resolvedDir,
|
|
29
31
|
schema: {
|
|
30
32
|
name: `${serviceName}/schemas/${types_1.SCHEMA_ID}`,
|
|
31
|
-
primaryDatasource: (0, types_1.toDatasource)(projectId,
|
|
33
|
+
primaryDatasource: (0, types_1.toDatasource)(projectId, dataConnectYaml.location, dataConnectYaml.schema.datasource),
|
|
32
34
|
source: {
|
|
33
35
|
files: schemaGQLs,
|
|
34
36
|
},
|
|
@@ -11,10 +11,12 @@ const logger_1 = require("../logger");
|
|
|
11
11
|
const error_1 = require("../error");
|
|
12
12
|
const projectUtils_1 = require("../projectUtils");
|
|
13
13
|
const utils_1 = require("../utils");
|
|
14
|
+
const experiments = require("../experiments");
|
|
14
15
|
const errors = require("./errors");
|
|
15
16
|
async function diffSchema(schema) {
|
|
16
17
|
const { serviceName, instanceName, databaseId } = getIdentifiers(schema);
|
|
17
18
|
await ensureServiceIsConnectedToCloudSql(serviceName, instanceName, databaseId, false);
|
|
19
|
+
setCompatibleMode(schema, databaseId, instanceName);
|
|
18
20
|
try {
|
|
19
21
|
await (0, client_1.upsertSchema)(schema, true);
|
|
20
22
|
(0, utils_1.logLabeledSuccess)("dataconnect", `Database schema is up to date.`);
|
|
@@ -43,6 +45,7 @@ async function migrateSchema(args) {
|
|
|
43
45
|
const { options, schema, validateOnly } = args;
|
|
44
46
|
const { serviceName, instanceId, instanceName, databaseId } = getIdentifiers(schema);
|
|
45
47
|
await ensureServiceIsConnectedToCloudSql(serviceName, instanceName, databaseId, true);
|
|
48
|
+
setCompatibleMode(schema, databaseId, instanceName);
|
|
46
49
|
try {
|
|
47
50
|
await (0, client_1.upsertSchema)(schema, validateOnly);
|
|
48
51
|
logger_1.logger.debug(`Database schema was up to date for ${instanceId}:${databaseId}`);
|
|
@@ -79,6 +82,24 @@ async function migrateSchema(args) {
|
|
|
79
82
|
return [];
|
|
80
83
|
}
|
|
81
84
|
exports.migrateSchema = migrateSchema;
|
|
85
|
+
function setCompatibleMode(schema, databaseId, instanceName) {
|
|
86
|
+
if (experiments.isEnabled("fdccompatiblemode")) {
|
|
87
|
+
if (schema.primaryDatasource.postgresql?.schemaValidation) {
|
|
88
|
+
schema.primaryDatasource.postgresql.schemaValidation = "COMPATIBLE";
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
schema.primaryDatasource = {
|
|
92
|
+
postgresql: {
|
|
93
|
+
database: databaseId,
|
|
94
|
+
cloudSql: {
|
|
95
|
+
instance: instanceName,
|
|
96
|
+
},
|
|
97
|
+
schemaValidation: "COMPATIBLE",
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
82
103
|
function getIdentifiers(schema) {
|
|
83
104
|
const databaseId = schema.primaryDatasource.postgresql?.database;
|
|
84
105
|
if (!databaseId) {
|
package/lib/dataconnect/types.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toDatasource = exports.requiresVector = exports.SCHEMA_ID = void 0;
|
|
3
|
+
exports.toDatasource = exports.Platform = exports.requiresVector = exports.SCHEMA_ID = void 0;
|
|
4
4
|
exports.SCHEMA_ID = "main";
|
|
5
5
|
function requiresVector(dm) {
|
|
6
6
|
return dm?.primaryDataSource?.postgres?.requiredExtensions?.includes("vector") ?? false;
|
|
7
7
|
}
|
|
8
8
|
exports.requiresVector = requiresVector;
|
|
9
|
+
var Platform;
|
|
10
|
+
(function (Platform) {
|
|
11
|
+
Platform["ANDROID"] = "ANDROID";
|
|
12
|
+
Platform["WEB"] = "WEB";
|
|
13
|
+
Platform["IOS"] = "IOS";
|
|
14
|
+
Platform["UNDETERMINED"] = "UNDETERMINED";
|
|
15
|
+
})(Platform = exports.Platform || (exports.Platform = {}));
|
|
9
16
|
function toDatasource(projectId, locationId, ds) {
|
|
10
17
|
if (ds.postgresql) {
|
|
11
18
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const clc = require("colorette");
|
|
4
4
|
const load_1 = require("../../dataconnect/load");
|
|
5
5
|
const fileUtils_1 = require("../../dataconnect/fileUtils");
|
|
6
6
|
const logger_1 = require("../../logger");
|
|
@@ -11,6 +11,7 @@ const build_1 = require("../../dataconnect/build");
|
|
|
11
11
|
const ensureApis_1 = require("../../dataconnect/ensureApis");
|
|
12
12
|
const requireTosAcceptance_1 = require("../../requireTosAcceptance");
|
|
13
13
|
const firedata_1 = require("../../gcp/firedata");
|
|
14
|
+
const error_1 = require("../../error");
|
|
14
15
|
async function default_1(context, options) {
|
|
15
16
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
16
17
|
await (0, ensureApis_1.ensureApis)(projectId);
|
|
@@ -18,10 +19,23 @@ async function default_1(context, options) {
|
|
|
18
19
|
const serviceCfgs = (0, fileUtils_1.readFirebaseJson)(options.config);
|
|
19
20
|
utils.logLabeledBullet("dataconnect", `Preparing to deploy`);
|
|
20
21
|
const filters = (0, filters_1.getResourceFilters)(options);
|
|
21
|
-
const serviceInfos = await Promise.all(serviceCfgs.map((c) => (0, load_1.load)(projectId,
|
|
22
|
+
const serviceInfos = await Promise.all(serviceCfgs.map((c) => (0, load_1.load)(projectId, options.config, c.source)));
|
|
22
23
|
for (const si of serviceInfos) {
|
|
23
24
|
si.deploymentMetadata = await (0, build_1.build)(options, si.sourceDirectory);
|
|
24
25
|
}
|
|
26
|
+
const unmatchedFilters = filters?.filter((f) => {
|
|
27
|
+
const serviceMatched = serviceInfos.some((s) => s.dataConnectYaml.serviceId === f.serviceId);
|
|
28
|
+
const connectorMatched = f.connectorId
|
|
29
|
+
? serviceInfos.some((s) => {
|
|
30
|
+
return (s.dataConnectYaml.serviceId === f.serviceId &&
|
|
31
|
+
s.connectorInfo.some((c) => c.connectorYaml.connectorId === f.connectorId));
|
|
32
|
+
})
|
|
33
|
+
: true;
|
|
34
|
+
return !serviceMatched || !connectorMatched;
|
|
35
|
+
});
|
|
36
|
+
if (unmatchedFilters?.length) {
|
|
37
|
+
throw new error_1.FirebaseError(`The following filters were specified in --only but didn't match anything in this project: ${unmatchedFilters.map(filters_1.toString).map(clc.bold).join(", ")}`);
|
|
38
|
+
}
|
|
25
39
|
context.dataconnect = {
|
|
26
40
|
serviceInfos,
|
|
27
41
|
filters,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toBackend = exports.resolveBackend = exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.AllFunctionsPlatforms = exports.isBlockingTriggered = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isCallableTriggered = exports.isHttpsTriggered = exports.of = exports.empty = void 0;
|
|
3
|
+
exports.toBackend = exports.envWithTypes = exports.resolveBackend = exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.AllFunctionsPlatforms = exports.isBlockingTriggered = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isCallableTriggered = exports.isHttpsTriggered = exports.of = exports.empty = void 0;
|
|
4
4
|
const backend = require("./backend");
|
|
5
5
|
const proto = require("../../gcp/proto");
|
|
6
6
|
const api = require("../../.../../api");
|
|
@@ -114,12 +114,21 @@ function envWithTypes(definedParams, rawEnvs) {
|
|
|
114
114
|
list: true,
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
+
else if (param.type === "secret") {
|
|
118
|
+
providedType = {
|
|
119
|
+
string: true,
|
|
120
|
+
boolean: false,
|
|
121
|
+
number: false,
|
|
122
|
+
list: false,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
117
125
|
}
|
|
118
126
|
}
|
|
119
127
|
out[envName] = new params.ParamValue(value, false, providedType);
|
|
120
128
|
}
|
|
121
129
|
return out;
|
|
122
130
|
}
|
|
131
|
+
exports.envWithTypes = envWithTypes;
|
|
123
132
|
class Resolver {
|
|
124
133
|
constructor(paramValues) {
|
|
125
134
|
this.paramValues = paramValues;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const adminSdkConfig_1 = require("./adminSdkConfig");
|
|
5
|
+
describe("adminSdkConfig", () => {
|
|
6
|
+
describe("getProjectAdminSdkConfigOrCached", () => {
|
|
7
|
+
it("should return a fake config for a demo project id", async () => {
|
|
8
|
+
const projectId = "demo-project-1234";
|
|
9
|
+
await (0, chai_1.expect)((0, adminSdkConfig_1.getProjectAdminSdkConfigOrCached)(projectId)).to.eventually.deep.equal({
|
|
10
|
+
projectId: "demo-project-1234",
|
|
11
|
+
databaseURL: "https://demo-project-1234.firebaseio.com",
|
|
12
|
+
storageBucket: "demo-project-1234.appspot.com",
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -106,6 +106,7 @@ Constants.SERVICE_FIRESTORE = "firestore.googleapis.com";
|
|
|
106
106
|
Constants.SERVICE_REALTIME_DATABASE = "firebaseio.com";
|
|
107
107
|
Constants.SERVICE_PUBSUB = "pubsub.googleapis.com";
|
|
108
108
|
Constants.SERVICE_EVENTARC = "eventarc.googleapis.com";
|
|
109
|
+
Constants.SERVICE_FIREALERTS = "firebasealerts.googleapis.com";
|
|
109
110
|
Constants.SERVICE_ANALYTICS = "app-measurement.com";
|
|
110
111
|
Constants.SERVICE_AUTH = "firebaseauth.googleapis.com";
|
|
111
112
|
Constants.SERVICE_CRASHLYTICS = "fabric.io";
|
|
@@ -322,6 +322,7 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
322
322
|
},
|
|
323
323
|
secretEnv: [],
|
|
324
324
|
predefinedTriggers: options.extDevTriggers,
|
|
325
|
+
ignore: cfg.ignore,
|
|
325
326
|
});
|
|
326
327
|
}
|
|
327
328
|
}
|
|
@@ -529,23 +530,16 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
529
530
|
else if (config.length > 1) {
|
|
530
531
|
logger_1.logger.warn(`TODO: Add support for multiple services in the Data Connect emulator. Currently emulating first service ${config[0].source}`);
|
|
531
532
|
}
|
|
532
|
-
|
|
533
|
-
if (!path.isAbsolute(configDir)) {
|
|
534
|
-
const cwd = options.cwd || process.cwd();
|
|
535
|
-
configDir = path.resolve(path.join(cwd), configDir);
|
|
536
|
-
}
|
|
533
|
+
const configDir = config[0].source;
|
|
537
534
|
const dataConnectEmulator = new dataconnectEmulator_1.DataConnectEmulator({
|
|
538
535
|
listen: listenForEmulator.dataconnect,
|
|
539
536
|
projectId,
|
|
540
537
|
auto_download: true,
|
|
541
538
|
configDir,
|
|
542
|
-
locationId: config[0].location,
|
|
543
539
|
rc: options.rc,
|
|
540
|
+
config: options.config,
|
|
544
541
|
});
|
|
545
542
|
await startEmulator(dataConnectEmulator);
|
|
546
|
-
if (!utils.isVSCodeExtension()) {
|
|
547
|
-
await dataConnectEmulator.connectToPostgres();
|
|
548
|
-
}
|
|
549
543
|
}
|
|
550
544
|
if (listenForEmulator.storage) {
|
|
551
545
|
const storageAddr = legacyGetFirstAddr(types_1.Emulators.STORAGE);
|