@inferencesh/sdk 0.6.14 → 0.6.19
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/README.md +1 -1
- package/dist/agent/actions.js +10 -0
- package/dist/agent/provider.d.ts +2 -1
- package/dist/agent/provider.js +5 -5
- package/dist/agent/types.d.ts +3 -0
- package/dist/api/apps.d.ts +4 -0
- package/dist/api/apps.js +6 -0
- package/dist/api/index.d.ts +3 -3
- package/dist/http/index.d.ts +3 -3
- package/dist/index.d.ts +9 -9
- package/dist/types.d.ts +131 -19
- package/dist/types.js +26 -9
- package/package.json +8 -5
- package/dist/agent/actions.test.d.ts +0 -1
- package/dist/agent/actions.test.js +0 -820
- package/dist/agent/api.test.d.ts +0 -1
- package/dist/agent/api.test.js +0 -246
- package/dist/agent/reducer.test.d.ts +0 -1
- package/dist/agent/reducer.test.js +0 -131
- package/dist/agent/types.test.d.ts +0 -1
- package/dist/agent/types.test.js +0 -75
- package/dist/api/agents.test.d.ts +0 -1
- package/dist/api/agents.test.js +0 -1014
- package/dist/api/api-keys.test.d.ts +0 -1
- package/dist/api/api-keys.test.js +0 -44
- package/dist/api/apps.test.d.ts +0 -1
- package/dist/api/apps.test.js +0 -135
- package/dist/api/chats.test.d.ts +0 -1
- package/dist/api/chats.test.js +0 -85
- package/dist/api/engines.test.d.ts +0 -1
- package/dist/api/engines.test.js +0 -133
- package/dist/api/files.test.d.ts +0 -1
- package/dist/api/files.test.js +0 -256
- package/dist/api/flow-runs.test.d.ts +0 -1
- package/dist/api/flow-runs.test.js +0 -97
- package/dist/api/flows.test.d.ts +0 -1
- package/dist/api/flows.test.js +0 -118
- package/dist/api/integrations.test.d.ts +0 -1
- package/dist/api/integrations.test.js +0 -109
- package/dist/api/knowledge.test.d.ts +0 -1
- package/dist/api/knowledge.test.js +0 -238
- package/dist/api/mcp-servers.test.d.ts +0 -1
- package/dist/api/mcp-servers.test.js +0 -98
- package/dist/api/projects.test.d.ts +0 -1
- package/dist/api/projects.test.js +0 -61
- package/dist/api/search.test.d.ts +0 -1
- package/dist/api/search.test.js +0 -50
- package/dist/api/secrets.test.d.ts +0 -1
- package/dist/api/secrets.test.js +0 -61
- package/dist/api/sessions.test.d.ts +0 -1
- package/dist/api/sessions.test.js +0 -61
- package/dist/api/tasks.test.d.ts +0 -1
- package/dist/api/tasks.test.js +0 -381
- package/dist/api/teams.test.d.ts +0 -1
- package/dist/api/teams.test.js +0 -139
- package/dist/client.test.d.ts +0 -1
- package/dist/client.test.js +0 -446
- package/dist/http/client.test.d.ts +0 -1
- package/dist/http/client.test.js +0 -435
- package/dist/http/errors.test.d.ts +0 -1
- package/dist/http/errors.test.js +0 -66
- package/dist/http/poll.test.d.ts +0 -1
- package/dist/http/poll.test.js +0 -146
- package/dist/http/streamable.test.d.ts +0 -4
- package/dist/http/streamable.test.js +0 -510
- package/dist/integration.test.d.ts +0 -9
- package/dist/integration.test.js +0 -107
- package/dist/proxy/express.test.d.ts +0 -1
- package/dist/proxy/express.test.js +0 -106
- package/dist/proxy/hono.test.d.ts +0 -1
- package/dist/proxy/hono.test.js +0 -90
- package/dist/proxy/index.test.d.ts +0 -1
- package/dist/proxy/index.test.js +0 -173
- package/dist/proxy/nextjs.test.d.ts +0 -1
- package/dist/proxy/nextjs.test.js +0 -125
- package/dist/proxy/remix.test.d.ts +0 -1
- package/dist/proxy/remix.test.js +0 -66
- package/dist/proxy/svelte.test.d.ts +0 -1
- package/dist/proxy/svelte.test.js +0 -69
- package/dist/sessions.integration.test.d.ts +0 -13
- package/dist/sessions.integration.test.js +0 -310
- package/dist/stream.test.d.ts +0 -1
- package/dist/stream.test.js +0 -363
- package/dist/streamable.integration.test.d.ts +0 -11
- package/dist/streamable.integration.test.js +0 -150
- package/dist/tool-builder.test.d.ts +0 -1
- package/dist/tool-builder.test.js +0 -407
- package/dist/utils.test.d.ts +0 -1
- package/dist/utils.test.js +0 -43
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import { FlowRunsAPI } from './flow-runs';
|
|
3
|
-
const mockFetch = jest.fn();
|
|
4
|
-
global.fetch = mockFetch;
|
|
5
|
-
function mockJsonResponse(body) {
|
|
6
|
-
mockFetch.mockResolvedValueOnce({
|
|
7
|
-
ok: true,
|
|
8
|
-
status: 200,
|
|
9
|
-
text: () => Promise.resolve(JSON.stringify(body)),
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
describe('FlowRunsAPI', () => {
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
jest.clearAllMocks();
|
|
15
|
-
});
|
|
16
|
-
const api = () => new FlowRunsAPI(new HttpClient({ apiKey: 'test-key' }));
|
|
17
|
-
it('should POST flow and input for create()', async () => {
|
|
18
|
-
const flowRun = { id: 'fr-1', flow: 'flow-1' };
|
|
19
|
-
mockJsonResponse(flowRun);
|
|
20
|
-
const result = await api().create('flow-1', { prompt: 'hi' });
|
|
21
|
-
expect(result).toEqual(flowRun);
|
|
22
|
-
const [, init] = mockFetch.mock.calls[0];
|
|
23
|
-
expect(JSON.parse(init.body)).toEqual({
|
|
24
|
-
flow: 'flow-1',
|
|
25
|
-
input: { prompt: 'hi' },
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
it('should POST /flowruns/{id}/cancel for cancel()', async () => {
|
|
29
|
-
mockJsonResponse(null);
|
|
30
|
-
await api().cancel('fr-1');
|
|
31
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
32
|
-
expect(url).toContain('/flowruns/fr-1/cancel');
|
|
33
|
-
expect(init.method).toBe('POST');
|
|
34
|
-
});
|
|
35
|
-
it('should open SSE on /flowruns/{id}/stream for stream()', async () => {
|
|
36
|
-
const http = new HttpClient({ apiKey: 'test-key' });
|
|
37
|
-
const createEventSource = jest
|
|
38
|
-
.spyOn(http, 'createEventSource')
|
|
39
|
-
.mockResolvedValue(null);
|
|
40
|
-
const flowRuns = new FlowRunsAPI(http);
|
|
41
|
-
await flowRuns.stream('fr-42');
|
|
42
|
-
expect(createEventSource).toHaveBeenCalledWith('/flowruns/fr-42/stream');
|
|
43
|
-
createEventSource.mockRestore();
|
|
44
|
-
});
|
|
45
|
-
it('should open task SSE for streamTasks()', async () => {
|
|
46
|
-
const http = new HttpClient({ apiKey: 'test-key' });
|
|
47
|
-
const createEventSource = jest
|
|
48
|
-
.spyOn(http, 'createEventSource')
|
|
49
|
-
.mockResolvedValue(null);
|
|
50
|
-
const flowRuns = new FlowRunsAPI(http);
|
|
51
|
-
await flowRuns.streamTasks('fr-42');
|
|
52
|
-
expect(createEventSource).toHaveBeenCalledWith('/flowruns/fr-42/tasks/stream');
|
|
53
|
-
createEventSource.mockRestore();
|
|
54
|
-
});
|
|
55
|
-
it('should POST /flowruns/list for list()', async () => {
|
|
56
|
-
const page = { items: [{ id: 'fr-1' }], next_cursor: null };
|
|
57
|
-
mockJsonResponse(page);
|
|
58
|
-
const result = await api().list({ limit: 10 });
|
|
59
|
-
expect(result).toEqual(page);
|
|
60
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
61
|
-
expect(url).toContain('/flowruns/list');
|
|
62
|
-
expect(init.method).toBe('POST');
|
|
63
|
-
});
|
|
64
|
-
it('should GET /flowruns/{id} for get()', async () => {
|
|
65
|
-
const flowRun = { id: 'fr-1' };
|
|
66
|
-
mockJsonResponse(flowRun);
|
|
67
|
-
const result = await api().get('fr-1');
|
|
68
|
-
expect(result).toEqual(flowRun);
|
|
69
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
70
|
-
expect(url).toContain('/flowruns/fr-1');
|
|
71
|
-
expect(init.method).toBe('GET');
|
|
72
|
-
});
|
|
73
|
-
it('should POST /flowruns/{id}/clone for clone()', async () => {
|
|
74
|
-
const flowRun = { id: 'fr-clone' };
|
|
75
|
-
mockJsonResponse(flowRun);
|
|
76
|
-
const result = await api().clone('fr-1');
|
|
77
|
-
expect(result).toEqual(flowRun);
|
|
78
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
79
|
-
expect(url).toContain('/flowruns/fr-1/clone');
|
|
80
|
-
expect(init.method).toBe('POST');
|
|
81
|
-
});
|
|
82
|
-
it('should POST /flowruns/{id} for update()', async () => {
|
|
83
|
-
const flowRun = { id: 'fr-1', fail_on_error: false };
|
|
84
|
-
mockJsonResponse(flowRun);
|
|
85
|
-
const result = await api().update('fr-1', { fail_on_error: false });
|
|
86
|
-
expect(result).toEqual(flowRun);
|
|
87
|
-
const [, init] = mockFetch.mock.calls[0];
|
|
88
|
-
expect(JSON.parse(init.body)).toEqual({ fail_on_error: false });
|
|
89
|
-
});
|
|
90
|
-
it('should POST visibility for updateVisibility()', async () => {
|
|
91
|
-
const flowRun = { id: 'fr-1', visibility: 'public' };
|
|
92
|
-
mockJsonResponse(flowRun);
|
|
93
|
-
await api().updateVisibility('fr-1', 'public');
|
|
94
|
-
const [, init] = mockFetch.mock.calls[0];
|
|
95
|
-
expect(JSON.parse(init.body)).toEqual({ visibility: 'public' });
|
|
96
|
-
});
|
|
97
|
-
});
|
package/dist/api/flows.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/api/flows.test.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import { FlowsAPI } from './flows';
|
|
3
|
-
const mockFetch = jest.fn();
|
|
4
|
-
global.fetch = mockFetch;
|
|
5
|
-
function mockJsonResponse(body) {
|
|
6
|
-
mockFetch.mockResolvedValueOnce({
|
|
7
|
-
ok: true,
|
|
8
|
-
status: 200,
|
|
9
|
-
text: () => Promise.resolve(JSON.stringify(body)),
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
describe('FlowsAPI', () => {
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
jest.clearAllMocks();
|
|
15
|
-
});
|
|
16
|
-
const api = () => new FlowsAPI(new HttpClient({ apiKey: 'test-key' }));
|
|
17
|
-
it('should POST name for create()', async () => {
|
|
18
|
-
const flow = { id: 'flow-1', name: 'My Flow' };
|
|
19
|
-
mockJsonResponse(flow);
|
|
20
|
-
const result = await api().create('My Flow');
|
|
21
|
-
expect(result).toEqual(flow);
|
|
22
|
-
const [, init] = mockFetch.mock.calls[0];
|
|
23
|
-
expect(JSON.parse(init.body)).toEqual({ name: 'My Flow' });
|
|
24
|
-
});
|
|
25
|
-
it('should POST /flows/{id}/app for createApp()', async () => {
|
|
26
|
-
const app = { id: 'app-from-flow' };
|
|
27
|
-
mockJsonResponse(app);
|
|
28
|
-
const result = await api().createApp('flow-1');
|
|
29
|
-
expect(result).toEqual(app);
|
|
30
|
-
const [url] = mockFetch.mock.calls[0];
|
|
31
|
-
expect(url).toContain('/flows/flow-1/app');
|
|
32
|
-
});
|
|
33
|
-
it('should open SSE on /flows/{id}/stream for stream()', async () => {
|
|
34
|
-
const http = new HttpClient({ apiKey: 'test-key' });
|
|
35
|
-
const createEventSource = jest
|
|
36
|
-
.spyOn(http, 'createEventSource')
|
|
37
|
-
.mockResolvedValue(null);
|
|
38
|
-
const flows = new FlowsAPI(http);
|
|
39
|
-
await flows.stream('flow-5');
|
|
40
|
-
expect(createEventSource).toHaveBeenCalledWith('/flows/flow-5/stream');
|
|
41
|
-
createEventSource.mockRestore();
|
|
42
|
-
});
|
|
43
|
-
it('should POST /flows/list for list()', async () => {
|
|
44
|
-
const page = { items: [{ id: 'flow-1' }], next_cursor: null };
|
|
45
|
-
mockJsonResponse(page);
|
|
46
|
-
const result = await api().list({ limit: 10 });
|
|
47
|
-
expect(result).toEqual(page);
|
|
48
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
49
|
-
expect(url).toContain('/flows/list');
|
|
50
|
-
expect(init.method).toBe('POST');
|
|
51
|
-
});
|
|
52
|
-
it('should GET /flows/{id} for get()', async () => {
|
|
53
|
-
const flow = { id: 'flow-1', name: 'Demo' };
|
|
54
|
-
mockJsonResponse(flow);
|
|
55
|
-
const result = await api().get('flow-1');
|
|
56
|
-
expect(result).toEqual(flow);
|
|
57
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
58
|
-
expect(url).toContain('/flows/flow-1');
|
|
59
|
-
expect(init.method).toBe('GET');
|
|
60
|
-
});
|
|
61
|
-
it('should POST /flows/{id} for update()', async () => {
|
|
62
|
-
const flow = { id: 'flow-1', name: 'Renamed' };
|
|
63
|
-
mockJsonResponse(flow);
|
|
64
|
-
const result = await api().update('flow-1', { name: 'Renamed' });
|
|
65
|
-
expect(result).toEqual(flow);
|
|
66
|
-
const [, init] = mockFetch.mock.calls[0];
|
|
67
|
-
expect(JSON.parse(init.body)).toEqual({ name: 'Renamed' });
|
|
68
|
-
});
|
|
69
|
-
it('should POST visibility for updateVisibility()', async () => {
|
|
70
|
-
const flow = { id: 'flow-1', visibility: 'public' };
|
|
71
|
-
mockJsonResponse(flow);
|
|
72
|
-
const result = await api().updateVisibility('flow-1', 'public');
|
|
73
|
-
expect(result).toEqual(flow);
|
|
74
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
75
|
-
expect(url).toContain('/flows/flow-1/visibility');
|
|
76
|
-
expect(JSON.parse(init.body)).toEqual({ visibility: 'public' });
|
|
77
|
-
});
|
|
78
|
-
it('should DELETE /flows/{id} for delete()', async () => {
|
|
79
|
-
mockJsonResponse(null);
|
|
80
|
-
await api().delete('flow-1');
|
|
81
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
82
|
-
expect(url).toContain('/flows/flow-1');
|
|
83
|
-
expect(init.method).toBe('DELETE');
|
|
84
|
-
});
|
|
85
|
-
it('should POST /flows/{id}/duplicate for duplicate()', async () => {
|
|
86
|
-
const flow = { id: 'flow-copy' };
|
|
87
|
-
mockJsonResponse(flow);
|
|
88
|
-
const result = await api().duplicate('flow-1');
|
|
89
|
-
expect(result).toEqual(flow);
|
|
90
|
-
const [url] = mockFetch.mock.calls[0];
|
|
91
|
-
expect(url).toContain('/flows/flow-1/duplicate');
|
|
92
|
-
});
|
|
93
|
-
it('should POST /flows/{id}/versions/list for listVersions()', async () => {
|
|
94
|
-
const versions = { items: [{ id: 'ver-1' }], next_cursor: null };
|
|
95
|
-
mockJsonResponse(versions);
|
|
96
|
-
const result = await api().listVersions('flow-1');
|
|
97
|
-
expect(result).toEqual(versions);
|
|
98
|
-
const [url] = mockFetch.mock.calls[0];
|
|
99
|
-
expect(url).toContain('/flows/flow-1/versions/list');
|
|
100
|
-
});
|
|
101
|
-
it('should POST transfer with team_id for transferOwnership()', async () => {
|
|
102
|
-
const flow = { id: 'flow-1' };
|
|
103
|
-
mockJsonResponse(flow);
|
|
104
|
-
await api().transferOwnership('flow-1', 'team-42');
|
|
105
|
-
const [, init] = mockFetch.mock.calls[0];
|
|
106
|
-
expect(JSON.parse(init.body)).toEqual({ team_id: 'team-42' });
|
|
107
|
-
});
|
|
108
|
-
it('should POST /flows/{id}/visibility for updateVisibility()', async () => {
|
|
109
|
-
const flow = { id: 'flow-1', visibility: 'public' };
|
|
110
|
-
mockJsonResponse(flow);
|
|
111
|
-
const result = await api().updateVisibility('flow-1', 'public');
|
|
112
|
-
expect(result).toEqual(flow);
|
|
113
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
114
|
-
expect(url).toContain('/flows/flow-1/visibility');
|
|
115
|
-
expect(init.method).toBe('POST');
|
|
116
|
-
expect(JSON.parse(init.body)).toEqual({ visibility: 'public' });
|
|
117
|
-
});
|
|
118
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import { IntegrationsAPI } from './integrations';
|
|
3
|
-
import { IntegrationProviderGoogleSA } from '../types';
|
|
4
|
-
const mockFetch = jest.fn();
|
|
5
|
-
global.fetch = mockFetch;
|
|
6
|
-
function mockJsonResponse(body) {
|
|
7
|
-
mockFetch.mockResolvedValueOnce({
|
|
8
|
-
ok: true,
|
|
9
|
-
status: 200,
|
|
10
|
-
text: () => Promise.resolve(JSON.stringify(body)),
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
describe('IntegrationsAPI', () => {
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
jest.clearAllMocks();
|
|
16
|
-
});
|
|
17
|
-
const api = () => new IntegrationsAPI(new HttpClient({ apiKey: 'test-key' }));
|
|
18
|
-
it('should POST /integrations/list for list()', async () => {
|
|
19
|
-
const page = { items: [{ provider: 'slack' }], next_cursor: null };
|
|
20
|
-
mockJsonResponse(page);
|
|
21
|
-
const result = await api().list();
|
|
22
|
-
expect(result).toEqual(page);
|
|
23
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
24
|
-
expect(url).toContain('/integrations/list');
|
|
25
|
-
expect(init.method).toBe('POST');
|
|
26
|
-
});
|
|
27
|
-
it('should GET /integrations/available for listAvailable()', async () => {
|
|
28
|
-
const available = [{ provider: 'github' }];
|
|
29
|
-
mockJsonResponse(available);
|
|
30
|
-
const result = await api().listAvailable();
|
|
31
|
-
expect(result).toEqual(available);
|
|
32
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
33
|
-
expect(url).toContain('/integrations/available');
|
|
34
|
-
expect(init.method).toBe('GET');
|
|
35
|
-
});
|
|
36
|
-
it('should POST /integrations for connect()', async () => {
|
|
37
|
-
const payload = { provider: 'slack', config: { token: 'xoxb-123' } };
|
|
38
|
-
const response = { integration: { provider: 'slack' }, redirect_url: null };
|
|
39
|
-
mockJsonResponse(response);
|
|
40
|
-
const result = await api().connect(payload);
|
|
41
|
-
expect(result).toEqual(response);
|
|
42
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
43
|
-
expect(url).toContain('/integrations');
|
|
44
|
-
expect(init.method).toBe('POST');
|
|
45
|
-
expect(JSON.parse(init.body)).toEqual(payload);
|
|
46
|
-
});
|
|
47
|
-
it('should GET /integrations/{provider} for get()', async () => {
|
|
48
|
-
const integration = { provider: 'slack', status: 'connected' };
|
|
49
|
-
mockJsonResponse(integration);
|
|
50
|
-
const result = await api().get('slack');
|
|
51
|
-
expect(result).toEqual(integration);
|
|
52
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
53
|
-
expect(url).toContain('/integrations/slack');
|
|
54
|
-
expect(init.method).toBe('GET');
|
|
55
|
-
});
|
|
56
|
-
it('should DELETE /integrations/{provider} for disconnect()', async () => {
|
|
57
|
-
mockJsonResponse(null);
|
|
58
|
-
await api().disconnect('slack');
|
|
59
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
60
|
-
expect(url).toContain('/integrations/slack');
|
|
61
|
-
expect(init.method).toBe('DELETE');
|
|
62
|
-
});
|
|
63
|
-
it('should GET /integrations/configs for getConfigs()', async () => {
|
|
64
|
-
const configs = [{ provider: 'github', scopes: ['repo'] }];
|
|
65
|
-
mockJsonResponse(configs);
|
|
66
|
-
const result = await api().getConfigs();
|
|
67
|
-
expect(result).toEqual(configs);
|
|
68
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
69
|
-
expect(url).toContain('/integrations/configs');
|
|
70
|
-
expect(init.method).toBe('GET');
|
|
71
|
-
});
|
|
72
|
-
it('should GET /integrations/capabilities for getCapabilities()', async () => {
|
|
73
|
-
const capabilities = { slack: ['post_message'] };
|
|
74
|
-
mockJsonResponse(capabilities);
|
|
75
|
-
const result = await api().getCapabilities();
|
|
76
|
-
expect(result).toEqual(capabilities);
|
|
77
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
78
|
-
expect(url).toContain('/integrations/capabilities');
|
|
79
|
-
expect(init.method).toBe('GET');
|
|
80
|
-
});
|
|
81
|
-
it('should POST typed integration requirements with secrets and scopes for checkRequirements()', async () => {
|
|
82
|
-
const payload = {
|
|
83
|
-
integrations: [
|
|
84
|
-
{
|
|
85
|
-
key: IntegrationProviderGoogleSA,
|
|
86
|
-
secrets: ['GOOGLE_SA_JSON'],
|
|
87
|
-
scopes: ['https://www.googleapis.com/auth/calendar'],
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
};
|
|
91
|
-
const response = {
|
|
92
|
-
satisfied: false,
|
|
93
|
-
errors: [
|
|
94
|
-
{
|
|
95
|
-
type: 'scope',
|
|
96
|
-
message: 'Missing calendar scope',
|
|
97
|
-
action: { type: 'add_scopes', provider: IntegrationProviderGoogleSA, scopes: ['https://www.googleapis.com/auth/calendar'] },
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
};
|
|
101
|
-
mockJsonResponse(response);
|
|
102
|
-
const result = await api().checkRequirements(payload);
|
|
103
|
-
expect(result).toEqual(response);
|
|
104
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
105
|
-
expect(url).toContain('/integrations/check');
|
|
106
|
-
expect(init.method).toBe('POST');
|
|
107
|
-
expect(JSON.parse(init.body)).toEqual(payload);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import { KnowledgeAPI, SkillsAPI } from './knowledge';
|
|
3
|
-
const mockFetch = jest.fn();
|
|
4
|
-
global.fetch = mockFetch;
|
|
5
|
-
function mockJsonResponse(body) {
|
|
6
|
-
mockFetch.mockResolvedValueOnce({
|
|
7
|
-
ok: true,
|
|
8
|
-
status: 200,
|
|
9
|
-
text: () => Promise.resolve(JSON.stringify(body)),
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
describe('KnowledgeAPI', () => {
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
jest.clearAllMocks();
|
|
15
|
-
});
|
|
16
|
-
const api = () => new KnowledgeAPI(new HttpClient({ apiKey: 'test-key' }));
|
|
17
|
-
it('should POST /knowledge/list for list()', async () => {
|
|
18
|
-
const page = { items: [{ id: 'know-1' }], next_cursor: null };
|
|
19
|
-
mockJsonResponse(page);
|
|
20
|
-
const result = await api().list();
|
|
21
|
-
expect(result).toEqual(page);
|
|
22
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
23
|
-
expect(url).toContain('/knowledge/list');
|
|
24
|
-
expect(init.method).toBe('POST');
|
|
25
|
-
});
|
|
26
|
-
it('should GET /knowledge/{namespace}/{name} for getByName()', async () => {
|
|
27
|
-
const entry = { id: 'know-1', namespace: 'acme', name: 'docs' };
|
|
28
|
-
mockJsonResponse(entry);
|
|
29
|
-
const result = await api().getByName('acme', 'docs');
|
|
30
|
-
expect(result).toEqual(entry);
|
|
31
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
32
|
-
expect(url).toContain('/knowledge/acme/docs');
|
|
33
|
-
expect(init.method).toBe('GET');
|
|
34
|
-
});
|
|
35
|
-
it('should POST /knowledge for create()', async () => {
|
|
36
|
-
const payload = { namespace: 'acme', name: 'docs', content: 'hello' };
|
|
37
|
-
const entry = { id: 'know-new', ...payload };
|
|
38
|
-
mockJsonResponse(entry);
|
|
39
|
-
const result = await api().create(payload);
|
|
40
|
-
expect(result).toEqual(entry);
|
|
41
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
42
|
-
expect(url).toContain('/knowledge');
|
|
43
|
-
expect(init.method).toBe('POST');
|
|
44
|
-
});
|
|
45
|
-
it('should POST team_id for transferOwnership()', async () => {
|
|
46
|
-
const entry = { id: 'know-1' };
|
|
47
|
-
mockJsonResponse(entry);
|
|
48
|
-
await api().transferOwnership('know-1', 'team-5');
|
|
49
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
50
|
-
expect(url).toContain('/knowledge/know-1/transfer');
|
|
51
|
-
expect(JSON.parse(init.body)).toEqual({ team_id: 'team-5' });
|
|
52
|
-
});
|
|
53
|
-
it('should GET /knowledge/{id} for get()', async () => {
|
|
54
|
-
const entry = { id: 'know-1', name: 'docs' };
|
|
55
|
-
mockJsonResponse(entry);
|
|
56
|
-
const result = await api().get('know-1');
|
|
57
|
-
expect(result).toEqual(entry);
|
|
58
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
59
|
-
expect(url).toContain('/knowledge/know-1');
|
|
60
|
-
expect(init.method).toBe('GET');
|
|
61
|
-
});
|
|
62
|
-
it('should POST /knowledge/{id} for update()', async () => {
|
|
63
|
-
const entry = { id: 'know-1', name: 'updated' };
|
|
64
|
-
mockJsonResponse(entry);
|
|
65
|
-
const result = await api().update('know-1', { name: 'updated' });
|
|
66
|
-
expect(result).toEqual(entry);
|
|
67
|
-
const [, init] = mockFetch.mock.calls[0];
|
|
68
|
-
expect(JSON.parse(init.body)).toEqual({ name: 'updated' });
|
|
69
|
-
});
|
|
70
|
-
it('should DELETE /knowledge/{id} for delete()', async () => {
|
|
71
|
-
mockJsonResponse(null);
|
|
72
|
-
await api().delete('know-1');
|
|
73
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
74
|
-
expect(url).toContain('/knowledge/know-1');
|
|
75
|
-
expect(init.method).toBe('DELETE');
|
|
76
|
-
});
|
|
77
|
-
it('should POST /knowledge/{id}/versions/list for listVersions()', async () => {
|
|
78
|
-
const page = { items: [{ id: 'ver-1' }], next_cursor: null };
|
|
79
|
-
mockJsonResponse(page);
|
|
80
|
-
const result = await api().listVersions('know-1', { limit: 10 });
|
|
81
|
-
expect(result).toEqual(page);
|
|
82
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
83
|
-
expect(url).toContain('/knowledge/know-1/versions/list');
|
|
84
|
-
expect(JSON.parse(init.body)).toEqual({ limit: 10 });
|
|
85
|
-
});
|
|
86
|
-
it('should GET /knowledge/{id}/versions/{versionId} for getVersion()', async () => {
|
|
87
|
-
const version = { id: 'ver-1', knowledge_id: 'know-1' };
|
|
88
|
-
mockJsonResponse(version);
|
|
89
|
-
const result = await api().getVersion('know-1', 'ver-1');
|
|
90
|
-
expect(result).toEqual(version);
|
|
91
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
92
|
-
expect(url).toContain('/knowledge/know-1/versions/ver-1');
|
|
93
|
-
expect(init.method).toBe('GET');
|
|
94
|
-
});
|
|
95
|
-
it('should POST visibility for updateVisibility()', async () => {
|
|
96
|
-
const entry = { id: 'know-1', visibility: 'team' };
|
|
97
|
-
mockJsonResponse(entry);
|
|
98
|
-
await api().updateVisibility('know-1', 'team');
|
|
99
|
-
const [, init] = mockFetch.mock.calls[0];
|
|
100
|
-
expect(JSON.parse(init.body)).toEqual({ visibility: 'team' });
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
describe('SkillsAPI', () => {
|
|
104
|
-
beforeEach(() => {
|
|
105
|
-
jest.clearAllMocks();
|
|
106
|
-
});
|
|
107
|
-
const api = () => new SkillsAPI(new HttpClient({ apiKey: 'test-key' }));
|
|
108
|
-
it('should GET /skills/resolve with ref param for resolve()', async () => {
|
|
109
|
-
const resolved = { ref: 'acme/skill@v1', content: '{}' };
|
|
110
|
-
mockJsonResponse(resolved);
|
|
111
|
-
const result = await api().resolve('acme/skill@v1', 'main');
|
|
112
|
-
expect(result).toEqual(resolved);
|
|
113
|
-
const [url] = mockFetch.mock.calls[0];
|
|
114
|
-
expect(url).toContain('/skills/resolve');
|
|
115
|
-
expect(url).toContain('ref=acme');
|
|
116
|
-
expect(url).toContain('skill=main');
|
|
117
|
-
});
|
|
118
|
-
it('should GET /skills/{namespace}/{name} for getByName()', async () => {
|
|
119
|
-
const skill = { id: 'skill-1', namespace: 'acme', name: 'research' };
|
|
120
|
-
mockJsonResponse(skill);
|
|
121
|
-
const result = await api().getByName('acme', 'research');
|
|
122
|
-
expect(result).toEqual(skill);
|
|
123
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
124
|
-
expect(url).toContain('/skills/acme/research');
|
|
125
|
-
expect(init.method).toBe('GET');
|
|
126
|
-
});
|
|
127
|
-
it('should GET /skills/{namespace}/{name}/download for download()', async () => {
|
|
128
|
-
mockJsonResponse({ url: 'https://cdn.example.com/skill.zip' });
|
|
129
|
-
await api().download('acme', 'research');
|
|
130
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
131
|
-
expect(url).toContain('/skills/acme/research/download');
|
|
132
|
-
expect(init.method).toBe('GET');
|
|
133
|
-
});
|
|
134
|
-
it('should POST /store/skills/list for listStore()', async () => {
|
|
135
|
-
const page = { items: [{ namespace: 'public', name: 'starter' }], next_cursor: null };
|
|
136
|
-
mockJsonResponse(page);
|
|
137
|
-
const result = await api().listStore();
|
|
138
|
-
expect(result).toEqual(page);
|
|
139
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
140
|
-
expect(url).toContain('/store/skills/list');
|
|
141
|
-
expect(init.method).toBe('POST');
|
|
142
|
-
});
|
|
143
|
-
it('should GET /skills/resolve with ref only when skill is omitted', async () => {
|
|
144
|
-
const resolved = { ref: 'acme/skill@v1' };
|
|
145
|
-
mockJsonResponse(resolved);
|
|
146
|
-
const result = await api().resolve('acme/skill@v1');
|
|
147
|
-
expect(result).toEqual(resolved);
|
|
148
|
-
const [url] = mockFetch.mock.calls[0];
|
|
149
|
-
expect(url).toContain('/skills/resolve');
|
|
150
|
-
expect(url).toContain('ref=acme');
|
|
151
|
-
expect(url).not.toContain('skill=');
|
|
152
|
-
});
|
|
153
|
-
it('should GET /skills/{namespace}/{name}/content for getContent()', async () => {
|
|
154
|
-
mockJsonResponse({ body: '# Skill instructions' });
|
|
155
|
-
const result = await api().getContent('acme', 'research');
|
|
156
|
-
expect(result).toEqual({ body: '# Skill instructions' });
|
|
157
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
158
|
-
expect(url).toContain('/skills/acme/research/content');
|
|
159
|
-
expect(init.method).toBe('GET');
|
|
160
|
-
});
|
|
161
|
-
it('should POST team_id for transferOwnership()', async () => {
|
|
162
|
-
const skill = { id: 'skill-1' };
|
|
163
|
-
mockJsonResponse(skill);
|
|
164
|
-
await api().transferOwnership('skill-1', 'team-8');
|
|
165
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
166
|
-
expect(url).toContain('/skills/skill-1/transfer');
|
|
167
|
-
expect(JSON.parse(init.body)).toEqual({ team_id: 'team-8' });
|
|
168
|
-
});
|
|
169
|
-
it('should POST /skills/list for list()', async () => {
|
|
170
|
-
const page = { items: [{ id: 'skill-1' }], next_cursor: null };
|
|
171
|
-
mockJsonResponse(page);
|
|
172
|
-
const result = await api().list({ limit: 10 });
|
|
173
|
-
expect(result).toEqual(page);
|
|
174
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
175
|
-
expect(url).toContain('/skills/list');
|
|
176
|
-
expect(init.method).toBe('POST');
|
|
177
|
-
});
|
|
178
|
-
it('should GET /skills/{id} for get()', async () => {
|
|
179
|
-
const skill = { id: 'skill-1', name: 'research' };
|
|
180
|
-
mockJsonResponse(skill);
|
|
181
|
-
const result = await api().get('skill-1');
|
|
182
|
-
expect(result).toEqual(skill);
|
|
183
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
184
|
-
expect(url).toContain('/skills/skill-1');
|
|
185
|
-
expect(init.method).toBe('GET');
|
|
186
|
-
});
|
|
187
|
-
it('should POST /skills for create()', async () => {
|
|
188
|
-
const payload = { namespace: 'acme', name: 'research' };
|
|
189
|
-
const skill = { id: 'skill-new', ...payload };
|
|
190
|
-
mockJsonResponse(skill);
|
|
191
|
-
const result = await api().create(payload);
|
|
192
|
-
expect(result).toEqual(skill);
|
|
193
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
194
|
-
expect(url).toContain('/skills');
|
|
195
|
-
expect(init.method).toBe('POST');
|
|
196
|
-
expect(JSON.parse(init.body)).toEqual(payload);
|
|
197
|
-
});
|
|
198
|
-
it('should POST /skills/{id} for update()', async () => {
|
|
199
|
-
const skill = { id: 'skill-1', name: 'updated' };
|
|
200
|
-
mockJsonResponse(skill);
|
|
201
|
-
const result = await api().update('skill-1', { name: 'updated' });
|
|
202
|
-
expect(result).toEqual(skill);
|
|
203
|
-
const [, init] = mockFetch.mock.calls[0];
|
|
204
|
-
expect(JSON.parse(init.body)).toEqual({ name: 'updated' });
|
|
205
|
-
});
|
|
206
|
-
it('should DELETE /skills/{id} for delete()', async () => {
|
|
207
|
-
mockJsonResponse(null);
|
|
208
|
-
await api().delete('skill-1');
|
|
209
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
210
|
-
expect(url).toContain('/skills/skill-1');
|
|
211
|
-
expect(init.method).toBe('DELETE');
|
|
212
|
-
});
|
|
213
|
-
it('should POST /skills/{id}/versions/list for listVersions()', async () => {
|
|
214
|
-
const page = { items: [{ id: 'ver-1' }], next_cursor: null };
|
|
215
|
-
mockJsonResponse(page);
|
|
216
|
-
const result = await api().listVersions('skill-1', { limit: 5 });
|
|
217
|
-
expect(result).toEqual(page);
|
|
218
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
219
|
-
expect(url).toContain('/skills/skill-1/versions/list');
|
|
220
|
-
expect(JSON.parse(init.body)).toEqual({ limit: 5 });
|
|
221
|
-
});
|
|
222
|
-
it('should GET /skills/{id}/versions/{versionId} for getVersion()', async () => {
|
|
223
|
-
const version = { id: 'ver-1', skill_id: 'skill-1' };
|
|
224
|
-
mockJsonResponse(version);
|
|
225
|
-
const result = await api().getVersion('skill-1', 'ver-1');
|
|
226
|
-
expect(result).toEqual(version);
|
|
227
|
-
const [url, init] = mockFetch.mock.calls[0];
|
|
228
|
-
expect(url).toContain('/skills/skill-1/versions/ver-1');
|
|
229
|
-
expect(init.method).toBe('GET');
|
|
230
|
-
});
|
|
231
|
-
it('should POST visibility for updateVisibility()', async () => {
|
|
232
|
-
const skill = { id: 'skill-1', visibility: 'team' };
|
|
233
|
-
mockJsonResponse(skill);
|
|
234
|
-
await api().updateVisibility('skill-1', 'team');
|
|
235
|
-
const [, init] = mockFetch.mock.calls[0];
|
|
236
|
-
expect(JSON.parse(init.body)).toEqual({ visibility: 'team' });
|
|
237
|
-
});
|
|
238
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|