firebase-tools-with-isolate 13.16.0 → 13.26.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 +3 -1
- package/lib/apiv2.js +10 -3
- package/lib/appdistribution/client.js +62 -8
- package/lib/appdistribution/distribution.js +1 -1
- package/lib/apphosting/backend.js +299 -0
- package/lib/apphosting/config.js +31 -8
- package/lib/apphosting/githubConnections.js +70 -22
- package/lib/apphosting/index.js +3 -312
- package/lib/apphosting/rollout.js +138 -0
- package/lib/apphosting/secrets/index.js +70 -5
- package/lib/apphosting/utils.js +41 -0
- package/lib/apphosting/yaml.js +82 -0
- package/lib/archiveDirectory.js +1 -1
- package/lib/auth.js +31 -5
- package/lib/bin/firebase.js +2 -2
- package/lib/command.js +18 -4
- package/lib/commands/appdistribution-distribute.js +4 -4
- package/lib/commands/{appdistribution-group-create.js → appdistribution-groups-create.js} +2 -1
- package/lib/commands/{appdistribution-group-delete.js → appdistribution-groups-delete.js} +3 -2
- package/lib/commands/appdistribution-groups-list.js +55 -0
- package/lib/commands/appdistribution-testers-list.js +52 -0
- package/lib/commands/appdistribution-testers-remove.js +1 -1
- package/lib/commands/apphosting-backends-create.js +4 -4
- package/lib/commands/apphosting-backends-delete.js +7 -15
- package/lib/commands/apphosting-backends-get.js +1 -1
- package/lib/commands/apphosting-config-export.js +51 -0
- package/lib/commands/apphosting-repos-create.js +23 -0
- package/lib/commands/apphosting-rollouts-create.js +14 -15
- package/lib/commands/apphosting-secrets-grantaccess.js +2 -2
- package/lib/commands/database-import.js +4 -2
- package/lib/commands/database-push.js +4 -2
- package/lib/commands/database-set.js +4 -2
- package/lib/commands/database-settings-get.js +1 -1
- package/lib/commands/database-settings-set.js +1 -1
- package/lib/commands/dataconnect-sdk-generate.js +4 -1
- package/lib/commands/dataconnect-services-list.js +4 -3
- package/lib/commands/dataconnect-sql-diff.js +1 -1
- package/lib/commands/dataconnect-sql-grant.js +37 -0
- package/lib/commands/dataconnect-sql-migrate.js +1 -1
- package/lib/commands/dataconnect-sql-shell.js +115 -0
- package/lib/commands/deploy.js +2 -0
- package/lib/commands/emulators-start.js +4 -1
- package/lib/commands/ext-dev-init.js +2 -2
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-register.js +2 -2
- package/lib/commands/ext-dev-upload.js +2 -2
- package/lib/commands/ext-dev-usage.js +2 -2
- package/lib/commands/ext-info.js +3 -1
- package/lib/commands/ext-install.js +2 -2
- package/lib/commands/ext-sdk-install.js +88 -0
- package/lib/commands/ext.js +1 -0
- package/lib/commands/firestore-databases-restore.js +39 -1
- package/lib/commands/functions-secrets-access.js +2 -4
- package/lib/commands/index.js +15 -2
- package/lib/commands/init.js +25 -15
- package/lib/commands/setup-emulators-dataconnect.js +0 -13
- package/lib/commands/use.js +1 -1
- package/lib/config.js +14 -4
- package/lib/crashlytics/buildToolsJarHelper.js +2 -2
- package/lib/dataconnect/client.js +1 -1
- package/lib/dataconnect/dataplaneClient.js +12 -9
- package/lib/dataconnect/ensureApis.js +6 -1
- package/lib/dataconnect/fileUtils.js +15 -39
- package/lib/dataconnect/freeTrial.js +45 -9
- package/lib/dataconnect/load.js +3 -1
- package/lib/dataconnect/provisionCloudSql.js +39 -26
- package/lib/dataconnect/schemaMigration.js +215 -74
- package/lib/dataconnect/types.js +4 -1
- package/lib/dataconnect/webhook.js +32 -0
- package/lib/deploy/dataconnect/deploy.js +18 -15
- package/lib/deploy/dataconnect/prepare.js +41 -0
- package/lib/deploy/dataconnect/release.js +16 -7
- package/lib/deploy/extensions/deploy.js +3 -1
- package/lib/deploy/extensions/deploymentSummary.js +7 -3
- package/lib/deploy/extensions/planner.js +44 -5
- package/lib/deploy/extensions/prepare.js +45 -73
- package/lib/deploy/extensions/release.js +11 -10
- package/lib/deploy/extensions/tasks.js +32 -21
- package/lib/deploy/firestore/prepare.js +9 -0
- package/lib/deploy/firestore/release.js +3 -6
- package/lib/deploy/functions/checkIam.js +7 -2
- package/lib/deploy/functions/ensure.js +11 -3
- package/lib/deploy/functions/prepare.js +10 -2
- package/lib/deploy/functions/release/planner.js +2 -1
- package/lib/deploy/functions/runtimes/discovery/index.js +6 -2
- package/lib/deploy/functions/runtimes/node/index.js +5 -0
- package/lib/deploy/functions/services/auth.js +34 -3
- package/lib/deploy/functions/services/index.js +2 -0
- package/lib/deploy/index.js +8 -5
- package/lib/deploy/lifecycleHooks.js +2 -1
- package/lib/emulator/apphosting/config.js +27 -0
- package/lib/emulator/apphosting/index.js +38 -0
- package/lib/emulator/apphosting/serve.js +50 -0
- package/lib/emulator/apphosting/utils.js +18 -0
- package/lib/emulator/auth/handlers.js +27 -0
- package/lib/emulator/auth/operations.js +41 -2
- package/lib/emulator/auth/state.js +2 -1
- package/lib/emulator/commandUtils.js +8 -3
- package/lib/emulator/constants.js +4 -1
- package/lib/emulator/controller.js +48 -5
- package/lib/emulator/dataconnect/pg-gateway/auth/base-auth-flow.js +11 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/cert.js +58 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/index.js +22 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/md5.js +124 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/password.js +54 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/sasl-mechanism.js +34 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/scram-sha-256.js +270 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/trust.js +2 -0
- package/lib/emulator/dataconnect/pg-gateway/backend-error.js +75 -0
- package/lib/emulator/dataconnect/pg-gateway/buffer-reader.js +54 -0
- package/lib/emulator/dataconnect/pg-gateway/buffer-writer.js +79 -0
- package/lib/emulator/dataconnect/pg-gateway/connection.js +315 -0
- package/lib/emulator/dataconnect/pg-gateway/connection.types.js +8 -0
- package/lib/emulator/dataconnect/pg-gateway/crypto.js +40 -0
- package/lib/emulator/dataconnect/pg-gateway/duplex.js +53 -0
- package/lib/emulator/dataconnect/pg-gateway/index.js +27 -0
- package/lib/emulator/dataconnect/pg-gateway/message-buffer.js +82 -0
- package/lib/emulator/dataconnect/pg-gateway/message-codes.js +52 -0
- package/lib/emulator/dataconnect/pg-gateway/platforms/node/index.js +16 -0
- package/lib/emulator/dataconnect/pg-gateway/polyfills/readable-stream-async-iterator.js +35 -0
- package/lib/emulator/dataconnect/pg-gateway/utils.js +40 -0
- package/lib/emulator/dataconnect/pgliteServer.js +95 -0
- package/lib/emulator/dataconnectEmulator.js +58 -75
- package/lib/emulator/dataconnectToolkitController.js +44 -0
- package/lib/emulator/downloadableEmulators.js +27 -16
- package/lib/emulator/emulatorLogger.js +3 -0
- package/lib/emulator/eventarcEmulator.js +1 -1
- package/lib/emulator/extensionsEmulator.js +38 -6
- package/lib/emulator/functionsEmulator.js +85 -41
- package/lib/emulator/functionsEmulatorShared.js +2 -1
- package/lib/emulator/functionsRuntimeWorker.js +2 -1
- package/lib/emulator/hub.js +13 -9
- package/lib/emulator/hubExport.js +10 -3
- package/lib/emulator/loggingEmulator.js +2 -2
- package/lib/emulator/portUtils.js +10 -11
- package/lib/emulator/registry.js +1 -0
- package/lib/emulator/storage/persistence.js +2 -2
- package/lib/emulator/storage/rules/runtime.js +1 -1
- package/lib/emulator/tasksEmulator.js +5 -2
- package/lib/emulator/types.js +3 -0
- package/lib/emulator/ui.js +51 -25
- package/lib/error.js +31 -1
- package/lib/experiments.js +5 -0
- package/lib/extensions/emulator/triggerHelper.js +1 -1
- package/lib/extensions/extensionsApi.js +14 -10
- package/lib/extensions/extensionsHelper.js +15 -6
- package/lib/extensions/localHelper.js +31 -0
- package/lib/extensions/runtimes/common.js +179 -39
- package/lib/extensions/runtimes/node.js +401 -0
- package/lib/extensions/types.js +25 -14
- package/lib/extensions/warnings.js +5 -2
- package/lib/firestore/api.js +2 -1
- package/lib/firestore/checkDatabaseType.js +10 -3
- package/lib/firestore/delete.js +11 -0
- package/lib/firestore/options.js +7 -0
- package/lib/frameworks/angular/index.js +15 -3
- package/lib/frameworks/constants.js +1 -1
- package/lib/frameworks/flutter/index.js +6 -6
- package/lib/frameworks/flutter/utils.js +34 -1
- package/lib/frameworks/next/index.js +10 -2
- package/lib/frameworks/next/utils.js +8 -5
- package/lib/frameworks/vite/index.js +2 -2
- package/lib/fsutils.js +13 -1
- package/lib/functions/constants.js +4 -0
- package/lib/functions/events/v1.js +9 -2
- package/lib/gcp/apphosting.js +1 -1
- package/lib/gcp/cloudmonitoring.js +3 -3
- package/lib/gcp/cloudsql/cloudsqladmin.js +32 -20
- package/lib/gcp/cloudsql/connect.js +49 -37
- package/lib/gcp/cloudsql/interactive.js +49 -0
- package/lib/gcp/cloudsql/permissions.js +165 -0
- package/lib/gcp/devConnect.js +38 -1
- package/lib/gcp/firestore.js +5 -1
- package/lib/gcp/secretManager.js +12 -5
- package/lib/getProjectNumber.js +1 -1
- package/lib/init/features/apphosting.js +15 -0
- package/lib/init/features/dataconnect/index.js +159 -120
- package/lib/init/features/dataconnect/sdk.js +77 -84
- package/lib/init/features/emulators.js +2 -15
- package/lib/init/features/firestore/index.js +20 -1
- package/lib/init/features/firestore/indexes.js +4 -4
- package/lib/init/features/genkit/index.js +444 -0
- package/lib/init/features/hosting/index.js +2 -2
- package/lib/init/features/index.js +1 -1
- package/lib/init/features/project.js +6 -6
- package/lib/init/features/storage.js +0 -2
- package/lib/init/index.js +1 -0
- package/lib/init/spawn.js +23 -2
- package/lib/logger.js +2 -2
- package/lib/management/projects.js +24 -4
- package/lib/projectUtils.js +1 -1
- package/lib/prompt.js +1 -1
- package/lib/rc.js +1 -8
- package/lib/requireAuth.js +19 -5
- package/lib/requireDatabaseInstance.js +1 -1
- package/lib/requirePermissions.js +1 -1
- package/lib/responseToError.js +5 -2
- package/lib/rulesDeploy.js +1 -1
- package/lib/templates.js +2 -2
- package/lib/utils.js +16 -11
- package/lib/vsCodeUtils.js +8 -0
- package/package.json +7 -6
- package/schema/connector-yaml.json +57 -17
- package/schema/firebase-config.json +24 -0
- package/templates/extensions/javascript/package.lint.json +2 -2
- package/templates/extensions/javascript/package.nolint.json +2 -2
- package/templates/extensions/typescript/package.lint.json +2 -2
- package/templates/extensions/typescript/package.nolint.json +2 -2
- package/templates/genkit/firebase.0.9.0.template +57 -0
- package/templates/init/apphosting/apphosting.yaml +23 -0
- package/templates/init/dataconnect/connector.yaml +0 -1
- package/templates/init/dataconnect/dataconnect-fdccompatiblemode.yaml +12 -0
- package/templates/init/dataconnect/dataconnect.yaml +1 -1
- package/templates/init/dataconnect/queries.gql +1 -2
- package/templates/init/functions/javascript/package.lint.json +2 -2
- package/templates/init/functions/javascript/package.nolint.json +2 -2
- package/templates/init/functions/typescript/package.lint.json +2 -2
- package/templates/init/functions/typescript/package.nolint.json +2 -2
- package/lib/ensureCloudResourceLocation.js +0 -12
- package/lib/init/features/genkit.js +0 -53
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const semver = require("semver");
|
|
6
|
+
const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
|
|
7
|
+
const command_1 = require("../command");
|
|
8
|
+
const extensionsApi = require("../extensions/extensionsApi");
|
|
9
|
+
const extensionsHelper_1 = require("../extensions/extensionsHelper");
|
|
10
|
+
const localHelper_1 = require("../extensions/localHelper");
|
|
11
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
12
|
+
const common_1 = require("../extensions/runtimes/common");
|
|
13
|
+
const error_1 = require("../error");
|
|
14
|
+
const displayExtensionInfo_1 = require("../extensions/displayExtensionInfo");
|
|
15
|
+
const refs = require("../extensions/refs");
|
|
16
|
+
const logger_1 = require("../logger");
|
|
17
|
+
const prompt_1 = require("../prompt");
|
|
18
|
+
const utils = require("../utils");
|
|
19
|
+
exports.command = new command_1.Command("ext:sdk:install <extensionName>")
|
|
20
|
+
.description("get an SDK for this extension. The SDK will be put in the 'generated' directory")
|
|
21
|
+
.option(`--codebase <codebase>`, `specifies a codebase to install the SDK into`)
|
|
22
|
+
.option(`--force`, `will overwrite existing sdk files if true`)
|
|
23
|
+
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extDevMinVersion")
|
|
24
|
+
.action(async (extensionName, options) => {
|
|
25
|
+
const runtime = await (0, common_1.getCodebaseRuntime)(options);
|
|
26
|
+
if (!runtime.startsWith("nodejs")) {
|
|
27
|
+
throw new error_1.FirebaseError(`Extension SDK generation is currently only supported for NodeJs. We detected the target source to be: ${runtime}`);
|
|
28
|
+
}
|
|
29
|
+
let spec;
|
|
30
|
+
let extensionRef;
|
|
31
|
+
let localPath;
|
|
32
|
+
if ((0, localHelper_1.isLocalExtension)(extensionName)) {
|
|
33
|
+
spec = await (0, localHelper_1.getLocalExtensionSpec)(extensionName);
|
|
34
|
+
spec.systemParams = [];
|
|
35
|
+
localPath = extensionName;
|
|
36
|
+
await (0, displayExtensionInfo_1.displayExtensionVersionInfo)({ spec });
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
await (0, requirePermissions_1.requirePermissions)(options, ["firebaseextensions.sources.get"]);
|
|
40
|
+
await (0, extensionsHelper_1.ensureExtensionsApiEnabled)(options);
|
|
41
|
+
const hasPublisherId = extensionName.split("/").length >= 2;
|
|
42
|
+
if (hasPublisherId) {
|
|
43
|
+
const nameAndVersion = extensionName.split("/")[1];
|
|
44
|
+
if (nameAndVersion.split("@").length < 2) {
|
|
45
|
+
extensionName = extensionName + "@latest";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const [name, version] = extensionName.split("@");
|
|
50
|
+
extensionName = `firebase/${name}@${version || "latest"}`;
|
|
51
|
+
}
|
|
52
|
+
const ref = refs.parse(extensionName);
|
|
53
|
+
const extension = await extensionsApi.getExtension(refs.toExtensionRef(ref));
|
|
54
|
+
const version = await extensionsApi.getExtensionVersion(extensionName);
|
|
55
|
+
spec = version.spec;
|
|
56
|
+
extensionRef = version.ref;
|
|
57
|
+
await (0, displayExtensionInfo_1.displayExtensionVersionInfo)({
|
|
58
|
+
spec,
|
|
59
|
+
extensionVersion: version,
|
|
60
|
+
latestApprovedVersion: extension.latestApprovedVersion,
|
|
61
|
+
latestVersion: extension.latestVersion,
|
|
62
|
+
});
|
|
63
|
+
if (version.state === "DEPRECATED") {
|
|
64
|
+
throw new error_1.FirebaseError(`Extension version ${clc.bold(extensionName)} is deprecated and cannot be installed. To install an SDK for the ` +
|
|
65
|
+
`latest non-deprecated version, omit the version in the extension ref.`);
|
|
66
|
+
}
|
|
67
|
+
logger_1.logger.info();
|
|
68
|
+
if ((extension.latestApprovedVersion &&
|
|
69
|
+
semver.gt(extension.latestApprovedVersion, version.spec.version)) ||
|
|
70
|
+
(!extension.latestApprovedVersion &&
|
|
71
|
+
extension.latestVersion &&
|
|
72
|
+
semver.gt(extension.latestVersion, version.spec.version))) {
|
|
73
|
+
const latest = extension.latestApprovedVersion || extension.latestVersion;
|
|
74
|
+
logger_1.logger.info(`You are about to install an SDK for extension version ${clc.bold(version.spec.version)} which is older than the latest ${extension.latestApprovedVersion ? "accepted version" : "version"} ${clc.bold(latest)}.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (!(await (0, prompt_1.confirm)({
|
|
78
|
+
nonInteractive: options.nonInteractive,
|
|
79
|
+
force: options.force,
|
|
80
|
+
default: true,
|
|
81
|
+
}))) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const codeSample = await (0, common_1.writeSDK)(extensionRef, localPath, spec, options);
|
|
85
|
+
logger_1.logger.info();
|
|
86
|
+
utils.logSuccess("Extension SDK installed successfully");
|
|
87
|
+
logger_1.logger.info(codeSample);
|
|
88
|
+
});
|
package/lib/commands/ext.js
CHANGED
|
@@ -8,12 +8,17 @@ const logger_1 = require("../logger");
|
|
|
8
8
|
const requirePermissions_1 = require("../requirePermissions");
|
|
9
9
|
const types_1 = require("../emulator/types");
|
|
10
10
|
const commandUtils_1 = require("../emulator/commandUtils");
|
|
11
|
+
const options_1 = require("../firestore/options");
|
|
11
12
|
const pretty_print_1 = require("../firestore/pretty-print");
|
|
12
13
|
const error_1 = require("../error");
|
|
13
14
|
exports.command = new command_1.Command("firestore:databases:restore")
|
|
14
15
|
.description("Restore a Firestore database in your Firebase project.")
|
|
15
16
|
.option("-d, --database <databaseID>", "ID of the database to restore into")
|
|
16
17
|
.option("-b, --backup <backup>", "Backup from which to restore")
|
|
18
|
+
.option("-e, --encryption-type <encryptionType>", `Encryption method of the restored database; one of ${options_1.EncryptionType.USE_SOURCE_ENCRYPTION} (default), ` +
|
|
19
|
+
`${options_1.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION}, ${options_1.EncryptionType.GOOGLE_DEFAULT_ENCRYPTION}`)
|
|
20
|
+
.option("-k, --kms-key-name <kmsKeyName>", "Resource ID of the Cloud KMS key to encrypt the restored database. This " +
|
|
21
|
+
"feature is allowlist only in initial launch.")
|
|
17
22
|
.before(requirePermissions_1.requirePermissions, ["datastore.backups.restoreDatabase"])
|
|
18
23
|
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
19
24
|
.action(async (options) => {
|
|
@@ -28,7 +33,28 @@ exports.command = new command_1.Command("firestore:databases:restore")
|
|
|
28
33
|
throw new error_1.FirebaseError(`Missing required flag --backup. ${helpCommandText}`);
|
|
29
34
|
}
|
|
30
35
|
const backupName = options.backup;
|
|
31
|
-
|
|
36
|
+
let encryptionConfig = undefined;
|
|
37
|
+
switch (options.encryptionType) {
|
|
38
|
+
case options_1.EncryptionType.GOOGLE_DEFAULT_ENCRYPTION:
|
|
39
|
+
throwIfKmsKeyNameIsSet(options.kmsKeyName);
|
|
40
|
+
encryptionConfig = { googleDefaultEncryption: {} };
|
|
41
|
+
break;
|
|
42
|
+
case options_1.EncryptionType.USE_SOURCE_ENCRYPTION:
|
|
43
|
+
throwIfKmsKeyNameIsSet(options.kmsKeyName);
|
|
44
|
+
encryptionConfig = { useSourceEncryption: {} };
|
|
45
|
+
break;
|
|
46
|
+
case options_1.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION:
|
|
47
|
+
encryptionConfig = {
|
|
48
|
+
customerManagedEncryption: { kmsKeyName: getKmsKeyOrThrow(options.kmsKeyName) },
|
|
49
|
+
};
|
|
50
|
+
break;
|
|
51
|
+
case undefined:
|
|
52
|
+
throwIfKmsKeyNameIsSet(options.kmsKeyName);
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
throw new error_1.FirebaseError(`Invalid value for flag --encryption-type. ${helpCommandText}`);
|
|
56
|
+
}
|
|
57
|
+
const databaseResp = await api.restoreDatabase(options.project, databaseId, backupName, encryptionConfig);
|
|
32
58
|
if (options.json) {
|
|
33
59
|
logger_1.logger.info(JSON.stringify(databaseResp, undefined, 2));
|
|
34
60
|
}
|
|
@@ -40,4 +66,16 @@ exports.command = new command_1.Command("firestore:databases:restore")
|
|
|
40
66
|
logger_1.logger.info(`Once the restore is complete, your database may be viewed at ${printer.firebaseConsoleDatabaseUrl(options.project, databaseId)}`);
|
|
41
67
|
}
|
|
42
68
|
return databaseResp;
|
|
69
|
+
function throwIfKmsKeyNameIsSet(kmsKeyName) {
|
|
70
|
+
if (kmsKeyName) {
|
|
71
|
+
throw new error_1.FirebaseError("--kms-key-name can only be set when specifying an --encryption-type " +
|
|
72
|
+
`of ${options_1.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION}.`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function getKmsKeyOrThrow(kmsKeyName) {
|
|
76
|
+
if (kmsKeyName)
|
|
77
|
+
return kmsKeyName;
|
|
78
|
+
throw new error_1.FirebaseError("--kms-key-name must be provided when specifying an --encryption-type " +
|
|
79
|
+
`of ${options_1.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION}.`);
|
|
80
|
+
}
|
|
43
81
|
});
|
|
@@ -7,16 +7,14 @@ const projectUtils_1 = require("../projectUtils");
|
|
|
7
7
|
const secretManager_1 = require("../gcp/secretManager");
|
|
8
8
|
const requireAuth_1 = require("../requireAuth");
|
|
9
9
|
const secretManager = require("../gcp/secretManager");
|
|
10
|
+
const secrets_1 = require("../apphosting/secrets");
|
|
10
11
|
exports.command = new command_1.Command("functions:secrets:access <KEY>[@version]")
|
|
11
12
|
.description("Access secret value given secret and its version. Defaults to accessing the latest version.")
|
|
12
13
|
.before(requireAuth_1.requireAuth)
|
|
13
14
|
.before(secretManager.ensureApi)
|
|
14
15
|
.action(async (key, options) => {
|
|
15
16
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
16
|
-
|
|
17
|
-
if (!version) {
|
|
18
|
-
version = "latest";
|
|
19
|
-
}
|
|
17
|
+
const [name, version] = (0, secrets_1.getSecretNameParts)(key);
|
|
20
18
|
const value = await (0, secretManager_1.accessSecretVersion)(projectId, name, version);
|
|
21
19
|
logger_1.logger.info(value);
|
|
22
20
|
});
|
package/lib/commands/index.js
CHANGED
|
@@ -17,11 +17,14 @@ function load(client) {
|
|
|
17
17
|
client.appdistribution = {};
|
|
18
18
|
client.appdistribution.distribute = loadCommand("appdistribution-distribute");
|
|
19
19
|
client.appdistribution.testers = {};
|
|
20
|
+
client.appdistribution.testers.list = loadCommand("appdistribution-testers-list");
|
|
20
21
|
client.appdistribution.testers.add = loadCommand("appdistribution-testers-add");
|
|
21
22
|
client.appdistribution.testers.delete = loadCommand("appdistribution-testers-remove");
|
|
22
23
|
client.appdistribution.group = {};
|
|
23
|
-
client.appdistribution.group.
|
|
24
|
-
client.appdistribution.group.
|
|
24
|
+
client.appdistribution.group.list = loadCommand("appdistribution-groups-list");
|
|
25
|
+
client.appdistribution.group.create = loadCommand("appdistribution-groups-create");
|
|
26
|
+
client.appdistribution.group.delete = loadCommand("appdistribution-groups-delete");
|
|
27
|
+
client.appdistribution.groups = client.appdistribution.group;
|
|
25
28
|
client.apps = {};
|
|
26
29
|
client.apps.create = loadCommand("apps-create");
|
|
27
30
|
client.apps.list = loadCommand("apps-list");
|
|
@@ -83,6 +86,8 @@ function load(client) {
|
|
|
83
86
|
client.ext.list = loadCommand("ext-list");
|
|
84
87
|
client.ext.uninstall = loadCommand("ext-uninstall");
|
|
85
88
|
client.ext.update = loadCommand("ext-update");
|
|
89
|
+
client.ext.sdk = {};
|
|
90
|
+
client.ext.sdk.install = loadCommand("ext-sdk-install");
|
|
86
91
|
client.ext.dev = {};
|
|
87
92
|
client.ext.dev.init = loadCommand("ext-dev-init");
|
|
88
93
|
client.ext.dev.list = loadCommand("ext-dev-list");
|
|
@@ -171,10 +176,16 @@ function load(client) {
|
|
|
171
176
|
client.apphosting.builds = {};
|
|
172
177
|
client.apphosting.builds.get = loadCommand("apphosting-builds-get");
|
|
173
178
|
client.apphosting.builds.create = loadCommand("apphosting-builds-create");
|
|
179
|
+
client.apphosting.repos = {};
|
|
180
|
+
client.apphosting.repos.create = loadCommand("apphosting-repos-create");
|
|
174
181
|
client.apphosting.rollouts = {};
|
|
175
182
|
client.apphosting.rollouts.create = loadCommand("apphosting-rollouts-create");
|
|
176
183
|
client.apphosting.rollouts.list = loadCommand("apphosting-rollouts-list");
|
|
177
184
|
}
|
|
185
|
+
if (experiments.isEnabled("emulatorapphosting")) {
|
|
186
|
+
client.apphosting.config = {};
|
|
187
|
+
client.apphosting.config.export = loadCommand("apphosting-config-export");
|
|
188
|
+
}
|
|
178
189
|
}
|
|
179
190
|
client.login = loadCommand("login");
|
|
180
191
|
client.login.add = loadCommand("login-add");
|
|
@@ -207,6 +218,8 @@ function load(client) {
|
|
|
207
218
|
client.dataconnect.sql = {};
|
|
208
219
|
client.dataconnect.sql.diff = loadCommand("dataconnect-sql-diff");
|
|
209
220
|
client.dataconnect.sql.migrate = loadCommand("dataconnect-sql-migrate");
|
|
221
|
+
client.dataconnect.sql.grant = loadCommand("dataconnect-sql-grant");
|
|
222
|
+
client.dataconnect.sql.shell = loadCommand("dataconnect-sql-shell");
|
|
210
223
|
client.dataconnect.sdk = {};
|
|
211
224
|
client.dataconnect.sdk.generate = loadCommand("dataconnect-sdk-generate");
|
|
212
225
|
client.target = loadCommand("target");
|
package/lib/commands/init.js
CHANGED
|
@@ -21,10 +21,10 @@ const GITIGNORE_TEMPLATE = (0, templates_1.readTemplateSync)("_gitignore");
|
|
|
21
21
|
function isOutside(from, to) {
|
|
22
22
|
return !!/^\.\./.exec(path.relative(from, to));
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
let choices = [
|
|
25
25
|
{
|
|
26
|
-
value: "
|
|
27
|
-
name: "
|
|
26
|
+
value: "dataconnect",
|
|
27
|
+
name: "Data Connect: Set up a Firebase Data Connect service",
|
|
28
28
|
checked: false,
|
|
29
29
|
},
|
|
30
30
|
{
|
|
@@ -38,15 +38,15 @@ const choices = [
|
|
|
38
38
|
checked: false,
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
value: "
|
|
42
|
-
name: "Hosting: Configure
|
|
41
|
+
value: "apphosting",
|
|
42
|
+
name: "App Hosting: Configure an apphosting.yaml file for App Hosting",
|
|
43
43
|
checked: false,
|
|
44
|
+
hidden: false,
|
|
44
45
|
},
|
|
45
46
|
{
|
|
46
|
-
value: "hosting
|
|
47
|
-
name: "Hosting:
|
|
47
|
+
value: "hosting",
|
|
48
|
+
name: "Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys",
|
|
48
49
|
checked: false,
|
|
49
|
-
hidden: true,
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
value: "storage",
|
|
@@ -69,10 +69,16 @@ const choices = [
|
|
|
69
69
|
checked: false,
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
|
-
value: "
|
|
73
|
-
name: "
|
|
72
|
+
value: "database",
|
|
73
|
+
name: "Realtime Database: Configure a security rules file for Realtime Database and (optionally) provision default instance",
|
|
74
74
|
checked: false,
|
|
75
75
|
},
|
|
76
|
+
{
|
|
77
|
+
value: "hosting:github",
|
|
78
|
+
name: "Hosting: Set up GitHub Action deploys",
|
|
79
|
+
checked: false,
|
|
80
|
+
hidden: true,
|
|
81
|
+
},
|
|
76
82
|
{
|
|
77
83
|
value: "dataconnect:sdk",
|
|
78
84
|
name: "Data Connect: Set up a generated SDK for your Firebase Data Connect service",
|
|
@@ -81,11 +87,15 @@ const choices = [
|
|
|
81
87
|
},
|
|
82
88
|
];
|
|
83
89
|
if ((0, experiments_1.isEnabled)("genkit")) {
|
|
84
|
-
choices
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
choices = [
|
|
91
|
+
...choices.slice(0, 2),
|
|
92
|
+
{
|
|
93
|
+
value: "genkit",
|
|
94
|
+
name: "Genkit: Setup a new Genkit project with Firebase",
|
|
95
|
+
checked: false,
|
|
96
|
+
},
|
|
97
|
+
...choices.slice(2),
|
|
98
|
+
];
|
|
89
99
|
}
|
|
90
100
|
const featureNames = choices.map((choice) => choice.value);
|
|
91
101
|
const DESCRIPTION = `Interactively configure the current directory as a Firebase project or initialize new features in an already configured Firebase project directory.
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.command = void 0;
|
|
4
4
|
const command_1 = require("../command");
|
|
5
5
|
const types_1 = require("../emulator/types");
|
|
6
|
-
const emulators_1 = require("../init/features/emulators");
|
|
7
|
-
const prompt_1 = require("../prompt");
|
|
8
6
|
const logger_1 = require("../logger");
|
|
9
7
|
const downloadableEmulators_1 = require("../emulator/downloadableEmulators");
|
|
10
8
|
const NAME = types_1.Emulators.DATACONNECT;
|
|
@@ -16,16 +14,5 @@ exports.command = new command_1.Command(`setup:emulators:${NAME}`)
|
|
|
16
14
|
logger_1.logger.info("Not currently in a Firebase project directory. Run this command from a project directory to configure the Data Connect emulator.");
|
|
17
15
|
return;
|
|
18
16
|
}
|
|
19
|
-
if (!options.nonInteractive) {
|
|
20
|
-
const dataconnectEmulatorConfig = options.rc.getDataconnect();
|
|
21
|
-
const defaultConnectionString = dataconnectEmulatorConfig?.postgres?.localConnectionString ?? emulators_1.DEFAULT_POSTGRES_CONNECTION;
|
|
22
|
-
const localConnectionString = await (0, prompt_1.promptOnce)({
|
|
23
|
-
type: "input",
|
|
24
|
-
name: "localConnectionString",
|
|
25
|
-
message: `What is the connection string of the local Postgres instance you would like to use with the Data Connect emulator?`,
|
|
26
|
-
default: defaultConnectionString,
|
|
27
|
-
});
|
|
28
|
-
options.rc.setDataconnect(localConnectionString);
|
|
29
|
-
}
|
|
30
17
|
logger_1.logger.info("Setup complete!");
|
|
31
18
|
});
|
package/lib/commands/use.js
CHANGED
|
@@ -53,7 +53,7 @@ exports.command = new command_1.Command("use [alias_or_project_id]")
|
|
|
53
53
|
const hasAlias = options.rc.hasProjectAlias(newActive);
|
|
54
54
|
const resolvedProject = options.rc.resolveAlias(newActive);
|
|
55
55
|
(0, command_2.validateProjectId)(resolvedProject);
|
|
56
|
-
return (0, projects_1.
|
|
56
|
+
return (0, projects_1.getProject)(resolvedProject)
|
|
57
57
|
.then((foundProject) => {
|
|
58
58
|
project = foundProject;
|
|
59
59
|
})
|
package/lib/config.js
CHANGED
|
@@ -164,21 +164,31 @@ class Config {
|
|
|
164
164
|
deleteProjectFile(p) {
|
|
165
165
|
fs.removeSync(this.path(p));
|
|
166
166
|
}
|
|
167
|
-
askWriteProjectFile(p, content, force) {
|
|
167
|
+
askWriteProjectFile(p, content, force, confirmByDefault) {
|
|
168
168
|
const writeTo = this.path(p);
|
|
169
169
|
let next;
|
|
170
|
-
if (
|
|
170
|
+
if (typeof content !== "string") {
|
|
171
|
+
content = JSON.stringify(content, null, 2) + "\n";
|
|
172
|
+
}
|
|
173
|
+
let existingContent;
|
|
174
|
+
if (fsutils.fileExistsSync(writeTo)) {
|
|
175
|
+
existingContent = fsutils.readFile(writeTo);
|
|
176
|
+
}
|
|
177
|
+
if (existingContent && existingContent !== content && !force) {
|
|
171
178
|
next = (0, prompt_1.promptOnce)({
|
|
172
179
|
type: "confirm",
|
|
173
180
|
message: "File " + clc.underline(p) + " already exists. Overwrite?",
|
|
174
|
-
default:
|
|
181
|
+
default: !!confirmByDefault,
|
|
175
182
|
});
|
|
176
183
|
}
|
|
177
184
|
else {
|
|
178
185
|
next = Promise.resolve(true);
|
|
179
186
|
}
|
|
180
187
|
return next.then((result) => {
|
|
181
|
-
if (
|
|
188
|
+
if (existingContent === content) {
|
|
189
|
+
utils.logBullet(clc.bold(p) + " is unchanged");
|
|
190
|
+
}
|
|
191
|
+
else if (result) {
|
|
182
192
|
this.writeProjectFile(p, content);
|
|
183
193
|
utils.logSuccess("Wrote " + clc.bold(p));
|
|
184
194
|
}
|
|
@@ -8,7 +8,7 @@ const spawn = require("cross-spawn");
|
|
|
8
8
|
const downloadUtils = require("../downloadUtils");
|
|
9
9
|
const error_1 = require("../error");
|
|
10
10
|
const logger_1 = require("../logger");
|
|
11
|
-
const
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
12
|
const utils = require("../utils");
|
|
13
13
|
const JAR_CACHE_DIR = process.env.FIREBASE_CRASHLYTICS_BUILDTOOLS_PATH ||
|
|
14
14
|
path.join(os.homedir(), ".cache", "firebase", "crashlytics", "buildtools");
|
|
@@ -26,7 +26,7 @@ async function fetchBuildtoolsJar() {
|
|
|
26
26
|
}
|
|
27
27
|
if (fs.existsSync(JAR_CACHE_DIR)) {
|
|
28
28
|
logger_1.logger.debug(`Deleting Jar cache at ${JAR_CACHE_DIR} because the CLI was run with a newer Jar version`);
|
|
29
|
-
|
|
29
|
+
(0, node_fs_1.rmSync)(JAR_CACHE_DIR, { recursive: true });
|
|
30
30
|
}
|
|
31
31
|
utils.logBullet("Downloading crashlytics-buildtools.jar to " + jarPath);
|
|
32
32
|
utils.logBullet("For open source licenses used by this command, look in the META-INF directory in the buildtools.jar file");
|
|
@@ -5,7 +5,7 @@ const api_1 = require("../api");
|
|
|
5
5
|
const apiv2_1 = require("../apiv2");
|
|
6
6
|
const operationPoller = require("../operation-poller");
|
|
7
7
|
const types = require("./types");
|
|
8
|
-
const DATACONNECT_API_VERSION = "
|
|
8
|
+
const DATACONNECT_API_VERSION = "v1beta";
|
|
9
9
|
const PAGE_SIZE_MAX = 100;
|
|
10
10
|
const dataconnectClient = () => new apiv2_1.Client({
|
|
11
11
|
urlPrefix: (0, api_1.dataconnectOrigin)(),
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeGraphQL = void 0;
|
|
3
|
+
exports.executeGraphQL = exports.dataconnectDataplaneClient = exports.DATACONNECT_API_VERSION = void 0;
|
|
4
4
|
const api_1 = require("../api");
|
|
5
5
|
const apiv2_1 = require("../apiv2");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
exports.DATACONNECT_API_VERSION = "v1beta";
|
|
7
|
+
function dataconnectDataplaneClient() {
|
|
8
|
+
return new apiv2_1.Client({
|
|
9
|
+
urlPrefix: (0, api_1.dataconnectOrigin)(),
|
|
10
|
+
apiVersion: exports.DATACONNECT_API_VERSION,
|
|
11
|
+
auth: true,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
exports.dataconnectDataplaneClient = dataconnectDataplaneClient;
|
|
15
|
+
async function executeGraphQL(client, servicePath, body) {
|
|
16
|
+
const res = await client.post(`${servicePath}:executeGraphql`, body, { resolveOnHTTPError: true });
|
|
14
17
|
return res;
|
|
15
18
|
}
|
|
16
19
|
exports.executeGraphQL = executeGraphQL;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureApis = void 0;
|
|
3
|
+
exports.ensureSparkApis = exports.ensureApis = void 0;
|
|
4
4
|
const api = require("../api");
|
|
5
5
|
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
6
6
|
async function ensureApis(projectId) {
|
|
@@ -10,3 +10,8 @@ async function ensureApis(projectId) {
|
|
|
10
10
|
await (0, ensureApiEnabled_1.ensure)(projectId, api.computeOrigin(), prefix);
|
|
11
11
|
}
|
|
12
12
|
exports.ensureApis = ensureApis;
|
|
13
|
+
async function ensureSparkApis(projectId) {
|
|
14
|
+
const prefix = "dataconnect";
|
|
15
|
+
await (0, ensureApiEnabled_1.ensure)(projectId, api.cloudSQLAdminOrigin(), prefix);
|
|
16
|
+
}
|
|
17
|
+
exports.ensureSparkApis = ensureSparkApis;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getPlatformFromFolder = exports.pickService = exports.readGQLFiles = exports.readConnectorYaml = exports.readDataConnectYaml = exports.readFirebaseJson = void 0;
|
|
4
4
|
const fs = require("fs-extra");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const error_1 = require("../error");
|
|
@@ -8,7 +8,7 @@ const types_1 = require("./types");
|
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const load_1 = require("./load");
|
|
10
10
|
function readFirebaseJson(config) {
|
|
11
|
-
if (!config
|
|
11
|
+
if (!config?.has("dataconnect")) {
|
|
12
12
|
return [];
|
|
13
13
|
}
|
|
14
14
|
const validator = (cfg) => {
|
|
@@ -96,61 +96,37 @@ exports.pickService = pickService;
|
|
|
96
96
|
const WEB_INDICATORS = ["package.json", "package-lock.json", "node_modules"];
|
|
97
97
|
const IOS_INDICATORS = ["info.plist", "podfile", "package.swift"];
|
|
98
98
|
const ANDROID_INDICATORS = ["androidmanifest.xml", "build.gradle", "build.gradle.kts"];
|
|
99
|
+
const DART_INDICATORS = ["pubspec.yaml", "pubspec.lock"];
|
|
99
100
|
const IOS_POSTFIX_INDICATORS = [".xcworkspace", ".xcodeproj"];
|
|
100
101
|
async function getPlatformFromFolder(dirPath) {
|
|
101
102
|
const fileNames = await fs.readdir(dirPath);
|
|
102
103
|
let hasWeb = false;
|
|
103
104
|
let hasAndroid = false;
|
|
104
105
|
let hasIOS = false;
|
|
106
|
+
let hasDart = false;
|
|
105
107
|
for (const fileName of fileNames) {
|
|
106
108
|
const cleanedFileName = fileName.toLowerCase();
|
|
107
109
|
hasWeb || (hasWeb = WEB_INDICATORS.some((indicator) => indicator === cleanedFileName));
|
|
108
110
|
hasAndroid || (hasAndroid = ANDROID_INDICATORS.some((indicator) => indicator === cleanedFileName));
|
|
109
111
|
hasIOS || (hasIOS = IOS_INDICATORS.some((indicator) => indicator === cleanedFileName) ||
|
|
110
112
|
IOS_POSTFIX_INDICATORS.some((indicator) => cleanedFileName.endsWith(indicator)));
|
|
113
|
+
hasDart || (hasDart = DART_INDICATORS.some((indicator) => indicator === cleanedFileName));
|
|
111
114
|
}
|
|
112
|
-
if (hasWeb && !hasAndroid && !hasIOS) {
|
|
115
|
+
if (!hasWeb && !hasAndroid && !hasIOS && !hasDart) {
|
|
116
|
+
return types_1.Platform.NONE;
|
|
117
|
+
}
|
|
118
|
+
else if (hasWeb && !hasAndroid && !hasIOS && !hasDart) {
|
|
113
119
|
return types_1.Platform.WEB;
|
|
114
120
|
}
|
|
115
|
-
else if (hasAndroid && !hasWeb && !hasIOS) {
|
|
121
|
+
else if (hasAndroid && !hasWeb && !hasIOS && !hasDart) {
|
|
116
122
|
return types_1.Platform.ANDROID;
|
|
117
123
|
}
|
|
118
|
-
else if (hasIOS && !hasWeb && !hasAndroid) {
|
|
124
|
+
else if (hasIOS && !hasWeb && !hasAndroid && !hasDart) {
|
|
119
125
|
return types_1.Platform.IOS;
|
|
120
126
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
exports.getPlatformFromFolder = getPlatformFromFolder;
|
|
124
|
-
async function directoryHasPackageJson(dirPath) {
|
|
125
|
-
const fileNames = await fs.readdir(dirPath);
|
|
126
|
-
return fileNames.some((f) => f.toLowerCase() === "package.json");
|
|
127
|
-
}
|
|
128
|
-
exports.directoryHasPackageJson = directoryHasPackageJson;
|
|
129
|
-
function generateSdkYaml(platform, connectorYaml, connectorYamlFolder, appFolder) {
|
|
130
|
-
const relPath = path.relative(connectorYamlFolder, appFolder);
|
|
131
|
-
const outputDir = path.join(relPath, "dataconnect-generated");
|
|
132
|
-
if (!connectorYaml.generate) {
|
|
133
|
-
connectorYaml.generate = {};
|
|
134
|
-
}
|
|
135
|
-
if (platform === types_1.Platform.WEB) {
|
|
136
|
-
connectorYaml.generate.javascriptSdk = {
|
|
137
|
-
outputDir,
|
|
138
|
-
package: `@firebasegen/${connectorYaml.connectorId}`,
|
|
139
|
-
packageJsonDir: appFolder,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
if (platform === types_1.Platform.IOS) {
|
|
143
|
-
connectorYaml.generate.swiftSdk = {
|
|
144
|
-
outputDir,
|
|
145
|
-
package: connectorYaml.connectorId,
|
|
146
|
-
};
|
|
127
|
+
else if (hasDart && !hasWeb && !hasIOS && !hasAndroid) {
|
|
128
|
+
return types_1.Platform.FLUTTER;
|
|
147
129
|
}
|
|
148
|
-
|
|
149
|
-
connectorYaml.generate.kotlinSdk = {
|
|
150
|
-
outputDir,
|
|
151
|
-
package: `connectors.${connectorYaml.connectorId}`,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
return connectorYaml;
|
|
130
|
+
return types_1.Platform.MULTIPLE;
|
|
155
131
|
}
|
|
156
|
-
exports.
|
|
132
|
+
exports.getPlatformFromFolder = getPlatformFromFolder;
|
|
@@ -1,22 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printFreeTrialUnavailable = exports.
|
|
3
|
+
exports.upgradeInstructions = exports.printFreeTrialUnavailable = exports.getFreeTrialInstanceId = exports.checkFreeTrialInstanceUsed = exports.freeTrialTermsLink = void 0;
|
|
4
|
+
const cloudmonitoring_1 = require("../gcp/cloudmonitoring");
|
|
4
5
|
const cloudsqladmin_1 = require("../gcp/cloudsql/cloudsqladmin");
|
|
5
6
|
const utils = require("../utils");
|
|
7
|
+
const clc = require("colorette");
|
|
6
8
|
function freeTrialTermsLink() {
|
|
7
9
|
return "https://firebase.google.com/pricing";
|
|
8
10
|
}
|
|
9
11
|
exports.freeTrialTermsLink = freeTrialTermsLink;
|
|
10
|
-
|
|
12
|
+
const FREE_TRIAL_METRIC = "sqladmin.googleapis.com/fdc_lifetime_free_trial_per_project";
|
|
13
|
+
async function checkFreeTrialInstanceUsed(projectId) {
|
|
14
|
+
const past7d = new Date();
|
|
15
|
+
past7d.setDate(past7d.getDate() - 7);
|
|
16
|
+
const query = {
|
|
17
|
+
filter: `metric.type="serviceruntime.googleapis.com/quota/allocation/usage" AND metric.label.quota_metric = "${FREE_TRIAL_METRIC}"`,
|
|
18
|
+
"interval.endTime": new Date().toJSON(),
|
|
19
|
+
"interval.startTime": past7d.toJSON(),
|
|
20
|
+
};
|
|
21
|
+
try {
|
|
22
|
+
const ts = await (0, cloudmonitoring_1.queryTimeSeries)(query, projectId);
|
|
23
|
+
if (ts.length) {
|
|
24
|
+
return ts[0].points.some((p) => p.value.int64Value);
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.checkFreeTrialInstanceUsed = checkFreeTrialInstanceUsed;
|
|
33
|
+
async function getFreeTrialInstanceId(projectId) {
|
|
11
34
|
const instances = await (0, cloudsqladmin_1.listInstances)(projectId);
|
|
12
35
|
return instances.find((i) => i.settings.userLabels?.["firebase-data-connect"] === "ft")?.name;
|
|
13
36
|
}
|
|
14
|
-
exports.
|
|
15
|
-
function printFreeTrialUnavailable(projectId, instanceId) {
|
|
16
|
-
|
|
17
|
-
"The free trial
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
37
|
+
exports.getFreeTrialInstanceId = getFreeTrialInstanceId;
|
|
38
|
+
function printFreeTrialUnavailable(projectId, configYamlPath, instanceId) {
|
|
39
|
+
if (!instanceId) {
|
|
40
|
+
utils.logLabeledError("data connect", "The CloudSQL free trial has already been used on this project.");
|
|
41
|
+
utils.logLabeledError("data connect", `You may create or use a paid CloudSQL instance by visiting https://console.cloud.google.com/sql/instances`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
utils.logLabeledError("data connect", `Project '${projectId} already has a CloudSQL instance '${instanceId}' on the Firebase Data Connect no-cost trial.`);
|
|
45
|
+
const reuseHint = `To use a different database in the same instance, ${clc.bold(`change the ${clc.blue("instanceId")} to "${instanceId}"`)} and update ${clc.blue("location")} in ` +
|
|
46
|
+
`${clc.green(configYamlPath)}.`;
|
|
47
|
+
utils.logLabeledError("data connect", reuseHint);
|
|
48
|
+
utils.logLabeledError("data connect", `Alternatively, you may create a new (paid) CloudSQL instance at https://console.cloud.google.com/sql/instances`);
|
|
21
49
|
}
|
|
22
50
|
exports.printFreeTrialUnavailable = printFreeTrialUnavailable;
|
|
51
|
+
function upgradeInstructions(projectId) {
|
|
52
|
+
return `If you'd like to provision a CloudSQL Postgres instance on the Firebase Data Connect no-cost trial:
|
|
53
|
+
1. Please upgrade to the pay-as-you-go (Blaze) billing plan. Visit the following page:
|
|
54
|
+
https://console.firebase.google.com/project/${projectId}/usage/details
|
|
55
|
+
2. Run ${clc.bold("firebase init dataconnect")} again to configure the Cloud SQL instance.
|
|
56
|
+
3. Run ${clc.bold("firebase deploy --only dataconnect")} to deploy your Data Connect service.`;
|
|
57
|
+
}
|
|
58
|
+
exports.upgradeInstructions = upgradeInstructions;
|
package/lib/dataconnect/load.js
CHANGED
|
@@ -30,7 +30,9 @@ async function load(projectId, config, sourceDirectory) {
|
|
|
30
30
|
sourceDirectory: resolvedDir,
|
|
31
31
|
schema: {
|
|
32
32
|
name: `${serviceName}/schemas/${types_1.SCHEMA_ID}`,
|
|
33
|
-
|
|
33
|
+
datasources: [
|
|
34
|
+
(0, types_1.toDatasource)(projectId, dataConnectYaml.location, dataConnectYaml.schema.datasource),
|
|
35
|
+
],
|
|
34
36
|
source: {
|
|
35
37
|
files: schemaGQLs,
|
|
36
38
|
},
|