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.
- package/lib/api.js +5 -1
- package/lib/apphosting/backend.js +40 -15
- package/lib/apptesting/ensureProjectConfigured.js +56 -0
- package/lib/apptesting/invokeTests.js +40 -0
- package/lib/apptesting/parseTestFiles.js +75 -0
- package/lib/apptesting/types.js +18 -0
- package/lib/auth.js +37 -2
- package/lib/command.js +24 -5
- package/lib/commands/apphosting-backends-create.js +8 -5
- package/lib/commands/apptesting-execute.js +101 -0
- package/lib/commands/dataconnect-sdk-generate.js +28 -26
- package/lib/commands/dataconnect-services-list.js +1 -1
- package/lib/commands/dataconnect-sql-diff.js +2 -2
- package/lib/commands/dataconnect-sql-grant.js +7 -2
- package/lib/commands/dataconnect-sql-migrate.js +2 -2
- package/lib/commands/dataconnect-sql-setup.js +3 -5
- package/lib/commands/dataconnect-sql-shell.js +2 -2
- package/lib/commands/ext-export.js +1 -1
- package/lib/commands/firestore-bulkdelete.js +73 -0
- package/lib/commands/firestore-databases-create.js +11 -0
- package/lib/commands/firestore-operations-cancel.js +44 -0
- package/lib/commands/firestore-operations-describe.js +29 -0
- package/lib/commands/firestore-operations-list.js +29 -0
- package/lib/commands/firestore-utils.js +15 -0
- package/lib/commands/functions-config-clone.js +2 -0
- package/lib/commands/functions-config-export.js +5 -2
- package/lib/commands/functions-config-get.js +2 -0
- package/lib/commands/functions-config-set.js +2 -0
- package/lib/commands/functions-config-unset.js +2 -0
- package/lib/commands/index.js +9 -0
- package/lib/commands/init.js +24 -4
- package/lib/commands/internaltesting-functions-discover.js +20 -5
- package/lib/commands/login.js +13 -9
- package/lib/commands/use.js +5 -0
- package/lib/config.js +16 -4
- package/lib/crashlytics/addNote.js +27 -0
- package/lib/crashlytics/buildToolsJarHelper.js +1 -2
- package/lib/crashlytics/deleteNote.js +23 -0
- package/lib/crashlytics/getIssueDetails.js +26 -0
- package/lib/crashlytics/getSampleCrash.js +34 -0
- package/lib/crashlytics/listNotes.js +29 -0
- package/lib/crashlytics/listTopDevices.js +33 -0
- package/lib/crashlytics/listTopIssues.js +8 -23
- package/lib/crashlytics/listTopOperatingSystems.js +32 -0
- package/lib/crashlytics/listTopVersions.js +32 -0
- package/lib/crashlytics/updateIssue.js +35 -0
- package/lib/crashlytics/utils.js +38 -0
- package/lib/dataconnect/appFinder.js +102 -0
- package/lib/dataconnect/client.js +23 -15
- package/lib/dataconnect/ensureApis.js +6 -9
- package/lib/dataconnect/errors.js +7 -1
- package/lib/dataconnect/freeTrial.js +16 -38
- package/lib/dataconnect/load.js +105 -6
- package/lib/dataconnect/provisionCloudSql.js +67 -70
- package/lib/dataconnect/schemaMigration.js +219 -169
- package/lib/deploy/dataconnect/deploy.js +7 -9
- package/lib/deploy/dataconnect/prepare.js +7 -12
- package/lib/deploy/dataconnect/release.js +43 -31
- package/lib/deploy/firestore/deploy.js +10 -0
- package/lib/deploy/functions/backend.js +7 -1
- package/lib/deploy/functions/build.js +28 -14
- package/lib/deploy/functions/deploy.js +3 -2
- package/lib/deploy/functions/ensure.js +1 -1
- package/lib/deploy/functions/functionsDeployHelper.js +8 -1
- package/lib/deploy/functions/params.js +4 -0
- package/lib/deploy/functions/prepare.js +25 -13
- package/lib/deploy/functions/pricing.js +12 -5
- package/lib/deploy/functions/release/fabricator.js +25 -3
- package/lib/deploy/functions/release/reporter.js +1 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +52 -5
- package/lib/deploy/functions/runtimes/node/index.js +83 -51
- package/lib/emulator/auth/operations.js +10 -1
- package/lib/emulator/commandUtils.js +7 -1
- package/lib/emulator/controller.js +22 -34
- package/lib/emulator/dataconnectEmulator.js +27 -24
- package/lib/emulator/downloadableEmulatorInfo.json +18 -18
- package/lib/emulator/env.js +2 -1
- package/lib/emulator/functionsEmulator.js +12 -2
- package/lib/emulator/hub.js +11 -8
- package/lib/emulator/tasksEmulator.js +1 -1
- package/lib/emulator/ui.js +3 -1
- package/lib/env.js +18 -0
- package/lib/experiments.js +20 -0
- package/lib/extensions/extensionsHelper.js +4 -15
- package/lib/extensions/runtimes/common.js +3 -2
- package/lib/extensions/utils.js +1 -12
- package/lib/firestore/api-sort.js +96 -3
- package/lib/firestore/api-types.js +20 -1
- package/lib/firestore/api.js +144 -15
- package/lib/firestore/pretty-print.js +35 -1
- package/lib/firestore/validator.js +1 -1
- package/lib/functional.js +7 -1
- package/lib/functions/deprecationWarnings.js +21 -0
- package/lib/functions/env.js +31 -16
- package/lib/functions/projectConfig.js +87 -8
- package/lib/functions/secrets.js +3 -0
- package/lib/gcp/cloudfunctions.js +1 -6
- package/lib/gcp/cloudfunctionsv2.js +3 -39
- package/lib/gcp/cloudscheduler.js +1 -1
- package/lib/gcp/cloudsql/cloudsqladmin.js +4 -16
- package/lib/gcp/cloudsql/connect.js +4 -3
- package/lib/gcp/cloudsql/permissionsSetup.js +23 -16
- package/lib/gcp/k8s.js +32 -0
- package/lib/gcp/runv2.js +181 -0
- package/lib/gemini/fdcExperience.js +5 -3
- package/lib/init/features/aitools/claude.js +43 -0
- package/lib/init/features/aitools/cursor.js +61 -0
- package/lib/init/features/aitools/gemini.js +58 -0
- package/lib/init/features/aitools/index.js +28 -0
- package/lib/init/features/aitools/promptUpdater.js +111 -0
- package/lib/init/features/aitools/studio.js +17 -0
- package/lib/init/features/aitools/types.js +2 -0
- package/lib/init/features/aitools.js +83 -0
- package/lib/init/features/apptesting/index.js +34 -0
- package/lib/init/features/dataconnect/create_app.js +53 -0
- package/lib/init/features/dataconnect/index.js +280 -186
- package/lib/init/features/dataconnect/sdk.js +232 -144
- package/lib/init/features/index.js +8 -3
- package/lib/init/features/project.js +4 -0
- package/lib/init/index.js +18 -2
- package/lib/management/apps.js +3 -3
- package/lib/management/studio.js +120 -0
- package/lib/mcp/errors.js +5 -7
- package/lib/mcp/index.js +179 -61
- package/lib/mcp/logging-transport.js +23 -0
- package/lib/mcp/prompt.js +10 -0
- package/lib/mcp/prompts/core/deploy.js +101 -0
- package/lib/mcp/prompts/core/index.js +5 -0
- package/lib/mcp/prompts/crashlytics/connect.js +114 -0
- package/lib/mcp/prompts/crashlytics/index.js +5 -0
- package/lib/mcp/prompts/dataconnect/index.js +9 -0
- package/lib/mcp/prompts/dataconnect/schema.js +67 -0
- package/lib/mcp/prompts/index.js +47 -0
- package/lib/mcp/tools/apphosting/fetch_logs.js +22 -22
- package/lib/mcp/tools/apphosting/list_backends.js +10 -10
- package/lib/mcp/tools/auth/disable_user.js +7 -7
- package/lib/mcp/tools/auth/get_user.js +13 -6
- package/lib/mcp/tools/auth/index.js +10 -10
- package/lib/mcp/tools/auth/list_users.js +6 -6
- package/lib/mcp/tools/auth/set_claims.js +7 -7
- package/lib/mcp/tools/auth/set_sms_region_policy.js +6 -6
- package/lib/mcp/tools/core/consult_assistant.js +13 -8
- package/lib/mcp/tools/core/create_android_sha.js +9 -9
- package/lib/mcp/tools/core/create_app.js +7 -7
- package/lib/mcp/tools/core/create_project.js +13 -13
- package/lib/mcp/tools/core/get_admin_sdk_config.js +7 -7
- package/lib/mcp/tools/core/get_environment.js +8 -8
- package/lib/mcp/tools/core/get_project.js +5 -5
- package/lib/mcp/tools/core/get_sdk_config.js +19 -9
- package/lib/mcp/tools/core/index.js +28 -24
- package/lib/mcp/tools/core/init.js +39 -16
- package/lib/mcp/tools/core/list_apps.js +6 -6
- package/lib/mcp/tools/core/list_projects.js +6 -6
- package/lib/mcp/tools/core/login.js +46 -0
- package/lib/mcp/tools/core/logout.js +62 -0
- package/lib/mcp/tools/core/update_environment.js +10 -10
- package/lib/mcp/tools/crashlytics/add_note.js +32 -0
- package/lib/mcp/tools/crashlytics/constants.js +11 -0
- package/lib/mcp/tools/crashlytics/delete_note.js +35 -0
- package/lib/mcp/tools/crashlytics/get_issue_details.js +31 -0
- package/lib/mcp/tools/crashlytics/get_sample_crash.js +43 -0
- package/lib/mcp/tools/crashlytics/index.js +22 -2
- package/lib/mcp/tools/crashlytics/list_notes.js +37 -0
- package/lib/mcp/tools/crashlytics/list_top_devices.js +33 -0
- package/lib/mcp/tools/crashlytics/list_top_issues.js +12 -13
- package/lib/mcp/tools/crashlytics/list_top_operating_systems.js +33 -0
- package/lib/mcp/tools/crashlytics/list_top_versions.js +33 -0
- package/lib/mcp/tools/crashlytics/update_issue.js +37 -0
- package/lib/mcp/tools/database/get_data.js +49 -0
- package/lib/mcp/tools/database/get_rules.js +39 -0
- package/lib/mcp/tools/database/index.js +8 -0
- package/lib/mcp/tools/database/set_data.js +57 -0
- package/lib/mcp/tools/database/validate_rules.js +41 -0
- package/lib/mcp/tools/dataconnect/compile.js +43 -0
- package/lib/mcp/tools/dataconnect/execute.js +71 -0
- package/lib/mcp/tools/dataconnect/generate_operation.js +8 -8
- package/lib/mcp/tools/dataconnect/generate_schema.js +6 -6
- package/lib/mcp/tools/dataconnect/index.js +10 -18
- package/lib/mcp/tools/dataconnect/list_services.js +107 -11
- package/lib/mcp/tools/firestore/delete_document.js +13 -13
- package/lib/mcp/tools/firestore/get_documents.js +13 -13
- package/lib/mcp/tools/firestore/list_collections.js +7 -10
- package/lib/mcp/tools/firestore/query_collection.js +13 -13
- package/lib/mcp/tools/index.js +24 -18
- package/lib/mcp/tools/messaging/index.js +2 -2
- package/lib/mcp/tools/messaging/send_message.js +7 -7
- package/lib/mcp/tools/remoteconfig/get_template.js +5 -5
- package/lib/mcp/tools/remoteconfig/index.js +4 -4
- package/lib/mcp/tools/remoteconfig/publish_template.js +7 -7
- package/lib/mcp/tools/remoteconfig/rollback_template.js +6 -6
- package/lib/mcp/tools/rules/get_rules.js +8 -8
- package/lib/mcp/tools/rules/validate_rules.js +10 -10
- package/lib/mcp/tools/storage/get_download_url.js +8 -8
- package/lib/mcp/tools/storage/get_rules.js +8 -8
- package/lib/mcp/types.js +2 -0
- package/lib/mcp/util/dataconnect/compile.js +20 -0
- package/lib/mcp/util/dataconnect/content.js +655 -0
- package/lib/mcp/util/dataconnect/emulator.js +16 -0
- package/lib/mcp/util.js +5 -18
- package/lib/requireAuth.js +14 -4
- package/lib/rtdb.js +10 -6
- package/lib/scopes.js +2 -1
- package/lib/serve/functions.js +4 -3
- package/lib/timeout.js +21 -0
- package/lib/track.js +18 -1
- package/lib/unzip.js +13 -0
- package/lib/utils.js +76 -2
- package/package.json +5 -3
- package/prompts/FIREBASE.md +121 -0
- package/prompts/FIREBASE_FUNCTIONS.md +221 -0
- package/schema/apptesting-yaml.json +64 -0
- package/schema/firebase-config.json +163 -53
- package/templates/init/aitools/cursor-rules-header.txt +8 -0
- package/templates/init/aitools/gemini-extension.json +11 -0
- package/templates/init/apptesting/smoke_test.yaml +6 -0
- package/templates/init/dataconnect/connector.yaml +0 -16
- package/templates/init/dataconnect/dataconnect.yaml +2 -1
- package/templates/init/dataconnect/mutations.gql +29 -29
- package/templates/init/dataconnect/queries.gql +73 -73
- package/templates/init/dataconnect/schema.gql +48 -48
- package/templates/init/firestore/firestore.indexes.json +26 -1
- package/lib/dataconnect/fileUtils.js +0 -168
- package/lib/emulator/adminSdkConfig.test.js +0 -16
- package/lib/extensions/resolveSource.js +0 -23
- package/lib/firestore/api-sort.test.js +0 -74
- package/lib/firestore/backupUtils.test.js +0 -18
- package/lib/firestore/pretty-print.test.js +0 -61
- package/lib/firestore/util.test.js +0 -42
- package/lib/mcp/tools/dataconnect/emulator.js +0 -16
- package/lib/mcp/tools/dataconnect/execute_graphql.js +0 -48
- package/lib/mcp/tools/dataconnect/execute_graphql_read.js +0 -48
- package/lib/mcp/tools/dataconnect/execute_mutation.js +0 -62
- package/lib/mcp/tools/dataconnect/execute_query.js +0 -62
- package/lib/mcp/tools/dataconnect/get_connector.js +0 -31
- package/lib/mcp/tools/dataconnect/get_schema.js +0 -31
- /package/lib/mcp/{tools → util}/dataconnect/converter.js +0 -0
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Example queries for a simple movie app.
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
#
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
#
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
#
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
#
|
|
1
|
+
# Example schema for simple movie review app
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
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
|
-
#
|
|
15
|
-
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
#
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
#
|
|
28
|
-
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
#
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
});
|