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
|
@@ -41,7 +41,11 @@ class PrettyPrint {
|
|
|
41
41
|
head: ["Field", "Value"],
|
|
42
42
|
colWidths: [30, colValueWidth],
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
const edition = !database.databaseEdition ||
|
|
45
|
+
database.databaseEdition === types.DatabaseEdition.DATABASE_EDITION_UNSPECIFIED
|
|
46
|
+
? types.DatabaseEdition.STANDARD
|
|
47
|
+
: database.databaseEdition;
|
|
48
|
+
table.push(["Name", clc.yellow(database.name)], ["Create Time", clc.yellow(database.createTime)], ["Last Update Time", clc.yellow(database.updateTime)], ["Type", clc.yellow(database.type)], ["Edition", clc.yellow(edition)], ["Location", clc.yellow(database.locationId)], ["Delete Protection State", clc.yellow(database.deleteProtectionState)], ["Point In Time Recovery", clc.yellow(database.pointInTimeRecoveryEnablement)], ["Earliest Version Time", clc.yellow(database.earliestVersionTime)], ["Version Retention Period", clc.yellow(database.versionRetentionPeriod)]);
|
|
45
49
|
if (database.cmekConfig) {
|
|
46
50
|
table.push(["KMS Key Name", clc.yellow(database.cmekConfig.kmsKeyName)]);
|
|
47
51
|
if (database.cmekConfig.activeKeyVersion) {
|
|
@@ -116,6 +120,29 @@ class PrettyPrint {
|
|
|
116
120
|
table.push(["Name", clc.yellow(backup.name)], ["Database", clc.yellow(backup.database)], ["Database UID", clc.yellow(backup.databaseUid)], ["State", clc.yellow(backup.state)], ["Snapshot Time", clc.yellow(backup.snapshotTime)], ["Expire Time", clc.yellow(backup.expireTime)], ["Stats", clc.yellow(backup.stats)]);
|
|
117
121
|
logger_1.logger.info(table.toString());
|
|
118
122
|
}
|
|
123
|
+
prettyPrintOperation(operation) {
|
|
124
|
+
const table = new Table({
|
|
125
|
+
head: ["Operation", ""],
|
|
126
|
+
});
|
|
127
|
+
table.push(["Name", clc.yellow(operation.name)], ["Done?", clc.yellow(operation.done ? "YES" : "NO")], ["Metadata", clc.yellow(JSON.stringify(operation.metadata, undefined, 2))]);
|
|
128
|
+
if (operation.response) {
|
|
129
|
+
table.push(["Response", clc.yellow(JSON.stringify(operation.response, undefined, 2))]);
|
|
130
|
+
}
|
|
131
|
+
logger_1.logger.info(table.toString());
|
|
132
|
+
}
|
|
133
|
+
prettyPrintOperations(operations) {
|
|
134
|
+
if (operations.length === 0) {
|
|
135
|
+
logger_1.logger.info("No operations found.");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const table = new Table({
|
|
139
|
+
head: ["Operation Name", "Done"],
|
|
140
|
+
});
|
|
141
|
+
for (const op of operations) {
|
|
142
|
+
table.push([clc.yellow(op.name), op.done ? clc.green("YES") : clc.yellow("NO")]);
|
|
143
|
+
}
|
|
144
|
+
logger_1.logger.info(table.toString());
|
|
145
|
+
}
|
|
119
146
|
prettyPrintLocations(locations) {
|
|
120
147
|
if (locations.length === 0) {
|
|
121
148
|
logger_1.logger.info("No Locations Available");
|
|
@@ -173,6 +200,13 @@ class PrettyPrint {
|
|
|
173
200
|
}
|
|
174
201
|
result += `(${field.fieldPath},${configString}) `;
|
|
175
202
|
});
|
|
203
|
+
result += " -- ";
|
|
204
|
+
if (index.density !== undefined) {
|
|
205
|
+
result += clc.cyan(`Density:${index.density} `);
|
|
206
|
+
}
|
|
207
|
+
if (index.multikey !== undefined) {
|
|
208
|
+
result += clc.cyan(`Multikey:${index.multikey ? "YES" : "NO"}`);
|
|
209
|
+
}
|
|
176
210
|
return result;
|
|
177
211
|
}
|
|
178
212
|
prettyBackupString(backup) {
|
|
@@ -26,7 +26,7 @@ exports.assertHasOneOf = assertHasOneOf;
|
|
|
26
26
|
function assertEnum(obj, prop, valid) {
|
|
27
27
|
const objString = clc.cyan(JSON.stringify(obj));
|
|
28
28
|
if (valid.indexOf(obj[prop]) < 0) {
|
|
29
|
-
throw new error_1.FirebaseError(`Field "${prop}" must be one of
|
|
29
|
+
throw new error_1.FirebaseError(`Field "${prop}" must be one of ${valid.join(", ")}: ${objString}`);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
exports.assertEnum = assertEnum;
|
package/lib/functional.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nullsafeVisitor = exports.mapObject = exports.partitionRecord = exports.partition = exports.assertExhaustive = exports.zipIn = exports.zip = exports.reduceFlat = exports.flatten = exports.flattenArray = exports.flattenObject = void 0;
|
|
3
|
+
exports.optionalValueMatches = exports.nullsafeVisitor = exports.mapObject = exports.partitionRecord = exports.partition = exports.assertExhaustive = exports.zipIn = exports.zip = exports.reduceFlat = exports.flatten = exports.flattenArray = exports.flattenObject = void 0;
|
|
4
4
|
function* flattenObject(obj) {
|
|
5
5
|
function* helper(path, obj) {
|
|
6
6
|
for (const [k, v] of Object.entries(obj)) {
|
|
@@ -85,3 +85,9 @@ const nullsafeVisitor = (func, ...rest) => (first) => {
|
|
|
85
85
|
return func(first, ...rest);
|
|
86
86
|
};
|
|
87
87
|
exports.nullsafeVisitor = nullsafeVisitor;
|
|
88
|
+
function optionalValueMatches(lhs, rhs, defaultValue) {
|
|
89
|
+
lhs = lhs === undefined ? defaultValue : lhs;
|
|
90
|
+
rhs = rhs === undefined ? defaultValue : rhs;
|
|
91
|
+
return lhs === rhs;
|
|
92
|
+
}
|
|
93
|
+
exports.optionalValueMatches = optionalValueMatches;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logFunctionsConfigDeprecationWarning = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const FUNCTIONS_CONFIG_DEPRECATION_MESSAGE = `DEPRECATION NOTICE: Action required to deploy after March 2026
|
|
6
|
+
|
|
7
|
+
functions.config() API is deprecated.
|
|
8
|
+
Cloud Runtime Configuration API, the Google Cloud service used to store function configuration data, will be shut down in March 2026. As a result, you must migrate away from using functions.config() to continue deploying your functions after March 2026.
|
|
9
|
+
|
|
10
|
+
What this means for you:
|
|
11
|
+
|
|
12
|
+
- The Firebase CLI commands for managing this configuration (functions:config:set, get, unset, clone, and export) are deprecated. These commands will no longer work after March 2026.
|
|
13
|
+
- firebase deploy command will fail for functions that use the legacy functions.config() API after March 2026.
|
|
14
|
+
|
|
15
|
+
Existing deployments will continue to work with their current configuration.
|
|
16
|
+
|
|
17
|
+
See your migration options at: https://firebase.google.com/docs/functions/config-env#migrate-to-dotenv`;
|
|
18
|
+
function logFunctionsConfigDeprecationWarning() {
|
|
19
|
+
(0, utils_1.logWarningToStderr)(FUNCTIONS_CONFIG_DEPRECATION_MESSAGE);
|
|
20
|
+
}
|
|
21
|
+
exports.logFunctionsConfigDeprecationWarning = logFunctionsConfigDeprecationWarning;
|
package/lib/functions/env.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadFirebaseEnvs = exports.loadUserEnvs = exports.checkForDuplicateKeys = exports.writeUserEnvs = exports.hasUserEnvs = exports.parseStrict = exports.validateKey = exports.KeyValidationError = exports.parse = void 0;
|
|
3
|
+
exports.writeResolvedParams = exports.loadFirebaseEnvs = exports.loadUserEnvs = exports.checkForDuplicateKeys = exports.writeUserEnvs = exports.hasUserEnvs = exports.parseStrict = exports.validateKey = exports.KeyValidationError = exports.parse = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
@@ -140,7 +140,7 @@ function parseStrict(data) {
|
|
|
140
140
|
return envs;
|
|
141
141
|
}
|
|
142
142
|
exports.parseStrict = parseStrict;
|
|
143
|
-
function findEnvfiles(
|
|
143
|
+
function findEnvfiles(configDir, projectId, projectAlias, isEmulator) {
|
|
144
144
|
const files = [".env"];
|
|
145
145
|
files.push(`.env.${projectId}`);
|
|
146
146
|
if (projectAlias) {
|
|
@@ -150,26 +150,28 @@ function findEnvfiles(functionsSource, projectId, projectAlias, isEmulator) {
|
|
|
150
150
|
files.push(FUNCTIONS_EMULATOR_DOTENV);
|
|
151
151
|
}
|
|
152
152
|
return files
|
|
153
|
-
.map((f) => path.join(
|
|
153
|
+
.map((f) => path.join(configDir, f))
|
|
154
154
|
.filter(fs.existsSync)
|
|
155
155
|
.map((p) => path.basename(p));
|
|
156
156
|
}
|
|
157
|
-
function hasUserEnvs(
|
|
158
|
-
|
|
157
|
+
function hasUserEnvs(opts) {
|
|
158
|
+
const configDir = opts.configDir || opts.functionsSource;
|
|
159
|
+
return findEnvfiles(configDir, opts.projectId, opts.projectAlias, opts.isEmulator).length > 0;
|
|
159
160
|
}
|
|
160
161
|
exports.hasUserEnvs = hasUserEnvs;
|
|
161
162
|
function writeUserEnvs(toWrite, envOpts) {
|
|
162
163
|
if (Object.keys(toWrite).length === 0) {
|
|
163
164
|
return;
|
|
164
165
|
}
|
|
165
|
-
const {
|
|
166
|
-
const
|
|
166
|
+
const { projectId, projectAlias, isEmulator } = envOpts;
|
|
167
|
+
const configDir = envOpts.configDir || envOpts.functionsSource;
|
|
168
|
+
const allEnvFiles = findEnvfiles(configDir, projectId, projectAlias, isEmulator);
|
|
167
169
|
const targetEnvFile = envOpts.isEmulator
|
|
168
170
|
? FUNCTIONS_EMULATOR_DOTENV
|
|
169
171
|
: `.env.${envOpts.projectId}`;
|
|
170
172
|
const targetEnvFileExists = allEnvFiles.includes(targetEnvFile);
|
|
171
173
|
if (!targetEnvFileExists) {
|
|
172
|
-
fs.writeFileSync(path.join(
|
|
174
|
+
fs.writeFileSync(path.join(configDir, targetEnvFile), "", { flag: "wx" });
|
|
173
175
|
(0, utils_1.logBullet)(clc.yellow(clc.bold("functions: ")) +
|
|
174
176
|
`Created new local file ${targetEnvFile} to store param values. We suggest explicitly adding or excluding this file from version control.`);
|
|
175
177
|
}
|
|
@@ -186,7 +188,7 @@ function writeUserEnvs(toWrite, envOpts) {
|
|
|
186
188
|
for (const k of Object.keys(toWrite)) {
|
|
187
189
|
lines += formatUserEnvForWrite(k, toWrite[k]);
|
|
188
190
|
}
|
|
189
|
-
fs.appendFileSync(path.join(
|
|
191
|
+
fs.appendFileSync(path.join(configDir, targetEnvFile), lines);
|
|
190
192
|
}
|
|
191
193
|
exports.writeUserEnvs = writeUserEnvs;
|
|
192
194
|
function checkForDuplicateKeys(isEmulator, keys, fullEnv, envsWithoutLocal) {
|
|
@@ -210,21 +212,23 @@ function formatUserEnvForWrite(key, value) {
|
|
|
210
212
|
}
|
|
211
213
|
return `${key}=${escapedValue}\n`;
|
|
212
214
|
}
|
|
213
|
-
function loadUserEnvs(
|
|
214
|
-
const
|
|
215
|
+
function loadUserEnvs(opts) {
|
|
216
|
+
const configDir = opts.configDir || opts.functionsSource;
|
|
217
|
+
const envFiles = findEnvfiles(configDir, opts.projectId, opts.projectAlias, opts.isEmulator);
|
|
215
218
|
if (envFiles.length === 0) {
|
|
216
219
|
return {};
|
|
217
220
|
}
|
|
218
|
-
if (projectAlias) {
|
|
219
|
-
if (envFiles.includes(`.env.${projectId}`) &&
|
|
220
|
-
|
|
221
|
-
|
|
221
|
+
if (opts.projectAlias) {
|
|
222
|
+
if (envFiles.includes(`.env.${opts.projectId}`) &&
|
|
223
|
+
envFiles.includes(`.env.${opts.projectAlias}`)) {
|
|
224
|
+
throw new error_1.FirebaseError(`Can't have both dotenv files with projectId (env.${opts.projectId}) ` +
|
|
225
|
+
`and projectAlias (.env.${opts.projectAlias}) as extensions.`);
|
|
222
226
|
}
|
|
223
227
|
}
|
|
224
228
|
let envs = {};
|
|
225
229
|
for (const f of envFiles) {
|
|
226
230
|
try {
|
|
227
|
-
const data = fs.readFileSync(path.join(
|
|
231
|
+
const data = fs.readFileSync(path.join(configDir, f), "utf8");
|
|
228
232
|
envs = { ...envs, ...parseStrict(data) };
|
|
229
233
|
}
|
|
230
234
|
catch (err) {
|
|
@@ -245,3 +249,14 @@ function loadFirebaseEnvs(firebaseConfig, projectId) {
|
|
|
245
249
|
};
|
|
246
250
|
}
|
|
247
251
|
exports.loadFirebaseEnvs = loadFirebaseEnvs;
|
|
252
|
+
function writeResolvedParams(resolvedEnvs, userEnvs, userEnvOpt) {
|
|
253
|
+
const toWrite = {};
|
|
254
|
+
for (const paramName of Object.keys(resolvedEnvs)) {
|
|
255
|
+
const paramValue = resolvedEnvs[paramName];
|
|
256
|
+
if (!paramValue.internal && !Object.prototype.hasOwnProperty.call(userEnvs, paramName)) {
|
|
257
|
+
toWrite[paramName] = paramValue.toString();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
writeUserEnvs(toWrite, userEnvOpt);
|
|
261
|
+
}
|
|
262
|
+
exports.writeResolvedParams = writeResolvedParams;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configForCodebase = exports.normalizeAndValidate = exports.validate = exports.assertUnique = exports.validateCodebase = exports.normalize = exports.DEFAULT_CODEBASE = void 0;
|
|
3
|
+
exports.resolveConfigDir = exports.requireLocal = exports.isRemoteConfig = exports.isLocalConfig = exports.configForCodebase = exports.normalizeAndValidate = exports.validate = exports.assertUnique = exports.validatePrefix = exports.validateCodebase = exports.normalize = exports.DEFAULT_CODEBASE = void 0;
|
|
4
4
|
const error_1 = require("../error");
|
|
5
5
|
exports.DEFAULT_CODEBASE = "default";
|
|
6
6
|
function normalize(config) {
|
|
@@ -23,15 +23,50 @@ function validateCodebase(codebase) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
exports.validateCodebase = validateCodebase;
|
|
26
|
+
function validatePrefix(prefix) {
|
|
27
|
+
if (prefix.length > 30) {
|
|
28
|
+
throw new error_1.FirebaseError("Invalid prefix. Prefix must be 30 characters or less.");
|
|
29
|
+
}
|
|
30
|
+
if (!/^[a-z](?:[a-z0-9-]*[a-z0-9])?$/.test(prefix)) {
|
|
31
|
+
throw new error_1.FirebaseError("Invalid prefix. Prefix must start with a lowercase letter, can contain only lowercase letters, numeric characters, and dashes, and cannot start or end with a dash.");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.validatePrefix = validatePrefix;
|
|
26
35
|
function validateSingle(config) {
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
const { source, remoteSource, runtime, codebase: providedCodebase, ...rest } = config;
|
|
37
|
+
if (source && remoteSource) {
|
|
38
|
+
throw new error_1.FirebaseError("Cannot specify both 'source' and 'remoteSource' in a single functions config. Please choose one.");
|
|
39
|
+
}
|
|
40
|
+
if (!source && !remoteSource) {
|
|
41
|
+
throw new error_1.FirebaseError("codebase source must be specified. Must specify either 'source' or 'remoteSource' in a functions config.");
|
|
42
|
+
}
|
|
43
|
+
const codebase = providedCodebase ?? exports.DEFAULT_CODEBASE;
|
|
44
|
+
validateCodebase(codebase);
|
|
45
|
+
if (config.prefix) {
|
|
46
|
+
validatePrefix(config.prefix);
|
|
29
47
|
}
|
|
30
|
-
|
|
31
|
-
|
|
48
|
+
const commonConfig = { codebase, ...rest };
|
|
49
|
+
if (source) {
|
|
50
|
+
return {
|
|
51
|
+
...commonConfig,
|
|
52
|
+
source,
|
|
53
|
+
...(runtime ? { runtime } : {}),
|
|
54
|
+
};
|
|
32
55
|
}
|
|
33
|
-
|
|
34
|
-
|
|
56
|
+
else if (remoteSource) {
|
|
57
|
+
if (!remoteSource.repository || !remoteSource.ref) {
|
|
58
|
+
throw new error_1.FirebaseError("remoteSource requires 'repository' and 'ref' to be specified.");
|
|
59
|
+
}
|
|
60
|
+
if (!runtime) {
|
|
61
|
+
throw new error_1.FirebaseError("functions.runtime is required when using remoteSource in firebase.json.");
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
...commonConfig,
|
|
65
|
+
remoteSource,
|
|
66
|
+
runtime,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
throw new error_1.FirebaseError("Invalid functions config.");
|
|
35
70
|
}
|
|
36
71
|
function assertUnique(config, property, propval) {
|
|
37
72
|
const values = new Set();
|
|
@@ -47,10 +82,33 @@ function assertUnique(config, property, propval) {
|
|
|
47
82
|
}
|
|
48
83
|
}
|
|
49
84
|
exports.assertUnique = assertUnique;
|
|
85
|
+
function assertUniqueSourcePrefixPair(config) {
|
|
86
|
+
const sourcePrefixPairs = new Set();
|
|
87
|
+
for (const c of config) {
|
|
88
|
+
let sourceIdentifier;
|
|
89
|
+
let sourceDescription;
|
|
90
|
+
if (c.source) {
|
|
91
|
+
sourceIdentifier = c.source;
|
|
92
|
+
sourceDescription = `source directory ('${c.source}')`;
|
|
93
|
+
}
|
|
94
|
+
else if (c.remoteSource) {
|
|
95
|
+
sourceIdentifier = `remote:${c.remoteSource.repository}#${c.remoteSource.ref}@dir:${c.remoteSource.dir || "."}`;
|
|
96
|
+
sourceDescription = `remote source ('${c.remoteSource.repository}')`;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const key = JSON.stringify({ source: sourceIdentifier, prefix: c.prefix || "" });
|
|
102
|
+
if (sourcePrefixPairs.has(key)) {
|
|
103
|
+
throw new error_1.FirebaseError(`More than one functions config specifies the same ${sourceDescription} and prefix ('${c.prefix ?? ""}'). Please add a unique 'prefix' to each function configuration that shares this source to resolve the conflict.`);
|
|
104
|
+
}
|
|
105
|
+
sourcePrefixPairs.add(key);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
50
108
|
function validate(config) {
|
|
51
109
|
const validated = config.map((cfg) => validateSingle(cfg));
|
|
52
|
-
assertUnique(validated, "source");
|
|
53
110
|
assertUnique(validated, "codebase");
|
|
111
|
+
assertUniqueSourcePrefixPair(validated);
|
|
54
112
|
return validated;
|
|
55
113
|
}
|
|
56
114
|
exports.validate = validate;
|
|
@@ -66,3 +124,24 @@ function configForCodebase(config, codebase) {
|
|
|
66
124
|
return codebaseCfg;
|
|
67
125
|
}
|
|
68
126
|
exports.configForCodebase = configForCodebase;
|
|
127
|
+
function isLocalConfig(c) {
|
|
128
|
+
return c.source !== undefined;
|
|
129
|
+
}
|
|
130
|
+
exports.isLocalConfig = isLocalConfig;
|
|
131
|
+
function isRemoteConfig(c) {
|
|
132
|
+
return c.remoteSource !== undefined;
|
|
133
|
+
}
|
|
134
|
+
exports.isRemoteConfig = isRemoteConfig;
|
|
135
|
+
function requireLocal(c, purpose) {
|
|
136
|
+
if (!isLocalConfig(c)) {
|
|
137
|
+
const msg = purpose ??
|
|
138
|
+
"This operation requires a local functions source directory, but the codebase is configured with a remote source.";
|
|
139
|
+
throw new error_1.FirebaseError(msg);
|
|
140
|
+
}
|
|
141
|
+
return c;
|
|
142
|
+
}
|
|
143
|
+
exports.requireLocal = requireLocal;
|
|
144
|
+
function resolveConfigDir(c) {
|
|
145
|
+
return c.configDir || c.source;
|
|
146
|
+
}
|
|
147
|
+
exports.resolveConfigDir = resolveConfigDir;
|
package/lib/functions/secrets.js
CHANGED
|
@@ -250,6 +250,9 @@ async function updateEndpointSecret(projectInfo, secretVersion, endpoint) {
|
|
|
250
250
|
});
|
|
251
251
|
return gcfV2.endpointFromFunction(cfn);
|
|
252
252
|
}
|
|
253
|
+
else if (endpoint.platform === "run") {
|
|
254
|
+
throw new error_1.FirebaseError("Updating Cloud Run functions is not yet implemented.");
|
|
255
|
+
}
|
|
253
256
|
else {
|
|
254
257
|
(0, functional_1.assertExhaustive)(endpoint.platform);
|
|
255
258
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.functionFromEndpoint = exports.endpointFromFunction = exports.listAllFunctions = exports.
|
|
3
|
+
exports.functionFromEndpoint = exports.endpointFromFunction = exports.listAllFunctions = exports.deleteFunction = exports.updateFunction = exports.setInvokerUpdate = exports.setInvokerCreate = exports.getIamPolicy = exports.setIamPolicy = exports.createFunction = exports.generateUploadUrl = exports.captureRuntimeValidationError = exports.API_VERSION = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const error_1 = require("../error");
|
|
6
6
|
const logger_1 = require("../logger");
|
|
@@ -203,11 +203,6 @@ async function list(projectId, region) {
|
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
async function listFunctions(projectId, region) {
|
|
207
|
-
const res = await list(projectId, region);
|
|
208
|
-
return res.functions;
|
|
209
|
-
}
|
|
210
|
-
exports.listFunctions = listFunctions;
|
|
211
206
|
async function listAllFunctions(projectId) {
|
|
212
207
|
return list(projectId, "-");
|
|
213
208
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.endpointFromFunction = exports.functionFromEndpoint = exports.deleteFunction = exports.updateFunction = exports.listAllFunctions = exports.
|
|
3
|
+
exports.endpointFromFunction = exports.functionFromEndpoint = exports.deleteFunction = exports.updateFunction = exports.listAllFunctions = exports.getFunction = exports.createFunction = exports.generateUploadUrl = exports.API_VERSION = void 0;
|
|
4
4
|
const apiv2_1 = require("../apiv2");
|
|
5
5
|
const error_1 = require("../error");
|
|
6
6
|
const api_1 = require("../api");
|
|
@@ -13,6 +13,7 @@ const utils = require("../utils");
|
|
|
13
13
|
const projectConfig = require("../functions/projectConfig");
|
|
14
14
|
const constants_1 = require("../functions/constants");
|
|
15
15
|
const cloudfunctions_1 = require("./cloudfunctions");
|
|
16
|
+
const k8s_1 = require("./k8s");
|
|
16
17
|
exports.API_VERSION = "v2";
|
|
17
18
|
const DEFAULT_MAX_INSTANCE_COUNT = 100;
|
|
18
19
|
const client = new apiv2_1.Client({
|
|
@@ -20,35 +21,6 @@ const client = new apiv2_1.Client({
|
|
|
20
21
|
auth: true,
|
|
21
22
|
apiVersion: exports.API_VERSION,
|
|
22
23
|
});
|
|
23
|
-
const BYTES_PER_UNIT = {
|
|
24
|
-
"": 1,
|
|
25
|
-
k: 1e3,
|
|
26
|
-
M: 1e6,
|
|
27
|
-
G: 1e9,
|
|
28
|
-
T: 1e12,
|
|
29
|
-
Ki: 1 << 10,
|
|
30
|
-
Mi: 1 << 20,
|
|
31
|
-
Gi: 1 << 30,
|
|
32
|
-
Ti: 1 << 40,
|
|
33
|
-
};
|
|
34
|
-
function mebibytes(memory) {
|
|
35
|
-
const re = /^([0-9]+(\.[0-9]*)?)(Ki|Mi|Gi|Ti|k|M|G|T|([eE]([0-9]+)))?$/;
|
|
36
|
-
const matches = re.exec(memory);
|
|
37
|
-
if (!matches) {
|
|
38
|
-
throw new Error(`Invalid memory quantity "${memory}""`);
|
|
39
|
-
}
|
|
40
|
-
const quantity = Number.parseFloat(matches[1]);
|
|
41
|
-
let bytes;
|
|
42
|
-
if (matches[5]) {
|
|
43
|
-
bytes = quantity * Math.pow(10, Number.parseFloat(matches[5]));
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
const suffix = matches[3] || "";
|
|
47
|
-
bytes = quantity * BYTES_PER_UNIT[suffix];
|
|
48
|
-
}
|
|
49
|
-
return bytes / (1 << 20);
|
|
50
|
-
}
|
|
51
|
-
exports.mebibytes = mebibytes;
|
|
52
24
|
function functionsOpLogReject(func, type, err) {
|
|
53
25
|
if (err?.message?.includes("Runtime validation errors")) {
|
|
54
26
|
const capturedMessage = (0, cloudfunctions_1.captureRuntimeValidationError)(err.message);
|
|
@@ -118,14 +90,6 @@ async function getFunction(projectId, location, functionId) {
|
|
|
118
90
|
return res.body;
|
|
119
91
|
}
|
|
120
92
|
exports.getFunction = getFunction;
|
|
121
|
-
async function listFunctions(projectId, region) {
|
|
122
|
-
const res = await listFunctionsInternal(projectId, region);
|
|
123
|
-
if (res.unreachable.includes(region)) {
|
|
124
|
-
throw new error_1.FirebaseError(`Cloud Functions region ${region} is unavailable`);
|
|
125
|
-
}
|
|
126
|
-
return res.functions;
|
|
127
|
-
}
|
|
128
|
-
exports.listFunctions = listFunctions;
|
|
129
93
|
async function listAllFunctions(projectId) {
|
|
130
94
|
return await listFunctionsInternal(projectId, "-");
|
|
131
95
|
}
|
|
@@ -390,7 +354,7 @@ function endpointFromFunction(gcfFunction) {
|
|
|
390
354
|
logger_1.logger.debug("Prod should always return a valid memory amount");
|
|
391
355
|
return prod;
|
|
392
356
|
}
|
|
393
|
-
const mem = mebibytes(prod);
|
|
357
|
+
const mem = (0, k8s_1.mebibytes)(prod);
|
|
394
358
|
if (!backend.isValidMemoryOption(mem)) {
|
|
395
359
|
logger_1.logger.debug("Converting a function to an endpoint with an invalid memory option", mem);
|
|
396
360
|
}
|
|
@@ -123,7 +123,7 @@ async function jobFromEndpoint(endpoint, location, projectNumber) {
|
|
|
123
123
|
},
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
-
else if (endpoint.platform === "gcfv2") {
|
|
126
|
+
else if (endpoint.platform === "gcfv2" || endpoint.platform === "run") {
|
|
127
127
|
job.timeZone = endpoint.scheduleTrigger.timeZone || DEFAULT_TIME_ZONE_V2;
|
|
128
128
|
job.httpTarget = {
|
|
129
129
|
uri: endpoint.uri,
|
|
@@ -54,9 +54,8 @@ async function createInstance(args) {
|
|
|
54
54
|
if (args.enableGoogleMlIntegration) {
|
|
55
55
|
databaseFlags.push({ name: "cloudsql.enable_google_ml_integration", value: "on" });
|
|
56
56
|
}
|
|
57
|
-
let op;
|
|
58
57
|
try {
|
|
59
|
-
|
|
58
|
+
await client.post(`projects/${args.projectId}/instances`, {
|
|
60
59
|
name: args.instanceId,
|
|
61
60
|
region: args.location,
|
|
62
61
|
databaseVersion: "POSTGRES_15",
|
|
@@ -77,23 +76,12 @@ async function createInstance(args) {
|
|
|
77
76
|
},
|
|
78
77
|
},
|
|
79
78
|
});
|
|
79
|
+
return;
|
|
80
80
|
}
|
|
81
81
|
catch (err) {
|
|
82
82
|
handleAllowlistError(err, args.location);
|
|
83
83
|
throw err;
|
|
84
84
|
}
|
|
85
|
-
if (!args.waitForCreation) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const opName = `projects/${args.projectId}/operations/${op.body.name}`;
|
|
89
|
-
const pollRes = await operationPoller.pollOperation({
|
|
90
|
-
apiOrigin: (0, api_1.cloudSQLAdminOrigin)(),
|
|
91
|
-
apiVersion: API_VERSION,
|
|
92
|
-
operationResourceName: opName,
|
|
93
|
-
doneFn: (op) => op.status === "DONE",
|
|
94
|
-
masterTimeout: 1200000,
|
|
95
|
-
});
|
|
96
|
-
return pollRes;
|
|
97
85
|
}
|
|
98
86
|
exports.createInstance = createInstance;
|
|
99
87
|
async function updateInstanceForDataConnect(instance, enableGoogleMlIntegration) {
|
|
@@ -162,7 +150,7 @@ async function deleteDatabase(projectId, instanceId, databaseId) {
|
|
|
162
150
|
return res.body;
|
|
163
151
|
}
|
|
164
152
|
exports.deleteDatabase = deleteDatabase;
|
|
165
|
-
async function createUser(projectId, instanceId, type, username, password) {
|
|
153
|
+
async function createUser(projectId, instanceId, type, username, password, retryTimeout) {
|
|
166
154
|
const maxRetries = 3;
|
|
167
155
|
let retries = 0;
|
|
168
156
|
while (true) {
|
|
@@ -191,7 +179,7 @@ async function createUser(projectId, instanceId, type, username, password) {
|
|
|
191
179
|
if (builtinRoleNotReady(err.message) && retries < maxRetries) {
|
|
192
180
|
retries++;
|
|
193
181
|
await new Promise((resolve) => {
|
|
194
|
-
setTimeout(resolve, 1000 * retries);
|
|
182
|
+
setTimeout(resolve, retryTimeout ?? 1000 * retries);
|
|
195
183
|
});
|
|
196
184
|
}
|
|
197
185
|
else {
|
|
@@ -85,7 +85,7 @@ async function execute(sqlStatements, opts) {
|
|
|
85
85
|
sqlStatements.push("COMMIT;");
|
|
86
86
|
}
|
|
87
87
|
for (const s of sqlStatements) {
|
|
88
|
-
logFn(
|
|
88
|
+
logFn(`> ${s}`);
|
|
89
89
|
try {
|
|
90
90
|
results.push(await conn.query(s));
|
|
91
91
|
}
|
|
@@ -97,6 +97,7 @@ async function execute(sqlStatements, opts) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
await cleanUpFn();
|
|
100
|
+
logFn(``);
|
|
100
101
|
return results;
|
|
101
102
|
}
|
|
102
103
|
exports.execute = execute;
|
|
@@ -116,7 +117,7 @@ exports.executeSqlCmdsAsIamUser = executeSqlCmdsAsIamUser;
|
|
|
116
117
|
async function executeSqlCmdsAsSuperUser(options, instanceId, databaseId, cmds, silent = false, transaction = false) {
|
|
117
118
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
118
119
|
const superuser = "firebasesuperuser";
|
|
119
|
-
const temporaryPassword = utils.
|
|
120
|
+
const temporaryPassword = utils.generatePassword(20);
|
|
120
121
|
await cloudSqlAdminClient.createUser(projectId, instanceId, "BUILT_IN", superuser, temporaryPassword);
|
|
121
122
|
return await execute([`SET ROLE = '${superuser}'`, ...cmds], {
|
|
122
123
|
projectId,
|
|
@@ -141,7 +142,7 @@ async function getIAMUser(options) {
|
|
|
141
142
|
return toDatabaseUser(account);
|
|
142
143
|
}
|
|
143
144
|
exports.getIAMUser = getIAMUser;
|
|
144
|
-
async function setupIAMUsers(instanceId,
|
|
145
|
+
async function setupIAMUsers(instanceId, options) {
|
|
145
146
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
146
147
|
const { user, mode } = await getIAMUser(options);
|
|
147
148
|
await cloudSqlAdminClient.createUser(projectId, instanceId, mode, user);
|