@vertesia/client 0.59.0 → 0.61.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/lib/cjs/store/FilesApi.js +19 -10
- package/lib/cjs/store/FilesApi.js.map +1 -1
- package/lib/cjs/store/ObjectsApi.js +28 -17
- package/lib/cjs/store/ObjectsApi.js.map +1 -1
- package/lib/cjs/store/WorkflowsApi.js +9 -2
- package/lib/cjs/store/WorkflowsApi.js.map +1 -1
- package/lib/esm/store/FilesApi.js +19 -10
- package/lib/esm/store/FilesApi.js.map +1 -1
- package/lib/esm/store/ObjectsApi.js +28 -17
- package/lib/esm/store/ObjectsApi.js.map +1 -1
- package/lib/esm/store/WorkflowsApi.js +9 -2
- package/lib/esm/store/WorkflowsApi.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/store/FilesApi.d.ts +6 -1
- package/lib/types/store/FilesApi.d.ts.map +1 -1
- package/lib/types/store/ObjectsApi.d.ts +7 -0
- package/lib/types/store/ObjectsApi.d.ts.map +1 -1
- package/lib/types/store/WorkflowsApi.d.ts +1 -1
- package/lib/types/store/WorkflowsApi.d.ts.map +1 -1
- package/lib/vertesia-client.js +1 -1
- package/lib/vertesia-client.js.map +1 -1
- package/package.json +3 -3
- package/src/store/FilesApi.ts +19 -10
- package/src/store/ObjectsApi.ts +338 -324
- package/src/store/WorkflowsApi.ts +12 -4
package/src/store/ObjectsApi.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
ComplexSearchPayload,
|
|
4
|
+
ComputeObjectFacetPayload,
|
|
5
|
+
ContentObject,
|
|
6
|
+
ContentObjectItem,
|
|
7
|
+
ContentSource,
|
|
8
|
+
CreateContentObjectPayload,
|
|
9
|
+
Embedding,
|
|
10
|
+
ExportPropertiesPayload,
|
|
11
|
+
ExportPropertiesResponse,
|
|
12
|
+
FindPayload,
|
|
13
|
+
GetFileUrlPayload,
|
|
14
|
+
GetFileUrlResponse,
|
|
15
|
+
GetRenditionParams,
|
|
16
|
+
GetRenditionResponse,
|
|
17
|
+
GetUploadUrlPayload,
|
|
18
|
+
ListWorkflowRunsResponse,
|
|
19
|
+
ObjectSearchPayload,
|
|
20
|
+
ObjectSearchQuery,
|
|
21
|
+
SupportedEmbeddingTypes,
|
|
22
22
|
} from "@vertesia/common";
|
|
23
23
|
|
|
24
24
|
import { StreamSource } from "../StreamSource.js";
|
|
@@ -26,141 +26,141 @@ import { AnalyzeDocApi } from "./AnalyzeDocApi.js";
|
|
|
26
26
|
import { ZenoClient } from "./client.js";
|
|
27
27
|
|
|
28
28
|
export interface UploadContentObjectPayload
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
extends Omit<CreateContentObjectPayload, "content"> {
|
|
30
|
+
content?:
|
|
31
|
+
| StreamSource
|
|
32
|
+
| File
|
|
33
|
+
| {
|
|
34
|
+
// the source URI
|
|
35
|
+
source: string;
|
|
36
|
+
// the original name of the input file if any
|
|
37
|
+
name?: string;
|
|
38
|
+
// the mime type of the content source.
|
|
39
|
+
type?: string;
|
|
40
|
+
|
|
41
|
+
// the target id in the content store
|
|
42
|
+
id?: string;
|
|
43
|
+
};
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export interface ComputeFacetsResponse {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
type?: { _id: string; count: number }[];
|
|
48
|
+
location?: { _id: string; count: number }[];
|
|
49
|
+
status?: { _id: string; count: number }[];
|
|
50
|
+
total?: { count: number }[];
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export class ObjectsApi extends ApiTopic {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
54
|
+
constructor(parent: ClientBase) {
|
|
55
|
+
super(parent, "/api/v1/objects");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
analyze(objectId: string) {
|
|
59
|
+
return new AnalyzeDocApi(this, objectId);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getUploadUrl(payload: GetUploadUrlPayload): Promise<GetFileUrlResponse> {
|
|
63
|
+
return this.post("/upload-url", {
|
|
64
|
+
payload,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getDownloadUrl(fileUri: string): Promise<{ url: string }> {
|
|
69
|
+
return this.post("/download-url", {
|
|
70
|
+
payload: {
|
|
71
|
+
file: fileUri,
|
|
72
|
+
} satisfies GetFileUrlPayload,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getContentSource(objectId: string): Promise<ContentSource> {
|
|
77
|
+
return this.get(`/${objectId}/content-source`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* List objects with revision filtering options
|
|
82
|
+
*
|
|
83
|
+
* @param payload Search/filter parameters
|
|
84
|
+
* @returns Matching content objects
|
|
85
|
+
*/
|
|
86
|
+
list<T = any>(
|
|
87
|
+
payload: ObjectSearchPayload = {},
|
|
88
|
+
): Promise<ContentObjectItem<T>[]> {
|
|
89
|
+
const limit = payload.limit || 100;
|
|
90
|
+
const offset = payload.offset || 0;
|
|
91
|
+
const query = payload.query || ({} as ObjectSearchQuery);
|
|
92
|
+
|
|
93
|
+
// Add revision filtering options
|
|
94
|
+
const showAllRevisions = payload.all_revisions === true;
|
|
95
|
+
const revisionRoot = payload.from_root;
|
|
96
|
+
|
|
97
|
+
return this.get("/", {
|
|
98
|
+
query: {
|
|
99
|
+
limit,
|
|
100
|
+
offset,
|
|
101
|
+
...query,
|
|
102
|
+
all_revisions: showAllRevisions ? "true" : undefined,
|
|
103
|
+
from_root: revisionRoot,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
computeFacets(
|
|
109
|
+
query: ComputeObjectFacetPayload,
|
|
110
|
+
): Promise<ComputeFacetsResponse> {
|
|
111
|
+
return this.post("/facets", {
|
|
112
|
+
payload: query,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
listFolders(path: string = "/") {
|
|
117
|
+
path; //TODO
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Find object based on query */
|
|
121
|
+
find(payload: FindPayload): Promise<ContentObject[]> {
|
|
122
|
+
return this.post("/find", {
|
|
123
|
+
payload,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Count number of objects matching this query */
|
|
128
|
+
count(payload: FindPayload): Promise<{ count: number }> {
|
|
129
|
+
return this.post("/count", {
|
|
130
|
+
payload,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Search object — different from find because allow full text search */
|
|
135
|
+
search(payload: ComplexSearchPayload): Promise<ContentObjectItem[]> {
|
|
136
|
+
return this.post("/search", {
|
|
137
|
+
payload,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
retrieve(id: string, select?: string): Promise<ContentObject> {
|
|
142
|
+
return this.get(`/${id}`, {
|
|
143
|
+
query: {
|
|
144
|
+
select,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
getObjectText(id: string): Promise<{ text: string }> {
|
|
150
|
+
return this.get(`/${id}/text`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async upload(source: StreamSource | File) {
|
|
154
|
+
const isStream = source instanceof StreamSource;
|
|
155
|
+
// get a signed URL to upload the file a computed mimeType and the file object id.
|
|
156
|
+
const { url, id, mime_type } = await this.getUploadUrl({
|
|
157
|
+
id: isStream ? source.id : undefined,
|
|
158
|
+
name: source.name,
|
|
159
|
+
mime_type: source.type,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// upload the file content to the signed URL
|
|
163
|
+
/*const res = await this.fetch(url, {
|
|
164
164
|
method: 'PUT',
|
|
165
165
|
//@ts-ignore: duplex is not in the types. See https://github.com/node-fetch/node-fetch/issues/1769
|
|
166
166
|
duplex: isStream ? "half" : undefined,
|
|
@@ -177,186 +177,200 @@ export class ObjectsApi extends ApiTopic {
|
|
|
177
177
|
}
|
|
178
178
|
});*/
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
180
|
+
const res = await fetch(url, {
|
|
181
|
+
method: "PUT",
|
|
182
|
+
body: isStream ? source.stream : source,
|
|
183
|
+
//@ts-ignore: duplex is not in the types. See https://github.com/node-fetch/node-fetch/issues/1769
|
|
184
|
+
duplex: isStream ? "half" : undefined,
|
|
185
|
+
headers: {
|
|
186
|
+
"Content-Type": mime_type || "application/octet-stream",
|
|
187
|
+
},
|
|
188
|
+
})
|
|
189
|
+
.then((res: Response) => {
|
|
190
|
+
if (res.ok) {
|
|
191
|
+
return res;
|
|
192
|
+
} else {
|
|
193
|
+
console.log(res);
|
|
194
|
+
throw new Error(`Failed to upload file: ${res.statusText}`);
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
.catch((err) => {
|
|
198
|
+
console.error("Failed to upload file", err);
|
|
199
|
+
throw err;
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
//Etag need to be unquoted
|
|
203
|
+
//When a server returns an ETag header, it includes the quotes around the actual hash value.
|
|
204
|
+
//This is part of the HTTP specification (RFC 7232), which states that ETags should be
|
|
205
|
+
//enclosed in double quotes.
|
|
206
|
+
const etag = res.headers.get("etag")?.replace(/^"(.*)"$/, "$1");
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
source: id,
|
|
210
|
+
name: source.name,
|
|
211
|
+
type: mime_type,
|
|
212
|
+
etag,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async create(
|
|
217
|
+
payload: UploadContentObjectPayload,
|
|
218
|
+
options?: {
|
|
219
|
+
collection_id?: string;
|
|
220
|
+
},
|
|
221
|
+
): Promise<ContentObject> {
|
|
222
|
+
const createPayload: CreateContentObjectPayload = {
|
|
223
|
+
...payload,
|
|
224
|
+
};
|
|
225
|
+
if (
|
|
226
|
+
payload.content instanceof StreamSource ||
|
|
227
|
+
payload.content instanceof File
|
|
228
|
+
) {
|
|
229
|
+
createPayload.content = await this.upload(payload.content);
|
|
195
230
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
//Etag need to be unquoted
|
|
203
|
-
//When a server returns an ETag header, it includes the quotes around the actual hash value.
|
|
204
|
-
//This is part of the HTTP specification (RFC 7232), which states that ETags should be
|
|
205
|
-
//enclosed in double quotes.
|
|
206
|
-
const etag = res.headers.get("etag")?.replace(/^"(.*)"$/, "$1");
|
|
207
|
-
|
|
208
|
-
return {
|
|
209
|
-
source: id,
|
|
210
|
-
name: source.name,
|
|
211
|
-
type: mime_type,
|
|
212
|
-
etag,
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
async create(
|
|
217
|
-
payload: UploadContentObjectPayload,
|
|
218
|
-
options?: {
|
|
219
|
-
collection_id?: string;
|
|
220
|
-
},
|
|
221
|
-
): Promise<ContentObject> {
|
|
222
|
-
const createPayload: CreateContentObjectPayload = {
|
|
223
|
-
...payload,
|
|
224
|
-
};
|
|
225
|
-
if (
|
|
226
|
-
payload.content instanceof StreamSource ||
|
|
227
|
-
payload.content instanceof File
|
|
228
|
-
) {
|
|
229
|
-
createPayload.content = await this.upload(payload.content);
|
|
231
|
+
return await this.post("/", {
|
|
232
|
+
payload: createPayload,
|
|
233
|
+
query: options || {},
|
|
234
|
+
});
|
|
230
235
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
return await this.post("/", {
|
|
260
|
-
payload: createPayload,
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Updates an existing object or creates a new revision
|
|
266
|
-
* Handles file uploads similar to the create method
|
|
267
|
-
*
|
|
268
|
-
* @param id The ID of the object to update
|
|
269
|
-
* @param payload The changes to apply
|
|
270
|
-
* @param options Additional options
|
|
271
|
-
* @param options.createRevision Whether to create a new revision instead of updating in place
|
|
272
|
-
* @param options.revisionLabel Optional label for the revision (e.g., "v1.2")
|
|
273
|
-
* @returns The updated object or newly created revision
|
|
274
|
-
*/
|
|
275
|
-
async update(
|
|
276
|
-
id: string,
|
|
277
|
-
payload: Partial<CreateContentObjectPayload>,
|
|
278
|
-
options?: {
|
|
279
|
-
createRevision?: boolean;
|
|
280
|
-
revisionLabel?: string;
|
|
281
|
-
},
|
|
282
|
-
): Promise<ContentObject> {
|
|
283
|
-
const updatePayload: Partial<CreateContentObjectPayload> = {
|
|
284
|
-
...payload,
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
// Handle file upload if content is provided as File or StreamSource
|
|
288
|
-
if (
|
|
289
|
-
payload.content instanceof StreamSource ||
|
|
290
|
-
payload.content instanceof File
|
|
291
|
-
) {
|
|
292
|
-
updatePayload.content = await this.upload(payload.content);
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Create an object which holds a reference to an external blob (i.e. not in the project bucket)
|
|
239
|
+
* The uri should starts either with gs:// or s3://. Not other protocols are supported yet.
|
|
240
|
+
* For the s3 blobs you must use a hash with the blob #region. Ex: s3://bucket/path/to/file#us-east-1
|
|
241
|
+
* @param uri
|
|
242
|
+
* @param payload
|
|
243
|
+
* @returns
|
|
244
|
+
*/
|
|
245
|
+
async createFromExternalSource(
|
|
246
|
+
uri: string,
|
|
247
|
+
payload: CreateContentObjectPayload = {},
|
|
248
|
+
): Promise<ContentObject> {
|
|
249
|
+
const metadata = await (this.client as ZenoClient).files.getMetadata(
|
|
250
|
+
uri,
|
|
251
|
+
);
|
|
252
|
+
const createPayload: CreateContentObjectPayload = {
|
|
253
|
+
...payload,
|
|
254
|
+
content: {
|
|
255
|
+
source: uri,
|
|
256
|
+
name: metadata.name,
|
|
257
|
+
type: metadata.contentType,
|
|
258
|
+
etag: metadata.etag,
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
return await this.post("/", {
|
|
262
|
+
payload: createPayload,
|
|
263
|
+
});
|
|
293
264
|
}
|
|
294
265
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
266
|
+
/**
|
|
267
|
+
* Updates an existing object or creates a new revision
|
|
268
|
+
* Handles file uploads similar to the create method
|
|
269
|
+
*
|
|
270
|
+
* @param id The ID of the object to update
|
|
271
|
+
* @param payload The changes to apply
|
|
272
|
+
* @param options Additional options
|
|
273
|
+
* @param options.createRevision Whether to create a new revision instead of updating in place
|
|
274
|
+
* @param options.revisionLabel Optional label for the revision (e.g., "v1.2")
|
|
275
|
+
* @returns The updated object or newly created revision
|
|
276
|
+
*/
|
|
277
|
+
async update(
|
|
278
|
+
id: string,
|
|
279
|
+
payload: Partial<CreateContentObjectPayload>,
|
|
280
|
+
options?: {
|
|
281
|
+
createRevision?: boolean;
|
|
282
|
+
revisionLabel?: string;
|
|
301
283
|
},
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
284
|
+
): Promise<ContentObject> {
|
|
285
|
+
const updatePayload: Partial<CreateContentObjectPayload> = {
|
|
286
|
+
...payload,
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// Handle file upload if content is provided as File or StreamSource
|
|
290
|
+
if (
|
|
291
|
+
payload.content instanceof StreamSource ||
|
|
292
|
+
payload.content instanceof File
|
|
293
|
+
) {
|
|
294
|
+
updatePayload.content = await this.upload(payload.content);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (options?.createRevision) {
|
|
298
|
+
return this.put(`/${id}`, {
|
|
299
|
+
payload: updatePayload,
|
|
300
|
+
headers: {
|
|
301
|
+
"x-create-revision": "true",
|
|
302
|
+
"x-revision-label": options.revisionLabel || "",
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
} else {
|
|
306
|
+
return this.put(`/${id}`, {
|
|
307
|
+
payload: updatePayload,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Retrieves all revisions of a content object
|
|
314
|
+
*
|
|
315
|
+
* @param id The ID of any revision in the object's history
|
|
316
|
+
* @returns Array of all revisions sharing the same root
|
|
317
|
+
*/
|
|
318
|
+
getRevisions(id: string): Promise<ContentObjectItem[]> {
|
|
319
|
+
return this.get(`/${id}/revisions`);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Retrieves all collections that contain a specific object
|
|
324
|
+
*
|
|
325
|
+
* @param id The ID of the object
|
|
326
|
+
* @returns Array of collections containing this object (both static and dynamic)
|
|
327
|
+
*/
|
|
328
|
+
getCollections(id: string): Promise<any[]> {
|
|
329
|
+
return this.get(`/${id}/collections`);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
delete(id: string): Promise<{ id: string }> {
|
|
333
|
+
return this.del(`/${id}`);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
listWorkflowRuns(documentId: string): Promise<ListWorkflowRunsResponse> {
|
|
337
|
+
return this.get(`/${documentId}/workflow-runs`);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
listRenditions(documentId: string): Promise<ContentObjectItem[]> {
|
|
341
|
+
return this.get(`/${documentId}/renditions`);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
getRendition(
|
|
345
|
+
documentId: string,
|
|
346
|
+
options: GetRenditionParams,
|
|
347
|
+
): Promise<GetRenditionResponse> {
|
|
348
|
+
const query = {
|
|
349
|
+
max_hw: options.max_hw,
|
|
350
|
+
generate_if_missing: options.generate_if_missing,
|
|
351
|
+
sign_url: options.sign_url,
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
return this.get(`/${documentId}/renditions/${options.format}`, {
|
|
355
|
+
query,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
exportProperties(
|
|
360
|
+
payload: ExportPropertiesPayload,
|
|
361
|
+
): Promise<ExportPropertiesResponse> {
|
|
362
|
+
return this.post("/export", {
|
|
363
|
+
payload,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
setEmbedding(
|
|
368
|
+
id: string,
|
|
369
|
+
type: SupportedEmbeddingTypes,
|
|
370
|
+
payload: Embedding,
|
|
371
|
+
): Promise<Record<SupportedEmbeddingTypes, Embedding>> {
|
|
372
|
+
return this.put(`/${id}/embeddings/${type}`, {
|
|
373
|
+
payload,
|
|
374
|
+
});
|
|
307
375
|
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Retrieves all revisions of a content object
|
|
312
|
-
*
|
|
313
|
-
* @param id The ID of any revision in the object's history
|
|
314
|
-
* @returns Array of all revisions sharing the same root
|
|
315
|
-
*/
|
|
316
|
-
getRevisions(id: string): Promise<ContentObjectItem[]> {
|
|
317
|
-
return this.get(`/${id}/revisions`);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
delete(id: string): Promise<{ id: string }> {
|
|
321
|
-
return this.del(`/${id}`);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
listWorkflowRuns(documentId: string): Promise<ListWorkflowRunsResponse> {
|
|
325
|
-
return this.get(`/${documentId}/workflow-runs`);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
listRenditions(documentId: string): Promise<ContentObjectItem[]> {
|
|
329
|
-
return this.get(`/${documentId}/renditions`);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
getRendition(
|
|
333
|
-
documentId: string,
|
|
334
|
-
options: GetRenditionParams,
|
|
335
|
-
): Promise<GetRenditionResponse> {
|
|
336
|
-
const query = {
|
|
337
|
-
max_hw: options.max_hw,
|
|
338
|
-
generate_if_missing: options.generate_if_missing,
|
|
339
|
-
as_signed_url: options.sign_url,
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
return this.get(`/${documentId}/renditions/${options.format}`, { query });
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
exportProperties(
|
|
346
|
-
payload: ExportPropertiesPayload,
|
|
347
|
-
): Promise<ExportPropertiesResponse> {
|
|
348
|
-
return this.post("/export", {
|
|
349
|
-
payload,
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
setEmbedding(
|
|
354
|
-
id: string,
|
|
355
|
-
type: SupportedEmbeddingTypes,
|
|
356
|
-
payload: Embedding,
|
|
357
|
-
): Promise<Record<SupportedEmbeddingTypes, Embedding>> {
|
|
358
|
-
return this.put(`/${id}/embeddings/${type}`, {
|
|
359
|
-
payload,
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
376
|
}
|