diff --git a/docs/snippets/schemas/v3/app.schema.mdx b/docs/snippets/schemas/v3/app.schema.mdx index 7eabc79f..6d5e5a21 100644 --- a/docs/snippets/schemas/v3/app.schema.mdx +++ b/docs/snippets/schemas/v3/app.schema.mdx @@ -3,11 +3,9 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "AppConfig", - "oneOf": [ - { - "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "GitHubAppConfig": { "type": "object", - "title": "GithubAppConfig", "properties": { "type": { "const": "githubApp", @@ -61,19 +59,70 @@ }, "required": [ "type", - "id" + "id", + "privateKey" ], - "oneOf": [ - { - "required": [ - "privateKey" + "additionalProperties": false + } + }, + "oneOf": [ + { + "type": "object", + "properties": { + "type": { + "const": "githubApp", + "description": "GitHub App Configuration" + }, + "deploymentHostname": { + "type": "string", + "format": "hostname", + "default": "github.com", + "description": "The hostname of the GitHub App deployment.", + "examples": [ + "github.com", + "github.example.com" ] }, - { - "required": [ - "privateKeyPath" + "id": { + "type": "string", + "description": "The ID of the GitHub App." + }, + "privateKey": { + "description": "The private key of the GitHub App.", + "anyOf": [ + { + "type": "object", + "properties": { + "secret": { + "type": "string", + "description": "The name of the secret that contains the token." + } + }, + "required": [ + "secret" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "env": { + "type": "string", + "description": "The name of the environment variable that contains the token. Only supported in declarative connection configs." + } + }, + "required": [ + "env" + ], + "additionalProperties": false + } ] } + }, + "required": [ + "type", + "id", + "privateKey" ], "additionalProperties": false } diff --git a/docs/snippets/schemas/v3/index.schema.mdx b/docs/snippets/schemas/v3/index.schema.mdx index c79cd2b3..84c73bc5 100644 --- a/docs/snippets/schemas/v3/index.schema.mdx +++ b/docs/snippets/schemas/v3/index.schema.mdx @@ -4280,11 +4280,9 @@ "items": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "AppConfig", - "oneOf": [ - { - "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "GitHubAppConfig": { "type": "object", - "title": "GithubAppConfig", "properties": { "type": { "const": "githubApp", @@ -4338,19 +4336,70 @@ }, "required": [ "type", - "id" + "id", + "privateKey" ], - "oneOf": [ - { - "required": [ - "privateKey" + "additionalProperties": false + } + }, + "oneOf": [ + { + "type": "object", + "properties": { + "type": { + "const": "githubApp", + "description": "GitHub App Configuration" + }, + "deploymentHostname": { + "type": "string", + "format": "hostname", + "default": "github.com", + "description": "The hostname of the GitHub App deployment.", + "examples": [ + "github.com", + "github.example.com" ] }, - { - "required": [ - "privateKeyPath" - ] + "id": { + "type": "string", + "description": "The ID of the GitHub App." + }, + "privateKey": { + "anyOf": [ + { + "type": "object", + "properties": { + "secret": { + "type": "string", + "description": "The name of the secret that contains the token." + } + }, + "required": [ + "secret" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "env": { + "type": "string", + "description": "The name of the environment variable that contains the token. Only supported in declarative connection configs." + } + }, + "required": [ + "env" + ], + "additionalProperties": false + } + ], + "description": "The private key of the GitHub App." } + }, + "required": [ + "type", + "id", + "privateKey" ], "additionalProperties": false } diff --git a/packages/backend/src/ee/githubAppManager.ts b/packages/backend/src/ee/githubAppManager.ts index 1a76d117..2518c27b 100644 --- a/packages/backend/src/ee/githubAppManager.ts +++ b/packages/backend/src/ee/githubAppManager.ts @@ -5,6 +5,7 @@ import { createLogger } from "@sourcebot/logger"; import { getTokenFromConfig } from "../utils.js"; import { PrismaClient } from "@sourcebot/db"; import { App } from "@octokit/app"; +import { GitHubAppConfig } from "@sourcebot/schemas/v3/index.type"; const logger = createLogger('githubAppManager'); const GITHUB_DEFAULT_DEPLOYMENT_HOSTNAME = 'github.com'; diff --git a/packages/schemas/src/v3/app.schema.ts b/packages/schemas/src/v3/app.schema.ts index 5b4b96f7..87a7eb27 100644 --- a/packages/schemas/src/v3/app.schema.ts +++ b/packages/schemas/src/v3/app.schema.ts @@ -2,11 +2,9 @@ const schema = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "AppConfig", - "oneOf": [ - { - "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "GitHubAppConfig": { "type": "object", - "title": "GithubAppConfig", "properties": { "type": { "const": "githubApp", @@ -60,19 +58,70 @@ const schema = { }, "required": [ "type", - "id" + "id", + "privateKey" ], - "oneOf": [ - { - "required": [ - "privateKey" + "additionalProperties": false + } + }, + "oneOf": [ + { + "type": "object", + "properties": { + "type": { + "const": "githubApp", + "description": "GitHub App Configuration" + }, + "deploymentHostname": { + "type": "string", + "format": "hostname", + "default": "github.com", + "description": "The hostname of the GitHub App deployment.", + "examples": [ + "github.com", + "github.example.com" ] }, - { - "required": [ - "privateKeyPath" + "id": { + "type": "string", + "description": "The ID of the GitHub App." + }, + "privateKey": { + "description": "The private key of the GitHub App.", + "anyOf": [ + { + "type": "object", + "properties": { + "secret": { + "type": "string", + "description": "The name of the secret that contains the token." + } + }, + "required": [ + "secret" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "env": { + "type": "string", + "description": "The name of the environment variable that contains the token. Only supported in declarative connection configs." + } + }, + "required": [ + "env" + ], + "additionalProperties": false + } ] } + }, + "required": [ + "type", + "id", + "privateKey" ], "additionalProperties": false } diff --git a/packages/schemas/src/v3/app.type.ts b/packages/schemas/src/v3/app.type.ts index 255ef033..c087a759 100644 --- a/packages/schemas/src/v3/app.type.ts +++ b/packages/schemas/src/v3/app.type.ts @@ -1,6 +1,34 @@ // THIS IS A AUTO-GENERATED FILE. DO NOT MODIFY MANUALLY! -export type AppConfig = GithubAppConfig; -export type GithubAppConfig = { - [k: string]: unknown; -}; +export type AppConfig = GitHubAppConfig; + +export interface GitHubAppConfig { + /** + * GitHub App Configuration + */ + type: "githubApp"; + /** + * The hostname of the GitHub App deployment. + */ + deploymentHostname?: string; + /** + * The ID of the GitHub App. + */ + id: string; + /** + * The private key of the GitHub App. + */ + privateKey: + | { + /** + * The name of the secret that contains the token. + */ + secret: string; + } + | { + /** + * The name of the environment variable that contains the token. Only supported in declarative connection configs. + */ + env: string; + }; +} diff --git a/packages/schemas/src/v3/githubApp.schema.ts b/packages/schemas/src/v3/githubApp.schema.ts deleted file mode 100644 index aab0ef20..00000000 --- a/packages/schemas/src/v3/githubApp.schema.ts +++ /dev/null @@ -1,75 +0,0 @@ -// THIS IS A AUTO-GENERATED FILE. DO NOT MODIFY MANUALLY! -const schema = { - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "title": "GithubAppConfig", - "properties": { - "type": { - "const": "githubApp", - "description": "GitHub App Configuration" - }, - "deploymentHostname": { - "type": "string", - "format": "hostname", - "default": "github.com", - "description": "The hostname of the GitHub App deployment.", - "examples": [ - "github.com", - "github.example.com" - ] - }, - "id": { - "type": "string", - "description": "The ID of the GitHub App." - }, - "privateKey": { - "description": "The private key of the GitHub App.", - "anyOf": [ - { - "type": "object", - "properties": { - "secret": { - "type": "string", - "description": "The name of the secret that contains the token." - } - }, - "required": [ - "secret" - ], - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "env": { - "type": "string", - "description": "The name of the environment variable that contains the token. Only supported in declarative connection configs." - } - }, - "required": [ - "env" - ], - "additionalProperties": false - } - ] - } - }, - "required": [ - "type", - "id" - ], - "oneOf": [ - { - "required": [ - "privateKey" - ] - }, - { - "required": [ - "privateKeyPath" - ] - } - ], - "additionalProperties": false -} as const; -export { schema as githubAppSchema }; \ No newline at end of file diff --git a/packages/schemas/src/v3/githubApp.type.ts b/packages/schemas/src/v3/githubApp.type.ts deleted file mode 100644 index cd5af6af..00000000 --- a/packages/schemas/src/v3/githubApp.type.ts +++ /dev/null @@ -1,34 +0,0 @@ -// THIS IS A AUTO-GENERATED FILE. DO NOT MODIFY MANUALLY! - -export type GithubAppConfig = { - /** - * GitHub App Configuration - */ - type: "githubApp"; - /** - * The hostname of the GitHub App deployment. - */ - deploymentHostname?: string; - /** - * The ID of the GitHub App. - */ - id: string; - /** - * The private key of the GitHub App. - */ - privateKey?: - | { - /** - * The name of the secret that contains the token. - */ - secret: string; - } - | { - /** - * The name of the environment variable that contains the token. Only supported in declarative connection configs. - */ - env: string; - }; -} & { - [k: string]: unknown; -}; diff --git a/packages/schemas/src/v3/index.schema.ts b/packages/schemas/src/v3/index.schema.ts index c326e7b6..d5125c69 100644 --- a/packages/schemas/src/v3/index.schema.ts +++ b/packages/schemas/src/v3/index.schema.ts @@ -4279,11 +4279,9 @@ const schema = { "items": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "AppConfig", - "oneOf": [ - { - "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "GitHubAppConfig": { "type": "object", - "title": "GithubAppConfig", "properties": { "type": { "const": "githubApp", @@ -4337,19 +4335,70 @@ const schema = { }, "required": [ "type", - "id" + "id", + "privateKey" ], - "oneOf": [ - { - "required": [ - "privateKey" + "additionalProperties": false + } + }, + "oneOf": [ + { + "type": "object", + "properties": { + "type": { + "const": "githubApp", + "description": "GitHub App Configuration" + }, + "deploymentHostname": { + "type": "string", + "format": "hostname", + "default": "github.com", + "description": "The hostname of the GitHub App deployment.", + "examples": [ + "github.com", + "github.example.com" ] }, - { - "required": [ - "privateKeyPath" - ] + "id": { + "type": "string", + "description": "The ID of the GitHub App." + }, + "privateKey": { + "anyOf": [ + { + "type": "object", + "properties": { + "secret": { + "type": "string", + "description": "The name of the secret that contains the token." + } + }, + "required": [ + "secret" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "env": { + "type": "string", + "description": "The name of the environment variable that contains the token. Only supported in declarative connection configs." + } + }, + "required": [ + "env" + ], + "additionalProperties": false + } + ], + "description": "The private key of the GitHub App." } + }, + "required": [ + "type", + "id", + "privateKey" ], "additionalProperties": false } diff --git a/packages/schemas/src/v3/index.type.ts b/packages/schemas/src/v3/index.type.ts index 3d0b1947..53ae9533 100644 --- a/packages/schemas/src/v3/index.type.ts +++ b/packages/schemas/src/v3/index.type.ts @@ -25,10 +25,7 @@ export type LanguageModel = | OpenAICompatibleLanguageModel | OpenRouterLanguageModel | XaiLanguageModel; -export type AppConfig = GithubAppConfig; -export type GithubAppConfig = { - [k: string]: unknown; -}; +export type AppConfig = GitHubAppConfig; export interface SourcebotConfig { $schema?: string; @@ -1073,3 +1070,33 @@ export interface XaiLanguageModel { baseUrl?: string; headers?: LanguageModelHeaders; } +export interface GitHubAppConfig { + /** + * GitHub App Configuration + */ + type: "githubApp"; + /** + * The hostname of the GitHub App deployment. + */ + deploymentHostname?: string; + /** + * The ID of the GitHub App. + */ + id: string; + /** + * The private key of the GitHub App. + */ + privateKey: + | { + /** + * The name of the secret that contains the token. + */ + secret: string; + } + | { + /** + * The name of the environment variable that contains the token. Only supported in declarative connection configs. + */ + env: string; + }; +} diff --git a/schemas/v3/app.json b/schemas/v3/app.json index 00703326..2fadfef4 100644 --- a/schemas/v3/app.json +++ b/schemas/v3/app.json @@ -1,9 +1,44 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "AppConfig", + "definitions": { + "GitHubAppConfig": { + "type": "object", + "properties": { + "type": { + "const": "githubApp", + "description": "GitHub App Configuration" + }, + "deploymentHostname": { + "type": "string", + "format": "hostname", + "default": "github.com", + "description": "The hostname of the GitHub App deployment.", + "examples": [ + "github.com", + "github.example.com" + ] + }, + "id": { + "type": "string", + "description": "The ID of the GitHub App." + }, + "privateKey": { + "$ref": "./shared.json#/definitions/Token", + "description": "The private key of the GitHub App." + } + }, + "required": [ + "type", + "id", + "privateKey" + ], + "additionalProperties": false + } + }, "oneOf": [ { - "$ref": "./githubApp.json" + "$ref": "#/definitions/GitHubAppConfig" } ] } \ No newline at end of file diff --git a/schemas/v3/githubApp.json b/schemas/v3/githubApp.json deleted file mode 100644 index c83553ce..00000000 --- a/schemas/v3/githubApp.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "title": "GithubAppConfig", - "properties": { - "type": { - "const": "githubApp", - "description": "GitHub App Configuration" - }, - "deploymentHostname": { - "type": "string", - "format": "hostname", - "default": "github.com", - "description": "The hostname of the GitHub App deployment.", - "examples": [ - "github.com", - "github.example.com" - ] - }, - "id": { - "type": "string", - "description": "The ID of the GitHub App." - }, - "privateKey": { - "$ref": "./shared.json#/definitions/Token", - "description": "The private key of the GitHub App." - } - }, - "required": [ - "type", - "id" - ], - "oneOf": [ - { - "required": ["privateKey"] - }, - { - "required": ["privateKeyPath"] - } - ], - "additionalProperties": false -} \ No newline at end of file