@objectstack/client 4.0.0 → 4.0.2
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/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +9 -0
- package/dist/index.d.mts +18 -8
- package/dist/index.d.ts +18 -8
- package/dist/index.js +20 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
- package/src/client.test.ts +4 -12
- package/src/index.ts +21 -17
package/src/client.test.ts
CHANGED
|
@@ -486,18 +486,10 @@ describe('AI namespace', () => {
|
|
|
486
486
|
expect(opts.method).toBe('POST');
|
|
487
487
|
});
|
|
488
488
|
|
|
489
|
-
it('should chat
|
|
490
|
-
const { client
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
});
|
|
494
|
-
const result = await client.ai.chat({
|
|
495
|
-
message: 'Show me customer stats',
|
|
496
|
-
conversationId: 'conv-1'
|
|
497
|
-
});
|
|
498
|
-
expect(result.conversationId).toBe('conv-1');
|
|
499
|
-
const body = JSON.parse(fetchMock.mock.calls[0][1].body);
|
|
500
|
-
expect(body.message).toBe('Show me customer stats');
|
|
489
|
+
it('should not expose chat method (use Vercel AI SDK useChat directly)', () => {
|
|
490
|
+
const { client } = createMockClient({ success: true, data: {} });
|
|
491
|
+
// ai.chat was removed — consumers should use @ai-sdk/react useChat() directly
|
|
492
|
+
expect(client.ai).not.toHaveProperty('chat');
|
|
501
493
|
});
|
|
502
494
|
|
|
503
495
|
it('should get AI suggestions', async () => {
|
package/src/index.ts
CHANGED
|
@@ -62,8 +62,6 @@ import {
|
|
|
62
62
|
MarkAllNotificationsReadResponse,
|
|
63
63
|
AiNlqRequest,
|
|
64
64
|
AiNlqResponse,
|
|
65
|
-
AiChatRequest,
|
|
66
|
-
AiChatResponse,
|
|
67
65
|
AiSuggestRequest,
|
|
68
66
|
AiSuggestResponse,
|
|
69
67
|
AiInsightsRequest,
|
|
@@ -361,10 +359,15 @@ export class ObjectStackClient {
|
|
|
361
359
|
* Get a specific metadata item by type and name
|
|
362
360
|
* @param type - Metadata type (e.g., 'object', 'plugin')
|
|
363
361
|
* @param name - Item name (snake_case identifier)
|
|
362
|
+
* @param options - Optional filters (e.g., packageId to scope by package)
|
|
364
363
|
*/
|
|
365
|
-
getItem: async (type: string, name: string) => {
|
|
364
|
+
getItem: async (type: string, name: string, options?: { packageId?: string }) => {
|
|
366
365
|
const route = this.getRoute('metadata');
|
|
367
|
-
const
|
|
366
|
+
const params = new URLSearchParams();
|
|
367
|
+
if (options?.packageId) params.set('package', options.packageId);
|
|
368
|
+
const qs = params.toString();
|
|
369
|
+
const url = `${this.baseUrl}${route}/${type}/${name}${qs ? `?${qs}` : ''}`;
|
|
370
|
+
const res = await this.fetch(url);
|
|
368
371
|
return this.unwrapResponse(res);
|
|
369
372
|
},
|
|
370
373
|
|
|
@@ -382,6 +385,19 @@ export class ObjectStackClient {
|
|
|
382
385
|
});
|
|
383
386
|
return this.unwrapResponse(res);
|
|
384
387
|
},
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Delete a metadata item
|
|
391
|
+
* @param type - Metadata type (e.g., 'object', 'plugin')
|
|
392
|
+
* @param name - Item name (snake_case identifier)
|
|
393
|
+
*/
|
|
394
|
+
deleteItem: async (type: string, name: string): Promise<{ type: string; name: string; deleted: boolean }> => {
|
|
395
|
+
const route = this.getRoute('metadata');
|
|
396
|
+
const res = await this.fetch(`${this.baseUrl}${route}/${encodeURIComponent(type)}/${encodeURIComponent(name)}`, {
|
|
397
|
+
method: 'DELETE',
|
|
398
|
+
});
|
|
399
|
+
return this.unwrapResponse(res);
|
|
400
|
+
},
|
|
385
401
|
|
|
386
402
|
/**
|
|
387
403
|
* Get object metadata with cache support
|
|
@@ -1209,17 +1225,7 @@ export class ObjectStackClient {
|
|
|
1209
1225
|
return this.unwrapResponse<AiNlqResponse>(res);
|
|
1210
1226
|
},
|
|
1211
1227
|
|
|
1212
|
-
|
|
1213
|
-
* Multi-turn AI chat
|
|
1214
|
-
*/
|
|
1215
|
-
chat: async (request: AiChatRequest): Promise<AiChatResponse> => {
|
|
1216
|
-
const route = this.getRoute('ai');
|
|
1217
|
-
const res = await this.fetch(`${this.baseUrl}${route}/chat`, {
|
|
1218
|
-
method: 'POST',
|
|
1219
|
-
body: JSON.stringify(request)
|
|
1220
|
-
});
|
|
1221
|
-
return this.unwrapResponse<AiChatResponse>(res);
|
|
1222
|
-
},
|
|
1228
|
+
// AI chat method removed — use Vercel AI SDK `useChat()` / `@ai-sdk/react` directly.
|
|
1223
1229
|
|
|
1224
1230
|
/**
|
|
1225
1231
|
* AI-powered field value suggestions
|
|
@@ -1826,8 +1832,6 @@ export type {
|
|
|
1826
1832
|
ListNotificationsResponse,
|
|
1827
1833
|
AiNlqRequest,
|
|
1828
1834
|
AiNlqResponse,
|
|
1829
|
-
AiChatRequest,
|
|
1830
|
-
AiChatResponse,
|
|
1831
1835
|
AiSuggestRequest,
|
|
1832
1836
|
AiSuggestResponse,
|
|
1833
1837
|
AiInsightsRequest,
|