firebase-tools-with-isolate 13.29.1 → 14.10.1-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 (396) hide show
  1. package/README.md +53 -4
  2. package/lib/api.js +10 -2
  3. package/lib/appdistribution/client.js +2 -2
  4. package/lib/apphosting/backend.js +157 -55
  5. package/lib/apphosting/config.js +121 -101
  6. package/lib/apphosting/githubConnections.js +65 -100
  7. package/lib/apphosting/repo.js +22 -36
  8. package/lib/apphosting/rollout.js +5 -11
  9. package/lib/apphosting/secrets/dialogs.js +13 -11
  10. package/lib/apphosting/secrets/index.js +47 -5
  11. package/lib/apphosting/utils.js +1 -3
  12. package/lib/apphosting/yaml.js +35 -49
  13. package/lib/auth.js +23 -6
  14. package/lib/bin/cli.js +99 -0
  15. package/lib/bin/firebase.js +7 -123
  16. package/lib/bin/mcp.js +49 -0
  17. package/lib/checkValidTargetFilters.js +1 -0
  18. package/lib/command.js +3 -2
  19. package/lib/commands/appdistribution-distribute.js +1 -1
  20. package/lib/commands/appdistribution-groups-create.js +1 -1
  21. package/lib/commands/appdistribution-groups-delete.js +1 -1
  22. package/lib/commands/appdistribution-groups-list.js +2 -2
  23. package/lib/commands/appdistribution-testers-add.js +1 -1
  24. package/lib/commands/appdistribution-testers-list.js +3 -3
  25. package/lib/commands/appdistribution-testers-remove.js +1 -1
  26. package/lib/commands/apphosting-backends-create.js +3 -3
  27. package/lib/commands/apphosting-backends-delete.js +23 -27
  28. package/lib/commands/apphosting-backends-get.js +12 -12
  29. package/lib/commands/apphosting-backends-list.js +5 -5
  30. package/lib/commands/apphosting-builds-create.js +8 -2
  31. package/lib/commands/apphosting-builds-get.js +8 -1
  32. package/lib/commands/apphosting-rollouts-create.js +3 -3
  33. package/lib/commands/apphosting-rollouts-list.js +8 -2
  34. package/lib/commands/apphosting-secrets-access.js +1 -1
  35. package/lib/commands/apphosting-secrets-describe.js +2 -2
  36. package/lib/commands/apphosting-secrets-grantaccess.js +20 -10
  37. package/lib/commands/apphosting-secrets-set.js +27 -1
  38. package/lib/commands/apps-android-sha-create.js +1 -1
  39. package/lib/commands/apps-android-sha-delete.js +1 -1
  40. package/lib/commands/apps-android-sha-list.js +2 -2
  41. package/lib/commands/apps-create.js +4 -108
  42. package/lib/commands/apps-init.js +94 -0
  43. package/lib/commands/apps-list.js +1 -1
  44. package/lib/commands/apps-sdkconfig.js +5 -10
  45. package/lib/commands/auth-export.js +1 -1
  46. package/lib/commands/auth-import.js +1 -1
  47. package/lib/commands/database-import.js +4 -6
  48. package/lib/commands/database-instances-create.js +1 -1
  49. package/lib/commands/database-instances-list.js +1 -1
  50. package/lib/commands/database-profile.js +1 -2
  51. package/lib/commands/database-remove.js +4 -6
  52. package/lib/commands/database-set.js +6 -6
  53. package/lib/commands/database-settings-set.js +1 -1
  54. package/lib/commands/database-update.js +6 -6
  55. package/lib/commands/dataconnect-sdk-generate.js +5 -2
  56. package/lib/commands/dataconnect-services-list.js +2 -2
  57. package/lib/commands/dataconnect-sql-diff.js +2 -2
  58. package/lib/commands/dataconnect-sql-grant.js +3 -3
  59. package/lib/commands/dataconnect-sql-migrate.js +2 -2
  60. package/lib/commands/dataconnect-sql-setup.js +39 -0
  61. package/lib/commands/dataconnect-sql-shell.js +5 -7
  62. package/lib/commands/deploy.js +4 -3
  63. package/lib/commands/emulators-exec.js +1 -1
  64. package/lib/commands/emulators-start.js +4 -3
  65. package/lib/commands/experiments-list.js +1 -1
  66. package/lib/commands/ext-dev-deprecate.js +1 -0
  67. package/lib/commands/ext-dev-init.js +3 -12
  68. package/lib/commands/ext-dev-list.js +1 -1
  69. package/lib/commands/ext-dev-register.js +3 -5
  70. package/lib/commands/ext-dev-undeprecate.js +1 -2
  71. package/lib/commands/ext-dev-usage.js +4 -6
  72. package/lib/commands/ext-export.js +1 -2
  73. package/lib/commands/ext-install.js +3 -3
  74. package/lib/commands/ext-sdk-install.js +1 -0
  75. package/lib/commands/ext-update.js +1 -0
  76. package/lib/commands/firestore-backups-delete.js +3 -4
  77. package/lib/commands/firestore-backups-get.js +1 -1
  78. package/lib/commands/firestore-backups-list.js +2 -2
  79. package/lib/commands/firestore-backups-schedules-create.js +4 -4
  80. package/lib/commands/firestore-backups-schedules-delete.js +3 -4
  81. package/lib/commands/firestore-backups-schedules-list.js +2 -2
  82. package/lib/commands/firestore-backups-schedules-update.js +1 -1
  83. package/lib/commands/firestore-databases-create.js +6 -6
  84. package/lib/commands/firestore-databases-delete.js +3 -7
  85. package/lib/commands/firestore-databases-get.js +1 -1
  86. package/lib/commands/firestore-databases-list.js +1 -1
  87. package/lib/commands/firestore-databases-restore.js +5 -5
  88. package/lib/commands/firestore-databases-update.js +4 -4
  89. package/lib/commands/firestore-delete.js +13 -14
  90. package/lib/commands/firestore-indexes-list.js +4 -4
  91. package/lib/commands/firestore-locations.js +1 -1
  92. package/lib/commands/functions-artifacts-setpolicy.js +132 -0
  93. package/lib/commands/functions-config-export.js +6 -10
  94. package/lib/commands/functions-delete.js +5 -7
  95. package/lib/commands/functions-deletegcfartifacts.js +5 -5
  96. package/lib/commands/functions-list.js +24 -33
  97. package/lib/commands/functions-secrets-access.js +1 -1
  98. package/lib/commands/functions-secrets-describe.js +1 -1
  99. package/lib/commands/functions-secrets-destroy.js +10 -12
  100. package/lib/commands/functions-secrets-get.js +1 -1
  101. package/lib/commands/functions-secrets-prune.js +14 -15
  102. package/lib/commands/functions-secrets-set.js +14 -18
  103. package/lib/commands/hosting-channel-create.js +1 -2
  104. package/lib/commands/hosting-channel-delete.js +4 -4
  105. package/lib/commands/hosting-channel-list.js +1 -1
  106. package/lib/commands/hosting-channel-open.js +2 -3
  107. package/lib/commands/hosting-disable.js +5 -5
  108. package/lib/commands/hosting-sites-delete.js +4 -4
  109. package/lib/commands/hosting-sites-get.js +1 -1
  110. package/lib/commands/hosting-sites-list.js +1 -1
  111. package/lib/commands/index.js +7 -4
  112. package/lib/commands/init.js +54 -60
  113. package/lib/commands/internaltesting-frameworks-compose.js +1 -1
  114. package/lib/commands/login-use.js +2 -11
  115. package/lib/commands/login.js +10 -8
  116. package/lib/commands/logout.js +2 -3
  117. package/lib/commands/mcp.js +11 -0
  118. package/lib/commands/open.js +4 -2
  119. package/lib/commands/projects-create.js +1 -2
  120. package/lib/commands/projects-list.js +1 -1
  121. package/lib/commands/remoteconfig-get.js +1 -1
  122. package/lib/commands/remoteconfig-rollback.js +5 -5
  123. package/lib/commands/remoteconfig-versions-list.js +2 -2
  124. package/lib/commands/setup-emulators-database.js +1 -1
  125. package/lib/commands/setup-emulators-dataconnect.js +1 -1
  126. package/lib/commands/setup-emulators-firestore.js +1 -1
  127. package/lib/commands/setup-emulators-pubsub.js +1 -1
  128. package/lib/commands/setup-emulators-storage.js +1 -1
  129. package/lib/commands/setup-emulators-ui.js +1 -1
  130. package/lib/commands/use.js +115 -111
  131. package/lib/config.js +49 -33
  132. package/lib/crashlytics/buildToolsJarHelper.js +1 -1
  133. package/lib/crashlytics/listTopIssues.js +45 -0
  134. package/lib/dataconnect/build.js +61 -4
  135. package/lib/dataconnect/client.js +26 -17
  136. package/lib/dataconnect/cloudAICompanionClient.js +72 -0
  137. package/lib/dataconnect/dataplaneClient.js +19 -2
  138. package/lib/dataconnect/ensureApis.js +6 -3
  139. package/lib/dataconnect/fileUtils.js +39 -6
  140. package/lib/dataconnect/freeTrial.js +21 -9
  141. package/lib/dataconnect/graphqlError.js +56 -2
  142. package/lib/dataconnect/provisionCloudSql.js +23 -12
  143. package/lib/dataconnect/schemaMigration.js +46 -26
  144. package/lib/dataconnect/types.js +5 -1
  145. package/lib/defaultCredentials.js +12 -1
  146. package/lib/deploy/apphosting/args.js +2 -0
  147. package/lib/deploy/apphosting/deploy.js +77 -0
  148. package/lib/deploy/apphosting/index.js +9 -0
  149. package/lib/deploy/apphosting/prepare.js +138 -0
  150. package/lib/deploy/apphosting/release.js +56 -0
  151. package/lib/deploy/apphosting/util.js +65 -0
  152. package/lib/deploy/dataconnect/deploy.js +14 -7
  153. package/lib/deploy/dataconnect/prepare.js +3 -5
  154. package/lib/deploy/extensions/v2FunctionHelper.js +2 -1
  155. package/lib/deploy/firestore/deploy.js +50 -4
  156. package/lib/deploy/functions/build.js +1 -0
  157. package/lib/deploy/functions/checkIam.js +41 -6
  158. package/lib/deploy/functions/containerCleaner.js +17 -2
  159. package/lib/deploy/functions/ensure.js +2 -1
  160. package/lib/deploy/functions/params.js +10 -17
  161. package/lib/deploy/functions/prepare.js +51 -18
  162. package/lib/deploy/functions/prepareFunctionsUpload.js +9 -5
  163. package/lib/deploy/functions/prompts.js +24 -17
  164. package/lib/deploy/functions/release/fabricator.js +4 -4
  165. package/lib/deploy/functions/release/index.js +27 -9
  166. package/lib/deploy/functions/release/planner.js +1 -0
  167. package/lib/deploy/functions/runtimes/discovery/index.js +13 -5
  168. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +4 -4
  169. package/lib/deploy/functions/runtimes/python/index.js +4 -1
  170. package/lib/deploy/functions/runtimes/supported/types.js +17 -11
  171. package/lib/deploy/functions/services/firestore.js +23 -4
  172. package/lib/deploy/index.js +29 -10
  173. package/lib/deploy/lifecycleHooks.js +6 -12
  174. package/lib/emulator/ExpressBasedEmulator.js +1 -1
  175. package/lib/emulator/apphosting/config.js +15 -14
  176. package/lib/emulator/apphosting/index.js +2 -0
  177. package/lib/emulator/apphosting/serve.js +147 -10
  178. package/lib/emulator/auth/cloudFunctions.js +13 -1
  179. package/lib/emulator/auth/operations.js +2 -1
  180. package/lib/emulator/auth/widget_ui.js +2 -1
  181. package/lib/emulator/commandUtils.js +14 -20
  182. package/lib/emulator/constants.js +2 -0
  183. package/lib/emulator/controller.js +24 -9
  184. package/lib/emulator/dataconnect/pgliteServer.js +136 -45
  185. package/lib/emulator/dataconnectEmulator.js +34 -6
  186. package/lib/emulator/dataconnectToolkitController.js +5 -0
  187. package/lib/emulator/downloadableEmulatorInfo.json +81 -0
  188. package/lib/emulator/downloadableEmulators.js +28 -80
  189. package/lib/emulator/env.js +47 -1
  190. package/lib/emulator/extensionsEmulator.js +5 -3
  191. package/lib/emulator/functionsEmulator.js +6 -26
  192. package/lib/emulator/hub.js +5 -4
  193. package/lib/emulator/hubClient.js +5 -0
  194. package/lib/emulator/initEmulators.js +29 -15
  195. package/lib/emulator/ui.js +4 -8
  196. package/lib/ensureApiEnabled.js +32 -1
  197. package/lib/experiments.js +11 -12
  198. package/lib/extensions/askUserForEventsConfig.js +6 -15
  199. package/lib/extensions/askUserForParam.js +23 -52
  200. package/lib/extensions/change-log.js +1 -25
  201. package/lib/extensions/checkProjectBilling.js +3 -9
  202. package/lib/extensions/diagnose.js +3 -6
  203. package/lib/extensions/emulator/triggerHelper.js +4 -0
  204. package/lib/extensions/extensionsHelper.js +25 -31
  205. package/lib/extensions/listExtensions.js +1 -1
  206. package/lib/extensions/manifest.js +3 -7
  207. package/lib/extensions/paramHelper.js +11 -2
  208. package/lib/extensions/provisioningHelper.js +1 -1
  209. package/lib/extensions/tos.js +4 -2
  210. package/lib/extensions/utils.js +1 -10
  211. package/lib/firebaseConfigValidate.js +7 -5
  212. package/lib/firestore/delete.js +5 -4
  213. package/lib/firestore/pretty-print.js +1 -1
  214. package/lib/frameworks/angular/index.js +11 -6
  215. package/lib/frameworks/angular/utils.js +76 -47
  216. package/lib/frameworks/constants.js +1 -1
  217. package/lib/frameworks/index.js +6 -4
  218. package/lib/frameworks/next/index.js +7 -4
  219. package/lib/frameworks/utils.js +11 -3
  220. package/lib/frameworks/vite/index.js +2 -3
  221. package/lib/fsAsync.js +9 -2
  222. package/lib/fsutils.js +16 -1
  223. package/lib/functions/artifacts.js +196 -0
  224. package/lib/functions/secrets.js +15 -16
  225. package/lib/gcp/apphosting.js +13 -1
  226. package/lib/gcp/artifactregistry.js +27 -2
  227. package/lib/gcp/auth.js +113 -1
  228. package/lib/gcp/cloudbilling.js +12 -1
  229. package/lib/gcp/cloudfunctions.js +32 -4
  230. package/lib/gcp/cloudfunctionsv2.js +15 -9
  231. package/lib/gcp/cloudscheduler.js +2 -2
  232. package/lib/gcp/cloudsql/cloudsqladmin.js +32 -11
  233. package/lib/gcp/cloudsql/connect.js +21 -14
  234. package/lib/gcp/cloudsql/interactive.js +1 -1
  235. package/lib/gcp/cloudsql/permissions.js +46 -99
  236. package/lib/gcp/cloudsql/permissionsSetup.js +224 -0
  237. package/lib/gcp/computeEngine.js +19 -2
  238. package/lib/gcp/devConnect.js +6 -1
  239. package/lib/gcp/firestore.js +55 -16
  240. package/lib/gcp/iam.js +1 -5
  241. package/lib/gcp/proto.js +4 -3
  242. package/lib/gcp/run.js +18 -1
  243. package/lib/gcp/serviceusage.js +2 -1
  244. package/lib/gcp/storage.js +47 -1
  245. package/lib/gemini/fdcExperience.js +56 -0
  246. package/lib/gemini/types.js +2 -0
  247. package/lib/hosting/api.js +4 -0
  248. package/lib/hosting/implicitInit.js +7 -3
  249. package/lib/hosting/interactive.js +2 -3
  250. package/lib/index.js +1 -2
  251. package/lib/init/features/account.js +2 -4
  252. package/lib/init/features/apphosting.js +75 -6
  253. package/lib/init/features/database.js +63 -62
  254. package/lib/init/features/dataconnect/index.js +131 -85
  255. package/lib/init/features/dataconnect/sdk.js +73 -18
  256. package/lib/init/features/emulators.js +29 -46
  257. package/lib/init/features/firestore/index.js +79 -43
  258. package/lib/init/features/firestore/indexes.js +30 -45
  259. package/lib/init/features/firestore/rules.js +36 -62
  260. package/lib/init/features/functions/index.js +11 -16
  261. package/lib/init/features/functions/javascript.js +17 -30
  262. package/lib/init/features/functions/npm-dependencies.js +4 -8
  263. package/lib/init/features/functions/python.js +1 -3
  264. package/lib/init/features/functions/typescript.js +25 -43
  265. package/lib/init/features/genkit/index.js +111 -106
  266. package/lib/init/features/hosting/github.js +22 -52
  267. package/lib/init/features/hosting/index.js +37 -57
  268. package/lib/init/features/index.js +10 -5
  269. package/lib/init/features/project.js +18 -21
  270. package/lib/init/features/remoteconfig.js +5 -10
  271. package/lib/init/features/storage.js +30 -10
  272. package/lib/init/index.js +79 -24
  273. package/lib/logger.js +76 -3
  274. package/lib/management/apps.js +292 -7
  275. package/lib/management/projects.js +100 -52
  276. package/lib/mcp/errors.js +20 -0
  277. package/lib/mcp/index.js +227 -0
  278. package/lib/mcp/tool.js +12 -0
  279. package/lib/mcp/tools/apphosting/fetch_logs.js +68 -0
  280. package/lib/mcp/tools/apphosting/index.js +6 -0
  281. package/lib/mcp/tools/apphosting/list_backends.js +51 -0
  282. package/lib/mcp/tools/auth/disable_user.js +30 -0
  283. package/lib/mcp/tools/auth/get_user.js +38 -0
  284. package/lib/mcp/tools/auth/index.js +15 -0
  285. package/lib/mcp/tools/auth/list_users.js +36 -0
  286. package/lib/mcp/tools/auth/set_claims.js +43 -0
  287. package/lib/mcp/tools/auth/set_sms_region_policy.js +36 -0
  288. package/lib/mcp/tools/core/consult_assistant.js +28 -0
  289. package/lib/mcp/tools/core/create_android_sha.js +43 -0
  290. package/lib/mcp/tools/core/create_app.js +90 -0
  291. package/lib/mcp/tools/core/create_project.js +68 -0
  292. package/lib/mcp/tools/core/get_admin_sdk_config.js +26 -0
  293. package/lib/mcp/tools/core/get_environment.js +51 -0
  294. package/lib/mcp/tools/core/get_project.js +22 -0
  295. package/lib/mcp/tools/core/get_sdk_config.js +40 -0
  296. package/lib/mcp/tools/core/index.js +29 -0
  297. package/lib/mcp/tools/core/init.js +153 -0
  298. package/lib/mcp/tools/core/list_apps.js +34 -0
  299. package/lib/mcp/tools/core/list_projects.js +45 -0
  300. package/lib/mcp/tools/core/update_environment.js +55 -0
  301. package/lib/mcp/tools/crashlytics/index.js +5 -0
  302. package/lib/mcp/tools/crashlytics/list_top_issues.js +39 -0
  303. package/lib/mcp/tools/dataconnect/converter.js +60 -0
  304. package/lib/mcp/tools/dataconnect/emulator.js +16 -0
  305. package/lib/mcp/tools/dataconnect/execute_graphql.js +48 -0
  306. package/lib/mcp/tools/dataconnect/execute_graphql_read.js +48 -0
  307. package/lib/mcp/tools/dataconnect/execute_mutation.js +62 -0
  308. package/lib/mcp/tools/dataconnect/execute_query.js +62 -0
  309. package/lib/mcp/tools/dataconnect/generate_operation.js +34 -0
  310. package/lib/mcp/tools/dataconnect/generate_schema.js +26 -0
  311. package/lib/mcp/tools/dataconnect/get_connector.js +31 -0
  312. package/lib/mcp/tools/dataconnect/get_schema.js +31 -0
  313. package/lib/mcp/tools/dataconnect/index.js +23 -0
  314. package/lib/mcp/tools/dataconnect/list_services.js +23 -0
  315. package/lib/mcp/tools/firestore/converter.js +102 -0
  316. package/lib/mcp/tools/firestore/delete_document.js +50 -0
  317. package/lib/mcp/tools/firestore/get_documents.js +58 -0
  318. package/lib/mcp/tools/firestore/index.js +17 -0
  319. package/lib/mcp/tools/firestore/list_collections.js +36 -0
  320. package/lib/mcp/tools/firestore/query_collection.js +132 -0
  321. package/lib/mcp/tools/index.js +62 -0
  322. package/lib/mcp/tools/messaging/index.js +5 -0
  323. package/lib/mcp/tools/messaging/send_message.js +42 -0
  324. package/lib/mcp/tools/remoteconfig/get_template.js +27 -0
  325. package/lib/mcp/tools/remoteconfig/index.js +7 -0
  326. package/lib/mcp/tools/remoteconfig/publish_template.js +34 -0
  327. package/lib/mcp/tools/remoteconfig/rollback_template.js +29 -0
  328. package/lib/mcp/tools/rules/get_rules.js +29 -0
  329. package/lib/mcp/tools/rules/validate_rules.js +97 -0
  330. package/lib/mcp/tools/storage/get_download_url.js +40 -0
  331. package/lib/mcp/tools/storage/get_rules.js +26 -0
  332. package/lib/mcp/tools/storage/index.js +11 -0
  333. package/lib/mcp/types.js +13 -0
  334. package/lib/mcp/util.js +214 -0
  335. package/lib/mcp/util.test.js +468 -0
  336. package/lib/messaging/interfaces.js +2 -0
  337. package/lib/messaging/sendMessage.js +48 -0
  338. package/lib/operation-poller.js +3 -1
  339. package/lib/profileReport.js +1 -1
  340. package/lib/prompt.js +86 -54
  341. package/lib/remoteconfig/publish.js +39 -0
  342. package/lib/requireAuth.js +2 -2
  343. package/lib/requireTosAcceptance.js +4 -0
  344. package/lib/rulesDeploy.js +10 -15
  345. package/lib/track.js +7 -37
  346. package/lib/utils.js +28 -41
  347. package/lib/vsCodeUtils.js +7 -3
  348. package/package.json +31 -15
  349. package/schema/connector-yaml.json +12 -0
  350. package/schema/dataconnect-yaml.json +5 -0
  351. package/schema/extension-yaml.json +17 -4
  352. package/schema/firebase-config.json +1117 -2121
  353. package/standalone/package-lock.json +1255 -992
  354. package/standalone/package.json +1 -1
  355. package/templates/dataconnect-prompts/operation-generation-cursor-windsurf-rule.txt +273 -0
  356. package/templates/dataconnect-prompts/schema-generation-cursor-windsurf-rule.txt +653 -0
  357. package/templates/genkit/firebase.0.9.0.template +1 -1
  358. package/templates/genkit/firebase.1.0.0.template +71 -0
  359. package/templates/init/dataconnect/connector.yaml +4 -1
  360. package/templates/init/dataconnect/dataconnect.yaml +1 -1
  361. package/templates/init/dataconnect/mutations.gql +9 -26
  362. package/templates/init/dataconnect/queries.gql +9 -14
  363. package/templates/init/dataconnect/schema.gql +28 -21
  364. package/templates/init/firestore/firestore.rules +2 -0
  365. package/templates/init/functions/javascript/index.js +14 -1
  366. package/templates/init/functions/javascript/package.lint.json +1 -1
  367. package/templates/init/functions/javascript/package.nolint.json +1 -1
  368. package/templates/init/functions/python/_gitignore +6 -1
  369. package/templates/init/functions/python/main.py +8 -0
  370. package/templates/init/functions/typescript/index.ts +14 -1
  371. package/templates/init/functions/typescript/package.lint.json +2 -2
  372. package/templates/init/functions/typescript/package.nolint.json +3 -3
  373. package/lib/commands/apphosting-config-export.js +0 -28
  374. package/lib/commands/experimental-functions-shell.js +0 -13
  375. package/lib/emulator/dataconnect/pg-gateway/auth/base-auth-flow.js +0 -11
  376. package/lib/emulator/dataconnect/pg-gateway/auth/cert.js +0 -58
  377. package/lib/emulator/dataconnect/pg-gateway/auth/index.js +0 -22
  378. package/lib/emulator/dataconnect/pg-gateway/auth/md5.js +0 -124
  379. package/lib/emulator/dataconnect/pg-gateway/auth/password.js +0 -54
  380. package/lib/emulator/dataconnect/pg-gateway/auth/sasl/sasl-mechanism.js +0 -34
  381. package/lib/emulator/dataconnect/pg-gateway/auth/sasl/scram-sha-256.js +0 -270
  382. package/lib/emulator/dataconnect/pg-gateway/backend-error.js +0 -75
  383. package/lib/emulator/dataconnect/pg-gateway/buffer-reader.js +0 -54
  384. package/lib/emulator/dataconnect/pg-gateway/buffer-writer.js +0 -79
  385. package/lib/emulator/dataconnect/pg-gateway/connection.js +0 -315
  386. package/lib/emulator/dataconnect/pg-gateway/connection.types.js +0 -8
  387. package/lib/emulator/dataconnect/pg-gateway/crypto.js +0 -40
  388. package/lib/emulator/dataconnect/pg-gateway/duplex.js +0 -53
  389. package/lib/emulator/dataconnect/pg-gateway/index.js +0 -27
  390. package/lib/emulator/dataconnect/pg-gateway/message-buffer.js +0 -82
  391. package/lib/emulator/dataconnect/pg-gateway/message-codes.js +0 -52
  392. package/lib/emulator/dataconnect/pg-gateway/platforms/node/index.js +0 -16
  393. package/lib/emulator/dataconnect/pg-gateway/polyfills/readable-stream-async-iterator.js +0 -35
  394. package/lib/emulator/dataconnect/pg-gateway/utils.js +0 -40
  395. package/templates/setup/web.js +0 -5
  396. /package/lib/{emulator/dataconnect/pg-gateway/auth/trust.js → dataconnect/cloudAICompanionTypes.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.actuate = exports.doSetup = void 0;
3
+ exports.toDNSCompatibleId = exports.postSetup = exports.actuate = exports.askQuestions = void 0;
4
4
  const path_1 = require("path");
5
5
  const clc = require("colorette");
6
6
  const fs = require("fs-extra");
@@ -18,6 +18,8 @@ const utils_1 = require("../../../utils");
18
18
  const cloudbilling_1 = require("../../../gcp/cloudbilling");
19
19
  const sdk = require("./sdk");
20
20
  const fileUtils_1 = require("../../../dataconnect/fileUtils");
21
+ const fdcExperience_1 = require("../../../gemini/fdcExperience");
22
+ const configstore_1 = require("../../../configstore");
21
23
  const DATACONNECT_YAML_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/dataconnect.yaml");
22
24
  const CONNECTOR_YAML_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/connector.yaml");
23
25
  const SCHEMA_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/schema.gql");
@@ -43,29 +45,11 @@ const defaultConnector = {
43
45
  ],
44
46
  };
45
47
  const defaultSchema = { path: "schema.gql", content: SCHEMA_TEMPLATE };
46
- async function doSetup(setup, config) {
47
- const isBillingEnabled = setup.projectId ? await (0, cloudbilling_1.checkBillingEnabled)(setup.projectId) : false;
48
+ async function askQuestions(setup) {
49
+ const hasBilling = await (0, cloudbilling_1.isBillingEnabled)(setup);
48
50
  if (setup.projectId) {
49
- isBillingEnabled ? await (0, ensureApis_1.ensureApis)(setup.projectId) : await (0, ensureApis_1.ensureSparkApis)(setup.projectId);
51
+ hasBilling ? await (0, ensureApis_1.ensureApis)(setup.projectId) : await (0, ensureApis_1.ensureSparkApis)(setup.projectId);
50
52
  }
51
- const info = await askQuestions(setup, isBillingEnabled);
52
- const dir = config.get("dataconnect.source", "dataconnect");
53
- const dataDir = config.get("emulators.dataconnect.dataDir", `${dir}/.dataconnect/pgliteData`);
54
- config.set("emulators.dataconnect.dataDir", dataDir);
55
- await actuate(setup, config, info);
56
- const cwdPlatformGuess = await (0, fileUtils_1.getPlatformFromFolder)(process.cwd());
57
- if (cwdPlatformGuess !== types_1.Platform.NONE) {
58
- await sdk.doSetup(setup, config);
59
- }
60
- else {
61
- (0, utils_1.logBullet)(`If you'd like to add the generated SDK to your app your, run ${clc.bold("firebase init dataconnect:sdk")}`);
62
- }
63
- if (setup.projectId && !isBillingEnabled) {
64
- (0, utils_1.logBullet)((0, freeTrial_1.upgradeInstructions)(setup.projectId));
65
- }
66
- }
67
- exports.doSetup = doSetup;
68
- async function askQuestions(setup, isBillingEnabled) {
69
53
  let info = {
70
54
  serviceId: "",
71
55
  locationId: "",
@@ -73,72 +57,91 @@ async function askQuestions(setup, isBillingEnabled) {
73
57
  isNewInstance: false,
74
58
  cloudSqlDatabase: "",
75
59
  isNewDatabase: false,
76
- connectors: [defaultConnector],
77
- schemaGql: [defaultSchema],
60
+ connectors: [],
61
+ schemaGql: [],
78
62
  shouldProvisionCSQL: false,
79
63
  };
80
- info = await promptForExistingServices(setup, info, isBillingEnabled);
64
+ info = await promptForExistingServices(setup, info);
81
65
  const requiredConfigUnset = info.serviceId === "" ||
82
66
  info.cloudSqlInstanceId === "" ||
83
67
  info.locationId === "" ||
84
68
  info.cloudSqlDatabase === "";
85
- const shouldConfigureBackend = isBillingEnabled && requiredConfigUnset
86
- ? await (0, prompt_1.confirm)({
87
- message: `Would you like to configure your backend resources now?`,
69
+ const shouldConfigureBackend = hasBilling &&
70
+ requiredConfigUnset &&
71
+ (await (0, prompt_1.confirm)({
72
+ message: `Would you like to configure your Cloud SQL datasource now?`,
88
73
  default: true,
89
- })
90
- : false;
74
+ }));
91
75
  if (shouldConfigureBackend) {
92
- info = await promptForService(info);
76
+ info = await promptForSchema(setup, info);
93
77
  info = await promptForCloudSQL(setup, info);
94
78
  info.shouldProvisionCSQL = !!(setup.projectId &&
95
79
  (info.isNewInstance || info.isNewDatabase) &&
96
- isBillingEnabled &&
80
+ hasBilling &&
97
81
  (await (0, prompt_1.confirm)({
98
82
  message: `Would you like to provision your Cloud SQL instance and database now?${info.isNewInstance ? " This will take several minutes." : ""}.`,
99
83
  default: true,
100
84
  })));
101
85
  }
102
- else {
103
- info.serviceId = info.serviceId || (0, path_1.basename)(process.cwd());
104
- info.cloudSqlInstanceId = info.cloudSqlInstanceId || `${info.serviceId || "app"}-fdc`;
105
- info.locationId = info.locationId || `us-central1`;
106
- info.cloudSqlDatabase = info.cloudSqlDatabase || `fdcdb`;
107
- }
108
- return info;
86
+ setup.featureInfo = setup.featureInfo || {};
87
+ setup.featureInfo.dataconnect = info;
109
88
  }
110
- async function actuate(setup, config, info) {
111
- await writeFiles(config, info);
89
+ exports.askQuestions = askQuestions;
90
+ async function actuate(setup, config, options) {
91
+ const dir = config.get("dataconnect.source", "dataconnect");
92
+ const dataDir = config.get("emulators.dataconnect.dataDir", `${dir}/.dataconnect/pgliteData`);
93
+ config.set("emulators.dataconnect.dataDir", dataDir);
94
+ const info = setup.featureInfo?.dataconnect;
95
+ if (!info) {
96
+ throw new Error("Data Connect feature RequiredInfo is not provided");
97
+ }
98
+ const defaultServiceId = toDNSCompatibleId((0, path_1.basename)(process.cwd()));
99
+ info.serviceId = info.serviceId || defaultServiceId;
100
+ info.cloudSqlInstanceId =
101
+ info.cloudSqlInstanceId || `${info.serviceId.toLowerCase() || "app"}-fdc`;
102
+ info.locationId = info.locationId || `us-central1`;
103
+ info.cloudSqlDatabase = info.cloudSqlDatabase || `fdcdb`;
104
+ if (!info.schemaGql.length && !info.connectors.flatMap((r) => r.files).length) {
105
+ info.schemaGql = [defaultSchema];
106
+ info.connectors = [defaultConnector];
107
+ }
108
+ await writeFiles(config, info, options);
112
109
  if (setup.projectId && info.shouldProvisionCSQL) {
113
110
  await (0, provisionCloudSql_1.provisionCloudSql)({
114
111
  projectId: setup.projectId,
115
- locationId: info.locationId,
112
+ location: info.locationId,
116
113
  instanceId: info.cloudSqlInstanceId,
117
114
  databaseId: info.cloudSqlDatabase,
118
- configYamlPath: (0, path_1.join)(config.get("dataconnect.source"), "dataconnect.yaml"),
119
115
  enableGoogleMlIntegration: false,
120
116
  waitForCreation: false,
121
117
  });
122
118
  }
123
119
  }
124
120
  exports.actuate = actuate;
125
- async function writeFiles(config, info) {
121
+ async function postSetup(setup, config) {
122
+ const cwdPlatformGuess = await (0, fileUtils_1.getPlatformFromFolder)(process.cwd());
123
+ if (cwdPlatformGuess !== types_1.Platform.NONE || (0, utils_1.envOverride)("FDC_CONNECTOR", "")) {
124
+ await sdk.doSetup(setup, config);
125
+ }
126
+ else {
127
+ (0, utils_1.logBullet)(`If you'd like to add the generated SDK to your app later, run ${clc.bold("firebase init dataconnect:sdk")}`);
128
+ }
129
+ if (setup.projectId && !setup.isBillingEnabled) {
130
+ (0, utils_1.logBullet)((0, freeTrial_1.upgradeInstructions)(setup.projectId));
131
+ }
132
+ }
133
+ exports.postSetup = postSetup;
134
+ async function writeFiles(config, info, options) {
126
135
  const dir = config.get("dataconnect.source") || "dataconnect";
127
136
  const subbedDataconnectYaml = subDataconnectYamlValues({
128
137
  ...info,
129
138
  connectorDirs: info.connectors.map((c) => c.path),
130
139
  });
131
- if (!config.get("dataconnect.source")) {
132
- if (!info.schemaGql.length && !info.connectors.flatMap((r) => r.files).length) {
133
- info.schemaGql = [defaultSchema];
134
- info.connectors = [defaultConnector];
135
- }
136
- }
137
140
  config.set("dataconnect", { source: dir });
138
- await config.askWriteProjectFile((0, path_1.join)(dir, "dataconnect.yaml"), subbedDataconnectYaml, false, true);
141
+ await config.askWriteProjectFile((0, path_1.join)(dir, "dataconnect.yaml"), subbedDataconnectYaml, !!options.force, true);
139
142
  if (info.schemaGql.length) {
140
143
  for (const f of info.schemaGql) {
141
- await config.askWriteProjectFile((0, path_1.join)(dir, "schema", f.path), f.content);
144
+ await config.askWriteProjectFile((0, path_1.join)(dir, "schema", f.path), f.content, !!options.force);
142
145
  }
143
146
  }
144
147
  else {
@@ -180,31 +183,16 @@ function subConnectorYamlValues(replacementValues) {
180
183
  }
181
184
  return replaced;
182
185
  }
183
- async function promptForExistingServices(setup, info, isBillingEnabled) {
184
- if (!setup.projectId || !isBillingEnabled) {
186
+ async function promptForExistingServices(setup, info) {
187
+ if (!setup.projectId) {
185
188
  return info;
186
189
  }
187
190
  const existingServices = await (0, client_1.listAllServices)(setup.projectId);
188
191
  const existingServicesAndSchemas = await Promise.all(existingServices.map(async (s) => {
189
- return {
190
- service: s,
191
- schema: await (0, client_1.getSchema)(s.name),
192
- };
192
+ return { service: s, schema: await (0, client_1.getSchema)(s.name) };
193
193
  }));
194
194
  if (existingServicesAndSchemas.length) {
195
- const choices = existingServicesAndSchemas.map((s) => {
196
- const serviceName = (0, names_1.parseServiceName)(s.service.name);
197
- return {
198
- name: `${serviceName.location}/${serviceName.serviceId}`,
199
- value: s,
200
- };
201
- });
202
- choices.push({ name: "Create a new service", value: undefined });
203
- const choice = await (0, prompt_1.promptOnce)({
204
- message: "Your project already has existing services. Which would you like to set up local files for?",
205
- type: "list",
206
- choices,
207
- });
195
+ const choice = await chooseExistingService(existingServicesAndSchemas);
208
196
  if (choice) {
209
197
  const serviceName = (0, names_1.parseServiceName)(choice.service.name);
210
198
  info.serviceId = serviceName.serviceId;
@@ -240,6 +228,34 @@ async function promptForExistingServices(setup, info, isBillingEnabled) {
240
228
  }
241
229
  return info;
242
230
  }
231
+ async function chooseExistingService(existing) {
232
+ const serviceEnvVar = (0, utils_1.envOverride)("FDC_CONNECTOR", "") || (0, utils_1.envOverride)("FDC_SERVICE", "");
233
+ if (serviceEnvVar) {
234
+ const [serviceLocationFromEnvVar, serviceIdFromEnvVar] = serviceEnvVar.split("/");
235
+ const serviceFromEnvVar = existing.find((s) => {
236
+ const serviceName = (0, names_1.parseServiceName)(s.service.name);
237
+ return (serviceName.serviceId === serviceIdFromEnvVar &&
238
+ serviceName.location === serviceLocationFromEnvVar);
239
+ });
240
+ if (serviceFromEnvVar) {
241
+ (0, utils_1.logBullet)(`Picking up the existing service ${clc.bold(serviceLocationFromEnvVar + "/" + serviceIdFromEnvVar)}.`);
242
+ return serviceFromEnvVar;
243
+ }
244
+ (0, utils_1.logWarning)(`Unable to pick up an existing service based on FDC_SERVICE=${serviceEnvVar}.`);
245
+ }
246
+ const choices = existing.map((s) => {
247
+ const serviceName = (0, names_1.parseServiceName)(s.service.name);
248
+ return {
249
+ name: `${serviceName.location}/${serviceName.serviceId}`,
250
+ value: s,
251
+ };
252
+ });
253
+ choices.push({ name: "Create a new service", value: undefined });
254
+ return await (0, prompt_1.select)({
255
+ message: "Your project already has existing services. Which would you like to set up local files for?",
256
+ choices,
257
+ });
258
+ }
243
259
  async function promptForCloudSQL(setup, info) {
244
260
  if (info.cloudSqlInstanceId === "" && setup.projectId) {
245
261
  const instances = await cloudsql.listInstances(setup.projectId);
@@ -255,9 +271,11 @@ async function promptForCloudSQL(setup, info) {
255
271
  if (!(await (0, freeTrial_1.checkFreeTrialInstanceUsed)(setup.projectId))) {
256
272
  choices.push({ name: "Create a new free trial instance", value: "", location: "" });
257
273
  }
258
- info.cloudSqlInstanceId = await (0, prompt_1.promptOnce)({
274
+ else {
275
+ choices.push({ name: "Create a new CloudSQL instance", value: "", location: "" });
276
+ }
277
+ info.cloudSqlInstanceId = await (0, prompt_1.select)({
259
278
  message: `Which CloudSQL instance would you like to use?`,
260
- type: "list",
261
279
  choices,
262
280
  });
263
281
  if (info.cloudSqlInstanceId !== "") {
@@ -267,17 +285,15 @@ async function promptForCloudSQL(setup, info) {
267
285
  }
268
286
  if (info.cloudSqlInstanceId === "") {
269
287
  info.isNewInstance = true;
270
- info.cloudSqlInstanceId = await (0, prompt_1.promptOnce)({
288
+ info.cloudSqlInstanceId = await (0, prompt_1.input)({
271
289
  message: `What ID would you like to use for your new CloudSQL instance?`,
272
- type: "input",
273
- default: `${info.serviceId || "app"}-fdc`,
290
+ default: `${info.serviceId.toLowerCase() || "app"}-fdc`,
274
291
  });
275
292
  }
276
293
  if (info.locationId === "") {
277
294
  const choices = await locationChoices(setup);
278
- info.locationId = await (0, prompt_1.promptOnce)({
295
+ info.locationId = await (0, prompt_1.select)({
279
296
  message: "What location would like to use?",
280
- type: "list",
281
297
  choices,
282
298
  });
283
299
  }
@@ -289,9 +305,8 @@ async function promptForCloudSQL(setup, info) {
289
305
  });
290
306
  choices.push({ name: "Create a new database", value: "" });
291
307
  if (dbs.length) {
292
- info.cloudSqlDatabase = await (0, prompt_1.promptOnce)({
308
+ info.cloudSqlDatabase = await (0, prompt_1.select)({
293
309
  message: `Which database in ${info.cloudSqlInstanceId} would you like to use?`,
294
- type: "list",
295
310
  choices,
296
311
  });
297
312
  }
@@ -302,21 +317,38 @@ async function promptForCloudSQL(setup, info) {
302
317
  }
303
318
  if (info.cloudSqlDatabase === "") {
304
319
  info.isNewDatabase = true;
305
- info.cloudSqlDatabase = await (0, prompt_1.promptOnce)({
320
+ info.cloudSqlDatabase = await (0, prompt_1.input)({
306
321
  message: `What ID would you like to use for your new database in ${info.cloudSqlInstanceId}?`,
307
- type: "input",
308
322
  default: `fdcdb`,
309
323
  });
310
324
  }
311
325
  return info;
312
326
  }
313
- async function promptForService(info) {
327
+ async function promptForSchema(setup, info) {
314
328
  if (info.serviceId === "") {
315
- info.serviceId = await (0, prompt_1.promptOnce)({
329
+ info.serviceId = await (0, prompt_1.input)({
316
330
  message: "What ID would you like to use for this service?",
317
- type: "input",
318
331
  default: (0, path_1.basename)(process.cwd()),
319
332
  });
333
+ if (setup.projectId) {
334
+ if (!configstore_1.configstore.get("gemini")) {
335
+ (0, utils_1.logBullet)("Learn more about Gemini in Firebase and how it uses your data: https://firebase.google.com/docs/gemini-in-firebase#how-gemini-in-firebase-uses-your-data");
336
+ }
337
+ if (await (0, prompt_1.confirm)({
338
+ message: `Do you want Gemini in Firebase to help generate a schema for your service?`,
339
+ default: false,
340
+ })) {
341
+ configstore_1.configstore.set("gemini", true);
342
+ await (0, ensureApis_1.ensureGIFApis)(setup.projectId);
343
+ const prompt = await (0, prompt_1.input)({
344
+ message: "Describe the app you are building:",
345
+ default: "movie rating app",
346
+ });
347
+ const schema = await (0, utils_1.promiseWithSpinner)(() => (0, fdcExperience_1.generateSchema)(prompt, setup.projectId), "Generating the Data Connect Schema...");
348
+ info.schemaGql = [{ path: "schema.gql", content: (0, fdcExperience_1.extractCodeBlock)(schema) }];
349
+ info.connectors = [emptyConnector];
350
+ }
351
+ }
320
352
  }
321
353
  return info;
322
354
  }
@@ -340,3 +372,17 @@ async function locationChoices(setup) {
340
372
  ];
341
373
  }
342
374
  }
375
+ function toDNSCompatibleId(id) {
376
+ let defaultServiceId = (0, path_1.basename)(id)
377
+ .toLowerCase()
378
+ .replaceAll(/[^a-z0-9-]/g, "")
379
+ .slice(0, 63);
380
+ while (defaultServiceId.endsWith("-") && defaultServiceId.length) {
381
+ defaultServiceId = defaultServiceId.slice(0, defaultServiceId.length - 1);
382
+ }
383
+ while (defaultServiceId.startsWith("-") && defaultServiceId.length) {
384
+ defaultServiceId = defaultServiceId.slice(1, defaultServiceId.length);
385
+ }
386
+ return defaultServiceId || "app";
387
+ }
388
+ exports.toDNSCompatibleId = toDNSCompatibleId;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.actuate = exports.generateSdkYaml = exports.doSetup = exports.FDC_APP_FOLDER = void 0;
4
4
  const yaml = require("yaml");
5
- const fs = require("fs");
6
5
  const clc = require("colorette");
7
6
  const path = require("path");
8
7
  const fsutils_1 = require("../../../fsutils");
@@ -14,10 +13,11 @@ const dataconnectEmulator_1 = require("../../../emulator/dataconnectEmulator");
14
13
  const error_1 = require("../../../error");
15
14
  const lodash_1 = require("lodash");
16
15
  const utils_1 = require("../../../utils");
16
+ const auth_1 = require("../../../auth");
17
17
  exports.FDC_APP_FOLDER = "_FDC_APP_FOLDER";
18
18
  async function doSetup(setup, config) {
19
19
  const sdkInfo = await askQuestions(setup, config);
20
- await actuate(sdkInfo);
20
+ await actuate(sdkInfo, config);
21
21
  (0, utils_1.logSuccess)(`If you'd like to add more generated SDKs to your app your later, run ${clc.bold("firebase init dataconnect:sdk")} again`);
22
22
  }
23
23
  exports.doSetup = doSetup;
@@ -28,7 +28,7 @@ async function askQuestions(setup, config) {
28
28
  .map((si) => {
29
29
  return si.connectorInfo.map((ci) => {
30
30
  return {
31
- name: `${si.dataConnectYaml.serviceId}/${ci.connectorYaml.connectorId}`,
31
+ name: `${si.dataConnectYaml.location}/${si.dataConnectYaml.serviceId}/${ci.connectorYaml.connectorId}`,
32
32
  value: ci,
33
33
  };
34
34
  });
@@ -40,7 +40,7 @@ async function askQuestions(setup, config) {
40
40
  let appDir = process.env[exports.FDC_APP_FOLDER] || process.cwd();
41
41
  let targetPlatform = await (0, fileUtils_1.getPlatformFromFolder)(appDir);
42
42
  if (targetPlatform === types_1.Platform.NONE && !process.env[exports.FDC_APP_FOLDER]?.length) {
43
- appDir = await (0, prompt_1.promptForDirectory)({
43
+ appDir = await (0, utils_1.promptForDirectory)({
44
44
  config,
45
45
  message: "Where is your app directory? Leave blank to set up a generated SDK in your current directory.",
46
46
  });
@@ -59,28 +59,57 @@ async function askQuestions(setup, config) {
59
59
  { name: "Android (Kotlin)", value: types_1.Platform.ANDROID },
60
60
  { name: "Flutter (Dart)", value: types_1.Platform.FLUTTER },
61
61
  ];
62
- targetPlatform = await (0, prompt_1.promptOnce)({
62
+ targetPlatform = await (0, prompt_1.select)({
63
63
  message: "Which platform do you want to set up a generated SDK for?",
64
- type: "list",
65
64
  choices: platforms,
66
65
  });
67
66
  }
68
67
  else {
69
68
  (0, utils_1.logSuccess)(`Detected ${targetPlatform} app in directory ${appDir}`);
70
69
  }
71
- const connectorInfo = await (0, prompt_1.promptOnce)({
72
- message: "Which connector do you want set up a generated SDK for?",
73
- type: "list",
74
- choices: connectorChoices,
75
- });
70
+ const connectorInfo = await chooseExistingConnector(connectorChoices);
76
71
  const connectorYaml = JSON.parse(JSON.stringify(connectorInfo.connectorYaml));
77
- const newConnectorYaml = generateSdkYaml(targetPlatform, connectorYaml, connectorInfo.directory, appDir);
72
+ const newConnectorYaml = await generateSdkYaml(targetPlatform, connectorYaml, connectorInfo.directory, appDir);
73
+ if (targetPlatform === types_1.Platform.WEB) {
74
+ const unusedFrameworks = fileUtils_1.SUPPORTED_FRAMEWORKS.filter((framework) => !newConnectorYaml.generate?.javascriptSdk[framework]);
75
+ if (unusedFrameworks.length > 0) {
76
+ const additionalFrameworks = await (0, prompt_1.checkbox)({
77
+ message: "Which frameworks would you like to generate SDKs for? " +
78
+ "Press Space to select features, then Enter to confirm your choices.",
79
+ choices: fileUtils_1.SUPPORTED_FRAMEWORKS.map((frameworkStr) => ({
80
+ value: frameworkStr,
81
+ checked: newConnectorYaml?.generate?.javascriptSdk?.[frameworkStr],
82
+ })),
83
+ });
84
+ for (const framework of additionalFrameworks) {
85
+ newConnectorYaml.generate.javascriptSdk[framework] = true;
86
+ }
87
+ }
88
+ }
78
89
  const connectorYamlContents = yaml.stringify(newConnectorYaml);
79
90
  connectorInfo.connectorYaml = newConnectorYaml;
80
91
  const displayIOSWarning = targetPlatform === types_1.Platform.IOS;
81
92
  return { connectorYamlContents, connectorInfo, displayIOSWarning };
82
93
  }
83
- function generateSdkYaml(targetPlatform, connectorYaml, connectorDir, appDir) {
94
+ async function chooseExistingConnector(choices) {
95
+ if (choices.length === 1) {
96
+ return choices[0].value;
97
+ }
98
+ const connectorEnvVar = (0, utils_1.envOverride)("FDC_CONNECTOR", "");
99
+ if (connectorEnvVar) {
100
+ const existingConnector = choices.find((c) => c.name === connectorEnvVar);
101
+ if (existingConnector) {
102
+ (0, utils_1.logBullet)(`Picking up the existing connector ${clc.bold(connectorEnvVar)}.`);
103
+ return existingConnector.value;
104
+ }
105
+ (0, utils_1.logWarning)(`Unable to pick up an existing connector based on FDC_CONNECTOR=${connectorEnvVar}.`);
106
+ }
107
+ return await (0, prompt_1.select)({
108
+ message: "Which connector do you want set up a generated SDK for?",
109
+ choices: choices,
110
+ });
111
+ }
112
+ async function generateSdkYaml(targetPlatform, connectorYaml, connectorDir, appDir) {
84
113
  if (!connectorYaml.generate) {
85
114
  connectorYaml.generate = {};
86
115
  }
@@ -93,11 +122,20 @@ function generateSdkYaml(targetPlatform, connectorYaml, connectorDir, appDir) {
93
122
  }
94
123
  if (targetPlatform === types_1.Platform.WEB) {
95
124
  const pkg = `${connectorYaml.connectorId}-connector`;
125
+ const packageJsonDir = path.relative(connectorDir, appDir);
96
126
  const javascriptSdk = {
97
127
  outputDir: path.relative(connectorDir, path.join(appDir, `dataconnect-generated/js/${pkg}`)),
98
128
  package: `@firebasegen/${pkg}`,
99
- packageJsonDir: path.relative(connectorDir, appDir),
129
+ packageJsonDir,
100
130
  };
131
+ const packageJson = await (0, fileUtils_1.resolvePackageJson)(appDir);
132
+ if (packageJson) {
133
+ const frameworksUsed = (0, fileUtils_1.getFrameworksFromPackageJson)(packageJson);
134
+ for (const framework of frameworksUsed) {
135
+ (0, utils_1.logBullet)(`Detected ${framework} app. Enabling ${framework} generated SDKs.`);
136
+ javascriptSdk[framework] = true;
137
+ }
138
+ }
101
139
  connectorYaml.generate.javascriptSdk = javascriptSdk;
102
140
  }
103
141
  if (targetPlatform === types_1.Platform.FLUTTER) {
@@ -124,17 +162,34 @@ function generateSdkYaml(targetPlatform, connectorYaml, connectorDir, appDir) {
124
162
  return connectorYaml;
125
163
  }
126
164
  exports.generateSdkYaml = generateSdkYaml;
127
- async function actuate(sdkInfo) {
165
+ async function actuate(sdkInfo, config) {
128
166
  const connectorYamlPath = `${sdkInfo.connectorInfo.directory}/connector.yaml`;
129
- fs.writeFileSync(connectorYamlPath, sdkInfo.connectorYamlContents, "utf8");
130
- (0, utils_1.logBullet)(`Wrote new config to ${connectorYamlPath}`);
167
+ (0, utils_1.logBullet)(`Writing your new SDK configuration to ${connectorYamlPath}`);
168
+ await config.askWriteProjectFile(path.relative(config.projectDir, connectorYamlPath), sdkInfo.connectorYamlContents, false, true);
169
+ const account = (0, auth_1.getGlobalDefaultAccount)();
131
170
  await dataconnectEmulator_1.DataConnectEmulator.generate({
132
171
  configDir: sdkInfo.connectorInfo.directory,
133
172
  connectorId: sdkInfo.connectorInfo.connectorYaml.connectorId,
173
+ account,
134
174
  });
135
175
  (0, utils_1.logBullet)(`Generated SDK code for ${sdkInfo.connectorInfo.connectorYaml.connectorId}`);
136
176
  if (sdkInfo.connectorInfo.connectorYaml.generate?.swiftSdk && sdkInfo.displayIOSWarning) {
137
- (0, utils_1.logBullet)(clc.bold("Please follow the instructions here to add your generated sdk to your XCode project:\n\thttps://firebase.google.com/docs/data-connect/gp/ios-sdk#set-client"));
177
+ (0, utils_1.logBullet)(clc.bold("Please follow the instructions here to add your generated sdk to your XCode project:\n\thttps://firebase.google.com/docs/data-connect/ios-sdk#set-client"));
178
+ }
179
+ if (sdkInfo.connectorInfo.connectorYaml.generate?.javascriptSdk) {
180
+ for (const framework of fileUtils_1.SUPPORTED_FRAMEWORKS) {
181
+ if (sdkInfo.connectorInfo.connectorYaml.generate.javascriptSdk[framework]) {
182
+ logInfoForFramework(framework);
183
+ }
184
+ }
138
185
  }
139
186
  }
140
187
  exports.actuate = actuate;
188
+ function logInfoForFramework(framework) {
189
+ if (framework === "react") {
190
+ (0, utils_1.logBullet)("Visit https://firebase.google.com/docs/data-connect/web-sdk#react for more information on how to set up React Generated SDKs for Firebase Data Connect");
191
+ }
192
+ else if (framework === "angular") {
193
+ (0, utils_1.logBullet)("Run `npm i --save @angular/fire @tanstack-query-firebase/angular @tanstack/angular-query-experimental` to install angular sdk dependencies.\nVisit https://github.com/invertase/tanstack-query-firebase/tree/main/packages/angular for more information on how to set up Angular Generated SDKs for Firebase Data Connect");
194
+ }
195
+ }
@@ -13,44 +13,40 @@ async function doSetup(setup, config) {
13
13
  return {
14
14
  value: e,
15
15
  name: constants_1.Constants.description(e),
16
- checked: config && (config.has(e) || config.has(`emulators.${e}`)),
16
+ checked: config?.has(e) || config?.has(`emulators.${e}`),
17
17
  };
18
18
  });
19
19
  const selections = {};
20
- await (0, prompt_1.prompt)(selections, [
21
- {
22
- type: "checkbox",
23
- name: "emulators",
24
- message: "Which Firebase emulators do you want to set up? " +
25
- "Press Space to select emulators, then Enter to confirm your choices.",
26
- choices: choices,
27
- },
28
- ]);
20
+ selections.emulators = await (0, prompt_1.checkbox)({
21
+ message: "Which Firebase emulators do you want to set up? " +
22
+ "Press Space to select emulators, then Enter to confirm your choices.",
23
+ choices: choices,
24
+ });
29
25
  if (!selections.emulators) {
30
26
  return;
31
27
  }
32
28
  setup.config.emulators = setup.config.emulators || {};
29
+ const emulators = setup.config.emulators || {};
33
30
  for (const selected of selections.emulators) {
34
- setup.config.emulators[selected] = setup.config.emulators[selected] || {};
35
- const currentPort = setup.config.emulators[selected].port;
31
+ if (selected === "extensions")
32
+ continue;
33
+ const selectedEmulator = emulators[selected] || {};
34
+ const currentPort = selectedEmulator.port;
36
35
  if (currentPort) {
37
36
  utils.logBullet(`Port for ${selected} already configured: ${clc.cyan(currentPort)}`);
38
37
  }
39
38
  else {
40
- await (0, prompt_1.prompt)(setup.config.emulators[selected], [
41
- {
42
- type: "number",
43
- name: "port",
44
- message: `Which port do you want to use for the ${clc.underline(selected)} emulator?`,
45
- default: constants_1.Constants.getDefaultPort(selected),
46
- },
47
- ]);
39
+ selectedEmulator.port = await (0, prompt_1.number)({
40
+ message: `Which port do you want to use for the ${clc.underline(selected)} emulator?`,
41
+ default: constants_1.Constants.getDefaultPort(selected),
42
+ });
48
43
  }
44
+ emulators[selected] = selectedEmulator;
49
45
  const additionalInitFn = initEmulators_1.AdditionalInitFns[selected];
50
46
  if (additionalInitFn) {
51
47
  const additionalOptions = await additionalInitFn(config);
52
48
  if (additionalOptions) {
53
- setup.config.emulators[selected] = {
49
+ emulators[selected] = {
54
50
  ...setup.config.emulators[selected],
55
51
  ...additionalOptions,
56
52
  };
@@ -66,34 +62,21 @@ async function doSetup(setup, config) {
66
62
  else {
67
63
  const ui = setup.config.emulators.ui || {};
68
64
  setup.config.emulators.ui = ui;
69
- await (0, prompt_1.prompt)(ui, [
70
- {
71
- name: "enabled",
72
- type: "confirm",
73
- message: `Would you like to enable the ${uiDesc}?`,
74
- default: true,
75
- },
76
- ]);
65
+ ui.enabled = await (0, prompt_1.confirm)({
66
+ message: `Would you like to enable the ${uiDesc}?`,
67
+ default: true,
68
+ });
77
69
  if (ui.enabled) {
78
- await (0, prompt_1.prompt)(ui, [
79
- {
80
- type: "input",
81
- name: "port",
82
- message: `Which port do you want to use for the ${clc.underline(uiDesc)} (leave empty to use any available port)?`,
83
- },
84
- ]);
85
- const portNum = Number.parseInt(ui.port);
86
- ui.port = isNaN(portNum) ? undefined : portNum;
70
+ ui.port = await (0, prompt_1.number)({
71
+ message: `Which port do you want to use for the ${clc.underline(uiDesc)} (leave empty to use any available port)?`,
72
+ required: false,
73
+ });
87
74
  }
88
75
  }
89
- await (0, prompt_1.prompt)(selections, [
90
- {
91
- name: "download",
92
- type: "confirm",
93
- message: "Would you like to download the emulators now?",
94
- default: true,
95
- },
96
- ]);
76
+ selections.download = await (0, prompt_1.confirm)({
77
+ message: "Would you like to download the emulators now?",
78
+ default: true,
79
+ });
97
80
  }
98
81
  if (setup.config.emulators.singleProjectMode === undefined) {
99
82
  setup.config.emulators.singleProjectMode = true;