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.command = void 0;
3
+ exports.command = exports.setNewActive = void 0;
4
4
  const clc = require("colorette");
5
5
  const command_1 = require("../command");
6
6
  const projects_1 = require("../management/projects");
@@ -9,6 +9,7 @@ const prompt_1 = require("../prompt");
9
9
  const requireAuth_1 = require("../requireAuth");
10
10
  const command_2 = require("../command");
11
11
  const utils = require("../utils");
12
+ const error_1 = require("../error");
12
13
  function listAliases(options) {
13
14
  if (options.rc.hasProjects) {
14
15
  logger_1.logger.info("Project aliases for", clc.bold(options.projectRoot || "") + ":");
@@ -29,6 +30,110 @@ function listAliases(options) {
29
30
  function verifyMessage(name) {
30
31
  return "please verify project " + clc.bold(name) + " exists and you have access.";
31
32
  }
33
+ async function setNewActive(projectOrAlias, aliasOpt, rc, projectRoot) {
34
+ let project;
35
+ const hasAlias = rc.hasProjectAlias(projectOrAlias);
36
+ const resolvedProject = rc.resolveAlias(projectOrAlias);
37
+ (0, command_2.validateProjectId)(resolvedProject);
38
+ try {
39
+ project = await (0, projects_1.getProject)(resolvedProject);
40
+ }
41
+ catch {
42
+ throw new error_1.FirebaseError("Invalid project selection, " + verifyMessage(projectOrAlias));
43
+ }
44
+ if (aliasOpt) {
45
+ if (!project) {
46
+ throw new error_1.FirebaseError(`Cannot create alias ${clc.bold(aliasOpt)}, ${verifyMessage(projectOrAlias)}`);
47
+ }
48
+ rc.addProjectAlias(aliasOpt, projectOrAlias);
49
+ logger_1.logger.info("Created alias", clc.bold(aliasOpt), "for", resolvedProject + ".");
50
+ }
51
+ if (hasAlias) {
52
+ if (!project) {
53
+ throw new error_1.FirebaseError(`Unable to use alias ${clc.bold(projectOrAlias)}, ${verifyMessage(resolvedProject)}`);
54
+ }
55
+ utils.makeActiveProject(projectRoot, projectOrAlias);
56
+ logger_1.logger.info("Now using alias", clc.bold(projectOrAlias), "(" + resolvedProject + ")");
57
+ }
58
+ else if (project) {
59
+ utils.makeActiveProject(projectRoot, projectOrAlias);
60
+ logger_1.logger.info("Now using project", clc.bold(projectOrAlias));
61
+ }
62
+ else {
63
+ throw new error_1.FirebaseError(`Invalid project selection, ${verifyMessage(projectOrAlias)}`);
64
+ }
65
+ }
66
+ exports.setNewActive = setNewActive;
67
+ function unalias(alias, options) {
68
+ if (options.rc.hasProjectAlias(alias)) {
69
+ options.rc.removeProjectAlias(alias);
70
+ logger_1.logger.info("Removed alias", clc.bold(alias));
71
+ logger_1.logger.info();
72
+ listAliases(options);
73
+ }
74
+ }
75
+ async function addAlias(options) {
76
+ if (options.nonInteractive) {
77
+ return utils.reject("Cannot run " +
78
+ clc.bold("firebase use --add") +
79
+ " in non-interactive mode. Use " +
80
+ clc.bold("firebase use <project_id> --alias <alias>") +
81
+ " instead.");
82
+ }
83
+ const projects = await (0, projects_1.listFirebaseProjects)();
84
+ const project = await (0, prompt_1.select)({
85
+ message: "Which project do you want to add?",
86
+ choices: projects.map((p) => p.projectId).sort(),
87
+ });
88
+ const alias = await (0, prompt_1.input)({
89
+ message: "What alias do you want to use for this project? (e.g. staging)",
90
+ validate: (input) => {
91
+ return input && input.length > 0;
92
+ },
93
+ });
94
+ const results = {
95
+ project,
96
+ alias,
97
+ };
98
+ options.rc.addProjectAlias(alias, project);
99
+ utils.makeActiveProject(options.projectRoot, results.alias);
100
+ logger_1.logger.info();
101
+ logger_1.logger.info("Created alias", clc.bold(results.alias || ""), "for", results.project + ".");
102
+ logger_1.logger.info("Now using alias", clc.bold(results.alias || "") + " (" + results.project + ")");
103
+ }
104
+ function clearAlias(options) {
105
+ utils.makeActiveProject(options.projectRoot, undefined);
106
+ delete options.projectAlias;
107
+ delete options.project;
108
+ logger_1.logger.info("Cleared active project.");
109
+ logger_1.logger.info();
110
+ listAliases(options);
111
+ }
112
+ async function genericUse(options) {
113
+ if (options.nonInteractive || !process.stdout.isTTY) {
114
+ if (options.project) {
115
+ logger_1.logger.info(options.project);
116
+ return options.project;
117
+ }
118
+ return utils.reject("No active project");
119
+ }
120
+ if (options.projectAlias) {
121
+ logger_1.logger.info("Active Project:", clc.bold(clc.cyan(options.projectAlias + " (" + options.project + ")")));
122
+ }
123
+ else if (options.project) {
124
+ logger_1.logger.info("Active Project:", clc.bold(clc.cyan(options.project)));
125
+ }
126
+ else {
127
+ let msg = "No project is currently active";
128
+ if (options.rc.hasProjects) {
129
+ msg += ", and no aliases have been created.";
130
+ }
131
+ logger_1.logger.info(msg + ".");
132
+ }
133
+ logger_1.logger.info();
134
+ listAliases(options);
135
+ return options.project;
136
+ }
32
137
  exports.command = new command_1.Command("use [alias_or_project_id]")
33
138
  .description("set an active Firebase project for your working directory")
34
139
  .option("--add", "create a new project alias interactively")
@@ -49,117 +154,16 @@ exports.command = new command_1.Command("use [alias_or_project_id]")
49
154
  " to start a project directory in the current folder.");
50
155
  }
51
156
  if (newActive) {
52
- let project;
53
- const hasAlias = options.rc.hasProjectAlias(newActive);
54
- const resolvedProject = options.rc.resolveAlias(newActive);
55
- (0, command_2.validateProjectId)(resolvedProject);
56
- return (0, projects_1.getProject)(resolvedProject)
57
- .then((foundProject) => {
58
- project = foundProject;
59
- })
60
- .catch(() => {
61
- return utils.reject("Invalid project selection, " + verifyMessage(newActive));
62
- })
63
- .then(() => {
64
- if (aliasOpt) {
65
- if (!project) {
66
- return utils.reject("Cannot create alias " + clc.bold(aliasOpt) + ", " + verifyMessage(newActive));
67
- }
68
- options.rc.addProjectAlias(aliasOpt, newActive);
69
- logger_1.logger.info("Created alias", clc.bold(aliasOpt), "for", resolvedProject + ".");
70
- }
71
- if (hasAlias) {
72
- if (!project) {
73
- return utils.reject("Unable to use alias " +
74
- clc.bold(newActive) +
75
- ", " +
76
- verifyMessage(resolvedProject));
77
- }
78
- utils.makeActiveProject(options.projectRoot, newActive);
79
- logger_1.logger.info("Now using alias", clc.bold(newActive), "(" + resolvedProject + ")");
80
- }
81
- else if (project) {
82
- utils.makeActiveProject(options.projectRoot, newActive);
83
- logger_1.logger.info("Now using project", clc.bold(newActive));
84
- }
85
- else {
86
- return utils.reject("Invalid project selection, " + verifyMessage(newActive));
87
- }
88
- });
89
- }
90
- else if (options.unalias) {
91
- if (options.rc.hasProjectAlias(options.unalias)) {
92
- options.rc.removeProjectAlias(options.unalias);
93
- logger_1.logger.info("Removed alias", clc.bold(options.unalias));
94
- logger_1.logger.info();
95
- listAliases(options);
96
- }
157
+ return setNewActive(newActive, aliasOpt, options.rc, options.projectRoot);
97
158
  }
98
- else if (options.add) {
99
- if (options.nonInteractive) {
100
- return utils.reject("Cannot run " +
101
- clc.bold("firebase use --add") +
102
- " in non-interactive mode. Use " +
103
- clc.bold("firebase use <project_id> --alias <alias>") +
104
- " instead.");
105
- }
106
- return (0, projects_1.listFirebaseProjects)().then((projects) => {
107
- const results = {};
108
- return (0, prompt_1.prompt)(results, [
109
- {
110
- type: "list",
111
- name: "project",
112
- message: "Which project do you want to add?",
113
- choices: projects.map((p) => p.projectId).sort(),
114
- },
115
- {
116
- type: "input",
117
- name: "alias",
118
- message: "What alias do you want to use for this project? (e.g. staging)",
119
- validate: (input) => {
120
- return input && input.length > 0;
121
- },
122
- },
123
- ]).then(() => {
124
- options.rc.addProjectAlias(results.alias, results.project);
125
- utils.makeActiveProject(options.projectRoot, results.alias);
126
- logger_1.logger.info();
127
- logger_1.logger.info("Created alias", clc.bold(results.alias || ""), "for", results.project + ".");
128
- logger_1.logger.info("Now using alias", clc.bold(results.alias || "") + " (" + results.project + ")");
129
- });
130
- });
131
- }
132
- else if (options.clear) {
133
- utils.makeActiveProject(options.projectRoot, undefined);
134
- options.projectAlias = null;
135
- options.project = null;
136
- logger_1.logger.info("Cleared active project.");
137
- logger_1.logger.info();
138
- listAliases(options);
159
+ if (options.unalias) {
160
+ return unalias(options.unalias, options);
139
161
  }
140
- else {
141
- if (options.nonInteractive || !process.stdout.isTTY) {
142
- if (options.project) {
143
- logger_1.logger.info(options.project);
144
- return options.project;
145
- }
146
- return utils.reject("No active project");
147
- }
148
- if (options.projectAlias) {
149
- logger_1.logger.info("Active Project:", clc.bold(clc.cyan(options.projectAlias + " (" + options.project + ")")));
150
- }
151
- else if (options.project) {
152
- logger_1.logger.info("Active Project:", clc.bold(clc.cyan(options.project)));
153
- }
154
- else {
155
- let msg = "No project is currently active";
156
- if (options.rc.hasProjects) {
157
- msg += ", and no aliases have been created.";
158
- }
159
- logger_1.logger.info(msg + ".");
160
- }
161
- logger_1.logger.info();
162
- listAliases(options);
163
- return options.project;
162
+ if (options.add) {
163
+ return addAlias(options);
164
+ }
165
+ if (options.clear) {
166
+ return clearAlias(options);
164
167
  }
168
+ return genericUse(options);
165
169
  });
package/lib/config.js CHANGED
@@ -126,6 +126,9 @@ class Config {
126
126
  return _.has(this.data, key);
127
127
  }
128
128
  path(pathName) {
129
+ if (path.isAbsolute(pathName)) {
130
+ return pathName;
131
+ }
129
132
  const outPath = path.normalize(path.join(this.projectDir, pathName));
130
133
  if (path.relative(this.projectDir, outPath).includes("..")) {
131
134
  throw new error_1.FirebaseError(clc.bold(pathName) + " is outside of project directory", { exit: 1 });
@@ -152,11 +155,20 @@ class Config {
152
155
  }
153
156
  }
154
157
  writeProjectFile(p, content) {
155
- if (typeof content !== "string") {
156
- content = JSON.stringify(content, null, 2) + "\n";
158
+ const path = this.path(p);
159
+ fs.ensureFileSync(path);
160
+ fs.writeFileSync(path, stringifyContent(content), "utf8");
161
+ switch (p) {
162
+ case "firebase.json":
163
+ utils.logSuccess("Wrote configuration info to " + clc.bold("firebase.json"));
164
+ break;
165
+ case ".firebaserc":
166
+ utils.logSuccess("Wrote project information to " + clc.bold(".firebaserc"));
167
+ break;
168
+ default:
169
+ utils.logSuccess("Wrote " + clc.bold(p));
170
+ break;
157
171
  }
158
- fs.ensureFileSync(this.path(p));
159
- fs.writeFileSync(this.path(p), content, "utf8");
160
172
  }
161
173
  projectFileExists(p) {
162
174
  return fs.existsSync(this.path(p));
@@ -164,38 +176,35 @@ class Config {
164
176
  deleteProjectFile(p) {
165
177
  fs.removeSync(this.path(p));
166
178
  }
167
- askWriteProjectFile(p, content, force, confirmByDefault) {
168
- const writeTo = this.path(p);
169
- let next;
170
- if (typeof content !== "string") {
171
- content = JSON.stringify(content, null, 2) + "\n";
172
- }
173
- let existingContent;
174
- if (fsutils.fileExistsSync(writeTo)) {
175
- existingContent = fsutils.readFile(writeTo);
176
- }
177
- if (existingContent && existingContent !== content && !force) {
178
- next = (0, prompt_1.promptOnce)({
179
- type: "confirm",
180
- message: "File " + clc.underline(p) + " already exists. Overwrite?",
181
- default: !!confirmByDefault,
182
- });
179
+ async confirmWriteProjectFile(path, content, confirmByDefault) {
180
+ const writeTo = this.path(path);
181
+ if (!fsutils.fileExistsSync(writeTo)) {
182
+ return true;
183
183
  }
184
- else {
185
- next = Promise.resolve(true);
184
+ const existingContent = fsutils.readFile(writeTo);
185
+ const newContent = stringifyContent(content);
186
+ if (existingContent === newContent) {
187
+ utils.logBullet(clc.bold(path) + " is unchanged");
188
+ return false;
186
189
  }
187
- return next.then((result) => {
188
- if (existingContent === content) {
189
- utils.logBullet(clc.bold(p) + " is unchanged");
190
- }
191
- else if (result) {
192
- this.writeProjectFile(p, content);
193
- utils.logSuccess("Wrote " + clc.bold(p));
194
- }
195
- else {
196
- utils.logBullet("Skipping write of " + clc.bold(p));
197
- }
190
+ const shouldWrite = await (0, prompt_1.confirm)({
191
+ message: "File " + clc.underline(path) + " already exists. Overwrite?",
192
+ default: !!confirmByDefault,
198
193
  });
194
+ if (!shouldWrite) {
195
+ utils.logBullet("Skipping write of " + clc.bold(path));
196
+ return false;
197
+ }
198
+ return true;
199
+ }
200
+ async askWriteProjectFile(path, content, force, confirmByDefault) {
201
+ if (!force) {
202
+ const shouldWrite = await this.confirmWriteProjectFile(path, content, confirmByDefault);
203
+ if (!shouldWrite) {
204
+ return;
205
+ }
206
+ }
207
+ this.writeProjectFile(path, content);
199
208
  }
200
209
  static load(options, allowMissing) {
201
210
  const pd = (0, detectProjectRoot_1.detectProjectRoot)(options);
@@ -241,4 +250,11 @@ Config.MATERIALIZE_TARGETS = [
241
250
  "storage",
242
251
  "remoteconfig",
243
252
  "dataconnect",
253
+ "apphosting",
244
254
  ];
255
+ function stringifyContent(content) {
256
+ if (typeof content === "string") {
257
+ return content;
258
+ }
259
+ return JSON.stringify(content, null, 2) + "\n";
260
+ }
@@ -12,7 +12,7 @@ const node_fs_1 = require("node:fs");
12
12
  const utils = require("../utils");
13
13
  const JAR_CACHE_DIR = process.env.FIREBASE_CRASHLYTICS_BUILDTOOLS_PATH ||
14
14
  path.join(os.homedir(), ".cache", "firebase", "crashlytics", "buildtools");
15
- const JAR_VERSION = "3.0.2";
15
+ const JAR_VERSION = "3.0.3";
16
16
  const JAR_URL = `https://dl.google.com/android/maven2/com/google/firebase/firebase-crashlytics-buildtools/${JAR_VERSION}/firebase-crashlytics-buildtools-${JAR_VERSION}.jar`;
17
17
  async function fetchBuildtoolsJar() {
18
18
  if (process.env.CRASHLYTICS_LOCAL_JAR) {
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listTopIssues = void 0;
4
+ const apiv2_1 = require("../apiv2");
5
+ const logger_1 = require("../logger");
6
+ const error_1 = require("../error");
7
+ const api_1 = require("../api");
8
+ const TIMEOUT = 10000;
9
+ const apiClient = new apiv2_1.Client({
10
+ urlPrefix: (0, api_1.crashlyticsApiOrigin)(),
11
+ apiVersion: "v1alpha",
12
+ });
13
+ async function listTopIssues(projectId, appId, issueType, issueCount) {
14
+ try {
15
+ const queryParams = new URLSearchParams();
16
+ queryParams.set("page_size", `${issueCount}`);
17
+ queryParams.set("filter.issue.error_types", `${issueType}`);
18
+ const requestProjectId = parseProjectId(appId);
19
+ if (requestProjectId === undefined) {
20
+ throw new error_1.FirebaseError("Unable to get the projectId from the AppId.");
21
+ }
22
+ const response = await apiClient.request({
23
+ method: "GET",
24
+ headers: {
25
+ "Content-Type": "application/json",
26
+ },
27
+ path: `/projects/${requestProjectId}/apps/${appId}/reports/topIssues`,
28
+ queryParams: queryParams,
29
+ timeout: TIMEOUT,
30
+ });
31
+ return response.body;
32
+ }
33
+ catch (err) {
34
+ logger_1.logger.debug(err.message);
35
+ throw new error_1.FirebaseError(`Failed to fetch the top issues for the Firebase Project ${projectId}, AppId ${appId}. Error: ${err}.`, { original: err });
36
+ }
37
+ }
38
+ exports.listTopIssues = listTopIssues;
39
+ function parseProjectId(appId) {
40
+ const appIdParts = appId.split(":");
41
+ if (appIdParts.length > 1) {
42
+ return appIdParts[1];
43
+ }
44
+ return undefined;
45
+ }
@@ -1,14 +1,71 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.build = void 0;
3
+ exports.handleBuildErrors = exports.build = void 0;
4
4
  const dataconnectEmulator_1 = require("../emulator/dataconnectEmulator");
5
5
  const error_1 = require("../error");
6
+ const prompt_1 = require("../prompt");
7
+ const utils = require("../utils");
6
8
  const graphqlError_1 = require("./graphqlError");
7
- async function build(options, configDir) {
8
- const buildResult = await dataconnectEmulator_1.DataConnectEmulator.build({ configDir });
9
+ const auth_1 = require("../auth");
10
+ async function build(options, configDir, dryRun) {
11
+ const account = (0, auth_1.getProjectDefaultAccount)(options.projectRoot);
12
+ const args = { configDir, account };
13
+ if (options.projectId) {
14
+ args.projectId = options.projectId;
15
+ }
16
+ const buildResult = await dataconnectEmulator_1.DataConnectEmulator.build(args);
9
17
  if (buildResult?.errors?.length) {
10
- throw new error_1.FirebaseError(`There are errors in your schema and connector files:\n${buildResult.errors.map(graphqlError_1.prettify).join("\n")}`);
18
+ await handleBuildErrors(buildResult.errors, options.nonInteractive, options.force, dryRun);
11
19
  }
12
20
  return buildResult?.metadata ?? {};
13
21
  }
14
22
  exports.build = build;
23
+ async function handleBuildErrors(errors, nonInteractive, force, dryRun) {
24
+ if (errors.filter((w) => !w.extensions?.warningLevel).length) {
25
+ throw new error_1.FirebaseError(`There are errors in your schema and connector files:\n${errors.map(graphqlError_1.prettify).join("\n")}`);
26
+ }
27
+ const requiredForces = errors.filter((w) => w.extensions?.warningLevel === "REQUIRE_FORCE");
28
+ if (requiredForces.length && !force) {
29
+ utils.logLabeledError("dataconnect", `There are changes in your schema or connectors that will result in broken behavior:\n` +
30
+ (0, graphqlError_1.prettifyTable)(requiredForces));
31
+ throw new error_1.FirebaseError("Rerun this command with --force to deploy these changes.");
32
+ }
33
+ const interactiveAcks = errors.filter((w) => w.extensions?.warningLevel === "INTERACTIVE_ACK");
34
+ const requiredAcks = errors.filter((w) => w.extensions?.warningLevel === "REQUIRE_ACK");
35
+ const choices = [
36
+ { name: "Acknowledge all changes and proceed", value: "proceed" },
37
+ { name: "Reject changes and abort", value: "abort" },
38
+ ];
39
+ if (requiredAcks.length) {
40
+ utils.logLabeledWarning("dataconnect", `There are changes in your schema or connectors that may break your existing applications or introduce operations that are insecure. These changes require explicit acknowledgement to proceed. You may either reject the changes and update your sources with the suggested workaround(s), if any, or acknowledge these changes and proceed with the deployment:\n` +
41
+ (0, graphqlError_1.prettifyTable)(requiredAcks));
42
+ if (nonInteractive && !force) {
43
+ throw new error_1.FirebaseError("Explicit acknowledgement required for breaking schema or connector changes and new insecure operations. Rerun this command with --force to deploy these changes.");
44
+ }
45
+ else if (!nonInteractive && !force && !dryRun) {
46
+ const result = await (0, prompt_1.select)({
47
+ message: "Would you like to proceed with these changes?",
48
+ choices,
49
+ default: "abort",
50
+ });
51
+ if (result === "abort") {
52
+ throw new error_1.FirebaseError(`Deployment aborted.`);
53
+ }
54
+ }
55
+ }
56
+ if (interactiveAcks.length) {
57
+ utils.logLabeledWarning("dataconnect", `There are existing insecure operations or changes in your schema or connectors that may cause unexpected behavior in your existing applications:\n` +
58
+ (0, graphqlError_1.prettifyTable)(interactiveAcks));
59
+ if (!nonInteractive && !force && !dryRun) {
60
+ const result = await (0, prompt_1.select)({
61
+ message: "Would you like to proceed with these changes?",
62
+ choices,
63
+ default: "proceed",
64
+ });
65
+ if (result === "abort") {
66
+ throw new error_1.FirebaseError(`Deployment aborted.`);
67
+ }
68
+ }
69
+ }
70
+ }
71
+ exports.handleBuildErrors = handleBuildErrors;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.upsertConnector = exports.listConnectors = exports.deleteConnector = exports.getConnector = exports.deleteSchema = exports.upsertSchema = exports.getSchema = exports.deleteServiceAndChildResources = exports.createService = exports.listAllServices = exports.getService = exports.listLocations = void 0;
3
+ exports.upsertConnector = exports.listConnectors = exports.deleteConnector = exports.getConnector = exports.deleteSchema = exports.upsertSchema = exports.listSchemas = exports.getSchema = exports.deleteService = exports.createService = exports.listAllServices = exports.getService = exports.listLocations = void 0;
4
4
  const api_1 = require("../api");
5
5
  const apiv2_1 = require("../apiv2");
6
6
  const operationPoller = require("../operation-poller");
7
7
  const types = require("./types");
8
- const DATACONNECT_API_VERSION = "v1beta";
8
+ const DATACONNECT_API_VERSION = "v1";
9
9
  const PAGE_SIZE_MAX = 100;
10
10
  const dataconnectClient = () => new apiv2_1.Client({
11
11
  urlPrefix: (0, api_1.dataconnectOrigin)(),
@@ -44,7 +44,9 @@ async function createService(projectId, locationId, serviceId) {
44
44
  }
45
45
  exports.createService = createService;
46
46
  async function deleteService(serviceName) {
47
- const op = await dataconnectClient().delete(serviceName);
47
+ const op = await dataconnectClient().delete(serviceName, {
48
+ queryParams: { force: "true" },
49
+ });
48
50
  const pollRes = await operationPoller.pollOperation({
49
51
  apiOrigin: (0, api_1.dataconnectOrigin)(),
50
52
  apiVersion: DATACONNECT_API_VERSION,
@@ -52,20 +54,7 @@ async function deleteService(serviceName) {
52
54
  });
53
55
  return pollRes;
54
56
  }
55
- async function deleteServiceAndChildResources(serviceName) {
56
- const connectors = await listConnectors(serviceName);
57
- await Promise.all(connectors.map(async (c) => deleteConnector(c.name)));
58
- try {
59
- await deleteSchema(serviceName);
60
- }
61
- catch (err) {
62
- if (err.status !== 404) {
63
- throw err;
64
- }
65
- }
66
- await deleteService(serviceName);
67
- }
68
- exports.deleteServiceAndChildResources = deleteServiceAndChildResources;
57
+ exports.deleteService = deleteService;
69
58
  async function getSchema(serviceName) {
70
59
  try {
71
60
  const res = await dataconnectClient().get(`${serviceName}/schemas/${types.SCHEMA_ID}`);
@@ -79,6 +68,25 @@ async function getSchema(serviceName) {
79
68
  }
80
69
  }
81
70
  exports.getSchema = getSchema;
71
+ async function listSchemas(serviceName, fields = []) {
72
+ const schemas = [];
73
+ const getNextPage = async (pageToken = "") => {
74
+ const res = await dataconnectClient().get(`${serviceName}/schemas`, {
75
+ queryParams: {
76
+ pageSize: PAGE_SIZE_MAX,
77
+ pageToken,
78
+ fields: fields.join(","),
79
+ },
80
+ });
81
+ schemas.push(...(res.body.schemas || []));
82
+ if (res.body.nextPageToken) {
83
+ await getNextPage(res.body.nextPageToken);
84
+ }
85
+ };
86
+ await getNextPage();
87
+ return schemas;
88
+ }
89
+ exports.listSchemas = listSchemas;
82
90
  async function upsertSchema(schema, validateOnly = false) {
83
91
  const op = await dataconnectClient().patch(`${schema.name}`, schema, {
84
92
  queryParams: {
@@ -93,6 +101,7 @@ async function upsertSchema(schema, validateOnly = false) {
93
101
  apiOrigin: (0, api_1.dataconnectOrigin)(),
94
102
  apiVersion: DATACONNECT_API_VERSION,
95
103
  operationResourceName: op.body.name,
104
+ masterTimeout: 120000,
96
105
  });
97
106
  }
98
107
  exports.upsertSchema = upsertSchema;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.callCloudAICompanion = exports.cloudAICompationClient = void 0;
4
+ const apiv2_1 = require("../apiv2");
5
+ const api_1 = require("../api");
6
+ const CLOUD_AI_COMPANION_VERSION = "v1";
7
+ const CLIENT_CONTEXT_NAME_IDENTIFIER = "firebase_vscode";
8
+ const FIREBASE_CHAT_REQUEST_CONTEXT_TYPE_NAME = "type.googleapis.com/google.cloud.cloudaicompanion.v1main.FirebaseChatRequestContext";
9
+ const FDC_SCHEMA_EXPERIENCE_CONTEXT = "/appeco/firebase/fdc-schema-generator";
10
+ const FDC_OPERATION_EXPERIENCE_CONTEXT = "/appeco/firebase/fdc-query-generator";
11
+ const USER_AUTHOR = "USER";
12
+ function cloudAICompationClient() {
13
+ return new apiv2_1.Client({
14
+ urlPrefix: (0, api_1.cloudAiCompanionOrigin)(),
15
+ apiVersion: CLOUD_AI_COMPANION_VERSION,
16
+ auth: true,
17
+ });
18
+ }
19
+ exports.cloudAICompationClient = cloudAICompationClient;
20
+ async function callCloudAICompanion(client, vscodeRequest, type) {
21
+ const request = buildRequest(vscodeRequest, type);
22
+ const { projectId } = getServiceParts(vscodeRequest.servicePath);
23
+ const instance = toChatResourceName(projectId);
24
+ try {
25
+ const res = await client.post(`${instance}:completeTask`, request);
26
+ return res.body;
27
+ }
28
+ catch (error) {
29
+ return { output: { messages: [] }, error: error };
30
+ }
31
+ }
32
+ exports.callCloudAICompanion = callCloudAICompanion;
33
+ function buildRequest({ servicePath, naturalLanguageQuery, chatHistory }, type) {
34
+ const { serviceId } = getServiceParts(servicePath);
35
+ const input = {
36
+ messages: [
37
+ ...chatHistory,
38
+ {
39
+ author: USER_AUTHOR,
40
+ content: naturalLanguageQuery,
41
+ },
42
+ ],
43
+ };
44
+ const clientContext = {
45
+ name: CLIENT_CONTEXT_NAME_IDENTIFIER,
46
+ additionalContext: {
47
+ "@type": FIREBASE_CHAT_REQUEST_CONTEXT_TYPE_NAME,
48
+ fdcInfo: {
49
+ serviceId,
50
+ fdcServiceName: servicePath,
51
+ requiresQuery: true,
52
+ },
53
+ },
54
+ };
55
+ return {
56
+ input,
57
+ clientContext,
58
+ experienceContext: {
59
+ experience: type === "schema" ? FDC_SCHEMA_EXPERIENCE_CONTEXT : FDC_OPERATION_EXPERIENCE_CONTEXT,
60
+ },
61
+ };
62
+ }
63
+ function toChatResourceName(projectId) {
64
+ return `projects/${projectId}/locations/global/instances/default`;
65
+ }
66
+ function getServiceParts(name) {
67
+ const match = name.match(/projects\/([^/]*)\/locations\/([^/]*)\/services\/([^/]*)/);
68
+ if (!match) {
69
+ throw new Error(`Invalid service name: ${name}`);
70
+ }
71
+ return { projectId: match[1], locationId: match[2], serviceId: match[3] };
72
+ }