firebase-tools-with-isolate 14.16.0 → 15.11.0-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.
Files changed (666) hide show
  1. package/README.md +59 -52
  2. package/lib/accountExporter.js +2 -3
  3. package/lib/accountImporter.js +4 -5
  4. package/lib/api.js +7 -3
  5. package/lib/apiv2.js +44 -15
  6. package/lib/appUtils.js +251 -0
  7. package/lib/appdistribution/client.js +81 -17
  8. package/lib/appdistribution/distribution.js +85 -2
  9. package/lib/appdistribution/options-parser-util.js +20 -11
  10. package/lib/appdistribution/types.js +3 -14
  11. package/lib/appdistribution/yaml_helper.js +93 -0
  12. package/lib/apphosting/backend.js +16 -17
  13. package/lib/apphosting/config.js +35 -12
  14. package/lib/apphosting/githubConnections.js +20 -20
  15. package/lib/apphosting/localbuilds.js +21 -0
  16. package/lib/apphosting/repo.js +9 -10
  17. package/lib/apphosting/rollout.js +3 -4
  18. package/lib/apphosting/secrets/dialogs.js +10 -10
  19. package/lib/apphosting/secrets/index.js +66 -8
  20. package/lib/apphosting/utils.js +16 -3
  21. package/lib/apphosting/yaml.js +3 -3
  22. package/lib/apptesting/ensureProjectConfigured.js +1 -2
  23. package/lib/apptesting/invokeTests.js +2 -3
  24. package/lib/apptesting/parseTestFiles.js +105 -45
  25. package/lib/apptesting/types.js +2 -2
  26. package/lib/archiveDirectory.js +8 -47
  27. package/lib/auth.js +22 -23
  28. package/lib/bin/cli.js +39 -13
  29. package/lib/bin/firebase.js +1 -2
  30. package/lib/bin/mcp.js +62 -9
  31. package/lib/checkMinRequiredVersion.js +1 -2
  32. package/lib/checkValidTargetFilters.js +1 -2
  33. package/lib/command.js +14 -10
  34. package/lib/commands/appdistribution-distribute.js +14 -87
  35. package/lib/commands/appdistribution-groups-list.js +3 -4
  36. package/lib/commands/appdistribution-testcases-export.js +32 -0
  37. package/lib/commands/appdistribution-testcases-import.js +34 -0
  38. package/lib/commands/appdistribution-testers-list.js +3 -4
  39. package/lib/commands/apphosting-backends-list.js +2 -2
  40. package/lib/commands/apphosting-secrets-set.js +2 -53
  41. package/lib/commands/apps-init.js +7 -7
  42. package/lib/commands/{apptesting-execute.js → apptesting-wata.js} +14 -9
  43. package/lib/commands/apptesting.js +93 -0
  44. package/lib/commands/database-instances-create.js +1 -1
  45. package/lib/commands/dataconnect-compile.js +46 -0
  46. package/lib/commands/dataconnect-execute.js +231 -0
  47. package/lib/commands/dataconnect-sdk-generate.js +71 -13
  48. package/lib/commands/dataconnect-sql-diff.js +9 -6
  49. package/lib/commands/dataconnect-sql-grant.js +14 -13
  50. package/lib/commands/dataconnect-sql-migrate.js +12 -7
  51. package/lib/commands/dataconnect-sql-setup.js +12 -9
  52. package/lib/commands/dataconnect-sql-shell.js +9 -5
  53. package/lib/commands/deploy.js +9 -4
  54. package/lib/commands/ext-dev-upload.js +2 -2
  55. package/lib/commands/firestore-backups-delete.js +1 -6
  56. package/lib/commands/firestore-backups-get.js +2 -8
  57. package/lib/commands/firestore-backups-list.js +5 -11
  58. package/lib/commands/firestore-backups-schedules-create.js +1 -6
  59. package/lib/commands/firestore-backups-schedules-delete.js +1 -6
  60. package/lib/commands/firestore-backups-schedules-list.js +1 -7
  61. package/lib/commands/firestore-backups-schedules-update.js +1 -6
  62. package/lib/commands/firestore-bulkdelete.js +7 -13
  63. package/lib/commands/firestore-databases-clone.js +99 -0
  64. package/lib/commands/firestore-databases-create.js +74 -22
  65. package/lib/commands/firestore-databases-delete.js +1 -6
  66. package/lib/commands/firestore-databases-get.js +1 -7
  67. package/lib/commands/firestore-databases-list.js +1 -7
  68. package/lib/commands/firestore-databases-restore.js +5 -10
  69. package/lib/commands/firestore-databases-update.js +7 -20
  70. package/lib/commands/firestore-locations.js +1 -7
  71. package/lib/commands/firestore-operations-cancel.js +3 -9
  72. package/lib/commands/firestore-operations-describe.js +2 -8
  73. package/lib/commands/firestore-operations-list.js +2 -8
  74. package/lib/commands/firestore-utils.js +1 -2
  75. package/lib/commands/functions-config-clone.js +2 -2
  76. package/lib/commands/functions-config-export.js +136 -92
  77. package/lib/commands/functions-config-get.js +1 -2
  78. package/lib/commands/functions-config-set.js +2 -2
  79. package/lib/commands/functions-config-unset.js +2 -2
  80. package/lib/commands/functions-list.js +16 -6
  81. package/lib/commands/functions-log.js +1 -1
  82. package/lib/commands/functions-secrets-set.js +19 -1
  83. package/lib/commands/help.js +1 -1
  84. package/lib/commands/hosting-channel-deploy.js +2 -2
  85. package/lib/commands/hosting-sites-create.js +4 -3
  86. package/lib/commands/index.js +42 -21
  87. package/lib/commands/init.js +32 -12
  88. package/lib/commands/internaltesting-functions-discover.js +1 -3
  89. package/lib/commands/logout.js +2 -2
  90. package/lib/commands/mcp.js +3 -2
  91. package/lib/commands/remoteconfig-experiments-delete.js +32 -0
  92. package/lib/commands/remoteconfig-experiments-get.js +20 -0
  93. package/lib/commands/remoteconfig-experiments-list.js +37 -0
  94. package/lib/commands/remoteconfig-rollouts-delete.js +32 -0
  95. package/lib/commands/remoteconfig-rollouts-get.js +20 -0
  96. package/lib/commands/remoteconfig-rollouts-list.js +37 -0
  97. package/lib/commands/remoteconfig-versions-list.js +8 -4
  98. package/lib/commands/studio-export.js +39 -0
  99. package/lib/commands/use.js +2 -2
  100. package/lib/config.js +6 -7
  101. package/lib/crashlytics/buildToolsJarHelper.js +2 -3
  102. package/lib/crashlytics/events.js +48 -0
  103. package/lib/crashlytics/filters.js +113 -0
  104. package/lib/crashlytics/issues.js +34 -0
  105. package/lib/crashlytics/notes.js +55 -0
  106. package/lib/crashlytics/reports.js +67 -0
  107. package/lib/crashlytics/types.js +60 -0
  108. package/lib/crashlytics/utils.js +4 -4
  109. package/lib/database/api.js +2 -3
  110. package/lib/database/metadata.js +5 -6
  111. package/lib/database/rulesConfig.js +2 -3
  112. package/lib/dataconnect/build.js +17 -5
  113. package/lib/dataconnect/checkIam.js +1 -2
  114. package/lib/dataconnect/client.js +19 -19
  115. package/lib/dataconnect/dataplaneClient.js +6 -6
  116. package/lib/dataconnect/ensureApis.js +13 -5
  117. package/lib/dataconnect/errors.js +3 -4
  118. package/lib/dataconnect/filters.js +2 -3
  119. package/lib/dataconnect/freeTrial.js +5 -13
  120. package/lib/dataconnect/graphqlError.js +2 -3
  121. package/lib/dataconnect/load.js +86 -38
  122. package/lib/dataconnect/names.js +8 -4
  123. package/lib/dataconnect/prompts.js +15 -2
  124. package/lib/dataconnect/provisionCloudSql.js +62 -27
  125. package/lib/dataconnect/schemaMigration.js +95 -30
  126. package/lib/dataconnect/types.js +44 -14
  127. package/lib/dataconnect/webhook.js +3 -3
  128. package/lib/defaultCredentials.js +3 -4
  129. package/lib/deploy/apphosting/deploy.js +48 -48
  130. package/lib/deploy/apphosting/prepare.js +32 -11
  131. package/lib/deploy/apphosting/release.js +32 -27
  132. package/lib/deploy/apphosting/util.js +8 -11
  133. package/lib/deploy/auth/deploy.js +63 -0
  134. package/lib/deploy/auth/index.js +9 -0
  135. package/lib/deploy/auth/prepare.js +26 -0
  136. package/lib/deploy/auth/release.js +5 -0
  137. package/lib/deploy/database/deploy.js +1 -2
  138. package/lib/deploy/database/prepare.js +2 -5
  139. package/lib/deploy/database/release.js +1 -2
  140. package/lib/deploy/dataconnect/context.js +37 -0
  141. package/lib/deploy/dataconnect/deploy.js +15 -6
  142. package/lib/deploy/dataconnect/prepare.js +15 -14
  143. package/lib/deploy/dataconnect/release.js +41 -7
  144. package/lib/deploy/extensions/deploy.js +1 -2
  145. package/lib/deploy/extensions/deploymentSummary.js +5 -5
  146. package/lib/deploy/extensions/planner.js +8 -9
  147. package/lib/deploy/extensions/prepare.js +18 -8
  148. package/lib/deploy/extensions/release.js +1 -2
  149. package/lib/deploy/extensions/secrets.js +2 -3
  150. package/lib/deploy/extensions/tasks.js +5 -6
  151. package/lib/deploy/extensions/v2FunctionHelper.js +2 -3
  152. package/lib/deploy/extensions/validate.js +1 -2
  153. package/lib/deploy/firestore/deploy.js +1 -47
  154. package/lib/deploy/firestore/prepare.js +69 -1
  155. package/lib/deploy/firestore/release.js +1 -1
  156. package/lib/deploy/functions/backend.js +81 -55
  157. package/lib/deploy/functions/build.js +54 -24
  158. package/lib/deploy/functions/cache/applyHash.js +1 -2
  159. package/lib/deploy/functions/cache/hash.js +4 -5
  160. package/lib/deploy/functions/cel.js +3 -3
  161. package/lib/deploy/functions/checkIam.js +11 -10
  162. package/lib/deploy/functions/containerCleaner.js +4 -4
  163. package/lib/deploy/functions/deploy.js +56 -15
  164. package/lib/deploy/functions/ensure.js +3 -4
  165. package/lib/deploy/functions/functionsDeployHelper.js +18 -18
  166. package/lib/deploy/functions/params.js +27 -17
  167. package/lib/deploy/functions/prepare.js +52 -41
  168. package/lib/deploy/functions/prepareFunctionsUpload.js +36 -16
  169. package/lib/deploy/functions/pricing.js +19 -4
  170. package/lib/deploy/functions/prompts.js +5 -6
  171. package/lib/deploy/functions/release/fabricator.js +116 -16
  172. package/lib/deploy/functions/release/index.js +14 -7
  173. package/lib/deploy/functions/release/planner.js +13 -11
  174. package/lib/deploy/functions/release/reporter.js +8 -5
  175. package/lib/deploy/functions/remoteSource.js +83 -0
  176. package/lib/deploy/functions/runtimes/dart/index.js +282 -0
  177. package/lib/deploy/functions/runtimes/discovery/index.js +5 -6
  178. package/lib/deploy/functions/runtimes/discovery/parsing.js +2 -3
  179. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +28 -5
  180. package/lib/deploy/functions/runtimes/index.js +10 -3
  181. package/lib/deploy/functions/runtimes/node/index.js +13 -14
  182. package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +2 -2
  183. package/lib/deploy/functions/runtimes/node/validate.js +1 -2
  184. package/lib/deploy/functions/runtimes/node/versioning.js +7 -7
  185. package/lib/deploy/functions/runtimes/python/index.js +3 -3
  186. package/lib/deploy/functions/runtimes/supported/index.js +9 -6
  187. package/lib/deploy/functions/runtimes/supported/types.js +12 -0
  188. package/lib/deploy/functions/services/database.js +1 -2
  189. package/lib/deploy/functions/services/dataconnect.js +28 -0
  190. package/lib/deploy/functions/services/firebaseAlerts.js +1 -2
  191. package/lib/deploy/functions/services/firestore.js +2 -3
  192. package/lib/deploy/functions/services/index.js +13 -2
  193. package/lib/deploy/functions/services/remoteConfig.js +1 -2
  194. package/lib/deploy/functions/services/storage.js +2 -3
  195. package/lib/deploy/functions/services/testLab.js +1 -2
  196. package/lib/deploy/functions/triggerRegionHelper.js +1 -2
  197. package/lib/deploy/functions/validate.js +95 -8
  198. package/lib/deploy/hosting/convertConfig.js +2 -3
  199. package/lib/deploy/hosting/deploy.js +1 -2
  200. package/lib/deploy/hosting/hashcache.js +2 -3
  201. package/lib/deploy/hosting/prepare.js +4 -5
  202. package/lib/deploy/hosting/release.js +1 -2
  203. package/lib/deploy/hosting/uploader.js +1 -1
  204. package/lib/deploy/index.js +39 -18
  205. package/lib/deploy/lifecycleHooks.js +1 -2
  206. package/lib/deploy/remoteconfig/deploy.js +1 -1
  207. package/lib/deploy/remoteconfig/functions.js +4 -5
  208. package/lib/deploy/remoteconfig/prepare.js +1 -1
  209. package/lib/deploy/remoteconfig/release.js +1 -1
  210. package/lib/deploy/storage/deploy.js +1 -1
  211. package/lib/deploy/storage/prepare.js +1 -1
  212. package/lib/deploy/storage/release.js +1 -1
  213. package/lib/deploymentTool.js +4 -4
  214. package/lib/detectProjectRoot.js +2 -3
  215. package/lib/downloadUtils.js +5 -4
  216. package/lib/emulator/adminSdkConfig.js +2 -3
  217. package/lib/emulator/apphosting/config.js +2 -23
  218. package/lib/emulator/apphosting/developmentServer.js +4 -4
  219. package/lib/emulator/apphosting/serve.js +42 -45
  220. package/lib/emulator/auth/errors.js +2 -2
  221. package/lib/emulator/auth/handlers.js +1 -2
  222. package/lib/emulator/auth/index.js +24 -18
  223. package/lib/emulator/auth/operations.js +22 -8
  224. package/lib/emulator/auth/server.js +1 -2
  225. package/lib/emulator/auth/state.js +5 -5
  226. package/lib/emulator/auth/utils.js +11 -12
  227. package/lib/emulator/commandUtils.js +14 -14
  228. package/lib/emulator/controller.js +12 -12
  229. package/lib/emulator/databaseEmulator.js +1 -5
  230. package/lib/emulator/dataconnect/pgliteServer.js +27 -34
  231. package/lib/emulator/dataconnectEmulator.js +1 -2
  232. package/lib/emulator/download.js +17 -4
  233. package/lib/emulator/downloadableEmulatorInfo.json +39 -31
  234. package/lib/emulator/downloadableEmulators.js +124 -86
  235. package/lib/emulator/emulatorLogger.js +1 -1
  236. package/lib/emulator/env.js +3 -4
  237. package/lib/emulator/eventarcEmulatorUtils.js +1 -2
  238. package/lib/emulator/extensions/postinstall.js +1 -2
  239. package/lib/emulator/extensions/validation.js +2 -3
  240. package/lib/emulator/functionsEmulator.js +103 -64
  241. package/lib/emulator/functionsEmulatorRuntime.js +5 -114
  242. package/lib/emulator/functionsEmulatorShared.js +18 -20
  243. package/lib/emulator/functionsEmulatorUtils.js +8 -9
  244. package/lib/emulator/functionsRuntimeWorker.js +22 -19
  245. package/lib/emulator/hub.js +35 -33
  246. package/lib/emulator/hubExport.js +27 -7
  247. package/lib/emulator/initEmulators.js +1 -1
  248. package/lib/emulator/portUtils.js +4 -5
  249. package/lib/emulator/shared/request.js +1 -2
  250. package/lib/emulator/storage/apis/firebase.js +1 -2
  251. package/lib/emulator/storage/apis/gcloud.js +1 -2
  252. package/lib/emulator/storage/apis/shared.js +1 -2
  253. package/lib/emulator/storage/crc.js +2 -3
  254. package/lib/emulator/storage/metadata.js +2 -2
  255. package/lib/emulator/storage/multipart.js +1 -2
  256. package/lib/emulator/storage/rfc.js +1 -2
  257. package/lib/emulator/storage/rules/config.js +1 -2
  258. package/lib/emulator/storage/rules/manager.js +1 -2
  259. package/lib/emulator/storage/rules/types.js +2 -2
  260. package/lib/emulator/storage/rules/utils.js +4 -5
  261. package/lib/emulator/storage/server.js +1 -2
  262. package/lib/emulator/storage/upload.js +2 -2
  263. package/lib/emulator/taskQueue.js +6 -1
  264. package/lib/emulator/types.js +6 -6
  265. package/lib/ensureApiEnabled.js +7 -7
  266. package/lib/env.js +26 -4
  267. package/lib/error.js +7 -7
  268. package/lib/errorOut.js +1 -2
  269. package/lib/experiments.js +36 -18
  270. package/lib/extensions/askUserForEventsConfig.js +7 -7
  271. package/lib/extensions/askUserForParam.js +7 -7
  272. package/lib/extensions/change-log.js +4 -5
  273. package/lib/extensions/checkProjectBilling.js +1 -2
  274. package/lib/extensions/diagnose.js +1 -2
  275. package/lib/extensions/displayExtensionInfo.js +5 -6
  276. package/lib/extensions/emulator/optionsHelper.js +4 -5
  277. package/lib/extensions/emulator/specHelper.js +6 -6
  278. package/lib/extensions/emulator/triggerHelper.js +1 -2
  279. package/lib/extensions/etags.js +2 -3
  280. package/lib/extensions/export.js +3 -4
  281. package/lib/extensions/extensionsApi.js +15 -16
  282. package/lib/extensions/extensionsHelper.js +31 -32
  283. package/lib/extensions/listExtensions.js +1 -2
  284. package/lib/extensions/localHelper.js +5 -5
  285. package/lib/extensions/manifest.js +11 -11
  286. package/lib/extensions/metricsUtils.js +3 -4
  287. package/lib/extensions/paramHelper.js +9 -10
  288. package/lib/extensions/provisioningHelper.js +5 -5
  289. package/lib/extensions/publishHelpers.js +1 -2
  290. package/lib/extensions/publisherApi.js +10 -11
  291. package/lib/extensions/refs.js +6 -7
  292. package/lib/extensions/runtimes/common.js +15 -16
  293. package/lib/extensions/runtimes/node.js +2 -2
  294. package/lib/extensions/secretsUtils.js +8 -8
  295. package/lib/extensions/tos.js +7 -8
  296. package/lib/extensions/types.js +3 -3
  297. package/lib/extensions/updateHelper.js +6 -7
  298. package/lib/extensions/utils.js +4 -5
  299. package/lib/extensions/versionHelper.js +1 -2
  300. package/lib/extensions/warnings.js +2 -3
  301. package/lib/fetchMOTD.js +1 -2
  302. package/lib/fetchWebSetup.js +3 -4
  303. package/lib/filterTargets.js +1 -2
  304. package/lib/firebaseConfigValidate.js +2 -3
  305. package/lib/firebase_studio/migrate.js +653 -0
  306. package/lib/firestore/api-sort.js +8 -9
  307. package/lib/firestore/api-types.js +39 -24
  308. package/lib/firestore/api.js +61 -14
  309. package/lib/firestore/backupUtils.js +3 -3
  310. package/lib/firestore/checkDatabaseType.js +1 -2
  311. package/lib/firestore/encodeFirestoreValue.js +1 -2
  312. package/lib/firestore/fsConfig.js +1 -2
  313. package/lib/firestore/options.js +1 -1
  314. package/lib/firestore/util.js +24 -4
  315. package/lib/firestore/validator.js +4 -5
  316. package/lib/frameworks/angular/index.js +10 -10
  317. package/lib/frameworks/angular/utils.js +10 -10
  318. package/lib/frameworks/astro/index.js +6 -6
  319. package/lib/frameworks/astro/utils.js +3 -4
  320. package/lib/frameworks/compose/discover/filesystem.js +2 -2
  321. package/lib/frameworks/compose/discover/frameworkMatcher.js +4 -5
  322. package/lib/frameworks/compose/discover/index.js +1 -2
  323. package/lib/frameworks/compose/driver/hooks.js +2 -2
  324. package/lib/frameworks/compose/driver/index.js +2 -2
  325. package/lib/frameworks/compose/index.js +1 -2
  326. package/lib/frameworks/constants.js +4 -4
  327. package/lib/frameworks/express/index.js +5 -5
  328. package/lib/frameworks/flutter/index.js +6 -6
  329. package/lib/frameworks/flutter/utils.js +3 -4
  330. package/lib/frameworks/index.js +4 -4
  331. package/lib/frameworks/next/constants.js +6 -1
  332. package/lib/frameworks/next/index.js +38 -11
  333. package/lib/frameworks/next/utils.js +69 -29
  334. package/lib/frameworks/nuxt/index.js +9 -9
  335. package/lib/frameworks/nuxt/utils.js +2 -3
  336. package/lib/frameworks/nuxt2/index.js +6 -6
  337. package/lib/frameworks/sveltekit/index.js +4 -4
  338. package/lib/frameworks/utils.js +13 -14
  339. package/lib/frameworks/vite/index.js +11 -8
  340. package/lib/fsAsync.js +16 -5
  341. package/lib/fsutils.js +5 -6
  342. package/lib/functional.js +11 -11
  343. package/lib/functions/artifacts.js +14 -14
  344. package/lib/functions/ensureTargeted.js +1 -2
  345. package/lib/functions/env.js +10 -10
  346. package/lib/functions/events/v2.js +2 -1
  347. package/lib/functions/functionslog.js +2 -3
  348. package/lib/functions/projectConfig.js +16 -12
  349. package/lib/functions/python.js +3 -3
  350. package/lib/functions/secrets.js +23 -11
  351. package/lib/functionsConfig.js +49 -11
  352. package/lib/functionsConfigClone.js +1 -2
  353. package/lib/gcp/apphosting.js +18 -18
  354. package/lib/gcp/apptesting.js +18 -0
  355. package/lib/gcp/artifactregistry.js +5 -5
  356. package/lib/gcp/auth.js +9 -10
  357. package/lib/gcp/cloudbilling.js +10 -8
  358. package/lib/gcp/cloudbuild.js +10 -11
  359. package/lib/gcp/cloudfunctions.js +14 -14
  360. package/lib/gcp/cloudfunctionsv2.js +47 -18
  361. package/lib/gcp/cloudlogging.js +16 -10
  362. package/lib/gcp/cloudmonitoring.js +7 -7
  363. package/lib/gcp/cloudscheduler.js +20 -8
  364. package/lib/gcp/cloudsql/cloudsqladmin.js +29 -22
  365. package/lib/gcp/cloudsql/connect.js +24 -39
  366. package/lib/gcp/cloudsql/fbToolsAuthClient.js +1 -1
  367. package/lib/gcp/cloudsql/interactive.js +2 -3
  368. package/lib/gcp/cloudsql/permissions.js +8 -8
  369. package/lib/gcp/cloudsql/permissionsSetup.js +13 -13
  370. package/lib/gcp/cloudtasks.js +13 -13
  371. package/lib/gcp/computeEngine.js +1 -2
  372. package/lib/gcp/devConnect.js +17 -17
  373. package/lib/gcp/eventarc.js +5 -5
  374. package/lib/gcp/firedata.js +4 -4
  375. package/lib/gcp/firestore.js +16 -16
  376. package/lib/gcp/iam.js +13 -14
  377. package/lib/gcp/identityPlatform.js +4 -5
  378. package/lib/gcp/k8s.js +1 -2
  379. package/lib/gcp/location.js +2 -2
  380. package/lib/gcp/proto.js +10 -11
  381. package/lib/gcp/pubsub.js +4 -5
  382. package/lib/gcp/resourceManager.js +5 -5
  383. package/lib/gcp/rules.js +18 -16
  384. package/lib/gcp/run.js +13 -13
  385. package/lib/gcp/runv2.js +120 -13
  386. package/lib/gcp/secretManager.js +24 -24
  387. package/lib/gcp/serviceusage.js +5 -5
  388. package/lib/gcp/storage.js +122 -25
  389. package/lib/gemini/fdcExperience.js +4 -15
  390. package/lib/getDefaultDatabaseInstance.js +3 -4
  391. package/lib/getDefaultHostingSite.js +2 -2
  392. package/lib/getProjectNumber.js +1 -2
  393. package/lib/hosting/api.js +26 -26
  394. package/lib/hosting/cloudRunProxy.js +1 -1
  395. package/lib/hosting/config.js +7 -8
  396. package/lib/hosting/expireUtils.js +3 -3
  397. package/lib/hosting/functionsProxy.js +1 -2
  398. package/lib/hosting/implicitInit.js +1 -2
  399. package/lib/hosting/initMiddleware.js +1 -2
  400. package/lib/hosting/interactive.js +13 -19
  401. package/lib/hosting/proxy.js +2 -3
  402. package/lib/hosting/runTags.js +5 -5
  403. package/lib/index.js +44 -1
  404. package/lib/init/features/account.js +1 -2
  405. package/lib/init/features/ailogic/index.js +102 -0
  406. package/lib/init/features/ailogic/utils.js +73 -0
  407. package/lib/init/features/aitools/claude.js +1 -1
  408. package/lib/init/features/aitools/cursor.js +1 -1
  409. package/lib/init/features/aitools/promptUpdater.js +5 -6
  410. package/lib/init/features/aitools.js +1 -2
  411. package/lib/init/features/apphosting.js +2 -3
  412. package/lib/init/features/apptesting/index.js +2 -3
  413. package/lib/init/features/auth.js +72 -0
  414. package/lib/init/features/database.js +4 -4
  415. package/lib/init/features/dataconnect/create_app.js +4 -5
  416. package/lib/init/features/dataconnect/index.js +187 -63
  417. package/lib/init/features/dataconnect/resolver.js +121 -0
  418. package/lib/init/features/dataconnect/sdk.js +125 -53
  419. package/lib/init/features/emulators.js +1 -2
  420. package/lib/init/features/extensions/index.js +1 -2
  421. package/lib/init/features/firestore/index.js +2 -3
  422. package/lib/init/features/firestore/indexes.js +3 -3
  423. package/lib/init/features/firestore/rules.js +3 -3
  424. package/lib/init/features/functions/dart.js +31 -0
  425. package/lib/init/features/functions/index.js +37 -15
  426. package/lib/init/features/functions/javascript.js +19 -5
  427. package/lib/init/features/functions/npm-dependencies.js +1 -2
  428. package/lib/init/features/functions/python.js +1 -2
  429. package/lib/init/features/functions/typescript.js +21 -5
  430. package/lib/init/features/functions/utils.js +10 -0
  431. package/lib/init/features/genkit/index.js +110 -51
  432. package/lib/init/features/hosting/github.js +3 -8
  433. package/lib/init/features/hosting/index.js +96 -125
  434. package/lib/init/features/index.js +14 -3
  435. package/lib/init/features/project.js +66 -76
  436. package/lib/init/features/remoteconfig.js +1 -2
  437. package/lib/init/features/{storage.js → storage/index.js} +14 -7
  438. package/lib/init/features/storage/rules.js +20 -0
  439. package/lib/init/index.js +30 -7
  440. package/lib/init/spawn.js +3 -4
  441. package/lib/listFiles.js +1 -2
  442. package/lib/loadCJSON.js +1 -2
  443. package/lib/logError.js +1 -2
  444. package/lib/logger.js +5 -5
  445. package/lib/management/apps.js +47 -46
  446. package/lib/management/database.js +10 -10
  447. package/lib/management/projects.js +31 -19
  448. package/lib/management/provisioning/errorHandler.js +52 -0
  449. package/lib/management/provisioning/provision.js +116 -0
  450. package/lib/management/provisioning/types.js +9 -0
  451. package/lib/management/studio.js +2 -3
  452. package/lib/mcp/errors.js +7 -8
  453. package/lib/mcp/index.js +174 -94
  454. package/lib/mcp/onemcp/index.js +14 -0
  455. package/lib/mcp/onemcp/onemcp_server.js +76 -0
  456. package/lib/mcp/prompt.js +7 -3
  457. package/lib/mcp/prompts/apptesting/index.js +9 -0
  458. package/lib/mcp/prompts/apptesting/run_test.js +128 -0
  459. package/lib/mcp/prompts/core/deploy.js +10 -11
  460. package/lib/mcp/prompts/core/index.js +3 -1
  461. package/lib/mcp/prompts/core/init.js +93 -0
  462. package/lib/mcp/prompts/crashlytics/connect.js +17 -90
  463. package/lib/mcp/prompts/dataconnect/schema.js +5 -2
  464. package/lib/mcp/prompts/firestore/generate_security_rules.js +384 -0
  465. package/lib/mcp/prompts/firestore/index.js +6 -0
  466. package/lib/mcp/prompts/index.js +53 -15
  467. package/lib/mcp/prompts/storage/generate_security_rules.js +272 -0
  468. package/lib/mcp/prompts/storage/index.js +6 -0
  469. package/lib/mcp/resource.js +27 -0
  470. package/lib/mcp/resources/docs.js +44 -0
  471. package/lib/mcp/resources/guides/app_id.js +39 -0
  472. package/lib/mcp/resources/guides/crashlytics_connect.js +51 -0
  473. package/lib/mcp/resources/guides/crashlytics_investigations.js +51 -0
  474. package/lib/mcp/resources/guides/crashlytics_issues.js +42 -0
  475. package/lib/mcp/resources/guides/crashlytics_reports.js +112 -0
  476. package/lib/mcp/resources/guides/init_ai.js +158 -0
  477. package/lib/mcp/resources/guides/init_auth.js +55 -0
  478. package/lib/mcp/resources/guides/init_backend.js +50 -0
  479. package/lib/mcp/resources/guides/init_data_connect.js +30 -0
  480. package/lib/mcp/resources/guides/init_firestore.js +65 -0
  481. package/lib/mcp/resources/guides/init_firestore_rules.js +58 -0
  482. package/lib/mcp/resources/guides/init_hosting.js +39 -0
  483. package/lib/mcp/resources/guides/init_rtdb.js +30 -0
  484. package/lib/mcp/resources/index.js +63 -0
  485. package/lib/mcp/tool.js +9 -4
  486. package/lib/mcp/tools/apphosting/fetch_logs.js +4 -4
  487. package/lib/mcp/tools/apphosting/list_backends.js +3 -3
  488. package/lib/mcp/tools/apptesting/index.js +9 -0
  489. package/lib/mcp/tools/apptesting/tests.js +101 -0
  490. package/lib/mcp/tools/auth/get_users.js +54 -0
  491. package/lib/mcp/tools/auth/index.js +3 -11
  492. package/lib/mcp/tools/auth/set_sms_region_policy.js +2 -2
  493. package/lib/mcp/tools/auth/update_user.js +86 -0
  494. package/lib/mcp/tools/core/create_android_sha.js +2 -2
  495. package/lib/mcp/tools/core/create_app.js +2 -2
  496. package/lib/mcp/tools/core/create_project.js +2 -2
  497. package/lib/mcp/tools/core/get_environment.js +76 -30
  498. package/lib/mcp/tools/core/get_project.js +2 -2
  499. package/lib/mcp/tools/core/get_sdk_config.js +3 -2
  500. package/lib/mcp/tools/core/get_security_rules.js +54 -0
  501. package/lib/mcp/tools/core/index.js +6 -4
  502. package/lib/mcp/tools/core/init.js +90 -9
  503. package/lib/mcp/tools/core/list_apps.js +2 -2
  504. package/lib/mcp/tools/core/list_projects.js +2 -2
  505. package/lib/mcp/tools/core/login.js +2 -2
  506. package/lib/mcp/tools/core/logout.js +3 -4
  507. package/lib/mcp/tools/core/read_resources.js +40 -0
  508. package/lib/mcp/tools/core/update_environment.js +4 -3
  509. package/lib/mcp/tools/core/validate_security_rules.js +125 -0
  510. package/lib/mcp/tools/crashlytics/events.js +176 -0
  511. package/lib/mcp/tools/crashlytics/index.js +12 -20
  512. package/lib/mcp/tools/crashlytics/issues.js +77 -0
  513. package/lib/mcp/tools/crashlytics/notes.js +79 -0
  514. package/lib/mcp/tools/crashlytics/reports.js +78 -0
  515. package/lib/mcp/tools/dataconnect/compile.js +14 -8
  516. package/lib/mcp/tools/dataconnect/execute.js +12 -10
  517. package/lib/mcp/tools/dataconnect/index.js +1 -9
  518. package/lib/mcp/tools/dataconnect/list_services.js +4 -3
  519. package/lib/mcp/tools/firestore/converter.js +2 -3
  520. package/lib/mcp/tools/firestore/index.js +1 -13
  521. package/lib/mcp/tools/firestore/query_collection.js +2 -2
  522. package/lib/mcp/tools/functions/get_logs.js +153 -0
  523. package/lib/mcp/tools/functions/index.js +6 -0
  524. package/lib/mcp/tools/functions/list_functions.js +48 -0
  525. package/lib/mcp/tools/index.js +87 -40
  526. package/lib/mcp/tools/messaging/send_message.js +2 -2
  527. package/lib/mcp/tools/{database → realtime_database}/get_data.js +2 -2
  528. package/lib/mcp/tools/{database → realtime_database}/index.js +1 -3
  529. package/lib/mcp/tools/{database → realtime_database}/set_data.js +2 -2
  530. package/lib/mcp/tools/remoteconfig/get_template.js +2 -2
  531. package/lib/mcp/tools/remoteconfig/index.js +2 -3
  532. package/lib/mcp/tools/remoteconfig/update_template.js +43 -0
  533. package/lib/mcp/tools/storage/get_download_url.js +2 -2
  534. package/lib/mcp/tools/storage/index.js +1 -7
  535. package/lib/mcp/types.js +3 -0
  536. package/lib/mcp/util/apptesting/availability.js +23 -0
  537. package/lib/mcp/util/availability.js +24 -0
  538. package/lib/mcp/util/crashlytics/availability.js +68 -0
  539. package/lib/mcp/util/dataconnect/compile.js +1 -2
  540. package/lib/mcp/util/dataconnect/converter.js +10 -10
  541. package/lib/mcp/util/dataconnect/emulator.js +1 -3
  542. package/lib/mcp/util.js +35 -11
  543. package/lib/messaging/sendMessage.js +1 -2
  544. package/lib/metaprogramming.js +1 -2
  545. package/lib/operation-poller.js +2 -2
  546. package/lib/profileReport.js +6 -6
  547. package/lib/profiler.js +1 -2
  548. package/lib/projectPath.js +1 -2
  549. package/lib/projectUtils.js +4 -5
  550. package/lib/prompt.js +9 -9
  551. package/lib/rc.js +2 -2
  552. package/lib/remoteconfig/deleteExperiment.js +31 -0
  553. package/lib/remoteconfig/deleteRollout.js +32 -0
  554. package/lib/remoteconfig/get.js +2 -3
  555. package/lib/remoteconfig/getExperiment.js +52 -0
  556. package/lib/remoteconfig/getRollout.js +43 -0
  557. package/lib/remoteconfig/interfaces.js +4 -2
  558. package/lib/remoteconfig/listExperiments.js +72 -0
  559. package/lib/remoteconfig/listRollouts.js +72 -0
  560. package/lib/remoteconfig/options.js +4 -0
  561. package/lib/remoteconfig/publish.js +1 -2
  562. package/lib/remoteconfig/rollback.js +1 -2
  563. package/lib/remoteconfig/versionslist.js +1 -2
  564. package/lib/requireAuth.js +2 -3
  565. package/lib/requireConfig.js +1 -2
  566. package/lib/requireDatabaseInstance.js +3 -3
  567. package/lib/requireHostingSite.js +1 -2
  568. package/lib/requireInteractive.js +1 -1
  569. package/lib/requirePermissions.js +1 -2
  570. package/lib/requireTosAcceptance.js +1 -2
  571. package/lib/responseToError.js +8 -8
  572. package/lib/rtdb.js +2 -3
  573. package/lib/rulesDeploy.js +1 -1
  574. package/lib/serve/hosting.js +3 -4
  575. package/lib/serve/index.js +1 -2
  576. package/lib/shortenUrl.js +1 -2
  577. package/lib/templates.js +3 -4
  578. package/lib/throttler/throttler.js +3 -3
  579. package/lib/timeout.js +2 -3
  580. package/lib/track.js +10 -23
  581. package/lib/tsconfig.publish.tsbuildinfo +1 -0
  582. package/lib/utils.js +76 -61
  583. package/lib/vsCodeUtils.js +2 -3
  584. package/package.json +20 -17
  585. package/schema/connector-yaml.json +30 -0
  586. package/schema/dataconnect-yaml.json +4 -0
  587. package/schema/firebase-config.json +59 -1
  588. package/templates/extensions/typescript/index.ts +1 -1
  589. package/templates/extensions/typescript/package.lint.json +1 -1
  590. package/templates/extensions/typescript/package.nolint.json +1 -1
  591. package/templates/extensions/typescript/tsconfig.json +2 -1
  592. package/templates/firebase-studio-export/readme_template.md +17 -0
  593. package/templates/firebase-studio-export/system_instructions_template.md +39 -0
  594. package/templates/firebase-studio-export/workflows/cleanup.md +20 -0
  595. package/templates/genkit/firebase.1.18.0.template +72 -0
  596. package/templates/init/aitools/gemini-extension.json +1 -1
  597. package/templates/init/apphosting/apphosting.yaml +1 -0
  598. package/templates/init/apptesting/smoke_test.yaml +2 -2
  599. package/templates/init/dataconnect/dataconnect-fdcwebhooks.yaml +14 -0
  600. package/templates/init/dataconnect/secondary_schema.gql +8 -0
  601. package/templates/init/dataconnect/secondary_schema.yaml +5 -0
  602. package/templates/init/dataconnect/seed_data.gql +279 -0
  603. package/templates/init/functions/dart/_gitignore +11 -0
  604. package/templates/init/functions/dart/pubspec.yaml +14 -0
  605. package/templates/init/functions/dart/server.dart +15 -0
  606. package/templates/init/functions/javascript/index-ongraphrequest.js +36 -0
  607. package/templates/init/functions/javascript/package-ongraphrequest.lint.json +28 -0
  608. package/templates/init/functions/javascript/package-ongraphrequest.nolint.json +25 -0
  609. package/templates/init/functions/javascript/package.lint.json +3 -3
  610. package/templates/init/functions/javascript/package.nolint.json +3 -3
  611. package/templates/init/functions/python/requirements.txt +1 -1
  612. package/templates/init/functions/typescript/index-ongraphrequest.ts +44 -0
  613. package/templates/init/functions/typescript/package-ongraphrequest.lint.json +33 -0
  614. package/templates/init/functions/typescript/package-ongraphrequest.nolint.json +27 -0
  615. package/templates/init/functions/typescript/package.lint.json +3 -3
  616. package/templates/init/functions/typescript/package.nolint.json +3 -3
  617. package/lib/crashlytics/addNote.js +0 -27
  618. package/lib/crashlytics/deleteNote.js +0 -23
  619. package/lib/crashlytics/getIssueDetails.js +0 -26
  620. package/lib/crashlytics/getSampleCrash.js +0 -34
  621. package/lib/crashlytics/listNotes.js +0 -29
  622. package/lib/crashlytics/listTopDevices.js +0 -33
  623. package/lib/crashlytics/listTopIssues.js +0 -30
  624. package/lib/crashlytics/listTopOperatingSystems.js +0 -32
  625. package/lib/crashlytics/listTopVersions.js +0 -32
  626. package/lib/crashlytics/updateIssue.js +0 -35
  627. package/lib/dataconnect/appFinder.js +0 -102
  628. package/lib/dataconnect/cloudAICompanionClient.js +0 -72
  629. package/lib/deploy/functions/runtimes/node/extractTriggers.js +0 -23
  630. package/lib/deploy/functions/runtimes/node/parseTriggers.js +0 -345
  631. package/lib/deploy/functions/runtimes/node/triggerParser.js +0 -72
  632. package/lib/functions/deprecationWarnings.js +0 -21
  633. package/lib/functions/runtimeConfigExport.js +0 -140
  634. package/lib/handlePreviewToggles.js +0 -38
  635. package/lib/mcp/tools/auth/disable_user.js +0 -30
  636. package/lib/mcp/tools/auth/get_user.js +0 -45
  637. package/lib/mcp/tools/auth/list_users.js +0 -36
  638. package/lib/mcp/tools/auth/set_claims.js +0 -43
  639. package/lib/mcp/tools/core/consult_assistant.js +0 -33
  640. package/lib/mcp/tools/core/get_admin_sdk_config.js +0 -26
  641. package/lib/mcp/tools/crashlytics/add_note.js +0 -32
  642. package/lib/mcp/tools/crashlytics/constants.js +0 -11
  643. package/lib/mcp/tools/crashlytics/delete_note.js +0 -35
  644. package/lib/mcp/tools/crashlytics/get_issue_details.js +0 -31
  645. package/lib/mcp/tools/crashlytics/get_sample_crash.js +0 -43
  646. package/lib/mcp/tools/crashlytics/list_notes.js +0 -37
  647. package/lib/mcp/tools/crashlytics/list_top_devices.js +0 -33
  648. package/lib/mcp/tools/crashlytics/list_top_issues.js +0 -38
  649. package/lib/mcp/tools/crashlytics/list_top_operating_systems.js +0 -33
  650. package/lib/mcp/tools/crashlytics/list_top_versions.js +0 -33
  651. package/lib/mcp/tools/crashlytics/update_issue.js +0 -37
  652. package/lib/mcp/tools/database/get_rules.js +0 -39
  653. package/lib/mcp/tools/database/validate_rules.js +0 -41
  654. package/lib/mcp/tools/dataconnect/generate_operation.js +0 -34
  655. package/lib/mcp/tools/dataconnect/generate_schema.js +0 -26
  656. package/lib/mcp/tools/firestore/delete_document.js +0 -50
  657. package/lib/mcp/tools/firestore/get_documents.js +0 -58
  658. package/lib/mcp/tools/firestore/list_collections.js +0 -33
  659. package/lib/mcp/tools/remoteconfig/publish_template.js +0 -34
  660. package/lib/mcp/tools/remoteconfig/rollback_template.js +0 -29
  661. package/lib/mcp/tools/rules/get_rules.js +0 -29
  662. package/lib/mcp/tools/rules/validate_rules.js +0 -97
  663. package/lib/mcp/tools/storage/get_rules.js +0 -26
  664. package/lib/mcp/util.test.js +0 -468
  665. package/lib/parseBoltRules.js +0 -29
  666. package/templates/genkit/firebase.0.9.0.template +0 -57
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.endpointFromFunction = exports.functionFromEndpoint = exports.deleteFunction = exports.updateFunction = exports.listAllFunctions = exports.getFunction = exports.createFunction = exports.generateUploadUrl = exports.API_VERSION = void 0;
3
+ exports.API_VERSION = void 0;
4
+ exports.generateUploadUrl = generateUploadUrl;
5
+ exports.createFunction = createFunction;
6
+ exports.getFunction = getFunction;
7
+ exports.listAllFunctions = listAllFunctions;
8
+ exports.updateFunction = updateFunction;
9
+ exports.deleteFunction = deleteFunction;
10
+ exports.functionFromEndpoint = functionFromEndpoint;
11
+ exports.endpointFromFunction = endpointFromFunction;
4
12
  const apiv2_1 = require("../apiv2");
5
13
  const error_1 = require("../error");
6
14
  const api_1 = require("../api");
@@ -31,7 +39,7 @@ function functionsOpLogReject(func, type, err) {
31
39
  utils.logLabeledWarning("functions", `Your current project quotas don't allow for the current max instances setting of ${maxInstances}. ` +
32
40
  "Either reduce this function's maximum instances, or request a quota increase on the underlying Cloud Run service " +
33
41
  "at https://cloud.google.com/run/quotas.");
34
- const suggestedFix = func.buildConfig.runtime.startsWith("python")
42
+ const suggestedFix = func.buildConfig.runtime?.startsWith("python")
35
43
  ? "firebase_functions.options.set_global_options(max_instances=10)"
36
44
  : "setGlobalOptions({maxInstances: 10})";
37
45
  utils.logLabeledWarning("functions", `You can adjust the max instances value in your function's runtime options:\n\t${suggestedFix}`);
@@ -62,7 +70,6 @@ async function generateUploadUrl(projectId, location) {
62
70
  throw err;
63
71
  }
64
72
  }
65
- exports.generateUploadUrl = generateUploadUrl;
66
73
  async function createFunction(cloudFunction) {
67
74
  const components = cloudFunction.name.split("/");
68
75
  const functionId = components.splice(-1, 1)[0];
@@ -83,17 +90,14 @@ async function createFunction(cloudFunction) {
83
90
  throw functionsOpLogReject(cloudFunction, "create", err);
84
91
  }
85
92
  }
86
- exports.createFunction = createFunction;
87
93
  async function getFunction(projectId, location, functionId) {
88
94
  const name = `projects/${projectId}/locations/${location}/functions/${functionId}`;
89
95
  const res = await client.get(name);
90
96
  return res.body;
91
97
  }
92
- exports.getFunction = getFunction;
93
98
  async function listAllFunctions(projectId) {
94
99
  return await listFunctionsInternal(projectId, "-");
95
100
  }
96
- exports.listAllFunctions = listAllFunctions;
97
101
  async function listFunctionsInternal(projectId, region) {
98
102
  const functions = [];
99
103
  const unreacahble = new Set();
@@ -140,7 +144,6 @@ async function updateFunction(cloudFunction) {
140
144
  throw functionsOpLogReject(cloudFunction, "update", err);
141
145
  }
142
146
  }
143
- exports.updateFunction = updateFunction;
144
147
  async function deleteFunction(cloudFunction) {
145
148
  try {
146
149
  const res = await client.delete(cloudFunction);
@@ -150,19 +153,18 @@ async function deleteFunction(cloudFunction) {
150
153
  throw functionsOpLogReject({ name: cloudFunction }, "update", err);
151
154
  }
152
155
  }
153
- exports.deleteFunction = deleteFunction;
154
156
  function functionFromEndpoint(endpoint) {
155
157
  if (endpoint.platform !== "gcfv2") {
156
158
  throw new error_1.FirebaseError("Trying to create a v2 CloudFunction with v1 API. This should never happen");
157
159
  }
158
- if (!supported.isRuntime(endpoint.runtime)) {
160
+ if (endpoint.runtime && !supported.isRuntime(endpoint.runtime)) {
159
161
  throw new error_1.FirebaseError("Failed internal assertion. Trying to deploy a new function with a deprecated runtime." +
160
162
  " This should never happen");
161
163
  }
162
164
  const gcfFunction = {
163
165
  name: backend.functionName(endpoint),
164
166
  buildConfig: {
165
- runtime: endpoint.runtime,
167
+ runtime: endpoint.runtime || undefined,
166
168
  entryPoint: endpoint.entryPoint,
167
169
  source: {
168
170
  storageSource: endpoint.source?.storageSource,
@@ -185,12 +187,22 @@ function functionFromEndpoint(endpoint) {
185
187
  return String(cpu);
186
188
  });
187
189
  if (endpoint.vpc) {
188
- proto.renameIfPresent(gcfFunction.serviceConfig, endpoint.vpc, "vpcConnector", "connector");
189
- proto.renameIfPresent(gcfFunction.serviceConfig, endpoint.vpc, "vpcConnectorEgressSettings", "egressSettings");
190
+ if (endpoint.vpc.connector) {
191
+ gcfFunction.serviceConfig.vpcConnector = endpoint.vpc.connector;
192
+ gcfFunction.serviceConfig.vpcConnectorEgressSettings = endpoint.vpc.egressSettings || null;
193
+ }
194
+ else if (endpoint.vpc.networkInterfaces) {
195
+ gcfFunction.serviceConfig.directVpcNetworkInterface = endpoint.vpc.networkInterfaces;
196
+ gcfFunction.serviceConfig.directVpcEgress = endpoint.vpc.egressSettings
197
+ ? `VPC_EGRESS_${endpoint.vpc.egressSettings}`
198
+ : null;
199
+ }
190
200
  }
191
201
  else if (endpoint.vpc === null) {
192
202
  gcfFunction.serviceConfig.vpcConnector = null;
193
203
  gcfFunction.serviceConfig.vpcConnectorEgressSettings = null;
204
+ gcfFunction.serviceConfig.directVpcNetworkInterface = null;
205
+ gcfFunction.serviceConfig.directVpcEgress = null;
194
206
  }
195
207
  if (backend.isEventTriggered(endpoint)) {
196
208
  gcfFunction.eventTrigger = {
@@ -248,6 +260,9 @@ function functionFromEndpoint(endpoint) {
248
260
  gcfFunction.labels["genkit-action"] = "true";
249
261
  }
250
262
  }
263
+ else if (backend.isDataConnectGraphqlTriggered(endpoint)) {
264
+ gcfFunction.labels = { ...gcfFunction.labels, "deployment-fdcgraphql": "true" };
265
+ }
251
266
  else if (backend.isBlockingTriggered(endpoint)) {
252
267
  gcfFunction.labels = {
253
268
  ...gcfFunction.labels,
@@ -272,7 +287,6 @@ function functionFromEndpoint(endpoint) {
272
287
  }
273
288
  return gcfFunction;
274
289
  }
275
- exports.functionFromEndpoint = functionFromEndpoint;
276
290
  function endpointFromFunction(gcfFunction) {
277
291
  const [, project, , region, , id] = gcfFunction.name.split("/");
278
292
  let trigger;
@@ -291,6 +305,11 @@ function endpointFromFunction(gcfFunction) {
291
305
  callableTrigger: {},
292
306
  };
293
307
  }
308
+ else if (gcfFunction.labels?.["deployment-fdcgraphql"] === "true") {
309
+ trigger = {
310
+ dataConnectGraphqlTrigger: {},
311
+ };
312
+ }
294
313
  else if (gcfFunction.labels?.[constants_1.BLOCKING_LABEL]) {
295
314
  trigger = {
296
315
  blockingTrigger: {
@@ -333,7 +352,7 @@ function endpointFromFunction(gcfFunction) {
333
352
  else {
334
353
  trigger = { httpsTrigger: {} };
335
354
  }
336
- if (!supported.isRuntime(gcfFunction.buildConfig.runtime)) {
355
+ if (gcfFunction.buildConfig?.runtime && !supported.isRuntime(gcfFunction.buildConfig.runtime)) {
337
356
  logger_1.logger.debug("GCFv2 function has a deprecated runtime:", JSON.stringify(gcfFunction, null, 2));
338
357
  }
339
358
  const endpoint = {
@@ -342,9 +361,9 @@ function endpointFromFunction(gcfFunction) {
342
361
  project,
343
362
  region,
344
363
  ...trigger,
345
- entryPoint: gcfFunction.buildConfig.entryPoint,
346
- runtime: gcfFunction.buildConfig.runtime,
347
- source: gcfFunction.buildConfig.source,
364
+ entryPoint: gcfFunction.buildConfig?.entryPoint || "",
365
+ runtime: gcfFunction.buildConfig?.runtime || undefined,
366
+ source: gcfFunction.buildConfig?.source,
348
367
  };
349
368
  if (gcfFunction.serviceConfig) {
350
369
  proto.copyIfPresent(endpoint, gcfFunction.serviceConfig, "ingressSettings", "environmentVariables", "secretEnvironmentVariables", "timeoutSeconds", "uri");
@@ -375,6 +394,17 @@ function endpointFromFunction(gcfFunction) {
375
394
  endpoint.vpc = { connector: gcfFunction.serviceConfig.vpcConnector };
376
395
  proto.renameIfPresent(endpoint.vpc, gcfFunction.serviceConfig, "egressSettings", "vpcConnectorEgressSettings");
377
396
  }
397
+ else if (gcfFunction.serviceConfig.directVpcNetworkInterface) {
398
+ endpoint.vpc = { networkInterfaces: gcfFunction.serviceConfig.directVpcNetworkInterface };
399
+ if (gcfFunction.serviceConfig.directVpcEgress) {
400
+ if (!gcfFunction.serviceConfig.directVpcEgress.startsWith("VPC_EGRESS_")) {
401
+ throw new error_1.FirebaseError(`Unexpected VPC egress setting: ${gcfFunction.serviceConfig.directVpcEgress}`);
402
+ }
403
+ if (gcfFunction.serviceConfig.directVpcEgress !== "VPC_EGRESS_UNSPECIFIED") {
404
+ endpoint.vpc.egressSettings = gcfFunction.serviceConfig.directVpcEgress.substring("VPC_EGRESS_".length);
405
+ }
406
+ }
407
+ }
378
408
  const serviceName = gcfFunction.serviceConfig.service;
379
409
  if (!serviceName) {
380
410
  logger_1.logger.debug("Got a v2 function without a service name." +
@@ -392,4 +422,3 @@ function endpointFromFunction(gcfFunction) {
392
422
  proto.copyIfPresent(endpoint, gcfFunction, "state");
393
423
  return endpoint;
394
424
  }
395
- exports.endpointFromFunction = endpointFromFunction;
@@ -1,20 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listEntries = void 0;
3
+ exports.listEntries = listEntries;
4
4
  const api_1 = require("../api");
5
5
  const apiv2_1 = require("../apiv2");
6
6
  const error_1 = require("../error");
7
7
  const API_VERSION = "v2";
8
- async function listEntries(projectId, filter, pageSize, order) {
8
+ async function listEntries(projectId, filter, pageSize, order, pageToken) {
9
9
  const client = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudloggingOrigin)(), apiVersion: API_VERSION });
10
+ const body = {
11
+ resourceNames: [`projects/${projectId}`],
12
+ filter,
13
+ orderBy: `timestamp ${order}`,
14
+ pageSize,
15
+ };
16
+ if (pageToken) {
17
+ body.pageToken = pageToken;
18
+ }
10
19
  try {
11
- const result = await client.post("/entries:list", {
12
- resourceNames: [`projects/${projectId}`],
13
- filter: filter,
14
- orderBy: `timestamp ${order}`,
15
- pageSize: pageSize,
16
- });
17
- return result.body.entries;
20
+ const result = await client.post("/entries:list", body);
21
+ return {
22
+ entries: result.body.entries ?? [],
23
+ nextPageToken: result.body.nextPageToken,
24
+ };
18
25
  }
19
26
  catch (err) {
20
27
  throw new error_1.FirebaseError("Failed to retrieve log entries from Google Cloud.", {
@@ -22,4 +29,3 @@ async function listEntries(projectId, filter, pageSize, order) {
22
29
  });
23
30
  }
24
31
  }
25
- exports.listEntries = listEntries;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.queryTimeSeries = exports.ValueType = exports.Reducer = exports.MetricKind = exports.Aligner = exports.TimeSeriesView = exports.CLOUD_MONITORING_VERSION = void 0;
3
+ exports.ValueType = exports.Reducer = exports.MetricKind = exports.Aligner = exports.TimeSeriesView = exports.CLOUD_MONITORING_VERSION = void 0;
4
+ exports.queryTimeSeries = queryTimeSeries;
4
5
  const api_1 = require("../api");
5
6
  const apiv2_1 = require("../apiv2");
6
7
  const error_1 = require("../error");
@@ -9,7 +10,7 @@ var TimeSeriesView;
9
10
  (function (TimeSeriesView) {
10
11
  TimeSeriesView["FULL"] = "FULL";
11
12
  TimeSeriesView["HEADERS"] = "HEADERS";
12
- })(TimeSeriesView = exports.TimeSeriesView || (exports.TimeSeriesView = {}));
13
+ })(TimeSeriesView || (exports.TimeSeriesView = TimeSeriesView = {}));
13
14
  var Aligner;
14
15
  (function (Aligner) {
15
16
  Aligner["ALIGN_NONE"] = "ALIGN_NONE";
@@ -25,14 +26,14 @@ var Aligner;
25
26
  Aligner["ALIGN_STDDEV"] = "ALIGN_STDDEV";
26
27
  Aligner["ALIGN_COUNT_TRUE"] = "ALIGN_COUNT_TRUE";
27
28
  Aligner["ALIGN_FRACTION_TRUE"] = "ALIGN_FRACTION_TRUE";
28
- })(Aligner = exports.Aligner || (exports.Aligner = {}));
29
+ })(Aligner || (exports.Aligner = Aligner = {}));
29
30
  var MetricKind;
30
31
  (function (MetricKind) {
31
32
  MetricKind["METRIC_KIND_UNSPECIFIED"] = "METRIC_KIND_UNSPECIFIED";
32
33
  MetricKind["GAUGE"] = "GAUGE";
33
34
  MetricKind["DELTA"] = "DELTA";
34
35
  MetricKind["CUMULATIVE"] = "CUMULATIVE";
35
- })(MetricKind = exports.MetricKind || (exports.MetricKind = {}));
36
+ })(MetricKind || (exports.MetricKind = MetricKind = {}));
36
37
  var Reducer;
37
38
  (function (Reducer) {
38
39
  Reducer["REDUCE_NONE"] = "REDUCE_NONE";
@@ -48,7 +49,7 @@ var Reducer;
48
49
  Reducer["REDUCE_PERCENTILE_95"] = "REDUCE_PERCENTILE_95";
49
50
  Reducer["REDUCE_PERCENTILE_50"] = "REDUCE_PERCENTILE_50";
50
51
  Reducer["REDUCE_PERCENTILE_05"] = "REDUCE_PERCENTILE_05";
51
- })(Reducer = exports.Reducer || (exports.Reducer = {}));
52
+ })(Reducer || (exports.Reducer = Reducer = {}));
52
53
  var ValueType;
53
54
  (function (ValueType) {
54
55
  ValueType["VALUE_TYPE_UNSPECIFIED"] = "VALUE_TYPE_UNSPECIFIED";
@@ -56,7 +57,7 @@ var ValueType;
56
57
  ValueType["INT64"] = "INT64";
57
58
  ValueType["DOUBLE"] = "DOUBLE";
58
59
  ValueType["STRING"] = "STRING";
59
- })(ValueType = exports.ValueType || (exports.ValueType = {}));
60
+ })(ValueType || (exports.ValueType = ValueType = {}));
60
61
  async function queryTimeSeries(query, project) {
61
62
  const client = new apiv2_1.Client({
62
63
  urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
@@ -74,4 +75,3 @@ async function queryTimeSeries(query, project) {
74
75
  });
75
76
  }
76
77
  }
77
- exports.queryTimeSeries = queryTimeSeries;
@@ -1,15 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jobFromEndpoint = exports.topicNameForEndpoint = exports.jobNameForEndpoint = exports.createOrReplaceJob = exports.getJob = exports.deleteJob = void 0;
3
+ exports.deleteJob = deleteJob;
4
+ exports.getJob = getJob;
5
+ exports.createOrReplaceJob = createOrReplaceJob;
6
+ exports.jobNameForEndpoint = jobNameForEndpoint;
7
+ exports.topicNameForEndpoint = topicNameForEndpoint;
8
+ exports.jobFromEndpoint = jobFromEndpoint;
4
9
  const _ = require("lodash");
5
10
  const error_1 = require("../error");
6
11
  const logger_1 = require("../logger");
7
12
  const api_1 = require("../api");
8
13
  const apiv2_1 = require("../apiv2");
14
+ const functional_1 = require("../functional");
15
+ const validate_1 = require("../deploy/functions/validate");
9
16
  const backend = require("../deploy/functions/backend");
10
17
  const proto = require("./proto");
11
18
  const gce = require("../gcp/computeEngine");
12
- const functional_1 = require("../functional");
13
19
  const VERSION = "v1";
14
20
  const DEFAULT_TIME_ZONE_V1 = "America/Los_Angeles";
15
21
  const DEFAULT_TIME_ZONE_V2 = "UTC";
@@ -24,13 +30,11 @@ function createJob(job) {
24
30
  function deleteJob(name) {
25
31
  return apiClient.delete(`/${name}`);
26
32
  }
27
- exports.deleteJob = deleteJob;
28
33
  function getJob(name) {
29
34
  return apiClient.get(`/${name}`, {
30
35
  resolveOnHTTPError: true,
31
36
  });
32
37
  }
33
- exports.getJob = getJob;
34
38
  function updateJob(job) {
35
39
  let fieldMasks;
36
40
  let json;
@@ -77,7 +81,6 @@ async function createOrReplaceJob(job) {
77
81
  logger_1.logger.debug(`updated scheduler job ${jobName}`);
78
82
  return updatedJob;
79
83
  }
80
- exports.createOrReplaceJob = createOrReplaceJob;
81
84
  function needUpdate(existingJob, newJob) {
82
85
  if (!existingJob) {
83
86
  return true;
@@ -91,6 +94,9 @@ function needUpdate(existingJob, newJob) {
91
94
  if (existingJob.timeZone !== newJob.timeZone) {
92
95
  return true;
93
96
  }
97
+ if (existingJob.attemptDeadline !== newJob.attemptDeadline) {
98
+ return true;
99
+ }
94
100
  if (newJob.retryConfig) {
95
101
  if (!existingJob.retryConfig) {
96
102
  return true;
@@ -105,12 +111,10 @@ function jobNameForEndpoint(endpoint, location) {
105
111
  const id = backend.scheduleIdForFunction(endpoint);
106
112
  return `projects/${endpoint.project}/locations/${location}/jobs/${id}`;
107
113
  }
108
- exports.jobNameForEndpoint = jobNameForEndpoint;
109
114
  function topicNameForEndpoint(endpoint) {
110
115
  const id = backend.scheduleIdForFunction(endpoint);
111
116
  return `projects/${endpoint.project}/topics/${id}`;
112
117
  }
113
- exports.topicNameForEndpoint = topicNameForEndpoint;
114
118
  async function jobFromEndpoint(endpoint, location, projectNumber) {
115
119
  const job = {};
116
120
  job.name = jobNameForEndpoint(endpoint, location);
@@ -140,6 +144,15 @@ async function jobFromEndpoint(endpoint, location, projectNumber) {
140
144
  throw new error_1.FirebaseError("Cannot create a scheduler job without a schedule:" + JSON.stringify(endpoint));
141
145
  }
142
146
  job.schedule = endpoint.scheduleTrigger.schedule;
147
+ if (endpoint.platform === "gcfv2" || endpoint.platform === "run") {
148
+ proto.convertIfPresent(job, endpoint, "attemptDeadline", "timeoutSeconds", (timeout) => {
149
+ if (timeout === null) {
150
+ return null;
151
+ }
152
+ const attemptDeadlineSeconds = Math.max(Math.min(timeout, validate_1.MAX_V2_SCHEDULE_ATTEMPT_DEADLINE_SECONDS), validate_1.DEFAULT_V2_SCHEDULE_ATTEMPT_DEADLINE_SECONDS);
153
+ return proto.durationFromSeconds(attemptDeadlineSeconds);
154
+ });
155
+ }
143
156
  if (endpoint.scheduleTrigger.retryConfig) {
144
157
  job.retryConfig = {};
145
158
  proto.copyIfPresent(job.retryConfig, endpoint.scheduleTrigger.retryConfig, "maxDoublings", "retryCount");
@@ -152,4 +165,3 @@ async function jobFromEndpoint(endpoint, location, projectNumber) {
152
165
  }
153
166
  return job;
154
167
  }
155
- exports.jobFromEndpoint = jobFromEndpoint;
@@ -1,13 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listUsers = exports.deleteUser = exports.getUser = exports.createUser = exports.deleteDatabase = exports.createDatabase = exports.getDatabase = exports.listDatabases = exports.updateInstanceForDataConnect = exports.createInstance = exports.instanceConsoleLink = exports.getInstance = exports.listInstances = exports.iamUserIsCSQLAdmin = void 0;
3
+ exports.DEFAULT_DATABASE_VERSION = void 0;
4
+ exports.iamUserIsCSQLAdmin = iamUserIsCSQLAdmin;
5
+ exports.listInstances = listInstances;
6
+ exports.getInstance = getInstance;
7
+ exports.instanceConsoleLink = instanceConsoleLink;
8
+ exports.createInstance = createInstance;
9
+ exports.updateInstanceForDataConnect = updateInstanceForDataConnect;
10
+ exports.listDatabases = listDatabases;
11
+ exports.getDatabase = getDatabase;
12
+ exports.createDatabase = createDatabase;
13
+ exports.deleteDatabase = deleteDatabase;
14
+ exports.createUser = createUser;
15
+ exports.getUser = getUser;
16
+ exports.deleteUser = deleteUser;
17
+ exports.listUsers = listUsers;
4
18
  const apiv2_1 = require("../../apiv2");
5
19
  const api_1 = require("../../api");
20
+ const clc = require("colorette");
6
21
  const operationPoller = require("../../operation-poller");
7
22
  const projectUtils_1 = require("../../projectUtils");
8
23
  const logger_1 = require("../../logger");
9
24
  const iam_1 = require("../iam");
10
25
  const error_1 = require("../../error");
26
+ const freeTrial_1 = require("../../dataconnect/freeTrial");
11
27
  const API_VERSION = "v1";
12
28
  const client = new apiv2_1.Client({
13
29
  urlPrefix: (0, api_1.cloudSQLAdminOrigin)(),
@@ -31,24 +47,21 @@ async function iamUserIsCSQLAdmin(options) {
31
47
  return false;
32
48
  }
33
49
  }
34
- exports.iamUserIsCSQLAdmin = iamUserIsCSQLAdmin;
35
50
  async function listInstances(projectId) {
36
51
  const res = await client.get(`projects/${projectId}/instances`);
37
52
  return res.body.items ?? [];
38
53
  }
39
- exports.listInstances = listInstances;
40
54
  async function getInstance(projectId, instanceId) {
41
55
  const res = await client.get(`projects/${projectId}/instances/${instanceId}`);
42
56
  if (res.body.state === "FAILED") {
43
- throw new error_1.FirebaseError(`Cloud SQL instance ${instanceId} is in a failed state.\nGo to ${instanceConsoleLink(projectId, instanceId)} to repair or delete it.`);
57
+ throw new error_1.FirebaseError(`Cloud SQL instance ${clc.bold(instanceId)} is in a failed state.\nGo to ${instanceConsoleLink(projectId, instanceId)} to repair or delete it.`);
44
58
  }
45
59
  return res.body;
46
60
  }
47
- exports.getInstance = getInstance;
48
61
  function instanceConsoleLink(projectId, instanceId) {
49
62
  return `https://console.cloud.google.com/sql/instances/${instanceId}/overview?project=${projectId}`;
50
63
  }
51
- exports.instanceConsoleLink = instanceConsoleLink;
64
+ exports.DEFAULT_DATABASE_VERSION = "POSTGRES_17";
52
65
  async function createInstance(args) {
53
66
  const databaseFlags = [{ name: "cloudsql.iam_authentication", value: "on" }];
54
67
  if (args.enableGoogleMlIntegration) {
@@ -58,7 +71,7 @@ async function createInstance(args) {
58
71
  await client.post(`projects/${args.projectId}/instances`, {
59
72
  name: args.instanceId,
60
73
  region: args.location,
61
- databaseVersion: "POSTGRES_15",
74
+ databaseVersion: exports.DEFAULT_DATABASE_VERSION,
62
75
  settings: {
63
76
  tier: "db-f1-micro",
64
77
  edition: "ENTERPRISE",
@@ -68,7 +81,7 @@ async function createInstance(args) {
68
81
  enableGoogleMlIntegration: args.enableGoogleMlIntegration,
69
82
  databaseFlags,
70
83
  storageAutoResize: false,
71
- userLabels: { "firebase-data-connect": args.freeTrial ? "ft" : "nt" },
84
+ userLabels: { "firebase-data-connect": args.freeTrialLabel },
72
85
  insightsConfig: {
73
86
  queryInsightsEnabled: true,
74
87
  queryPlansPerMinute: 5,
@@ -79,11 +92,10 @@ async function createInstance(args) {
79
92
  return;
80
93
  }
81
94
  catch (err) {
82
- handleAllowlistError(err, args.location);
95
+ await handleCreateInstanceError(err, args.location, args.projectId);
83
96
  throw err;
84
97
  }
85
98
  }
86
- exports.createInstance = createInstance;
87
99
  async function updateInstanceForDataConnect(instance, enableGoogleMlIntegration) {
88
100
  let dbFlags = setDatabaseFlag({ name: "cloudsql.iam_authentication", value: "on" }, instance.settings.databaseFlags);
89
101
  if (enableGoogleMlIntegration) {
@@ -92,7 +104,7 @@ async function updateInstanceForDataConnect(instance, enableGoogleMlIntegration)
92
104
  const op = await client.patch(`projects/${instance.project}/instances/${instance.name}`, {
93
105
  settings: {
94
106
  ipConfiguration: {
95
- ipv4Enabled: true,
107
+ enablePrivatePathForGoogleCloudServices: !!instance?.settings?.ipConfiguration?.privateNetwork,
96
108
  },
97
109
  databaseFlags: dbFlags,
98
110
  enableGoogleMlIntegration,
@@ -108,11 +120,14 @@ async function updateInstanceForDataConnect(instance, enableGoogleMlIntegration)
108
120
  });
109
121
  return pollRes;
110
122
  }
111
- exports.updateInstanceForDataConnect = updateInstanceForDataConnect;
112
- function handleAllowlistError(err, region) {
113
- if (err.message.includes("Not allowed to set system label: firebase-data-connect")) {
123
+ async function handleCreateInstanceError(err, region, projectId) {
124
+ if (err?.message?.includes("Not allowed to set system label: firebase-data-connect")) {
114
125
  throw new error_1.FirebaseError(`Cloud SQL free trial instances are not yet available in ${region}. Please check https://firebase.google.com/docs/data-connect/ for a full list of available regions.`);
115
126
  }
127
+ if (err?.message?.includes("The billing account is not in good standing") &&
128
+ (await (0, freeTrial_1.checkFreeTrialInstanceUsed)(projectId))) {
129
+ throw new error_1.FirebaseError(`You have already used your Cloud SQL free trial. To create more instances, you need to attach a billing account to project ${projectId}.`);
130
+ }
116
131
  }
117
132
  function setDatabaseFlag(flag, flags = []) {
118
133
  const temp = flags.filter((f) => f.name !== flag.name);
@@ -123,12 +138,10 @@ async function listDatabases(projectId, instanceId) {
123
138
  const res = await client.get(`projects/${projectId}/instances/${instanceId}/databases`);
124
139
  return res.body.items;
125
140
  }
126
- exports.listDatabases = listDatabases;
127
141
  async function getDatabase(projectId, instanceId, databaseId) {
128
142
  const res = await client.get(`projects/${projectId}/instances/${instanceId}/databases/${databaseId}`);
129
143
  return res.body;
130
144
  }
131
- exports.getDatabase = getDatabase;
132
145
  async function createDatabase(projectId, instanceId, databaseId) {
133
146
  const op = await client.post(`projects/${projectId}/instances/${instanceId}/databases`, {
134
147
  project: projectId,
@@ -144,12 +157,10 @@ async function createDatabase(projectId, instanceId, databaseId) {
144
157
  });
145
158
  return pollRes;
146
159
  }
147
- exports.createDatabase = createDatabase;
148
160
  async function deleteDatabase(projectId, instanceId, databaseId) {
149
161
  const res = await client.delete(`projects/${projectId}/instances/${instanceId}/databases/${databaseId}`);
150
162
  return res.body;
151
163
  }
152
- exports.deleteDatabase = deleteDatabase;
153
164
  async function createUser(projectId, instanceId, type, username, password, retryTimeout) {
154
165
  const maxRetries = 3;
155
166
  let retries = 0;
@@ -188,7 +199,6 @@ async function createUser(projectId, instanceId, type, username, password, retry
188
199
  }
189
200
  }
190
201
  }
191
- exports.createUser = createUser;
192
202
  function builtinRoleNotReady(message) {
193
203
  return message.includes("cloudsqliamuser");
194
204
  }
@@ -196,7 +206,6 @@ async function getUser(projectId, instanceId, username) {
196
206
  const res = await client.get(`projects/${projectId}/instances/${instanceId}/users/${username}`);
197
207
  return res.body;
198
208
  }
199
- exports.getUser = getUser;
200
209
  async function deleteUser(projectId, instanceId, username) {
201
210
  const res = await client.delete(`projects/${projectId}/instances/${instanceId}/users`, {
202
211
  queryParams: {
@@ -205,9 +214,7 @@ async function deleteUser(projectId, instanceId, username) {
205
214
  });
206
215
  return res.body;
207
216
  }
208
- exports.deleteUser = deleteUser;
209
217
  async function listUsers(projectId, instanceId) {
210
218
  const res = await client.get(`projects/${projectId}/instances/${instanceId}/users`);
211
219
  return res.body.items;
212
220
  }
213
- exports.listUsers = listUsers;
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toDatabaseUser = exports.setupIAMUsers = exports.getIAMUser = exports.getDataConnectP4SA = exports.executeSqlCmdsAsSuperUser = exports.executeSqlCmdsAsIamUser = exports.execute = void 0;
3
+ exports.execute = execute;
4
+ exports.executeSqlCmdsAsIamUser = executeSqlCmdsAsIamUser;
5
+ exports.executeSqlCmdsAsSuperUser = executeSqlCmdsAsSuperUser;
6
+ exports.getDataConnectP4SA = getDataConnectP4SA;
7
+ exports.getIAMUser = getIAMUser;
8
+ exports.setupIAMUsers = setupIAMUsers;
9
+ exports.toDatabaseUser = toDatabaseUser;
4
10
  const pg = require("pg");
5
11
  const cloud_sql_connector_1 = require("@google-cloud/cloud-sql-connector");
6
12
  const requireAuth_1 = require("../../requireAuth");
@@ -20,36 +26,18 @@ async function execute(sqlStatements, opts) {
20
26
  throw new error_1.FirebaseError(`Could not get instance connection string for ${opts.instanceId}:${opts.databaseId}`);
21
27
  }
22
28
  let connector;
23
- let pool;
29
+ let authType;
24
30
  switch (user.type) {
25
31
  case "CLOUD_IAM_USER": {
26
32
  connector = new cloud_sql_connector_1.Connector({
27
33
  auth: new fbToolsAuthClient_1.FBToolsAuthClient(),
28
34
  });
29
- const clientOpts = await connector.getOptions({
30
- instanceConnectionName: connectionName,
31
- ipType: cloud_sql_connector_1.IpAddressTypes.PUBLIC,
32
- authType: cloud_sql_connector_1.AuthTypes.IAM,
33
- });
34
- pool = new pg.Pool({
35
- ...clientOpts,
36
- user: opts.username,
37
- database: opts.databaseId,
38
- });
35
+ authType = cloud_sql_connector_1.AuthTypes.IAM;
39
36
  break;
40
37
  }
41
38
  case "CLOUD_IAM_SERVICE_ACCOUNT": {
42
39
  connector = new cloud_sql_connector_1.Connector();
43
- const clientOpts = await connector.getOptions({
44
- instanceConnectionName: connectionName,
45
- ipType: cloud_sql_connector_1.IpAddressTypes.PUBLIC,
46
- authType: cloud_sql_connector_1.AuthTypes.IAM,
47
- });
48
- pool = new pg.Pool({
49
- ...clientOpts,
50
- user: opts.username,
51
- database: opts.databaseId,
52
- });
40
+ authType = cloud_sql_connector_1.AuthTypes.IAM;
53
41
  break;
54
42
  }
55
43
  default: {
@@ -59,19 +47,23 @@ async function execute(sqlStatements, opts) {
59
47
  connector = new cloud_sql_connector_1.Connector({
60
48
  auth: new fbToolsAuthClient_1.FBToolsAuthClient(),
61
49
  });
62
- const clientOpts = await connector.getOptions({
63
- instanceConnectionName: connectionName,
64
- ipType: cloud_sql_connector_1.IpAddressTypes.PUBLIC,
65
- });
66
- pool = new pg.Pool({
67
- ...clientOpts,
68
- user: opts.username,
69
- password: opts.password,
70
- database: opts.databaseId,
71
- });
50
+ authType = cloud_sql_connector_1.AuthTypes.PASSWORD;
72
51
  break;
73
52
  }
74
53
  }
54
+ const connectionOpts = {
55
+ instanceConnectionName: connectionName,
56
+ ipType: instance.ipAddresses.some((ip) => ip.type === "PRIMARY")
57
+ ? cloud_sql_connector_1.IpAddressTypes.PUBLIC
58
+ : cloud_sql_connector_1.IpAddressTypes.PRIVATE,
59
+ authType: authType,
60
+ };
61
+ const pool = new pg.Pool({
62
+ ...(await connector.getOptions(connectionOpts)),
63
+ password: opts.password,
64
+ user: opts.username,
65
+ database: opts.databaseId,
66
+ });
75
67
  const cleanUpFn = async () => {
76
68
  conn.release();
77
69
  await pool.end();
@@ -100,7 +92,6 @@ async function execute(sqlStatements, opts) {
100
92
  logFn(``);
101
93
  return results;
102
94
  }
103
- exports.execute = execute;
104
95
  async function executeSqlCmdsAsIamUser(options, instanceId, databaseId, cmds, silent = false, transaction = false) {
105
96
  const projectId = (0, projectUtils_1.needProjectId)(options);
106
97
  const { user: iamUser } = await getIAMUser(options);
@@ -113,7 +104,6 @@ async function executeSqlCmdsAsIamUser(options, instanceId, databaseId, cmds, si
113
104
  transaction: transaction,
114
105
  });
115
106
  }
116
- exports.executeSqlCmdsAsIamUser = executeSqlCmdsAsIamUser;
117
107
  async function executeSqlCmdsAsSuperUser(options, instanceId, databaseId, cmds, silent = false, transaction = false) {
118
108
  const projectId = (0, projectUtils_1.needProjectId)(options);
119
109
  const superuser = "firebasesuperuser";
@@ -129,11 +119,9 @@ async function executeSqlCmdsAsSuperUser(options, instanceId, databaseId, cmds,
129
119
  transaction: transaction,
130
120
  });
131
121
  }
132
- exports.executeSqlCmdsAsSuperUser = executeSqlCmdsAsSuperUser;
133
122
  function getDataConnectP4SA(projectNumber) {
134
123
  return `service-${projectNumber}@${(0, api_1.dataconnectP4SADomain)()}`;
135
124
  }
136
- exports.getDataConnectP4SA = getDataConnectP4SA;
137
125
  async function getIAMUser(options) {
138
126
  const account = await (0, requireAuth_1.requireAuth)(options);
139
127
  if (!account) {
@@ -141,7 +129,6 @@ async function getIAMUser(options) {
141
129
  }
142
130
  return toDatabaseUser(account);
143
131
  }
144
- exports.getIAMUser = getIAMUser;
145
132
  async function setupIAMUsers(instanceId, options) {
146
133
  const projectId = (0, projectUtils_1.needProjectId)(options);
147
134
  const { user, mode } = await getIAMUser(options);
@@ -151,7 +138,6 @@ async function setupIAMUsers(instanceId, options) {
151
138
  await cloudSqlAdminClient.createUser(projectId, instanceId, fdcP4SAmode, fdcP4SAUser);
152
139
  return user;
153
140
  }
154
- exports.setupIAMUsers = setupIAMUsers;
155
141
  function toDatabaseUser(account) {
156
142
  let mode = "CLOUD_IAM_USER";
157
143
  let user = account;
@@ -161,4 +147,3 @@ function toDatabaseUser(account) {
161
147
  }
162
148
  return { user, mode };
163
149
  }
164
- exports.toDatabaseUser = toDatabaseUser;
@@ -36,7 +36,7 @@ class FBToolsAuthClient extends google_auth_library_1.AuthClient {
36
36
  async getRequestHeaders() {
37
37
  const token = await this.getAccessToken();
38
38
  return {
39
- ...apiv2.STANDARD_HEADERS,
39
+ ...apiv2.standardHeaders(),
40
40
  Authorization: `Bearer ${token.token}`,
41
41
  };
42
42
  }