This commit is contained in:
bkellam 2025-11-01 16:45:09 -07:00
parent 7e161e6df3
commit 9c73f12627
34 changed files with 4329 additions and 563 deletions

View file

@ -33,13 +33,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
}
@ -82,13 +95,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
}

View file

@ -17,13 +17,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},

View file

@ -21,13 +21,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},

View file

@ -21,13 +21,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},
@ -216,13 +229,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},
@ -405,13 +431,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},
@ -659,13 +698,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},
@ -814,13 +866,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},

View file

@ -17,13 +17,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},

View file

@ -17,13 +17,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},

View file

@ -17,13 +17,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -11,13 +11,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},
@ -78,13 +91,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
}
@ -109,13 +135,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
}

View file

@ -8,6 +8,7 @@
"postinstall": "yarn build"
},
"dependencies": {
"@google-cloud/secret-manager": "^6.1.1",
"@sourcebot/db": "*",
"@sourcebot/schemas": "*",
"dotenv": "^16.4.5"

View file

@ -1,4 +1,5 @@
import { Token } from "@sourcebot/schemas/v3/shared.type";
import { SecretManagerServiceClient } from "@google-cloud/secret-manager";
export const getTokenFromConfig = async (token: Token) => {
if ('env' in token) {
@ -8,6 +9,23 @@ export const getTokenFromConfig = async (token: Token) => {
}
return envToken;
} else if ('gcpSecretName' in token) {
try {
const client = new SecretManagerServiceClient();
const [ response ] = await client.accessSecretVersion({
name: token.gcpSecretName,
});
if (!response.payload?.data) {
throw new Error(`Secret ${token.gcpSecretName} not found.`);
}
return response.payload.data.toString();
} catch (error) {
console.log("HERE IN THE EXCEPTION HANDLER");
throw error;
}
} else {
throw new Error('Invalid token configuration');
}

View file

@ -32,13 +32,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
}
@ -81,13 +94,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
}

View file

@ -18,10 +18,17 @@ export interface GitHubAppConfig {
/**
* The private key of the GitHub App.
*/
privateKey: {
privateKey:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
}

View file

@ -16,13 +16,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},

View file

@ -8,11 +8,18 @@ export interface AzureDevOpsConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token: {
token:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The URL of the Azure DevOps host. For Azure DevOps Cloud, use https://dev.azure.com. For Azure DevOps Server, use your server URL.

View file

@ -20,13 +20,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},

View file

@ -12,11 +12,18 @@ export interface BitbucketConnectionConfig {
/**
* An authentication token.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Bitbucket URL

View file

@ -20,13 +20,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},
@ -215,13 +228,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},
@ -404,13 +430,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},
@ -658,13 +697,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},
@ -813,13 +865,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},

View file

@ -17,11 +17,18 @@ export interface GithubConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The URL of the GitHub host. Defaults to https://github.com
@ -99,11 +106,18 @@ export interface GitlabConnectionConfig {
/**
* An authentication token.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The URL of the GitLab host. Defaults to https://gitlab.com
@ -163,11 +177,18 @@ export interface GiteaConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The URL of the Gitea host. Defaults to https://gitea.com
@ -242,11 +263,18 @@ export interface BitbucketConnectionConfig {
/**
* An authentication token.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Bitbucket URL
@ -292,11 +320,18 @@ export interface AzureDevOpsConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token: {
token:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The URL of the Azure DevOps host. For Azure DevOps Cloud, use https://dev.azure.com. For Azure DevOps Server, use your server URL.

View file

@ -16,13 +16,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},

View file

@ -8,11 +8,18 @@ export interface GiteaConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The URL of the Gitea host. Defaults to https://gitea.com

View file

@ -16,13 +16,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},

View file

@ -8,11 +8,18 @@ export interface GithubConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The URL of the GitHub host. Defaults to https://github.com

View file

@ -16,13 +16,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},

View file

@ -8,11 +8,18 @@ export interface GitlabConnectionConfig {
/**
* An authentication token.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The URL of the GitLab host. Defaults to https://gitlab.com

File diff suppressed because it is too large Load diff

View file

@ -155,11 +155,18 @@ export interface GithubConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The URL of the GitHub host. Defaults to https://github.com
@ -237,11 +244,18 @@ export interface GitlabConnectionConfig {
/**
* An authentication token.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The URL of the GitLab host. Defaults to https://gitlab.com
@ -301,11 +315,18 @@ export interface GiteaConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The URL of the Gitea host. Defaults to https://gitea.com
@ -380,11 +401,18 @@ export interface BitbucketConnectionConfig {
/**
* An authentication token.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Bitbucket URL
@ -430,11 +458,18 @@ export interface AzureDevOpsConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token: {
token:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The URL of the Azure DevOps host. For Azure DevOps Cloud, use https://dev.azure.com. For Azure DevOps Server, use your server URL.
@ -516,29 +551,50 @@ export interface AmazonBedrockLanguageModel {
/**
* Optional access key ID to use with the model. Defaults to the `AWS_ACCESS_KEY_ID` environment variable.
*/
accessKeyId?: {
accessKeyId?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional secret access key to use with the model. Defaults to the `AWS_SECRET_ACCESS_KEY` environment variable.
*/
accessKeySecret?: {
accessKeySecret?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.
*/
sessionToken?: {
sessionToken?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The AWS region. Defaults to the `AWS_REGION` environment variable.
@ -560,12 +616,20 @@ export interface LanguageModelHeaders {
*/
[k: string]:
| string
| (
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
};
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
}
);
}
export interface AnthropicLanguageModel {
/**
@ -583,11 +647,18 @@ export interface AnthropicLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -615,11 +686,18 @@ export interface AzureLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `AZURE_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Sets a custom api version. Defaults to `preview`.
@ -647,11 +725,18 @@ export interface DeepSeekLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `DEEPSEEK_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -675,11 +760,18 @@ export interface GoogleGenerativeAILanguageModel {
/**
* Optional API key to use with the model. Defaults to the `GOOGLE_GENERATIVE_AI_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -711,11 +803,18 @@ export interface GoogleVertexAnthropicLanguageModel {
/**
* Optional file path to service account credentials JSON. Defaults to the `GOOGLE_APPLICATION_CREDENTIALS` environment variable or application default credentials.
*/
credentials?: {
credentials?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -747,11 +846,18 @@ export interface GoogleVertexLanguageModel {
/**
* Optional file path to service account credentials JSON. Defaults to the `GOOGLE_APPLICATION_CREDENTIALS` environment variable or application default credentials.
*/
credentials?: {
credentials?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -775,11 +881,18 @@ export interface MistralLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `MISTRAL_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -803,11 +916,18 @@ export interface OpenAILanguageModel {
/**
* Optional API key to use with the model. Defaults to the `OPENAI_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -835,11 +955,18 @@ export interface OpenAICompatibleLanguageModel {
/**
* Optional API key. If specified, adds an `Authorization` header to request headers with the value Bearer <token>.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Base URL of the OpenAI-compatible chat completions API endpoint.
@ -862,12 +989,20 @@ export interface LanguageModelQueryParams {
*/
[k: string]:
| string
| (
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
};
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
}
);
}
export interface OpenRouterLanguageModel {
/**
@ -885,11 +1020,18 @@ export interface OpenRouterLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `OPENROUTER_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -913,11 +1055,18 @@ export interface XaiLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `XAI_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -941,10 +1090,17 @@ export interface GitHubAppConfig {
/**
* The private key of the GitHub App.
*/
privateKey: {
privateKey:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
}

File diff suppressed because it is too large Load diff

View file

@ -30,29 +30,50 @@ export interface AmazonBedrockLanguageModel {
/**
* Optional access key ID to use with the model. Defaults to the `AWS_ACCESS_KEY_ID` environment variable.
*/
accessKeyId?: {
accessKeyId?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional secret access key to use with the model. Defaults to the `AWS_SECRET_ACCESS_KEY` environment variable.
*/
accessKeySecret?: {
accessKeySecret?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.
*/
sessionToken?: {
sessionToken?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* The AWS region. Defaults to the `AWS_REGION` environment variable.
@ -74,12 +95,20 @@ export interface LanguageModelHeaders {
*/
[k: string]:
| string
| (
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
};
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
}
);
}
export interface AnthropicLanguageModel {
/**
@ -97,11 +126,18 @@ export interface AnthropicLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -129,11 +165,18 @@ export interface AzureLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `AZURE_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Sets a custom api version. Defaults to `preview`.
@ -161,11 +204,18 @@ export interface DeepSeekLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `DEEPSEEK_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -189,11 +239,18 @@ export interface GoogleGenerativeAILanguageModel {
/**
* Optional API key to use with the model. Defaults to the `GOOGLE_GENERATIVE_AI_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -225,11 +282,18 @@ export interface GoogleVertexAnthropicLanguageModel {
/**
* Optional file path to service account credentials JSON. Defaults to the `GOOGLE_APPLICATION_CREDENTIALS` environment variable or application default credentials.
*/
credentials?: {
credentials?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -261,11 +325,18 @@ export interface GoogleVertexLanguageModel {
/**
* Optional file path to service account credentials JSON. Defaults to the `GOOGLE_APPLICATION_CREDENTIALS` environment variable or application default credentials.
*/
credentials?: {
credentials?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -289,11 +360,18 @@ export interface MistralLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `MISTRAL_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -317,11 +395,18 @@ export interface OpenAILanguageModel {
/**
* Optional API key to use with the model. Defaults to the `OPENAI_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -349,11 +434,18 @@ export interface OpenAICompatibleLanguageModel {
/**
* Optional API key. If specified, adds an `Authorization` header to request headers with the value Bearer <token>.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Base URL of the OpenAI-compatible chat completions API endpoint.
@ -376,12 +468,20 @@ export interface LanguageModelQueryParams {
*/
[k: string]:
| string
| (
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
};
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
}
);
}
export interface OpenRouterLanguageModel {
/**
@ -399,11 +499,18 @@ export interface OpenRouterLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `OPENROUTER_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.
@ -427,11 +534,18 @@ export interface XaiLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `XAI_API_KEY` environment variable.
*/
token?: {
token?:
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
/**
* Optional base URL.

View file

@ -10,13 +10,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},
@ -77,13 +90,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
}
@ -108,13 +134,26 @@ const schema = {
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
}

View file

@ -4,11 +4,18 @@
* This interface was referenced by `Shared`'s JSON-Schema
* via the `definition` "Token".
*/
export type Token = {
export type Token =
| {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
* The name of the environment variable that contains the token.
*/
env: string;
}
| {
/**
* The name of the GCP secret that contains the token.
*/
gcpSecretName: string;
};
export interface Shared {

View file

@ -4,12 +4,12 @@ import { getAuditService } from "@/ee/features/audit/factory";
import { env } from "@/env.mjs";
import { addUserToOrganization, orgHasAvailability } from "@/lib/authUtils";
import { ErrorCode } from "@/lib/errorCodes";
import { notAuthenticated, notFound, orgNotFound, secretAlreadyExists, ServiceError, ServiceErrorException, unexpectedError } from "@/lib/serviceError";
import { notAuthenticated, notFound, orgNotFound, ServiceError, ServiceErrorException, unexpectedError } from "@/lib/serviceError";
import { getOrgMetadata, isHttpError, isServiceError } from "@/lib/utils";
import { prisma } from "@/prisma";
import { render } from "@react-email/components";
import * as Sentry from '@sentry/nextjs';
import { encrypt, generateApiKey, getTokenFromConfig, hashSecret } from "@sourcebot/crypto";
import { generateApiKey, getTokenFromConfig, hashSecret } from "@sourcebot/crypto";
import { ApiKey, ConnectionSyncJobStatus, Org, OrgRole, Prisma, RepoIndexingJobStatus, RepoIndexingJobType, StripeSubscriptionStatus } from "@sourcebot/db";
import { createLogger } from "@sourcebot/logger";
import { GiteaConnectionConfig } from "@sourcebot/schemas/v3/gitea.type";

View file

@ -9,13 +9,26 @@
"properties": {
"env": {
"type": "string",
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
"description": "The name of the environment variable that contains the token."
}
},
"required": [
"env"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"gcpSecretName": {
"type": "string",
"description": "The name of the GCP secret that contains the token."
}
},
"required": [
"gcpSecretName"
],
"additionalProperties": false
}
]
},