@codraoss/api 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,138 @@
1
+ import * as hono_types from 'hono/types';
2
+ import { Hono } from 'hono';
3
+ import { SessionStore, ReviewRuntime, DashboardSessionUser } from '@codraoss/core/ports';
4
+ import * as dbAccounts from '@codraoss/db/accounts';
5
+ import * as dbJobs from '@codraoss/db/jobs';
6
+ import * as dbFileReviews from '@codraoss/db/file-reviews';
7
+ import * as dbCommentFeedback from '@codraoss/db/comment-feedback';
8
+ import * as dbModelConfigs from '@codraoss/db/model-configs';
9
+ import * as dbRepoConfigs from '@codraoss/db/repo-configs';
10
+ import * as dbAppSettings from '@codraoss/db/app-settings';
11
+ import * as dbStats from '@codraoss/db/stats';
12
+ import * as dbWebhookDeliveries from '@codraoss/db/webhook-deliveries';
13
+
14
+ interface RepositoriesPort {
15
+ accounts: typeof dbAccounts;
16
+ jobs: typeof dbJobs;
17
+ fileReviews: typeof dbFileReviews;
18
+ commentFeedback: typeof dbCommentFeedback;
19
+ modelConfigs: typeof dbModelConfigs;
20
+ repoConfigs: typeof dbRepoConfigs;
21
+ appSettings: typeof dbAppSettings;
22
+ stats: typeof dbStats;
23
+ webhookDeliveries: typeof dbWebhookDeliveries;
24
+ }
25
+ interface ConfigPort {
26
+ getGlobalConfig: () => Promise<any>;
27
+ updateGlobalConfig: (config: any) => Promise<void>;
28
+ loadRepoConfig: (input: {
29
+ installationId: string;
30
+ owner: string;
31
+ repo: string;
32
+ }) => Promise<any>;
33
+ invalidateRepoConfigCache: (owner: string, repo: string) => Promise<void>;
34
+ }
35
+ interface ModelRunnerPort {
36
+ testConnection: (modelId: string) => Promise<{
37
+ ok: boolean;
38
+ modelUsed: string;
39
+ provider: string;
40
+ inputTokens: number;
41
+ outputTokens: number;
42
+ degraded?: string;
43
+ warning?: string;
44
+ }>;
45
+ syncProviderModelCatalog: () => Promise<Array<{
46
+ providerId: string;
47
+ providerName: string;
48
+ error: string;
49
+ }>>;
50
+ createProviderWithSecret: (input: {
51
+ name: string;
52
+ apiFormat: string;
53
+ baseUrl?: string | null;
54
+ apiKey?: string;
55
+ enabled: boolean;
56
+ }) => Promise<any>;
57
+ updateProviderWithSecret: (id: string, input: {
58
+ name: string;
59
+ apiFormat: string;
60
+ baseUrl?: string | null;
61
+ apiKey?: string;
62
+ clearApiKey?: boolean;
63
+ enabled: boolean;
64
+ }) => Promise<any>;
65
+ }
66
+ interface PlatformPort {
67
+ scheduleBestEffortJobMaintenance: (executionContext?: any) => void;
68
+ createReviewRuntime: () => ReviewRuntime;
69
+ getUpdatesEmailPreference: (githubUserId: number) => Promise<any>;
70
+ syncUpdatesEmail: (githubUserId: number, email: string | null | undefined) => Promise<boolean>;
71
+ terminateJobWorkflow: (job: {
72
+ id: string;
73
+ workflowInstanceId?: string | null;
74
+ }) => Promise<void>;
75
+ enqueueReviewJob: (input: {
76
+ jobId: string;
77
+ deliveryId: string;
78
+ phase: string;
79
+ requestId?: string;
80
+ }) => Promise<void>;
81
+ getOrFetchRawDiffForCompletedJob: (runtime: ReviewRuntime, job: any, github: any) => Promise<string>;
82
+ logger: {
83
+ info(message: string, data?: unknown): void;
84
+ warn(message: string, data?: unknown): void;
85
+ error(message: string, data?: unknown): void;
86
+ debug(message: string, data?: unknown): void;
87
+ };
88
+ }
89
+ interface AuthProviderPort {
90
+ createOAuthState: () => Promise<string>;
91
+ consumeOAuthState: (state: string) => Promise<boolean>;
92
+ beginAuthorization: (callbackUrl: string, state: string) => Promise<{
93
+ url: string;
94
+ }>;
95
+ completeAuthorization: (code: string, state: string, expectedState: string) => Promise<{
96
+ identity: any;
97
+ }>;
98
+ }
99
+ interface WebhookPort {
100
+ verifySignature: (signature: string | null, body: string) => Promise<boolean>;
101
+ normalizePayload: (eventName: string, payload: any) => any;
102
+ extractReviewRequest: (input: any) => any;
103
+ }
104
+ interface ApiRouterDeps {
105
+ repositories: RepositoriesPort;
106
+ gitProvider: {
107
+ getAppInstallationUrl: () => Promise<string>;
108
+ listInstallations: () => Promise<any[]>;
109
+ createService: (installationId?: number | string | null) => any;
110
+ };
111
+ config: ConfigPort;
112
+ modelRunner: ModelRunnerPort;
113
+ sessionStore: SessionStore;
114
+ platform: PlatformPort;
115
+ authProvider: AuthProviderPort;
116
+ webhook: WebhookPort;
117
+ }
118
+ interface ApiEnv {
119
+ Bindings: {
120
+ deps: ApiRouterDeps;
121
+ APP_URL: string;
122
+ ENVIRONMENT: string;
123
+ AUTH_CALLBACK_URL: string;
124
+ GITHUB_CLIENT_ID: string;
125
+ GITHUB_APP_SLUG?: string;
126
+ DASHBOARD_ALLOWED_USERS: string;
127
+ BOT_USERNAME: string;
128
+ };
129
+ Variables: {
130
+ sessionToken: string | null;
131
+ sessionUser: DashboardSessionUser | null;
132
+ requestId: string;
133
+ };
134
+ }
135
+
136
+ declare function createApiRouter(): Hono<ApiEnv, hono_types.BlankSchema, "/">;
137
+
138
+ export { type ApiEnv, type ApiRouterDeps, type ConfigPort, type PlatformPort, type RepositoriesPort, createApiRouter };