firebase-tools 15.34.2 → 15.36.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 +2 -4
- package/lib/appcheck/debugTokens.js +293 -0
- package/lib/appcheck/localConfig.js +191 -0
- package/lib/appdistribution/options-parser-util.js +1 -1
- package/lib/apphosting/constants.js +1 -4
- package/lib/apphosting/githubConnections.js +1 -1
- package/lib/apphosting/utils.js +0 -26
- package/lib/auth.js +8 -2
- package/lib/commands/appcheck-debugtokens-create.js +60 -35
- package/lib/commands/appcheck-debugtokens-delete.js +21 -7
- package/lib/commands/appcheck-debugtokens-list.js +37 -8
- package/lib/commands/appcheck-debugtokens-prune.js +59 -0
- package/lib/commands/crashlytics-heapdumps-status.js +1 -1
- package/lib/commands/{crashlytics-onboard-web.js → crashlytics-setup.js} +5 -5
- package/lib/commands/crashlytics-sourcemap-upload.js +4 -0
- package/lib/commands/deploy.js +1 -3
- package/lib/commands/emulators-start.js +2 -2
- package/lib/commands/hosting-channel-create.js +1 -3
- package/lib/commands/hosting-channel-delete.js +1 -3
- package/lib/commands/hosting-channel-deploy.js +1 -3
- package/lib/commands/hosting-channel-list.js +1 -3
- package/lib/commands/hosting-channel-open.js +1 -3
- package/lib/commands/hosting-clone.js +3 -5
- package/lib/commands/hosting-disable.js +2 -2
- package/lib/commands/hosting-sites-create.js +1 -3
- package/lib/commands/hosting-sites-delete.js +1 -3
- package/lib/commands/hosting-sites-get.js +1 -3
- package/lib/commands/hosting-sites-list.js +1 -3
- package/lib/commands/index.js +4 -2
- package/lib/commands/run-services-get.js +19 -0
- package/lib/commands/run-services-list.js +11 -0
- package/lib/crashlytics/alerts.js +1 -0
- package/lib/crashlytics/events.js +122 -1
- package/lib/crashlytics/filters.js +12 -6
- package/lib/crashlytics/firebasetelemetry.js +5 -3
- package/lib/crashlytics/onboarding.js +8 -7
- package/lib/crashlytics/profilingManager.js +14 -34
- package/lib/crashlytics/reports.js +46 -17
- package/lib/crashlytics/sourcemap.js +19 -5
- package/lib/crashlytics/utils.js +14 -0
- package/lib/database/import.js +5 -4
- package/lib/dataconnect/dataplaneClient.js +0 -10
- package/lib/dataconnect/names.js +3 -3
- package/lib/dataconnect/schemaMigration.js +1 -1
- package/lib/deploy/apphosting/deploy.js +20 -41
- package/lib/deploy/apphosting/localBuild.js +49 -0
- package/lib/deploy/apphosting/prepare.js +12 -25
- package/lib/deploy/apphosting/release.js +1 -1
- package/lib/deploy/apphosting/util.js +27 -4
- package/lib/deploy/functions/backend.js +0 -10
- package/lib/deploy/functions/cel.js +1 -1
- package/lib/deploy/functions/containerCleaner.js +1 -142
- package/lib/deploy/functions/functionsDeployHelper.js +0 -4
- package/lib/deploy/functions/release/reporter.js +0 -26
- package/lib/deploy/functions/runtimes/discovery/index.js +4 -1
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +1 -1
- package/lib/deploy/functions/services/index.js +13 -11
- package/lib/deploy/functions/validate.js +1 -1
- package/lib/deploy/hosting/prepare.js +1 -3
- package/lib/deploy/lifecycleHooks.js +1 -1
- package/lib/deploy/run/deploy.js +26 -43
- package/lib/deploy/run/get.js +30 -0
- package/lib/deploy/run/list.js +38 -0
- package/lib/deploy/run/prereqs.js +0 -3
- package/lib/deploy/run/util.js +9 -0
- package/lib/emulator/auth/operations.js +2 -2
- package/lib/emulator/auth/server.js +4 -2
- package/lib/emulator/auth/widget_ui.js +1 -1
- package/lib/emulator/commandUtils.js +109 -24
- package/lib/emulator/databaseEmulator.js +16 -11
- package/lib/emulator/dataconnect/pgliteServer.js +31 -24
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/downloadableEmulators.js +45 -7
- package/lib/emulator/extensions/postinstall.js +6 -6
- package/lib/emulator/firestoreEmulator.js +21 -15
- package/lib/emulator/functionsEmulator.js +11 -7
- package/lib/emulator/functionsEmulatorRuntime.js +7 -2
- package/lib/emulator/hub.js +12 -8
- package/lib/emulator/shared/express.js +30 -0
- package/lib/emulator/storage/apis/firebase.js +11 -10
- package/lib/emulator/storage/apis/gcloud.js +21 -20
- package/lib/emulator/storage/files.js +1 -1
- package/lib/emulator/storage/rules/manager.js +15 -12
- package/lib/emulator/storage/rules/runtime.js +1 -0
- package/lib/emulator/storage/server.js +10 -5
- package/lib/extensions/extensionsApi.js +0 -8
- package/lib/extensions/extensionsHelper.js +3 -24
- package/lib/extensions/paramHelper.js +1 -1
- package/lib/extensions/provisioningHelper.js +1 -6
- package/lib/extensions/secretsUtils.js +0 -24
- package/lib/firestore/util.js +3 -3
- package/lib/frameworks/angular/utils.js +1 -1
- package/lib/frameworks/next/utils.js +1 -12
- package/lib/fsAsync.js +34 -20
- package/lib/functions/kits/install.js +233 -628
- package/lib/functions/kits/sources/directory.js +91 -0
- package/lib/functions/kits/sources/npm.js +324 -0
- package/lib/functions/kits/sources/types.js +12 -0
- package/lib/functionsConfig.js +0 -4
- package/lib/functionsShellCommandAction.js +1 -1
- package/lib/gcp/artifactregistry.js +0 -5
- package/lib/gcp/cloudfunctionsv2.js +0 -6
- package/lib/gcp/devConnect.js +2 -2
- package/lib/gcp/iam.js +0 -4
- package/lib/gcp/pubsub.js +0 -14
- package/lib/gcp/storage.js +2 -1
- package/lib/hosting/api.js +79 -0
- package/lib/hosting/proxy.js +4 -1
- package/lib/init/features/hosting/github.js +6 -4
- package/lib/init/features/hosting/index.js +4 -0
- package/lib/init/features/run.js +3 -7
- package/lib/mcp/apps/init/mcp-app.js +4 -1
- package/lib/mcp/index.js +8 -2
- package/lib/mcp/prompts/apptesting/run_test.js +3 -3
- package/lib/mcp/prompts/core/deploy.js +3 -3
- package/lib/mcp/resources/guides/crashlytics_reports.js +33 -71
- package/lib/mcp/resources/guides/init_ai.js +10 -10
- package/lib/mcp/tools/crashlytics/events.js +18 -93
- package/lib/mcp/tools/crashlytics/index.js +2 -0
- package/lib/mcp/tools/crashlytics/reports.js +26 -31
- package/lib/mcp/tools/crashlytics/setup.js +392 -0
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +4 -10
- package/package.json +1 -2
- package/lib/deploy/hosting/args.js +0 -2
package/lib/emulator/hub.js
CHANGED
|
@@ -10,6 +10,7 @@ const types_1 = require("./types");
|
|
|
10
10
|
const hubExport_1 = require("./hubExport");
|
|
11
11
|
const registry_1 = require("./registry");
|
|
12
12
|
const ExpressBasedEmulator_1 = require("./ExpressBasedEmulator");
|
|
13
|
+
const express_1 = require("./shared/express");
|
|
13
14
|
const pkg = require("../../package.json");
|
|
14
15
|
class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
15
16
|
static readLocatorFile(projectId) {
|
|
@@ -63,11 +64,12 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
63
64
|
app.get(EmulatorHub.PATH_EMULATORS, (req, res) => {
|
|
64
65
|
res.json(this.getRunningEmulatorsMapping());
|
|
65
66
|
});
|
|
66
|
-
app.post(EmulatorHub.PATH_EXPORT, async (req, res) => {
|
|
67
|
+
app.post(EmulatorHub.PATH_EXPORT, (0, express_1.asyncHandler)(async (req, res) => {
|
|
67
68
|
if (req.headers.origin) {
|
|
68
69
|
res.status(403).json({
|
|
69
70
|
message: `Export cannot be triggered by external callers.`,
|
|
70
71
|
});
|
|
72
|
+
return;
|
|
71
73
|
}
|
|
72
74
|
const path = req.body.path;
|
|
73
75
|
const initiatedBy = req.body.initiatedBy || "unknown";
|
|
@@ -91,8 +93,8 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
91
93
|
message: errorString,
|
|
92
94
|
});
|
|
93
95
|
}
|
|
94
|
-
});
|
|
95
|
-
app.put(EmulatorHub.PATH_DISABLE_FUNCTIONS, async (req, res) => {
|
|
96
|
+
}));
|
|
97
|
+
app.put(EmulatorHub.PATH_DISABLE_FUNCTIONS, (0, express_1.asyncHandler)(async (req, res) => {
|
|
96
98
|
utils.logLabeledBullet("emulators", `Disabling Cloud Functions triggers, non-HTTP functions will not execute.`);
|
|
97
99
|
const instance = registry_1.EmulatorRegistry.get(types_1.Emulators.FUNCTIONS);
|
|
98
100
|
if (!instance) {
|
|
@@ -102,8 +104,8 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
102
104
|
const emu = instance;
|
|
103
105
|
await emu.disableBackgroundTriggers();
|
|
104
106
|
res.status(200).json({ enabled: false });
|
|
105
|
-
});
|
|
106
|
-
app.put(EmulatorHub.PATH_ENABLE_FUNCTIONS, async (req, res) => {
|
|
107
|
+
}));
|
|
108
|
+
app.put(EmulatorHub.PATH_ENABLE_FUNCTIONS, (0, express_1.asyncHandler)(async (req, res) => {
|
|
107
109
|
utils.logLabeledBullet("emulators", `Enabling Cloud Functions triggers, non-HTTP functions will execute.`);
|
|
108
110
|
const instance = registry_1.EmulatorRegistry.get(types_1.Emulators.FUNCTIONS);
|
|
109
111
|
if (!instance) {
|
|
@@ -113,12 +115,13 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
113
115
|
const emu = instance;
|
|
114
116
|
await emu.reloadTriggers();
|
|
115
117
|
res.status(200).json({ enabled: true });
|
|
116
|
-
});
|
|
117
|
-
app.post(EmulatorHub.PATH_CLEAR_DATA_CONNECT, async (req, res) => {
|
|
118
|
+
}));
|
|
119
|
+
app.post(EmulatorHub.PATH_CLEAR_DATA_CONNECT, (0, express_1.asyncHandler)(async (req, res) => {
|
|
118
120
|
if (req.headers.origin) {
|
|
119
121
|
res.status(403).json({
|
|
120
122
|
message: `Clear SQL Connect cannot be triggered by external callers.`,
|
|
121
123
|
});
|
|
124
|
+
return;
|
|
122
125
|
}
|
|
123
126
|
utils.logLabeledBullet("emulators", `Clearing data from SQL Connect data sources.`);
|
|
124
127
|
const instance = registry_1.EmulatorRegistry.get(types_1.Emulators.DATACONNECT);
|
|
@@ -128,7 +131,8 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
128
131
|
}
|
|
129
132
|
await instance.clearData();
|
|
130
133
|
res.status(200).json({ success: true });
|
|
131
|
-
});
|
|
134
|
+
}));
|
|
135
|
+
app.use((0, express_1.jsonErrorHandler)(types_1.Emulators.HUB));
|
|
132
136
|
return app;
|
|
133
137
|
}
|
|
134
138
|
async stop() {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asyncHandler = asyncHandler;
|
|
4
|
+
exports.jsonErrorHandler = jsonErrorHandler;
|
|
5
|
+
const error_1 = require("../../error");
|
|
6
|
+
const emulatorLogger_1 = require("../emulatorLogger");
|
|
7
|
+
function asyncHandler(fn) {
|
|
8
|
+
return (req, res, next) => {
|
|
9
|
+
void fn(req, res, next).catch((err) => {
|
|
10
|
+
next(err ?? new Error("Async route handler rejected without a reason"));
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function jsonErrorHandler(emulator) {
|
|
15
|
+
return (err, req, res, next) => {
|
|
16
|
+
if (res.headersSent) {
|
|
17
|
+
next(err);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const e = err;
|
|
21
|
+
const status = e?.status ?? e?.statusCode;
|
|
22
|
+
const code = typeof status === "number" && status >= 400 && status < 600 ? status : 500;
|
|
23
|
+
if (code >= 500) {
|
|
24
|
+
emulatorLogger_1.EmulatorLogger.forEmulator(emulator).log("WARN", `${req.method} ${req.path} failed: ${(0, error_1.getErrStack)(err)}`);
|
|
25
|
+
}
|
|
26
|
+
res
|
|
27
|
+
.status(code)
|
|
28
|
+
.json({ error: { code, message: code < 500 ? (0, error_1.getErrMsg)(err) : "Internal error" } });
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -13,6 +13,7 @@ const multipart_1 = require("../multipart");
|
|
|
13
13
|
const errors_1 = require("../errors");
|
|
14
14
|
const upload_1 = require("../upload");
|
|
15
15
|
const request_1 = require("../../shared/request");
|
|
16
|
+
const express_2 = require("../../shared/express");
|
|
16
17
|
function createFirebaseEndpoints(emulator) {
|
|
17
18
|
const firebaseStorageAPI = (0, express_1.Router)();
|
|
18
19
|
const { storageLayer, uploadService } = emulator;
|
|
@@ -86,7 +87,7 @@ function createFirebaseEndpoints(emulator) {
|
|
|
86
87
|
}
|
|
87
88
|
next();
|
|
88
89
|
});
|
|
89
|
-
firebaseStorageAPI.get("/b/:bucketId/o/:objectId", async (req, res) => {
|
|
90
|
+
firebaseStorageAPI.get("/b/:bucketId/o/:objectId", (0, express_2.asyncHandler)(async (req, res) => {
|
|
90
91
|
let metadata;
|
|
91
92
|
let data;
|
|
92
93
|
try {
|
|
@@ -118,8 +119,8 @@ function createFirebaseEndpoints(emulator) {
|
|
|
118
119
|
return (0, shared_1.sendFileBytes)(metadata, data, req, res);
|
|
119
120
|
}
|
|
120
121
|
return res.json(new metadata_1.OutgoingFirebaseMetadata(metadata));
|
|
121
|
-
});
|
|
122
|
-
firebaseStorageAPI.get("/b/:bucketId/o", async (req, res) => {
|
|
122
|
+
}));
|
|
123
|
+
firebaseStorageAPI.get("/b/:bucketId/o", (0, express_2.asyncHandler)(async (req, res) => {
|
|
123
124
|
const maxResults = req.query.maxResults?.toString();
|
|
124
125
|
let listResponse;
|
|
125
126
|
let prefix = "";
|
|
@@ -164,7 +165,7 @@ function createFirebaseEndpoints(emulator) {
|
|
|
164
165
|
return { name: item.name, bucket: item.bucket };
|
|
165
166
|
}),
|
|
166
167
|
});
|
|
167
|
-
});
|
|
168
|
+
}));
|
|
168
169
|
const handleUpload = async (req, res) => {
|
|
169
170
|
const bucketId = req.params.bucketId;
|
|
170
171
|
const objectId = req.params.objectId
|
|
@@ -440,17 +441,17 @@ function createFirebaseEndpoints(emulator) {
|
|
|
440
441
|
setObjectHeaders(res, metadata);
|
|
441
442
|
return res.json(new metadata_1.OutgoingFirebaseMetadata(metadata));
|
|
442
443
|
};
|
|
443
|
-
firebaseStorageAPI.patch("/b/:bucketId/o/:objectId", (0, express_1.json)({ limit: "130mb" }), handleMetadataUpdate);
|
|
444
|
-
firebaseStorageAPI.put("/b/:bucketId/o/:objectId?", firebasePostUploadMiddleware, async (req, res) => {
|
|
444
|
+
firebaseStorageAPI.patch("/b/:bucketId/o/:objectId", (0, express_1.json)({ limit: "130mb" }), (0, express_2.asyncHandler)(handleMetadataUpdate));
|
|
445
|
+
firebaseStorageAPI.put("/b/:bucketId/o/:objectId?", firebasePostUploadMiddleware, (0, express_2.asyncHandler)(async (req, res) => {
|
|
445
446
|
switch (req.header("x-http-method-override")?.toLowerCase()) {
|
|
446
447
|
case "patch":
|
|
447
448
|
return handleMetadataUpdate(req, res);
|
|
448
449
|
default:
|
|
449
450
|
return handleObjectPostRequest(req, res);
|
|
450
451
|
}
|
|
451
|
-
});
|
|
452
|
-
firebaseStorageAPI.post("/b/:bucketId/o/:objectId?", firebasePostUploadMiddleware, handleObjectPostRequest);
|
|
453
|
-
firebaseStorageAPI.delete("/b/:bucketId/o/:objectId", async (req, res) => {
|
|
452
|
+
}));
|
|
453
|
+
firebaseStorageAPI.post("/b/:bucketId/o/:objectId?", firebasePostUploadMiddleware, (0, express_2.asyncHandler)(handleObjectPostRequest));
|
|
454
|
+
firebaseStorageAPI.delete("/b/:bucketId/o/:objectId", (0, express_2.asyncHandler)(async (req, res) => {
|
|
454
455
|
try {
|
|
455
456
|
await storageLayer.deleteObject({
|
|
456
457
|
bucketId: req.params.bucketId,
|
|
@@ -473,7 +474,7 @@ function createFirebaseEndpoints(emulator) {
|
|
|
473
474
|
throw err;
|
|
474
475
|
}
|
|
475
476
|
res.sendStatus(204);
|
|
476
|
-
});
|
|
477
|
+
}));
|
|
477
478
|
firebaseStorageAPI.get("/", (req, res) => {
|
|
478
479
|
res.json({ emulator: "storage" });
|
|
479
480
|
});
|
|
@@ -12,6 +12,7 @@ const multipart_1 = require("../multipart");
|
|
|
12
12
|
const upload_1 = require("../upload");
|
|
13
13
|
const errors_1 = require("../errors");
|
|
14
14
|
const request_1 = require("../../shared/request");
|
|
15
|
+
const express_2 = require("../../shared/express");
|
|
15
16
|
function createCloudEndpoints(emulator) {
|
|
16
17
|
const gcloudStorageAPI = (0, express_1.Router)();
|
|
17
18
|
const { adminStorageLayer, uploadService } = emulator;
|
|
@@ -66,17 +67,17 @@ function createCloudEndpoints(emulator) {
|
|
|
66
67
|
adminStorageLayer.createBucket(req.params[0]);
|
|
67
68
|
next();
|
|
68
69
|
});
|
|
69
|
-
gcloudStorageAPI.get("/b", async (req, res) => {
|
|
70
|
+
gcloudStorageAPI.get("/b", (0, express_2.asyncHandler)(async (req, res) => {
|
|
70
71
|
res.json({
|
|
71
72
|
kind: "storage#buckets",
|
|
72
73
|
items: await adminStorageLayer.listBuckets(),
|
|
73
74
|
});
|
|
74
|
-
});
|
|
75
|
+
}));
|
|
75
76
|
gcloudStorageAPI.get([
|
|
76
77
|
"/b/:bucketId/o/:objectId",
|
|
77
78
|
"/download/storage/v1/b/:bucketId/o/:objectId",
|
|
78
79
|
"/storage/v1/b/:bucketId/o/:objectId",
|
|
79
|
-
], async (req, res) => {
|
|
80
|
+
], (0, express_2.asyncHandler)(async (req, res) => {
|
|
80
81
|
let getObjectResponse;
|
|
81
82
|
try {
|
|
82
83
|
getObjectResponse = await adminStorageLayer.getObject({
|
|
@@ -97,8 +98,8 @@ function createCloudEndpoints(emulator) {
|
|
|
97
98
|
return (0, shared_1.sendFileBytes)(getObjectResponse.metadata, getObjectResponse.data, req, res);
|
|
98
99
|
}
|
|
99
100
|
return res.json(new metadata_1.CloudStorageObjectMetadata(getObjectResponse.metadata));
|
|
100
|
-
});
|
|
101
|
-
gcloudStorageAPI.patch("/b/:bucketId/o/:objectId", (0, express_1.json)({ limit: "130mb" }), async (req, res) => {
|
|
101
|
+
}));
|
|
102
|
+
gcloudStorageAPI.patch("/b/:bucketId/o/:objectId", (0, express_1.json)({ limit: "130mb" }), (0, express_2.asyncHandler)(async (req, res) => {
|
|
102
103
|
let updatedMetadata;
|
|
103
104
|
try {
|
|
104
105
|
updatedMetadata = await adminStorageLayer.updateObjectMetadata({
|
|
@@ -117,8 +118,8 @@ function createCloudEndpoints(emulator) {
|
|
|
117
118
|
throw err;
|
|
118
119
|
}
|
|
119
120
|
return res.json(new metadata_1.CloudStorageObjectMetadata(updatedMetadata));
|
|
120
|
-
});
|
|
121
|
-
gcloudStorageAPI.get(["/b/:bucketId/o", "/storage/v1/b/:bucketId/o"], async (req, res) => {
|
|
121
|
+
}));
|
|
122
|
+
gcloudStorageAPI.get(["/b/:bucketId/o", "/storage/v1/b/:bucketId/o"], (0, express_2.asyncHandler)(async (req, res) => {
|
|
122
123
|
let listResponse;
|
|
123
124
|
try {
|
|
124
125
|
listResponse = await adminStorageLayer.listObjects({
|
|
@@ -142,8 +143,8 @@ function createCloudEndpoints(emulator) {
|
|
|
142
143
|
prefixes: listResponse.prefixes,
|
|
143
144
|
items: listResponse.items?.map((item) => new metadata_1.CloudStorageObjectMetadata(item)),
|
|
144
145
|
});
|
|
145
|
-
});
|
|
146
|
-
gcloudStorageAPI.delete(["/b/:bucketId/o/:objectId", "/storage/v1/b/:bucketId/o/:objectId"], async (req, res) => {
|
|
146
|
+
}));
|
|
147
|
+
gcloudStorageAPI.delete(["/b/:bucketId/o/:objectId", "/storage/v1/b/:bucketId/o/:objectId"], (0, express_2.asyncHandler)(async (req, res) => {
|
|
147
148
|
try {
|
|
148
149
|
await adminStorageLayer.deleteObject({
|
|
149
150
|
bucketId: req.params.bucketId,
|
|
@@ -160,8 +161,8 @@ function createCloudEndpoints(emulator) {
|
|
|
160
161
|
throw err;
|
|
161
162
|
}
|
|
162
163
|
return res.sendStatus(204);
|
|
163
|
-
});
|
|
164
|
-
gcloudStorageAPI.put("/upload/storage/v1/b/:bucketId/o", bodyParser.raw({ type: "*/*", limit: "130mb" }), async (req, res) => {
|
|
164
|
+
}));
|
|
165
|
+
gcloudStorageAPI.put("/upload/storage/v1/b/:bucketId/o", bodyParser.raw({ type: "*/*", limit: "130mb" }), (0, express_2.asyncHandler)(async (req, res) => {
|
|
165
166
|
if (!req.query.upload_id) {
|
|
166
167
|
res.sendStatus(400);
|
|
167
168
|
return;
|
|
@@ -192,8 +193,8 @@ function createCloudEndpoints(emulator) {
|
|
|
192
193
|
throw err;
|
|
193
194
|
}
|
|
194
195
|
return res.json(new metadata_1.CloudStorageObjectMetadata(metadata));
|
|
195
|
-
});
|
|
196
|
-
gcloudStorageAPI.post("/b/:bucketId/o/:objectId/acl", (0, express_1.json)({ limit: "130mb" }), async (req, res) => {
|
|
196
|
+
}));
|
|
197
|
+
gcloudStorageAPI.post("/b/:bucketId/o/:objectId/acl", (0, express_1.json)({ limit: "130mb" }), (0, express_2.asyncHandler)(async (req, res) => {
|
|
197
198
|
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.STORAGE).log("WARN_ONCE", "Cloud Storage ACLs are not supported in the Storage Emulator. All related methods will succeed, but have no effect.");
|
|
198
199
|
let getObjectResponse;
|
|
199
200
|
try {
|
|
@@ -226,8 +227,8 @@ function createCloudEndpoints(emulator) {
|
|
|
226
227
|
etag: "someEtag",
|
|
227
228
|
generation: metadata.generation.toString(),
|
|
228
229
|
});
|
|
229
|
-
});
|
|
230
|
-
gcloudStorageAPI.post("/upload/storage/v1/b/:bucketId/o", postUploadMiddleware, async (req, res) => {
|
|
230
|
+
}));
|
|
231
|
+
gcloudStorageAPI.post("/upload/storage/v1/b/:bucketId/o", postUploadMiddleware, (0, express_2.asyncHandler)(async (req, res) => {
|
|
231
232
|
const uploadType = req.query.uploadType || req.header("X-Goog-Upload-Protocol");
|
|
232
233
|
if (uploadType === "resumable") {
|
|
233
234
|
const name = getIncomingFileNameFromRequest(req.query, req.body);
|
|
@@ -310,8 +311,8 @@ function createCloudEndpoints(emulator) {
|
|
|
310
311
|
authorization: req.header("authorization"),
|
|
311
312
|
});
|
|
312
313
|
return await finalizeOneShotUpload(upload);
|
|
313
|
-
});
|
|
314
|
-
gcloudStorageAPI.get("/:bucketId/:objectId(**)", async (req, res) => {
|
|
314
|
+
}));
|
|
315
|
+
gcloudStorageAPI.get("/:bucketId/:objectId(**)", (0, express_2.asyncHandler)(async (req, res) => {
|
|
315
316
|
let getObjectResponse;
|
|
316
317
|
try {
|
|
317
318
|
getObjectResponse = await adminStorageLayer.getObject({
|
|
@@ -329,11 +330,11 @@ function createCloudEndpoints(emulator) {
|
|
|
329
330
|
throw err;
|
|
330
331
|
}
|
|
331
332
|
return (0, shared_1.sendFileBytes)(getObjectResponse.metadata, getObjectResponse.data, req, res);
|
|
332
|
-
});
|
|
333
|
+
}));
|
|
333
334
|
gcloudStorageAPI.post("/:bucketId", (req, res, next) => {
|
|
334
335
|
adminStorageLayer.createBucket(req.params.bucketId);
|
|
335
336
|
next();
|
|
336
|
-
}, async (req, res) => {
|
|
337
|
+
}, (0, express_2.asyncHandler)(async (req, res) => {
|
|
337
338
|
const contentTypeHeader = req.header("content-type");
|
|
338
339
|
if (!contentTypeHeader?.includes("multipart/form-data")) {
|
|
339
340
|
return res.status(400).send("Content-Type must be multipart/form-data");
|
|
@@ -390,7 +391,7 @@ function createCloudEndpoints(emulator) {
|
|
|
390
391
|
}
|
|
391
392
|
throw err;
|
|
392
393
|
}
|
|
393
|
-
});
|
|
394
|
+
}));
|
|
394
395
|
gcloudStorageAPI.post("/b/:bucketId/o/:objectId/:method(rewriteTo|copyTo)/b/:destBucketId/o/:destObjectId", (0, express_1.json)({ limit: "130mb" }), (req, res, next) => {
|
|
395
396
|
if (req.params.method === "rewriteTo" && req.query.rewriteToken) {
|
|
396
397
|
return next();
|
|
@@ -382,6 +382,6 @@ class StorageLayer {
|
|
|
382
382
|
}
|
|
383
383
|
exports.StorageLayer = StorageLayer;
|
|
384
384
|
function getPathSep(decodedPath) {
|
|
385
|
-
const firstSepIndex = decodedPath.search(/[
|
|
385
|
+
const firstSepIndex = decodedPath.search(/[/|\\\\]/g);
|
|
386
386
|
return decodedPath[firstSepIndex];
|
|
387
387
|
}
|
|
@@ -32,6 +32,19 @@ class DefaultStorageRulesManager {
|
|
|
32
32
|
await this._watcher.close();
|
|
33
33
|
}
|
|
34
34
|
updateWatcher(rulesFile) {
|
|
35
|
+
const handleFileChange = async () => {
|
|
36
|
+
await new Promise((res) => setTimeout(res, WATCHER_CHANGE_DELAY_MS));
|
|
37
|
+
try {
|
|
38
|
+
const content = (0, fsutils_1.readFile)(rulesFile);
|
|
39
|
+
this._rules.content = content;
|
|
40
|
+
this._logger.logLabeled("BULLET", "storage", "Change detected, updating rules for Cloud Storage...");
|
|
41
|
+
await this.loadRuleset();
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
45
|
+
this._logger.logLabeled("DEBUG", "storage", `A rule file change was detected, but there was an error reading it: ${message}`);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
35
48
|
return new Promise((resolve) => {
|
|
36
49
|
const timer = setTimeout(resolve, WATCHER_READY_TIMEOUT_MS);
|
|
37
50
|
timer.unref?.();
|
|
@@ -47,18 +60,8 @@ class DefaultStorageRulesManager {
|
|
|
47
60
|
this._logger.logLabeled("DEBUG", "storage", `A storage rules file watcher error occurred: ${message}`);
|
|
48
61
|
resolve();
|
|
49
62
|
})
|
|
50
|
-
.on("change",
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
const content = (0, fsutils_1.readFile)(rulesFile);
|
|
54
|
-
this._rules.content = content;
|
|
55
|
-
this._logger.logLabeled("BULLET", "storage", "Change detected, updating rules for Cloud Storage...");
|
|
56
|
-
await this.loadRuleset();
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
60
|
-
this._logger.logLabeled("DEBUG", "storage", `A rule file change was detected, but there was an error reading it: ${message}`);
|
|
61
|
-
}
|
|
63
|
+
.on("change", () => {
|
|
64
|
+
void handleFileChange();
|
|
62
65
|
});
|
|
63
66
|
});
|
|
64
67
|
}
|
|
@@ -93,6 +93,7 @@ class StorageRulesRuntime {
|
|
|
93
93
|
const command = (0, downloadableEmulators_1._getCommand)(types_2.Emulators.STORAGE, {});
|
|
94
94
|
this._childprocess = (0, cross_spawn_1.spawn)(command.binary, command.args, {
|
|
95
95
|
stdio: ["pipe", "pipe", "pipe"],
|
|
96
|
+
windowsHide: true,
|
|
96
97
|
});
|
|
97
98
|
this._childprocess.on("exit", () => {
|
|
98
99
|
this._alive = false;
|
|
@@ -9,6 +9,7 @@ const bodyParser = require("body-parser");
|
|
|
9
9
|
const gcloud_1 = require("./apis/gcloud");
|
|
10
10
|
const firebase_1 = require("./apis/firebase");
|
|
11
11
|
const errors_1 = require("../auth/errors");
|
|
12
|
+
const express_1 = require("../shared/express");
|
|
12
13
|
function createApp(defaultProjectId, emulator) {
|
|
13
14
|
const { storageLayer } = emulator;
|
|
14
15
|
const app = express();
|
|
@@ -38,7 +39,7 @@ function createApp(defaultProjectId, emulator) {
|
|
|
38
39
|
}));
|
|
39
40
|
app.use(bodyParser.raw({ limit: "130mb", type: "application/x-www-form-urlencoded" }));
|
|
40
41
|
app.use(bodyParser.raw({ limit: "130mb", type: "multipart/related" }));
|
|
41
|
-
app.post("/internal/export", express.json({ limit: "130mb" }), async (req, res) => {
|
|
42
|
+
app.post("/internal/export", express.json({ limit: "130mb" }), (0, express_1.asyncHandler)(async (req, res) => {
|
|
42
43
|
const initiatedBy = req.body.initiatedBy || "unknown";
|
|
43
44
|
const path = req.body.path;
|
|
44
45
|
if (!path) {
|
|
@@ -47,8 +48,8 @@ function createApp(defaultProjectId, emulator) {
|
|
|
47
48
|
}
|
|
48
49
|
await storageLayer.export(path, { initiatedBy });
|
|
49
50
|
res.sendStatus(200);
|
|
50
|
-
});
|
|
51
|
-
app.put("/internal/setRules", express.json({ limit: "130mb" }), async (req, res) => {
|
|
51
|
+
}));
|
|
52
|
+
app.put("/internal/setRules", express.json({ limit: "130mb" }), (0, express_1.asyncHandler)(async (req, res) => {
|
|
52
53
|
const rulesRaw = req.body.rules;
|
|
53
54
|
if (!(rulesRaw && Array.isArray(rulesRaw.files) && rulesRaw.files.length > 0)) {
|
|
54
55
|
res.status(400).json({
|
|
@@ -70,7 +71,10 @@ function createApp(defaultProjectId, emulator) {
|
|
|
70
71
|
if (!isRulesFile(file) || !file.resource) {
|
|
71
72
|
throw new errors_1.InvalidArgumentError("Each member of 'rules.files' array must contain 'name', 'content', and 'resource'");
|
|
72
73
|
}
|
|
73
|
-
rules.push({
|
|
74
|
+
rules.push({
|
|
75
|
+
resource: file.resource,
|
|
76
|
+
rules: { name: file.name, content: file.content },
|
|
77
|
+
});
|
|
74
78
|
}
|
|
75
79
|
return rules;
|
|
76
80
|
}
|
|
@@ -95,13 +99,14 @@ function createApp(defaultProjectId, emulator) {
|
|
|
95
99
|
res.status(200).json({
|
|
96
100
|
message: "Rules updated successfully",
|
|
97
101
|
});
|
|
98
|
-
});
|
|
102
|
+
}));
|
|
99
103
|
app.post("/internal/reset", (req, res) => {
|
|
100
104
|
emulator.reset();
|
|
101
105
|
res.sendStatus(200);
|
|
102
106
|
});
|
|
103
107
|
app.use("/v0", (0, firebase_1.createFirebaseEndpoints)(emulator));
|
|
104
108
|
app.use("/", (0, gcloud_1.createCloudEndpoints)(emulator));
|
|
109
|
+
app.use((0, express_1.jsonErrorHandler)(types_1.Emulators.STORAGE));
|
|
105
110
|
return Promise.resolve(app);
|
|
106
111
|
}
|
|
107
112
|
function isRulesFile(file) {
|
|
@@ -9,7 +9,6 @@ exports.updateInstance = updateInstance;
|
|
|
9
9
|
exports.updateInstanceFromRegistry = updateInstanceFromRegistry;
|
|
10
10
|
exports.populateSpec = populateSpec;
|
|
11
11
|
exports.createSource = createSource;
|
|
12
|
-
exports.getSource = getSource;
|
|
13
12
|
exports.getExtensionVersion = getExtensionVersion;
|
|
14
13
|
exports.listExtensions = listExtensions;
|
|
15
14
|
exports.listExtensionVersions = listExtensionVersions;
|
|
@@ -263,13 +262,6 @@ async function createSource(projectId, packageUri, extensionRoot) {
|
|
|
263
262
|
}
|
|
264
263
|
return pollRes;
|
|
265
264
|
}
|
|
266
|
-
async function getSource(sourceName) {
|
|
267
|
-
const res = await extensionsApiClient.get(`/${sourceName}`);
|
|
268
|
-
if (res.body.spec) {
|
|
269
|
-
populateSpec(res.body.spec);
|
|
270
|
-
}
|
|
271
|
-
return res.body;
|
|
272
|
-
}
|
|
273
265
|
async function getExtensionVersion(extensionVersionRef) {
|
|
274
266
|
const ref = refs.parse(extensionVersionRef);
|
|
275
267
|
if (!ref.version) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resourceTypeToNiceName = exports.AUTOPOPULATED_PARAM_PLACEHOLDERS = exports.EXTENSIONS_BUCKET_NAME = exports.
|
|
3
|
+
exports.resourceTypeToNiceName = exports.AUTOPOPULATED_PARAM_PLACEHOLDERS = exports.EXTENSIONS_BUCKET_NAME = exports.logPrefix = exports.SourceOrigin = exports.SpecParamType = void 0;
|
|
4
4
|
exports.getDBInstanceFromURL = getDBInstanceFromURL;
|
|
5
5
|
exports.getFirebaseProjectParams = getFirebaseProjectParams;
|
|
6
6
|
exports.substituteParams = substituteParams;
|
|
@@ -10,7 +10,6 @@ exports.validateSpec = validateSpec;
|
|
|
10
10
|
exports.promptForValidInstanceId = promptForValidInstanceId;
|
|
11
11
|
exports.promptForValidRepoURI = promptForValidRepoURI;
|
|
12
12
|
exports.promptForExtensionRoot = promptForExtensionRoot;
|
|
13
|
-
exports.checkExtensionsApiEnabled = checkExtensionsApiEnabled;
|
|
14
13
|
exports.ensureExtensionsApiEnabled = ensureExtensionsApiEnabled;
|
|
15
14
|
exports.ensureExtensionsPublisherApiEnabled = ensureExtensionsPublisherApiEnabled;
|
|
16
15
|
exports.getNextVersionByStage = getNextVersionByStage;
|
|
@@ -21,7 +20,6 @@ exports.getMissingPublisherError = getMissingPublisherError;
|
|
|
21
20
|
exports.createSourceFromLocation = createSourceFromLocation;
|
|
22
21
|
exports.getPublisherProjectFromName = getPublisherProjectFromName;
|
|
23
22
|
exports.displayReleaseNotes = displayReleaseNotes;
|
|
24
|
-
exports.promptForRepeatInstance = promptForRepeatInstance;
|
|
25
23
|
exports.isUrlPath = isUrlPath;
|
|
26
24
|
exports.isLocalPath = isLocalPath;
|
|
27
25
|
exports.isLocalOrURLPath = isLocalOrURLPath;
|
|
@@ -77,7 +75,6 @@ var SourceOrigin;
|
|
|
77
75
|
})(SourceOrigin || (exports.SourceOrigin = SourceOrigin = {}));
|
|
78
76
|
exports.logPrefix = "extensions";
|
|
79
77
|
const VALID_LICENSES = ["apache-2.0"];
|
|
80
|
-
exports.URL_REGEX = /^https:/;
|
|
81
78
|
exports.EXTENSIONS_BUCKET_NAME = (0, utils_1.envOverride)("FIREBASE_EXTENSIONS_UPLOAD_BUCKET", "firebase-ext-eap-uploads");
|
|
82
79
|
exports.AUTOPOPULATED_PARAM_PLACEHOLDERS = {
|
|
83
80
|
PROJECT_ID: "project-id",
|
|
@@ -89,7 +86,7 @@ exports.AUTOPOPULATED_PARAM_PLACEHOLDERS = {
|
|
|
89
86
|
exports.resourceTypeToNiceName = {
|
|
90
87
|
"firebaseextensions.v1beta.function": "Cloud Function",
|
|
91
88
|
};
|
|
92
|
-
const repoRegex = new RegExp(`^https
|
|
89
|
+
const repoRegex = new RegExp(`^https://github.com/[^/]+/[^/]+$`);
|
|
93
90
|
const stageOptions = ["rc", "alpha", "beta", "stable"];
|
|
94
91
|
function getDBInstanceFromURL(databaseUrl = "") {
|
|
95
92
|
const instanceRegex = new RegExp("(?:https://)(.*)(?:.firebaseio.com)");
|
|
@@ -271,7 +268,7 @@ function validateSpec(spec) {
|
|
|
271
268
|
async function promptForValidInstanceId(instanceId) {
|
|
272
269
|
let instanceIdIsValid = false;
|
|
273
270
|
let newInstanceId = "";
|
|
274
|
-
const instanceIdRegex = /^[a-z][a-z\d
|
|
271
|
+
const instanceIdRegex = /^[a-z][a-z\d-]*[a-z\d]$/;
|
|
275
272
|
while (!instanceIdIsValid) {
|
|
276
273
|
newInstanceId = await (0, prompt_1.input)({
|
|
277
274
|
default: instanceId,
|
|
@@ -348,13 +345,6 @@ async function promptForReleaseStage(args) {
|
|
|
348
345
|
}
|
|
349
346
|
return stage;
|
|
350
347
|
}
|
|
351
|
-
async function checkExtensionsApiEnabled(options) {
|
|
352
|
-
const projectId = (0, projectUtils_1.getProjectId)(options);
|
|
353
|
-
if (!projectId) {
|
|
354
|
-
return false;
|
|
355
|
-
}
|
|
356
|
-
return await (0, ensureApiEnabled_1.check)(projectId, (0, api_1.extensionsOrigin)(), "extensions", options.markdown);
|
|
357
|
-
}
|
|
358
348
|
async function ensureExtensionsApiEnabled(options) {
|
|
359
349
|
const projectId = (0, projectUtils_1.getProjectId)(options);
|
|
360
350
|
if (!projectId) {
|
|
@@ -759,17 +749,6 @@ function displayReleaseNotes(args) {
|
|
|
759
749
|
`Once an extension version is uploaded, it becomes installable by other users and cannot be changed. If you wish to make changes after uploading, you will need to upload a new version.\n`;
|
|
760
750
|
logger_1.logger.info(message);
|
|
761
751
|
}
|
|
762
|
-
async function promptForRepeatInstance(projectName, extensionName) {
|
|
763
|
-
const message = `An extension with the ID '${clc.bold(extensionName)}' already exists in the project '${clc.bold(projectName)}'. What would you like to do?`;
|
|
764
|
-
return await (0, prompt_1.select)({
|
|
765
|
-
message,
|
|
766
|
-
choices: [
|
|
767
|
-
{ name: "Update or reconfigure the existing instance", value: "updateExisting" },
|
|
768
|
-
{ name: "Install a new instance with a different ID", value: "installNew" },
|
|
769
|
-
{ name: "Cancel extension installation", value: "cancel" },
|
|
770
|
-
],
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
752
|
function isUrlPath(extInstallPath) {
|
|
774
753
|
return extInstallPath.startsWith("https:");
|
|
775
754
|
}
|
|
@@ -181,7 +181,7 @@ function readEnvFile(envPath) {
|
|
|
181
181
|
return result.envs;
|
|
182
182
|
}
|
|
183
183
|
function isSystemParam(paramName) {
|
|
184
|
-
const regex = /^firebaseextensions\.[a-zA-Z0-9
|
|
184
|
+
const regex = /^firebaseextensions\.[a-zA-Z0-9.]*\//;
|
|
185
185
|
return regex.test(paramName);
|
|
186
186
|
}
|
|
187
187
|
function partitionParams(params) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DeferredProduct = void 0;
|
|
4
|
-
exports.checkProductsProvisioned = checkProductsProvisioned;
|
|
5
4
|
exports.bulkCheckProductsProvisioned = bulkCheckProductsProvisioned;
|
|
6
5
|
exports.getUsedProducts = getUsedProducts;
|
|
7
6
|
const marked_1 = require("marked");
|
|
@@ -16,10 +15,6 @@ var DeferredProduct;
|
|
|
16
15
|
DeferredProduct[DeferredProduct["STORAGE"] = 0] = "STORAGE";
|
|
17
16
|
DeferredProduct[DeferredProduct["AUTH"] = 1] = "AUTH";
|
|
18
17
|
})(DeferredProduct || (exports.DeferredProduct = DeferredProduct = {}));
|
|
19
|
-
async function checkProductsProvisioned(projectId, spec) {
|
|
20
|
-
const usedProducts = getUsedProducts(spec);
|
|
21
|
-
await checkProducts(projectId, usedProducts);
|
|
22
|
-
}
|
|
23
18
|
async function bulkCheckProductsProvisioned(projectId, instanceSpecs) {
|
|
24
19
|
const usedProducts = await Promise.all(instanceSpecs.map(async (i) => {
|
|
25
20
|
const extensionSpec = await (0, planner_1.getExtensionSpec)(i);
|
|
@@ -86,7 +81,7 @@ function getUsedProducts(spec) {
|
|
|
86
81
|
return usedProducts;
|
|
87
82
|
}
|
|
88
83
|
function getTriggerType(propertiesYaml) {
|
|
89
|
-
return propertiesYaml?.match(/eventType
|
|
84
|
+
return propertiesYaml?.match(/eventType: ([\S]+)/)?.[1];
|
|
90
85
|
}
|
|
91
86
|
async function isStorageProvisioned(projectId) {
|
|
92
87
|
const client = new apiv2_1.Client({ urlPrefix: (0, api_1.firebaseStorageOrigin)(), apiVersion: "v1beta" });
|
|
@@ -4,17 +4,14 @@ exports.SECRET_ROLE = exports.SECRET_LABEL = void 0;
|
|
|
4
4
|
exports.ensureSecretManagerApiEnabled = ensureSecretManagerApiEnabled;
|
|
5
5
|
exports.usesSecrets = usesSecrets;
|
|
6
6
|
exports.grantFirexServiceAgentSecretAdminRole = grantFirexServiceAgentSecretAdminRole;
|
|
7
|
-
exports.getManagedSecrets = getManagedSecrets;
|
|
8
7
|
exports.getActiveSecrets = getActiveSecrets;
|
|
9
8
|
exports.getSecretLabels = getSecretLabels;
|
|
10
|
-
exports.prettySecretName = prettySecretName;
|
|
11
9
|
const getProjectNumber_1 = require("../getProjectNumber");
|
|
12
10
|
const utils = require("../utils");
|
|
13
11
|
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
14
12
|
const projectUtils_1 = require("../projectUtils");
|
|
15
13
|
const types_1 = require("./types");
|
|
16
14
|
const secretManagerApi = require("../gcp/secretManager");
|
|
17
|
-
const logger_1 = require("../logger");
|
|
18
15
|
const api_1 = require("../api");
|
|
19
16
|
exports.SECRET_LABEL = "firebase-extensions-managed";
|
|
20
17
|
exports.SECRET_ROLE = "secretmanager.secretAccessor";
|
|
@@ -31,19 +28,6 @@ async function grantFirexServiceAgentSecretAdminRole(secret) {
|
|
|
31
28
|
const saEmail = `service-${projectNumber}@${firexSaProjectId}.iam.gserviceaccount.com`;
|
|
32
29
|
return secretManagerApi.ensureServiceAgentRole(secret, [saEmail], "roles/secretmanager.admin");
|
|
33
30
|
}
|
|
34
|
-
async function getManagedSecrets(instance) {
|
|
35
|
-
if (!instance.config?.source?.spec) {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
return (await Promise.all(getActiveSecrets(instance.config.source.spec, instance.config.params).map(async (secretResourceName) => {
|
|
39
|
-
const secret = secretManagerApi.parseSecretResourceName(secretResourceName);
|
|
40
|
-
const labels = (await secretManagerApi.getSecret(secret.projectId, secret.name)).labels;
|
|
41
|
-
if (labels && labels[exports.SECRET_LABEL]) {
|
|
42
|
-
return secretResourceName;
|
|
43
|
-
}
|
|
44
|
-
return Promise.resolve("");
|
|
45
|
-
}))).filter((secretId) => !!secretId);
|
|
46
|
-
}
|
|
47
31
|
function getActiveSecrets(spec, params) {
|
|
48
32
|
return spec.params
|
|
49
33
|
.map((p) => (p.type === types_1.ParamType.SECRET ? params[p.param] : ""))
|
|
@@ -54,11 +38,3 @@ function getSecretLabels(instanceId) {
|
|
|
54
38
|
labels[exports.SECRET_LABEL] = instanceId;
|
|
55
39
|
return labels;
|
|
56
40
|
}
|
|
57
|
-
function prettySecretName(secretResourceName) {
|
|
58
|
-
const nameTokens = secretResourceName.split("/");
|
|
59
|
-
if (nameTokens.length !== 4 && nameTokens.length !== 6) {
|
|
60
|
-
logger_1.logger.debug(`unable to parse secret secretResourceName: ${secretResourceName}`);
|
|
61
|
-
return secretResourceName;
|
|
62
|
-
}
|
|
63
|
-
return nameTokens.slice(0, 4).join("/");
|
|
64
|
-
}
|
package/lib/firestore/util.js
CHANGED
|
@@ -6,9 +6,9 @@ exports.parseFieldName = parseFieldName;
|
|
|
6
6
|
exports.booleanXOR = booleanXOR;
|
|
7
7
|
exports.getCurrentMinuteAsIsoString = getCurrentMinuteAsIsoString;
|
|
8
8
|
const error_1 = require("../error");
|
|
9
|
-
const DATABASE_NAME_REGEX = /projects\/([
|
|
10
|
-
const INDEX_NAME_REGEX = /projects\/([
|
|
11
|
-
const FIELD_NAME_REGEX = /projects\/([
|
|
9
|
+
const DATABASE_NAME_REGEX = /projects\/([^/]+?)\/databases\/([^/]+)/;
|
|
10
|
+
const INDEX_NAME_REGEX = /projects\/([^/]+?)\/databases\/([^/]+?)\/collectionGroups\/([^/]+?)\/indexes\/([^/]*)/;
|
|
11
|
+
const FIELD_NAME_REGEX = /projects\/([^/]+?)\/databases\/([^/]+?)\/collectionGroups\/([^/]+?)\/fields\/([^/]*)/;
|
|
12
12
|
function parseDatabaseName(name) {
|
|
13
13
|
if (!name) {
|
|
14
14
|
throw new error_1.FirebaseError(`Cannot parse undefined database name.`);
|
|
@@ -52,7 +52,7 @@ async function localesForTarget(dir, architectHost, target, workspaceProject) {
|
|
|
52
52
|
locales = [defaultLocale];
|
|
53
53
|
for (const [locale, { baseHref }] of Object.entries(i18n.locales)) {
|
|
54
54
|
if (baseHref !== "")
|
|
55
|
-
throw new error_1.FirebaseError(`All your i18n locales must have a baseHref of
|
|
55
|
+
throw new error_1.FirebaseError(`All your i18n locales must have a baseHref of "" on Firebase, errored on ${locale}.`);
|
|
56
56
|
locales.push(locale);
|
|
57
57
|
}
|
|
58
58
|
}
|