@inkeep/agents-manage-api 0.1.2 → 0.1.6
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/LICENSE.md +7 -0
- package/README.md +1 -1
- package/SUPPLEMENTAL_TERMS.md +40 -0
- package/dist/index.cjs +5083 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +13 -18
- package/dist/index.js +5052 -26
- package/package.json +10 -10
- package/dist/ManagementServer.d.ts +0 -28
- package/dist/ManagementServer.d.ts.map +0 -1
- package/dist/ManagementServer.js +0 -41
- package/dist/__tests__/setup.d.ts +0 -2
- package/dist/__tests__/setup.d.ts.map +0 -1
- package/dist/__tests__/setup.js +0 -26
- package/dist/__tests__/utils/testProject.d.ts +0 -18
- package/dist/__tests__/utils/testProject.d.ts.map +0 -1
- package/dist/__tests__/utils/testProject.js +0 -26
- package/dist/__tests__/utils/testRequest.d.ts +0 -2
- package/dist/__tests__/utils/testRequest.d.ts.map +0 -1
- package/dist/__tests__/utils/testRequest.js +0 -11
- package/dist/__tests__/utils/testTenant.d.ts +0 -64
- package/dist/__tests__/utils/testTenant.d.ts.map +0 -1
- package/dist/__tests__/utils/testTenant.js +0 -71
- package/dist/app.d.ts +0 -11
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js +0 -148
- package/dist/data/conversations.d.ts +0 -59
- package/dist/data/conversations.d.ts.map +0 -1
- package/dist/data/conversations.js +0 -216
- package/dist/data/db/clean.d.ts +0 -6
- package/dist/data/db/clean.d.ts.map +0 -1
- package/dist/data/db/clean.js +0 -77
- package/dist/data/db/dbClient.d.ts +0 -3
- package/dist/data/db/dbClient.d.ts.map +0 -1
- package/dist/data/db/dbClient.js +0 -13
- package/dist/data/graphFull.d.ts +0 -11
- package/dist/data/graphFull.d.ts.map +0 -1
- package/dist/data/graphFull.js +0 -90
- package/dist/data/graphFullClient.d.ts +0 -22
- package/dist/data/graphFullClient.d.ts.map +0 -1
- package/dist/data/graphFullClient.js +0 -189
- package/dist/data/tools.d.ts +0 -82
- package/dist/data/tools.d.ts.map +0 -1
- package/dist/data/tools.js +0 -271
- package/dist/env.d.ts +0 -41
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -59
- package/dist/index.d.ts.map +0 -1
- package/dist/logger.d.ts +0 -4
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -32
- package/dist/middleware/auth.d.ts +0 -12
- package/dist/middleware/auth.d.ts.map +0 -1
- package/dist/middleware/auth.js +0 -36
- package/dist/openapi.d.ts +0 -2
- package/dist/openapi.d.ts.map +0 -1
- package/dist/openapi.js +0 -38
- package/dist/routes/agentArtifactComponents.d.ts +0 -4
- package/dist/routes/agentArtifactComponents.d.ts.map +0 -1
- package/dist/routes/agentArtifactComponents.js +0 -230
- package/dist/routes/agentDataComponents.d.ts +0 -4
- package/dist/routes/agentDataComponents.d.ts.map +0 -1
- package/dist/routes/agentDataComponents.js +0 -225
- package/dist/routes/agentGraph.d.ts +0 -4
- package/dist/routes/agentGraph.d.ts.map +0 -1
- package/dist/routes/agentGraph.js +0 -289
- package/dist/routes/agentRelations.d.ts +0 -4
- package/dist/routes/agentRelations.d.ts.map +0 -1
- package/dist/routes/agentRelations.js +0 -290
- package/dist/routes/agentToolRelations.d.ts +0 -4
- package/dist/routes/agentToolRelations.d.ts.map +0 -1
- package/dist/routes/agentToolRelations.js +0 -342
- package/dist/routes/agents.d.ts +0 -4
- package/dist/routes/agents.d.ts.map +0 -1
- package/dist/routes/agents.js +0 -213
- package/dist/routes/apiKeys.d.ts +0 -4
- package/dist/routes/apiKeys.d.ts.map +0 -1
- package/dist/routes/apiKeys.js +0 -236
- package/dist/routes/artifactComponents.d.ts +0 -4
- package/dist/routes/artifactComponents.d.ts.map +0 -1
- package/dist/routes/artifactComponents.js +0 -202
- package/dist/routes/contextConfigs.d.ts +0 -4
- package/dist/routes/contextConfigs.d.ts.map +0 -1
- package/dist/routes/contextConfigs.js +0 -181
- package/dist/routes/credentials.d.ts +0 -10
- package/dist/routes/credentials.d.ts.map +0 -1
- package/dist/routes/credentials.js +0 -219
- package/dist/routes/dataComponents.d.ts +0 -4
- package/dist/routes/dataComponents.d.ts.map +0 -1
- package/dist/routes/dataComponents.js +0 -188
- package/dist/routes/externalAgents.d.ts +0 -4
- package/dist/routes/externalAgents.d.ts.map +0 -1
- package/dist/routes/externalAgents.js +0 -216
- package/dist/routes/graphFull.d.ts +0 -4
- package/dist/routes/graphFull.d.ts.map +0 -1
- package/dist/routes/graphFull.js +0 -248
- package/dist/routes/index.d.ts +0 -4
- package/dist/routes/index.d.ts.map +0 -1
- package/dist/routes/index.js +0 -37
- package/dist/routes/oauth.d.ts +0 -21
- package/dist/routes/oauth.d.ts.map +0 -1
- package/dist/routes/oauth.js +0 -191
- package/dist/routes/projects.d.ts +0 -4
- package/dist/routes/projects.d.ts.map +0 -1
- package/dist/routes/projects.js +0 -221
- package/dist/routes/tools.d.ts +0 -11
- package/dist/routes/tools.d.ts.map +0 -1
- package/dist/routes/tools.js +0 -555
- package/dist/utils/auth-detection.d.ts +0 -22
- package/dist/utils/auth-detection.d.ts.map +0 -1
- package/dist/utils/auth-detection.js +0 -149
- package/dist/utils/oauth-service.d.ts +0 -88
- package/dist/utils/oauth-service.d.ts.map +0 -1
- package/dist/utils/oauth-service.js +0 -240
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
-
import { commonGetErrorResponses, createApiError, } from '@inkeep/agents-core';
|
|
3
|
-
import { CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, ErrorResponseSchema, IdParamsSchema, ListResponseSchema, PaginationQueryParamsSchema, SingleResponseSchema, TenantProjectParamsSchema, createCredentialReference, deleteCredentialReference, getCredentialReferenceById, listCredentialReferencesPaginated, updateCredentialReference, getCredentialStoreLookupKeyFromRetrievalParams, } from '@inkeep/agents-core';
|
|
4
|
-
import dbClient from '../data/db/dbClient.js';
|
|
5
|
-
const app = new OpenAPIHono();
|
|
6
|
-
app.openapi(createRoute({
|
|
7
|
-
method: 'get',
|
|
8
|
-
path: '/',
|
|
9
|
-
summary: 'List Credentials',
|
|
10
|
-
operationId: 'list-credentials',
|
|
11
|
-
tags: ['CRUD Credential'],
|
|
12
|
-
request: {
|
|
13
|
-
params: TenantProjectParamsSchema,
|
|
14
|
-
query: PaginationQueryParamsSchema,
|
|
15
|
-
},
|
|
16
|
-
responses: {
|
|
17
|
-
200: {
|
|
18
|
-
description: 'List of credentials retrieved successfully',
|
|
19
|
-
content: {
|
|
20
|
-
'application/json': {
|
|
21
|
-
schema: ListResponseSchema(CredentialReferenceApiSelectSchema),
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
...commonGetErrorResponses,
|
|
26
|
-
},
|
|
27
|
-
}), async (c) => {
|
|
28
|
-
const { tenantId, projectId } = c.req.valid('param');
|
|
29
|
-
const page = Number(c.req.query('page')) || 1;
|
|
30
|
-
const limit = Math.min(Number(c.req.query('limit')) || 10, 100);
|
|
31
|
-
const result = await listCredentialReferencesPaginated(dbClient)({
|
|
32
|
-
scopes: { tenantId, projectId },
|
|
33
|
-
pagination: { page, limit },
|
|
34
|
-
});
|
|
35
|
-
return c.json(result);
|
|
36
|
-
});
|
|
37
|
-
app.openapi(createRoute({
|
|
38
|
-
method: 'get',
|
|
39
|
-
path: '/{id}',
|
|
40
|
-
summary: 'Get Credential',
|
|
41
|
-
operationId: 'get-credential-by-id',
|
|
42
|
-
tags: ['CRUD Credential'],
|
|
43
|
-
request: {
|
|
44
|
-
params: TenantProjectParamsSchema.merge(IdParamsSchema),
|
|
45
|
-
},
|
|
46
|
-
responses: {
|
|
47
|
-
200: {
|
|
48
|
-
description: 'Credential found',
|
|
49
|
-
content: {
|
|
50
|
-
'application/json': {
|
|
51
|
-
schema: SingleResponseSchema(CredentialReferenceApiSelectSchema),
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
...commonGetErrorResponses,
|
|
56
|
-
},
|
|
57
|
-
}), async (c) => {
|
|
58
|
-
const { tenantId, projectId, id } = c.req.valid('param');
|
|
59
|
-
const credential = await getCredentialReferenceById(dbClient)({
|
|
60
|
-
scopes: { tenantId, projectId },
|
|
61
|
-
id,
|
|
62
|
-
});
|
|
63
|
-
if (!credential) {
|
|
64
|
-
throw createApiError({
|
|
65
|
-
code: 'not_found',
|
|
66
|
-
message: 'Credential not found',
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return c.json({ data: credential });
|
|
70
|
-
});
|
|
71
|
-
app.openapi(createRoute({
|
|
72
|
-
method: 'post',
|
|
73
|
-
path: '/',
|
|
74
|
-
summary: 'Create Credential',
|
|
75
|
-
operationId: 'create-credential',
|
|
76
|
-
tags: ['CRUD Credential'],
|
|
77
|
-
request: {
|
|
78
|
-
params: TenantProjectParamsSchema,
|
|
79
|
-
body: {
|
|
80
|
-
content: {
|
|
81
|
-
'application/json': {
|
|
82
|
-
schema: CredentialReferenceApiInsertSchema,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
responses: {
|
|
88
|
-
201: {
|
|
89
|
-
description: 'Credential created successfully',
|
|
90
|
-
content: {
|
|
91
|
-
'application/json': {
|
|
92
|
-
schema: SingleResponseSchema(CredentialReferenceApiSelectSchema),
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
...commonGetErrorResponses,
|
|
97
|
-
},
|
|
98
|
-
}), async (c) => {
|
|
99
|
-
const { tenantId, projectId } = c.req.valid('param');
|
|
100
|
-
const body = c.req.valid('json');
|
|
101
|
-
const credentialData = {
|
|
102
|
-
...body,
|
|
103
|
-
tenantId,
|
|
104
|
-
projectId,
|
|
105
|
-
};
|
|
106
|
-
const credential = await createCredentialReference(dbClient)(credentialData);
|
|
107
|
-
return c.json({ data: credential }, 201);
|
|
108
|
-
});
|
|
109
|
-
app.openapi(createRoute({
|
|
110
|
-
method: 'put',
|
|
111
|
-
path: '/{id}',
|
|
112
|
-
summary: 'Update Credential',
|
|
113
|
-
operationId: 'update-credential',
|
|
114
|
-
tags: ['CRUD Credential'],
|
|
115
|
-
request: {
|
|
116
|
-
params: TenantProjectParamsSchema.merge(IdParamsSchema),
|
|
117
|
-
body: {
|
|
118
|
-
content: {
|
|
119
|
-
'application/json': {
|
|
120
|
-
schema: CredentialReferenceApiUpdateSchema,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
responses: {
|
|
126
|
-
200: {
|
|
127
|
-
description: 'Credential updated successfully',
|
|
128
|
-
content: {
|
|
129
|
-
'application/json': {
|
|
130
|
-
schema: SingleResponseSchema(CredentialReferenceApiSelectSchema),
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
...commonGetErrorResponses,
|
|
135
|
-
},
|
|
136
|
-
}), async (c) => {
|
|
137
|
-
const { tenantId, projectId, id } = c.req.valid('param');
|
|
138
|
-
const body = c.req.valid('json');
|
|
139
|
-
const updatedCredential = await updateCredentialReference(dbClient)({
|
|
140
|
-
scopes: { tenantId, projectId },
|
|
141
|
-
id,
|
|
142
|
-
data: body,
|
|
143
|
-
});
|
|
144
|
-
if (!updatedCredential) {
|
|
145
|
-
throw createApiError({
|
|
146
|
-
code: 'not_found',
|
|
147
|
-
message: 'Credential not found',
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return c.json({ data: updatedCredential });
|
|
151
|
-
});
|
|
152
|
-
app.openapi(createRoute({
|
|
153
|
-
method: 'delete',
|
|
154
|
-
path: '/{id}',
|
|
155
|
-
summary: 'Delete Credential',
|
|
156
|
-
operationId: 'delete-credential',
|
|
157
|
-
tags: ['CRUD Credential'],
|
|
158
|
-
request: {
|
|
159
|
-
params: TenantProjectParamsSchema.merge(IdParamsSchema),
|
|
160
|
-
},
|
|
161
|
-
responses: {
|
|
162
|
-
204: {
|
|
163
|
-
description: 'Credential deleted successfully',
|
|
164
|
-
},
|
|
165
|
-
404: {
|
|
166
|
-
description: 'Credential not found',
|
|
167
|
-
content: {
|
|
168
|
-
'application/json': {
|
|
169
|
-
schema: ErrorResponseSchema,
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
}), async (c) => {
|
|
175
|
-
const { tenantId, projectId, id } = c.req.valid('param');
|
|
176
|
-
const credential = await getCredentialReferenceById(dbClient)({
|
|
177
|
-
scopes: { tenantId, projectId },
|
|
178
|
-
id,
|
|
179
|
-
});
|
|
180
|
-
if (!credential) {
|
|
181
|
-
throw createApiError({
|
|
182
|
-
code: 'not_found',
|
|
183
|
-
message: 'Credential not found',
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
const credentialStores = c.get('credentialStores');
|
|
187
|
-
const credentialStore = credentialStores.get(credential.credentialStoreId);
|
|
188
|
-
if (credentialStore && credential.retrievalParams) {
|
|
189
|
-
const lookupKey = getCredentialStoreLookupKeyFromRetrievalParams({
|
|
190
|
-
retrievalParams: credential.retrievalParams,
|
|
191
|
-
credentialStoreType: credentialStore.type,
|
|
192
|
-
});
|
|
193
|
-
if (!lookupKey) {
|
|
194
|
-
throw createApiError({
|
|
195
|
-
code: 'bad_request',
|
|
196
|
-
message: 'Could not generate lookup key for credential store',
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
try {
|
|
200
|
-
await credentialStore.delete(lookupKey);
|
|
201
|
-
}
|
|
202
|
-
catch (error) {
|
|
203
|
-
// Log the error but continue with database deletion for graceful failure handling
|
|
204
|
-
console.error(`Failed to delete credential from external store "${credential.credentialStoreId}":`, error);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
const deleted = await deleteCredentialReference(dbClient)({
|
|
208
|
-
scopes: { tenantId, projectId },
|
|
209
|
-
id,
|
|
210
|
-
});
|
|
211
|
-
if (!deleted) {
|
|
212
|
-
throw createApiError({
|
|
213
|
-
code: 'not_found',
|
|
214
|
-
message: 'Failed to delete credential',
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
return c.body(null, 204);
|
|
218
|
-
});
|
|
219
|
-
export default app;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dataComponents.d.ts","sourceRoot":"","sources":["../../src/routes/dataComponents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAoB7D,QAAA,MAAM,GAAG,0CAAoB,CAAC;AAwN9B,eAAe,GAAG,CAAC"}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
-
import { commonGetErrorResponses, createApiError } from '@inkeep/agents-core';
|
|
3
|
-
import { DataComponentApiInsertSchema, DataComponentApiSelectSchema, DataComponentApiUpdateSchema, ErrorResponseSchema, IdParamsSchema, ListResponseSchema, PaginationQueryParamsSchema, SingleResponseSchema, TenantProjectParamsSchema, createDataComponent, deleteDataComponent, getDataComponent, listDataComponentsPaginated, updateDataComponent, } from '@inkeep/agents-core';
|
|
4
|
-
import dbClient from '../data/db/dbClient.js';
|
|
5
|
-
const app = new OpenAPIHono();
|
|
6
|
-
app.openapi(createRoute({
|
|
7
|
-
method: 'get',
|
|
8
|
-
path: '/',
|
|
9
|
-
summary: 'List Data Components',
|
|
10
|
-
operationId: 'list-data-components',
|
|
11
|
-
tags: ['CRUD Data Component'],
|
|
12
|
-
request: {
|
|
13
|
-
params: TenantProjectParamsSchema,
|
|
14
|
-
query: PaginationQueryParamsSchema,
|
|
15
|
-
},
|
|
16
|
-
responses: {
|
|
17
|
-
200: {
|
|
18
|
-
description: 'List of data components retrieved successfully',
|
|
19
|
-
content: {
|
|
20
|
-
'application/json': {
|
|
21
|
-
schema: ListResponseSchema(DataComponentApiSelectSchema),
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
...commonGetErrorResponses,
|
|
26
|
-
},
|
|
27
|
-
}), async (c) => {
|
|
28
|
-
const { tenantId, projectId } = c.req.valid('param');
|
|
29
|
-
const page = Number(c.req.query('page')) || 1;
|
|
30
|
-
const limit = Math.min(Number(c.req.query('limit')) || 10, 100);
|
|
31
|
-
const result = await listDataComponentsPaginated(dbClient)({
|
|
32
|
-
scopes: { tenantId, projectId },
|
|
33
|
-
pagination: { page, limit },
|
|
34
|
-
});
|
|
35
|
-
return c.json(result);
|
|
36
|
-
});
|
|
37
|
-
app.openapi(createRoute({
|
|
38
|
-
method: 'get',
|
|
39
|
-
path: '/{id}',
|
|
40
|
-
summary: 'Get Data Component',
|
|
41
|
-
operationId: 'get-data-component-by-id',
|
|
42
|
-
tags: ['CRUD Data Component'],
|
|
43
|
-
request: {
|
|
44
|
-
params: TenantProjectParamsSchema.merge(IdParamsSchema),
|
|
45
|
-
},
|
|
46
|
-
responses: {
|
|
47
|
-
200: {
|
|
48
|
-
description: 'Data component found',
|
|
49
|
-
content: {
|
|
50
|
-
'application/json': {
|
|
51
|
-
schema: SingleResponseSchema(DataComponentApiSelectSchema),
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
...commonGetErrorResponses,
|
|
56
|
-
},
|
|
57
|
-
}), async (c) => {
|
|
58
|
-
const { tenantId, projectId, id } = c.req.valid('param');
|
|
59
|
-
const dataComponent = await getDataComponent(dbClient)({
|
|
60
|
-
scopes: { tenantId, projectId },
|
|
61
|
-
dataComponentId: id,
|
|
62
|
-
});
|
|
63
|
-
if (!dataComponent) {
|
|
64
|
-
throw createApiError({
|
|
65
|
-
code: 'not_found',
|
|
66
|
-
message: 'Data component not found',
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return c.json({ data: dataComponent });
|
|
70
|
-
});
|
|
71
|
-
app.openapi(createRoute({
|
|
72
|
-
method: 'post',
|
|
73
|
-
path: '/',
|
|
74
|
-
summary: 'Create Data Component',
|
|
75
|
-
operationId: 'create-data-component',
|
|
76
|
-
tags: ['CRUD Data Component'],
|
|
77
|
-
request: {
|
|
78
|
-
params: TenantProjectParamsSchema,
|
|
79
|
-
body: {
|
|
80
|
-
content: {
|
|
81
|
-
'application/json': {
|
|
82
|
-
schema: DataComponentApiInsertSchema,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
responses: {
|
|
88
|
-
201: {
|
|
89
|
-
description: 'Data component created successfully',
|
|
90
|
-
content: {
|
|
91
|
-
'application/json': {
|
|
92
|
-
schema: SingleResponseSchema(DataComponentApiSelectSchema),
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
...commonGetErrorResponses,
|
|
97
|
-
},
|
|
98
|
-
}), async (c) => {
|
|
99
|
-
const { tenantId, projectId } = c.req.valid('param');
|
|
100
|
-
const body = c.req.valid('json');
|
|
101
|
-
const dataComponentData = {
|
|
102
|
-
...body,
|
|
103
|
-
tenantId,
|
|
104
|
-
projectId,
|
|
105
|
-
};
|
|
106
|
-
const dataComponent = await createDataComponent(dbClient)(dataComponentData);
|
|
107
|
-
return c.json({ data: dataComponent }, 201);
|
|
108
|
-
});
|
|
109
|
-
app.openapi(createRoute({
|
|
110
|
-
method: 'put',
|
|
111
|
-
path: '/{id}',
|
|
112
|
-
summary: 'Update Data Component',
|
|
113
|
-
operationId: 'update-data-component',
|
|
114
|
-
tags: ['CRUD Data Component'],
|
|
115
|
-
request: {
|
|
116
|
-
params: TenantProjectParamsSchema.merge(IdParamsSchema),
|
|
117
|
-
body: {
|
|
118
|
-
content: {
|
|
119
|
-
'application/json': {
|
|
120
|
-
schema: DataComponentApiUpdateSchema,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
responses: {
|
|
126
|
-
200: {
|
|
127
|
-
description: 'Data component updated successfully',
|
|
128
|
-
content: {
|
|
129
|
-
'application/json': {
|
|
130
|
-
schema: SingleResponseSchema(DataComponentApiSelectSchema),
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
...commonGetErrorResponses,
|
|
135
|
-
},
|
|
136
|
-
}), async (c) => {
|
|
137
|
-
const { tenantId, projectId, id } = c.req.valid('param');
|
|
138
|
-
const body = c.req.valid('json');
|
|
139
|
-
const updatedDataComponent = await updateDataComponent(dbClient)({
|
|
140
|
-
scopes: { tenantId, projectId },
|
|
141
|
-
dataComponentId: id,
|
|
142
|
-
data: body,
|
|
143
|
-
});
|
|
144
|
-
if (!updatedDataComponent) {
|
|
145
|
-
throw createApiError({
|
|
146
|
-
code: 'not_found',
|
|
147
|
-
message: 'Data component not found',
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return c.json({ data: updatedDataComponent });
|
|
151
|
-
});
|
|
152
|
-
app.openapi(createRoute({
|
|
153
|
-
method: 'delete',
|
|
154
|
-
path: '/{id}',
|
|
155
|
-
summary: 'Delete Data Component',
|
|
156
|
-
operationId: 'delete-data-component',
|
|
157
|
-
tags: ['CRUD Data Component'],
|
|
158
|
-
request: {
|
|
159
|
-
params: TenantProjectParamsSchema.merge(IdParamsSchema),
|
|
160
|
-
},
|
|
161
|
-
responses: {
|
|
162
|
-
204: {
|
|
163
|
-
description: 'Data component deleted successfully',
|
|
164
|
-
},
|
|
165
|
-
404: {
|
|
166
|
-
description: 'Data component not found',
|
|
167
|
-
content: {
|
|
168
|
-
'application/json': {
|
|
169
|
-
schema: ErrorResponseSchema,
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
}), async (c) => {
|
|
175
|
-
const { tenantId, projectId, id } = c.req.valid('param');
|
|
176
|
-
const deleted = await deleteDataComponent(dbClient)({
|
|
177
|
-
scopes: { tenantId, projectId },
|
|
178
|
-
dataComponentId: id,
|
|
179
|
-
});
|
|
180
|
-
if (!deleted) {
|
|
181
|
-
throw createApiError({
|
|
182
|
-
code: 'not_found',
|
|
183
|
-
message: 'Data component not found',
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
return c.body(null, 204);
|
|
187
|
-
});
|
|
188
|
-
export default app;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"externalAgents.d.ts","sourceRoot":"","sources":["../../src/routes/externalAgents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAsB7D,QAAA,MAAM,GAAG,0CAAoB,CAAC;AAuP9B,eAAe,GAAG,CAAC"}
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
-
import { commonGetErrorResponses, createApiError } from '@inkeep/agents-core';
|
|
3
|
-
import { ErrorResponseSchema, ExternalAgentApiInsertSchema, ExternalAgentApiSelectSchema, ExternalAgentApiUpdateSchema, IdParamsSchema, ListResponseSchema, PaginationQueryParamsSchema, SingleResponseSchema, TenantProjectParamsSchema, createExternalAgent, deleteExternalAgent, getExternalAgent, listExternalAgentsPaginated, updateExternalAgent, } from '@inkeep/agents-core';
|
|
4
|
-
import dbClient from '../data/db/dbClient.js';
|
|
5
|
-
import { nanoid } from 'nanoid';
|
|
6
|
-
const app = new OpenAPIHono();
|
|
7
|
-
app.openapi(createRoute({
|
|
8
|
-
method: 'get',
|
|
9
|
-
path: '/',
|
|
10
|
-
summary: 'List External Agents',
|
|
11
|
-
operationId: 'list-external-agents',
|
|
12
|
-
tags: ['CRUD External Agents'],
|
|
13
|
-
request: {
|
|
14
|
-
params: TenantProjectParamsSchema,
|
|
15
|
-
query: PaginationQueryParamsSchema,
|
|
16
|
-
},
|
|
17
|
-
responses: {
|
|
18
|
-
200: {
|
|
19
|
-
description: 'List of external agents retrieved successfully',
|
|
20
|
-
content: {
|
|
21
|
-
'application/json': {
|
|
22
|
-
schema: ListResponseSchema(ExternalAgentApiSelectSchema),
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
...commonGetErrorResponses,
|
|
27
|
-
},
|
|
28
|
-
}), async (c) => {
|
|
29
|
-
const { tenantId, projectId } = c.req.valid('param');
|
|
30
|
-
const { page, limit } = c.req.valid('query');
|
|
31
|
-
const result = await listExternalAgentsPaginated(dbClient)({
|
|
32
|
-
scopes: { tenantId, projectId },
|
|
33
|
-
pagination: { page, limit },
|
|
34
|
-
});
|
|
35
|
-
// Add type field to all external agents in the response
|
|
36
|
-
const dataWithType = {
|
|
37
|
-
...result,
|
|
38
|
-
data: result.data.map((agent) => ({
|
|
39
|
-
...agent,
|
|
40
|
-
type: 'external',
|
|
41
|
-
})),
|
|
42
|
-
};
|
|
43
|
-
return c.json(dataWithType);
|
|
44
|
-
});
|
|
45
|
-
app.openapi(createRoute({
|
|
46
|
-
method: 'get',
|
|
47
|
-
path: '/{id}',
|
|
48
|
-
summary: 'Get External Agent',
|
|
49
|
-
operationId: 'get-external-agent-by-id',
|
|
50
|
-
tags: ['CRUD External Agents'],
|
|
51
|
-
request: {
|
|
52
|
-
params: TenantProjectParamsSchema.merge(IdParamsSchema),
|
|
53
|
-
},
|
|
54
|
-
responses: {
|
|
55
|
-
200: {
|
|
56
|
-
description: 'External agent found',
|
|
57
|
-
content: {
|
|
58
|
-
'application/json': {
|
|
59
|
-
schema: SingleResponseSchema(ExternalAgentApiSelectSchema),
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
...commonGetErrorResponses,
|
|
64
|
-
},
|
|
65
|
-
}), async (c) => {
|
|
66
|
-
const { tenantId, projectId, id } = c.req.valid('param');
|
|
67
|
-
const externalAgent = await getExternalAgent(dbClient)({
|
|
68
|
-
scopes: { tenantId, projectId },
|
|
69
|
-
agentId: id,
|
|
70
|
-
});
|
|
71
|
-
if (!externalAgent) {
|
|
72
|
-
throw createApiError({
|
|
73
|
-
code: 'not_found',
|
|
74
|
-
message: 'External agent not found',
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
// Add type field to the external agent response
|
|
78
|
-
const agentWithType = {
|
|
79
|
-
...externalAgent,
|
|
80
|
-
type: 'external',
|
|
81
|
-
};
|
|
82
|
-
return c.json({ data: agentWithType });
|
|
83
|
-
});
|
|
84
|
-
app.openapi(createRoute({
|
|
85
|
-
method: 'post',
|
|
86
|
-
path: '/',
|
|
87
|
-
summary: 'Create External Agent',
|
|
88
|
-
operationId: 'create-external-agent',
|
|
89
|
-
tags: ['CRUD External Agents'],
|
|
90
|
-
request: {
|
|
91
|
-
params: TenantProjectParamsSchema,
|
|
92
|
-
body: {
|
|
93
|
-
content: {
|
|
94
|
-
'application/json': {
|
|
95
|
-
schema: ExternalAgentApiInsertSchema,
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
responses: {
|
|
101
|
-
201: {
|
|
102
|
-
description: 'External agent created successfully',
|
|
103
|
-
content: {
|
|
104
|
-
'application/json': {
|
|
105
|
-
schema: SingleResponseSchema(ExternalAgentApiSelectSchema),
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
...commonGetErrorResponses,
|
|
110
|
-
},
|
|
111
|
-
}), async (c) => {
|
|
112
|
-
const { tenantId, projectId } = c.req.valid('param');
|
|
113
|
-
const body = c.req.valid('json');
|
|
114
|
-
const externalAgentData = {
|
|
115
|
-
tenantId,
|
|
116
|
-
projectId,
|
|
117
|
-
id: body.id ? String(body.id) : nanoid(),
|
|
118
|
-
name: body.name,
|
|
119
|
-
description: body.description,
|
|
120
|
-
baseUrl: body.baseUrl,
|
|
121
|
-
credentialReferenceId: body.credentialReferenceId || undefined,
|
|
122
|
-
headers: body.headers || undefined,
|
|
123
|
-
};
|
|
124
|
-
const externalAgent = await createExternalAgent(dbClient)(externalAgentData);
|
|
125
|
-
// Add type field to the external agent response
|
|
126
|
-
const agentWithType = {
|
|
127
|
-
...externalAgent,
|
|
128
|
-
type: 'external',
|
|
129
|
-
};
|
|
130
|
-
return c.json({ data: agentWithType }, 201);
|
|
131
|
-
});
|
|
132
|
-
app.openapi(createRoute({
|
|
133
|
-
method: 'put',
|
|
134
|
-
path: '/{id}',
|
|
135
|
-
summary: 'Update External Agent',
|
|
136
|
-
operationId: 'update-external-agent',
|
|
137
|
-
tags: ['CRUD External Agents'],
|
|
138
|
-
request: {
|
|
139
|
-
params: TenantProjectParamsSchema.merge(IdParamsSchema),
|
|
140
|
-
body: {
|
|
141
|
-
content: {
|
|
142
|
-
'application/json': {
|
|
143
|
-
schema: ExternalAgentApiUpdateSchema,
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
responses: {
|
|
149
|
-
200: {
|
|
150
|
-
description: 'External agent updated successfully',
|
|
151
|
-
content: {
|
|
152
|
-
'application/json': {
|
|
153
|
-
schema: SingleResponseSchema(ExternalAgentApiSelectSchema),
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
...commonGetErrorResponses,
|
|
158
|
-
},
|
|
159
|
-
}), async (c) => {
|
|
160
|
-
const { tenantId, projectId, id } = c.req.valid('param');
|
|
161
|
-
const body = c.req.valid('json');
|
|
162
|
-
const updatedExternalAgent = await updateExternalAgent(dbClient)({
|
|
163
|
-
scopes: { tenantId, projectId },
|
|
164
|
-
agentId: id,
|
|
165
|
-
data: body,
|
|
166
|
-
});
|
|
167
|
-
if (!updatedExternalAgent) {
|
|
168
|
-
throw createApiError({
|
|
169
|
-
code: 'not_found',
|
|
170
|
-
message: 'External agent not found',
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
// Add type field to the external agent response
|
|
174
|
-
const agentWithType = {
|
|
175
|
-
...updatedExternalAgent,
|
|
176
|
-
type: 'external',
|
|
177
|
-
};
|
|
178
|
-
return c.json({ data: agentWithType });
|
|
179
|
-
});
|
|
180
|
-
app.openapi(createRoute({
|
|
181
|
-
method: 'delete',
|
|
182
|
-
path: '/{id}',
|
|
183
|
-
summary: 'Delete External Agent',
|
|
184
|
-
operationId: 'delete-external-agent',
|
|
185
|
-
tags: ['CRUD External Agents'],
|
|
186
|
-
request: {
|
|
187
|
-
params: TenantProjectParamsSchema.merge(IdParamsSchema),
|
|
188
|
-
},
|
|
189
|
-
responses: {
|
|
190
|
-
204: {
|
|
191
|
-
description: 'External agent deleted successfully',
|
|
192
|
-
},
|
|
193
|
-
404: {
|
|
194
|
-
description: 'External agent not found',
|
|
195
|
-
content: {
|
|
196
|
-
'application/json': {
|
|
197
|
-
schema: ErrorResponseSchema,
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
}), async (c) => {
|
|
203
|
-
const { tenantId, projectId, id } = c.req.valid('param');
|
|
204
|
-
const deleted = await deleteExternalAgent(dbClient)({
|
|
205
|
-
scopes: { tenantId, projectId },
|
|
206
|
-
agentId: id,
|
|
207
|
-
});
|
|
208
|
-
if (!deleted) {
|
|
209
|
-
throw createApiError({
|
|
210
|
-
code: 'not_found',
|
|
211
|
-
message: 'External agent not found',
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
return c.body(null, 204);
|
|
215
|
-
});
|
|
216
|
-
export default app;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphFull.d.ts","sourceRoot":"","sources":["../../src/routes/graphFull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAkB7D,QAAA,MAAM,GAAG,0CAAoB,CAAC;AAuS9B,eAAe,GAAG,CAAC"}
|