firebase-tools 15.1.0 → 15.2.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/accountExporter.js +3 -5
- package/lib/accountImporter.js +4 -5
- package/lib/api.js +3 -3
- package/lib/apiv2.js +9 -13
- package/lib/appUtils.js +19 -21
- package/lib/appdistribution/client.js +4 -8
- package/lib/appdistribution/distribution.js +4 -4
- package/lib/appdistribution/options-parser-util.js +8 -9
- package/lib/appdistribution/types.js +2 -2
- package/lib/appdistribution/yaml_helper.js +33 -17
- package/lib/apphosting/app.js +8 -13
- package/lib/apphosting/backend.js +34 -24
- package/lib/apphosting/config.js +14 -14
- package/lib/apphosting/githubConnections.js +38 -35
- package/lib/apphosting/localbuilds.js +4 -6
- package/lib/apphosting/repo.js +24 -20
- package/lib/apphosting/rollout.js +12 -5
- package/lib/apphosting/secrets/dialogs.js +9 -9
- package/lib/apphosting/secrets/index.js +9 -11
- package/lib/apphosting/utils.js +2 -3
- package/lib/apphosting/yaml.js +12 -11
- package/lib/apptesting/ensureProjectConfigured.js +1 -2
- package/lib/apptesting/invokeTests.js +2 -3
- package/lib/apptesting/parseTestFiles.js +5 -6
- package/lib/apptesting/types.js +2 -2
- package/lib/archiveDirectory.js +1 -2
- package/lib/auth.js +36 -40
- package/lib/bin/cli.js +2 -3
- package/lib/bin/mcp.js +1 -2
- package/lib/checkMinRequiredVersion.js +1 -2
- package/lib/checkValidTargetFilters.js +1 -2
- package/lib/command.js +6 -9
- package/lib/commands/appdistribution-testers-list.js +2 -3
- package/lib/commands/apphosting-backends-list.js +4 -6
- package/lib/commands/apphosting-builds-create.js +2 -3
- package/lib/commands/apphosting-builds-get.js +1 -2
- package/lib/commands/apphosting-rollouts-list.js +1 -2
- package/lib/commands/apps-init.js +1 -1
- package/lib/commands/{apptesting-execute.js → apptesting-wata.js} +3 -4
- package/lib/commands/crashlytics-symbols-upload.js +2 -2
- package/lib/commands/dataconnect-execute.js +4 -4
- package/lib/commands/dataconnect-sdk-generate.js +5 -6
- package/lib/commands/dataconnect-services-list.js +7 -8
- package/lib/commands/dataconnect-sql-diff.js +1 -2
- package/lib/commands/dataconnect-sql-migrate.js +4 -3
- package/lib/commands/dataconnect-sql-setup.js +2 -2
- package/lib/commands/dataconnect-sql-shell.js +5 -1
- package/lib/commands/emulators-start.js +1 -2
- package/lib/commands/ext-configure.js +6 -4
- package/lib/commands/ext-dev-list.js +2 -3
- package/lib/commands/ext-dev-upload.js +2 -2
- package/lib/commands/ext-export.js +1 -1
- package/lib/commands/ext-info.js +2 -3
- package/lib/commands/ext-install.js +5 -7
- package/lib/commands/firestore-backups-list.js +1 -2
- package/lib/commands/firestore-backups-schedules-list.js +1 -2
- package/lib/commands/firestore-indexes-list.js +1 -2
- package/lib/commands/firestore-utils.js +1 -2
- package/lib/commands/functions-artifacts-setpolicy.js +1 -2
- package/lib/commands/functions-config-export.js +2 -3
- package/lib/commands/hosting-channel-deploy.js +2 -2
- package/lib/commands/hosting-clone.js +2 -3
- package/lib/commands/hosting-sites-create.js +1 -1
- package/lib/commands/index.js +2 -3
- package/lib/commands/init.js +4 -5
- package/lib/commands/internaltesting-functions-discover.js +1 -1
- package/lib/commands/login.js +4 -5
- package/lib/commands/logout.js +3 -3
- package/lib/commands/projects-create.js +1 -1
- package/lib/commands/remoteconfig-experiments-list.js +2 -3
- package/lib/commands/remoteconfig-get.js +1 -1
- package/lib/commands/remoteconfig-rollback.js +1 -2
- package/lib/commands/remoteconfig-rollouts-list.js +2 -3
- package/lib/commands/remoteconfig-versions-list.js +3 -4
- package/lib/commands/use.js +3 -3
- package/lib/config.js +4 -5
- package/lib/crashlytics/buildToolsJarHelper.js +3 -5
- package/lib/crashlytics/events.js +4 -7
- package/lib/crashlytics/filters.js +10 -12
- package/lib/crashlytics/issues.js +2 -3
- package/lib/crashlytics/notes.js +3 -4
- package/lib/crashlytics/reports.js +21 -15
- package/lib/crashlytics/types.js +7 -7
- package/lib/crashlytics/utils.js +4 -4
- package/lib/database/api.js +2 -3
- package/lib/database/import.js +4 -4
- package/lib/database/metadata.js +5 -6
- package/lib/database/rulesConfig.js +2 -3
- package/lib/dataconnect/build.js +10 -13
- package/lib/dataconnect/checkIam.js +1 -2
- package/lib/dataconnect/client.js +15 -18
- package/lib/dataconnect/dataplaneClient.js +6 -6
- package/lib/dataconnect/ensureApis.js +2 -3
- package/lib/dataconnect/errors.js +8 -11
- package/lib/dataconnect/filters.js +2 -3
- package/lib/dataconnect/freeTrial.js +3 -4
- package/lib/dataconnect/graphqlError.js +5 -8
- package/lib/dataconnect/load.js +10 -11
- package/lib/dataconnect/names.js +14 -18
- package/lib/dataconnect/prompts.js +1 -2
- package/lib/dataconnect/provisionCloudSql.js +13 -17
- package/lib/dataconnect/schemaMigration.js +60 -27
- package/lib/dataconnect/types.js +10 -12
- package/lib/dataconnect/webhook.js +3 -3
- package/lib/defaultCredentials.js +3 -4
- package/lib/deploy/apphosting/deploy.js +2 -3
- package/lib/deploy/apphosting/prepare.js +3 -5
- package/lib/deploy/apphosting/release.js +1 -1
- package/lib/deploy/apphosting/util.js +1 -2
- package/lib/deploy/database/deploy.js +1 -2
- package/lib/deploy/database/prepare.js +1 -2
- package/lib/deploy/database/release.js +1 -2
- package/lib/deploy/dataconnect/context.js +15 -4
- package/lib/deploy/dataconnect/deploy.js +5 -6
- package/lib/deploy/dataconnect/prepare.js +7 -9
- package/lib/deploy/dataconnect/release.js +7 -10
- package/lib/deploy/extensions/deploy.js +7 -9
- package/lib/deploy/extensions/deploymentSummary.js +6 -7
- package/lib/deploy/extensions/planner.js +15 -18
- package/lib/deploy/extensions/prepare.js +9 -11
- package/lib/deploy/extensions/release.js +10 -12
- package/lib/deploy/extensions/secrets.js +8 -11
- package/lib/deploy/extensions/tasks.js +6 -8
- package/lib/deploy/extensions/v2FunctionHelper.js +2 -3
- package/lib/deploy/extensions/validate.js +1 -2
- package/lib/deploy/firestore/deploy.js +3 -5
- package/lib/deploy/firestore/prepare.js +2 -3
- package/lib/deploy/firestore/release.js +3 -4
- package/lib/deploy/functions/backend.js +52 -42
- package/lib/deploy/functions/build.js +41 -15
- package/lib/deploy/functions/cache/applyHash.js +3 -5
- package/lib/deploy/functions/cache/hash.js +4 -5
- package/lib/deploy/functions/cel.js +3 -3
- package/lib/deploy/functions/checkIam.js +8 -8
- package/lib/deploy/functions/containerCleaner.js +10 -6
- package/lib/deploy/functions/deploy.js +6 -8
- package/lib/deploy/functions/ensure.js +6 -9
- package/lib/deploy/functions/functionsDeployHelper.js +10 -11
- package/lib/deploy/functions/params.js +10 -10
- package/lib/deploy/functions/prepare.js +41 -36
- package/lib/deploy/functions/prepareFunctionsUpload.js +24 -10
- package/lib/deploy/functions/pricing.js +3 -3
- package/lib/deploy/functions/prompts.js +7 -10
- package/lib/deploy/functions/release/executor.js +5 -6
- package/lib/deploy/functions/release/fabricator.js +76 -29
- package/lib/deploy/functions/release/index.js +23 -14
- package/lib/deploy/functions/release/planner.js +15 -14
- package/lib/deploy/functions/release/reporter.js +20 -20
- package/lib/deploy/functions/release/sourceTokenScraper.js +4 -5
- package/lib/deploy/functions/remoteSource.js +3 -4
- package/lib/deploy/functions/runtimes/discovery/index.js +9 -12
- package/lib/deploy/functions/runtimes/discovery/parsing.js +2 -3
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +29 -10
- package/lib/deploy/functions/runtimes/index.js +1 -2
- package/lib/deploy/functions/runtimes/node/index.js +18 -9
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +2 -2
- package/lib/deploy/functions/runtimes/node/validate.js +1 -2
- package/lib/deploy/functions/runtimes/node/versioning.js +6 -7
- package/lib/deploy/functions/runtimes/python/index.js +12 -12
- package/lib/deploy/functions/runtimes/supported/index.js +5 -6
- package/lib/deploy/functions/services/auth.js +49 -36
- package/lib/deploy/functions/services/database.js +1 -2
- package/lib/deploy/functions/services/dataconnect.js +16 -2
- package/lib/deploy/functions/services/firebaseAlerts.js +1 -2
- package/lib/deploy/functions/services/firestore.js +3 -5
- package/lib/deploy/functions/services/index.js +2 -2
- package/lib/deploy/functions/services/remoteConfig.js +1 -2
- package/lib/deploy/functions/services/storage.js +3 -5
- package/lib/deploy/functions/services/testLab.js +1 -2
- package/lib/deploy/functions/triggerRegionHelper.js +1 -2
- package/lib/deploy/functions/validate.js +12 -11
- package/lib/deploy/hosting/convertConfig.js +38 -22
- package/lib/deploy/hosting/deploy.js +4 -7
- package/lib/deploy/hosting/hashcache.js +2 -3
- package/lib/deploy/hosting/prepare.js +14 -14
- package/lib/deploy/hosting/release.js +1 -2
- package/lib/deploy/index.js +7 -8
- package/lib/deploy/lifecycleHooks.js +3 -5
- package/lib/deploy/remoteconfig/deploy.js +1 -1
- package/lib/deploy/remoteconfig/functions.js +5 -6
- package/lib/deploy/remoteconfig/prepare.js +2 -3
- package/lib/deploy/remoteconfig/release.js +2 -2
- package/lib/deploy/storage/deploy.js +1 -1
- package/lib/deploy/storage/prepare.js +1 -1
- package/lib/deploy/storage/release.js +1 -1
- package/lib/deploymentTool.js +5 -6
- package/lib/detectProjectRoot.js +1 -2
- package/lib/downloadUtils.js +2 -3
- package/lib/emulator/adminSdkConfig.js +2 -3
- package/lib/emulator/apphosting/config.js +1 -2
- package/lib/emulator/apphosting/developmentServer.js +3 -3
- package/lib/emulator/apphosting/serve.js +20 -14
- package/lib/emulator/auth/cloudFunctions.js +2 -3
- package/lib/emulator/auth/errors.js +2 -2
- package/lib/emulator/auth/handlers.js +3 -4
- package/lib/emulator/auth/index.js +6 -6
- package/lib/emulator/auth/operations.js +171 -129
- package/lib/emulator/auth/server.js +30 -22
- package/lib/emulator/auth/state.js +26 -36
- package/lib/emulator/auth/utils.js +12 -13
- package/lib/emulator/commandUtils.js +20 -20
- package/lib/emulator/controller.js +32 -29
- package/lib/emulator/databaseEmulator.js +1 -2
- package/lib/emulator/dataconnect/pgliteServer.js +48 -104
- package/lib/emulator/dataconnectEmulator.js +6 -9
- package/lib/emulator/download.js +2 -3
- package/lib/emulator/downloadableEmulatorInfo.json +7 -7
- package/lib/emulator/downloadableEmulators.js +49 -24
- package/lib/emulator/emulatorLogger.js +19 -4
- package/lib/emulator/env.js +6 -8
- package/lib/emulator/eventarcEmulator.js +2 -3
- package/lib/emulator/eventarcEmulatorUtils.js +3 -6
- package/lib/emulator/extensions/postinstall.js +1 -2
- package/lib/emulator/extensions/validation.js +4 -7
- package/lib/emulator/extensionsEmulator.js +6 -9
- package/lib/emulator/functionsEmulator.js +89 -46
- package/lib/emulator/functionsEmulatorRuntime.js +1 -1
- package/lib/emulator/functionsEmulatorShared.js +30 -30
- package/lib/emulator/functionsEmulatorShell.js +4 -6
- package/lib/emulator/functionsEmulatorUtils.js +8 -9
- package/lib/emulator/functionsRuntimeWorker.js +18 -9
- package/lib/emulator/hub.js +41 -34
- package/lib/emulator/hubClient.js +1 -1
- package/lib/emulator/initEmulators.js +2 -3
- package/lib/emulator/loggingEmulator.js +2 -2
- package/lib/emulator/portUtils.js +4 -5
- package/lib/emulator/registry.js +10 -4
- package/lib/emulator/shared/request.js +1 -2
- package/lib/emulator/storage/apis/firebase.js +16 -20
- package/lib/emulator/storage/apis/gcloud.js +6 -9
- package/lib/emulator/storage/apis/shared.js +1 -2
- package/lib/emulator/storage/crc.js +2 -3
- package/lib/emulator/storage/files.js +18 -41
- package/lib/emulator/storage/metadata.js +10 -4
- package/lib/emulator/storage/multipart.js +1 -2
- package/lib/emulator/storage/rfc.js +1 -2
- package/lib/emulator/storage/rules/config.js +1 -2
- package/lib/emulator/storage/rules/manager.js +3 -5
- package/lib/emulator/storage/rules/runtime.js +15 -13
- package/lib/emulator/storage/rules/types.js +2 -2
- package/lib/emulator/storage/rules/utils.js +5 -6
- package/lib/emulator/storage/server.js +1 -2
- package/lib/emulator/storage/upload.js +3 -4
- package/lib/emulator/taskQueue.js +11 -4
- package/lib/emulator/tasksEmulator.js +11 -12
- package/lib/emulator/types.js +6 -6
- package/lib/emulator/ui.js +6 -1
- package/lib/ensureApiEnabled.js +7 -9
- package/lib/env.js +2 -3
- package/lib/error.js +11 -13
- package/lib/errorOut.js +1 -2
- package/lib/experiments.js +15 -18
- package/lib/extensions/askUserForEventsConfig.js +12 -13
- package/lib/extensions/askUserForParam.js +11 -12
- package/lib/extensions/change-log.js +4 -5
- package/lib/extensions/checkProjectBilling.js +1 -2
- package/lib/extensions/diagnose.js +1 -2
- package/lib/extensions/displayExtensionInfo.js +25 -32
- package/lib/extensions/emulator/optionsHelper.js +6 -8
- package/lib/extensions/emulator/specHelper.js +15 -16
- package/lib/extensions/emulator/triggerHelper.js +3 -5
- package/lib/extensions/etags.js +2 -3
- package/lib/extensions/export.js +7 -9
- package/lib/extensions/extensionsApi.js +23 -29
- package/lib/extensions/extensionsHelper.js +52 -80
- package/lib/extensions/listExtensions.js +3 -5
- package/lib/extensions/localHelper.js +5 -5
- package/lib/extensions/manifest.js +15 -16
- package/lib/extensions/metricsUtils.js +3 -4
- package/lib/extensions/paramHelper.js +21 -18
- package/lib/extensions/provisioningHelper.js +17 -21
- package/lib/extensions/publishHelpers.js +1 -2
- package/lib/extensions/publisherApi.js +11 -13
- package/lib/extensions/refs.js +6 -7
- package/lib/extensions/runtimes/common.js +18 -19
- package/lib/extensions/runtimes/node.js +5 -6
- package/lib/extensions/secretsUtils.js +8 -8
- package/lib/extensions/tos.js +7 -8
- package/lib/extensions/types.js +3 -3
- package/lib/extensions/updateHelper.js +6 -7
- package/lib/extensions/utils.js +6 -8
- package/lib/extensions/versionHelper.js +1 -2
- package/lib/extensions/warnings.js +6 -8
- package/lib/fetchMOTD.js +1 -2
- package/lib/fetchWebSetup.js +3 -4
- package/lib/filterTargets.js +1 -2
- package/lib/firebaseConfigValidate.js +2 -3
- package/lib/firestore/api-sort.js +8 -9
- package/lib/firestore/api-types.js +15 -15
- package/lib/firestore/api.js +15 -13
- package/lib/firestore/backupUtils.js +3 -3
- package/lib/firestore/checkDatabaseType.js +1 -2
- package/lib/firestore/delete.js +1 -2
- package/lib/firestore/encodeFirestoreValue.js +1 -2
- package/lib/firestore/fsConfig.js +1 -2
- package/lib/firestore/options.js +1 -1
- package/lib/firestore/util.js +5 -6
- package/lib/firestore/validator.js +4 -5
- package/lib/frameworks/angular/index.js +14 -15
- package/lib/frameworks/angular/utils.js +21 -23
- package/lib/frameworks/astro/index.js +7 -7
- package/lib/frameworks/astro/utils.js +4 -6
- package/lib/frameworks/compose/discover/filesystem.js +3 -3
- package/lib/frameworks/compose/discover/frameworkMatcher.js +4 -5
- package/lib/frameworks/compose/discover/index.js +1 -2
- package/lib/frameworks/compose/discover/runtime/node.js +8 -11
- package/lib/frameworks/compose/driver/docker.js +3 -5
- package/lib/frameworks/compose/driver/hooks.js +2 -2
- package/lib/frameworks/compose/driver/index.js +2 -2
- package/lib/frameworks/compose/driver/local.js +2 -3
- package/lib/frameworks/compose/index.js +5 -7
- package/lib/frameworks/constants.js +3 -3
- package/lib/frameworks/express/index.js +7 -8
- package/lib/frameworks/flutter/index.js +6 -7
- package/lib/frameworks/flutter/utils.js +4 -5
- package/lib/frameworks/index.js +21 -22
- package/lib/frameworks/next/constants.js +5 -2
- package/lib/frameworks/next/index.js +34 -32
- package/lib/frameworks/next/utils.js +40 -39
- package/lib/frameworks/nuxt/index.js +9 -9
- package/lib/frameworks/nuxt/utils.js +4 -6
- package/lib/frameworks/nuxt2/index.js +7 -7
- package/lib/frameworks/sveltekit/index.js +6 -8
- package/lib/frameworks/utils.js +26 -24
- package/lib/frameworks/vite/index.js +8 -9
- package/lib/fsAsync.js +1 -2
- package/lib/fsutils.js +5 -6
- package/lib/functional.js +11 -11
- package/lib/functions/artifacts.js +25 -22
- package/lib/functions/ensureTargeted.js +1 -2
- package/lib/functions/env.js +13 -14
- package/lib/functions/functionslog.js +2 -3
- package/lib/functions/projectConfig.js +29 -33
- package/lib/functions/python.js +10 -4
- package/lib/functions/secrets.js +32 -18
- package/lib/functionsConfig.js +14 -14
- package/lib/functionsConfigClone.js +1 -2
- package/lib/functionsShellCommandAction.js +2 -3
- package/lib/gcp/apphosting.js +43 -28
- package/lib/gcp/apptesting.js +2 -2
- package/lib/gcp/artifactregistry.js +5 -5
- package/lib/gcp/auth.js +11 -13
- package/lib/gcp/cloudbilling.js +4 -5
- package/lib/gcp/cloudbuild.js +10 -11
- package/lib/gcp/cloudfunctions.js +61 -45
- package/lib/gcp/cloudfunctionsv2.js +81 -43
- package/lib/gcp/cloudlogging.js +2 -4
- package/lib/gcp/cloudmonitoring.js +7 -7
- package/lib/gcp/cloudscheduler.js +12 -14
- package/lib/gcp/cloudsql/cloudsqladmin.js +18 -20
- package/lib/gcp/cloudsql/connect.js +14 -9
- package/lib/gcp/cloudsql/fbToolsAuthClient.js +5 -3
- package/lib/gcp/cloudsql/interactive.js +2 -3
- package/lib/gcp/cloudsql/permissions.js +8 -8
- package/lib/gcp/cloudsql/permissionsSetup.js +9 -9
- package/lib/gcp/cloudtasks.js +19 -18
- package/lib/gcp/computeEngine.js +1 -2
- package/lib/gcp/devConnect.js +32 -29
- package/lib/gcp/docker.js +2 -4
- package/lib/gcp/eventarc.js +5 -5
- package/lib/gcp/firedata.js +4 -4
- package/lib/gcp/firestore.js +16 -16
- package/lib/gcp/iam.js +11 -12
- package/lib/gcp/identityPlatform.js +4 -5
- package/lib/gcp/k8s.js +1 -2
- package/lib/gcp/location.js +2 -2
- package/lib/gcp/proto.js +10 -11
- package/lib/gcp/pubsub.js +4 -5
- package/lib/gcp/resourceManager.js +5 -5
- package/lib/gcp/rules.js +13 -14
- package/lib/gcp/run.js +24 -31
- package/lib/gcp/runv2.js +39 -27
- package/lib/gcp/secretManager.js +60 -39
- package/lib/gcp/serviceusage.js +8 -4
- package/lib/gcp/storage.js +22 -20
- package/lib/gemini/fdcExperience.js +5 -5
- package/lib/getDefaultDatabaseInstance.js +2 -4
- package/lib/getDefaultHostingSite.js +3 -4
- package/lib/getProjectNumber.js +1 -2
- package/lib/hosting/api.js +32 -36
- package/lib/hosting/cloudRunProxy.js +2 -3
- package/lib/hosting/config.js +17 -17
- package/lib/hosting/expireUtils.js +3 -3
- package/lib/hosting/functionsProxy.js +1 -2
- package/lib/hosting/implicitInit.js +1 -2
- package/lib/hosting/initMiddleware.js +1 -2
- package/lib/hosting/interactive.js +1 -2
- package/lib/hosting/proxy.js +3 -5
- package/lib/hosting/runTags.js +8 -11
- package/lib/init/features/account.js +1 -2
- package/lib/init/features/ailogic/index.js +3 -5
- package/lib/init/features/ailogic/utils.js +6 -8
- package/lib/init/features/aitools/claude.js +1 -2
- package/lib/init/features/aitools/cursor.js +1 -2
- package/lib/init/features/aitools/gemini.js +1 -1
- package/lib/init/features/aitools/promptUpdater.js +10 -12
- package/lib/init/features/aitools.js +1 -2
- package/lib/init/features/apphosting.js +3 -4
- package/lib/init/features/apptesting/index.js +9 -9
- package/lib/init/features/database.js +4 -5
- package/lib/init/features/dataconnect/create_app.js +3 -4
- package/lib/init/features/dataconnect/index.js +25 -22
- package/lib/init/features/dataconnect/resolver.js +6 -10
- package/lib/init/features/dataconnect/sdk.js +31 -24
- package/lib/init/features/emulators.js +7 -6
- package/lib/init/features/extensions/index.js +3 -5
- package/lib/init/features/firestore/index.js +7 -9
- package/lib/init/features/firestore/indexes.js +2 -2
- package/lib/init/features/firestore/rules.js +3 -3
- package/lib/init/features/functions/index.js +3 -5
- package/lib/init/features/functions/javascript.js +1 -2
- package/lib/init/features/functions/npm-dependencies.js +1 -2
- package/lib/init/features/functions/python.js +1 -2
- package/lib/init/features/functions/typescript.js +1 -2
- package/lib/init/features/genkit/index.js +44 -18
- package/lib/init/features/hosting/github.js +6 -8
- package/lib/init/features/hosting/index.js +10 -13
- package/lib/init/features/project.js +4 -7
- package/lib/init/features/remoteconfig.js +1 -2
- package/lib/init/features/storage.js +3 -5
- package/lib/init/index.js +4 -7
- package/lib/init/spawn.js +7 -9
- package/lib/listFiles.js +1 -2
- package/lib/loadCJSON.js +1 -2
- package/lib/localFunction.js +14 -15
- package/lib/logError.js +1 -2
- package/lib/logger.js +7 -7
- package/lib/management/apps.js +22 -22
- package/lib/management/database.js +11 -12
- package/lib/management/projects.js +57 -56
- package/lib/management/provisioning/errorHandler.js +3 -5
- package/lib/management/provisioning/provision.js +15 -9
- package/lib/management/studio.js +2 -3
- package/lib/mcp/errors.js +4 -4
- package/lib/mcp/index.js +16 -23
- package/lib/mcp/prompt.js +1 -2
- package/lib/mcp/prompts/core/consult.js +2 -3
- package/lib/mcp/prompts/crashlytics/connect.js +15 -122
- package/lib/mcp/prompts/dataconnect/schema.js +3 -3
- package/lib/mcp/prompts/index.js +8 -10
- package/lib/mcp/resource.js +3 -15
- package/lib/mcp/resources/guides/app_id.js +39 -0
- package/lib/mcp/resources/guides/crashlytics_connect.js +51 -0
- package/lib/mcp/resources/guides/crashlytics_investigations.js +51 -0
- package/lib/mcp/resources/guides/crashlytics_issues.js +42 -0
- package/lib/mcp/resources/guides/crashlytics_reports.js +112 -0
- package/lib/mcp/resources/index.js +11 -3
- package/lib/mcp/tool.js +3 -15
- package/lib/mcp/tools/apphosting/fetch_logs.js +3 -4
- package/lib/mcp/tools/apphosting/list_backends.js +1 -1
- package/lib/mcp/tools/auth/get_users.js +5 -16
- package/lib/mcp/tools/core/create_android_sha.js +4 -1
- package/lib/mcp/tools/core/get_environment.js +3 -3
- package/lib/mcp/tools/core/get_sdk_config.js +4 -5
- package/lib/mcp/tools/core/get_security_rules.js +1 -2
- package/lib/mcp/tools/core/init.js +2 -2
- package/lib/mcp/tools/core/logout.js +1 -1
- package/lib/mcp/tools/core/read_resources.js +2 -2
- package/lib/mcp/tools/core/validate_security_rules.js +1 -2
- package/lib/mcp/tools/crashlytics/events.js +43 -19
- package/lib/mcp/tools/crashlytics/index.js +1 -6
- package/lib/mcp/tools/crashlytics/issues.js +33 -12
- package/lib/mcp/tools/crashlytics/reports.js +66 -117
- package/lib/mcp/tools/dataconnect/list_services.js +2 -3
- package/lib/mcp/tools/firestore/converter.js +3 -5
- package/lib/mcp/tools/firestore/delete_document.js +1 -1
- package/lib/mcp/tools/functions/get_logs.js +14 -12
- package/lib/mcp/tools/functions/list_functions.js +1 -1
- package/lib/mcp/tools/index.js +17 -9
- package/lib/mcp/util/apptesting/availability.js +1 -2
- package/lib/mcp/util/availability.js +1 -2
- package/lib/mcp/util/crashlytics/availability.js +1 -2
- package/lib/mcp/util/dataconnect/compile.js +7 -6
- package/lib/mcp/util/dataconnect/converter.js +7 -10
- package/lib/mcp/util/dataconnect/emulator.js +1 -2
- package/lib/mcp/util.js +9 -11
- package/lib/messaging/sendMessage.js +1 -2
- package/lib/metaprogramming.js +1 -2
- package/lib/operation-poller.js +2 -2
- package/lib/profileReport.js +6 -6
- package/lib/profiler.js +1 -2
- package/lib/projectPath.js +1 -2
- package/lib/projectUtils.js +5 -6
- package/lib/prompt.js +22 -13
- package/lib/rc.js +5 -7
- package/lib/remoteconfig/deleteExperiment.js +1 -2
- package/lib/remoteconfig/deleteRollout.js +1 -2
- package/lib/remoteconfig/get.js +2 -3
- package/lib/remoteconfig/getExperiment.js +2 -2
- package/lib/remoteconfig/getRollout.js +2 -2
- package/lib/remoteconfig/interfaces.js +1 -1
- package/lib/remoteconfig/listExperiments.js +2 -2
- package/lib/remoteconfig/listRollouts.js +2 -2
- package/lib/remoteconfig/publish.js +1 -2
- package/lib/remoteconfig/rollback.js +1 -2
- package/lib/remoteconfig/versionslist.js +1 -2
- package/lib/requireAuth.js +4 -6
- package/lib/requireConfig.js +5 -8
- package/lib/requireDatabaseInstance.js +2 -2
- package/lib/requireHostingSite.js +1 -2
- package/lib/requireInteractive.js +1 -1
- package/lib/requirePermissions.js +1 -2
- package/lib/requireTosAcceptance.js +1 -2
- package/lib/responseToError.js +1 -2
- package/lib/rtdb.js +2 -3
- package/lib/rulesDeploy.js +3 -4
- package/lib/serve/functions.js +9 -1
- package/lib/serve/hosting.js +4 -5
- package/lib/serve/index.js +1 -2
- package/lib/shortenUrl.js +1 -2
- package/lib/templates.js +3 -4
- package/lib/throttler/throttler.js +3 -3
- package/lib/timeout.js +2 -3
- package/lib/track.js +23 -14
- package/lib/tsconfig.publish.tsbuildinfo +1 -0
- package/lib/unzip.js +2 -3
- package/lib/utils.js +62 -63
- package/lib/vsCodeUtils.js +2 -3
- package/package.json +6 -6
- package/templates/extensions/typescript/index.ts +1 -1
- package/templates/extensions/typescript/package.lint.json +1 -1
- package/templates/extensions/typescript/package.nolint.json +1 -1
- package/templates/extensions/typescript/tsconfig.json +2 -1
package/lib/gcp/run.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LOCATION_LABEL = void 0;
|
|
4
|
+
exports.gcpIds = gcpIds;
|
|
5
|
+
exports.getService = getService;
|
|
6
|
+
exports.updateService = updateService;
|
|
7
|
+
exports.serviceIsResolved = serviceIsResolved;
|
|
8
|
+
exports.replaceService = replaceService;
|
|
9
|
+
exports.setIamPolicy = setIamPolicy;
|
|
10
|
+
exports.getIamPolicy = getIamPolicy;
|
|
11
|
+
exports.setInvokerCreate = setInvokerCreate;
|
|
12
|
+
exports.setInvokerUpdate = setInvokerUpdate;
|
|
13
|
+
exports.fetchServiceLogs = fetchServiceLogs;
|
|
4
14
|
const apiv2_1 = require("../apiv2");
|
|
5
15
|
const error_1 = require("../error");
|
|
6
16
|
const api_1 = require("../api");
|
|
@@ -16,16 +26,13 @@ const client = new apiv2_1.Client({
|
|
|
16
26
|
});
|
|
17
27
|
exports.LOCATION_LABEL = "cloud.googleapis.com/location";
|
|
18
28
|
function gcpIds(service) {
|
|
19
|
-
var _a;
|
|
20
29
|
return {
|
|
21
30
|
serviceId: service.metadata.name,
|
|
22
31
|
projectNumber: service.metadata.namespace,
|
|
23
|
-
region:
|
|
32
|
+
region: service.metadata.labels?.[exports.LOCATION_LABEL] || "unknown-region",
|
|
24
33
|
};
|
|
25
34
|
}
|
|
26
|
-
exports.gcpIds = gcpIds;
|
|
27
35
|
async function getService(name) {
|
|
28
|
-
var _a, _b;
|
|
29
36
|
try {
|
|
30
37
|
const response = await client.get(name);
|
|
31
38
|
return response.body;
|
|
@@ -33,11 +40,10 @@ async function getService(name) {
|
|
|
33
40
|
catch (err) {
|
|
34
41
|
throw new error_1.FirebaseError(`Failed to fetch Run service ${name}`, {
|
|
35
42
|
original: err,
|
|
36
|
-
status:
|
|
43
|
+
status: err?.context?.response?.statusCode,
|
|
37
44
|
});
|
|
38
45
|
}
|
|
39
46
|
}
|
|
40
|
-
exports.getService = getService;
|
|
41
47
|
async function updateService(name, service) {
|
|
42
48
|
delete service.status;
|
|
43
49
|
service = await exports.replaceService(name, service);
|
|
@@ -49,32 +55,28 @@ async function updateService(name, service) {
|
|
|
49
55
|
}
|
|
50
56
|
return service;
|
|
51
57
|
}
|
|
52
|
-
exports.updateService = updateService;
|
|
53
58
|
function serviceIsResolved(service) {
|
|
54
|
-
|
|
55
|
-
if (((_a = service.status) === null || _a === void 0 ? void 0 : _a.observedGeneration) !== service.metadata.generation) {
|
|
59
|
+
if (service.status?.observedGeneration !== service.metadata.generation) {
|
|
56
60
|
logger_1.logger.debug(`Service ${service.metadata.name} is not resolved because` +
|
|
57
|
-
`observed generation ${
|
|
61
|
+
`observed generation ${service.status?.observedGeneration} does not ` +
|
|
58
62
|
`match spec generation ${service.metadata.generation}`);
|
|
59
63
|
return false;
|
|
60
64
|
}
|
|
61
|
-
const readyCondition =
|
|
65
|
+
const readyCondition = service.status?.conditions?.find((condition) => {
|
|
62
66
|
return condition.type === "Ready";
|
|
63
67
|
});
|
|
64
|
-
if (
|
|
68
|
+
if (readyCondition?.status === "Unknown") {
|
|
65
69
|
logger_1.logger.debug(`Waiting for service ${service.metadata.name} to be ready. ` +
|
|
66
|
-
`Status is ${JSON.stringify(
|
|
70
|
+
`Status is ${JSON.stringify(service.status?.conditions)}`);
|
|
67
71
|
return false;
|
|
68
72
|
}
|
|
69
|
-
else if (
|
|
73
|
+
else if (readyCondition?.status === "True") {
|
|
70
74
|
return true;
|
|
71
75
|
}
|
|
72
76
|
logger_1.logger.debug(`Service ${service.metadata.name} has unexpected ready status ${JSON.stringify(readyCondition)}. It may have failed rollout.`);
|
|
73
|
-
throw new error_1.FirebaseError(`Unexpected Status ${readyCondition
|
|
77
|
+
throw new error_1.FirebaseError(`Unexpected Status ${readyCondition?.status} for service ${service.metadata.name}`);
|
|
74
78
|
}
|
|
75
|
-
exports.serviceIsResolved = serviceIsResolved;
|
|
76
79
|
async function replaceService(name, service) {
|
|
77
|
-
var _a, _b;
|
|
78
80
|
try {
|
|
79
81
|
const response = await client.put(name, service);
|
|
80
82
|
return response.body;
|
|
@@ -82,13 +84,11 @@ async function replaceService(name, service) {
|
|
|
82
84
|
catch (err) {
|
|
83
85
|
throw new error_1.FirebaseError(`Failed to replace Run service ${name}`, {
|
|
84
86
|
original: err,
|
|
85
|
-
status:
|
|
87
|
+
status: err?.context?.response?.statusCode,
|
|
86
88
|
});
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
|
-
exports.replaceService = replaceService;
|
|
90
91
|
async function setIamPolicy(name, policy, httpClient = client) {
|
|
91
|
-
var _a, _b;
|
|
92
92
|
try {
|
|
93
93
|
await httpClient.post(`${name}:setIamPolicy`, {
|
|
94
94
|
policy,
|
|
@@ -98,11 +98,10 @@ async function setIamPolicy(name, policy, httpClient = client) {
|
|
|
98
98
|
catch (err) {
|
|
99
99
|
throw new error_1.FirebaseError(`Failed to set the IAM Policy on the Service ${name}`, {
|
|
100
100
|
original: err,
|
|
101
|
-
status:
|
|
101
|
+
status: err?.context?.response?.statusCode,
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
exports.setIamPolicy = setIamPolicy;
|
|
106
105
|
async function getIamPolicy(serviceName, httpClient = client) {
|
|
107
106
|
try {
|
|
108
107
|
const response = await httpClient.get(`${serviceName}:getIamPolicy`);
|
|
@@ -114,7 +113,6 @@ async function getIamPolicy(serviceName, httpClient = client) {
|
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
115
|
}
|
|
117
|
-
exports.getIamPolicy = getIamPolicy;
|
|
118
116
|
async function setInvokerCreate(projectId, serviceName, invoker, httpClient = client) {
|
|
119
117
|
if (invoker.length === 0) {
|
|
120
118
|
throw new error_1.FirebaseError("Invoker cannot be an empty array");
|
|
@@ -129,16 +127,14 @@ async function setInvokerCreate(projectId, serviceName, invoker, httpClient = cl
|
|
|
129
127
|
};
|
|
130
128
|
await setIamPolicy(serviceName, policy, httpClient);
|
|
131
129
|
}
|
|
132
|
-
exports.setInvokerCreate = setInvokerCreate;
|
|
133
130
|
async function setInvokerUpdate(projectId, serviceName, invoker, httpClient = client) {
|
|
134
|
-
var _a;
|
|
135
131
|
if (invoker.length === 0) {
|
|
136
132
|
throw new error_1.FirebaseError("Invoker cannot be an empty array");
|
|
137
133
|
}
|
|
138
134
|
const invokerMembers = proto.getInvokerMembers(invoker, projectId);
|
|
139
135
|
const invokerRole = "roles/run.invoker";
|
|
140
136
|
const currentPolicy = await getIamPolicy(serviceName, httpClient);
|
|
141
|
-
const currentInvokerBinding =
|
|
137
|
+
const currentInvokerBinding = currentPolicy.bindings?.find((binding) => binding.role === invokerRole);
|
|
142
138
|
if (currentInvokerBinding &&
|
|
143
139
|
JSON.stringify(currentInvokerBinding.members.sort()) === JSON.stringify(invokerMembers.sort())) {
|
|
144
140
|
return;
|
|
@@ -155,9 +151,7 @@ async function setInvokerUpdate(projectId, serviceName, invoker, httpClient = cl
|
|
|
155
151
|
};
|
|
156
152
|
await setIamPolicy(serviceName, policy, httpClient);
|
|
157
153
|
}
|
|
158
|
-
exports.setInvokerUpdate = setInvokerUpdate;
|
|
159
154
|
async function fetchServiceLogs(projectId, serviceId) {
|
|
160
|
-
var _a, _b;
|
|
161
155
|
const filter = `resource.type="cloud_run_revision" AND resource.labels.service_name="${serviceId}"`;
|
|
162
156
|
const pageSize = 100;
|
|
163
157
|
const order = "desc";
|
|
@@ -168,8 +162,7 @@ async function fetchServiceLogs(projectId, serviceId) {
|
|
|
168
162
|
catch (err) {
|
|
169
163
|
throw new error_1.FirebaseError(`Failed to fetch logs for Cloud Run service ${serviceId}`, {
|
|
170
164
|
original: err,
|
|
171
|
-
status:
|
|
165
|
+
status: err?.context?.response?.statusCode,
|
|
172
166
|
});
|
|
173
167
|
}
|
|
174
168
|
}
|
|
175
|
-
exports.fetchServiceLogs = fetchServiceLogs;
|
package/lib/gcp/runv2.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FIREBASE_FUNCTION_METADTA_ANNOTATION = exports.FUNCTION_SIGNATURE_TYPE_ENV = exports.FUNCTION_TARGET_ENV = exports.FUNCTION_ID_ANNOTATION = exports.FUNCTION_TARGET_ANNOTATION = exports.TRIGGER_TYPE_ANNOTATION = exports.CLIENT_NAME_LABEL = exports.RUNTIME_LABEL = exports.API_VERSION = void 0;
|
|
4
|
+
exports.submitBuild = submitBuild;
|
|
5
|
+
exports.updateService = updateService;
|
|
6
|
+
exports.listServices = listServices;
|
|
7
|
+
exports.endpointFromService = endpointFromService;
|
|
8
|
+
exports.serviceFromEndpoint = serviceFromEndpoint;
|
|
4
9
|
const apiv2_1 = require("../apiv2");
|
|
5
10
|
const error_1 = require("../error");
|
|
6
11
|
const api_1 = require("../api");
|
|
@@ -31,7 +36,6 @@ async function submitBuild(projectId, location, build) {
|
|
|
31
36
|
operationResourceName: res.body.buildOperation,
|
|
32
37
|
});
|
|
33
38
|
}
|
|
34
|
-
exports.submitBuild = submitBuild;
|
|
35
39
|
async function updateService(service) {
|
|
36
40
|
const fieldMask = proto.fieldMasks(service, "labels", "annotations", "tags");
|
|
37
41
|
fieldMask.push("template.revision");
|
|
@@ -47,9 +51,7 @@ async function updateService(service) {
|
|
|
47
51
|
});
|
|
48
52
|
return svc;
|
|
49
53
|
}
|
|
50
|
-
exports.updateService = updateService;
|
|
51
54
|
async function listServices(projectId) {
|
|
52
|
-
var _a, _b;
|
|
53
55
|
const allServices = [];
|
|
54
56
|
let pageToken = undefined;
|
|
55
57
|
do {
|
|
@@ -65,8 +67,8 @@ async function listServices(projectId) {
|
|
|
65
67
|
}
|
|
66
68
|
if (res.body.services) {
|
|
67
69
|
for (const service of res.body.services) {
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
+
if (service.labels?.[exports.CLIENT_NAME_LABEL] === "cloud-functions" ||
|
|
71
|
+
service.labels?.[exports.CLIENT_NAME_LABEL] === "firebase-functions") {
|
|
70
72
|
allServices.push(service);
|
|
71
73
|
}
|
|
72
74
|
}
|
|
@@ -75,7 +77,6 @@ async function listServices(projectId) {
|
|
|
75
77
|
} while (pageToken);
|
|
76
78
|
return allServices;
|
|
77
79
|
}
|
|
78
|
-
exports.listServices = listServices;
|
|
79
80
|
function functionNameToServiceName(id) {
|
|
80
81
|
return id.toLowerCase().replace(/_/g, "-");
|
|
81
82
|
}
|
|
@@ -88,32 +89,41 @@ exports.FUNCTION_TARGET_ENV = "FUNCTION_TARGET";
|
|
|
88
89
|
exports.FUNCTION_SIGNATURE_TYPE_ENV = "FUNCTION_SIGNATURE_TYPE";
|
|
89
90
|
exports.FIREBASE_FUNCTION_METADTA_ANNOTATION = "firebase-functions-metadata";
|
|
90
91
|
function endpointFromService(service) {
|
|
91
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
92
92
|
const [, project, , location, , svcId] = service.name.split("/");
|
|
93
|
-
const metadata = JSON.parse(
|
|
93
|
+
const metadata = JSON.parse(service.annotations?.[exports.FIREBASE_FUNCTION_METADTA_ANNOTATION] || "{}");
|
|
94
94
|
const [env, secretEnv] = (0, functional_1.partition)(service.template.containers[0].env || [], (e) => "value" in e);
|
|
95
95
|
const id = metadata.functionId ||
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
service.annotations?.[exports.FUNCTION_ID_ANNOTATION] ||
|
|
97
|
+
service.annotations?.[exports.FUNCTION_TARGET_ANNOTATION] ||
|
|
98
|
+
env.find((e) => e.name === exports.FUNCTION_TARGET_ENV)?.value ||
|
|
99
99
|
svcId;
|
|
100
100
|
const memory = (0, k8s_1.mebibytes)(service.template.containers[0].resources.limits.memory);
|
|
101
101
|
if (!backend.isValidMemoryOption(memory)) {
|
|
102
102
|
logger_1.logger.debug("Converting a service to an endpoint with an invalid memory option", memory);
|
|
103
103
|
}
|
|
104
104
|
const cpu = Number(service.template.containers[0].resources.limits.cpu);
|
|
105
|
-
const endpoint =
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
105
|
+
const endpoint = {
|
|
106
|
+
platform: service.labels?.[exports.CLIENT_NAME_LABEL] === "cloud-functions" ? "gcfv2" : "run",
|
|
107
|
+
id,
|
|
108
|
+
project,
|
|
109
|
+
labels: service.labels || {},
|
|
110
|
+
region: location,
|
|
111
|
+
runtime: service.labels?.[exports.RUNTIME_LABEL] || (0, supported_1.latest)("nodejs"),
|
|
112
|
+
availableMemoryMb: memory,
|
|
113
|
+
cpu: cpu,
|
|
114
|
+
entryPoint: env.find((e) => e.name === exports.FUNCTION_TARGET_ENV)?.value ||
|
|
115
|
+
service.annotations?.[exports.FUNCTION_TARGET_ANNOTATION] ||
|
|
116
|
+
service.annotations?.[exports.FUNCTION_ID_ANNOTATION] ||
|
|
117
|
+
id,
|
|
118
|
+
...(service.annotations?.[exports.TRIGGER_TYPE_ANNOTATION] === "HTTP_TRIGGER"
|
|
119
|
+
? { httpsTrigger: {} }
|
|
120
|
+
: {
|
|
121
|
+
eventTrigger: {
|
|
122
|
+
eventType: service.annotations?.[exports.TRIGGER_TYPE_ANNOTATION] || "unknown",
|
|
123
|
+
retry: false,
|
|
124
|
+
},
|
|
125
|
+
}),
|
|
126
|
+
};
|
|
117
127
|
proto.renameIfPresent(endpoint, service.template, "concurrency", "containerConcurrency");
|
|
118
128
|
proto.renameIfPresent(endpoint, service.labels || {}, "codebase", constants_1.CODEBASE_LABEL);
|
|
119
129
|
proto.renameIfPresent(endpoint, service.scaling || {}, "minInstances", "minInstanceCount");
|
|
@@ -133,9 +143,12 @@ function endpointFromService(service) {
|
|
|
133
143
|
});
|
|
134
144
|
return endpoint;
|
|
135
145
|
}
|
|
136
|
-
exports.endpointFromService = endpointFromService;
|
|
137
146
|
function serviceFromEndpoint(endpoint, image) {
|
|
138
|
-
const labels =
|
|
147
|
+
const labels = {
|
|
148
|
+
...endpoint.labels,
|
|
149
|
+
...(endpoint.runtime ? { [exports.RUNTIME_LABEL]: endpoint.runtime } : {}),
|
|
150
|
+
[exports.CLIENT_NAME_LABEL]: "firebase-functions",
|
|
151
|
+
};
|
|
139
152
|
delete labels["deployment-tool"];
|
|
140
153
|
if (endpoint.codebase) {
|
|
141
154
|
labels[constants_1.CODEBASE_LABEL] = endpoint.codebase;
|
|
@@ -200,4 +213,3 @@ function serviceFromEndpoint(endpoint, image) {
|
|
|
200
213
|
}
|
|
201
214
|
return service;
|
|
202
215
|
}
|
|
203
|
-
exports.serviceFromEndpoint = serviceFromEndpoint;
|
package/lib/gcp/secretManager.js
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FIREBASE_MANAGED = exports.secretManagerConsoleUri = void 0;
|
|
4
|
+
exports.getSecret = getSecret;
|
|
5
|
+
exports.listSecrets = listSecrets;
|
|
6
|
+
exports.getSecretMetadata = getSecretMetadata;
|
|
7
|
+
exports.listSecretVersions = listSecretVersions;
|
|
8
|
+
exports.getSecretVersion = getSecretVersion;
|
|
9
|
+
exports.accessSecretVersion = accessSecretVersion;
|
|
10
|
+
exports.destroySecretVersion = destroySecretVersion;
|
|
11
|
+
exports.secretExists = secretExists;
|
|
12
|
+
exports.parseSecretResourceName = parseSecretResourceName;
|
|
13
|
+
exports.parseSecretVersionResourceName = parseSecretVersionResourceName;
|
|
14
|
+
exports.toSecretVersionResourceName = toSecretVersionResourceName;
|
|
15
|
+
exports.createSecret = createSecret;
|
|
16
|
+
exports.patchSecret = patchSecret;
|
|
17
|
+
exports.deleteSecret = deleteSecret;
|
|
18
|
+
exports.addVersion = addVersion;
|
|
19
|
+
exports.getIamPolicy = getIamPolicy;
|
|
20
|
+
exports.setIamPolicy = setIamPolicy;
|
|
21
|
+
exports.ensureServiceAgentRole = ensureServiceAgentRole;
|
|
22
|
+
exports.checkServiceAgentRole = checkServiceAgentRole;
|
|
23
|
+
exports.isFunctionsManaged = isFunctionsManaged;
|
|
24
|
+
exports.isAppHostingManaged = isAppHostingManaged;
|
|
25
|
+
exports.ensureApi = ensureApi;
|
|
26
|
+
exports.labels = labels;
|
|
4
27
|
const utils_1 = require("../utils");
|
|
5
28
|
const error_1 = require("../error");
|
|
6
29
|
const apiv2_1 = require("../apiv2");
|
|
@@ -17,16 +40,13 @@ exports.secretManagerConsoleUri = secretManagerConsoleUri;
|
|
|
17
40
|
const API_VERSION = "v1";
|
|
18
41
|
const client = new apiv2_1.Client({ urlPrefix: (0, api_1.secretManagerOrigin)(), apiVersion: API_VERSION });
|
|
19
42
|
async function getSecret(projectId, name) {
|
|
20
|
-
var _a, _b;
|
|
21
43
|
const getRes = await client.get(`projects/${projectId}/secrets/${name}`);
|
|
22
44
|
const secret = parseSecretResourceName(getRes.body.name);
|
|
23
|
-
secret.labels =
|
|
24
|
-
secret.replication =
|
|
45
|
+
secret.labels = getRes.body.labels ?? {};
|
|
46
|
+
secret.replication = getRes.body.replication ?? {};
|
|
25
47
|
return secret;
|
|
26
48
|
}
|
|
27
|
-
exports.getSecret = getSecret;
|
|
28
49
|
async function listSecrets(projectId, filter) {
|
|
29
|
-
var _a, _b;
|
|
30
50
|
const secrets = [];
|
|
31
51
|
const path = `projects/${projectId}/secrets`;
|
|
32
52
|
const baseOpts = filter ? { queryParams: { filter } } : {};
|
|
@@ -34,10 +54,14 @@ async function listSecrets(projectId, filter) {
|
|
|
34
54
|
while (true) {
|
|
35
55
|
const opts = pageToken === ""
|
|
36
56
|
? baseOpts
|
|
37
|
-
:
|
|
57
|
+
: { ...baseOpts, queryParams: { ...baseOpts?.queryParams, pageToken } };
|
|
38
58
|
const res = await client.get(path, opts);
|
|
39
59
|
for (const s of res.body.secrets || []) {
|
|
40
|
-
secrets.push(
|
|
60
|
+
secrets.push({
|
|
61
|
+
...parseSecretResourceName(s.name),
|
|
62
|
+
labels: s.labels ?? {},
|
|
63
|
+
replication: s.replication ?? {},
|
|
64
|
+
});
|
|
41
65
|
}
|
|
42
66
|
if (!res.body.nextPageToken) {
|
|
43
67
|
break;
|
|
@@ -46,7 +70,6 @@ async function listSecrets(projectId, filter) {
|
|
|
46
70
|
}
|
|
47
71
|
return secrets;
|
|
48
72
|
}
|
|
49
|
-
exports.listSecrets = listSecrets;
|
|
50
73
|
async function getSecretMetadata(projectId, secretName, version) {
|
|
51
74
|
const secretInfo = {};
|
|
52
75
|
try {
|
|
@@ -60,7 +83,6 @@ async function getSecretMetadata(projectId, secretName, version) {
|
|
|
60
83
|
}
|
|
61
84
|
return secretInfo;
|
|
62
85
|
}
|
|
63
|
-
exports.getSecretMetadata = getSecretMetadata;
|
|
64
86
|
async function listSecretVersions(projectId, name, filter) {
|
|
65
87
|
const secrets = [];
|
|
66
88
|
const path = `projects/${projectId}/secrets/${name}/versions`;
|
|
@@ -69,10 +91,14 @@ async function listSecretVersions(projectId, name, filter) {
|
|
|
69
91
|
while (true) {
|
|
70
92
|
const opts = pageToken === ""
|
|
71
93
|
? baseOpts
|
|
72
|
-
:
|
|
94
|
+
: { ...baseOpts, queryParams: { ...baseOpts?.queryParams, pageToken } };
|
|
73
95
|
const res = await client.get(path, opts);
|
|
74
96
|
for (const s of res.body.versions || []) {
|
|
75
|
-
secrets.push(
|
|
97
|
+
secrets.push({
|
|
98
|
+
...parseSecretVersionResourceName(s.name),
|
|
99
|
+
state: s.state,
|
|
100
|
+
createTime: s.createTime,
|
|
101
|
+
});
|
|
76
102
|
}
|
|
77
103
|
if (!res.body.nextPageToken) {
|
|
78
104
|
break;
|
|
@@ -81,17 +107,18 @@ async function listSecretVersions(projectId, name, filter) {
|
|
|
81
107
|
}
|
|
82
108
|
return secrets;
|
|
83
109
|
}
|
|
84
|
-
exports.listSecretVersions = listSecretVersions;
|
|
85
110
|
async function getSecretVersion(projectId, name, version) {
|
|
86
111
|
const getRes = await client.get(`projects/${projectId}/secrets/${name}/versions/${version}`);
|
|
87
|
-
return
|
|
112
|
+
return {
|
|
113
|
+
...parseSecretVersionResourceName(getRes.body.name),
|
|
114
|
+
state: getRes.body.state,
|
|
115
|
+
createTime: getRes.body.createTime,
|
|
116
|
+
};
|
|
88
117
|
}
|
|
89
|
-
exports.getSecretVersion = getSecretVersion;
|
|
90
118
|
async function accessSecretVersion(projectId, name, version) {
|
|
91
119
|
const res = await client.get(`projects/${projectId}/secrets/${name}/versions/${version}:access`);
|
|
92
120
|
return Buffer.from(res.body.payload.data, "base64").toString();
|
|
93
121
|
}
|
|
94
|
-
exports.accessSecretVersion = accessSecretVersion;
|
|
95
122
|
async function destroySecretVersion(projectId, name, version) {
|
|
96
123
|
if (version === "latest") {
|
|
97
124
|
const sv = await getSecretVersion(projectId, name, "latest");
|
|
@@ -99,7 +126,6 @@ async function destroySecretVersion(projectId, name, version) {
|
|
|
99
126
|
}
|
|
100
127
|
await client.post(`projects/${projectId}/secrets/${name}/versions/${version}:destroy`);
|
|
101
128
|
}
|
|
102
|
-
exports.destroySecretVersion = destroySecretVersion;
|
|
103
129
|
async function secretExists(projectId, name) {
|
|
104
130
|
try {
|
|
105
131
|
await getSecret(projectId, name);
|
|
@@ -112,10 +138,9 @@ async function secretExists(projectId, name) {
|
|
|
112
138
|
throw err;
|
|
113
139
|
}
|
|
114
140
|
}
|
|
115
|
-
exports.secretExists = secretExists;
|
|
116
141
|
function parseSecretResourceName(resourceName) {
|
|
117
142
|
const match = SECRET_NAME_REGEX.exec(resourceName);
|
|
118
|
-
if (!
|
|
143
|
+
if (!match?.groups) {
|
|
119
144
|
throw new error_1.FirebaseError(`Invalid secret resource name [${resourceName}].`);
|
|
120
145
|
}
|
|
121
146
|
return {
|
|
@@ -125,10 +150,9 @@ function parseSecretResourceName(resourceName) {
|
|
|
125
150
|
replication: {},
|
|
126
151
|
};
|
|
127
152
|
}
|
|
128
|
-
exports.parseSecretResourceName = parseSecretResourceName;
|
|
129
153
|
function parseSecretVersionResourceName(resourceName) {
|
|
130
154
|
const match = resourceName.match(SECRET_VERSION_NAME_REGEX);
|
|
131
|
-
if (!
|
|
155
|
+
if (!match?.groups) {
|
|
132
156
|
throw new error_1.FirebaseError(`Invalid secret version resource name [${resourceName}].`);
|
|
133
157
|
}
|
|
134
158
|
return {
|
|
@@ -142,11 +166,9 @@ function parseSecretVersionResourceName(resourceName) {
|
|
|
142
166
|
createTime: "",
|
|
143
167
|
};
|
|
144
168
|
}
|
|
145
|
-
exports.parseSecretVersionResourceName = parseSecretVersionResourceName;
|
|
146
169
|
function toSecretVersionResourceName(secretVersion) {
|
|
147
170
|
return `projects/${secretVersion.secret.projectId}/secrets/${secretVersion.secret.name}/versions/${secretVersion.versionId}`;
|
|
148
171
|
}
|
|
149
|
-
exports.toSecretVersionResourceName = toSecretVersionResourceName;
|
|
150
172
|
async function createSecret(projectId, name, labels, location) {
|
|
151
173
|
let replication;
|
|
152
174
|
if (location) {
|
|
@@ -168,35 +190,41 @@ async function createSecret(projectId, name, labels, location) {
|
|
|
168
190
|
replication,
|
|
169
191
|
labels,
|
|
170
192
|
}, { queryParams: { secretId: name } });
|
|
171
|
-
return
|
|
172
|
-
|
|
193
|
+
return {
|
|
194
|
+
...parseSecretResourceName(createRes.body.name),
|
|
195
|
+
labels,
|
|
196
|
+
replication,
|
|
197
|
+
};
|
|
173
198
|
}
|
|
174
|
-
exports.createSecret = createSecret;
|
|
175
199
|
async function patchSecret(projectId, name, labels) {
|
|
176
200
|
const fullName = `projects/${projectId}/secrets/${name}`;
|
|
177
201
|
const res = await client.patch(fullName, { name: fullName, labels }, { queryParams: { updateMask: "labels" } });
|
|
178
|
-
return
|
|
202
|
+
return {
|
|
203
|
+
...parseSecretResourceName(res.body.name),
|
|
204
|
+
labels: res.body.labels,
|
|
205
|
+
replication: res.body.replication,
|
|
206
|
+
};
|
|
179
207
|
}
|
|
180
|
-
exports.patchSecret = patchSecret;
|
|
181
208
|
async function deleteSecret(projectId, name) {
|
|
182
209
|
const path = `projects/${projectId}/secrets/${name}`;
|
|
183
210
|
await client.delete(path);
|
|
184
211
|
}
|
|
185
|
-
exports.deleteSecret = deleteSecret;
|
|
186
212
|
async function addVersion(projectId, name, payloadData) {
|
|
187
213
|
const res = await client.post(`projects/${projectId}/secrets/${name}:addVersion`, {
|
|
188
214
|
payload: {
|
|
189
215
|
data: Buffer.from(payloadData).toString("base64"),
|
|
190
216
|
},
|
|
191
217
|
});
|
|
192
|
-
return
|
|
218
|
+
return {
|
|
219
|
+
...parseSecretVersionResourceName(res.body.name),
|
|
220
|
+
state: res.body.state,
|
|
221
|
+
createTime: "",
|
|
222
|
+
};
|
|
193
223
|
}
|
|
194
|
-
exports.addVersion = addVersion;
|
|
195
224
|
async function getIamPolicy(secret) {
|
|
196
225
|
const res = await client.get(`projects/${secret.projectId}/secrets/${secret.name}:getIamPolicy`);
|
|
197
226
|
return res.body;
|
|
198
227
|
}
|
|
199
|
-
exports.getIamPolicy = getIamPolicy;
|
|
200
228
|
async function setIamPolicy(secret, bindings) {
|
|
201
229
|
await client.post(`projects/${secret.projectId}/secrets/${secret.name}:setIamPolicy`, {
|
|
202
230
|
policy: {
|
|
@@ -205,7 +233,6 @@ async function setIamPolicy(secret, bindings) {
|
|
|
205
233
|
updateMask: "bindings",
|
|
206
234
|
});
|
|
207
235
|
}
|
|
208
|
-
exports.setIamPolicy = setIamPolicy;
|
|
209
236
|
async function ensureServiceAgentRole(secret, serviceAccountEmails, role) {
|
|
210
237
|
const bindings = await checkServiceAgentRole(secret, serviceAccountEmails, role);
|
|
211
238
|
if (bindings.length) {
|
|
@@ -213,7 +240,6 @@ async function ensureServiceAgentRole(secret, serviceAccountEmails, role) {
|
|
|
213
240
|
}
|
|
214
241
|
(0, utils_1.logLabeledSuccess)("secretmanager", `Granted ${role} on projects/${secret.projectId}/secrets/${secret.name} to ${serviceAccountEmails.join(", ")}`);
|
|
215
242
|
}
|
|
216
|
-
exports.ensureServiceAgentRole = ensureServiceAgentRole;
|
|
217
243
|
async function checkServiceAgentRole(secret, serviceAccountEmails, role) {
|
|
218
244
|
const policy = await module.exports.getIamPolicy(secret);
|
|
219
245
|
const bindings = policy.bindings || [];
|
|
@@ -233,22 +259,17 @@ async function checkServiceAgentRole(secret, serviceAccountEmails, role) {
|
|
|
233
259
|
return [];
|
|
234
260
|
return bindings;
|
|
235
261
|
}
|
|
236
|
-
exports.checkServiceAgentRole = checkServiceAgentRole;
|
|
237
262
|
exports.FIREBASE_MANAGED = "firebase-managed";
|
|
238
263
|
function isFunctionsManaged(secret) {
|
|
239
264
|
return (secret.labels[exports.FIREBASE_MANAGED] === "true" || secret.labels[exports.FIREBASE_MANAGED] === "functions");
|
|
240
265
|
}
|
|
241
|
-
exports.isFunctionsManaged = isFunctionsManaged;
|
|
242
266
|
function isAppHostingManaged(secret) {
|
|
243
267
|
return secret.labels[exports.FIREBASE_MANAGED] === "apphosting";
|
|
244
268
|
}
|
|
245
|
-
exports.isAppHostingManaged = isAppHostingManaged;
|
|
246
269
|
function ensureApi(options) {
|
|
247
270
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
248
271
|
return ensureApiEnabled.ensure(projectId, (0, api_1.secretManagerOrigin)(), "secretmanager", true);
|
|
249
272
|
}
|
|
250
|
-
exports.ensureApi = ensureApi;
|
|
251
273
|
function labels(product = "functions") {
|
|
252
274
|
return { [exports.FIREBASE_MANAGED]: product };
|
|
253
275
|
}
|
|
254
|
-
exports.labels = labels;
|
package/lib/gcp/serviceusage.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.apiClient = void 0;
|
|
4
|
+
exports.generateServiceIdentity = generateServiceIdentity;
|
|
5
|
+
exports.generateServiceIdentityAndPoll = generateServiceIdentityAndPoll;
|
|
4
6
|
const colorette_1 = require("colorette");
|
|
5
7
|
const api_1 = require("../api");
|
|
6
8
|
const apiv2_1 = require("../apiv2");
|
|
@@ -29,12 +31,14 @@ async function generateServiceIdentity(projectNumber, service, prefix) {
|
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
|
-
exports.generateServiceIdentity = generateServiceIdentity;
|
|
33
34
|
async function generateServiceIdentityAndPoll(projectNumber, service, prefix) {
|
|
34
35
|
const op = await generateServiceIdentity(projectNumber, service, prefix);
|
|
35
36
|
if (op.done) {
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
|
-
await poller.pollOperation(
|
|
39
|
+
await poller.pollOperation({
|
|
40
|
+
...serviceUsagePollerOptions,
|
|
41
|
+
operationResourceName: op.name,
|
|
42
|
+
headers: { "x-goog-quota-user": `projects/${projectNumber}` },
|
|
43
|
+
});
|
|
39
44
|
}
|
|
40
|
-
exports.generateServiceIdentityAndPoll = generateServiceIdentityAndPoll;
|