@vertesia/client 1.5.0-dev.20260717.131047Z → 1.5.0-dev.20260725.083715Z
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/AppsApi.d.ts +41 -7
- package/lib/AppsApi.d.ts.map +1 -1
- package/lib/AppsApi.js +72 -7
- package/lib/AppsApi.js.map +1 -1
- package/lib/AuditTrailApi.d.ts +2 -1
- package/lib/AuditTrailApi.d.ts.map +1 -1
- package/lib/AuditTrailApi.js +3 -0
- package/lib/AuditTrailApi.js.map +1 -1
- package/lib/ProjectsApi.d.ts +3 -1
- package/lib/ProjectsApi.d.ts.map +1 -1
- package/lib/ProjectsApi.js +16 -8
- package/lib/ProjectsApi.js.map +1 -1
- package/lib/ViewsApi.d.ts +21 -0
- package/lib/ViewsApi.d.ts.map +1 -0
- package/lib/ViewsApi.js +41 -0
- package/lib/ViewsApi.js.map +1 -0
- package/lib/client.d.ts +3 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +4 -1
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/store/AgentsApi.d.ts +5 -1
- package/lib/store/AgentsApi.d.ts.map +1 -1
- package/lib/store/AgentsApi.js +8 -0
- package/lib/store/AgentsApi.js.map +1 -1
- package/lib/store/AnalyzeDocApi.d.ts +9 -11
- package/lib/store/AnalyzeDocApi.d.ts.map +1 -1
- package/lib/store/AnalyzeDocApi.js +12 -36
- package/lib/store/AnalyzeDocApi.js.map +1 -1
- package/lib/store/FilesApi.d.ts.map +1 -1
- package/lib/store/FilesApi.js +10 -4
- package/lib/store/FilesApi.js.map +1 -1
- package/lib/store/ObjectsApi.d.ts.map +1 -1
- package/lib/store/ObjectsApi.js +3 -2
- package/lib/store/ObjectsApi.js.map +1 -1
- package/lib/store/ViewsApi.d.ts +12 -0
- package/lib/store/ViewsApi.d.ts.map +1 -0
- package/lib/store/ViewsApi.js +17 -0
- package/lib/store/ViewsApi.js.map +1 -0
- package/lib/store/client.d.ts +2 -0
- package/lib/store/client.d.ts.map +1 -1
- package/lib/store/client.js +2 -0
- package/lib/store/client.js.map +1 -1
- package/lib/store/index.d.ts +1 -0
- package/lib/store/index.d.ts.map +1 -1
- package/lib/store/index.js +1 -0
- package/lib/store/index.js.map +1 -1
- package/lib/store/uploadMimeType.d.ts +3 -0
- package/lib/store/uploadMimeType.d.ts.map +1 -0
- package/lib/store/uploadMimeType.js +11 -0
- package/lib/store/uploadMimeType.js.map +1 -0
- package/lib/vertesia-client.js +5 -5
- package/lib/vertesia-client.js.map +1 -1
- package/package.json +8 -8
- package/src/AppsApi.test.ts +132 -0
- package/src/AppsApi.ts +100 -9
- package/src/AuditTrailApi.ts +10 -1
- package/src/ProjectsApi.test.ts +33 -0
- package/src/ProjectsApi.ts +19 -8
- package/src/ViewsApi.test.ts +36 -0
- package/src/ViewsApi.ts +60 -0
- package/src/client.ts +4 -1
- package/src/index.ts +1 -0
- package/src/store/AgentsApi.ts +17 -0
- package/src/store/AnalyzeDocApi.ts +16 -54
- package/src/store/FilesApi.ts +10 -4
- package/src/store/ObjectsApi.ts +3 -2
- package/src/store/ViewsApi.test.ts +33 -0
- package/src/store/ViewsApi.ts +20 -0
- package/src/store/client.ts +2 -0
- package/src/store/index.ts +1 -0
- package/src/store/uploadMimeType.test.ts +22 -0
- package/src/store/uploadMimeType.ts +16 -0
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import { ApiTopic, type ClientBase
|
|
1
|
+
import { ApiTopic, type ClientBase } from '@vertesia/api-fetch-client';
|
|
2
2
|
import type {
|
|
3
|
-
AdaptedTable,
|
|
4
|
-
AdaptTablesRequest,
|
|
5
3
|
DocAnalyzeRunStatusResponse,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ExportTableFormats,
|
|
11
|
-
GetAdaptedTablesRequestQuery,
|
|
12
|
-
PdfToRichtextOptions,
|
|
13
|
-
WorkflowRunStatus,
|
|
4
|
+
DocumentPrepOptions,
|
|
5
|
+
GroundedAssistantResponse,
|
|
6
|
+
GroundedExtractionRequest,
|
|
7
|
+
GroundedExtractionResultResponse,
|
|
14
8
|
} from '@vertesia/common';
|
|
15
9
|
|
|
16
10
|
export class AnalyzeDocApi extends ApiTopic {
|
|
@@ -21,7 +15,7 @@ export class AnalyzeDocApi extends ApiTopic {
|
|
|
21
15
|
super(parent, `/${objectId}/analyze`);
|
|
22
16
|
}
|
|
23
17
|
|
|
24
|
-
async start(payload:
|
|
18
|
+
async start(payload: DocumentPrepOptions): Promise<DocAnalyzeRunStatusResponse> {
|
|
25
19
|
return this.post('/', { payload });
|
|
26
20
|
}
|
|
27
21
|
|
|
@@ -29,51 +23,19 @@ export class AnalyzeDocApi extends ApiTopic {
|
|
|
29
23
|
return this.get('/status');
|
|
30
24
|
}
|
|
31
25
|
|
|
32
|
-
async
|
|
33
|
-
return this.
|
|
26
|
+
async startGroundedExtraction(payload?: GroundedExtractionRequest): Promise<DocAnalyzeRunStatusResponse> {
|
|
27
|
+
return this.post('/grounded', { payload: payload ?? {} });
|
|
34
28
|
}
|
|
35
29
|
|
|
36
|
-
async
|
|
37
|
-
return this.
|
|
30
|
+
async getGroundedExtractionResult(): Promise<GroundedExtractionResultResponse> {
|
|
31
|
+
return this.get('/grounded/result');
|
|
38
32
|
}
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// Build query parameters
|
|
47
|
-
const queryParams: NonNullable<IRequestParams['query']> = {};
|
|
48
|
-
if (query?.format) queryParams.format = query.format;
|
|
49
|
-
if (query?.raw !== undefined) queryParams.raw = query.raw;
|
|
50
|
-
|
|
51
|
-
// If format is CSV, set response type to text to avoid automatic JSON parsing
|
|
52
|
-
const options: IRequestParams & { responseType?: 'text' } = { query: queryParams };
|
|
53
|
-
if (query?.format === 'csv') {
|
|
54
|
-
options.responseType = 'text';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return this.get(path, options);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async getXml(): Promise<string> {
|
|
61
|
-
return this.get('/xml');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async getTables(format?: ExportTableFormats): Promise<DocTableCsv[] | DocTableJson[]> {
|
|
65
|
-
const options: IRequestParams = {};
|
|
66
|
-
if (format) {
|
|
67
|
-
options.query = { format: format };
|
|
68
|
-
}
|
|
69
|
-
return this.get('/tables', options);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async getImages(): Promise<DocImage[]> {
|
|
73
|
-
return this.get('/images');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async getAnnotated(): Promise<{ url: string }> {
|
|
77
|
-
return this.get('/annotated');
|
|
34
|
+
/**
|
|
35
|
+
* Launch the interactive grounded extraction assistant for this document.
|
|
36
|
+
* Returns the agent_run_id used to stream/render the conversation.
|
|
37
|
+
*/
|
|
38
|
+
async startGroundedAssistant(payload?: GroundedExtractionRequest): Promise<GroundedAssistantResponse> {
|
|
39
|
+
return this.post('/grounded/assistant', { payload: payload ?? {} });
|
|
78
40
|
}
|
|
79
41
|
}
|
package/src/store/FilesApi.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
} from '@vertesia/common';
|
|
18
18
|
import { StreamSource } from '../StreamSource.js';
|
|
19
19
|
import { fetchSignedUrl } from './signed-url.js';
|
|
20
|
+
import { getUploadMimeTypeHint, resolveUploadMimeType } from './uploadMimeType.js';
|
|
20
21
|
|
|
21
22
|
export const MEMORIES_PREFIX = 'memories';
|
|
22
23
|
export const ARTIFACTS_PREFIX = 'agents';
|
|
@@ -137,7 +138,7 @@ export class FilesApi extends ApiTopic {
|
|
|
137
138
|
): Promise<{ source: string; name: string; type?: string; etag?: string }[]> {
|
|
138
139
|
const fileDescriptors = sources.map((s) => ({
|
|
139
140
|
name: s.name,
|
|
140
|
-
mime_type: s.type,
|
|
141
|
+
mime_type: getUploadMimeTypeHint(s.type),
|
|
141
142
|
id: s instanceof StreamSource ? s.id : undefined,
|
|
142
143
|
}));
|
|
143
144
|
|
|
@@ -153,7 +154,7 @@ export class FilesApi extends ApiTopic {
|
|
|
153
154
|
const idx = i + j;
|
|
154
155
|
const { url, id, mime_type } = files[idx];
|
|
155
156
|
const isStream = source instanceof StreamSource;
|
|
156
|
-
const sourceMimeType = source.type
|
|
157
|
+
const sourceMimeType = resolveUploadMimeType(source.type, mime_type);
|
|
157
158
|
|
|
158
159
|
const res = await fetchSignedUrl(url, {
|
|
159
160
|
method: 'PUT',
|
|
@@ -193,13 +194,18 @@ export class FilesApi extends ApiTopic {
|
|
|
193
194
|
*/
|
|
194
195
|
async uploadFileWithPath(source: StreamSource | File): Promise<{ id: string; path: string }> {
|
|
195
196
|
const isStream = source instanceof StreamSource;
|
|
196
|
-
const { url, id, path } = await this.getUploadUrl(
|
|
197
|
+
const { url, id, path, mime_type } = await this.getUploadUrl({
|
|
198
|
+
id: isStream ? source.id : undefined,
|
|
199
|
+
name: source.name,
|
|
200
|
+
mime_type: getUploadMimeTypeHint(source.type),
|
|
201
|
+
});
|
|
202
|
+
const sourceMimeType = resolveUploadMimeType(source.type, mime_type) || 'application/gzip';
|
|
197
203
|
|
|
198
204
|
const res = await fetchSignedUrl(url, {
|
|
199
205
|
method: 'PUT',
|
|
200
206
|
body: isStream ? source.stream : source,
|
|
201
207
|
headers: {
|
|
202
|
-
'Content-Type':
|
|
208
|
+
'Content-Type': sourceMimeType,
|
|
203
209
|
},
|
|
204
210
|
}).catch((err) => {
|
|
205
211
|
console.error('Failed to upload file', { err, url, id, path });
|
package/src/store/ObjectsApi.ts
CHANGED
|
@@ -56,6 +56,7 @@ import { StreamSource } from '../StreamSource.js';
|
|
|
56
56
|
import { AnalyzeDocApi } from './AnalyzeDocApi.js';
|
|
57
57
|
import type { ZenoClient } from './client.js';
|
|
58
58
|
import { fetchSignedUrl } from './signed-url.js';
|
|
59
|
+
import { getUploadMimeTypeHint, resolveUploadMimeType } from './uploadMimeType.js';
|
|
59
60
|
|
|
60
61
|
type ContentObjectWritePayload = Omit<CreateContentObjectPayload, 'content'> & {
|
|
61
62
|
content?: ContentSource | File | StreamSource;
|
|
@@ -259,9 +260,9 @@ export class ObjectsApi extends ApiTopic {
|
|
|
259
260
|
const { url, id, mime_type } = await this.getUploadUrl({
|
|
260
261
|
id: isStream ? source.id : undefined,
|
|
261
262
|
name: source.name,
|
|
262
|
-
mime_type: source.type,
|
|
263
|
+
mime_type: getUploadMimeTypeHint(source.type),
|
|
263
264
|
});
|
|
264
|
-
const sourceMimeType = source.type
|
|
265
|
+
const sourceMimeType = resolveUploadMimeType(source.type, mime_type);
|
|
265
266
|
|
|
266
267
|
// upload the file content to the signed URL
|
|
267
268
|
const res = await fetchSignedUrl(url, {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { ZenoClient } from './client.js';
|
|
3
|
+
|
|
4
|
+
describe('StoreViewsApi', () => {
|
|
5
|
+
it('uses the View execution resource for persisted and draft execution', async () => {
|
|
6
|
+
const requests: Request[] = [];
|
|
7
|
+
const fetchMock = vi.fn(async () => {
|
|
8
|
+
return new Response(JSON.stringify({}), {
|
|
9
|
+
status: 200,
|
|
10
|
+
headers: { 'content-type': 'application/json' },
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
const client = new ZenoClient({
|
|
14
|
+
serverUrl: 'https://api.example.com',
|
|
15
|
+
fetch: fetchMock,
|
|
16
|
+
onRequest: (request) => requests.push(request),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
await client.views.execute('app:content:document-library');
|
|
20
|
+
await client.views.preview({
|
|
21
|
+
configuration: {
|
|
22
|
+
name: 'Document library',
|
|
23
|
+
description: 'Browse documents.',
|
|
24
|
+
scope: {},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
expect(requests.map((request) => request.url)).toEqual([
|
|
29
|
+
'https://api.example.com/api/v1/view-executions/app%3Acontent%3Adocument-library/execute',
|
|
30
|
+
'https://api.example.com/api/v1/view-executions/preview',
|
|
31
|
+
]);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ApiTopic, type ClientBase } from '@vertesia/api-fetch-client';
|
|
2
|
+
import type { ExecuteViewRequest, PreviewViewExperienceRequest, ViewExecutionResult } from '@vertesia/common';
|
|
3
|
+
|
|
4
|
+
export class StoreViewsApi extends ApiTopic {
|
|
5
|
+
constructor(parent: ClientBase) {
|
|
6
|
+
super(parent, '/api/v1/view-executions');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
execute(id: string, payload: ExecuteViewRequest = {}): Promise<ViewExecutionResult> {
|
|
10
|
+
return this.post(`/${encodeURIComponent(id)}/execute`, { payload });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Validate and execute an unsaved View configuration without persisting it.
|
|
15
|
+
* Returns the same normalized results as {@link execute}.
|
|
16
|
+
*/
|
|
17
|
+
preview(payload: PreviewViewExperienceRequest): Promise<ViewExecutionResult> {
|
|
18
|
+
return this.post('/preview', { payload });
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/store/client.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { RenderingApi } from './RenderingApi.js';
|
|
|
24
24
|
import { SchedulesApi } from './SchedulesApi.js';
|
|
25
25
|
import { TaskApi } from './TaskApi.js';
|
|
26
26
|
import { TypesApi } from './TypesApi.js';
|
|
27
|
+
import { StoreViewsApi } from './ViewsApi.js';
|
|
27
28
|
import { VERSION, VERSION_HEADER } from './version.js';
|
|
28
29
|
import { WorkflowsApi } from './WorkflowsApi.js';
|
|
29
30
|
|
|
@@ -125,4 +126,5 @@ export class ZenoClient extends AbstractFetchClient<ZenoClient> {
|
|
|
125
126
|
query = new QueryApi(this);
|
|
126
127
|
hiveMemory = new HiveMemoryApi(this);
|
|
127
128
|
rendering = new RenderingApi(this);
|
|
129
|
+
views = new StoreViewsApi(this);
|
|
128
130
|
}
|
package/src/store/index.ts
CHANGED
|
@@ -20,5 +20,6 @@ export * from './signed-url.js';
|
|
|
20
20
|
export * from './TaskApi.js';
|
|
21
21
|
export * from './TypeCatalogApi.js';
|
|
22
22
|
export * from './TypesApi.js';
|
|
23
|
+
export * from './ViewsApi.js';
|
|
23
24
|
export { APP_VERSION_HEADER } from './version.js';
|
|
24
25
|
export * from './WorkflowsApi.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { getUploadMimeTypeHint, resolveUploadMimeType } from './uploadMimeType.js';
|
|
3
|
+
|
|
4
|
+
describe('upload MIME type resolution', () => {
|
|
5
|
+
it('keeps a specific browser-provided content type', () => {
|
|
6
|
+
expect(getUploadMimeTypeHint('text/plain')).toBe('text/plain');
|
|
7
|
+
expect(resolveUploadMimeType('text/plain', 'text/markdown')).toBe('text/plain');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('uses filename inference when the browser reports generic binary content', () => {
|
|
11
|
+
expect(getUploadMimeTypeHint('application/octet-stream')).toBeUndefined();
|
|
12
|
+
expect(resolveUploadMimeType('application/octet-stream', 'text/markdown')).toBe('text/markdown');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('uses filename inference when the browser omits the content type', () => {
|
|
16
|
+
expect(resolveUploadMimeType('', 'text/markdown')).toBe('text/markdown');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('retains octet-stream when no more specific type can be inferred', () => {
|
|
20
|
+
expect(resolveUploadMimeType('application/octet-stream', undefined)).toBe('application/octet-stream');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const GENERIC_BINARY_CONTENT_TYPE = 'application/octet-stream';
|
|
2
|
+
|
|
3
|
+
function normalizedContentType(contentType: string | undefined): string | undefined {
|
|
4
|
+
return contentType?.split(';', 1)[0]?.trim().toLowerCase() || undefined;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function getUploadMimeTypeHint(contentType: string | undefined): string | undefined {
|
|
8
|
+
return normalizedContentType(contentType) === GENERIC_BINARY_CONTENT_TYPE ? undefined : contentType || undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function resolveUploadMimeType(
|
|
12
|
+
sourceContentType: string | undefined,
|
|
13
|
+
inferredContentType: string | undefined,
|
|
14
|
+
): string | undefined {
|
|
15
|
+
return getUploadMimeTypeHint(sourceContentType) || inferredContentType || sourceContentType || undefined;
|
|
16
|
+
}
|