@introspection-sdk/introspection-node 0.5.0 → 0.5.1
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/.turbo/turbo-build.log +1 -1
- package/dist/pagination.d.ts +38 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +43 -0
- package/dist/pagination.js.map +1 -0
- package/dist/resources/experiments.d.ts +6 -4
- package/dist/resources/experiments.d.ts.map +1 -1
- package/dist/resources/experiments.js +11 -15
- package/dist/resources/experiments.js.map +1 -1
- package/dist/resources/recipes.d.ts +6 -4
- package/dist/resources/recipes.d.ts.map +1 -1
- package/dist/resources/recipes.js +11 -15
- package/dist/resources/recipes.js.map +1 -1
- package/dist/resources/runtimes.d.ts +6 -4
- package/dist/resources/runtimes.d.ts.map +1 -1
- package/dist/resources/runtimes.js +11 -15
- package/dist/resources/runtimes.js.map +1 -1
- package/dist/runner-resources/conversations.d.ts +14 -10
- package/dist/runner-resources/conversations.d.ts.map +1 -1
- package/dist/runner-resources/conversations.js +24 -30
- package/dist/runner-resources/conversations.js.map +1 -1
- package/dist/runner-resources/files.d.ts +14 -11
- package/dist/runner-resources/files.d.ts.map +1 -1
- package/dist/runner-resources/files.js +31 -36
- package/dist/runner-resources/files.js.map +1 -1
- package/dist/runner-resources/tasks.d.ts +6 -4
- package/dist/runner-resources/tasks.d.ts.map +1 -1
- package/dist/runner-resources/tasks.js +11 -15
- package/dist/runner-resources/tasks.js.map +1 -1
- package/package.json +6 -6
- package/src/pagination.ts +69 -0
- package/src/resources/experiments.ts +15 -14
- package/src/resources/recipes.ts +15 -14
- package/src/resources/runtimes.ts +15 -14
- package/src/runner-resources/conversations.ts +37 -33
- package/src/runner-resources/files.ts +52 -37
- package/src/runner-resources/tasks.ts +15 -14
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
File as FileResource,
|
|
3
|
+
FileCreateOptions,
|
|
3
4
|
FileCreateTextParams,
|
|
4
5
|
FileListParams,
|
|
5
6
|
FileType,
|
|
@@ -8,6 +9,7 @@ import type {
|
|
|
8
9
|
Paginated,
|
|
9
10
|
} from "@introspection-sdk/types";
|
|
10
11
|
import { HttpClient } from "../http.js";
|
|
12
|
+
import { Paginator, cursorPaginate } from "../pagination.js";
|
|
11
13
|
|
|
12
14
|
export type FileUploadBody =
|
|
13
15
|
| { file: Blob; name?: string; file_type?: FileType }
|
|
@@ -22,23 +24,20 @@ export class FileVersionsApi {
|
|
|
22
24
|
constructor(private readonly http: HttpClient) {}
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
+
* List versions of a file. `await` the result for the first page, or
|
|
28
|
+
* `for await` it to stream every version across pages (fetched lazily;
|
|
29
|
+
* stop early to stop fetching).
|
|
27
30
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
for (const f of page.records) yield f;
|
|
40
|
-
next = page.next ?? undefined;
|
|
41
|
-
} while (next);
|
|
31
|
+
list(fileId: string, params?: ListParams): Paginator<FileResource> {
|
|
32
|
+
return cursorPaginate(
|
|
33
|
+
(next) =>
|
|
34
|
+
this.http.request<Paginated<FileResource>>({
|
|
35
|
+
method: "GET",
|
|
36
|
+
path: `/v1/files/${encodeURIComponent(fileId)}/versions`,
|
|
37
|
+
query: { ...params, next } as Record<string, unknown>,
|
|
38
|
+
}),
|
|
39
|
+
params?.next,
|
|
40
|
+
);
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
get(fileId: string, versionId: string): Promise<FileResource> {
|
|
@@ -48,8 +47,12 @@ export class FileVersionsApi {
|
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
create(
|
|
52
|
-
|
|
50
|
+
create(
|
|
51
|
+
fileId: string,
|
|
52
|
+
body: FileUploadBody,
|
|
53
|
+
options?: FileCreateOptions,
|
|
54
|
+
): Promise<FileResource> {
|
|
55
|
+
const form = toFormData(body, options);
|
|
53
56
|
return this.http.request<FileResource>({
|
|
54
57
|
method: "POST",
|
|
55
58
|
path: `/v1/files/${encodeURIComponent(fileId)}/versions`,
|
|
@@ -66,25 +69,28 @@ export class FilesApi {
|
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* starting cursor
|
|
72
|
+
* List files matching `params`. `await` the result for the first page,
|
|
73
|
+
* or `for await` it to stream every file across pages (fetched lazily —
|
|
74
|
+
* `limit` sets the page size, `next` the starting cursor; stop early to
|
|
75
|
+
* stop fetching).
|
|
72
76
|
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
} while (next);
|
|
77
|
+
list(params?: FileListParams): Paginator<FileResource> {
|
|
78
|
+
return cursorPaginate(
|
|
79
|
+
(next) =>
|
|
80
|
+
this.http.request<Paginated<FileResource>>({
|
|
81
|
+
method: "GET",
|
|
82
|
+
path: "/v1/files",
|
|
83
|
+
query: { ...params, next } as Record<string, unknown>,
|
|
84
|
+
}),
|
|
85
|
+
params?.next,
|
|
86
|
+
);
|
|
84
87
|
}
|
|
85
88
|
|
|
86
|
-
upload(
|
|
87
|
-
|
|
89
|
+
upload(
|
|
90
|
+
body: FileUploadBody,
|
|
91
|
+
options?: FileCreateOptions,
|
|
92
|
+
): Promise<FileResource> {
|
|
93
|
+
const form = toFormData(body, options);
|
|
88
94
|
return this.http.request<FileResource>({
|
|
89
95
|
method: "POST",
|
|
90
96
|
path: "/v1/files",
|
|
@@ -92,11 +98,16 @@ export class FilesApi {
|
|
|
92
98
|
});
|
|
93
99
|
}
|
|
94
100
|
|
|
95
|
-
createText(
|
|
101
|
+
createText(
|
|
102
|
+
body: FileCreateTextParams,
|
|
103
|
+
options?: FileCreateOptions,
|
|
104
|
+
): Promise<FileResource> {
|
|
96
105
|
return this.http.request<FileResource>({
|
|
97
106
|
method: "POST",
|
|
98
107
|
path: "/v1/files",
|
|
99
|
-
body
|
|
108
|
+
body: options?.visibility
|
|
109
|
+
? { ...body, visibility: options.visibility }
|
|
110
|
+
: body,
|
|
100
111
|
});
|
|
101
112
|
}
|
|
102
113
|
|
|
@@ -140,7 +151,10 @@ export class FilesApi {
|
|
|
140
151
|
}
|
|
141
152
|
}
|
|
142
153
|
|
|
143
|
-
function toFormData(
|
|
154
|
+
function toFormData(
|
|
155
|
+
body: FileUploadBody,
|
|
156
|
+
options?: FileCreateOptions,
|
|
157
|
+
): FormData {
|
|
144
158
|
const fd = new FormData();
|
|
145
159
|
if ("file" in body && body.file instanceof Blob) {
|
|
146
160
|
fd.append("file", body.file, body.name);
|
|
@@ -160,5 +174,6 @@ function toFormData(body: FileUploadBody): FormData {
|
|
|
160
174
|
}
|
|
161
175
|
if (body.name) fd.append("name", body.name);
|
|
162
176
|
if (body.file_type) fd.append("file_type", body.file_type);
|
|
177
|
+
if (options?.visibility) fd.append("visibility", options.visibility);
|
|
163
178
|
return fd;
|
|
164
179
|
}
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
TaskUpdateParams,
|
|
13
13
|
} from "@introspection-sdk/types";
|
|
14
14
|
import { HttpClient } from "../http.js";
|
|
15
|
+
import { Paginator, cursorPaginate } from "../pagination.js";
|
|
15
16
|
import { parseSse } from "../streaming.js";
|
|
16
17
|
|
|
17
18
|
export interface StartParams extends TaskCreateParams {
|
|
@@ -85,21 +86,21 @@ export class TasksApi {
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* starting cursor
|
|
89
|
+
* List tasks matching `params`. `await` the result for the first page,
|
|
90
|
+
* or `for await` it to stream every task across pages (fetched lazily —
|
|
91
|
+
* `limit` sets the page size, `next` the starting cursor; stop early to
|
|
92
|
+
* stop fetching).
|
|
91
93
|
*/
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
} while (next);
|
|
94
|
+
list(params?: TaskListParams): Paginator<Task> {
|
|
95
|
+
return cursorPaginate(
|
|
96
|
+
(next) =>
|
|
97
|
+
this.http.request<Paginated<Task>>({
|
|
98
|
+
method: "GET",
|
|
99
|
+
path: "/v1/tasks",
|
|
100
|
+
query: { ...params, next } as Record<string, unknown>,
|
|
101
|
+
}),
|
|
102
|
+
params?.next,
|
|
103
|
+
);
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
create(body: TaskCreateParams): Promise<TaskCreateResponse> {
|