@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.
Files changed (56) hide show
  1. package/lib/cjs/store/FilesApi.js +19 -10
  2. package/lib/cjs/store/FilesApi.js.map +1 -1
  3. package/lib/cjs/store/ObjectsApi.js +28 -17
  4. package/lib/cjs/store/ObjectsApi.js.map +1 -1
  5. package/lib/cjs/store/WorkflowsApi.js +9 -2
  6. package/lib/cjs/store/WorkflowsApi.js.map +1 -1
  7. package/lib/esm/store/FilesApi.js +19 -10
  8. package/lib/esm/store/FilesApi.js.map +1 -1
  9. package/lib/esm/store/ObjectsApi.js +28 -17
  10. package/lib/esm/store/ObjectsApi.js.map +1 -1
  11. package/lib/esm/store/WorkflowsApi.js +9 -2
  12. package/lib/esm/store/WorkflowsApi.js.map +1 -1
  13. package/lib/tsconfig.tsbuildinfo +1 -1
  14. package/lib/types/AccountApi.d.ts +0 -1
  15. package/lib/types/AccountsApi.d.ts +0 -1
  16. package/lib/types/AnalyticsApi.d.ts +0 -1
  17. package/lib/types/ApiKeysApi.d.ts +0 -1
  18. package/lib/types/CommandsApi.d.ts +0 -1
  19. package/lib/types/EnvironmentsApi.d.ts +0 -1
  20. package/lib/types/IamApi.d.ts +0 -1
  21. package/lib/types/InteractionBase.d.ts +0 -1
  22. package/lib/types/InteractionsApi.d.ts +0 -1
  23. package/lib/types/PluginsApi.d.ts +0 -1
  24. package/lib/types/ProjectsApi.d.ts +0 -1
  25. package/lib/types/PromptsApi.d.ts +0 -1
  26. package/lib/types/RefsApi.d.ts +0 -1
  27. package/lib/types/RunsApi.d.ts +0 -1
  28. package/lib/types/StreamSource.d.ts +0 -1
  29. package/lib/types/TrainingApi.d.ts +0 -1
  30. package/lib/types/UsersApi.d.ts +0 -1
  31. package/lib/types/client.d.ts +0 -1
  32. package/lib/types/execute.d.ts +0 -1
  33. package/lib/types/index.d.ts +0 -1
  34. package/lib/types/nodejs/NodeStreamSource.d.ts +0 -1
  35. package/lib/types/nodejs/index.d.ts +0 -1
  36. package/lib/types/store/AgentsApi.d.ts +0 -1
  37. package/lib/types/store/AnalyzeDocApi.d.ts +0 -1
  38. package/lib/types/store/CollectionsApi.d.ts +0 -1
  39. package/lib/types/store/CommandsApi.d.ts +0 -1
  40. package/lib/types/store/EmbeddingsApi.d.ts +0 -1
  41. package/lib/types/store/FilesApi.d.ts +6 -2
  42. package/lib/types/store/FilesApi.d.ts.map +1 -1
  43. package/lib/types/store/ObjectsApi.d.ts +7 -1
  44. package/lib/types/store/ObjectsApi.d.ts.map +1 -1
  45. package/lib/types/store/TypesApi.d.ts +0 -1
  46. package/lib/types/store/WorkflowsApi.d.ts +1 -2
  47. package/lib/types/store/WorkflowsApi.d.ts.map +1 -1
  48. package/lib/types/store/client.d.ts +0 -1
  49. package/lib/types/store/errors.d.ts +0 -1
  50. package/lib/types/store/index.d.ts +0 -1
  51. package/lib/vertesia-client.js +1 -1
  52. package/lib/vertesia-client.js.map +1 -1
  53. package/package.json +3 -3
  54. package/src/store/FilesApi.ts +19 -10
  55. package/src/store/ObjectsApi.ts +338 -324
  56. package/src/store/WorkflowsApi.ts +12 -4
@@ -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 path;
101
+ return id;
102
102
  }
103
103
 
104
- async downloadFile(name: string): Promise<ReadableStream<Uint8Array>> {
105
- const { url } = await this.getDownloadUrl(name);
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 ${name} not found`); //TODO: type fetch error better with a fetch error class
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 ${name} is forbidden`);
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 ${name}: ${res.statusText}`,
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 ${name}.`, err);
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 memory pack ${name}`,
140
+ `No body in response while downloading file ${location}`,
132
141
  );
133
142
  }
134
143