firebase-tools 13.3.1 → 13.4.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.
- package/lib/api.js +2 -1
- package/lib/apiv2.js +8 -3
- package/lib/commands/apphosting-backends-create.js +3 -3
- package/lib/commands/apphosting-backends-delete.js +3 -39
- package/lib/commands/apphosting-backends-get.js +4 -35
- package/lib/commands/apphosting-backends-list.js +17 -9
- package/lib/commands/apphosting-builds-create.js +4 -4
- package/lib/commands/apphosting-builds-get.js +2 -2
- package/lib/commands/apphosting-rollouts-create.js +3 -3
- package/lib/commands/apphosting-rollouts-list.js +2 -2
- package/lib/commands/firestore-backups-delete.js +44 -0
- package/lib/commands/firestore-backups-get.js +25 -0
- package/lib/commands/firestore-backups-list.js +34 -0
- package/lib/commands/firestore-backups-schedules-create.js +67 -0
- package/lib/commands/firestore-backups-schedules-delete.js +46 -0
- package/lib/commands/firestore-backups-schedules-list.js +28 -0
- package/lib/commands/firestore-backups-schedules-update.js +33 -0
- package/lib/commands/firestore-databases-create.js +4 -2
- package/lib/commands/firestore-databases-delete.js +4 -2
- package/lib/commands/firestore-databases-get.js +3 -1
- package/lib/commands/firestore-databases-list.js +3 -1
- package/lib/commands/firestore-databases-restore.js +42 -0
- package/lib/commands/firestore-databases-update.js +4 -2
- package/lib/commands/firestore-indexes-list.js +5 -3
- package/lib/commands/firestore-locations.js +3 -1
- package/lib/commands/index.js +10 -0
- package/lib/deploy/extensions/v2FunctionHelper.js +2 -1
- package/lib/deploy/functions/backend.js +5 -1
- package/lib/deploy/functions/build.js +9 -6
- package/lib/deploy/functions/ensure.js +2 -2
- package/lib/deploy/functions/prepare.js +5 -9
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +2 -1
- package/lib/emulator/downloadableEmulators.js +3 -3
- package/lib/ensureApiEnabled.js +8 -6
- package/lib/extensions/extensionsHelper.js +2 -2
- package/lib/extensions/secretsUtils.js +2 -1
- package/lib/fetchWebSetup.js +2 -1
- package/lib/firestore/api-sort.js +23 -1
- package/lib/firestore/api-types.js +6 -1
- package/lib/firestore/api.js +18 -115
- package/lib/firestore/backupUtils.js +30 -0
- package/lib/firestore/pretty-print.js +184 -0
- package/lib/frameworks/index.js +6 -2
- package/lib/frameworks/next/constants.js +35 -1
- package/lib/frameworks/next/index.js +25 -3
- package/lib/frameworks/next/utils.js +20 -1
- package/lib/functions/secrets.js +1 -1
- package/lib/gcp/apphosting.js +2 -3
- package/lib/gcp/auth.js +5 -2
- package/lib/gcp/firestore.js +75 -1
- package/lib/gcp/storage.js +1 -1
- package/lib/hosting/api.js +12 -1
- package/lib/init/features/apphosting/index.js +12 -7
- package/lib/init/features/database.js +2 -1
- package/lib/init/features/extensions/index.js +2 -1
- package/lib/init/features/functions/index.js +3 -2
- package/package.json +2 -1
package/lib/gcp/firestore.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteDocuments = exports.deleteDocument = exports.listCollectionIds = exports.getDatabase = void 0;
|
|
3
|
+
exports.getBackupSchedule = exports.listBackupSchedules = exports.getBackup = exports.listBackups = exports.deleteBackupSchedule = exports.deleteBackup = exports.updateBackupSchedule = exports.createBackupSchedule = exports.deleteDocuments = exports.deleteDocument = exports.listCollectionIds = exports.getDatabase = exports.DayOfWeek = void 0;
|
|
4
4
|
const api_1 = require("../api");
|
|
5
5
|
const apiv2_1 = require("../apiv2");
|
|
6
6
|
const logger_1 = require("../logger");
|
|
7
|
+
const proto_1 = require("./proto");
|
|
8
|
+
const error_1 = require("../error");
|
|
7
9
|
const prodOnlyClient = new apiv2_1.Client({
|
|
8
10
|
auth: true,
|
|
9
11
|
apiVersion: "v1",
|
|
@@ -14,6 +16,16 @@ const emuOrProdClient = new apiv2_1.Client({
|
|
|
14
16
|
apiVersion: "v1",
|
|
15
17
|
urlPrefix: api_1.firestoreOriginOrEmulator,
|
|
16
18
|
});
|
|
19
|
+
var DayOfWeek;
|
|
20
|
+
(function (DayOfWeek) {
|
|
21
|
+
DayOfWeek["MONDAY"] = "MONDAY";
|
|
22
|
+
DayOfWeek["TUEDAY"] = "TUESDAY";
|
|
23
|
+
DayOfWeek["WEDNESDAY"] = "WEDNESDAY";
|
|
24
|
+
DayOfWeek["THURSDAY"] = "THURSDAY";
|
|
25
|
+
DayOfWeek["FRIDAY"] = "FRIDAY";
|
|
26
|
+
DayOfWeek["SATURDAY"] = "SATURDAY";
|
|
27
|
+
DayOfWeek["SUNDAY"] = "SUNDAY";
|
|
28
|
+
})(DayOfWeek = exports.DayOfWeek || (exports.DayOfWeek = {}));
|
|
17
29
|
async function getDatabase(project, database, allowEmulator = false) {
|
|
18
30
|
const apiClient = allowEmulator ? emuOrProdClient : prodOnlyClient;
|
|
19
31
|
const url = `projects/${project}/databases/${database}`;
|
|
@@ -54,3 +66,65 @@ async function deleteDocuments(project, docs, allowEmulator = false) {
|
|
|
54
66
|
return res.body.writeResults.length;
|
|
55
67
|
}
|
|
56
68
|
exports.deleteDocuments = deleteDocuments;
|
|
69
|
+
async function createBackupSchedule(project, databaseId, retention, dailyRecurrence, weeklyRecurrence) {
|
|
70
|
+
const url = `projects/${project}/databases/${databaseId}/backupSchedules`;
|
|
71
|
+
const data = {
|
|
72
|
+
retention: (0, proto_1.durationFromSeconds)(retention),
|
|
73
|
+
dailyRecurrence,
|
|
74
|
+
weeklyRecurrence,
|
|
75
|
+
};
|
|
76
|
+
(0, proto_1.assertOneOf)("BackupSchedule", data, "recurrence", "dailyRecurrence", "weeklyRecurrence");
|
|
77
|
+
const res = await prodOnlyClient.post(url, data);
|
|
78
|
+
return res.body;
|
|
79
|
+
}
|
|
80
|
+
exports.createBackupSchedule = createBackupSchedule;
|
|
81
|
+
async function updateBackupSchedule(backupScheduleName, retention) {
|
|
82
|
+
const data = {
|
|
83
|
+
retention: (0, proto_1.durationFromSeconds)(retention),
|
|
84
|
+
};
|
|
85
|
+
const res = await prodOnlyClient.patch(backupScheduleName, data);
|
|
86
|
+
return res.body;
|
|
87
|
+
}
|
|
88
|
+
exports.updateBackupSchedule = updateBackupSchedule;
|
|
89
|
+
async function deleteBackup(backupName) {
|
|
90
|
+
await prodOnlyClient.delete(backupName);
|
|
91
|
+
}
|
|
92
|
+
exports.deleteBackup = deleteBackup;
|
|
93
|
+
async function deleteBackupSchedule(backupScheduleName) {
|
|
94
|
+
await prodOnlyClient.delete(backupScheduleName);
|
|
95
|
+
}
|
|
96
|
+
exports.deleteBackupSchedule = deleteBackupSchedule;
|
|
97
|
+
async function listBackups(project, location) {
|
|
98
|
+
const url = `/projects/${project}/locations/${location}/backups`;
|
|
99
|
+
const res = await prodOnlyClient.get(url);
|
|
100
|
+
return res.body;
|
|
101
|
+
}
|
|
102
|
+
exports.listBackups = listBackups;
|
|
103
|
+
async function getBackup(backupName) {
|
|
104
|
+
const res = await prodOnlyClient.get(backupName);
|
|
105
|
+
const backup = res.body;
|
|
106
|
+
if (!backup) {
|
|
107
|
+
throw new error_1.FirebaseError("Not found");
|
|
108
|
+
}
|
|
109
|
+
return backup;
|
|
110
|
+
}
|
|
111
|
+
exports.getBackup = getBackup;
|
|
112
|
+
async function listBackupSchedules(project, database) {
|
|
113
|
+
const url = `/projects/${project}/databases/${database}/backupSchedules`;
|
|
114
|
+
const res = await prodOnlyClient.get(url);
|
|
115
|
+
const backupSchedules = res.body.backupSchedules;
|
|
116
|
+
if (!backupSchedules) {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
return backupSchedules;
|
|
120
|
+
}
|
|
121
|
+
exports.listBackupSchedules = listBackupSchedules;
|
|
122
|
+
async function getBackupSchedule(backupScheduleName) {
|
|
123
|
+
const res = await prodOnlyClient.get(backupScheduleName);
|
|
124
|
+
const backupSchedule = res.body;
|
|
125
|
+
if (!backupSchedule) {
|
|
126
|
+
throw new error_1.FirebaseError("Not found");
|
|
127
|
+
}
|
|
128
|
+
return backupSchedule;
|
|
129
|
+
}
|
|
130
|
+
exports.getBackupSchedule = getBackupSchedule;
|
package/lib/gcp/storage.js
CHANGED
|
@@ -10,7 +10,7 @@ const logger_1 = require("../logger");
|
|
|
10
10
|
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
11
11
|
async function getDefaultBucket(projectId) {
|
|
12
12
|
var _a;
|
|
13
|
-
await (0, ensureApiEnabled_1.ensure)(projectId,
|
|
13
|
+
await (0, ensureApiEnabled_1.ensure)(projectId, api_1.firebaseStorageOrigin, "storage", false);
|
|
14
14
|
try {
|
|
15
15
|
const localAPIClient = new apiv2_1.Client({ urlPrefix: api_1.firebaseStorageOrigin, apiVersion: "v1alpha" });
|
|
16
16
|
const response = await localAPIClient.get(`/projects/${projectId}/defaultBucket`);
|
package/lib/hosting/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDeploymentDomain = exports.getAllSiteDomains = exports.getSiteDomains = exports.cleanAuthState = exports.getCleanDomains = exports.removeAuthDomain = exports.addAuthDomains = exports.deleteSite = exports.updateSite = exports.createSite = exports.getSite = exports.listSites = exports.createRelease = exports.cloneVersion = exports.listVersions = exports.updateVersion = exports.createVersion = exports.deleteChannel = exports.updateChannelTtl = exports.createChannel = exports.listChannels = exports.getChannel = exports.normalizeName = exports.SiteType = void 0;
|
|
3
|
+
exports.getDeploymentDomain = exports.getAllSiteDomains = exports.getSiteDomains = exports.cleanAuthState = exports.getCleanDomains = exports.removeAuthDomain = exports.addAuthDomains = exports.deleteSite = exports.updateSite = exports.createSite = exports.getSite = exports.listDemoSites = exports.listSites = exports.createRelease = exports.cloneVersion = exports.listVersions = exports.updateVersion = exports.createVersion = exports.deleteChannel = exports.updateChannelTtl = exports.createChannel = exports.listChannels = exports.getChannel = exports.normalizeName = exports.SiteType = void 0;
|
|
4
4
|
const error_1 = require("../error");
|
|
5
5
|
const api_1 = require("../api");
|
|
6
6
|
const apiv2_1 = require("../apiv2");
|
|
@@ -159,6 +159,17 @@ async function listSites(project) {
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
exports.listSites = listSites;
|
|
162
|
+
function listDemoSites(projectId) {
|
|
163
|
+
return [
|
|
164
|
+
{
|
|
165
|
+
name: `projects/${projectId}/sites/${projectId}`,
|
|
166
|
+
defaultUrl: `https://${projectId}.firebaseapp.com`,
|
|
167
|
+
appId: "fake-app-id",
|
|
168
|
+
labels: {},
|
|
169
|
+
},
|
|
170
|
+
];
|
|
171
|
+
}
|
|
172
|
+
exports.listDemoSites = listDemoSites;
|
|
162
173
|
async function getSite(project, site) {
|
|
163
174
|
try {
|
|
164
175
|
const res = await apiClient.get(`/projects/${project}/sites/${site}`);
|
|
@@ -24,10 +24,10 @@ const apphostingPollerOptions = {
|
|
|
24
24
|
};
|
|
25
25
|
async function doSetup(projectId, location, serviceAccount) {
|
|
26
26
|
await Promise.all([
|
|
27
|
-
(0, ensureApiEnabled_1.ensure)(projectId,
|
|
28
|
-
(0, ensureApiEnabled_1.ensure)(projectId,
|
|
29
|
-
(0, ensureApiEnabled_1.ensure)(projectId,
|
|
30
|
-
(0, ensureApiEnabled_1.ensure)(projectId,
|
|
27
|
+
(0, ensureApiEnabled_1.ensure)(projectId, api_1.cloudbuildOrigin, "apphosting", true),
|
|
28
|
+
(0, ensureApiEnabled_1.ensure)(projectId, api_1.secretManagerOrigin, "apphosting", true),
|
|
29
|
+
(0, ensureApiEnabled_1.ensure)(projectId, api_1.cloudRunApiOrigin, "apphosting", true),
|
|
30
|
+
(0, ensureApiEnabled_1.ensure)(projectId, api_1.artifactRegistryDomain, "apphosting", true),
|
|
31
31
|
]);
|
|
32
32
|
const allowedLocations = (await apphosting.listLocations(projectId)).map((loc) => loc.locationId);
|
|
33
33
|
if (location) {
|
|
@@ -122,9 +122,14 @@ async function createBackend(projectId, location, backendId, repository, service
|
|
|
122
122
|
return await createBackendAndPoll();
|
|
123
123
|
}
|
|
124
124
|
catch (err) {
|
|
125
|
-
if (err.status === 403
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
if (err.status === 403) {
|
|
126
|
+
if (err.message.includes(defaultServiceAccount)) {
|
|
127
|
+
await provisionDefaultComputeServiceAccount(projectId);
|
|
128
|
+
return await createBackendAndPoll();
|
|
129
|
+
}
|
|
130
|
+
else if (serviceAccount && err.message.includes(serviceAccount)) {
|
|
131
|
+
throw new error_1.FirebaseError(`Failed to create backend due to missing delegation permissions for ${serviceAccount}. Make sure you have the iam.serviceAccounts.actAs permission.`, { children: [err] });
|
|
132
|
+
}
|
|
128
133
|
}
|
|
129
134
|
throw err;
|
|
130
135
|
}
|
|
@@ -12,6 +12,7 @@ const ensureApiEnabled_1 = require("../../ensureApiEnabled");
|
|
|
12
12
|
const getDefaultDatabaseInstance_1 = require("../../getDefaultDatabaseInstance");
|
|
13
13
|
const error_1 = require("../../error");
|
|
14
14
|
const apiv2_1 = require("../../apiv2");
|
|
15
|
+
const api_1 = require("../../api");
|
|
15
16
|
const DEFAULT_RULES = JSON.stringify({ rules: { ".read": "auth != null", ".write": "auth != null" } }, null, 2);
|
|
16
17
|
async function getDBRules(instanceDetails) {
|
|
17
18
|
if (!instanceDetails || !instanceDetails.name) {
|
|
@@ -70,7 +71,7 @@ async function doSetup(setup, config) {
|
|
|
70
71
|
setup.config = setup.config || {};
|
|
71
72
|
let instanceDetails;
|
|
72
73
|
if (setup.projectId) {
|
|
73
|
-
await (0, ensureApiEnabled_1.ensure)(setup.projectId,
|
|
74
|
+
await (0, ensureApiEnabled_1.ensure)(setup.projectId, api_1.rtdbManagementOrigin, "database", false);
|
|
74
75
|
logger_1.logger.info();
|
|
75
76
|
setup.instance =
|
|
76
77
|
setup.instance || (await (0, getDefaultDatabaseInstance_1.getDefaultDatabaseInstance)({ project: setup.projectId }));
|
|
@@ -4,12 +4,13 @@ exports.doSetup = void 0;
|
|
|
4
4
|
const requirePermissions_1 = require("../../../requirePermissions");
|
|
5
5
|
const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
|
|
6
6
|
const manifest = require("../../../extensions/manifest");
|
|
7
|
+
const api_1 = require("../../../api");
|
|
7
8
|
async function doSetup(setup, config, options) {
|
|
8
9
|
var _a, _b;
|
|
9
10
|
const projectId = (_b = (_a = setup === null || setup === void 0 ? void 0 : setup.rcfile) === null || _a === void 0 ? void 0 : _a.projects) === null || _b === void 0 ? void 0 : _b.default;
|
|
10
11
|
if (projectId) {
|
|
11
12
|
await (0, requirePermissions_1.requirePermissions)(Object.assign(Object.assign({}, options), { project: projectId }));
|
|
12
|
-
await Promise.all([(0, ensureApiEnabled_1.ensure)(projectId,
|
|
13
|
+
await Promise.all([(0, ensureApiEnabled_1.ensure)(projectId, api_1.extensionsOrigin, "unused", true)]);
|
|
13
14
|
}
|
|
14
15
|
return manifest.writeEmptyManifest(config, options);
|
|
15
16
|
}
|
|
@@ -8,6 +8,7 @@ const requirePermissions_1 = require("../../../requirePermissions");
|
|
|
8
8
|
const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
|
|
9
9
|
const projectConfig_1 = require("../../../functions/projectConfig");
|
|
10
10
|
const error_1 = require("../../../error");
|
|
11
|
+
const api_1 = require("../../../api");
|
|
11
12
|
const MAX_ATTEMPTS = 5;
|
|
12
13
|
async function doSetup(setup, config, options) {
|
|
13
14
|
var _a, _b;
|
|
@@ -15,8 +16,8 @@ async function doSetup(setup, config, options) {
|
|
|
15
16
|
if (projectId) {
|
|
16
17
|
await (0, requirePermissions_1.requirePermissions)(Object.assign(Object.assign({}, options), { project: projectId }));
|
|
17
18
|
await Promise.all([
|
|
18
|
-
(0, ensureApiEnabled_1.ensure)(projectId,
|
|
19
|
-
(0, ensureApiEnabled_1.ensure)(projectId,
|
|
19
|
+
(0, ensureApiEnabled_1.ensure)(projectId, api_1.functionsOrigin, "unused", true),
|
|
20
|
+
(0, ensureApiEnabled_1.ensure)(projectId, api_1.runtimeconfigOrigin, "unused", true),
|
|
20
21
|
]);
|
|
21
22
|
}
|
|
22
23
|
setup.functions = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-tools",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.4.1",
|
|
4
4
|
"description": "Command-Line Interface for Firebase",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"cross-env": "^5.1.3",
|
|
75
75
|
"cross-spawn": "^7.0.3",
|
|
76
76
|
"csv-parse": "^5.0.4",
|
|
77
|
+
"deep-equal-in-any-order": "^2.0.6",
|
|
77
78
|
"exegesis": "^4.1.0",
|
|
78
79
|
"exegesis-express": "^4.0.0",
|
|
79
80
|
"express": "^4.16.4",
|