firebase-tools-with-isolate 13.15.0-0 → 13.26.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 (235) hide show
  1. package/lib/api.js +3 -1
  2. package/lib/apiv2.js +10 -3
  3. package/lib/appdistribution/client.js +62 -8
  4. package/lib/appdistribution/distribution.js +1 -1
  5. package/lib/apphosting/backend.js +299 -0
  6. package/lib/apphosting/config.js +31 -8
  7. package/lib/apphosting/githubConnections.js +70 -22
  8. package/lib/apphosting/index.js +3 -312
  9. package/lib/apphosting/rollout.js +138 -0
  10. package/lib/apphosting/secrets/index.js +70 -5
  11. package/lib/apphosting/utils.js +41 -0
  12. package/lib/apphosting/yaml.js +82 -0
  13. package/lib/archiveDirectory.js +1 -1
  14. package/lib/auth.js +31 -5
  15. package/lib/bin/firebase.js +2 -2
  16. package/lib/command.js +18 -4
  17. package/lib/commands/appdistribution-distribute.js +4 -4
  18. package/lib/commands/{appdistribution-group-create.js → appdistribution-groups-create.js} +2 -1
  19. package/lib/commands/{appdistribution-group-delete.js → appdistribution-groups-delete.js} +3 -2
  20. package/lib/commands/appdistribution-groups-list.js +55 -0
  21. package/lib/commands/appdistribution-testers-list.js +52 -0
  22. package/lib/commands/appdistribution-testers-remove.js +1 -1
  23. package/lib/commands/apphosting-backends-create.js +4 -4
  24. package/lib/commands/apphosting-backends-delete.js +7 -15
  25. package/lib/commands/apphosting-backends-get.js +1 -1
  26. package/lib/commands/apphosting-config-export.js +51 -0
  27. package/lib/commands/apphosting-repos-create.js +23 -0
  28. package/lib/commands/apphosting-rollouts-create.js +14 -15
  29. package/lib/commands/apphosting-secrets-grantaccess.js +2 -2
  30. package/lib/commands/database-import.js +4 -2
  31. package/lib/commands/database-push.js +4 -2
  32. package/lib/commands/database-set.js +4 -2
  33. package/lib/commands/database-settings-get.js +1 -1
  34. package/lib/commands/database-settings-set.js +1 -1
  35. package/lib/commands/dataconnect-sdk-generate.js +4 -1
  36. package/lib/commands/dataconnect-services-list.js +4 -3
  37. package/lib/commands/dataconnect-sql-diff.js +1 -1
  38. package/lib/commands/dataconnect-sql-grant.js +37 -0
  39. package/lib/commands/dataconnect-sql-migrate.js +1 -1
  40. package/lib/commands/dataconnect-sql-shell.js +115 -0
  41. package/lib/commands/deploy.js +5 -1
  42. package/lib/commands/emulators-start.js +4 -1
  43. package/lib/commands/ext-dev-init.js +2 -2
  44. package/lib/commands/ext-dev-list.js +1 -1
  45. package/lib/commands/ext-dev-register.js +2 -2
  46. package/lib/commands/ext-dev-upload.js +2 -2
  47. package/lib/commands/ext-dev-usage.js +2 -2
  48. package/lib/commands/ext-info.js +3 -1
  49. package/lib/commands/ext-install.js +2 -2
  50. package/lib/commands/ext-sdk-install.js +88 -0
  51. package/lib/commands/ext.js +1 -0
  52. package/lib/commands/firestore-databases-restore.js +39 -1
  53. package/lib/commands/functions-secrets-access.js +2 -4
  54. package/lib/commands/index.js +15 -2
  55. package/lib/commands/init.js +25 -15
  56. package/lib/commands/setup-emulators-dataconnect.js +0 -13
  57. package/lib/commands/use.js +1 -1
  58. package/lib/config.js +14 -4
  59. package/lib/crashlytics/buildToolsJarHelper.js +2 -2
  60. package/lib/dataconnect/client.js +3 -2
  61. package/lib/dataconnect/dataplaneClient.js +12 -9
  62. package/lib/dataconnect/ensureApis.js +6 -1
  63. package/lib/dataconnect/fileUtils.js +29 -12
  64. package/lib/dataconnect/freeTrial.js +45 -9
  65. package/lib/dataconnect/load.js +3 -1
  66. package/lib/dataconnect/provisionCloudSql.js +41 -24
  67. package/lib/dataconnect/schemaMigration.js +215 -74
  68. package/lib/dataconnect/types.js +4 -1
  69. package/lib/dataconnect/webhook.js +32 -0
  70. package/lib/deploy/dataconnect/deploy.js +18 -15
  71. package/lib/deploy/dataconnect/prepare.js +41 -0
  72. package/lib/deploy/dataconnect/release.js +16 -7
  73. package/lib/deploy/extensions/deploy.js +3 -1
  74. package/lib/deploy/extensions/deploymentSummary.js +7 -3
  75. package/lib/deploy/extensions/planner.js +95 -5
  76. package/lib/deploy/extensions/prepare.js +89 -42
  77. package/lib/deploy/extensions/release.js +17 -10
  78. package/lib/deploy/extensions/tasks.js +32 -21
  79. package/lib/deploy/firestore/prepare.js +9 -0
  80. package/lib/deploy/firestore/release.js +3 -6
  81. package/lib/deploy/functions/build.js +5 -5
  82. package/lib/deploy/functions/checkIam.js +7 -2
  83. package/lib/deploy/functions/deploy.js +12 -12
  84. package/lib/deploy/functions/ensure.js +11 -3
  85. package/lib/deploy/functions/params.js +5 -3
  86. package/lib/deploy/functions/prepare.js +18 -3
  87. package/lib/deploy/functions/release/index.js +4 -0
  88. package/lib/deploy/functions/release/planner.js +2 -1
  89. package/lib/deploy/functions/runtimes/discovery/index.js +6 -2
  90. package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
  91. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +46 -0
  92. package/lib/deploy/functions/runtimes/node/index.js +5 -0
  93. package/lib/deploy/functions/services/auth.js +34 -3
  94. package/lib/deploy/functions/services/index.js +2 -0
  95. package/lib/deploy/index.js +8 -5
  96. package/lib/deploy/lifecycleHooks.js +2 -1
  97. package/lib/emulator/apphosting/config.js +27 -0
  98. package/lib/emulator/apphosting/index.js +38 -0
  99. package/lib/emulator/apphosting/serve.js +50 -0
  100. package/lib/emulator/apphosting/utils.js +18 -0
  101. package/lib/emulator/auth/handlers.js +27 -0
  102. package/lib/emulator/auth/operations.js +41 -2
  103. package/lib/emulator/auth/state.js +2 -1
  104. package/lib/emulator/commandUtils.js +8 -3
  105. package/lib/emulator/constants.js +11 -1
  106. package/lib/emulator/controller.js +59 -6
  107. package/lib/emulator/dataconnect/pg-gateway/auth/base-auth-flow.js +11 -0
  108. package/lib/emulator/dataconnect/pg-gateway/auth/cert.js +58 -0
  109. package/lib/emulator/dataconnect/pg-gateway/auth/index.js +22 -0
  110. package/lib/emulator/dataconnect/pg-gateway/auth/md5.js +124 -0
  111. package/lib/emulator/dataconnect/pg-gateway/auth/password.js +54 -0
  112. package/lib/emulator/dataconnect/pg-gateway/auth/sasl/sasl-mechanism.js +34 -0
  113. package/lib/emulator/dataconnect/pg-gateway/auth/sasl/scram-sha-256.js +270 -0
  114. package/lib/emulator/dataconnect/pg-gateway/auth/trust.js +2 -0
  115. package/lib/emulator/dataconnect/pg-gateway/backend-error.js +75 -0
  116. package/lib/emulator/dataconnect/pg-gateway/buffer-reader.js +54 -0
  117. package/lib/emulator/dataconnect/pg-gateway/buffer-writer.js +79 -0
  118. package/lib/emulator/dataconnect/pg-gateway/connection.js +315 -0
  119. package/lib/emulator/dataconnect/pg-gateway/connection.types.js +8 -0
  120. package/lib/emulator/dataconnect/pg-gateway/crypto.js +40 -0
  121. package/lib/emulator/dataconnect/pg-gateway/duplex.js +53 -0
  122. package/lib/emulator/dataconnect/pg-gateway/index.js +27 -0
  123. package/lib/emulator/dataconnect/pg-gateway/message-buffer.js +82 -0
  124. package/lib/emulator/dataconnect/pg-gateway/message-codes.js +52 -0
  125. package/lib/emulator/dataconnect/pg-gateway/platforms/node/index.js +16 -0
  126. package/lib/emulator/dataconnect/pg-gateway/polyfills/readable-stream-async-iterator.js +35 -0
  127. package/lib/emulator/dataconnect/pg-gateway/utils.js +40 -0
  128. package/lib/emulator/dataconnect/pgliteServer.js +95 -0
  129. package/lib/emulator/dataconnectEmulator.js +58 -75
  130. package/lib/emulator/dataconnectToolkitController.js +44 -0
  131. package/lib/emulator/downloadableEmulators.js +30 -19
  132. package/lib/emulator/emulatorLogger.js +3 -0
  133. package/lib/emulator/env.js +3 -0
  134. package/lib/emulator/eventarcEmulator.js +1 -1
  135. package/lib/emulator/extensionsEmulator.js +38 -6
  136. package/lib/emulator/functionsEmulator.js +115 -42
  137. package/lib/emulator/functionsEmulatorShared.js +18 -1
  138. package/lib/emulator/functionsRuntimeWorker.js +2 -1
  139. package/lib/emulator/hub.js +13 -9
  140. package/lib/emulator/hubExport.js +10 -3
  141. package/lib/emulator/loggingEmulator.js +2 -2
  142. package/lib/emulator/portUtils.js +11 -11
  143. package/lib/emulator/registry.js +2 -0
  144. package/lib/emulator/storage/persistence.js +2 -2
  145. package/lib/emulator/storage/rules/runtime.js +1 -1
  146. package/lib/emulator/taskQueue.js +348 -0
  147. package/lib/emulator/tasksEmulator.js +240 -0
  148. package/lib/emulator/types.js +6 -0
  149. package/lib/emulator/ui.js +51 -25
  150. package/lib/error.js +31 -1
  151. package/lib/experiments.js +5 -0
  152. package/lib/extensions/askUserForEventsConfig.js +18 -8
  153. package/lib/extensions/askUserForParam.js +2 -1
  154. package/lib/extensions/displayExtensionInfo.js +5 -5
  155. package/lib/extensions/emulator/triggerHelper.js +1 -1
  156. package/lib/extensions/extensionsApi.js +15 -11
  157. package/lib/extensions/extensionsHelper.js +39 -8
  158. package/lib/extensions/localHelper.js +32 -1
  159. package/lib/extensions/refs.js +26 -11
  160. package/lib/extensions/runtimes/common.js +215 -0
  161. package/lib/extensions/runtimes/node.js +401 -0
  162. package/lib/extensions/types.js +67 -1
  163. package/lib/extensions/warnings.js +5 -2
  164. package/lib/firestore/api.js +2 -1
  165. package/lib/firestore/checkDatabaseType.js +10 -3
  166. package/lib/firestore/delete.js +11 -0
  167. package/lib/firestore/options.js +7 -0
  168. package/lib/frameworks/angular/index.js +15 -3
  169. package/lib/frameworks/constants.js +2 -2
  170. package/lib/frameworks/flutter/index.js +6 -6
  171. package/lib/frameworks/flutter/utils.js +34 -1
  172. package/lib/frameworks/next/constants.js +1 -1
  173. package/lib/frameworks/next/index.js +45 -17
  174. package/lib/frameworks/next/utils.js +57 -4
  175. package/lib/frameworks/vite/index.js +2 -2
  176. package/lib/fsutils.js +13 -1
  177. package/lib/functions/constants.js +4 -0
  178. package/lib/functions/events/v1.js +9 -2
  179. package/lib/gcp/apphosting.js +1 -1
  180. package/lib/gcp/cloudmonitoring.js +3 -3
  181. package/lib/gcp/cloudsql/cloudsqladmin.js +32 -20
  182. package/lib/gcp/cloudsql/connect.js +49 -37
  183. package/lib/gcp/cloudsql/interactive.js +49 -0
  184. package/lib/gcp/cloudsql/permissions.js +165 -0
  185. package/lib/gcp/devConnect.js +38 -1
  186. package/lib/gcp/firestore.js +5 -1
  187. package/lib/gcp/secretManager.js +12 -5
  188. package/lib/getProjectNumber.js +1 -1
  189. package/lib/init/features/apphosting.js +15 -0
  190. package/lib/init/features/dataconnect/index.js +166 -121
  191. package/lib/init/features/dataconnect/sdk.js +90 -81
  192. package/lib/init/features/emulators.js +2 -15
  193. package/lib/init/features/firestore/index.js +20 -1
  194. package/lib/init/features/firestore/indexes.js +4 -4
  195. package/lib/init/features/genkit/index.js +444 -0
  196. package/lib/init/features/hosting/index.js +2 -2
  197. package/lib/init/features/index.js +1 -1
  198. package/lib/init/features/project.js +6 -6
  199. package/lib/init/features/storage.js +0 -2
  200. package/lib/init/index.js +1 -0
  201. package/lib/init/spawn.js +23 -2
  202. package/lib/logger.js +2 -2
  203. package/lib/management/projects.js +24 -4
  204. package/lib/projectUtils.js +1 -1
  205. package/lib/prompt.js +22 -1
  206. package/lib/rc.js +1 -8
  207. package/lib/requireAuth.js +19 -5
  208. package/lib/requireDatabaseInstance.js +1 -1
  209. package/lib/requirePermissions.js +1 -1
  210. package/lib/responseToError.js +5 -2
  211. package/lib/rulesDeploy.js +1 -1
  212. package/lib/templates.js +2 -2
  213. package/lib/utils.js +16 -11
  214. package/lib/vsCodeUtils.js +8 -0
  215. package/package.json +8 -7
  216. package/schema/connector-yaml.json +57 -17
  217. package/schema/firebase-config.json +36 -0
  218. package/templates/extensions/javascript/package.lint.json +2 -2
  219. package/templates/extensions/javascript/package.nolint.json +2 -2
  220. package/templates/extensions/typescript/package.lint.json +2 -2
  221. package/templates/extensions/typescript/package.nolint.json +2 -2
  222. package/templates/genkit/firebase.0.9.0.template +57 -0
  223. package/templates/init/apphosting/apphosting.yaml +23 -0
  224. package/templates/init/dataconnect/connector.yaml +4 -3
  225. package/templates/init/dataconnect/dataconnect-fdccompatiblemode.yaml +12 -0
  226. package/templates/init/dataconnect/dataconnect.yaml +6 -6
  227. package/templates/init/dataconnect/mutations.gql +44 -29
  228. package/templates/init/dataconnect/queries.gql +65 -38
  229. package/templates/init/dataconnect/schema.gql +38 -21
  230. package/templates/init/functions/javascript/package.lint.json +2 -2
  231. package/templates/init/functions/javascript/package.nolint.json +2 -2
  232. package/templates/init/functions/typescript/package.lint.json +2 -2
  233. package/templates/init/functions/typescript/package.nolint.json +2 -2
  234. package/lib/ensureCloudResourceLocation.js +0 -12
  235. package/lib/init/features/genkit.js +0 -53
@@ -3,8 +3,8 @@
3
3
  "description": "Greet the world",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
- "firebase-admin": "^12.1.0",
7
- "firebase-functions": "^5.0.0"
6
+ "firebase-admin": "^12.6.0",
7
+ "firebase-functions": "^6.0.1"
8
8
  },
9
9
  "devDependencies": {
10
10
  "axios": "^1.3.2",
@@ -10,8 +10,8 @@
10
10
  },
11
11
  "main": "lib/index.js",
12
12
  "dependencies": {
13
- "firebase-admin": "^12.1.0",
14
- "firebase-functions": "^5.0.0"
13
+ "firebase-admin": "^12.6.0",
14
+ "firebase-functions": "^6.0.1"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@types/chai": "^4.3.4",
@@ -8,8 +8,8 @@
8
8
  },
9
9
  "main": "lib/index.js",
10
10
  "dependencies": {
11
- "firebase-admin": "^12.1.0",
12
- "firebase-functions": "^5.0.0"
11
+ "firebase-admin": "^12.6.0",
12
+ "firebase-functions": "^6.0.1"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/chai": "^4.3.4",
@@ -0,0 +1,57 @@
1
+ // Import the Genkit core libraries and plugins.
2
+ import {genkit, z} from "genkit";
3
+ $GENKIT_CONFIG_IMPORTS
4
+ $GENKIT_MODEL_IMPORT
5
+
6
+ // From the Firebase plugin, import the functions needed to deploy flows using
7
+ // Cloud Functions.
8
+ import {firebaseAuth} from "@genkit-ai/firebase/auth";
9
+ import {onFlow} from "@genkit-ai/firebase/functions";
10
+
11
+ const ai = genkit({
12
+ plugins: [
13
+ $GENKIT_CONFIG_PLUGINS
14
+ ],
15
+ });
16
+
17
+ // Define a simple flow that prompts an LLM to generate menu suggestions.
18
+ export const menuSuggestionFlow = onFlow(
19
+ ai,
20
+ {
21
+ name: "menuSuggestionFlow",
22
+ inputSchema: z.string(),
23
+ outputSchema: z.string(),
24
+ authPolicy: firebaseAuth((user) => {
25
+ // By default, the firebaseAuth policy requires that all requests have an
26
+ // `Authorization: Bearer` header containing the user's Firebase
27
+ // Authentication ID token. All other requests are rejected with error
28
+ // 403. If your app client uses the Cloud Functions for Firebase callable
29
+ // functions feature, the library automatically attaches this header to
30
+ // requests.
31
+
32
+ // You should also set additional policy requirements as appropriate for
33
+ // your app. For example:
34
+ // if (!user.email_verified) {
35
+ // throw new Error("Verified email required to run flow");
36
+ // }
37
+ }),
38
+ },
39
+ async (subject) => {
40
+ // Construct a request and send it to the model API.
41
+ const prompt =
42
+ `Suggest an item for the menu of a ${subject} themed restaurant`;
43
+ const llmResponse = await ai.generate({
44
+ model: $GENKIT_MODEL,
45
+ prompt: prompt,
46
+ config: {
47
+ temperature: 1,
48
+ },
49
+ });
50
+
51
+ // Handle the response from the model API. In this sample, we just
52
+ // convert it to a string, but more complicated flows might coerce the
53
+ // response into structured output or chain the response into another
54
+ // LLM call, etc.
55
+ return llmResponse.text;
56
+ }
57
+ );
@@ -0,0 +1,23 @@
1
+ # Settings for Backend (on Cloud Run).
2
+ # See https://firebase.google.com/docs/app-hosting/configure#cloud-run
3
+ runConfig:
4
+ minInstances: 0
5
+ # maxInstances: 100
6
+ # concurrency: 80
7
+ # cpu: 1
8
+ # memoryMiB: 512
9
+
10
+ # Environment variables and secrets.
11
+ # env:
12
+ # Configure environment variables.
13
+ # See https://firebase.google.com/docs/app-hosting/configure#user-defined-environment
14
+ # - variable: MESSAGE
15
+ # value: Hello world!
16
+ # availability:
17
+ # - BUILD
18
+ # - RUNTIME
19
+
20
+ # Grant access to secrets in Cloud Secret Manager.
21
+ # See https://firebase.google.com/docs/app-hosting/configure#secret-parameters
22
+ # - variable: MY_SECRET
23
+ # secret: mySecretRef
@@ -1,13 +1,14 @@
1
- connectorId: "__connectorId__"
2
- authMode: "PUBLIC"
1
+ connectorId: __connectorId__
3
2
  ## ## Here's an example of how to add generated SDKs.
4
3
  ## ## You'll need to replace the outputDirs with ones pointing to where you want the generated code in your app.
5
4
  # generate:
6
5
  # javascriptSdk:
7
6
  # outputDir: <Path where you want the generated SDK to be written to, relative to this file>
8
7
  # package: "@firebasegen/my-connector"
9
- # packageJSONDir: < Optional. Path to your Javascript app's package.json>
8
+ # packageJsonDir: < Optional. Path to your Javascript app's package.json>
10
9
  # swiftSdk:
11
10
  # outputDir: <Path where you want the generated SDK to be written to, relative to this file>
11
+ # package: "firebasegen/default"
12
12
  # kotlinSdk:
13
13
  # outputDir: <Path where you want the generated SDK to be written to, relative to this file>
14
+ # package: connectors.default
@@ -0,0 +1,12 @@
1
+ specVersion: "v1beta"
2
+ serviceId: __serviceId__
3
+ location: __location__
4
+ schema:
5
+ source: "./schema"
6
+ datasource:
7
+ postgresql:
8
+ database: __cloudSqlDatabase__
9
+ cloudSql:
10
+ instanceId: __cloudSqlInstanceId__
11
+ # schemaValidation: "COMPATIBLE"
12
+ connectorDirs: __connectorDirs__
@@ -1,11 +1,11 @@
1
- specVersion: "v1alpha"
2
- serviceId: "__serviceId__"
3
- location: "__location__"
1
+ specVersion: "v1beta"
2
+ serviceId: __serviceId__
3
+ location: __location__
4
4
  schema:
5
5
  source: "./schema"
6
6
  datasource:
7
7
  postgresql:
8
- database: "__cloudSqlDatabase__"
8
+ database: __cloudSqlDatabase__
9
9
  cloudSql:
10
- instanceId: "__cloudSqlInstanceId__"
11
- connectorDirs: [__connectorIds__]
10
+ instanceId: __cloudSqlInstanceId__
11
+ connectorDirs: __connectorDirs__
@@ -1,35 +1,50 @@
1
- # # Example mutations for a simple email app
1
+ # # Example mutations for a simple movie app
2
2
 
3
- # # Logged in user can create their own account.
4
- # mutation CreateUser($name: String!, $address: String!) @auth(level: USER) {
5
- # # <type>_insert lets you create a new row in your table.
6
- # user_insert(data: {
7
- # # Server values let your service populate sensitive data.
8
- # # Users can only setup their own account.
9
- # uid_expr: "auth.uid",
10
- # name: $name,
11
- # address: $address
12
- # })
3
+ # # Create a movie based on user input
4
+ # mutation CreateMovie(
5
+ # $title: String!
6
+ # $genre: String!
7
+ # $imageUrl: String!
8
+ # ) @auth(level: USER_EMAIL_VERIFIED) {
9
+ # movie_insert(
10
+ # data: {
11
+ # title: $title
12
+ # genre: $genre
13
+ # imageUrl: $imageUrl
14
+ # }
15
+ # )
13
16
  # }
14
17
 
15
- # # Logged in user can send emails from their account.
16
- # mutation CreateEmail($content: String, $subject: String) @auth(level: USER) {
17
- # email_insert(data: {
18
- # # The request variable name doesn't have to match the field name.
19
- # text: $content,
20
- # subject: $subject,
21
- # # Server values let your service populate sensitive data.
22
- # # Users are only allowed to create emails sent from their account.
23
- # fromUid_expr: "auth.uid",
24
- # # Server values let your service populate data for you
25
- # # Here, we use sent_date: { today: true } to set 'sent' to today's date.
26
- # sent_date: { today: true }
27
- # })
18
+ # # Upsert (update or insert) a user's username based on their auth.uid
19
+ # mutation UpsertUser($username: String!) @auth(level: USER) {
20
+ # user_upsert(
21
+ # data: {
22
+ # id_expr: "auth.uid"
23
+ # username: $username
24
+ # }
25
+ # )
28
26
  # }
29
27
 
30
- # mutation CreateRecipient($emailId: UUID) @auth(level: USER) {
31
- # recipient_insert(data: {
32
- # emailId: $emailId,
33
- # userUid_expr: "auth.uid"
34
- # })
28
+ # # Add a review for a movie
29
+ # mutation AddReview(
30
+ # $movieId: UUID!
31
+ # $rating: Int!
32
+ # $reviewText: String!
33
+ # ) @auth(level: USER) {
34
+ # review_upsert(
35
+ # data: {
36
+ # userId_expr: "auth.uid"
37
+ # movieId: $movieId
38
+ # rating: $rating
39
+ # reviewText: $reviewText
40
+ # # reviewDate defaults to today in the schema. No need to set it manually.
41
+ # }
42
+ # )
43
+ # }
44
+
45
+ # # Logged in user can delete their review for a movie
46
+ # mutation DeleteReview(
47
+ # $movieId: UUID!
48
+ # ) @auth(level: USER) {
49
+ # review_delete(key: { userId_expr: "auth.uid", movieId: $movieId })
35
50
  # }
@@ -1,56 +1,83 @@
1
- # # Example queries for a simple email app.
1
+ # # Example queries for a simple movie app.
2
2
 
3
3
  # # @auth() directives control who can call each operation.
4
- # # Only admins should be able to list all emails, so we use NO_ACCESS
5
- # query ListEmails @auth(level: NO_ACCESS) {
6
- # emails {
7
- # id, subject, text, sent
8
- # from {
9
- # name
10
- # }
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
11
  # }
12
12
  # }
13
13
 
14
- # # Only admins should be able to list all users, so we use NO_ACCESS
14
+ # # List all users, only admins should be able to list all users, so we use NO_ACCESS
15
15
  # query ListUsers @auth(level: NO_ACCESS) {
16
- # users { uid, name, address }
16
+ # users { id, username }
17
17
  # }
18
-
19
- # # Logged in users should be able to see their inbox though, so we use USER
20
- # query ListInbox @auth(level: USER) {
21
- # # where allows you to filter lists
22
- # # Here, we use it to filter to only emails that are sent to the logged in user.
23
- # emails(where: {
24
- # users_via_Recipient: {
25
- # exist: { uid: { eq_expr: "auth.uid" }
26
- # }}
27
- # }) {
28
- # id subject sent
29
- # content: text # Select the `text` field but alias it as `content` in the response.
30
- # sender: from { name address uid }
18
+
19
+ # # Logged in user can list all their reviews and movie titles associated with the review
20
+ # # Since the query requires the uid of the current authenticated user, the auth level is set to USER
21
+ # query ListUserReviews @auth(level: USER) {
22
+ # user(key: {id_expr: "auth.uid"}) {
23
+ # id
24
+ # username
31
25
  # # <field>_on_<foreign_key_field> makes it easy to grab info from another table
32
- # # Here, we use it to grab all the recipients of the email.
33
- # to: recipients_on_email {
34
- # user { name address uid }
26
+ # # Here, we use it to grab all the reviews written by the user.
27
+ # reviews: reviews_on_user {
28
+ # id
29
+ # rating
30
+ # reviewDate
31
+ # reviewText
32
+ # movie {
33
+ # id
34
+ # title
35
+ # }
35
36
  # }
36
37
  # }
37
38
  # }
38
39
 
39
- # query GetUidByEmail($emails: [String!]) @auth(level: PUBLIC) {
40
- # users(where: { address: { in: $emails } }) {
41
- # uid address
40
+ # # Get movie by id
41
+ # query GetMovieById($id: UUID!) @auth(level: PUBLIC) {
42
+ # movie(id: $id) {
43
+ # id
44
+ # title
45
+ # imageUrl
46
+ # genre
47
+ # metadata: movieMetadata_on_movie {
48
+ # rating
49
+ # releaseYear
50
+ # description
51
+ # }
52
+ # reviews: reviews_on_movie {
53
+ # id
54
+ # reviewText
55
+ # reviewDate
56
+ # rating
57
+ # user {
58
+ # id
59
+ # username
60
+ # }
61
+ # }
42
62
  # }
43
63
  # }
44
64
 
45
- # query ListSent($uid: String) @auth(level: PUBLIC) {
46
- # emails(where: {
47
- # from: {uid: {eq: $uid }}
48
- # }) {
49
- # id subject sent
50
- # content: text
51
- # sender: from { name address uid }
52
- # to: recipients_on_email {
53
- # user { name address uid }
65
+ # # Search for movies, actors, and reviews
66
+ # query SearchMovie(
67
+ # $titleInput: String
68
+ # $genre: String
69
+ # ) @auth(level: PUBLIC) {
70
+ # movies(
71
+ # where: {
72
+ # _and: [
73
+ # { genre: { eq: $genre } }
74
+ # { title: { contains: $titleInput } }
75
+ # ]
54
76
  # }
77
+ # ) {
78
+ # id
79
+ # title
80
+ # genre
81
+ # imageUrl
55
82
  # }
56
83
  # }
@@ -1,28 +1,45 @@
1
- # # Example schema for simple email app
2
- # type User @table(key: "uid") {
3
- # uid: String!
4
- # name: String!
5
- # address: String!
1
+ # # Example schema for simple movie review app
2
+
3
+ # # Users
4
+ # # Suppose a user can leave reviews for movies
5
+ # # user -> reviews is a one to many relationship,
6
+ # # movie -> reviews is a one to many relationship
7
+ # # movie <-> user is a many to many relationship
8
+ # type User @table {
9
+ # id: String! @col(name: "user_auth")
10
+ # username: String! @col(name: "username", dataType: "varchar(50)")
11
+ # # The following are generated by the user: User! field in the Review table
12
+ # # reviews_on_user
13
+ # # movies_via_Review
6
14
  # }
7
15
 
8
- # type Email @table {
9
- # subject: String!
10
- # sent: Date!
11
- # text: String!
12
- # from: User!
16
+ # # Movies
17
+ # type Movie @table {
18
+ # # The below parameter values are generated by default with @table, and can be edited manually.
19
+ # # implies directive `@col(name: "movie_id")`, generating a column name
20
+ # id: UUID! @default(expr: "uuidV4()")
21
+ # title: String!
22
+ # imageUrl: String!
23
+ # genre: String
13
24
  # }
14
25
 
15
- # type Recipient @table(key: ["email", "user"]) {
16
- # email: Email!
17
- # user: User!
26
+ # # Movie Metadata
27
+ # # Movie - MovieMetadata is a one-to-one relationship
28
+ # type MovieMetadata @table {
29
+ # # @unique indicates a 1-1 relationship
30
+ # movie: Movie! @unique
31
+ # # movieId: UUID <- this is created by the above reference
32
+ # rating: Float
33
+ # releaseYear: Int
34
+ # description: String
18
35
  # }
19
36
 
20
- # type EmailMeta @table(key: ["user", "email"]) {
21
- # user: User!
22
- # email: Email!
23
- # labels: [String]
24
- # read: Boolean!
25
- # starred: Boolean!
26
- # muted: Boolean!
27
- # snoozed: Date
37
+ # # Reviews
38
+ # type Review @table(name: "Reviews", key: ["movie", "user"]) {
39
+ # id: UUID! @default(expr: "uuidV4()")
40
+ # user: User!
41
+ # movie: Movie!
42
+ # rating: Int
43
+ # reviewText: String
44
+ # reviewDate: Date! @default(expr: "request.time")
28
45
  # }
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "main": "index.js",
16
16
  "dependencies": {
17
- "firebase-admin": "^12.1.0",
18
- "firebase-functions": "^5.0.0"
17
+ "firebase-admin": "^12.6.0",
18
+ "firebase-functions": "^6.0.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "eslint": "^8.15.0",
@@ -13,8 +13,8 @@
13
13
  },
14
14
  "main": "index.js",
15
15
  "dependencies": {
16
- "firebase-admin": "^12.1.0",
17
- "firebase-functions": "^5.0.0"
16
+ "firebase-admin": "^12.6.0",
17
+ "firebase-functions": "^6.0.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "firebase-functions-test": "^3.1.0"
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "main": "lib/index.js",
17
17
  "dependencies": {
18
- "firebase-admin": "^12.1.0",
19
- "firebase-functions": "^5.0.0"
18
+ "firebase-admin": "^12.6.0",
19
+ "firebase-functions": "^6.0.1"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@typescript-eslint/eslint-plugin": "^5.12.0",
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "main": "lib/index.js",
16
16
  "dependencies": {
17
- "firebase-admin": "^12.1.0",
18
- "firebase-functions": "^5.0.0"
17
+ "firebase-admin": "^12.6.0",
18
+ "firebase-functions": "^6.0.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "typescript": "^4.9.0",
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureLocationSet = void 0;
4
- const error_1 = require("./error");
5
- function ensureLocationSet(location, feature) {
6
- if (!location) {
7
- throw new error_1.FirebaseError(`Cloud resource location is not set for this project but the operation ` +
8
- `you are attempting to perform in ${feature} requires it. ` +
9
- `Please see this documentation for more details: https://firebase.google.com/docs/projects/locations`);
10
- }
11
- }
12
- exports.ensureLocationSet = ensureLocationSet;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.doSetup = void 0;
4
- const logger_1 = require("../../logger");
5
- const functions_1 = require("./functions");
6
- const prompt_1 = require("../../prompt");
7
- const spawn_1 = require("../spawn");
8
- async function doSetup(setup, config, options) {
9
- if (setup.functions?.languageChoice !== "typescript") {
10
- const continueFunctions = await (0, prompt_1.promptOnce)({
11
- type: "confirm",
12
- message: "Genkit's Firebase integration uses Cloud Functions for Firebase with TypeScript. Initialize Functions to continue?",
13
- default: true,
14
- });
15
- if (!continueFunctions) {
16
- logger_1.logger.info("Stopped Genkit initialization");
17
- return;
18
- }
19
- setup.languageOverride = "typescript";
20
- await (0, functions_1.doSetup)(setup, config, options);
21
- delete setup.languageOverride;
22
- logger_1.logger.info();
23
- }
24
- const projectDir = `${config.projectDir}/${setup.functions.source}`;
25
- const installType = await (0, prompt_1.promptOnce)({
26
- type: "list",
27
- message: "Install the Genkit CLI globally or locally in this project?",
28
- choices: [
29
- { name: "Globally", value: "globally" },
30
- { name: "Just this project", value: "project" },
31
- ],
32
- });
33
- try {
34
- logger_1.logger.info("Installing Genkit CLI");
35
- if (installType === "globally") {
36
- await (0, spawn_1.wrapSpawn)("npm", ["install", "-g", "genkit"], projectDir);
37
- await (0, spawn_1.wrapSpawn)("genkit", ["init", "-p", "firebase"], projectDir);
38
- logger_1.logger.info("Start the Genkit developer experience by running:");
39
- logger_1.logger.info(` cd ${setup.functions.source} && genkit start`);
40
- }
41
- else {
42
- await (0, spawn_1.wrapSpawn)("npm", ["install", "genkit", "--save-dev"], projectDir);
43
- await (0, spawn_1.wrapSpawn)("npx", ["genkit", "init", "-p", "firebase"], projectDir);
44
- logger_1.logger.info("Start the Genkit developer experience by running:");
45
- logger_1.logger.info(` cd ${setup.functions.source} && npx genkit start`);
46
- }
47
- }
48
- catch (e) {
49
- logger_1.logger.error("Genkit initialization failed...");
50
- return;
51
- }
52
- }
53
- exports.doSetup = doSetup;