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.
- package/lib/api.js +3 -1
- package/lib/apiv2.js +10 -3
- package/lib/appdistribution/client.js +62 -8
- package/lib/appdistribution/distribution.js +1 -1
- package/lib/apphosting/backend.js +299 -0
- package/lib/apphosting/config.js +31 -8
- package/lib/apphosting/githubConnections.js +70 -22
- package/lib/apphosting/index.js +3 -312
- package/lib/apphosting/rollout.js +138 -0
- package/lib/apphosting/secrets/index.js +70 -5
- package/lib/apphosting/utils.js +41 -0
- package/lib/apphosting/yaml.js +82 -0
- package/lib/archiveDirectory.js +1 -1
- package/lib/auth.js +31 -5
- package/lib/bin/firebase.js +2 -2
- package/lib/command.js +18 -4
- package/lib/commands/appdistribution-distribute.js +4 -4
- package/lib/commands/{appdistribution-group-create.js → appdistribution-groups-create.js} +2 -1
- package/lib/commands/{appdistribution-group-delete.js → appdistribution-groups-delete.js} +3 -2
- package/lib/commands/appdistribution-groups-list.js +55 -0
- package/lib/commands/appdistribution-testers-list.js +52 -0
- package/lib/commands/appdistribution-testers-remove.js +1 -1
- package/lib/commands/apphosting-backends-create.js +4 -4
- package/lib/commands/apphosting-backends-delete.js +7 -15
- package/lib/commands/apphosting-backends-get.js +1 -1
- package/lib/commands/apphosting-config-export.js +51 -0
- package/lib/commands/apphosting-repos-create.js +23 -0
- package/lib/commands/apphosting-rollouts-create.js +14 -15
- package/lib/commands/apphosting-secrets-grantaccess.js +2 -2
- package/lib/commands/database-import.js +4 -2
- package/lib/commands/database-push.js +4 -2
- package/lib/commands/database-set.js +4 -2
- package/lib/commands/database-settings-get.js +1 -1
- package/lib/commands/database-settings-set.js +1 -1
- package/lib/commands/dataconnect-sdk-generate.js +4 -1
- package/lib/commands/dataconnect-services-list.js +4 -3
- package/lib/commands/dataconnect-sql-diff.js +1 -1
- package/lib/commands/dataconnect-sql-grant.js +37 -0
- package/lib/commands/dataconnect-sql-migrate.js +1 -1
- package/lib/commands/dataconnect-sql-shell.js +115 -0
- package/lib/commands/deploy.js +5 -1
- package/lib/commands/emulators-start.js +4 -1
- package/lib/commands/ext-dev-init.js +2 -2
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-register.js +2 -2
- package/lib/commands/ext-dev-upload.js +2 -2
- package/lib/commands/ext-dev-usage.js +2 -2
- package/lib/commands/ext-info.js +3 -1
- package/lib/commands/ext-install.js +2 -2
- package/lib/commands/ext-sdk-install.js +88 -0
- package/lib/commands/ext.js +1 -0
- package/lib/commands/firestore-databases-restore.js +39 -1
- package/lib/commands/functions-secrets-access.js +2 -4
- package/lib/commands/index.js +15 -2
- package/lib/commands/init.js +25 -15
- package/lib/commands/setup-emulators-dataconnect.js +0 -13
- package/lib/commands/use.js +1 -1
- package/lib/config.js +14 -4
- package/lib/crashlytics/buildToolsJarHelper.js +2 -2
- package/lib/dataconnect/client.js +3 -2
- package/lib/dataconnect/dataplaneClient.js +12 -9
- package/lib/dataconnect/ensureApis.js +6 -1
- package/lib/dataconnect/fileUtils.js +29 -12
- package/lib/dataconnect/freeTrial.js +45 -9
- package/lib/dataconnect/load.js +3 -1
- package/lib/dataconnect/provisionCloudSql.js +41 -24
- package/lib/dataconnect/schemaMigration.js +215 -74
- package/lib/dataconnect/types.js +4 -1
- package/lib/dataconnect/webhook.js +32 -0
- package/lib/deploy/dataconnect/deploy.js +18 -15
- package/lib/deploy/dataconnect/prepare.js +41 -0
- package/lib/deploy/dataconnect/release.js +16 -7
- package/lib/deploy/extensions/deploy.js +3 -1
- package/lib/deploy/extensions/deploymentSummary.js +7 -3
- package/lib/deploy/extensions/planner.js +95 -5
- package/lib/deploy/extensions/prepare.js +89 -42
- package/lib/deploy/extensions/release.js +17 -10
- package/lib/deploy/extensions/tasks.js +32 -21
- package/lib/deploy/firestore/prepare.js +9 -0
- package/lib/deploy/firestore/release.js +3 -6
- package/lib/deploy/functions/build.js +5 -5
- package/lib/deploy/functions/checkIam.js +7 -2
- package/lib/deploy/functions/deploy.js +12 -12
- package/lib/deploy/functions/ensure.js +11 -3
- package/lib/deploy/functions/params.js +5 -3
- package/lib/deploy/functions/prepare.js +18 -3
- package/lib/deploy/functions/release/index.js +4 -0
- package/lib/deploy/functions/release/planner.js +2 -1
- package/lib/deploy/functions/runtimes/discovery/index.js +6 -2
- package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +46 -0
- package/lib/deploy/functions/runtimes/node/index.js +5 -0
- package/lib/deploy/functions/services/auth.js +34 -3
- package/lib/deploy/functions/services/index.js +2 -0
- package/lib/deploy/index.js +8 -5
- package/lib/deploy/lifecycleHooks.js +2 -1
- package/lib/emulator/apphosting/config.js +27 -0
- package/lib/emulator/apphosting/index.js +38 -0
- package/lib/emulator/apphosting/serve.js +50 -0
- package/lib/emulator/apphosting/utils.js +18 -0
- package/lib/emulator/auth/handlers.js +27 -0
- package/lib/emulator/auth/operations.js +41 -2
- package/lib/emulator/auth/state.js +2 -1
- package/lib/emulator/commandUtils.js +8 -3
- package/lib/emulator/constants.js +11 -1
- package/lib/emulator/controller.js +59 -6
- package/lib/emulator/dataconnect/pg-gateway/auth/base-auth-flow.js +11 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/cert.js +58 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/index.js +22 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/md5.js +124 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/password.js +54 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/sasl-mechanism.js +34 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/scram-sha-256.js +270 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/trust.js +2 -0
- package/lib/emulator/dataconnect/pg-gateway/backend-error.js +75 -0
- package/lib/emulator/dataconnect/pg-gateway/buffer-reader.js +54 -0
- package/lib/emulator/dataconnect/pg-gateway/buffer-writer.js +79 -0
- package/lib/emulator/dataconnect/pg-gateway/connection.js +315 -0
- package/lib/emulator/dataconnect/pg-gateway/connection.types.js +8 -0
- package/lib/emulator/dataconnect/pg-gateway/crypto.js +40 -0
- package/lib/emulator/dataconnect/pg-gateway/duplex.js +53 -0
- package/lib/emulator/dataconnect/pg-gateway/index.js +27 -0
- package/lib/emulator/dataconnect/pg-gateway/message-buffer.js +82 -0
- package/lib/emulator/dataconnect/pg-gateway/message-codes.js +52 -0
- package/lib/emulator/dataconnect/pg-gateway/platforms/node/index.js +16 -0
- package/lib/emulator/dataconnect/pg-gateway/polyfills/readable-stream-async-iterator.js +35 -0
- package/lib/emulator/dataconnect/pg-gateway/utils.js +40 -0
- package/lib/emulator/dataconnect/pgliteServer.js +95 -0
- package/lib/emulator/dataconnectEmulator.js +58 -75
- package/lib/emulator/dataconnectToolkitController.js +44 -0
- package/lib/emulator/downloadableEmulators.js +30 -19
- package/lib/emulator/emulatorLogger.js +3 -0
- package/lib/emulator/env.js +3 -0
- package/lib/emulator/eventarcEmulator.js +1 -1
- package/lib/emulator/extensionsEmulator.js +38 -6
- package/lib/emulator/functionsEmulator.js +115 -42
- package/lib/emulator/functionsEmulatorShared.js +18 -1
- package/lib/emulator/functionsRuntimeWorker.js +2 -1
- package/lib/emulator/hub.js +13 -9
- package/lib/emulator/hubExport.js +10 -3
- package/lib/emulator/loggingEmulator.js +2 -2
- package/lib/emulator/portUtils.js +11 -11
- package/lib/emulator/registry.js +2 -0
- package/lib/emulator/storage/persistence.js +2 -2
- package/lib/emulator/storage/rules/runtime.js +1 -1
- package/lib/emulator/taskQueue.js +348 -0
- package/lib/emulator/tasksEmulator.js +240 -0
- package/lib/emulator/types.js +6 -0
- package/lib/emulator/ui.js +51 -25
- package/lib/error.js +31 -1
- package/lib/experiments.js +5 -0
- package/lib/extensions/askUserForEventsConfig.js +18 -8
- package/lib/extensions/askUserForParam.js +2 -1
- package/lib/extensions/displayExtensionInfo.js +5 -5
- package/lib/extensions/emulator/triggerHelper.js +1 -1
- package/lib/extensions/extensionsApi.js +15 -11
- package/lib/extensions/extensionsHelper.js +39 -8
- package/lib/extensions/localHelper.js +32 -1
- package/lib/extensions/refs.js +26 -11
- package/lib/extensions/runtimes/common.js +215 -0
- package/lib/extensions/runtimes/node.js +401 -0
- package/lib/extensions/types.js +67 -1
- package/lib/extensions/warnings.js +5 -2
- package/lib/firestore/api.js +2 -1
- package/lib/firestore/checkDatabaseType.js +10 -3
- package/lib/firestore/delete.js +11 -0
- package/lib/firestore/options.js +7 -0
- package/lib/frameworks/angular/index.js +15 -3
- package/lib/frameworks/constants.js +2 -2
- package/lib/frameworks/flutter/index.js +6 -6
- package/lib/frameworks/flutter/utils.js +34 -1
- package/lib/frameworks/next/constants.js +1 -1
- package/lib/frameworks/next/index.js +45 -17
- package/lib/frameworks/next/utils.js +57 -4
- package/lib/frameworks/vite/index.js +2 -2
- package/lib/fsutils.js +13 -1
- package/lib/functions/constants.js +4 -0
- package/lib/functions/events/v1.js +9 -2
- package/lib/gcp/apphosting.js +1 -1
- package/lib/gcp/cloudmonitoring.js +3 -3
- package/lib/gcp/cloudsql/cloudsqladmin.js +32 -20
- package/lib/gcp/cloudsql/connect.js +49 -37
- package/lib/gcp/cloudsql/interactive.js +49 -0
- package/lib/gcp/cloudsql/permissions.js +165 -0
- package/lib/gcp/devConnect.js +38 -1
- package/lib/gcp/firestore.js +5 -1
- package/lib/gcp/secretManager.js +12 -5
- package/lib/getProjectNumber.js +1 -1
- package/lib/init/features/apphosting.js +15 -0
- package/lib/init/features/dataconnect/index.js +166 -121
- package/lib/init/features/dataconnect/sdk.js +90 -81
- package/lib/init/features/emulators.js +2 -15
- package/lib/init/features/firestore/index.js +20 -1
- package/lib/init/features/firestore/indexes.js +4 -4
- package/lib/init/features/genkit/index.js +444 -0
- package/lib/init/features/hosting/index.js +2 -2
- package/lib/init/features/index.js +1 -1
- package/lib/init/features/project.js +6 -6
- package/lib/init/features/storage.js +0 -2
- package/lib/init/index.js +1 -0
- package/lib/init/spawn.js +23 -2
- package/lib/logger.js +2 -2
- package/lib/management/projects.js +24 -4
- package/lib/projectUtils.js +1 -1
- package/lib/prompt.js +22 -1
- package/lib/rc.js +1 -8
- package/lib/requireAuth.js +19 -5
- package/lib/requireDatabaseInstance.js +1 -1
- package/lib/requirePermissions.js +1 -1
- package/lib/responseToError.js +5 -2
- package/lib/rulesDeploy.js +1 -1
- package/lib/templates.js +2 -2
- package/lib/utils.js +16 -11
- package/lib/vsCodeUtils.js +8 -0
- package/package.json +8 -7
- package/schema/connector-yaml.json +57 -17
- package/schema/firebase-config.json +36 -0
- package/templates/extensions/javascript/package.lint.json +2 -2
- package/templates/extensions/javascript/package.nolint.json +2 -2
- package/templates/extensions/typescript/package.lint.json +2 -2
- package/templates/extensions/typescript/package.nolint.json +2 -2
- package/templates/genkit/firebase.0.9.0.template +57 -0
- package/templates/init/apphosting/apphosting.yaml +23 -0
- package/templates/init/dataconnect/connector.yaml +4 -3
- package/templates/init/dataconnect/dataconnect-fdccompatiblemode.yaml +12 -0
- package/templates/init/dataconnect/dataconnect.yaml +6 -6
- package/templates/init/dataconnect/mutations.gql +44 -29
- package/templates/init/dataconnect/queries.gql +65 -38
- package/templates/init/dataconnect/schema.gql +38 -21
- package/templates/init/functions/javascript/package.lint.json +2 -2
- package/templates/init/functions/javascript/package.nolint.json +2 -2
- package/templates/init/functions/typescript/package.lint.json +2 -2
- package/templates/init/functions/typescript/package.nolint.json +2 -2
- package/lib/ensureCloudResourceLocation.js +0 -12
- package/lib/init/features/genkit.js +0 -53
|
@@ -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:
|
|
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
|
-
#
|
|
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: "
|
|
2
|
-
serviceId:
|
|
3
|
-
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:
|
|
8
|
+
database: __cloudSqlDatabase__
|
|
9
9
|
cloudSql:
|
|
10
|
-
instanceId:
|
|
11
|
-
connectorDirs:
|
|
10
|
+
instanceId: __cloudSqlInstanceId__
|
|
11
|
+
connectorDirs: __connectorDirs__
|
|
@@ -1,35 +1,50 @@
|
|
|
1
|
-
# # Example mutations for a simple
|
|
1
|
+
# # Example mutations for a simple movie app
|
|
2
2
|
|
|
3
|
-
# #
|
|
4
|
-
# mutation
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
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
|
-
# #
|
|
16
|
-
# mutation
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
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
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
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
|
|
1
|
+
# # Example queries for a simple movie app.
|
|
2
2
|
|
|
3
3
|
# # @auth() directives control who can call each operation.
|
|
4
|
-
# #
|
|
5
|
-
# query
|
|
6
|
-
#
|
|
7
|
-
# id
|
|
8
|
-
#
|
|
9
|
-
#
|
|
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
|
-
# #
|
|
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 {
|
|
16
|
+
# users { id, username }
|
|
17
17
|
# }
|
|
18
|
-
|
|
19
|
-
# # Logged in
|
|
20
|
-
# query
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
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
|
|
33
|
-
#
|
|
34
|
-
#
|
|
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
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
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
|
-
#
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
#
|
|
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
|
|
2
|
-
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
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
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
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
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
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
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
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
|
# }
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"main": "lib/index.js",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"firebase-admin": "^12.
|
|
19
|
-
"firebase-functions": "^
|
|
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",
|
|
@@ -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;
|