sourcegraph/internal/database/BUILD.bazel
Quinn Slack b4e03f45b0
Prompt Library (#63872)
The Prompt Library lets you create, share, and browse chat prompts for
use with Cody. Prompts are owned by users or organizations, and site
admins can make prompts public so that all users on the instance can see
and use them.

A prompt is just plain text for now, and you can see a list of prompts
in your Prompt Library from within Cody chat
(https://github.com/sourcegraph/cody/pull/4903).

See https://www.loom.com/share/f3124269300c481ebfcbd0a1e300be1b.

Depends on https://github.com/sourcegraph/cody/pull/4903.


![image](https://github.com/user-attachments/assets/d1098809-f7ff-4233-8ecb-9bc53ad4dbb2)


## Test plan

Add a prompt on the web. Ensure you can access it from Cody.

## Changelog

- The Prompt Library lets you create, share, and browse chat prompts for
use with Cody. Prompts are owned by users or organizations, and site
admins can make prompts public so that all users on the instance can see
and use them. To use a prompt from your Prompt Library in Cody, select
it in the **Prompts** dropdown in the Cody chat message field.
2024-07-18 16:04:55 -07:00

376 lines
12 KiB
Python

load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//dev:migrations.bzl", "generate_schemas")
load("//dev:write_generated_to_source_files.bzl", "write_generated_to_source_files")
go_library(
name = "database",
srcs = [
"access_requests.go",
"access_tokens.go",
"assigned_owners.go",
"assigned_teams.go",
"authenticator.go",
"authz.go",
"bitbucket_project_permissions.go",
"code_hosts.go",
"code_monitor_action_jobs.go",
"code_monitor_emails.go",
"code_monitor_last_searched.go",
"code_monitor_monitors.go",
"code_monitor_queries.go",
"code_monitor_recipients.go",
"code_monitor_slack_webhook.go",
"code_monitor_trigger_jobs.go",
"code_monitor_webhook.go",
"code_monitors.go",
"codeowners.go",
"conf.go",
"database.go",
"doc.go",
"errors.go",
"event_logs.go",
"event_logs_scrape_state_own.go",
"executor_secret_access_logs.go",
"executor_secrets.go",
"executors.go",
"external_accounts.go",
"external_services.go",
"feature_flags.go",
"gitserver_repos.go",
"global_state.go",
"helpers.go",
"insights.go",
"mockerr.go",
"namespace_permissions.go",
"namespaces.go",
"org_invitations.go",
"org_members.go",
"orgs.go",
"outbound_webhook_jobs.go",
"outbound_webhook_logs.go",
"outbound_webhooks.go",
"own_signal_configurations.go",
"ownership_stats.go",
"permission_sync_code_host_state.go",
"permission_sync_jobs.go",
"permissions.go",
"perms_store.go",
"phabricator.go",
"prompts.go",
"recent_contribution_signal.go",
"recent_view_signal.go",
"redis_key_value.go",
"repo_commits_changelists.go",
"repo_kvps.go",
"repo_paths.go",
"repo_statistics.go",
"repos.go",
"repos_perm.go",
"role_permissions.go",
"roles.go",
"saved_searches.go",
"search_contexts.go",
"security_event_logs.go",
"settings.go",
"sub_repo_perms_store.go",
"survey_responses.go",
"teams.go",
"telemetry_export_store.go",
"temporary_settings.go",
"user_credentials.go",
"user_emails.go",
"user_roles.go",
"users.go",
"webhook_logs.go",
"webhooks.go",
"zoekt_repos.go",
],
importpath = "github.com/sourcegraph/sourcegraph/internal/database",
visibility = ["//:__subpackages__"],
deps = [
"//internal/accesstoken",
"//internal/actor",
"//internal/api",
"//internal/audit",
"//internal/authz",
"//internal/collections",
"//internal/conf",
"//internal/conf/confdefaults",
"//internal/conf/conftypes",
"//internal/conf/reposource",
"//internal/database/basestore",
"//internal/database/batch",
"//internal/database/dbconn",
"//internal/database/dbtest",
"//internal/database/dbutil",
"//internal/dotcom",
"//internal/encryption",
"//internal/encryption/keyring",
"//internal/env",
"//internal/errcode",
"//internal/eventlogger",
"//internal/executor",
"//internal/extsvc",
"//internal/extsvc/auth",
"//internal/extsvc/awscodecommit",
"//internal/extsvc/azuredevops",
"//internal/extsvc/bitbucketcloud",
"//internal/extsvc/bitbucketserver",
"//internal/extsvc/gerrit",
"//internal/extsvc/github",
"//internal/extsvc/gitlab",
"//internal/extsvc/gitolite",
"//internal/extsvc/pagure",
"//internal/extsvc/perforce",
"//internal/extsvc/phabricator",
"//internal/featureflag",
"//internal/github_apps/auth",
"//internal/github_apps/store",
"//internal/hashutil",
"//internal/jsonc",
"//internal/lazyregexp",
"//internal/licensing",
"//internal/own/codeowners/v1:codeowners",
"//internal/own/types",
"//internal/perforce",
"//internal/randstring",
"//internal/ratelimit",
"//internal/rbac/types",
"//internal/search/result",
"//internal/security",
"//internal/telemetry/sensitivemetadataallowlist",
"//internal/temporarysettings",
"//internal/timeutil",
"//internal/trace",
"//internal/types",
"//internal/version",
"//lib/errors",
"//lib/pointers",
"//lib/telemetrygateway/v1:telemetrygateway",
"//schema",
"@com_github_gofrs_uuid//:uuid",
"@com_github_google_uuid//:uuid",
"@com_github_grafana_regexp//:regexp",
"@com_github_grafana_regexp//syntax",
"@com_github_graph_gophers_graphql_go//:graphql-go",
"@com_github_graph_gophers_graphql_go//relay",
"@com_github_jackc_pgconn//:pgconn",
"@com_github_json_iterator_go//:go",
"@com_github_keegancsmith_sqlf//:sqlf",
"@com_github_lib_pq//:pq",
"@com_github_prometheus_client_golang//prometheus",
"@com_github_prometheus_client_golang//prometheus/promauto",
"@com_github_sourcegraph_log//:log",
"@com_github_sourcegraph_log//logtest",
"@com_github_sourcegraph_zoekt//:zoekt",
"@com_github_stretchr_testify//require",
"@com_github_tidwall_gjson//:gjson",
"@com_github_xeipuuv_gojsonschema//:gojsonschema",
"@io_opentelemetry_go_otel//attribute",
"@org_golang_google_protobuf//proto",
"@org_golang_x_crypto//bcrypt",
"@org_golang_x_sync//errgroup",
"@org_golang_x_time//rate",
],
)
go_test(
name = "database_test",
size = "enormous",
timeout = "long",
srcs = [
"access_requests_test.go",
"access_tokens_test.go",
"assigned_owners_test.go",
"assigned_teams_test.go",
"authenticator_test.go",
"authz_test.go",
"bitbucket_project_permissions_test.go",
"code_hosts_test.go",
"code_monitor_action_jobs_test.go",
"code_monitor_emails_test.go",
"code_monitor_last_searched_test.go",
"code_monitor_queries_test.go",
"code_monitor_recipient_test.go",
"code_monitor_slack_webhook_test.go",
"code_monitor_test.go",
"code_monitor_trigger_jobs_test.go",
"code_monitor_webhook_test.go",
"codeowners_test.go",
"conf_test.go",
"database_test.go",
"dbstore_db_test.go",
"err_test.go",
"errors_test.go",
"event_logs_test.go",
"executor_secret_access_logs_test.go",
"executor_secrets_internal_test.go",
"executor_secrets_test.go",
"executors_test.go",
"external_accounts_test.go",
"external_services_external_test.go",
"external_services_test.go",
"feature_flags_test.go",
"gitserver_repos_test.go",
"global_state_test.go",
"helpers_test.go",
"main_test.go",
"namespace_permissions_test.go",
"namespaces_test.go",
"org_invitations_test.go",
"org_members_db_test.go",
"orgs_test.go",
"outbound_webhook_jobs_test.go",
"outbound_webhook_logs_test.go",
"outbound_webhooks_test.go",
"own_signal_configurations_test.go",
"ownership_stats_test.go",
"permission_sync_code_host_state_test.go",
"permission_sync_jobs_test.go",
"permissions_test.go",
"perms_store_test.go",
"phabricator_test.go",
"prompts_test.go",
"recent_contribution_signal_test.go",
"recent_view_signal_test.go",
"redis_key_value_test.go",
"repo_commits_changelists_test.go",
"repo_kvps_test.go",
"repo_paths_test.go",
"repo_statistics_test.go",
"repos_perm_test.go",
"repos_test.go",
"role_permissions_test.go",
"roles_test.go",
"saved_searches_test.go",
"search_contexts_test.go",
"security_event_logs_test.go",
"settings_test.go",
"sub_repo_perms_store_test.go",
"survey_responses_test.go",
"teams_test.go",
"telemetry_export_store_test.go",
"temporary_settings_test.go",
"user_credentials_test.go",
"user_emails_test.go",
"user_roles_test.go",
"users_builtin_auth_test.go",
"users_test.go",
"util_test.go",
"webhook_logs_test.go",
"webhooks_test.go",
"zoekt_repos_test.go",
],
embed = [":database"],
tags = [
# Test requires localhost database
"requires-network",
],
deps = [
"//internal/actor",
"//internal/api",
"//internal/authz",
"//internal/conf",
"//internal/database/basestore",
"//internal/database/batch",
"//internal/database/dbmocks",
"//internal/database/dbtest",
"//internal/database/dbutil",
"//internal/dotcom",
"//internal/encryption",
"//internal/encryption/keyring",
"//internal/encryption/testing",
"//internal/errcode",
"//internal/executor",
"//internal/extsvc",
"//internal/extsvc/auth",
"//internal/extsvc/bitbucketserver",
"//internal/extsvc/github",
"//internal/extsvc/gitlab",
"//internal/featureflag",
"//internal/github_apps/auth",
"//internal/github_apps/types",
"//internal/jsonc",
"//internal/licensing",
"//internal/own/codeowners/v1:codeowners",
"//internal/own/types",
"//internal/perforce",
"//internal/rbac/types",
"//internal/search/result",
"//internal/temporarysettings",
"//internal/timeutil",
"//internal/trace",
"//internal/trace/tracetest",
"//internal/types",
"//internal/types/typestest",
"//internal/version",
"//lib/errors",
"//lib/pointers",
"//lib/telemetrygateway/v1:telemetrygateway",
"//schema",
"@com_github_cockroachdb_errors//errbase",
"@com_github_gitchander_permutation//:permutation",
"@com_github_gomodule_oauth1//oauth",
"@com_github_google_go_cmp//cmp",
"@com_github_google_go_cmp//cmp/cmpopts",
"@com_github_google_uuid//:uuid",
"@com_github_graph_gophers_graphql_go//relay",
"@com_github_hexops_autogold_v2//:autogold",
"@com_github_jackc_pgconn//:pgconn",
"@com_github_keegancsmith_sqlf//:sqlf",
"@com_github_lib_pq//:pq",
"@com_github_sourcegraph_log//:log",
"@com_github_sourcegraph_log//logtest",
"@com_github_sourcegraph_zoekt//:zoekt",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
"@org_golang_google_protobuf//proto",
"@org_golang_google_protobuf//testing/protocmp",
"@org_golang_google_protobuf//types/known/structpb",
"@org_golang_google_protobuf//types/known/timestamppb",
"@org_golang_x_exp//maps",
"@org_golang_x_sync//errgroup",
],
)
generate_schemas(
name = "generate_schemas",
srcs = [
"//migrations/codeinsights:sql",
"//migrations/codeintel:sql",
"//migrations/frontend:sql",
],
out_codeinsights_schema = "_schema.codeinsights.json",
out_codeinsights_schema_md = "_schema.codeinsights.md",
out_codeinsights_squash = "_codeinsights_squashed.sql",
out_codeintel_schema = "_schema.codeintel.json",
out_codeintel_schema_md = "_schema.codeintel.md",
out_codeintel_squash = "_codeintel_squashed.sql",
out_frontend_schema = "_schema.json",
out_frontend_schema_md = "_schema.md",
out_frontend_squash = "_frontend_squashed.sql",
visibility = ["//visibility:public"],
)
write_generated_to_source_files(
name = "write_schemas",
output_files = {
"schema.json": "_schema.json",
"schema.codeintel.json": "_schema.codeintel.json",
"schema.codeinsights.json": "_schema.codeinsights.json",
"schema.md": "_schema.md",
"schema.codeintel.md": "_schema.codeintel.md",
"schema.codeinsights.md": "_schema.codeinsights.md",
},
target = ":generate_schemas",
)
exports_files(
srcs = [
"schema.codeinsights.json",
"schema.codeintel.json",
"schema.json",
],
)