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: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
privateKey:
| {
/**
* 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,12 +8,19 @@ export interface AzureDevOpsConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token:
| {
/**
* 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,12 +12,19 @@ export interface BitbucketConnectionConfig {
/**
* An authentication token.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +17,19 @@ export interface GithubConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +106,19 @@ export interface GitlabConnectionConfig {
/**
* An authentication token.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +177,19 @@ export interface GiteaConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +263,19 @@ export interface BitbucketConnectionConfig {
/**
* An authentication token.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +320,19 @@ export interface AzureDevOpsConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token:
| {
/**
* 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,12 +8,19 @@ export interface GiteaConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +8,19 @@ export interface GithubConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +8,19 @@ export interface GitlabConnectionConfig {
/**
* An authentication token.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +155,19 @@ export interface GithubConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +244,19 @@ export interface GitlabConnectionConfig {
/**
* An authentication token.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +315,19 @@ export interface GiteaConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +401,19 @@ export interface BitbucketConnectionConfig {
/**
* An authentication token.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +458,19 @@ export interface AzureDevOpsConnectionConfig {
/**
* A Personal Access Token (PAT).
*/
token: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token:
| {
/**
* 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,30 +551,51 @@ export interface AmazonBedrockLanguageModel {
/**
* Optional access key ID to use with the model. Defaults to the `AWS_ACCESS_KEY_ID` environment variable.
*/
accessKeyId?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
accessKeyId?:
| {
/**
* 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?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
accessKeySecret?:
| {
/**
* 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?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
sessionToken?:
| {
/**
* 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.
*/
env: string;
};
| (
| {
/**
* 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,12 +647,19 @@ export interface AnthropicLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +686,19 @@ export interface AzureLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `AZURE_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +725,19 @@ export interface DeepSeekLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `DEEPSEEK_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +760,19 @@ export interface GoogleGenerativeAILanguageModel {
/**
* Optional API key to use with the model. Defaults to the `GOOGLE_GENERATIVE_AI_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +803,19 @@ export interface GoogleVertexAnthropicLanguageModel {
/**
* Optional file path to service account credentials JSON. Defaults to the `GOOGLE_APPLICATION_CREDENTIALS` environment variable or application default credentials.
*/
credentials?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
credentials?:
| {
/**
* 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,12 +846,19 @@ export interface GoogleVertexLanguageModel {
/**
* Optional file path to service account credentials JSON. Defaults to the `GOOGLE_APPLICATION_CREDENTIALS` environment variable or application default credentials.
*/
credentials?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
credentials?:
| {
/**
* 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,12 +881,19 @@ export interface MistralLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `MISTRAL_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +916,19 @@ export interface OpenAILanguageModel {
/**
* Optional API key to use with the model. Defaults to the `OPENAI_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +955,19 @@ export interface OpenAICompatibleLanguageModel {
/**
* Optional API key. If specified, adds an `Authorization` header to request headers with the value Bearer <token>.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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.
*/
env: string;
};
| (
| {
/**
* 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,12 +1020,19 @@ export interface OpenRouterLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `OPENROUTER_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +1055,19 @@ export interface XaiLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `XAI_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
privateKey:
| {
/**
* 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,30 +30,51 @@ export interface AmazonBedrockLanguageModel {
/**
* Optional access key ID to use with the model. Defaults to the `AWS_ACCESS_KEY_ID` environment variable.
*/
accessKeyId?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
accessKeyId?:
| {
/**
* 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?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
accessKeySecret?:
| {
/**
* 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?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
sessionToken?:
| {
/**
* 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.
*/
env: string;
};
| (
| {
/**
* 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,12 +126,19 @@ export interface AnthropicLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +165,19 @@ export interface AzureLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `AZURE_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +204,19 @@ export interface DeepSeekLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `DEEPSEEK_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +239,19 @@ export interface GoogleGenerativeAILanguageModel {
/**
* Optional API key to use with the model. Defaults to the `GOOGLE_GENERATIVE_AI_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +282,19 @@ export interface GoogleVertexAnthropicLanguageModel {
/**
* Optional file path to service account credentials JSON. Defaults to the `GOOGLE_APPLICATION_CREDENTIALS` environment variable or application default credentials.
*/
credentials?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
credentials?:
| {
/**
* 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,12 +325,19 @@ export interface GoogleVertexLanguageModel {
/**
* Optional file path to service account credentials JSON. Defaults to the `GOOGLE_APPLICATION_CREDENTIALS` environment variable or application default credentials.
*/
credentials?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
credentials?:
| {
/**
* 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,12 +360,19 @@ export interface MistralLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `MISTRAL_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +395,19 @@ export interface OpenAILanguageModel {
/**
* Optional API key to use with the model. Defaults to the `OPENAI_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +434,19 @@ export interface OpenAICompatibleLanguageModel {
/**
* Optional API key. If specified, adds an `Authorization` header to request headers with the value Bearer <token>.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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.
*/
env: string;
};
| (
| {
/**
* 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,12 +499,19 @@ export interface OpenRouterLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `OPENROUTER_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +534,19 @@ export interface XaiLanguageModel {
/**
* Optional API key to use with the model. Defaults to the `XAI_API_KEY` environment variable.
*/
token?: {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
token?:
| {
/**
* 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,12 +4,19 @@
* This interface was referenced by `Shared`'s JSON-Schema
* via the `definition` "Token".
*/
export type Token = {
/**
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
*/
env: string;
};
export type Token =
| {
/**
* 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 {
[k: string]: unknown;

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
}
]
},