@recursorsdk/sdk 1.0.2 → 1.1.0
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.
- package/dist/index.d.ts +29 -1
- package/dist/index.js +2 -1
- package/dist/mixins/github.d.ts +60 -0
- package/dist/mixins/github.js +41 -0
- package/dist/mixins/intelligence.d.ts +3 -1
- package/dist/mixins/intelligence.js +7 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
export * from "./types.js";
|
|
2
2
|
export type { WebSocketMessage, WebSocketEventHandler } from "./websocket.js";
|
|
3
3
|
export { RecursorWebSocket } from "./websocket.js";
|
|
4
|
+
export type { GitHubRepository, GitHubIndexResponse, GitHubAuthResponse, SSOLoginUrlResponse } from "./mixins/github.js";
|
|
4
5
|
import { RecursorBase } from "./base.js";
|
|
5
6
|
declare const RecursorSDK_base: {
|
|
7
|
+
new (...args: any[]): {
|
|
8
|
+
githubAuthCallback(code: string): Promise<import("./mixins/github.js").GitHubAuthResponse>;
|
|
9
|
+
githubListRepositories(token: string): Promise<import("./mixins/github.js").GitHubRepository[]>;
|
|
10
|
+
githubIndexRepository(fullName: string, token: string): Promise<import("./mixins/github.js").GitHubIndexResponse>;
|
|
11
|
+
ssoGithubLogin(code: string): Promise<import("./types.js").TokenResponse>;
|
|
12
|
+
ssoGoogleLogin(idToken: string): Promise<import("./types.js").TokenResponse>;
|
|
13
|
+
ssoGetLoginUrl(provider: string): Promise<import("./mixins/github.js").SSOLoginUrlResponse>;
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
accessToken?: string;
|
|
17
|
+
timeoutMs: number;
|
|
18
|
+
wsClient?: any;
|
|
19
|
+
localIndex: Record<string, any>;
|
|
20
|
+
offlineQueue: any[];
|
|
21
|
+
setAccessToken(token: string): void;
|
|
22
|
+
setApiKey(key: string): void;
|
|
23
|
+
headers(): import("./types.js").HeadersInit;
|
|
24
|
+
get<T>(path: string, params?: Record<string, unknown>): Promise<T>;
|
|
25
|
+
post<T>(path: string, body?: unknown, method?: string): Promise<T>;
|
|
26
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
27
|
+
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
28
|
+
delete<T>(path: string): Promise<T>;
|
|
29
|
+
checkHealth(): Promise<boolean>;
|
|
30
|
+
};
|
|
31
|
+
} & {
|
|
6
32
|
new (...args: any[]): {
|
|
7
33
|
createWebSocket(): Promise<import("./websocket.js").RecursorWebSocket>;
|
|
8
34
|
connectWebSocket(): Promise<import("./websocket.js").RecursorWebSocket>;
|
|
@@ -108,11 +134,13 @@ declare const RecursorSDK_base: {
|
|
|
108
134
|
listCorrections(args: {
|
|
109
135
|
page?: number;
|
|
110
136
|
page_size?: number;
|
|
137
|
+
project_id?: string;
|
|
111
138
|
}): Promise<any>;
|
|
112
|
-
searchCorrections(query: string, limit?: number): Promise<any[]>;
|
|
139
|
+
searchCorrections(query: string, limit?: number, project_id?: string): Promise<any[]>;
|
|
113
140
|
createCorrection(data: {
|
|
114
141
|
input_text: string;
|
|
115
142
|
output_text: string;
|
|
143
|
+
project_id?: string;
|
|
116
144
|
}): Promise<any>;
|
|
117
145
|
baseUrl: string;
|
|
118
146
|
apiKey?: string;
|
package/dist/index.js
CHANGED
|
@@ -7,12 +7,13 @@ import { WorkflowMixin } from "./mixins/workflows.js";
|
|
|
7
7
|
import { IntelligenceMixin } from "./mixins/intelligence.js";
|
|
8
8
|
import { EnterpriseMixin } from "./mixins/enterprise.js";
|
|
9
9
|
import { WebSocketMixin } from "./mixins/websocket.js";
|
|
10
|
+
import { GitHubMixin } from "./mixins/github.js";
|
|
10
11
|
/**
|
|
11
12
|
* RecursorSDK
|
|
12
13
|
*
|
|
13
14
|
* The main client for the Recursor API.
|
|
14
15
|
* Composed of multiple mixins to provide a modular yet flat API.
|
|
15
16
|
*/
|
|
16
|
-
export class RecursorSDK extends WebSocketMixin(EnterpriseMixin(IntelligenceMixin(WorkflowMixin(CodebaseMixin(RecursorBase))))) {
|
|
17
|
+
export class RecursorSDK extends GitHubMixin(WebSocketMixin(EnterpriseMixin(IntelligenceMixin(WorkflowMixin(CodebaseMixin(RecursorBase)))))) {
|
|
17
18
|
}
|
|
18
19
|
export default RecursorSDK;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { RecursorBase, Constructor } from "../base.js";
|
|
2
|
+
import { TokenResponse } from "../types.js";
|
|
3
|
+
/** GitHub repository object returned from the API */
|
|
4
|
+
export interface GitHubRepository {
|
|
5
|
+
id: number;
|
|
6
|
+
name: string;
|
|
7
|
+
full_name: string;
|
|
8
|
+
private: boolean;
|
|
9
|
+
html_url: string;
|
|
10
|
+
description: string | null;
|
|
11
|
+
language: string | null;
|
|
12
|
+
default_branch: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
/** Response from triggering repository indexing */
|
|
16
|
+
export interface GitHubIndexResponse {
|
|
17
|
+
status: string;
|
|
18
|
+
repository: string;
|
|
19
|
+
message: string;
|
|
20
|
+
}
|
|
21
|
+
/** Response from exchanging a GitHub OAuth code */
|
|
22
|
+
export interface GitHubAuthResponse {
|
|
23
|
+
access_token: string;
|
|
24
|
+
}
|
|
25
|
+
/** Response containing an SSO authorization URL */
|
|
26
|
+
export interface SSOLoginUrlResponse {
|
|
27
|
+
authorize_url: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function GitHubMixin<TBase extends Constructor<RecursorBase>>(Base: TBase): {
|
|
30
|
+
new (...args: any[]): {
|
|
31
|
+
/** Exchange a GitHub OAuth code for an access token. */
|
|
32
|
+
githubAuthCallback(code: string): Promise<GitHubAuthResponse>;
|
|
33
|
+
/** List repositories for the authenticated GitHub user. */
|
|
34
|
+
githubListRepositories(token: string): Promise<GitHubRepository[]>;
|
|
35
|
+
/** Trigger background indexing for a selected GitHub repository. */
|
|
36
|
+
githubIndexRepository(fullName: string, token: string): Promise<GitHubIndexResponse>;
|
|
37
|
+
/** Login or register using a GitHub OAuth code. Auto-sets access token. */
|
|
38
|
+
ssoGithubLogin(code: string): Promise<TokenResponse>;
|
|
39
|
+
/** Login or register using a Google ID token. Auto-sets access token. */
|
|
40
|
+
ssoGoogleLogin(idToken: string): Promise<TokenResponse>;
|
|
41
|
+
/** Get the SSO authorization URL for a given provider. */
|
|
42
|
+
ssoGetLoginUrl(provider: string): Promise<SSOLoginUrlResponse>;
|
|
43
|
+
baseUrl: string;
|
|
44
|
+
apiKey?: string;
|
|
45
|
+
accessToken?: string;
|
|
46
|
+
timeoutMs: number;
|
|
47
|
+
wsClient?: any;
|
|
48
|
+
localIndex: Record<string, any>;
|
|
49
|
+
offlineQueue: any[];
|
|
50
|
+
setAccessToken(token: string): void;
|
|
51
|
+
setApiKey(key: string): void;
|
|
52
|
+
headers(): import("../types.js").HeadersInit;
|
|
53
|
+
get<T>(path: string, params?: Record<string, unknown>): Promise<T>;
|
|
54
|
+
post<T>(path: string, body?: unknown, method?: string): Promise<T>;
|
|
55
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
56
|
+
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
57
|
+
delete<T>(path: string): Promise<T>;
|
|
58
|
+
checkHealth(): Promise<boolean>;
|
|
59
|
+
};
|
|
60
|
+
} & TBase;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export function GitHubMixin(Base) {
|
|
2
|
+
return class extends Base {
|
|
3
|
+
// ==================== GitHub Sync ====================
|
|
4
|
+
/** Exchange a GitHub OAuth code for an access token. */
|
|
5
|
+
async githubAuthCallback(code) {
|
|
6
|
+
return await this.post("/client/github/auth/callback", { code });
|
|
7
|
+
}
|
|
8
|
+
/** List repositories for the authenticated GitHub user. */
|
|
9
|
+
async githubListRepositories(token) {
|
|
10
|
+
return await this.get("/client/github/repositories", { token });
|
|
11
|
+
}
|
|
12
|
+
/** Trigger background indexing for a selected GitHub repository. */
|
|
13
|
+
async githubIndexRepository(fullName, token) {
|
|
14
|
+
return await this.post("/client/github/index", {
|
|
15
|
+
full_name: fullName,
|
|
16
|
+
token,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
// ==================== SSO Authentication ====================
|
|
20
|
+
/** Login or register using a GitHub OAuth code. Auto-sets access token. */
|
|
21
|
+
async ssoGithubLogin(code) {
|
|
22
|
+
const response = await this.post("/client/auth/sso/github/login", { code });
|
|
23
|
+
if (response.access_token) {
|
|
24
|
+
this.setAccessToken(response.access_token);
|
|
25
|
+
}
|
|
26
|
+
return response;
|
|
27
|
+
}
|
|
28
|
+
/** Login or register using a Google ID token. Auto-sets access token. */
|
|
29
|
+
async ssoGoogleLogin(idToken) {
|
|
30
|
+
const response = await this.post("/client/auth/sso/google/login", { id_token: idToken });
|
|
31
|
+
if (response.access_token) {
|
|
32
|
+
this.setAccessToken(response.access_token);
|
|
33
|
+
}
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
/** Get the SSO authorization URL for a given provider. */
|
|
37
|
+
async ssoGetLoginUrl(provider) {
|
|
38
|
+
return await this.get(`/client/auth/sso/${provider}/login`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -35,11 +35,13 @@ export declare function IntelligenceMixin<TBase extends Constructor<RecursorBase
|
|
|
35
35
|
listCorrections(args: {
|
|
36
36
|
page?: number;
|
|
37
37
|
page_size?: number;
|
|
38
|
+
project_id?: string;
|
|
38
39
|
}): Promise<any>;
|
|
39
|
-
searchCorrections(query: string, limit?: number): Promise<any[]>;
|
|
40
|
+
searchCorrections(query: string, limit?: number, project_id?: string): Promise<any[]>;
|
|
40
41
|
createCorrection(data: {
|
|
41
42
|
input_text: string;
|
|
42
43
|
output_text: string;
|
|
44
|
+
project_id?: string;
|
|
43
45
|
}): Promise<any>;
|
|
44
46
|
baseUrl: string;
|
|
45
47
|
apiKey?: string;
|
|
@@ -82,10 +82,14 @@ export function IntelligenceMixin(Base) {
|
|
|
82
82
|
}
|
|
83
83
|
// ==================== Corrections ====================
|
|
84
84
|
async listCorrections(args) {
|
|
85
|
-
|
|
85
|
+
const params = { ...args };
|
|
86
|
+
return await this.get("/client/corrections", params);
|
|
86
87
|
}
|
|
87
|
-
async searchCorrections(query, limit = 5) {
|
|
88
|
-
|
|
88
|
+
async searchCorrections(query, limit = 5, project_id) {
|
|
89
|
+
const params = { query, limit };
|
|
90
|
+
if (project_id)
|
|
91
|
+
params.project_id = project_id;
|
|
92
|
+
return await this.get("/client/corrections/search", params);
|
|
89
93
|
}
|
|
90
94
|
async createCorrection(data) {
|
|
91
95
|
return await this.post("/client/corrections", data);
|
package/package.json
CHANGED