@vertesia/client 0.60.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/AccountApi.d.ts +0 -1
- package/lib/types/AccountsApi.d.ts +0 -1
- package/lib/types/AnalyticsApi.d.ts +0 -1
- package/lib/types/ApiKeysApi.d.ts +0 -1
- package/lib/types/CommandsApi.d.ts +0 -1
- package/lib/types/EnvironmentsApi.d.ts +0 -1
- package/lib/types/IamApi.d.ts +0 -1
- package/lib/types/InteractionBase.d.ts +0 -1
- package/lib/types/InteractionsApi.d.ts +0 -1
- package/lib/types/PluginsApi.d.ts +0 -1
- package/lib/types/ProjectsApi.d.ts +0 -1
- package/lib/types/PromptsApi.d.ts +0 -1
- package/lib/types/RefsApi.d.ts +0 -1
- package/lib/types/RunsApi.d.ts +0 -1
- package/lib/types/StreamSource.d.ts +0 -1
- package/lib/types/TrainingApi.d.ts +0 -1
- package/lib/types/UsersApi.d.ts +0 -1
- package/lib/types/client.d.ts +0 -1
- package/lib/types/execute.d.ts +0 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/nodejs/NodeStreamSource.d.ts +0 -1
- package/lib/types/nodejs/index.d.ts +0 -1
- package/lib/types/store/AgentsApi.d.ts +0 -1
- package/lib/types/store/AnalyzeDocApi.d.ts +0 -1
- package/lib/types/store/CollectionsApi.d.ts +0 -1
- package/lib/types/store/CommandsApi.d.ts +0 -1
- package/lib/types/store/EmbeddingsApi.d.ts +0 -1
- package/lib/types/store/FilesApi.d.ts +6 -2
- package/lib/types/store/FilesApi.d.ts.map +1 -1
- package/lib/types/store/ObjectsApi.d.ts +7 -1
- package/lib/types/store/ObjectsApi.d.ts.map +1 -1
- package/lib/types/store/TypesApi.d.ts +0 -1
- package/lib/types/store/WorkflowsApi.d.ts +1 -2
- package/lib/types/store/WorkflowsApi.d.ts.map +1 -1
- package/lib/types/store/client.d.ts +0 -1
- package/lib/types/store/errors.d.ts +0 -1
- package/lib/types/store/index.d.ts +0 -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/FilesApi.ts
CHANGED
|
@@ -74,7 +74,7 @@ export class FilesApi extends ApiTopic {
|
|
|
74
74
|
*/
|
|
75
75
|
async uploadFile(source: StreamSource | File): Promise<string> {
|
|
76
76
|
const isStream = source instanceof StreamSource;
|
|
77
|
-
const { url, path } = await this.getUploadUrl(source);
|
|
77
|
+
const { url, id, path } = await this.getUploadUrl(source);
|
|
78
78
|
|
|
79
79
|
await fetch(url, {
|
|
80
80
|
method: "PUT",
|
|
@@ -94,15 +94,24 @@ export class FilesApi extends ApiTopic {
|
|
|
94
94
|
}
|
|
95
95
|
})
|
|
96
96
|
.catch((err) => {
|
|
97
|
-
console.error("Failed to upload file", err);
|
|
97
|
+
console.error("Failed to upload file", { err, url, id, path });
|
|
98
98
|
throw err;
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
return
|
|
101
|
+
return id;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @param location can be a relative path in the project, a reference to a cloud storage, or a accessible HTTPS URL (typically signed URL)
|
|
107
|
+
* @returns ReadableStream
|
|
108
|
+
*/
|
|
109
|
+
async downloadFile(location: string): Promise<ReadableStream<Uint8Array>> {
|
|
110
|
+
//if start with HTTPS, no download url needed - assume it's signed already
|
|
111
|
+
const needSign = !location.startsWith("https:");
|
|
112
|
+
const { url } = needSign
|
|
113
|
+
? await this.getDownloadUrl(location)
|
|
114
|
+
: { url: location };
|
|
106
115
|
|
|
107
116
|
const res = await fetch(url, {
|
|
108
117
|
method: "GET",
|
|
@@ -111,24 +120,24 @@ export class FilesApi extends ApiTopic {
|
|
|
111
120
|
if (res.ok) {
|
|
112
121
|
return res;
|
|
113
122
|
} else if (res.status === 404) {
|
|
114
|
-
throw new Error(`File ${
|
|
123
|
+
throw new Error(`File ${location} not found`); //TODO: type fetch error better with a fetch error class
|
|
115
124
|
} else if (res.status === 403) {
|
|
116
|
-
throw new Error(`File ${
|
|
125
|
+
throw new Error(`File ${location} is forbidden`);
|
|
117
126
|
} else {
|
|
118
127
|
console.log(res);
|
|
119
128
|
throw new Error(
|
|
120
|
-
`Failed to download file ${
|
|
129
|
+
`Failed to download file ${location}: ${res.statusText}`,
|
|
121
130
|
);
|
|
122
131
|
}
|
|
123
132
|
})
|
|
124
133
|
.catch((err) => {
|
|
125
|
-
console.error(`Failed to download file ${
|
|
134
|
+
console.error(`Failed to download file ${location}.`, err);
|
|
126
135
|
throw err;
|
|
127
136
|
});
|
|
128
137
|
|
|
129
138
|
if (!res.body) {
|
|
130
139
|
throw new Error(
|
|
131
|
-
`No body in response while downloading
|
|
140
|
+
`No body in response while downloading file ${location}`,
|
|
132
141
|
);
|
|
133
142
|
}
|
|
134
143
|
|