aint-sdk 0.1.0-alpha.2 → 0.1.0-alpha.3
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/CHANGELOG.md +8 -0
- package/README.md +31 -0
- package/client.d.mts +9 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +9 -0
- package/client.d.ts.map +1 -1
- package/client.js +11 -0
- package/client.js.map +1 -1
- package/client.mjs +11 -0
- package/client.mjs.map +1 -1
- package/core/pagination.d.mts +56 -0
- package/core/pagination.d.mts.map +1 -0
- package/core/pagination.d.ts +56 -0
- package/core/pagination.d.ts.map +1 -0
- package/core/pagination.js +102 -0
- package/core/pagination.js.map +1 -0
- package/core/pagination.mjs +96 -0
- package/core/pagination.mjs.map +1 -0
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/package.json +11 -1
- package/pagination.d.mts +2 -0
- package/pagination.d.mts.map +1 -0
- package/pagination.d.ts +2 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +6 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +2 -0
- package/pagination.mjs.map +1 -0
- package/resources/index.d.mts +1 -0
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/projects.d.mts +220 -0
- package/resources/projects.d.mts.map +1 -0
- package/resources/projects.d.ts +220 -0
- package/resources/projects.d.ts.map +1 -0
- package/resources/projects.js +73 -0
- package/resources/projects.js.map +1 -0
- package/resources/projects.mjs +69 -0
- package/resources/projects.mjs.map +1 -0
- package/src/client.ts +52 -0
- package/src/core/pagination.ts +166 -0
- package/src/index.ts +1 -0
- package/src/pagination.ts +2 -0
- package/src/resources/index.ts +9 -0
- package/src/resources/projects.ts +289 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { APIResource } from "../core/resource.js";
|
|
2
|
+
import { APIPromise } from "../core/api-promise.js";
|
|
3
|
+
import { PageNumberPagination, type PageNumberPaginationParams, PagePromise } from "../core/pagination.js";
|
|
4
|
+
import { RequestOptions } from "../internal/request-options.js";
|
|
5
|
+
export declare class Projects extends APIResource {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new project
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const project = await client.projects.create();
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
create(body: ProjectCreateParams, options?: RequestOptions): APIPromise<Project>;
|
|
15
|
+
/**
|
|
16
|
+
* Updates an existing project
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const project = await client.projects.update('id');
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
update(id: string, body: ProjectUpdateParams, options?: RequestOptions): APIPromise<Project>;
|
|
24
|
+
/**
|
|
25
|
+
* Returns a paginated list of the user's projects
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* // Automatically fetches more pages as needed.
|
|
30
|
+
* for await (const project of client.projects.list()) {
|
|
31
|
+
* // ...
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
list(query?: ProjectListParams | null | undefined, options?: RequestOptions): PagePromise<ProjectsPageNumberPagination, Project>;
|
|
36
|
+
/**
|
|
37
|
+
* Deletes a project (soft delete)
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* await client.projects.delete('id');
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
delete(id: string, options?: RequestOptions): APIPromise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Returns a single project by ID
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const project = await client.projects.get('id');
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
get(id: string, options?: RequestOptions): APIPromise<Project>;
|
|
54
|
+
}
|
|
55
|
+
export type ProjectsPageNumberPagination = PageNumberPagination<Project>;
|
|
56
|
+
/**
|
|
57
|
+
* A translation project
|
|
58
|
+
*/
|
|
59
|
+
export interface Project {
|
|
60
|
+
/**
|
|
61
|
+
* Unique project identifier
|
|
62
|
+
*/
|
|
63
|
+
id: string;
|
|
64
|
+
/**
|
|
65
|
+
* Project name
|
|
66
|
+
*/
|
|
67
|
+
name: string;
|
|
68
|
+
/**
|
|
69
|
+
* Number of translation batches
|
|
70
|
+
*/
|
|
71
|
+
batch_count?: number | null;
|
|
72
|
+
/**
|
|
73
|
+
* Number of chapters in the project
|
|
74
|
+
*/
|
|
75
|
+
chapter_count?: number | null;
|
|
76
|
+
/**
|
|
77
|
+
* Project creation timestamp
|
|
78
|
+
*/
|
|
79
|
+
created_at?: string | null;
|
|
80
|
+
/**
|
|
81
|
+
* Custom translation instructions
|
|
82
|
+
*/
|
|
83
|
+
custom_instructions?: string | null;
|
|
84
|
+
/**
|
|
85
|
+
* Project description
|
|
86
|
+
*/
|
|
87
|
+
description?: string | null;
|
|
88
|
+
/**
|
|
89
|
+
* Last update timestamp
|
|
90
|
+
*/
|
|
91
|
+
last_updated_at?: string | null;
|
|
92
|
+
/**
|
|
93
|
+
* Name of the last updated chapter
|
|
94
|
+
*/
|
|
95
|
+
last_updated_chapter_name?: string | null;
|
|
96
|
+
/**
|
|
97
|
+
* Source language for translation
|
|
98
|
+
*/
|
|
99
|
+
original_language?: string | null;
|
|
100
|
+
/**
|
|
101
|
+
* JSON string of section break positions for latest file uploaded for batch
|
|
102
|
+
* translation
|
|
103
|
+
*/
|
|
104
|
+
section_breaks?: string | null;
|
|
105
|
+
/**
|
|
106
|
+
* Target language for translation
|
|
107
|
+
*/
|
|
108
|
+
translated_language?: string | null;
|
|
109
|
+
/**
|
|
110
|
+
* Latest filename of uploaded content for batch translation
|
|
111
|
+
*/
|
|
112
|
+
uploaded_filename?: string | null;
|
|
113
|
+
/**
|
|
114
|
+
* Length of latest file uploaded for batch translation in characters
|
|
115
|
+
*/
|
|
116
|
+
uploaded_length?: number | null;
|
|
117
|
+
/**
|
|
118
|
+
* UUID of latest file uploaded for batch translation
|
|
119
|
+
*/
|
|
120
|
+
uploaded_uuid?: string | null;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Paginated list of projects
|
|
124
|
+
*/
|
|
125
|
+
export interface ProjectListResponse {
|
|
126
|
+
/**
|
|
127
|
+
* List of projects
|
|
128
|
+
*/
|
|
129
|
+
data: Array<Project>;
|
|
130
|
+
/**
|
|
131
|
+
* Current page number
|
|
132
|
+
*/
|
|
133
|
+
page: number;
|
|
134
|
+
/**
|
|
135
|
+
* Number of items per page
|
|
136
|
+
*/
|
|
137
|
+
page_size: number;
|
|
138
|
+
/**
|
|
139
|
+
* Total number of projects
|
|
140
|
+
*/
|
|
141
|
+
total: number;
|
|
142
|
+
/**
|
|
143
|
+
* Total number of pages
|
|
144
|
+
*/
|
|
145
|
+
total_pages: number;
|
|
146
|
+
}
|
|
147
|
+
export interface ProjectCreateParams {
|
|
148
|
+
/**
|
|
149
|
+
* Custom translation instructions
|
|
150
|
+
*/
|
|
151
|
+
custom_instructions?: string | null;
|
|
152
|
+
/**
|
|
153
|
+
* Project description
|
|
154
|
+
*/
|
|
155
|
+
description?: string | null;
|
|
156
|
+
/**
|
|
157
|
+
* Project name (defaults to 'My Project')
|
|
158
|
+
*/
|
|
159
|
+
name?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Source language (defaults to 'Korean')
|
|
162
|
+
*/
|
|
163
|
+
original_language?: string | null;
|
|
164
|
+
/**
|
|
165
|
+
* Target language (defaults to 'English')
|
|
166
|
+
*/
|
|
167
|
+
translated_language?: string | null;
|
|
168
|
+
}
|
|
169
|
+
export interface ProjectUpdateParams {
|
|
170
|
+
/**
|
|
171
|
+
* Custom translation instructions
|
|
172
|
+
*/
|
|
173
|
+
custom_instructions?: string | null;
|
|
174
|
+
/**
|
|
175
|
+
* Project description
|
|
176
|
+
*/
|
|
177
|
+
description?: string | null;
|
|
178
|
+
/**
|
|
179
|
+
* Project name
|
|
180
|
+
*/
|
|
181
|
+
name?: string;
|
|
182
|
+
/**
|
|
183
|
+
* Source language
|
|
184
|
+
*/
|
|
185
|
+
original_language?: string | null;
|
|
186
|
+
/**
|
|
187
|
+
* JSON string of section break positions for batch translation
|
|
188
|
+
*/
|
|
189
|
+
section_breaks?: string | null;
|
|
190
|
+
/**
|
|
191
|
+
* Target language
|
|
192
|
+
*/
|
|
193
|
+
translated_language?: string | null;
|
|
194
|
+
}
|
|
195
|
+
export interface ProjectListParams extends PageNumberPaginationParams {
|
|
196
|
+
/**
|
|
197
|
+
* Filter by original language
|
|
198
|
+
*/
|
|
199
|
+
original_language?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Search query for project name
|
|
202
|
+
*/
|
|
203
|
+
query?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Sort direction
|
|
206
|
+
*/
|
|
207
|
+
sort_direction?: 'asc' | 'desc';
|
|
208
|
+
/**
|
|
209
|
+
* Field to sort by
|
|
210
|
+
*/
|
|
211
|
+
sort_field?: 'last_updated_at' | 'created_at' | 'name';
|
|
212
|
+
/**
|
|
213
|
+
* Filter by translated language
|
|
214
|
+
*/
|
|
215
|
+
translated_language?: string;
|
|
216
|
+
}
|
|
217
|
+
export declare namespace Projects {
|
|
218
|
+
export { type Project as Project, type ProjectListResponse as ProjectListResponse, type ProjectsPageNumberPagination as ProjectsPageNumberPagination, type ProjectCreateParams as ProjectCreateParams, type ProjectUpdateParams as ProjectUpdateParams, type ProjectListParams as ProjectListParams, };
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=projects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../src/resources/projects.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,oBAAoB,EAAE,KAAK,0BAA0B,EAAE,WAAW,EAAE;OAEtE,EAAE,cAAc,EAAE;AAGzB,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAIhF;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAI5F;;;;;;;;;;OAUG;IACH,IAAI,CACF,KAAK,GAAE,iBAAiB,GAAG,IAAI,GAAG,SAAc,EAChD,OAAO,CAAC,EAAE,cAAc,GACvB,WAAW,CAAC,4BAA4B,EAAE,OAAO,CAAC;IAIrD;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;IAO9D;;;;;;;OAOG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;CAG/D;AAED,MAAM,MAAM,4BAA4B,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAA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TRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Projects = void 0;
|
|
5
|
+
const resource_1 = require("../core/resource.js");
|
|
6
|
+
const pagination_1 = require("../core/pagination.js");
|
|
7
|
+
const headers_1 = require("../internal/headers.js");
|
|
8
|
+
const path_1 = require("../internal/utils/path.js");
|
|
9
|
+
class Projects extends resource_1.APIResource {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new project
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const project = await client.projects.create();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
create(body, options) {
|
|
19
|
+
return this._client.post('/projects', { body, ...options });
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Updates an existing project
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const project = await client.projects.update('id');
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
update(id, body, options) {
|
|
30
|
+
return this._client.patch((0, path_1.path) `/projects/${id}`, { body, ...options });
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns a paginated list of the user's projects
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* // Automatically fetches more pages as needed.
|
|
38
|
+
* for await (const project of client.projects.list()) {
|
|
39
|
+
* // ...
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
list(query = {}, options) {
|
|
44
|
+
return this._client.getAPIList('/projects', (pagination_1.PageNumberPagination), { query, ...options });
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Deletes a project (soft delete)
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* await client.projects.delete('id');
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
delete(id, options) {
|
|
55
|
+
return this._client.delete((0, path_1.path) `/projects/${id}`, {
|
|
56
|
+
...options,
|
|
57
|
+
headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns a single project by ID
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const project = await client.projects.get('id');
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
get(id, options) {
|
|
69
|
+
return this._client.get((0, path_1.path) `/projects/${id}`, options);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.Projects = Projects;
|
|
73
|
+
//# sourceMappingURL=projects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../src/resources/projects.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAE/C,sDAAwG;AACxG,oDAAmD;AAEnD,oDAA8C;AAE9C,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;;;;OAOG;IACH,MAAM,CAAC,IAAyB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,IAAyB,EAAE,OAAwB;QACpE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAA,WAAI,EAAA,aAAa,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,CACF,QAA8C,EAAE,EAChD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,CAAA,iCAA6B,CAAA,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACpG,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,OAAwB;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAA,WAAI,EAAA,aAAa,EAAE,EAAE,EAAE;YAChD,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SAC7D,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,GAAG,CAAC,EAAU,EAAE,OAAwB;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,aAAa,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;CACF;AArED,4BAqEC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from "../core/resource.mjs";
|
|
3
|
+
import { PageNumberPagination } from "../core/pagination.mjs";
|
|
4
|
+
import { buildHeaders } from "../internal/headers.mjs";
|
|
5
|
+
import { path } from "../internal/utils/path.mjs";
|
|
6
|
+
export class Projects extends APIResource {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new project
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const project = await client.projects.create();
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
create(body, options) {
|
|
16
|
+
return this._client.post('/projects', { body, ...options });
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Updates an existing project
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const project = await client.projects.update('id');
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
update(id, body, options) {
|
|
27
|
+
return this._client.patch(path `/projects/${id}`, { body, ...options });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns a paginated list of the user's projects
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* // Automatically fetches more pages as needed.
|
|
35
|
+
* for await (const project of client.projects.list()) {
|
|
36
|
+
* // ...
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
list(query = {}, options) {
|
|
41
|
+
return this._client.getAPIList('/projects', (PageNumberPagination), { query, ...options });
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Deletes a project (soft delete)
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* await client.projects.delete('id');
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
delete(id, options) {
|
|
52
|
+
return this._client.delete(path `/projects/${id}`, {
|
|
53
|
+
...options,
|
|
54
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns a single project by ID
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const project = await client.projects.get('id');
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
get(id, options) {
|
|
66
|
+
return this._client.get(path `/projects/${id}`, options);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=projects.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.mjs","sourceRoot":"","sources":["../src/resources/projects.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAEf,EAAE,oBAAoB,EAAgD;OACtE,EAAE,YAAY,EAAE;OAEhB,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC;;;;;;;OAOG;IACH,MAAM,CAAC,IAAyB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,IAAyB,EAAE,OAAwB;QACpE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAA,aAAa,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,CACF,QAA8C,EAAE,EAChD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,CAAA,oBAA6B,CAAA,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACpG,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,OAAwB;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAA,aAAa,EAAE,EAAE,EAAE;YAChD,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SAC7D,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,GAAG,CAAC,EAAU,EAAE,OAAwB;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,aAAa,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;CACF"}
|
package/src/client.ts
CHANGED
|
@@ -13,9 +13,24 @@ import * as Shims from './internal/shims';
|
|
|
13
13
|
import * as Opts from './internal/request-options';
|
|
14
14
|
import { VERSION } from './version';
|
|
15
15
|
import * as Errors from './core/error';
|
|
16
|
+
import * as Pagination from './core/pagination';
|
|
17
|
+
import {
|
|
18
|
+
AbstractPage,
|
|
19
|
+
type PageNumberPaginationParams,
|
|
20
|
+
PageNumberPaginationResponse,
|
|
21
|
+
} from './core/pagination';
|
|
16
22
|
import * as Uploads from './core/uploads';
|
|
17
23
|
import * as API from './resources/index';
|
|
18
24
|
import { APIPromise } from './core/api-promise';
|
|
25
|
+
import {
|
|
26
|
+
Project,
|
|
27
|
+
ProjectCreateParams,
|
|
28
|
+
ProjectListParams,
|
|
29
|
+
ProjectListResponse,
|
|
30
|
+
ProjectUpdateParams,
|
|
31
|
+
Projects,
|
|
32
|
+
ProjectsPageNumberPagination,
|
|
33
|
+
} from './resources/projects';
|
|
19
34
|
import { User, Users } from './resources/users';
|
|
20
35
|
import { type Fetch } from './internal/builtin-types';
|
|
21
36
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
@@ -506,6 +521,25 @@ export class AintSDK {
|
|
|
506
521
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
507
522
|
}
|
|
508
523
|
|
|
524
|
+
getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(
|
|
525
|
+
path: string,
|
|
526
|
+
Page: new (...args: any[]) => PageClass,
|
|
527
|
+
opts?: RequestOptions,
|
|
528
|
+
): Pagination.PagePromise<PageClass, Item> {
|
|
529
|
+
return this.requestAPIList(Page, { method: 'get', path, ...opts });
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
requestAPIList<
|
|
533
|
+
Item = unknown,
|
|
534
|
+
PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>,
|
|
535
|
+
>(
|
|
536
|
+
Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass,
|
|
537
|
+
options: FinalRequestOptions,
|
|
538
|
+
): Pagination.PagePromise<PageClass, Item> {
|
|
539
|
+
const request = this.makeRequest(options, null, undefined);
|
|
540
|
+
return new Pagination.PagePromise<PageClass, Item>(this as any as AintSDK, request, Page);
|
|
541
|
+
}
|
|
542
|
+
|
|
509
543
|
async fetchWithTimeout(
|
|
510
544
|
url: RequestInfo,
|
|
511
545
|
init: RequestInit | undefined,
|
|
@@ -739,12 +773,30 @@ export class AintSDK {
|
|
|
739
773
|
static toFile = Uploads.toFile;
|
|
740
774
|
|
|
741
775
|
users: API.Users = new API.Users(this);
|
|
776
|
+
projects: API.Projects = new API.Projects(this);
|
|
742
777
|
}
|
|
743
778
|
|
|
744
779
|
AintSDK.Users = Users;
|
|
780
|
+
AintSDK.Projects = Projects;
|
|
745
781
|
|
|
746
782
|
export declare namespace AintSDK {
|
|
747
783
|
export type RequestOptions = Opts.RequestOptions;
|
|
748
784
|
|
|
785
|
+
export import PageNumberPagination = Pagination.PageNumberPagination;
|
|
786
|
+
export {
|
|
787
|
+
type PageNumberPaginationParams as PageNumberPaginationParams,
|
|
788
|
+
type PageNumberPaginationResponse as PageNumberPaginationResponse,
|
|
789
|
+
};
|
|
790
|
+
|
|
749
791
|
export { Users as Users, type User as User };
|
|
792
|
+
|
|
793
|
+
export {
|
|
794
|
+
Projects as Projects,
|
|
795
|
+
type Project as Project,
|
|
796
|
+
type ProjectListResponse as ProjectListResponse,
|
|
797
|
+
type ProjectsPageNumberPagination as ProjectsPageNumberPagination,
|
|
798
|
+
type ProjectCreateParams as ProjectCreateParams,
|
|
799
|
+
type ProjectUpdateParams as ProjectUpdateParams,
|
|
800
|
+
type ProjectListParams as ProjectListParams,
|
|
801
|
+
};
|
|
750
802
|
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { AintSDKError } from './error';
|
|
4
|
+
import { FinalRequestOptions } from '../internal/request-options';
|
|
5
|
+
import { defaultParseResponse } from '../internal/parse';
|
|
6
|
+
import { type AintSDK } from '../client';
|
|
7
|
+
import { APIPromise } from './api-promise';
|
|
8
|
+
import { type APIResponseProps } from '../internal/parse';
|
|
9
|
+
import { maybeObj } from '../internal/utils/values';
|
|
10
|
+
|
|
11
|
+
export type PageRequestOptions = Pick<FinalRequestOptions, 'query' | 'headers' | 'body' | 'path' | 'method'>;
|
|
12
|
+
|
|
13
|
+
export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
|
|
14
|
+
#client: AintSDK;
|
|
15
|
+
protected options: FinalRequestOptions;
|
|
16
|
+
|
|
17
|
+
protected response: Response;
|
|
18
|
+
protected body: unknown;
|
|
19
|
+
|
|
20
|
+
constructor(client: AintSDK, response: Response, body: unknown, options: FinalRequestOptions) {
|
|
21
|
+
this.#client = client;
|
|
22
|
+
this.options = options;
|
|
23
|
+
this.response = response;
|
|
24
|
+
this.body = body;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
abstract nextPageRequestOptions(): PageRequestOptions | null;
|
|
28
|
+
|
|
29
|
+
abstract getPaginatedItems(): Item[];
|
|
30
|
+
|
|
31
|
+
hasNextPage(): boolean {
|
|
32
|
+
const items = this.getPaginatedItems();
|
|
33
|
+
if (!items.length) return false;
|
|
34
|
+
return this.nextPageRequestOptions() != null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async getNextPage(): Promise<this> {
|
|
38
|
+
const nextOptions = this.nextPageRequestOptions();
|
|
39
|
+
if (!nextOptions) {
|
|
40
|
+
throw new AintSDKError(
|
|
41
|
+
'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.',
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return await this.#client.requestAPIList(this.constructor as any, nextOptions);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async *iterPages(): AsyncGenerator<this> {
|
|
49
|
+
let page: this = this;
|
|
50
|
+
yield page;
|
|
51
|
+
while (page.hasNextPage()) {
|
|
52
|
+
page = await page.getNextPage();
|
|
53
|
+
yield page;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
58
|
+
for await (const page of this.iterPages()) {
|
|
59
|
+
for (const item of page.getPaginatedItems()) {
|
|
60
|
+
yield item;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* This subclass of Promise will resolve to an instantiated Page once the request completes.
|
|
68
|
+
*
|
|
69
|
+
* It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg:
|
|
70
|
+
*
|
|
71
|
+
* for await (const item of client.items.list()) {
|
|
72
|
+
* console.log(item)
|
|
73
|
+
* }
|
|
74
|
+
*/
|
|
75
|
+
export class PagePromise<
|
|
76
|
+
PageClass extends AbstractPage<Item>,
|
|
77
|
+
Item = ReturnType<PageClass['getPaginatedItems']>[number],
|
|
78
|
+
>
|
|
79
|
+
extends APIPromise<PageClass>
|
|
80
|
+
implements AsyncIterable<Item>
|
|
81
|
+
{
|
|
82
|
+
constructor(
|
|
83
|
+
client: AintSDK,
|
|
84
|
+
request: Promise<APIResponseProps>,
|
|
85
|
+
Page: new (...args: ConstructorParameters<typeof AbstractPage>) => PageClass,
|
|
86
|
+
) {
|
|
87
|
+
super(
|
|
88
|
+
client,
|
|
89
|
+
request,
|
|
90
|
+
async (client, props) =>
|
|
91
|
+
new Page(client, props.response, await defaultParseResponse(client, props), props.options),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Allow auto-paginating iteration on an unawaited list call, eg:
|
|
97
|
+
*
|
|
98
|
+
* for await (const item of client.items.list()) {
|
|
99
|
+
* console.log(item)
|
|
100
|
+
* }
|
|
101
|
+
*/
|
|
102
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
103
|
+
const page = await this;
|
|
104
|
+
for await (const item of page) {
|
|
105
|
+
yield item;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface PageNumberPaginationResponse<Item> {
|
|
111
|
+
data: Array<Item>;
|
|
112
|
+
|
|
113
|
+
page: number;
|
|
114
|
+
|
|
115
|
+
total_pages: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface PageNumberPaginationParams {
|
|
119
|
+
page?: number;
|
|
120
|
+
|
|
121
|
+
page_size?: number;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export class PageNumberPagination<Item>
|
|
125
|
+
extends AbstractPage<Item>
|
|
126
|
+
implements PageNumberPaginationResponse<Item>
|
|
127
|
+
{
|
|
128
|
+
data: Array<Item>;
|
|
129
|
+
|
|
130
|
+
page: number;
|
|
131
|
+
|
|
132
|
+
total_pages: number;
|
|
133
|
+
|
|
134
|
+
constructor(
|
|
135
|
+
client: AintSDK,
|
|
136
|
+
response: Response,
|
|
137
|
+
body: PageNumberPaginationResponse<Item>,
|
|
138
|
+
options: FinalRequestOptions,
|
|
139
|
+
) {
|
|
140
|
+
super(client, response, body, options);
|
|
141
|
+
|
|
142
|
+
this.data = body.data || [];
|
|
143
|
+
this.page = body.page || 0;
|
|
144
|
+
this.total_pages = body.total_pages || 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
getPaginatedItems(): Item[] {
|
|
148
|
+
return this.data ?? [];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
nextPageRequestOptions(): PageRequestOptions | null {
|
|
152
|
+
const currentPage = this.page;
|
|
153
|
+
|
|
154
|
+
if (currentPage >= this.total_pages) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
...this.options,
|
|
160
|
+
query: {
|
|
161
|
+
...maybeObj(this.options.query),
|
|
162
|
+
page: currentPage + 1,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { AintSDK as default } from './client';
|
|
|
5
5
|
export { type Uploadable, toFile } from './core/uploads';
|
|
6
6
|
export { APIPromise } from './core/api-promise';
|
|
7
7
|
export { AintSDK, type ClientOptions } from './client';
|
|
8
|
+
export { PagePromise } from './core/pagination';
|
|
8
9
|
export {
|
|
9
10
|
AintSDKError,
|
|
10
11
|
APIError,
|
package/src/resources/index.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
+
export {
|
|
4
|
+
Projects,
|
|
5
|
+
type Project,
|
|
6
|
+
type ProjectListResponse,
|
|
7
|
+
type ProjectCreateParams,
|
|
8
|
+
type ProjectUpdateParams,
|
|
9
|
+
type ProjectListParams,
|
|
10
|
+
type ProjectsPageNumberPagination,
|
|
11
|
+
} from './projects';
|
|
3
12
|
export { Users, type User } from './users';
|