firebase-tools-with-isolate 14.10.1 → 14.16.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 (236) hide show
  1. package/lib/api.js +5 -1
  2. package/lib/apphosting/backend.js +40 -15
  3. package/lib/apptesting/ensureProjectConfigured.js +56 -0
  4. package/lib/apptesting/invokeTests.js +40 -0
  5. package/lib/apptesting/parseTestFiles.js +75 -0
  6. package/lib/apptesting/types.js +18 -0
  7. package/lib/auth.js +37 -2
  8. package/lib/command.js +24 -5
  9. package/lib/commands/apphosting-backends-create.js +8 -5
  10. package/lib/commands/apptesting-execute.js +101 -0
  11. package/lib/commands/dataconnect-sdk-generate.js +28 -26
  12. package/lib/commands/dataconnect-services-list.js +1 -1
  13. package/lib/commands/dataconnect-sql-diff.js +2 -2
  14. package/lib/commands/dataconnect-sql-grant.js +7 -2
  15. package/lib/commands/dataconnect-sql-migrate.js +2 -2
  16. package/lib/commands/dataconnect-sql-setup.js +3 -5
  17. package/lib/commands/dataconnect-sql-shell.js +2 -2
  18. package/lib/commands/ext-export.js +1 -1
  19. package/lib/commands/firestore-bulkdelete.js +73 -0
  20. package/lib/commands/firestore-databases-create.js +11 -0
  21. package/lib/commands/firestore-operations-cancel.js +44 -0
  22. package/lib/commands/firestore-operations-describe.js +29 -0
  23. package/lib/commands/firestore-operations-list.js +29 -0
  24. package/lib/commands/firestore-utils.js +15 -0
  25. package/lib/commands/functions-config-clone.js +2 -0
  26. package/lib/commands/functions-config-export.js +5 -2
  27. package/lib/commands/functions-config-get.js +2 -0
  28. package/lib/commands/functions-config-set.js +2 -0
  29. package/lib/commands/functions-config-unset.js +2 -0
  30. package/lib/commands/index.js +9 -0
  31. package/lib/commands/init.js +24 -4
  32. package/lib/commands/internaltesting-functions-discover.js +20 -5
  33. package/lib/commands/login.js +13 -9
  34. package/lib/commands/use.js +5 -0
  35. package/lib/config.js +16 -4
  36. package/lib/crashlytics/addNote.js +27 -0
  37. package/lib/crashlytics/buildToolsJarHelper.js +1 -2
  38. package/lib/crashlytics/deleteNote.js +23 -0
  39. package/lib/crashlytics/getIssueDetails.js +26 -0
  40. package/lib/crashlytics/getSampleCrash.js +34 -0
  41. package/lib/crashlytics/listNotes.js +29 -0
  42. package/lib/crashlytics/listTopDevices.js +33 -0
  43. package/lib/crashlytics/listTopIssues.js +8 -23
  44. package/lib/crashlytics/listTopOperatingSystems.js +32 -0
  45. package/lib/crashlytics/listTopVersions.js +32 -0
  46. package/lib/crashlytics/updateIssue.js +35 -0
  47. package/lib/crashlytics/utils.js +38 -0
  48. package/lib/dataconnect/appFinder.js +102 -0
  49. package/lib/dataconnect/client.js +23 -15
  50. package/lib/dataconnect/ensureApis.js +6 -9
  51. package/lib/dataconnect/errors.js +7 -1
  52. package/lib/dataconnect/freeTrial.js +16 -38
  53. package/lib/dataconnect/load.js +105 -6
  54. package/lib/dataconnect/provisionCloudSql.js +67 -70
  55. package/lib/dataconnect/schemaMigration.js +219 -169
  56. package/lib/deploy/dataconnect/deploy.js +7 -9
  57. package/lib/deploy/dataconnect/prepare.js +7 -12
  58. package/lib/deploy/dataconnect/release.js +43 -31
  59. package/lib/deploy/firestore/deploy.js +10 -0
  60. package/lib/deploy/functions/backend.js +7 -1
  61. package/lib/deploy/functions/build.js +28 -14
  62. package/lib/deploy/functions/deploy.js +3 -2
  63. package/lib/deploy/functions/ensure.js +1 -1
  64. package/lib/deploy/functions/functionsDeployHelper.js +8 -1
  65. package/lib/deploy/functions/params.js +4 -0
  66. package/lib/deploy/functions/prepare.js +25 -13
  67. package/lib/deploy/functions/pricing.js +12 -5
  68. package/lib/deploy/functions/release/fabricator.js +25 -3
  69. package/lib/deploy/functions/release/reporter.js +1 -0
  70. package/lib/deploy/functions/runtimes/discovery/index.js +52 -5
  71. package/lib/deploy/functions/runtimes/node/index.js +83 -51
  72. package/lib/emulator/auth/operations.js +10 -1
  73. package/lib/emulator/commandUtils.js +7 -1
  74. package/lib/emulator/controller.js +22 -34
  75. package/lib/emulator/dataconnectEmulator.js +27 -24
  76. package/lib/emulator/downloadableEmulatorInfo.json +18 -18
  77. package/lib/emulator/env.js +2 -1
  78. package/lib/emulator/functionsEmulator.js +12 -2
  79. package/lib/emulator/hub.js +11 -8
  80. package/lib/emulator/tasksEmulator.js +1 -1
  81. package/lib/emulator/ui.js +3 -1
  82. package/lib/env.js +18 -0
  83. package/lib/experiments.js +20 -0
  84. package/lib/extensions/extensionsHelper.js +4 -15
  85. package/lib/extensions/runtimes/common.js +3 -2
  86. package/lib/extensions/utils.js +1 -12
  87. package/lib/firestore/api-sort.js +96 -3
  88. package/lib/firestore/api-types.js +20 -1
  89. package/lib/firestore/api.js +144 -15
  90. package/lib/firestore/pretty-print.js +35 -1
  91. package/lib/firestore/validator.js +1 -1
  92. package/lib/functional.js +7 -1
  93. package/lib/functions/deprecationWarnings.js +21 -0
  94. package/lib/functions/env.js +31 -16
  95. package/lib/functions/projectConfig.js +87 -8
  96. package/lib/functions/secrets.js +3 -0
  97. package/lib/gcp/cloudfunctions.js +1 -6
  98. package/lib/gcp/cloudfunctionsv2.js +3 -39
  99. package/lib/gcp/cloudscheduler.js +1 -1
  100. package/lib/gcp/cloudsql/cloudsqladmin.js +4 -16
  101. package/lib/gcp/cloudsql/connect.js +4 -3
  102. package/lib/gcp/cloudsql/permissionsSetup.js +23 -16
  103. package/lib/gcp/k8s.js +32 -0
  104. package/lib/gcp/runv2.js +181 -0
  105. package/lib/gemini/fdcExperience.js +5 -3
  106. package/lib/init/features/aitools/claude.js +43 -0
  107. package/lib/init/features/aitools/cursor.js +61 -0
  108. package/lib/init/features/aitools/gemini.js +58 -0
  109. package/lib/init/features/aitools/index.js +28 -0
  110. package/lib/init/features/aitools/promptUpdater.js +111 -0
  111. package/lib/init/features/aitools/studio.js +17 -0
  112. package/lib/init/features/aitools/types.js +2 -0
  113. package/lib/init/features/aitools.js +83 -0
  114. package/lib/init/features/apptesting/index.js +34 -0
  115. package/lib/init/features/dataconnect/create_app.js +53 -0
  116. package/lib/init/features/dataconnect/index.js +280 -186
  117. package/lib/init/features/dataconnect/sdk.js +232 -144
  118. package/lib/init/features/index.js +8 -3
  119. package/lib/init/features/project.js +4 -0
  120. package/lib/init/index.js +18 -2
  121. package/lib/management/apps.js +3 -3
  122. package/lib/management/studio.js +120 -0
  123. package/lib/mcp/errors.js +5 -7
  124. package/lib/mcp/index.js +179 -61
  125. package/lib/mcp/logging-transport.js +23 -0
  126. package/lib/mcp/prompt.js +10 -0
  127. package/lib/mcp/prompts/core/deploy.js +101 -0
  128. package/lib/mcp/prompts/core/index.js +5 -0
  129. package/lib/mcp/prompts/crashlytics/connect.js +114 -0
  130. package/lib/mcp/prompts/crashlytics/index.js +5 -0
  131. package/lib/mcp/prompts/dataconnect/index.js +9 -0
  132. package/lib/mcp/prompts/dataconnect/schema.js +67 -0
  133. package/lib/mcp/prompts/index.js +47 -0
  134. package/lib/mcp/tools/apphosting/fetch_logs.js +22 -22
  135. package/lib/mcp/tools/apphosting/list_backends.js +10 -10
  136. package/lib/mcp/tools/auth/disable_user.js +7 -7
  137. package/lib/mcp/tools/auth/get_user.js +13 -6
  138. package/lib/mcp/tools/auth/index.js +10 -10
  139. package/lib/mcp/tools/auth/list_users.js +6 -6
  140. package/lib/mcp/tools/auth/set_claims.js +7 -7
  141. package/lib/mcp/tools/auth/set_sms_region_policy.js +6 -6
  142. package/lib/mcp/tools/core/consult_assistant.js +13 -8
  143. package/lib/mcp/tools/core/create_android_sha.js +9 -9
  144. package/lib/mcp/tools/core/create_app.js +7 -7
  145. package/lib/mcp/tools/core/create_project.js +13 -13
  146. package/lib/mcp/tools/core/get_admin_sdk_config.js +7 -7
  147. package/lib/mcp/tools/core/get_environment.js +8 -8
  148. package/lib/mcp/tools/core/get_project.js +5 -5
  149. package/lib/mcp/tools/core/get_sdk_config.js +19 -9
  150. package/lib/mcp/tools/core/index.js +28 -24
  151. package/lib/mcp/tools/core/init.js +39 -16
  152. package/lib/mcp/tools/core/list_apps.js +6 -6
  153. package/lib/mcp/tools/core/list_projects.js +6 -6
  154. package/lib/mcp/tools/core/login.js +46 -0
  155. package/lib/mcp/tools/core/logout.js +62 -0
  156. package/lib/mcp/tools/core/update_environment.js +10 -10
  157. package/lib/mcp/tools/crashlytics/add_note.js +32 -0
  158. package/lib/mcp/tools/crashlytics/constants.js +11 -0
  159. package/lib/mcp/tools/crashlytics/delete_note.js +35 -0
  160. package/lib/mcp/tools/crashlytics/get_issue_details.js +31 -0
  161. package/lib/mcp/tools/crashlytics/get_sample_crash.js +43 -0
  162. package/lib/mcp/tools/crashlytics/index.js +22 -2
  163. package/lib/mcp/tools/crashlytics/list_notes.js +37 -0
  164. package/lib/mcp/tools/crashlytics/list_top_devices.js +33 -0
  165. package/lib/mcp/tools/crashlytics/list_top_issues.js +12 -13
  166. package/lib/mcp/tools/crashlytics/list_top_operating_systems.js +33 -0
  167. package/lib/mcp/tools/crashlytics/list_top_versions.js +33 -0
  168. package/lib/mcp/tools/crashlytics/update_issue.js +37 -0
  169. package/lib/mcp/tools/database/get_data.js +49 -0
  170. package/lib/mcp/tools/database/get_rules.js +39 -0
  171. package/lib/mcp/tools/database/index.js +8 -0
  172. package/lib/mcp/tools/database/set_data.js +57 -0
  173. package/lib/mcp/tools/database/validate_rules.js +41 -0
  174. package/lib/mcp/tools/dataconnect/compile.js +43 -0
  175. package/lib/mcp/tools/dataconnect/execute.js +71 -0
  176. package/lib/mcp/tools/dataconnect/generate_operation.js +8 -8
  177. package/lib/mcp/tools/dataconnect/generate_schema.js +6 -6
  178. package/lib/mcp/tools/dataconnect/index.js +10 -18
  179. package/lib/mcp/tools/dataconnect/list_services.js +107 -11
  180. package/lib/mcp/tools/firestore/delete_document.js +13 -13
  181. package/lib/mcp/tools/firestore/get_documents.js +13 -13
  182. package/lib/mcp/tools/firestore/list_collections.js +7 -10
  183. package/lib/mcp/tools/firestore/query_collection.js +13 -13
  184. package/lib/mcp/tools/index.js +24 -18
  185. package/lib/mcp/tools/messaging/index.js +2 -2
  186. package/lib/mcp/tools/messaging/send_message.js +7 -7
  187. package/lib/mcp/tools/remoteconfig/get_template.js +5 -5
  188. package/lib/mcp/tools/remoteconfig/index.js +4 -4
  189. package/lib/mcp/tools/remoteconfig/publish_template.js +7 -7
  190. package/lib/mcp/tools/remoteconfig/rollback_template.js +6 -6
  191. package/lib/mcp/tools/rules/get_rules.js +8 -8
  192. package/lib/mcp/tools/rules/validate_rules.js +10 -10
  193. package/lib/mcp/tools/storage/get_download_url.js +8 -8
  194. package/lib/mcp/tools/storage/get_rules.js +8 -8
  195. package/lib/mcp/types.js +2 -0
  196. package/lib/mcp/util/dataconnect/compile.js +20 -0
  197. package/lib/mcp/util/dataconnect/content.js +655 -0
  198. package/lib/mcp/util/dataconnect/emulator.js +16 -0
  199. package/lib/mcp/util.js +5 -18
  200. package/lib/requireAuth.js +14 -4
  201. package/lib/rtdb.js +10 -6
  202. package/lib/scopes.js +2 -1
  203. package/lib/serve/functions.js +4 -3
  204. package/lib/timeout.js +21 -0
  205. package/lib/track.js +18 -1
  206. package/lib/unzip.js +13 -0
  207. package/lib/utils.js +76 -2
  208. package/package.json +5 -3
  209. package/prompts/FIREBASE.md +121 -0
  210. package/prompts/FIREBASE_FUNCTIONS.md +221 -0
  211. package/schema/apptesting-yaml.json +64 -0
  212. package/schema/firebase-config.json +163 -53
  213. package/templates/init/aitools/cursor-rules-header.txt +8 -0
  214. package/templates/init/aitools/gemini-extension.json +11 -0
  215. package/templates/init/apptesting/smoke_test.yaml +6 -0
  216. package/templates/init/dataconnect/connector.yaml +0 -16
  217. package/templates/init/dataconnect/dataconnect.yaml +2 -1
  218. package/templates/init/dataconnect/mutations.gql +29 -29
  219. package/templates/init/dataconnect/queries.gql +73 -73
  220. package/templates/init/dataconnect/schema.gql +48 -48
  221. package/templates/init/firestore/firestore.indexes.json +26 -1
  222. package/lib/dataconnect/fileUtils.js +0 -168
  223. package/lib/emulator/adminSdkConfig.test.js +0 -16
  224. package/lib/extensions/resolveSource.js +0 -23
  225. package/lib/firestore/api-sort.test.js +0 -74
  226. package/lib/firestore/backupUtils.test.js +0 -18
  227. package/lib/firestore/pretty-print.test.js +0 -61
  228. package/lib/firestore/util.test.js +0 -42
  229. package/lib/mcp/tools/dataconnect/emulator.js +0 -16
  230. package/lib/mcp/tools/dataconnect/execute_graphql.js +0 -48
  231. package/lib/mcp/tools/dataconnect/execute_graphql_read.js +0 -48
  232. package/lib/mcp/tools/dataconnect/execute_mutation.js +0 -62
  233. package/lib/mcp/tools/dataconnect/execute_query.js +0 -62
  234. package/lib/mcp/tools/dataconnect/get_connector.js +0 -31
  235. package/lib/mcp/tools/dataconnect/get_schema.js +0 -31
  236. /package/lib/mcp/{tools → util}/dataconnect/converter.js +0 -0
@@ -1,78 +1,78 @@
1
- # # Example queries for a simple movie app.
1
+ # Example queries for a simple movie app.
2
2
 
3
- # # @auth() directives control who can call each operation.
4
- # # Anyone should be able to list all movies, so the auth level is set to PUBLIC
5
- # query ListMovies @auth(level: PUBLIC) {
6
- # movies {
7
- # id
8
- # title
9
- # imageUrl
10
- # genre
11
- # }
12
- # }
3
+ # @auth() directives control who can call each operation.
4
+ # Anyone should be able to list all movies, so the auth level is set to PUBLIC
5
+ query ListMovies @auth(level: PUBLIC, insecureReason: "Anyone can list all movies.") {
6
+ movies {
7
+ id
8
+ title
9
+ imageUrl
10
+ genre
11
+ }
12
+ }
13
13
 
14
- # # List all users, only admins should be able to list all users, so we use NO_ACCESS
15
- # query ListUsers @auth(level: NO_ACCESS) {
16
- # users {
17
- # id
18
- # username
19
- # }
20
- # }
14
+ # List all users, only admins should be able to list all users, so we use NO_ACCESS
15
+ query ListUsers @auth(level: NO_ACCESS) {
16
+ users {
17
+ id
18
+ username
19
+ }
20
+ }
21
21
 
22
- # # Logged in users can list all their reviews and movie titles associated with the review
23
- # # Since the query uses the uid of the current authenticated user, we set auth level to USER
24
- # query ListUserReviews @auth(level: USER) {
25
- # user(key: { id_expr: "auth.uid" }) {
26
- # id
27
- # username
28
- # # <field>_on_<foreign_key_field> makes it easy to grab info from another table
29
- # # Here, we use it to grab all the reviews written by the user.
30
- # reviews: reviews_on_user {
31
- # rating
32
- # reviewDate
33
- # reviewText
34
- # movie {
35
- # id
36
- # title
37
- # }
38
- # }
39
- # }
40
- # }
22
+ # Logged in users can list all their reviews and movie titles associated with the review
23
+ # Since the query uses the uid of the current authenticated user, we set auth level to USER
24
+ query ListUserReviews @auth(level: USER) {
25
+ user(key: { id_expr: "auth.uid" }) {
26
+ id
27
+ username
28
+ # <field>_on_<foreign_key_field> makes it easy to grab info from another table
29
+ # Here, we use it to grab all the reviews written by the user.
30
+ reviews: reviews_on_user {
31
+ rating
32
+ reviewDate
33
+ reviewText
34
+ movie {
35
+ id
36
+ title
37
+ }
38
+ }
39
+ }
40
+ }
41
41
 
42
- # # Get movie by id
43
- # query GetMovieById($id: UUID!) @auth(level: PUBLIC) {
44
- # movie(id: $id) {
45
- # id
46
- # title
47
- # imageUrl
48
- # genre
49
- # metadata: movieMetadata_on_movie {
50
- # rating
51
- # releaseYear
52
- # description
53
- # }
54
- # reviews: reviews_on_movie {
55
- # reviewText
56
- # reviewDate
57
- # rating
58
- # user {
59
- # id
60
- # username
61
- # }
62
- # }
63
- # }
64
- # }
42
+ # Get movie by id
43
+ query GetMovieById($id: UUID!) @auth(level: PUBLIC, insecureReason: "Anyone can get a movie by id.") {
44
+ movie(id: $id) {
45
+ id
46
+ title
47
+ imageUrl
48
+ genre
49
+ metadata: movieMetadata_on_movie {
50
+ rating
51
+ releaseYear
52
+ description
53
+ }
54
+ reviews: reviews_on_movie {
55
+ reviewText
56
+ reviewDate
57
+ rating
58
+ user {
59
+ id
60
+ username
61
+ }
62
+ }
63
+ }
64
+ }
65
65
 
66
- # # Search for movies, actors, and reviews
67
- # query SearchMovie($titleInput: String, $genre: String) @auth(level: PUBLIC) {
68
- # movies(
69
- # where: {
70
- # _and: [{ genre: { eq: $genre } }, { title: { contains: $titleInput } }]
71
- # }
72
- # ) {
73
- # id
74
- # title
75
- # genre
76
- # imageUrl
77
- # }
78
- # }
66
+ # Search for movies, actors, and reviews
67
+ query SearchMovie($titleInput: String, $genre: String) @auth(level: PUBLIC, insecureReason: "Anyone can search for movies.") {
68
+ movies(
69
+ where: {
70
+ _and: [{ genre: { eq: $genre } }, { title: { contains: $titleInput } }]
71
+ }
72
+ ) {
73
+ id
74
+ title
75
+ genre
76
+ imageUrl
77
+ }
78
+ }
@@ -1,52 +1,52 @@
1
- # # Example schema for simple movie review app
1
+ # Example schema for simple movie review app
2
2
 
3
- # # User table is keyed by Firebase Auth UID.
4
- # type User @table {
5
- # # `@default(expr: "auth.uid")` sets it to Firebase Auth UID during insert and upsert.
6
- # id: String! @default(expr: "auth.uid")
7
- # username: String! @col(dataType: "varchar(50)")
8
- # # The `user: User!` field in the Review table generates the following one-to-many query field.
9
- # # reviews_on_user: [Review!]!
10
- # # The `Review` join table the following many-to-many query field.
11
- # # movies_via_Review: [Movie!]!
12
- # }
3
+ # User table is keyed by Firebase Auth UID.
4
+ type User @table {
5
+ # `@default(expr: "auth.uid")` sets it to Firebase Auth UID during insert and upsert.
6
+ id: String! @default(expr: "auth.uid")
7
+ username: String! @col(dataType: "varchar(50)")
8
+ # The `user: User!` field in the Review table generates the following one-to-many query field.
9
+ # reviews_on_user: [Review!]!
10
+ # The `Review` join table the following many-to-many query field.
11
+ # movies_via_Review: [Movie!]!
12
+ }
13
13
 
14
- # # Movie is keyed by a randomly generated UUID.
15
- # type Movie @table {
16
- # # If you do not pass a 'key' to `@table`, Data Connect automatically adds the following 'id' column.
17
- # # Feel free to uncomment and customize it.
18
- # # id: UUID! @default(expr: "uuidV4()")
19
- # title: String!
20
- # imageUrl: String!
21
- # genre: String
22
- # }
14
+ # Movie is keyed by a randomly generated UUID.
15
+ type Movie @table {
16
+ # If you do not pass a 'key' to `@table`, Data Connect automatically adds the following 'id' column.
17
+ # Feel free to uncomment and customize it.
18
+ # id: UUID! @default(expr: "uuidV4()")
19
+ title: String!
20
+ imageUrl: String!
21
+ genre: String
22
+ }
23
23
 
24
- # # MovieMetadata is a metadata attached to a Movie.
25
- # # Movie <-> MovieMetadata is a one-to-one relationship
26
- # type MovieMetadata @table {
27
- # # @unique ensures each Movie can only one MovieMetadata.
28
- # movie: Movie! @unique
29
- # # The movie field adds the following foreign key field. Feel free to uncomment and customize it.
30
- # # movieId: UUID!
31
- # rating: Float
32
- # releaseYear: Int
33
- # description: String
34
- # }
24
+ # MovieMetadata is a metadata attached to a Movie.
25
+ # Movie <-> MovieMetadata is a one-to-one relationship
26
+ type MovieMetadata @table {
27
+ # @unique ensures each Movie can only one MovieMetadata.
28
+ movie: Movie! @unique
29
+ # The movie field adds the following foreign key field. Feel free to uncomment and customize it.
30
+ # movieId: UUID!
31
+ rating: Float
32
+ releaseYear: Int
33
+ description: String
34
+ }
35
35
 
36
- # # Reviews is a join table between User and Movie.
37
- # # It has a composite primary keys `userUid` and `movieId`.
38
- # # A user can leave reviews for many movies. A movie can have reviews from many users.
39
- # # User <-> Review is a one-to-many relationship
40
- # # Movie <-> Review is a one-to-many relationship
41
- # # Movie <-> User is a many-to-many relationship
42
- # type Review @table(name: "Reviews", key: ["movie", "user"]) {
43
- # user: User!
44
- # # The user field adds the following foreign key field. Feel free to uncomment and customize it.
45
- # # userUid: String!
46
- # movie: Movie!
47
- # # The movie field adds the following foreign key field. Feel free to uncomment and customize it.
48
- # # movieId: UUID!
49
- # rating: Int
50
- # reviewText: String
51
- # reviewDate: Date! @default(expr: "request.time")
52
- # }
36
+ # Reviews is a join table between User and Movie.
37
+ # It has a composite primary keys `userUid` and `movieId`.
38
+ # A user can leave reviews for many movies. A movie can have reviews from many users.
39
+ # User <-> Review is a one-to-many relationship
40
+ # Movie <-> Review is a one-to-many relationship
41
+ # Movie <-> User is a many-to-many relationship
42
+ type Review @table(name: "Reviews", key: ["movie", "user"]) {
43
+ user: User!
44
+ # The user field adds the following foreign key field. Feel free to uncomment and customize it.
45
+ # userUid: String!
46
+ movie: Movie!
47
+ # The movie field adds the following foreign key field. Feel free to uncomment and customize it.
48
+ # movieId: UUID!
49
+ rating: Int
50
+ reviewText: String
51
+ reviewDate: Date! @default(expr: "request.time")
52
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
- // Example:
2
+ // Example (Standard Edition):
3
3
  //
4
4
  // "indexes": [
5
5
  // {
@@ -21,6 +21,31 @@
21
21
  // },
22
22
  // ]
23
23
  // ]
24
+ //
25
+ // Example (Enterprise Edition):
26
+ //
27
+ // "indexes": [
28
+ // {
29
+ // "collectionGroup": "reviews",
30
+ // "queryScope": "COLLECTION_GROUP",
31
+ // "apiScope": "MONGODB_COMPATIBLE_API",
32
+ // "density": "DENSE",
33
+ // "multikey": false,
34
+ // "fields": [
35
+ // { "fieldPath": "baz", "mode": "ASCENDING" }
36
+ // ]
37
+ // },
38
+ // {
39
+ // "collectionGroup": "items",
40
+ // "queryScope": "COLLECTION_GROUP",
41
+ // "apiScope": "MONGODB_COMPATIBLE_API",
42
+ // "density": "SPARSE_ANY",
43
+ // "multikey": true,
44
+ // "fields": [
45
+ // { "fieldPath": "baz", "mode": "ASCENDING" }
46
+ // ]
47
+ // },
48
+ // ]
24
49
  "indexes": [],
25
50
  "fieldOverrides": []
26
51
  }
@@ -1,168 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFrameworksFromPackageJson = exports.frameworksMap = exports.SUPPORTED_FRAMEWORKS = exports.resolvePackageJson = exports.getPlatformFromFolder = exports.pickService = exports.readGQLFiles = exports.readConnectorYaml = exports.readDataConnectYaml = exports.readFirebaseJson = void 0;
4
- const fs = require("fs-extra");
5
- const path = require("path");
6
- const clc = require("colorette");
7
- const error_1 = require("../error");
8
- const types_1 = require("./types");
9
- const utils_1 = require("../utils");
10
- const load_1 = require("./load");
11
- function readFirebaseJson(config) {
12
- if (!config?.has("dataconnect")) {
13
- return [];
14
- }
15
- const validator = (cfg) => {
16
- if (!cfg["source"]) {
17
- throw new error_1.FirebaseError("Invalid firebase.json: DataConnect requires `source`");
18
- }
19
- return {
20
- source: cfg["source"],
21
- };
22
- };
23
- const configs = config.get("dataconnect");
24
- if (typeof configs === "object" && !Array.isArray(configs)) {
25
- return [validator(configs)];
26
- }
27
- else if (Array.isArray(configs)) {
28
- return configs.map(validator);
29
- }
30
- else {
31
- throw new error_1.FirebaseError("Invalid firebase.json: dataconnect should be of the form { source: string }");
32
- }
33
- }
34
- exports.readFirebaseJson = readFirebaseJson;
35
- async function readDataConnectYaml(sourceDirectory) {
36
- const file = await (0, utils_1.readFileFromDirectory)(sourceDirectory, "dataconnect.yaml");
37
- const dataconnectYaml = await (0, utils_1.wrappedSafeLoad)(file.source);
38
- return validateDataConnectYaml(dataconnectYaml);
39
- }
40
- exports.readDataConnectYaml = readDataConnectYaml;
41
- function validateDataConnectYaml(unvalidated) {
42
- if (!unvalidated["location"]) {
43
- throw new error_1.FirebaseError("Missing required field 'location' in dataconnect.yaml");
44
- }
45
- return unvalidated;
46
- }
47
- async function readConnectorYaml(sourceDirectory) {
48
- const file = await (0, utils_1.readFileFromDirectory)(sourceDirectory, "connector.yaml");
49
- const connectorYaml = await (0, utils_1.wrappedSafeLoad)(file.source);
50
- return validateConnectorYaml(connectorYaml);
51
- }
52
- exports.readConnectorYaml = readConnectorYaml;
53
- function validateConnectorYaml(unvalidated) {
54
- return unvalidated;
55
- }
56
- async function readGQLFiles(sourceDir) {
57
- if (!fs.existsSync(sourceDir)) {
58
- return [];
59
- }
60
- const files = await fs.readdir(sourceDir);
61
- return files
62
- .filter((f) => f.endsWith(".gql") || f.endsWith(".graphql"))
63
- .map((f) => toFile(sourceDir, f));
64
- }
65
- exports.readGQLFiles = readGQLFiles;
66
- function toFile(sourceDir, relPath) {
67
- const fullPath = path.join(sourceDir, relPath);
68
- if (!fs.existsSync(fullPath)) {
69
- throw new error_1.FirebaseError(`file ${fullPath} not found`);
70
- }
71
- const content = fs.readFileSync(fullPath).toString();
72
- return {
73
- path: relPath,
74
- content,
75
- };
76
- }
77
- async function pickService(projectId, config, serviceId) {
78
- const serviceCfgs = readFirebaseJson(config);
79
- let serviceInfo;
80
- if (serviceCfgs.length === 0) {
81
- throw new error_1.FirebaseError("No Data Connect services found in firebase.json." +
82
- `\nYou can run ${clc.bold("firebase init dataconnect")} to add a Data Connect service.`);
83
- }
84
- else if (serviceCfgs.length === 1) {
85
- serviceInfo = await (0, load_1.load)(projectId, config, serviceCfgs[0].source);
86
- if (serviceId && serviceId !== serviceInfo.dataConnectYaml.serviceId) {
87
- throw new error_1.FirebaseError(`No service named ${serviceId} declared in firebase.json. Found ${serviceInfo.dataConnectYaml.serviceId}.` +
88
- `\nYou can run ${clc.bold("firebase init dataconnect")} to add this Data Connect service.`);
89
- }
90
- return serviceInfo;
91
- }
92
- else {
93
- if (!serviceId) {
94
- throw new error_1.FirebaseError("Multiple Data Connect services found in firebase.json. Please specify a service ID to use.");
95
- }
96
- const infos = await Promise.all(serviceCfgs.map((c) => (0, load_1.load)(projectId, config, c.source)));
97
- const maybe = infos.find((i) => i.dataConnectYaml.serviceId === serviceId);
98
- if (!maybe) {
99
- throw new error_1.FirebaseError(`No service named ${serviceId} declared in firebase.json. Found ${infos.map((i) => i.dataConnectYaml.serviceId).join(", ")}.` +
100
- `\nYou can run ${clc.bold("firebase init dataconnect")} to add this Data Connect service.`);
101
- }
102
- return maybe;
103
- }
104
- }
105
- exports.pickService = pickService;
106
- const WEB_INDICATORS = ["package.json", "package-lock.json", "node_modules"];
107
- const IOS_INDICATORS = ["info.plist", "podfile", "package.swift", ".xcodeproj"];
108
- const ANDROID_INDICATORS = ["androidmanifest.xml", "build.gradle", "build.gradle.kts"];
109
- const DART_INDICATORS = ["pubspec.yaml", "pubspec.lock"];
110
- const IOS_POSTFIX_INDICATORS = [".xcworkspace", ".xcodeproj"];
111
- async function getPlatformFromFolder(dirPath) {
112
- const fileNames = await fs.readdir(dirPath);
113
- let hasWeb = false;
114
- let hasAndroid = false;
115
- let hasIOS = false;
116
- let hasDart = false;
117
- for (const fileName of fileNames) {
118
- const cleanedFileName = fileName.toLowerCase();
119
- hasWeb || (hasWeb = WEB_INDICATORS.some((indicator) => indicator === cleanedFileName));
120
- hasAndroid || (hasAndroid = ANDROID_INDICATORS.some((indicator) => indicator === cleanedFileName));
121
- hasIOS || (hasIOS = IOS_INDICATORS.some((indicator) => indicator === cleanedFileName) ||
122
- IOS_POSTFIX_INDICATORS.some((indicator) => cleanedFileName.endsWith(indicator)));
123
- hasDart || (hasDart = DART_INDICATORS.some((indicator) => indicator === cleanedFileName));
124
- }
125
- if (!hasWeb && !hasAndroid && !hasIOS && !hasDart) {
126
- return types_1.Platform.NONE;
127
- }
128
- else if (hasWeb && !hasAndroid && !hasIOS && !hasDart) {
129
- return types_1.Platform.WEB;
130
- }
131
- else if (hasAndroid && !hasWeb && !hasIOS && !hasDart) {
132
- return types_1.Platform.ANDROID;
133
- }
134
- else if (hasIOS && !hasWeb && !hasAndroid && !hasDart) {
135
- return types_1.Platform.IOS;
136
- }
137
- else if (hasDart && !hasWeb && !hasIOS && !hasAndroid) {
138
- return types_1.Platform.FLUTTER;
139
- }
140
- return types_1.Platform.MULTIPLE;
141
- }
142
- exports.getPlatformFromFolder = getPlatformFromFolder;
143
- async function resolvePackageJson(packageJsonPath) {
144
- let validPackageJsonPath = packageJsonPath;
145
- if (!packageJsonPath.endsWith("package.json")) {
146
- validPackageJsonPath = path.join(packageJsonPath, "package.json");
147
- }
148
- validPackageJsonPath = path.resolve(validPackageJsonPath);
149
- try {
150
- return JSON.parse((await fs.readFile(validPackageJsonPath)).toString());
151
- }
152
- catch {
153
- return undefined;
154
- }
155
- }
156
- exports.resolvePackageJson = resolvePackageJson;
157
- exports.SUPPORTED_FRAMEWORKS = ["react", "angular"];
158
- exports.frameworksMap = {
159
- react: ["react", "next"],
160
- angular: ["@angular/core"],
161
- };
162
- function getFrameworksFromPackageJson(packageJson) {
163
- const devDependencies = Object.keys(packageJson.devDependencies ?? {});
164
- const dependencies = Object.keys(packageJson.dependencies ?? {});
165
- const allDeps = Array.from(new Set([...devDependencies, ...dependencies]));
166
- return exports.SUPPORTED_FRAMEWORKS.filter((framework) => exports.frameworksMap[framework].find((dep) => allDeps.includes(dep)));
167
- }
168
- exports.getFrameworksFromPackageJson = getFrameworksFromPackageJson;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chai_1 = require("chai");
4
- const adminSdkConfig_1 = require("./adminSdkConfig");
5
- describe("adminSdkConfig", () => {
6
- describe("getProjectAdminSdkConfigOrCached", () => {
7
- it("should return a fake config for a demo project id", async () => {
8
- const projectId = "demo-project-1234";
9
- await (0, chai_1.expect)((0, adminSdkConfig_1.getProjectAdminSdkConfigOrCached)(projectId)).to.eventually.deep.equal({
10
- projectId: "demo-project-1234",
11
- databaseURL: "https://demo-project-1234.firebaseio.com",
12
- storageBucket: "demo-project-1234.appspot.com",
13
- });
14
- });
15
- });
16
- });
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getExtensionRegistry = void 0;
4
- const apiv2_1 = require("../apiv2");
5
- const api_1 = require("../api");
6
- const EXTENSIONS_REGISTRY_ENDPOINT = "/extensions.json";
7
- async function getExtensionRegistry(onlyFeatured = false) {
8
- const client = new apiv2_1.Client({ urlPrefix: (0, api_1.firebaseExtensionsRegistryOrigin)() });
9
- const res = await client.get(EXTENSIONS_REGISTRY_ENDPOINT);
10
- const extensions = res.body.mods || {};
11
- if (onlyFeatured) {
12
- const featuredList = new Set(res.body.featured?.discover || []);
13
- const filteredExtensions = {};
14
- for (const [name, extension] of Object.entries(extensions)) {
15
- if (featuredList.has(name)) {
16
- filteredExtensions[name] = extension;
17
- }
18
- }
19
- return filteredExtensions;
20
- }
21
- return extensions;
22
- }
23
- exports.getExtensionRegistry = getExtensionRegistry;
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chai_1 = require("chai");
4
- const firestore_1 = require("../gcp/firestore");
5
- const proto_1 = require("../gcp/proto");
6
- const sort = require("./api-sort");
7
- describe("compareApiBackup", () => {
8
- it("should compare backups by location", () => {
9
- const nam5Backup = {
10
- name: "projects/example/locations/nam5/backups/backupid",
11
- };
12
- const usWest1Backup = {
13
- name: "projects/example/locations/us-west1/backups/backupid",
14
- };
15
- (0, chai_1.expect)(sort.compareApiBackup(usWest1Backup, nam5Backup)).to.greaterThanOrEqual(1);
16
- (0, chai_1.expect)(sort.compareApiBackup(nam5Backup, usWest1Backup)).to.lessThanOrEqual(-1);
17
- });
18
- it("should compare backups by snapshotTime (descending) if location is the same", () => {
19
- const earlierBackup = {
20
- name: "projects/example/locations/nam5/backups/backupid",
21
- snapshotTime: "2024-01-01T00:00:00.000000Z",
22
- };
23
- const laterBackup = {
24
- name: "projects/example/locations/nam5/backups/backupid",
25
- snapshotTime: "2024-02-02T00:00:00.000000Z",
26
- };
27
- (0, chai_1.expect)(sort.compareApiBackup(earlierBackup, laterBackup)).to.greaterThanOrEqual(1);
28
- (0, chai_1.expect)(sort.compareApiBackup(laterBackup, earlierBackup)).to.lessThanOrEqual(-1);
29
- });
30
- it("should compare backups by full name if location and snapshotTime are the same", () => {
31
- const nam5Backup1 = {
32
- name: "projects/example/locations/nam5/backups/earlier-backupid",
33
- snapshotTime: "2024-01-01T00:00:00.000000Z",
34
- };
35
- const nam5Backup2 = {
36
- name: "projects/example/locations/nam5/backups/later-backupid",
37
- snapshotTime: "2024-01-01T00:00:00.000000Z",
38
- };
39
- (0, chai_1.expect)(sort.compareApiBackup(nam5Backup2, nam5Backup1)).to.greaterThanOrEqual(1);
40
- (0, chai_1.expect)(sort.compareApiBackup(nam5Backup1, nam5Backup2)).to.lessThanOrEqual(-1);
41
- });
42
- });
43
- describe("compareApiBackupSchedule", () => {
44
- it("daily schedules should precede weekly ones", () => {
45
- const dailySchedule = {
46
- name: "projects/example/databases/mydatabase/backupSchedules/schedule",
47
- dailyRecurrence: {},
48
- retention: (0, proto_1.durationFromSeconds)(60 * 60 * 24),
49
- };
50
- const weeklySchedule = {
51
- name: "projects/example/databases/mydatabase/backupSchedules/schedule",
52
- weeklyRecurrence: {
53
- day: firestore_1.DayOfWeek.FRIDAY,
54
- },
55
- retention: (0, proto_1.durationFromSeconds)(60 * 60 * 24 * 7),
56
- };
57
- (0, chai_1.expect)(sort.compareApiBackupSchedule(weeklySchedule, dailySchedule)).to.greaterThanOrEqual(1);
58
- (0, chai_1.expect)(sort.compareApiBackup(dailySchedule, weeklySchedule)).to.lessThanOrEqual(-1);
59
- });
60
- it("should compare schedules with the same recurrence by name", () => {
61
- const dailySchedule1 = {
62
- name: "projects/example/databases/mydatabase/backupSchedules/schedule1",
63
- dailyRecurrence: {},
64
- retention: (0, proto_1.durationFromSeconds)(60 * 60 * 24),
65
- };
66
- const dailySchedule2 = {
67
- name: "projects/example/databases/mydatabase/backupSchedules/schedule2",
68
- dailyRecurrence: {},
69
- retention: (0, proto_1.durationFromSeconds)(60 * 60 * 24),
70
- };
71
- (0, chai_1.expect)(sort.compareApiBackupSchedule(dailySchedule1, dailySchedule2)).to.lessThanOrEqual(-1);
72
- (0, chai_1.expect)(sort.compareApiBackup(dailySchedule2, dailySchedule1)).to.greaterThanOrEqual(1);
73
- });
74
- });
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chai_1 = require("chai");
4
- const backupUtils_1 = require("./backupUtils");
5
- describe("calculateRetention", () => {
6
- it("should accept minutes", () => {
7
- (0, chai_1.expect)((0, backupUtils_1.calculateRetention)("5m")).to.eq(300);
8
- });
9
- it("should accept hours", () => {
10
- (0, chai_1.expect)((0, backupUtils_1.calculateRetention)("3h")).to.eq(10800);
11
- });
12
- it("should accept days", () => {
13
- (0, chai_1.expect)((0, backupUtils_1.calculateRetention)("2d")).to.eq(172800);
14
- });
15
- it("should accept weeks", () => {
16
- (0, chai_1.expect)((0, backupUtils_1.calculateRetention)("3w")).to.eq(1814400);
17
- });
18
- });
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chai_1 = require("chai");
4
- const API = require("./api-types");
5
- const pretty_print_1 = require("./pretty-print");
6
- const printer = new pretty_print_1.PrettyPrint();
7
- describe("prettyIndexString", () => {
8
- it("should correctly print an order type Index", () => {
9
- (0, chai_1.expect)(printer.prettyIndexString({
10
- name: "/projects/project/databases/(default)/collectionGroups/collectionB/indexes/a",
11
- queryScope: API.QueryScope.COLLECTION,
12
- fields: [
13
- { fieldPath: "foo", order: API.Order.ASCENDING },
14
- { fieldPath: "bar", order: API.Order.DESCENDING },
15
- ],
16
- }, false)).to.contain("(foo,ASCENDING) (bar,DESCENDING) ");
17
- });
18
- it("should correctly print a contains type Index", () => {
19
- (0, chai_1.expect)(printer.prettyIndexString({
20
- name: "/projects/project/databases/(default)/collectionGroups/collectionB/indexes/a",
21
- queryScope: API.QueryScope.COLLECTION,
22
- fields: [
23
- { fieldPath: "foo", order: API.Order.ASCENDING },
24
- { fieldPath: "baz", arrayConfig: API.ArrayConfig.CONTAINS },
25
- ],
26
- }, false)).to.contain("(foo,ASCENDING) (baz,CONTAINS) ");
27
- });
28
- it("should correctly print a vector type Index", () => {
29
- (0, chai_1.expect)(printer.prettyIndexString({
30
- name: "/projects/project/databases/(default)/collectionGroups/collectionB/indexes/a",
31
- queryScope: API.QueryScope.COLLECTION,
32
- fields: [{ fieldPath: "foo", vectorConfig: { dimension: 100, flat: {} } }],
33
- }, false)).to.contain("(foo,VECTOR<100>) ");
34
- });
35
- it("should correctly print a vector type Index with other fields", () => {
36
- (0, chai_1.expect)(printer.prettyIndexString({
37
- name: "/projects/project/databases/(default)/collectionGroups/collectionB/indexes/a",
38
- queryScope: API.QueryScope.COLLECTION,
39
- fields: [
40
- { fieldPath: "foo", order: API.Order.ASCENDING },
41
- { fieldPath: "bar", vectorConfig: { dimension: 200, flat: {} } },
42
- ],
43
- }, false)).to.contain("(foo,ASCENDING) (bar,VECTOR<200>) ");
44
- });
45
- });
46
- describe("firebaseConsoleDatabaseUrl", () => {
47
- it("should provide a console link", () => {
48
- (0, chai_1.expect)(printer.firebaseConsoleDatabaseUrl("example-project", "example-db")).to.equal("https://console.firebase.google.com/project/example-project/firestore/databases/example-db/data");
49
- });
50
- it("should convert (default) to -default-", () => {
51
- (0, chai_1.expect)(printer.firebaseConsoleDatabaseUrl("example-project", "(default)")).to.equal("https://console.firebase.google.com/project/example-project/firestore/databases/-default-/data");
52
- });
53
- });
54
- describe("prettyStringArray", () => {
55
- it("should correctly print an array of strings", () => {
56
- (0, chai_1.expect)(printer.prettyStringArray(["kms-key-1", "kms-key-2"])).to.equal("kms-key-1\nkms-key-2\n");
57
- });
58
- it("should print nothing if the array is empty", () => {
59
- (0, chai_1.expect)(printer.prettyStringArray([])).to.equal("");
60
- });
61
- });