firebase-tools-with-isolate 14.10.1 → 14.16.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 +5 -1
- package/lib/apphosting/backend.js +40 -15
- package/lib/apptesting/ensureProjectConfigured.js +56 -0
- package/lib/apptesting/invokeTests.js +40 -0
- package/lib/apptesting/parseTestFiles.js +75 -0
- package/lib/apptesting/types.js +18 -0
- package/lib/auth.js +37 -2
- package/lib/command.js +24 -5
- package/lib/commands/apphosting-backends-create.js +8 -5
- package/lib/commands/apptesting-execute.js +101 -0
- package/lib/commands/dataconnect-sdk-generate.js +28 -26
- package/lib/commands/dataconnect-services-list.js +1 -1
- package/lib/commands/dataconnect-sql-diff.js +2 -2
- package/lib/commands/dataconnect-sql-grant.js +7 -2
- package/lib/commands/dataconnect-sql-migrate.js +2 -2
- package/lib/commands/dataconnect-sql-setup.js +3 -5
- package/lib/commands/dataconnect-sql-shell.js +2 -2
- package/lib/commands/ext-export.js +1 -1
- package/lib/commands/firestore-bulkdelete.js +73 -0
- package/lib/commands/firestore-databases-create.js +11 -0
- package/lib/commands/firestore-operations-cancel.js +44 -0
- package/lib/commands/firestore-operations-describe.js +29 -0
- package/lib/commands/firestore-operations-list.js +29 -0
- package/lib/commands/firestore-utils.js +15 -0
- package/lib/commands/functions-config-clone.js +2 -0
- package/lib/commands/functions-config-export.js +5 -2
- package/lib/commands/functions-config-get.js +2 -0
- package/lib/commands/functions-config-set.js +2 -0
- package/lib/commands/functions-config-unset.js +2 -0
- package/lib/commands/index.js +9 -0
- package/lib/commands/init.js +24 -4
- package/lib/commands/internaltesting-functions-discover.js +20 -5
- package/lib/commands/login.js +13 -9
- package/lib/commands/use.js +5 -0
- package/lib/config.js +16 -4
- package/lib/crashlytics/addNote.js +27 -0
- package/lib/crashlytics/buildToolsJarHelper.js +1 -2
- package/lib/crashlytics/deleteNote.js +23 -0
- package/lib/crashlytics/getIssueDetails.js +26 -0
- package/lib/crashlytics/getSampleCrash.js +34 -0
- package/lib/crashlytics/listNotes.js +29 -0
- package/lib/crashlytics/listTopDevices.js +33 -0
- package/lib/crashlytics/listTopIssues.js +8 -23
- package/lib/crashlytics/listTopOperatingSystems.js +32 -0
- package/lib/crashlytics/listTopVersions.js +32 -0
- package/lib/crashlytics/updateIssue.js +35 -0
- package/lib/crashlytics/utils.js +38 -0
- package/lib/dataconnect/appFinder.js +102 -0
- package/lib/dataconnect/client.js +23 -15
- package/lib/dataconnect/ensureApis.js +6 -9
- package/lib/dataconnect/errors.js +7 -1
- package/lib/dataconnect/freeTrial.js +16 -38
- package/lib/dataconnect/load.js +105 -6
- package/lib/dataconnect/provisionCloudSql.js +67 -70
- package/lib/dataconnect/schemaMigration.js +219 -169
- package/lib/deploy/dataconnect/deploy.js +7 -9
- package/lib/deploy/dataconnect/prepare.js +7 -12
- package/lib/deploy/dataconnect/release.js +43 -31
- package/lib/deploy/firestore/deploy.js +10 -0
- package/lib/deploy/functions/backend.js +7 -1
- package/lib/deploy/functions/build.js +28 -14
- package/lib/deploy/functions/deploy.js +3 -2
- package/lib/deploy/functions/ensure.js +1 -1
- package/lib/deploy/functions/functionsDeployHelper.js +8 -1
- package/lib/deploy/functions/params.js +4 -0
- package/lib/deploy/functions/prepare.js +25 -13
- package/lib/deploy/functions/pricing.js +12 -5
- package/lib/deploy/functions/release/fabricator.js +25 -3
- package/lib/deploy/functions/release/reporter.js +1 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +52 -5
- package/lib/deploy/functions/runtimes/node/index.js +83 -51
- package/lib/emulator/auth/operations.js +10 -1
- package/lib/emulator/commandUtils.js +7 -1
- package/lib/emulator/controller.js +22 -34
- package/lib/emulator/dataconnectEmulator.js +27 -24
- package/lib/emulator/downloadableEmulatorInfo.json +18 -18
- package/lib/emulator/env.js +2 -1
- package/lib/emulator/functionsEmulator.js +12 -2
- package/lib/emulator/hub.js +11 -8
- package/lib/emulator/tasksEmulator.js +1 -1
- package/lib/emulator/ui.js +3 -1
- package/lib/env.js +18 -0
- package/lib/experiments.js +20 -0
- package/lib/extensions/extensionsHelper.js +4 -15
- package/lib/extensions/runtimes/common.js +3 -2
- package/lib/extensions/utils.js +1 -12
- package/lib/firestore/api-sort.js +96 -3
- package/lib/firestore/api-types.js +20 -1
- package/lib/firestore/api.js +144 -15
- package/lib/firestore/pretty-print.js +35 -1
- package/lib/firestore/validator.js +1 -1
- package/lib/functional.js +7 -1
- package/lib/functions/deprecationWarnings.js +21 -0
- package/lib/functions/env.js +31 -16
- package/lib/functions/projectConfig.js +87 -8
- package/lib/functions/secrets.js +3 -0
- package/lib/gcp/cloudfunctions.js +1 -6
- package/lib/gcp/cloudfunctionsv2.js +3 -39
- package/lib/gcp/cloudscheduler.js +1 -1
- package/lib/gcp/cloudsql/cloudsqladmin.js +4 -16
- package/lib/gcp/cloudsql/connect.js +4 -3
- package/lib/gcp/cloudsql/permissionsSetup.js +23 -16
- package/lib/gcp/k8s.js +32 -0
- package/lib/gcp/runv2.js +181 -0
- package/lib/gemini/fdcExperience.js +5 -3
- package/lib/init/features/aitools/claude.js +43 -0
- package/lib/init/features/aitools/cursor.js +61 -0
- package/lib/init/features/aitools/gemini.js +58 -0
- package/lib/init/features/aitools/index.js +28 -0
- package/lib/init/features/aitools/promptUpdater.js +111 -0
- package/lib/init/features/aitools/studio.js +17 -0
- package/lib/init/features/aitools/types.js +2 -0
- package/lib/init/features/aitools.js +83 -0
- package/lib/init/features/apptesting/index.js +34 -0
- package/lib/init/features/dataconnect/create_app.js +53 -0
- package/lib/init/features/dataconnect/index.js +280 -186
- package/lib/init/features/dataconnect/sdk.js +232 -144
- package/lib/init/features/index.js +8 -3
- package/lib/init/features/project.js +4 -0
- package/lib/init/index.js +18 -2
- package/lib/management/apps.js +3 -3
- package/lib/management/studio.js +120 -0
- package/lib/mcp/errors.js +5 -7
- package/lib/mcp/index.js +179 -61
- package/lib/mcp/logging-transport.js +23 -0
- package/lib/mcp/prompt.js +10 -0
- package/lib/mcp/prompts/core/deploy.js +101 -0
- package/lib/mcp/prompts/core/index.js +5 -0
- package/lib/mcp/prompts/crashlytics/connect.js +114 -0
- package/lib/mcp/prompts/crashlytics/index.js +5 -0
- package/lib/mcp/prompts/dataconnect/index.js +9 -0
- package/lib/mcp/prompts/dataconnect/schema.js +67 -0
- package/lib/mcp/prompts/index.js +47 -0
- package/lib/mcp/tools/apphosting/fetch_logs.js +22 -22
- package/lib/mcp/tools/apphosting/list_backends.js +10 -10
- package/lib/mcp/tools/auth/disable_user.js +7 -7
- package/lib/mcp/tools/auth/get_user.js +13 -6
- package/lib/mcp/tools/auth/index.js +10 -10
- package/lib/mcp/tools/auth/list_users.js +6 -6
- package/lib/mcp/tools/auth/set_claims.js +7 -7
- package/lib/mcp/tools/auth/set_sms_region_policy.js +6 -6
- package/lib/mcp/tools/core/consult_assistant.js +13 -8
- package/lib/mcp/tools/core/create_android_sha.js +9 -9
- package/lib/mcp/tools/core/create_app.js +7 -7
- package/lib/mcp/tools/core/create_project.js +13 -13
- package/lib/mcp/tools/core/get_admin_sdk_config.js +7 -7
- package/lib/mcp/tools/core/get_environment.js +8 -8
- package/lib/mcp/tools/core/get_project.js +5 -5
- package/lib/mcp/tools/core/get_sdk_config.js +19 -9
- package/lib/mcp/tools/core/index.js +28 -24
- package/lib/mcp/tools/core/init.js +39 -16
- package/lib/mcp/tools/core/list_apps.js +6 -6
- package/lib/mcp/tools/core/list_projects.js +6 -6
- package/lib/mcp/tools/core/login.js +46 -0
- package/lib/mcp/tools/core/logout.js +62 -0
- package/lib/mcp/tools/core/update_environment.js +10 -10
- package/lib/mcp/tools/crashlytics/add_note.js +32 -0
- package/lib/mcp/tools/crashlytics/constants.js +11 -0
- package/lib/mcp/tools/crashlytics/delete_note.js +35 -0
- package/lib/mcp/tools/crashlytics/get_issue_details.js +31 -0
- package/lib/mcp/tools/crashlytics/get_sample_crash.js +43 -0
- package/lib/mcp/tools/crashlytics/index.js +22 -2
- package/lib/mcp/tools/crashlytics/list_notes.js +37 -0
- package/lib/mcp/tools/crashlytics/list_top_devices.js +33 -0
- package/lib/mcp/tools/crashlytics/list_top_issues.js +12 -13
- package/lib/mcp/tools/crashlytics/list_top_operating_systems.js +33 -0
- package/lib/mcp/tools/crashlytics/list_top_versions.js +33 -0
- package/lib/mcp/tools/crashlytics/update_issue.js +37 -0
- package/lib/mcp/tools/database/get_data.js +49 -0
- package/lib/mcp/tools/database/get_rules.js +39 -0
- package/lib/mcp/tools/database/index.js +8 -0
- package/lib/mcp/tools/database/set_data.js +57 -0
- package/lib/mcp/tools/database/validate_rules.js +41 -0
- package/lib/mcp/tools/dataconnect/compile.js +43 -0
- package/lib/mcp/tools/dataconnect/execute.js +71 -0
- package/lib/mcp/tools/dataconnect/generate_operation.js +8 -8
- package/lib/mcp/tools/dataconnect/generate_schema.js +6 -6
- package/lib/mcp/tools/dataconnect/index.js +10 -18
- package/lib/mcp/tools/dataconnect/list_services.js +107 -11
- package/lib/mcp/tools/firestore/delete_document.js +13 -13
- package/lib/mcp/tools/firestore/get_documents.js +13 -13
- package/lib/mcp/tools/firestore/list_collections.js +7 -10
- package/lib/mcp/tools/firestore/query_collection.js +13 -13
- package/lib/mcp/tools/index.js +24 -18
- package/lib/mcp/tools/messaging/index.js +2 -2
- package/lib/mcp/tools/messaging/send_message.js +7 -7
- package/lib/mcp/tools/remoteconfig/get_template.js +5 -5
- package/lib/mcp/tools/remoteconfig/index.js +4 -4
- package/lib/mcp/tools/remoteconfig/publish_template.js +7 -7
- package/lib/mcp/tools/remoteconfig/rollback_template.js +6 -6
- package/lib/mcp/tools/rules/get_rules.js +8 -8
- package/lib/mcp/tools/rules/validate_rules.js +10 -10
- package/lib/mcp/tools/storage/get_download_url.js +8 -8
- package/lib/mcp/tools/storage/get_rules.js +8 -8
- package/lib/mcp/types.js +2 -0
- package/lib/mcp/util/dataconnect/compile.js +20 -0
- package/lib/mcp/util/dataconnect/content.js +655 -0
- package/lib/mcp/util/dataconnect/emulator.js +16 -0
- package/lib/mcp/util.js +5 -18
- package/lib/requireAuth.js +14 -4
- package/lib/rtdb.js +10 -6
- package/lib/scopes.js +2 -1
- package/lib/serve/functions.js +4 -3
- package/lib/timeout.js +21 -0
- package/lib/track.js +18 -1
- package/lib/unzip.js +13 -0
- package/lib/utils.js +76 -2
- package/package.json +5 -3
- package/prompts/FIREBASE.md +121 -0
- package/prompts/FIREBASE_FUNCTIONS.md +221 -0
- package/schema/apptesting-yaml.json +64 -0
- package/schema/firebase-config.json +163 -53
- package/templates/init/aitools/cursor-rules-header.txt +8 -0
- package/templates/init/aitools/gemini-extension.json +11 -0
- package/templates/init/apptesting/smoke_test.yaml +6 -0
- package/templates/init/dataconnect/connector.yaml +0 -16
- package/templates/init/dataconnect/dataconnect.yaml +2 -1
- package/templates/init/dataconnect/mutations.gql +29 -29
- package/templates/init/dataconnect/queries.gql +73 -73
- package/templates/init/dataconnect/schema.gql +48 -48
- package/templates/init/firestore/firestore.indexes.json +26 -1
- package/lib/dataconnect/fileUtils.js +0 -168
- package/lib/emulator/adminSdkConfig.test.js +0 -16
- package/lib/extensions/resolveSource.js +0 -23
- package/lib/firestore/api-sort.test.js +0 -74
- package/lib/firestore/backupUtils.test.js +0 -18
- package/lib/firestore/pretty-print.test.js +0 -61
- package/lib/firestore/util.test.js +0 -42
- package/lib/mcp/tools/dataconnect/emulator.js +0 -16
- package/lib/mcp/tools/dataconnect/execute_graphql.js +0 -48
- package/lib/mcp/tools/dataconnect/execute_graphql_read.js +0 -48
- package/lib/mcp/tools/dataconnect/execute_mutation.js +0 -62
- package/lib/mcp/tools/dataconnect/execute_query.js +0 -62
- package/lib/mcp/tools/dataconnect/get_connector.js +0 -31
- package/lib/mcp/tools/dataconnect/get_schema.js +0 -31
- /package/lib/mcp/{tools → util}/dataconnect/converter.js +0 -0
|
@@ -165,7 +165,7 @@ class TasksEmulator {
|
|
|
165
165
|
req.body.task.name =
|
|
166
166
|
req.body.task.name ??
|
|
167
167
|
`/projects/${projectId}/locations/${locationId}/queues/${queueName}/tasks/${Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)}`;
|
|
168
|
-
req.body.task.httpRequest.body = JSON.parse(
|
|
168
|
+
req.body.task.httpRequest.body = JSON.parse(Buffer.from(req.body.task.httpRequest.body, "base64").toString("utf-8"));
|
|
169
169
|
const task = req.body.task;
|
|
170
170
|
try {
|
|
171
171
|
this.controller.enqueue(queueKey, task);
|
package/lib/emulator/ui.js
CHANGED
|
@@ -12,6 +12,8 @@ const constants_1 = require("./constants");
|
|
|
12
12
|
const track_1 = require("../track");
|
|
13
13
|
const ExpressBasedEmulator_1 = require("./ExpressBasedEmulator");
|
|
14
14
|
const experiments_1 = require("../experiments");
|
|
15
|
+
const functional_1 = require("../functional");
|
|
16
|
+
const env_1 = require("./env");
|
|
15
17
|
class EmulatorUI extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
16
18
|
constructor(args) {
|
|
17
19
|
super({
|
|
@@ -35,7 +37,7 @@ class EmulatorUI extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
35
37
|
const downloadDetails = downloadableEmulators.getDownloadDetails(types_1.Emulators.UI);
|
|
36
38
|
const webDir = path.join(downloadDetails.unzipDir, "client");
|
|
37
39
|
app.get("/api/config", this.jsonHandler(() => {
|
|
38
|
-
const emulatorInfos = hub.getRunningEmulatorsMapping();
|
|
40
|
+
const emulatorInfos = (0, functional_1.mapObject)(hub.getRunningEmulatorsMapping(), env_1.maybeUsePortForwarding);
|
|
39
41
|
const json = {
|
|
40
42
|
projectId,
|
|
41
43
|
experiments: enabledExperiments ?? [],
|
package/lib/env.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFirebaseMcp = exports.isFirebaseStudio = void 0;
|
|
4
|
+
const fsutils_1 = require("./fsutils");
|
|
5
|
+
let googleIdxFolderExists;
|
|
6
|
+
function isFirebaseStudio() {
|
|
7
|
+
if (googleIdxFolderExists === true || process.env.MONOSPACE_ENV)
|
|
8
|
+
return true;
|
|
9
|
+
if (googleIdxFolderExists === false)
|
|
10
|
+
return false;
|
|
11
|
+
googleIdxFolderExists = (0, fsutils_1.dirExistsSync)("/google/idx");
|
|
12
|
+
return googleIdxFolderExists;
|
|
13
|
+
}
|
|
14
|
+
exports.isFirebaseStudio = isFirebaseStudio;
|
|
15
|
+
function isFirebaseMcp() {
|
|
16
|
+
return !!process.env.IS_FIREBASE_MCP;
|
|
17
|
+
}
|
|
18
|
+
exports.isFirebaseMcp = isFirebaseMcp;
|
package/lib/experiments.js
CHANGED
|
@@ -41,6 +41,17 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
41
41
|
"of how that image was created.",
|
|
42
42
|
public: true,
|
|
43
43
|
},
|
|
44
|
+
dangerouslyAllowFunctionsConfig: {
|
|
45
|
+
shortDescription: "Allows the use of deprecated functions.config() API",
|
|
46
|
+
fullDescription: "The functions.config() API is deprecated and will be removed on December 31, 2025. " +
|
|
47
|
+
"This experiment allows continued use of the API during the migration period.",
|
|
48
|
+
default: true,
|
|
49
|
+
public: true,
|
|
50
|
+
},
|
|
51
|
+
runfunctions: {
|
|
52
|
+
shortDescription: "Functions created using the V2 API target Cloud Run Functions (not production ready)",
|
|
53
|
+
public: false,
|
|
54
|
+
},
|
|
44
55
|
emulatoruisnapshot: {
|
|
45
56
|
shortDescription: "Load pre-release versions of the emulator UI",
|
|
46
57
|
},
|
|
@@ -105,6 +116,15 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
105
116
|
default: true,
|
|
106
117
|
public: false,
|
|
107
118
|
},
|
|
119
|
+
mcpalpha: {
|
|
120
|
+
shortDescription: "Opt-in to early MCP features before they're widely released.",
|
|
121
|
+
default: false,
|
|
122
|
+
public: true,
|
|
123
|
+
},
|
|
124
|
+
apptesting: {
|
|
125
|
+
shortDescription: "Adds experimental App Testing feature",
|
|
126
|
+
public: true,
|
|
127
|
+
},
|
|
108
128
|
});
|
|
109
129
|
function isValidExperiment(name) {
|
|
110
130
|
return Object.keys(exports.ALL_EXPERIMENTS).includes(name);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.diagnoseAndFixProject = exports.getSourceOrigin = exports.isLocalOrURLPath = exports.isLocalPath = exports.isUrlPath = exports.instanceIdExists = exports.promptForRepeatInstance = exports.
|
|
3
|
+
exports.diagnoseAndFixProject = exports.getSourceOrigin = exports.isLocalOrURLPath = exports.isLocalPath = exports.isUrlPath = exports.instanceIdExists = exports.promptForRepeatInstance = exports.displayReleaseNotes = exports.getPublisherProjectFromName = exports.createSourceFromLocation = exports.getMissingPublisherError = exports.uploadExtensionVersionFromLocalSource = exports.uploadExtensionVersionFromGitHubSource = exports.unpackExtensionState = exports.getNextVersionByStage = exports.ensureExtensionsPublisherApiEnabled = exports.ensureExtensionsApiEnabled = exports.checkExtensionsApiEnabled = exports.promptForExtensionRoot = exports.promptForValidRepoURI = exports.promptForValidInstanceId = exports.validateSpec = exports.validateCommandLineParams = exports.populateDefaultParams = exports.substituteSecretParams = exports.substituteParams = exports.getFirebaseProjectParams = exports.getDBInstanceFromURL = exports.resourceTypeToNiceName = exports.AUTOPOPULATED_PARAM_PLACEHOLDERS = exports.EXTENSIONS_BUCKET_NAME = exports.URL_REGEX = exports.logPrefix = exports.SourceOrigin = exports.SpecParamType = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const ora = require("ora");
|
|
6
6
|
const semver = require("semver");
|
|
@@ -14,10 +14,8 @@ const unzip_1 = require("./../unzip");
|
|
|
14
14
|
marked_1.marked.use((0, marked_terminal_1.markedTerminal)());
|
|
15
15
|
const api_1 = require("../api");
|
|
16
16
|
const archiveDirectory_1 = require("../archiveDirectory");
|
|
17
|
-
const utils_1 = require("./utils");
|
|
18
17
|
const functionsConfig_1 = require("../functionsConfig");
|
|
19
18
|
const adminSdkConfig_1 = require("../emulator/adminSdkConfig");
|
|
20
|
-
const resolveSource_1 = require("./resolveSource");
|
|
21
19
|
const error_1 = require("../error");
|
|
22
20
|
const diagnose_1 = require("./diagnose");
|
|
23
21
|
const askUserForParam_1 = require("./askUserForParam");
|
|
@@ -30,7 +28,7 @@ const prompt_1 = require("../prompt");
|
|
|
30
28
|
const refs = require("./refs");
|
|
31
29
|
const localHelper_1 = require("./localHelper");
|
|
32
30
|
const logger_1 = require("../logger");
|
|
33
|
-
const
|
|
31
|
+
const utils_1 = require("../utils");
|
|
34
32
|
const change_log_1 = require("./change-log");
|
|
35
33
|
const getProjectNumber_1 = require("../getProjectNumber");
|
|
36
34
|
const constants_1 = require("../emulator/constants");
|
|
@@ -54,7 +52,7 @@ var SourceOrigin;
|
|
|
54
52
|
exports.logPrefix = "extensions";
|
|
55
53
|
const VALID_LICENSES = ["apache-2.0"];
|
|
56
54
|
exports.URL_REGEX = /^https:/;
|
|
57
|
-
exports.EXTENSIONS_BUCKET_NAME = (0,
|
|
55
|
+
exports.EXTENSIONS_BUCKET_NAME = (0, utils_1.envOverride)("FIREBASE_EXTENSIONS_UPLOAD_BUCKET", "firebase-ext-eap-uploads");
|
|
58
56
|
const AUTOPOPULATED_PARAM_NAMES = [
|
|
59
57
|
"PROJECT_ID",
|
|
60
58
|
"STORAGE_BUCKET",
|
|
@@ -96,7 +94,7 @@ async function getFirebaseProjectParams(projectId, emulatorMode = false) {
|
|
|
96
94
|
projectNumber = await (0, getProjectNumber_1.getProjectNumber)({ projectId });
|
|
97
95
|
}
|
|
98
96
|
catch (err) {
|
|
99
|
-
(0,
|
|
97
|
+
(0, utils_1.logLabeledError)("extensions", `Unable to look up project number for ${projectId}.\n` +
|
|
100
98
|
" If this is a real project, ensure that you are logged in and have access to it.\n" +
|
|
101
99
|
" If this is a fake project, please use a project ID starting with 'demo-' to skip production calls.\n" +
|
|
102
100
|
" Continuing with a fake project number - secrets and other features that require production access may behave unexpectedly.");
|
|
@@ -782,15 +780,6 @@ function displayReleaseNotes(args) {
|
|
|
782
780
|
logger_1.logger.info(message);
|
|
783
781
|
}
|
|
784
782
|
exports.displayReleaseNotes = displayReleaseNotes;
|
|
785
|
-
async function promptForOfficialExtension(message) {
|
|
786
|
-
const officialExts = await (0, resolveSource_1.getExtensionRegistry)(true);
|
|
787
|
-
return await (0, prompt_1.select)({
|
|
788
|
-
message,
|
|
789
|
-
choices: (0, utils_1.convertOfficialExtensionsToList)(officialExts),
|
|
790
|
-
pageSize: Object.keys(officialExts).length,
|
|
791
|
-
});
|
|
792
|
-
}
|
|
793
|
-
exports.promptForOfficialExtension = promptForOfficialExtension;
|
|
794
783
|
async function promptForRepeatInstance(projectName, extensionName) {
|
|
795
784
|
const message = `An extension with the ID '${clc.bold(extensionName)}' already exists in the project '${clc.bold(projectName)}'. What would you like to do?`;
|
|
796
785
|
return await (0, prompt_1.select)({
|
|
@@ -135,13 +135,14 @@ exports.copyDirectory = copyDirectory;
|
|
|
135
135
|
async function getCodebaseRuntime(options) {
|
|
136
136
|
const config = (0, projectConfig_1.normalizeAndValidate)(options.config.src.functions);
|
|
137
137
|
const codebaseConfig = (0, projectConfig_1.configForCodebase)(config, options.codebase || projectConfig_1.DEFAULT_CODEBASE);
|
|
138
|
-
const
|
|
138
|
+
const localCfg = (0, projectConfig_1.requireLocal)(codebaseConfig);
|
|
139
|
+
const sourceDirName = localCfg.source;
|
|
139
140
|
const sourceDir = options.config.path(sourceDirName);
|
|
140
141
|
const delegateContext = {
|
|
141
142
|
projectId: "",
|
|
142
143
|
sourceDir,
|
|
143
144
|
projectDir: options.config.projectDir,
|
|
144
|
-
runtime:
|
|
145
|
+
runtime: localCfg.runtime,
|
|
145
146
|
};
|
|
146
147
|
let delegate;
|
|
147
148
|
try {
|
package/lib/extensions/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getResourceRuntime = exports.formatTimestamp = exports.getRandomString = exports.
|
|
3
|
+
exports.getResourceRuntime = exports.formatTimestamp = exports.getRandomString = exports.convertExtensionOptionToLabeledList = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
function convertExtensionOptionToLabeledList(options) {
|
|
6
6
|
return options.map((option) => {
|
|
@@ -12,17 +12,6 @@ function convertExtensionOptionToLabeledList(options) {
|
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
exports.convertExtensionOptionToLabeledList = convertExtensionOptionToLabeledList;
|
|
15
|
-
function convertOfficialExtensionsToList(officialExts) {
|
|
16
|
-
const l = Object.entries(officialExts).map(([key, entry]) => {
|
|
17
|
-
return {
|
|
18
|
-
checked: false,
|
|
19
|
-
value: `${entry.publisher}/${key}`,
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
l.sort((a, b) => a.value.localeCompare(b.value));
|
|
23
|
-
return l;
|
|
24
|
-
}
|
|
25
|
-
exports.convertOfficialExtensionsToList = convertOfficialExtensionsToList;
|
|
26
15
|
function getRandomString(length) {
|
|
27
16
|
const SUFFIX_CHAR_SET = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
28
17
|
let result = "";
|
|
@@ -8,6 +8,19 @@ const QUERY_SCOPE_SEQUENCE = [
|
|
|
8
8
|
API.QueryScope.COLLECTION,
|
|
9
9
|
undefined,
|
|
10
10
|
];
|
|
11
|
+
const API_SCOPE_SEQUENCE = [
|
|
12
|
+
API.ApiScope.ANY_API,
|
|
13
|
+
API.ApiScope.DATASTORE_MODE_API,
|
|
14
|
+
API.ApiScope.MONGODB_COMPATIBLE_API,
|
|
15
|
+
undefined,
|
|
16
|
+
];
|
|
17
|
+
const DENSITY_SEQUENCE = [
|
|
18
|
+
API.Density.DENSITY_UNSPECIFIED,
|
|
19
|
+
API.Density.SPARSE_ALL,
|
|
20
|
+
API.Density.SPARSE_ANY,
|
|
21
|
+
API.Density.DENSE,
|
|
22
|
+
undefined,
|
|
23
|
+
];
|
|
11
24
|
const ORDER_SEQUENCE = [API.Order.ASCENDING, API.Order.DESCENDING, undefined];
|
|
12
25
|
const ARRAY_CONFIG_SEQUENCE = [API.ArrayConfig.CONTAINS, undefined];
|
|
13
26
|
function compareSpecIndex(a, b) {
|
|
@@ -17,7 +30,23 @@ function compareSpecIndex(a, b) {
|
|
|
17
30
|
if (a.queryScope !== b.queryScope) {
|
|
18
31
|
return compareQueryScope(a.queryScope, b.queryScope);
|
|
19
32
|
}
|
|
20
|
-
|
|
33
|
+
let cmp = compareArrays(a.fields, b.fields, compareIndexField);
|
|
34
|
+
if (cmp !== 0) {
|
|
35
|
+
return cmp;
|
|
36
|
+
}
|
|
37
|
+
cmp = compareApiScope(a.apiScope, b.apiScope);
|
|
38
|
+
if (cmp !== 0) {
|
|
39
|
+
return cmp;
|
|
40
|
+
}
|
|
41
|
+
cmp = compareDensity(a.density, b.density);
|
|
42
|
+
if (cmp !== 0) {
|
|
43
|
+
return cmp;
|
|
44
|
+
}
|
|
45
|
+
cmp = compareBoolean(a.multikey, b.multikey);
|
|
46
|
+
if (cmp !== 0) {
|
|
47
|
+
return cmp;
|
|
48
|
+
}
|
|
49
|
+
return compareBoolean(a.unique, b.unique);
|
|
21
50
|
}
|
|
22
51
|
exports.compareSpecIndex = compareSpecIndex;
|
|
23
52
|
function compareApiIndex(a, b) {
|
|
@@ -31,7 +60,23 @@ function compareApiIndex(a, b) {
|
|
|
31
60
|
if (a.queryScope !== b.queryScope) {
|
|
32
61
|
return compareQueryScope(a.queryScope, b.queryScope);
|
|
33
62
|
}
|
|
34
|
-
|
|
63
|
+
let cmp = compareArrays(a.fields, b.fields, compareIndexField);
|
|
64
|
+
if (cmp !== 0) {
|
|
65
|
+
return cmp;
|
|
66
|
+
}
|
|
67
|
+
cmp = compareApiScope(a.apiScope, b.apiScope);
|
|
68
|
+
if (cmp !== 0) {
|
|
69
|
+
return cmp;
|
|
70
|
+
}
|
|
71
|
+
cmp = compareDensity(a.density, b.density);
|
|
72
|
+
if (cmp !== 0) {
|
|
73
|
+
return cmp;
|
|
74
|
+
}
|
|
75
|
+
cmp = compareBoolean(a.multikey, b.multikey);
|
|
76
|
+
if (cmp !== 0) {
|
|
77
|
+
return cmp;
|
|
78
|
+
}
|
|
79
|
+
return compareBoolean(a.unique, b.unique);
|
|
35
80
|
}
|
|
36
81
|
exports.compareApiIndex = compareApiIndex;
|
|
37
82
|
function compareApiDatabase(a, b) {
|
|
@@ -115,14 +160,62 @@ function compareFieldIndex(a, b) {
|
|
|
115
160
|
if (a.arrayConfig !== b.arrayConfig) {
|
|
116
161
|
return compareArrayConfig(a.arrayConfig, b.arrayConfig);
|
|
117
162
|
}
|
|
118
|
-
|
|
163
|
+
let cmp = compareApiScope(a.apiScope, b.apiScope);
|
|
164
|
+
if (cmp !== 0) {
|
|
165
|
+
return cmp;
|
|
166
|
+
}
|
|
167
|
+
cmp = compareDensity(a.density, b.density);
|
|
168
|
+
if (cmp !== 0) {
|
|
169
|
+
return cmp;
|
|
170
|
+
}
|
|
171
|
+
cmp = compareBoolean(a.multikey, b.multikey);
|
|
172
|
+
if (cmp !== 0) {
|
|
173
|
+
return cmp;
|
|
174
|
+
}
|
|
175
|
+
return compareBoolean(a.unique, b.unique);
|
|
119
176
|
}
|
|
120
177
|
function compareQueryScope(a, b) {
|
|
121
178
|
return QUERY_SCOPE_SEQUENCE.indexOf(a) - QUERY_SCOPE_SEQUENCE.indexOf(b);
|
|
122
179
|
}
|
|
180
|
+
function compareApiScope(a, b) {
|
|
181
|
+
if (a === b) {
|
|
182
|
+
return 0;
|
|
183
|
+
}
|
|
184
|
+
if (a === undefined) {
|
|
185
|
+
return -1;
|
|
186
|
+
}
|
|
187
|
+
if (b === undefined) {
|
|
188
|
+
return 1;
|
|
189
|
+
}
|
|
190
|
+
return API_SCOPE_SEQUENCE.indexOf(a) - API_SCOPE_SEQUENCE.indexOf(b);
|
|
191
|
+
}
|
|
192
|
+
function compareDensity(a, b) {
|
|
193
|
+
if (a === b) {
|
|
194
|
+
return 0;
|
|
195
|
+
}
|
|
196
|
+
if (a === undefined) {
|
|
197
|
+
return -1;
|
|
198
|
+
}
|
|
199
|
+
if (b === undefined) {
|
|
200
|
+
return 1;
|
|
201
|
+
}
|
|
202
|
+
return DENSITY_SEQUENCE.indexOf(a) - DENSITY_SEQUENCE.indexOf(b);
|
|
203
|
+
}
|
|
123
204
|
function compareOrder(a, b) {
|
|
124
205
|
return ORDER_SEQUENCE.indexOf(a) - ORDER_SEQUENCE.indexOf(b);
|
|
125
206
|
}
|
|
207
|
+
function compareBoolean(a, b) {
|
|
208
|
+
if (a === b) {
|
|
209
|
+
return 0;
|
|
210
|
+
}
|
|
211
|
+
if (a === undefined) {
|
|
212
|
+
return -1;
|
|
213
|
+
}
|
|
214
|
+
if (b === undefined) {
|
|
215
|
+
return 1;
|
|
216
|
+
}
|
|
217
|
+
return Number(a) - Number(b);
|
|
218
|
+
}
|
|
126
219
|
function compareArrayConfig(a, b) {
|
|
127
220
|
return ARRAY_CONFIG_SEQUENCE.indexOf(a) - ARRAY_CONFIG_SEQUENCE.indexOf(b);
|
|
128
221
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RecurrenceType = exports.PointInTimeRecoveryEnablement = exports.PointInTimeRecoveryEnablementOption = exports.DatabaseDeleteProtectionState = exports.DatabaseDeleteProtectionStateOption = exports.DatabaseType = exports.StateTtl = exports.State = exports.ArrayConfig = exports.Order = exports.QueryScope = exports.Mode = void 0;
|
|
3
|
+
exports.RecurrenceType = exports.DatabaseEdition = exports.PointInTimeRecoveryEnablement = exports.PointInTimeRecoveryEnablementOption = exports.DatabaseDeleteProtectionState = exports.DatabaseDeleteProtectionStateOption = exports.DatabaseType = exports.StateTtl = exports.State = exports.ArrayConfig = exports.Order = exports.Density = exports.ApiScope = exports.QueryScope = exports.Mode = void 0;
|
|
4
4
|
var Mode;
|
|
5
5
|
(function (Mode) {
|
|
6
6
|
Mode["ASCENDING"] = "ASCENDING";
|
|
@@ -12,6 +12,19 @@ var QueryScope;
|
|
|
12
12
|
QueryScope["COLLECTION"] = "COLLECTION";
|
|
13
13
|
QueryScope["COLLECTION_GROUP"] = "COLLECTION_GROUP";
|
|
14
14
|
})(QueryScope = exports.QueryScope || (exports.QueryScope = {}));
|
|
15
|
+
var ApiScope;
|
|
16
|
+
(function (ApiScope) {
|
|
17
|
+
ApiScope["ANY_API"] = "ANY_API";
|
|
18
|
+
ApiScope["DATASTORE_MODE_API"] = "DATASTORE_MODE_API";
|
|
19
|
+
ApiScope["MONGODB_COMPATIBLE_API"] = "MONGODB_COMPATIBLE_API";
|
|
20
|
+
})(ApiScope = exports.ApiScope || (exports.ApiScope = {}));
|
|
21
|
+
var Density;
|
|
22
|
+
(function (Density) {
|
|
23
|
+
Density["DENSITY_UNSPECIFIED"] = "DENSITY_UNSPECIFIED";
|
|
24
|
+
Density["SPARSE_ALL"] = "SPARSE_ALL";
|
|
25
|
+
Density["SPARSE_ANY"] = "SPARSE_ANY";
|
|
26
|
+
Density["DENSE"] = "DENSE";
|
|
27
|
+
})(Density = exports.Density || (exports.Density = {}));
|
|
15
28
|
var Order;
|
|
16
29
|
(function (Order) {
|
|
17
30
|
Order["ASCENDING"] = "ASCENDING";
|
|
@@ -58,6 +71,12 @@ var PointInTimeRecoveryEnablement;
|
|
|
58
71
|
PointInTimeRecoveryEnablement["ENABLED"] = "POINT_IN_TIME_RECOVERY_ENABLED";
|
|
59
72
|
PointInTimeRecoveryEnablement["DISABLED"] = "POINT_IN_TIME_RECOVERY_DISABLED";
|
|
60
73
|
})(PointInTimeRecoveryEnablement = exports.PointInTimeRecoveryEnablement || (exports.PointInTimeRecoveryEnablement = {}));
|
|
74
|
+
var DatabaseEdition;
|
|
75
|
+
(function (DatabaseEdition) {
|
|
76
|
+
DatabaseEdition["DATABASE_EDITION_UNSPECIFIED"] = "DATABASE_EDITION_UNSPECIFIED";
|
|
77
|
+
DatabaseEdition["STANDARD"] = "STANDARD";
|
|
78
|
+
DatabaseEdition["ENTERPRISE"] = "ENTERPRISE";
|
|
79
|
+
})(DatabaseEdition = exports.DatabaseEdition || (exports.DatabaseEdition = {}));
|
|
61
80
|
var RecurrenceType;
|
|
62
81
|
(function (RecurrenceType) {
|
|
63
82
|
RecurrenceType["DAILY"] = "DAILY";
|
package/lib/firestore/api.js
CHANGED
|
@@ -6,6 +6,7 @@ const logger_1 = require("../logger");
|
|
|
6
6
|
const utils = require("../utils");
|
|
7
7
|
const validator = require("./validator");
|
|
8
8
|
const types = require("./api-types");
|
|
9
|
+
const api_types_1 = require("./api-types");
|
|
9
10
|
const sort = require("./api-sort");
|
|
10
11
|
const util = require("./util");
|
|
11
12
|
const prompt_1 = require("../prompt");
|
|
@@ -13,11 +14,28 @@ const api_1 = require("../api");
|
|
|
13
14
|
const error_1 = require("../error");
|
|
14
15
|
const apiv2_1 = require("../apiv2");
|
|
15
16
|
const pretty_print_1 = require("./pretty-print");
|
|
17
|
+
const functional_1 = require("../functional");
|
|
16
18
|
class FirestoreApi {
|
|
17
19
|
constructor() {
|
|
18
20
|
this.apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.firestoreOrigin)(), apiVersion: "v1" });
|
|
19
21
|
this.printer = new pretty_print_1.PrettyPrint();
|
|
20
22
|
}
|
|
23
|
+
static processIndexes(indexes) {
|
|
24
|
+
return indexes.map((index) => {
|
|
25
|
+
let fields = index.fields;
|
|
26
|
+
const lastField = index.fields?.[index.fields.length - 1];
|
|
27
|
+
if (lastField?.fieldPath === "__name__") {
|
|
28
|
+
const defaultDirection = index.fields?.[index.fields.length - 2]?.order;
|
|
29
|
+
if (lastField?.order === defaultDirection) {
|
|
30
|
+
fields = fields.slice(0, -1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
...index,
|
|
35
|
+
fields,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
21
39
|
async deploy(options, indexes, fieldOverrides, databaseId = "(default)") {
|
|
22
40
|
const spec = this.upgradeOldSpec({
|
|
23
41
|
indexes,
|
|
@@ -28,8 +46,10 @@ class FirestoreApi {
|
|
|
28
46
|
const fieldOverridesToDeploy = spec.fieldOverrides;
|
|
29
47
|
const existingIndexes = await this.listIndexes(options.project, databaseId);
|
|
30
48
|
const existingFieldOverrides = await this.listFieldOverrides(options.project, databaseId);
|
|
49
|
+
const database = await this.getDatabase(options.project, databaseId);
|
|
50
|
+
const edition = database.databaseEdition ?? api_types_1.DatabaseEdition.STANDARD;
|
|
31
51
|
const indexesToDelete = existingIndexes.filter((index) => {
|
|
32
|
-
return !indexesToDeploy.some((spec) => this.indexMatchesSpec(index, spec));
|
|
52
|
+
return !indexesToDeploy.some((spec) => this.indexMatchesSpec(index, spec, edition));
|
|
33
53
|
});
|
|
34
54
|
const fieldOverridesToDelete = existingFieldOverrides.filter((field) => {
|
|
35
55
|
return !fieldOverridesToDeploy.some((spec) => {
|
|
@@ -65,7 +85,7 @@ class FirestoreApi {
|
|
|
65
85
|
}
|
|
66
86
|
}
|
|
67
87
|
for (const index of indexesToDeploy) {
|
|
68
|
-
const exists = existingIndexes.some((x) => this.indexMatchesSpec(x, index));
|
|
88
|
+
const exists = existingIndexes.some((x) => this.indexMatchesSpec(x, index, edition));
|
|
69
89
|
if (exists) {
|
|
70
90
|
logger_1.logger.debug(`Skipping existing index: ${JSON.stringify(index)}`);
|
|
71
91
|
}
|
|
@@ -126,17 +146,7 @@ class FirestoreApi {
|
|
|
126
146
|
if (!indexes) {
|
|
127
147
|
return [];
|
|
128
148
|
}
|
|
129
|
-
return
|
|
130
|
-
const fields = index.fields.filter((field) => {
|
|
131
|
-
return field.fieldPath !== "__name__";
|
|
132
|
-
});
|
|
133
|
-
return {
|
|
134
|
-
name: index.name,
|
|
135
|
-
state: index.state,
|
|
136
|
-
queryScope: index.queryScope,
|
|
137
|
-
fields,
|
|
138
|
-
};
|
|
139
|
-
});
|
|
149
|
+
return FirestoreApi.processIndexes(indexes);
|
|
140
150
|
}
|
|
141
151
|
async listFieldOverrides(project, databaseId = "(default)") {
|
|
142
152
|
const parent = `projects/${project}/databases/${databaseId}/collectionGroups/-`;
|
|
@@ -156,6 +166,10 @@ class FirestoreApi {
|
|
|
156
166
|
collectionGroup: util.parseIndexName(index.name).collectionGroupId,
|
|
157
167
|
queryScope: index.queryScope,
|
|
158
168
|
fields: index.fields,
|
|
169
|
+
apiScope: index.apiScope,
|
|
170
|
+
density: index.density,
|
|
171
|
+
multikey: index.multikey,
|
|
172
|
+
unique: index.unique,
|
|
159
173
|
};
|
|
160
174
|
});
|
|
161
175
|
if (!fields) {
|
|
@@ -175,6 +189,10 @@ class FirestoreApi {
|
|
|
175
189
|
order: firstField.order,
|
|
176
190
|
arrayConfig: firstField.arrayConfig,
|
|
177
191
|
queryScope: index.queryScope,
|
|
192
|
+
apiScope: index.apiScope,
|
|
193
|
+
density: index.density,
|
|
194
|
+
multikey: index.multikey,
|
|
195
|
+
unique: index.unique,
|
|
178
196
|
};
|
|
179
197
|
}),
|
|
180
198
|
};
|
|
@@ -201,6 +219,19 @@ class FirestoreApi {
|
|
|
201
219
|
validator.assertHas(index, "collectionGroup");
|
|
202
220
|
validator.assertHas(index, "queryScope");
|
|
203
221
|
validator.assertEnum(index, "queryScope", Object.keys(types.QueryScope));
|
|
222
|
+
if (index.apiScope) {
|
|
223
|
+
validator.assertEnum(index, "apiScope", Object.keys(types.ApiScope));
|
|
224
|
+
}
|
|
225
|
+
if (index.density) {
|
|
226
|
+
validator.assertEnum(index, "density", Object.keys(types.Density));
|
|
227
|
+
}
|
|
228
|
+
if (index.multikey) {
|
|
229
|
+
validator.assertType("multikey", index.multikey, "boolean");
|
|
230
|
+
}
|
|
231
|
+
if (index.unique !== undefined) {
|
|
232
|
+
validator.assertType("unique", index.unique, "boolean");
|
|
233
|
+
throw new error_1.FirebaseError("The `unique` index configuration is not supported yet.");
|
|
234
|
+
}
|
|
204
235
|
validator.assertHas(index, "fields");
|
|
205
236
|
index.fields.forEach((field) => {
|
|
206
237
|
validator.assertHas(field, "fieldPath");
|
|
@@ -235,6 +266,18 @@ class FirestoreApi {
|
|
|
235
266
|
if (index.queryScope) {
|
|
236
267
|
validator.assertEnum(index, "queryScope", Object.keys(types.QueryScope));
|
|
237
268
|
}
|
|
269
|
+
if (index.apiScope) {
|
|
270
|
+
validator.assertEnum(index, "apiScope", Object.keys(types.ApiScope));
|
|
271
|
+
}
|
|
272
|
+
if (index.density) {
|
|
273
|
+
validator.assertEnum(index, "density", Object.keys(types.Density));
|
|
274
|
+
}
|
|
275
|
+
if (index.multikey) {
|
|
276
|
+
validator.assertType("multikey", index.multikey, "boolean");
|
|
277
|
+
}
|
|
278
|
+
if (index.unique) {
|
|
279
|
+
validator.assertType("unique", index.unique, "boolean");
|
|
280
|
+
}
|
|
238
281
|
});
|
|
239
282
|
}
|
|
240
283
|
async patchField(project, spec, databaseId = "(default)") {
|
|
@@ -242,6 +285,10 @@ class FirestoreApi {
|
|
|
242
285
|
const indexes = spec.indexes.map((index) => {
|
|
243
286
|
return {
|
|
244
287
|
queryScope: index.queryScope,
|
|
288
|
+
apiScope: index.apiScope,
|
|
289
|
+
density: index.density,
|
|
290
|
+
multikey: index.multikey,
|
|
291
|
+
unique: index.unique,
|
|
245
292
|
fields: [
|
|
246
293
|
{
|
|
247
294
|
fieldPath: spec.fieldPath,
|
|
@@ -278,13 +325,28 @@ class FirestoreApi {
|
|
|
278
325
|
return this.apiClient.post(url, {
|
|
279
326
|
fields: index.fields,
|
|
280
327
|
queryScope: index.queryScope,
|
|
328
|
+
apiScope: index.apiScope,
|
|
329
|
+
density: index.density,
|
|
330
|
+
multikey: index.multikey,
|
|
331
|
+
unique: index.unique,
|
|
281
332
|
});
|
|
282
333
|
}
|
|
283
334
|
deleteIndex(index) {
|
|
284
335
|
const url = index.name;
|
|
285
336
|
return this.apiClient.delete(`/${url}`);
|
|
286
337
|
}
|
|
287
|
-
|
|
338
|
+
optionalApiScopeMatches(lhs, rhs) {
|
|
339
|
+
return (0, functional_1.optionalValueMatches)(lhs, rhs, types.ApiScope.ANY_API);
|
|
340
|
+
}
|
|
341
|
+
optionalDensityMatches(lhs, rhs, edition) {
|
|
342
|
+
const defaultValue = edition === api_types_1.DatabaseEdition.STANDARD ? types.Density.SPARSE_ALL : types.Density.DENSE;
|
|
343
|
+
return (0, functional_1.optionalValueMatches)(lhs, rhs, defaultValue);
|
|
344
|
+
}
|
|
345
|
+
optionalMultikeyMatches(lhs, rhs) {
|
|
346
|
+
const defaultValue = false;
|
|
347
|
+
return (0, functional_1.optionalValueMatches)(lhs, rhs, defaultValue);
|
|
348
|
+
}
|
|
349
|
+
indexMatchesSpec(index, spec, edition) {
|
|
288
350
|
const collection = util.parseIndexName(index.name).collectionGroupId;
|
|
289
351
|
if (collection !== spec.collectionGroup) {
|
|
290
352
|
return false;
|
|
@@ -292,6 +354,15 @@ class FirestoreApi {
|
|
|
292
354
|
if (index.queryScope !== spec.queryScope) {
|
|
293
355
|
return false;
|
|
294
356
|
}
|
|
357
|
+
if (!this.optionalApiScopeMatches(index.apiScope, spec.apiScope)) {
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
if (!this.optionalDensityMatches(index.density, spec.density, edition)) {
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
if (!this.optionalMultikeyMatches(index.multikey, spec.multikey)) {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
295
366
|
if (index.fields.length !== spec.fields.length) {
|
|
296
367
|
return false;
|
|
297
368
|
}
|
|
@@ -308,6 +379,9 @@ class FirestoreApi {
|
|
|
308
379
|
if (iField.arrayConfig !== sField.arrayConfig) {
|
|
309
380
|
return false;
|
|
310
381
|
}
|
|
382
|
+
if (!utils.deepEqual(iField.vectorConfig, sField.vectorConfig)) {
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
311
385
|
i++;
|
|
312
386
|
}
|
|
313
387
|
return true;
|
|
@@ -364,8 +438,19 @@ class FirestoreApi {
|
|
|
364
438
|
const i = {
|
|
365
439
|
collectionGroup: index.collectionGroup || index.collectionId,
|
|
366
440
|
queryScope: index.queryScope || types.QueryScope.COLLECTION,
|
|
367
|
-
fields: [],
|
|
368
441
|
};
|
|
442
|
+
if (index.apiScope) {
|
|
443
|
+
i.apiScope = index.apiScope;
|
|
444
|
+
}
|
|
445
|
+
if (index.density) {
|
|
446
|
+
i.density = index.density;
|
|
447
|
+
}
|
|
448
|
+
if (index.multikey !== undefined) {
|
|
449
|
+
i.multikey = index.multikey;
|
|
450
|
+
}
|
|
451
|
+
if (index.unique !== undefined) {
|
|
452
|
+
i.unique = index.unique;
|
|
453
|
+
}
|
|
369
454
|
if (index.fields) {
|
|
370
455
|
i.fields = index.fields.map((field) => {
|
|
371
456
|
const f = {
|
|
@@ -425,6 +510,7 @@ class FirestoreApi {
|
|
|
425
510
|
const payload = {
|
|
426
511
|
locationId: req.locationId,
|
|
427
512
|
type: req.type,
|
|
513
|
+
databaseEdition: req.databaseEdition,
|
|
428
514
|
deleteProtectionState: req.deleteProtectionState,
|
|
429
515
|
pointInTimeRecoveryEnablement: req.pointInTimeRecoveryEnablement,
|
|
430
516
|
cmekConfig: req.cmekConfig,
|
|
@@ -459,6 +545,18 @@ class FirestoreApi {
|
|
|
459
545
|
}
|
|
460
546
|
return database;
|
|
461
547
|
}
|
|
548
|
+
async bulkDeleteDocuments(project, databaseId, collectionIds) {
|
|
549
|
+
const name = `/projects/${project}/databases/${databaseId}`;
|
|
550
|
+
const url = `${name}:bulkDeleteDocuments`;
|
|
551
|
+
const payload = {
|
|
552
|
+
name,
|
|
553
|
+
collectionIds,
|
|
554
|
+
};
|
|
555
|
+
const res = await this.apiClient.post(url, payload);
|
|
556
|
+
return {
|
|
557
|
+
name: res.body?.name,
|
|
558
|
+
};
|
|
559
|
+
}
|
|
462
560
|
async restoreDatabase(project, databaseId, backupName, encryptionConfig) {
|
|
463
561
|
const url = `/projects/${project}/databases:restore`;
|
|
464
562
|
const payload = {
|
|
@@ -474,5 +572,36 @@ class FirestoreApi {
|
|
|
474
572
|
}
|
|
475
573
|
return database;
|
|
476
574
|
}
|
|
575
|
+
async listOperations(project, databaseId, limit) {
|
|
576
|
+
const url = `/projects/${project}/databases/${databaseId}/operations`;
|
|
577
|
+
const res = await this.apiClient.get(url, {
|
|
578
|
+
queryParams: {
|
|
579
|
+
pageSize: limit,
|
|
580
|
+
},
|
|
581
|
+
});
|
|
582
|
+
return res.body;
|
|
583
|
+
}
|
|
584
|
+
async describeOperation(project, databaseId, operationName) {
|
|
585
|
+
const url = `/projects/${project}/databases/${databaseId}/operations/${operationName}`;
|
|
586
|
+
const res = await this.apiClient.get(url);
|
|
587
|
+
return res.body;
|
|
588
|
+
}
|
|
589
|
+
async cancelOperation(project, databaseId, operationName) {
|
|
590
|
+
const url = `/projects/${project}/databases/${databaseId}/operations/${operationName}:cancel`;
|
|
591
|
+
try {
|
|
592
|
+
const res = await this.apiClient.post(url);
|
|
593
|
+
return { success: res.status === 200 };
|
|
594
|
+
}
|
|
595
|
+
catch (error) {
|
|
596
|
+
const reason = "Cannot cancel an operation that is completed.";
|
|
597
|
+
const details = error.context?.body?.error?.details || [];
|
|
598
|
+
for (const detail of details) {
|
|
599
|
+
if (detail.detail?.includes(reason)) {
|
|
600
|
+
throw new error_1.FirebaseError(reason);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
throw error;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
477
606
|
}
|
|
478
607
|
exports.FirestoreApi = FirestoreApi;
|