@inkeep/agents-api 0.0.0-dev-20260123202200 → 0.0.0-dev-20260123211824
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/dist/.well-known/workflow/v1/manifest.debug.json +14 -14
- package/dist/.well-known/workflow/v1/step.cjs +946 -26
- package/dist/createApp.d.ts +2 -2
- package/dist/data/db/runDbClient.d.ts +2 -2
- package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
- package/dist/domains/evals/routes/index.d.ts +2 -2
- package/dist/domains/evals/workflow/routes.d.ts +2 -2
- package/dist/domains/manage/index.js +0 -2
- package/dist/domains/manage/routes/agent.js +5 -2
- package/dist/domains/manage/routes/agentFull.js +5 -2
- package/dist/domains/manage/routes/agentToolRelations.js +5 -2
- package/dist/domains/manage/routes/apiKeys.js +1 -2
- package/dist/domains/manage/routes/cliAuth.js +2 -2
- package/dist/domains/manage/routes/conversations.d.ts +2 -2
- package/dist/domains/manage/routes/credentials.js +1 -2
- package/dist/domains/manage/routes/dataComponents.js +1 -2
- package/dist/domains/manage/routes/evals/evaluationResults.d.ts +2 -2
- package/dist/domains/manage/routes/externalAgents.js +1 -2
- package/dist/domains/manage/routes/index.d.ts +2 -2
- package/dist/domains/manage/routes/index.js +4 -0
- package/dist/domains/manage/routes/mcp.d.ts +2 -2
- package/dist/domains/manage/routes/playgroundToken.js +0 -1
- package/dist/domains/manage/routes/projectFull.js +28 -6
- package/dist/domains/manage/routes/projectMembers.js +16 -35
- package/dist/domains/manage/routes/projectPermissions.js +17 -10
- package/dist/domains/manage/routes/projects.js +4 -5
- package/dist/domains/manage/routes/signoz.d.ts +2 -2
- package/dist/domains/manage/routes/userOrganizations.js +2 -2
- package/dist/domains/manage/routes/userProjectMemberships.d.ts +9 -0
- package/dist/domains/manage/routes/userProjectMemberships.js +45 -0
- package/dist/domains/run/agents/Agent.js +93 -2
- package/dist/domains/run/agents/relationTools.d.ts +2 -2
- package/dist/factory.d.ts +26 -26
- package/dist/index.d.ts +26 -26
- package/dist/initialization.js +2 -2
- package/dist/middleware/evalsAuth.d.ts +2 -2
- package/dist/middleware/manageAuth.d.ts +2 -2
- package/dist/middleware/projectAccess.d.ts +4 -11
- package/dist/middleware/projectAccess.js +1 -17
- package/dist/middleware/projectConfig.d.ts +3 -3
- package/dist/middleware/tenantAccess.js +4 -4
- package/dist/types/app.d.ts +2 -0
- package/package.json +3 -3
package/dist/createApp.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AppConfig } from "./types/app.js";
|
|
2
2
|
import "./types/index.js";
|
|
3
3
|
import { Hono } from "hono";
|
|
4
|
-
import * as
|
|
4
|
+
import * as hono_types3 from "hono/types";
|
|
5
5
|
|
|
6
6
|
//#region src/createApp.d.ts
|
|
7
7
|
declare const isWebhookRoute: (path: string) => boolean;
|
|
8
|
-
declare function createAgentsHono(config: AppConfig): Hono<
|
|
8
|
+
declare function createAgentsHono(config: AppConfig): Hono<hono_types3.BlankEnv, hono_types3.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { createAgentsHono, isWebhookRoute };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _inkeep_agents_core0 from "@inkeep/agents-core";
|
|
2
2
|
|
|
3
3
|
//#region src/data/db/runDbClient.d.ts
|
|
4
|
-
declare const runDbClient:
|
|
4
|
+
declare const runDbClient: _inkeep_agents_core0.AgentsRunDatabaseClient;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { runDbClient as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono14 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/evals/routes/datasetTriggers.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono14.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono15 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/evals/routes/index.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono15.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types6 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/evals/workflow/routes.d.ts
|
|
5
|
-
declare const workflowRoutes: Hono<
|
|
5
|
+
declare const workflowRoutes: Hono<hono_types6.BlankEnv, hono_types6.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { workflowRoutes };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import cliAuth_default from "./routes/cliAuth.js";
|
|
2
|
-
import evals_default from "./routes/evals/index.js";
|
|
3
2
|
import routes_default from "./routes/index.js";
|
|
4
3
|
import invitations_default from "./routes/invitations.js";
|
|
5
4
|
import mcp_default from "./routes/mcp.js";
|
|
@@ -20,7 +19,6 @@ function createManageRoutes() {
|
|
|
20
19
|
app.route("/tenants/:tenantId/playground/token", playgroundToken_default);
|
|
21
20
|
app.route("/tenants/:tenantId/signoz", signoz_default);
|
|
22
21
|
app.route("/tenants/:tenantId", projectFull_default);
|
|
23
|
-
app.route("/tenants/:tenantId/projects/:projectId/evals", evals_default);
|
|
24
22
|
app.route("/oauth", oauth_default);
|
|
25
23
|
app.route("/mcp", mcp_default);
|
|
26
24
|
return app;
|
|
@@ -11,8 +11,11 @@ app.use("/", async (c, next) => {
|
|
|
11
11
|
return next();
|
|
12
12
|
});
|
|
13
13
|
app.use("/:id", async (c, next) => {
|
|
14
|
-
if (
|
|
15
|
-
|
|
14
|
+
if ([
|
|
15
|
+
"PUT",
|
|
16
|
+
"PATCH",
|
|
17
|
+
"DELETE"
|
|
18
|
+
].includes(c.req.method)) return requireProjectPermission("edit")(c, next);
|
|
16
19
|
return next();
|
|
17
20
|
});
|
|
18
21
|
app.openapi(createRoute({
|
|
@@ -12,8 +12,11 @@ app.use("/", async (c, next) => {
|
|
|
12
12
|
return next();
|
|
13
13
|
});
|
|
14
14
|
app.use("/:agentId", async (c, next) => {
|
|
15
|
-
if (
|
|
16
|
-
|
|
15
|
+
if ([
|
|
16
|
+
"PUT",
|
|
17
|
+
"PATCH",
|
|
18
|
+
"DELETE"
|
|
19
|
+
].includes(c.req.method)) return requireProjectPermission("edit")(c, next);
|
|
17
20
|
return next();
|
|
18
21
|
});
|
|
19
22
|
app.openapi(createRoute({
|
|
@@ -10,8 +10,11 @@ app.use("/", async (c, next) => {
|
|
|
10
10
|
return next();
|
|
11
11
|
});
|
|
12
12
|
app.use("/:id", async (c, next) => {
|
|
13
|
-
if (
|
|
14
|
-
|
|
13
|
+
if ([
|
|
14
|
+
"PUT",
|
|
15
|
+
"PATCH",
|
|
16
|
+
"DELETE"
|
|
17
|
+
].includes(c.req.method)) return requireProjectPermission("edit")(c, next);
|
|
15
18
|
return next();
|
|
16
19
|
});
|
|
17
20
|
app.openapi(createRoute({
|
|
@@ -11,8 +11,7 @@ app.use("/", async (c, next) => {
|
|
|
11
11
|
return next();
|
|
12
12
|
});
|
|
13
13
|
app.use("/:id", async (c, next) => {
|
|
14
|
-
if (c.req.method === "
|
|
15
|
-
if (c.req.method === "DELETE") return requireProjectPermission("edit")(c, next);
|
|
14
|
+
if (c.req.method === "PUT" || c.req.method === "DELETE") return requireProjectPermission("edit")(c, next);
|
|
16
15
|
return next();
|
|
17
16
|
});
|
|
18
17
|
app.openapi(createRoute({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
2
2
|
import { sessionAuth } from "../../../middleware/sessionAuth.js";
|
|
3
3
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
4
|
-
import {
|
|
4
|
+
import { getUserOrganizationsFromDb } from "@inkeep/agents-core";
|
|
5
5
|
|
|
6
6
|
//#region src/domains/manage/routes/cliAuth.ts
|
|
7
7
|
const cliAuthRoutes = new OpenAPIHono();
|
|
@@ -37,7 +37,7 @@ cliAuthRoutes.openapi(createRoute({
|
|
|
37
37
|
const user = c.get("user");
|
|
38
38
|
const userId = c.get("userId");
|
|
39
39
|
if (!user || !userId) return c.json({ error: "Not authenticated" }, 401);
|
|
40
|
-
const organizations = await
|
|
40
|
+
const organizations = await getUserOrganizationsFromDb(runDbClient_default)(userId);
|
|
41
41
|
if (organizations.length === 0) return c.json({ error: "User has no organization" }, 404);
|
|
42
42
|
const org = organizations[0];
|
|
43
43
|
return c.json({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono16 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/conversations.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono16.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -10,8 +10,7 @@ app.use("/", async (c, next) => {
|
|
|
10
10
|
return next();
|
|
11
11
|
});
|
|
12
12
|
app.use("/:id", async (c, next) => {
|
|
13
|
-
if (c.req.method === "PATCH") return requireProjectPermission("edit")(c, next);
|
|
14
|
-
if (c.req.method === "DELETE") return requireProjectPermission("edit")(c, next);
|
|
13
|
+
if (c.req.method === "PATCH" || c.req.method === "DELETE" || c.req.method === "PUT") return requireProjectPermission("edit")(c, next);
|
|
15
14
|
return next();
|
|
16
15
|
});
|
|
17
16
|
app.openapi(createRoute({
|
|
@@ -10,8 +10,7 @@ app.use("/", async (c, next) => {
|
|
|
10
10
|
return next();
|
|
11
11
|
});
|
|
12
12
|
app.use("/:id", async (c, next) => {
|
|
13
|
-
if (c.req.method === "
|
|
14
|
-
if (c.req.method === "DELETE") return requireProjectPermission("edit")(c, next);
|
|
13
|
+
if (c.req.method === "PUT" || c.req.method === "DELETE") return requireProjectPermission("edit")(c, next);
|
|
15
14
|
return next();
|
|
16
15
|
});
|
|
17
16
|
app.openapi(createRoute({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono18 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/evals/evaluationResults.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono18.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -10,8 +10,7 @@ app.use("/", async (c, next) => {
|
|
|
10
10
|
return next();
|
|
11
11
|
});
|
|
12
12
|
app.use("/:id", async (c, next) => {
|
|
13
|
-
if (c.req.method === "
|
|
14
|
-
if (c.req.method === "DELETE") return requireProjectPermission("edit")(c, next);
|
|
13
|
+
if (c.req.method === "PUT" || c.req.method === "DELETE") return requireProjectPermission("edit")(c, next);
|
|
15
14
|
return next();
|
|
16
15
|
});
|
|
17
16
|
app.openapi(createRoute({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono17 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/index.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono17.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -9,6 +9,7 @@ import conversations_default from "./conversations.js";
|
|
|
9
9
|
import credentialStores_default from "./credentialStores.js";
|
|
10
10
|
import credentials_default from "./credentials.js";
|
|
11
11
|
import dataComponents_default from "./dataComponents.js";
|
|
12
|
+
import evals_default from "./evals/index.js";
|
|
12
13
|
import externalAgents_default from "./externalAgents.js";
|
|
13
14
|
import functions_default from "./functions.js";
|
|
14
15
|
import functionTools_default from "./functionTools.js";
|
|
@@ -28,6 +29,7 @@ import subAgentToolRelations_default from "./subAgentToolRelations.js";
|
|
|
28
29
|
import thirdPartyMCPServers_default from "./thirdPartyMCPServers.js";
|
|
29
30
|
import tools_default from "./tools.js";
|
|
30
31
|
import triggers_default from "./triggers.js";
|
|
32
|
+
import userProjectMemberships_default from "./userProjectMemberships.js";
|
|
31
33
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
32
34
|
|
|
33
35
|
//#region src/domains/manage/routes/index.ts
|
|
@@ -62,6 +64,8 @@ app.route("/projects/:projectId/agent", agentFull_default);
|
|
|
62
64
|
app.route("/projects/:projectId/mcp-catalog", mcpCatalog_default);
|
|
63
65
|
app.route("/projects/:projectId/third-party-mcp-servers", thirdPartyMCPServers_default);
|
|
64
66
|
app.route("/projects/:projectId/agents/:agentId/triggers", triggers_default);
|
|
67
|
+
app.route("/projects/:projectId/evals", evals_default);
|
|
68
|
+
app.route("/users/:userId/project-memberships", userProjectMemberships_default);
|
|
65
69
|
var routes_default = app;
|
|
66
70
|
|
|
67
71
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types8 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/mcp.d.ts
|
|
5
|
-
declare const app: Hono<
|
|
5
|
+
declare const app: Hono<hono_types8.BlankEnv, hono_types8.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -14,10 +14,27 @@ app.use("/project-full", async (c, next) => {
|
|
|
14
14
|
return next();
|
|
15
15
|
});
|
|
16
16
|
app.use("/project-full/:projectId", async (c, next) => {
|
|
17
|
-
if (c.req.method === "
|
|
18
|
-
if (c.req.method === "DELETE") return requireProjectPermission("edit")(c, next);
|
|
17
|
+
if (c.req.method === "GET") return requireProjectPermission("view")(c, next);
|
|
19
18
|
return next();
|
|
20
19
|
});
|
|
20
|
+
app.use("/project-full/:projectId/with-relation-ids", async (c, next) => {
|
|
21
|
+
if (c.req.method === "GET") return requireProjectPermission("view")(c, next);
|
|
22
|
+
return next();
|
|
23
|
+
});
|
|
24
|
+
const requireProjectUpsertPermission = async (c, next) => {
|
|
25
|
+
const tenantId = c.get("tenantId");
|
|
26
|
+
const projectId = c.req.param("projectId");
|
|
27
|
+
if (!tenantId || !projectId) throw createApiError({
|
|
28
|
+
code: "bad_request",
|
|
29
|
+
message: "Missing tenantId or projectId"
|
|
30
|
+
});
|
|
31
|
+
const exists = await getProjectMetadata(runDbClient_default)({
|
|
32
|
+
tenantId,
|
|
33
|
+
projectId
|
|
34
|
+
});
|
|
35
|
+
c.set("isProjectCreate", !exists);
|
|
36
|
+
return exists ? requireProjectPermission("edit")(c, next) : requirePermission({ project: ["create"] })(c, next);
|
|
37
|
+
};
|
|
21
38
|
app.openapi(createRoute({
|
|
22
39
|
method: "post",
|
|
23
40
|
path: "/project-full",
|
|
@@ -163,6 +180,10 @@ app.openapi(createRoute({
|
|
|
163
180
|
});
|
|
164
181
|
}
|
|
165
182
|
});
|
|
183
|
+
app.use("/project-full/:projectId", async (c, next) => {
|
|
184
|
+
if (c.req.method === "PUT") return requireProjectUpsertPermission(c, next);
|
|
185
|
+
return next();
|
|
186
|
+
});
|
|
166
187
|
app.openapi(createRoute({
|
|
167
188
|
method: "put",
|
|
168
189
|
path: "/project-full/{projectId}",
|
|
@@ -196,10 +217,7 @@ app.openapi(createRoute({
|
|
|
196
217
|
code: "bad_request",
|
|
197
218
|
message: `Project ID mismatch: expected ${projectId}, got ${validatedProjectData.id}`
|
|
198
219
|
});
|
|
199
|
-
const isCreate =
|
|
200
|
-
tenantId,
|
|
201
|
-
projectId
|
|
202
|
-
});
|
|
220
|
+
const isCreate = c.get("isProjectCreate") ?? false;
|
|
203
221
|
if (isCreate) {
|
|
204
222
|
await createProjectMetadataAndBranch(runDbClient_default, configDb)({
|
|
205
223
|
tenantId,
|
|
@@ -245,6 +263,10 @@ app.openapi(createRoute({
|
|
|
245
263
|
});
|
|
246
264
|
}
|
|
247
265
|
});
|
|
266
|
+
app.use("/project-full/:projectId", async (c, next) => {
|
|
267
|
+
if (c.req.method === "DELETE") return requirePermission({ project: ["delete"] })(c, next);
|
|
268
|
+
return next();
|
|
269
|
+
});
|
|
248
270
|
app.openapi(createRoute({
|
|
249
271
|
method: "delete",
|
|
250
272
|
path: "/project-full/{projectId}",
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import { requireProjectPermission } from "../../../middleware/projectAccess.js";
|
|
2
2
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
3
|
-
import { changeProjectRole, commonGetErrorResponses, createApiError, grantProjectAccess, isAuthzEnabled, listProjectMembers, revokeProjectAccess } from "@inkeep/agents-core";
|
|
3
|
+
import { ProjectRoles, changeProjectRole, commonGetErrorResponses, createApiError, grantProjectAccess, isAuthzEnabled, listProjectMembers, revokeProjectAccess } from "@inkeep/agents-core";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/projectMembers.ts
|
|
6
6
|
const app = new OpenAPIHono();
|
|
7
|
+
const projectRoleEnum = z.enum([
|
|
8
|
+
ProjectRoles.ADMIN,
|
|
9
|
+
ProjectRoles.MEMBER,
|
|
10
|
+
ProjectRoles.VIEWER
|
|
11
|
+
]);
|
|
7
12
|
const ProjectMemberSchema = z.object({
|
|
8
13
|
userId: z.string().min(1),
|
|
9
|
-
role:
|
|
10
|
-
"project_admin",
|
|
11
|
-
"project_member",
|
|
12
|
-
"project_viewer"
|
|
13
|
-
])
|
|
14
|
+
role: projectRoleEnum
|
|
14
15
|
});
|
|
15
16
|
const ProjectMemberResponseSchema = z.object({ data: z.object({
|
|
16
17
|
userId: z.string(),
|
|
17
|
-
role:
|
|
18
|
-
"project_admin",
|
|
19
|
-
"project_member",
|
|
20
|
-
"project_viewer"
|
|
21
|
-
]),
|
|
18
|
+
role: projectRoleEnum,
|
|
22
19
|
projectId: z.string()
|
|
23
20
|
}) });
|
|
24
21
|
const ProjectMemberParamsSchema = z.object({
|
|
@@ -31,16 +28,8 @@ const ProjectMemberUserParamsSchema = z.object({
|
|
|
31
28
|
userId: z.string()
|
|
32
29
|
});
|
|
33
30
|
const UpdateRoleSchema = z.object({
|
|
34
|
-
role:
|
|
35
|
-
|
|
36
|
-
"project_member",
|
|
37
|
-
"project_viewer"
|
|
38
|
-
]),
|
|
39
|
-
previousRole: z.enum([
|
|
40
|
-
"project_admin",
|
|
41
|
-
"project_member",
|
|
42
|
-
"project_viewer"
|
|
43
|
-
]).optional()
|
|
31
|
+
role: projectRoleEnum,
|
|
32
|
+
previousRole: projectRoleEnum.optional()
|
|
44
33
|
});
|
|
45
34
|
app.openapi(createRoute({
|
|
46
35
|
method: "get",
|
|
@@ -55,18 +44,14 @@ app.openapi(createRoute({
|
|
|
55
44
|
description: "List of project members",
|
|
56
45
|
content: { "application/json": { schema: z.object({ data: z.array(z.object({
|
|
57
46
|
userId: z.string(),
|
|
58
|
-
role:
|
|
59
|
-
"project_admin",
|
|
60
|
-
"project_member",
|
|
61
|
-
"project_viewer"
|
|
62
|
-
])
|
|
47
|
+
role: projectRoleEnum
|
|
63
48
|
})) }) } }
|
|
64
49
|
},
|
|
65
50
|
...commonGetErrorResponses
|
|
66
51
|
}
|
|
67
52
|
}), async (c) => {
|
|
68
53
|
const { projectId, tenantId } = c.req.valid("param");
|
|
69
|
-
if (!isAuthzEnabled(
|
|
54
|
+
if (!isAuthzEnabled()) return c.json({ data: [] });
|
|
70
55
|
const members = await listProjectMembers({
|
|
71
56
|
tenantId,
|
|
72
57
|
projectId
|
|
@@ -98,7 +83,7 @@ app.openapi(createRoute({
|
|
|
98
83
|
}), async (c) => {
|
|
99
84
|
const { projectId, tenantId } = c.req.valid("param");
|
|
100
85
|
const { userId, role } = c.req.valid("json");
|
|
101
|
-
if (!isAuthzEnabled(
|
|
86
|
+
if (!isAuthzEnabled()) throw createApiError({
|
|
102
87
|
code: "bad_request",
|
|
103
88
|
message: "Project member management requires authorization to be enabled (ENABLE_AUTHZ=true)"
|
|
104
89
|
});
|
|
@@ -135,7 +120,7 @@ app.openapi(createRoute({
|
|
|
135
120
|
}), async (c) => {
|
|
136
121
|
const { projectId, userId, tenantId } = c.req.valid("param");
|
|
137
122
|
const { role: newRole, previousRole } = c.req.valid("json");
|
|
138
|
-
if (!isAuthzEnabled(
|
|
123
|
+
if (!isAuthzEnabled()) throw createApiError({
|
|
139
124
|
code: "bad_request",
|
|
140
125
|
message: "Project member management requires authorization to be enabled (ENABLE_AUTHZ=true)"
|
|
141
126
|
});
|
|
@@ -170,11 +155,7 @@ app.openapi(createRoute({
|
|
|
170
155
|
tags: ["Project Members"],
|
|
171
156
|
request: {
|
|
172
157
|
params: ProjectMemberUserParamsSchema,
|
|
173
|
-
query: z.object({ role:
|
|
174
|
-
"project_admin",
|
|
175
|
-
"project_member",
|
|
176
|
-
"project_viewer"
|
|
177
|
-
]) })
|
|
158
|
+
query: z.object({ role: projectRoleEnum })
|
|
178
159
|
},
|
|
179
160
|
responses: {
|
|
180
161
|
204: { description: "Member removed successfully" },
|
|
@@ -183,7 +164,7 @@ app.openapi(createRoute({
|
|
|
183
164
|
}), async (c) => {
|
|
184
165
|
const { projectId, userId, tenantId } = c.req.valid("param");
|
|
185
166
|
const { role } = c.req.valid("query");
|
|
186
|
-
if (!isAuthzEnabled(
|
|
167
|
+
if (!isAuthzEnabled()) throw createApiError({
|
|
187
168
|
code: "bad_request",
|
|
188
169
|
message: "Project member management requires authorization to be enabled (ENABLE_AUTHZ=true)"
|
|
189
170
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { env } from "../../../env.js";
|
|
1
2
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
|
-
import {
|
|
3
|
+
import { OrgRoles, SpiceDbProjectPermissions, SpiceDbResourceTypes, checkBulkPermissions, commonGetErrorResponses, createApiError, isAuthzEnabled } from "@inkeep/agents-core";
|
|
3
4
|
|
|
4
5
|
//#region src/domains/manage/routes/projectPermissions.ts
|
|
5
6
|
const app = new OpenAPIHono();
|
|
@@ -28,15 +29,21 @@ app.openapi(createRoute({
|
|
|
28
29
|
...commonGetErrorResponses
|
|
29
30
|
}
|
|
30
31
|
}), async (c) => {
|
|
31
|
-
const { projectId
|
|
32
|
+
const { projectId } = c.req.valid("param");
|
|
32
33
|
const userId = c.get("userId");
|
|
33
34
|
const tenantRole = c.get("tenantRole");
|
|
34
|
-
|
|
35
|
+
const isTestEnvironment = process.env.ENVIRONMENT === "test";
|
|
36
|
+
if (env.DISABLE_AUTH || isTestEnvironment) return c.json({ data: {
|
|
35
37
|
canView: true,
|
|
36
38
|
canUse: true,
|
|
37
39
|
canEdit: true
|
|
38
40
|
} });
|
|
39
|
-
if (
|
|
41
|
+
if (tenantRole === OrgRoles.OWNER || tenantRole === OrgRoles.ADMIN) return c.json({ data: {
|
|
42
|
+
canView: true,
|
|
43
|
+
canUse: true,
|
|
44
|
+
canEdit: true
|
|
45
|
+
} });
|
|
46
|
+
if (!isAuthzEnabled()) return c.json({ data: {
|
|
40
47
|
canView: true,
|
|
41
48
|
canUse: true,
|
|
42
49
|
canEdit: false
|
|
@@ -49,17 +56,17 @@ app.openapi(createRoute({
|
|
|
49
56
|
resourceType: SpiceDbResourceTypes.PROJECT,
|
|
50
57
|
resourceId: projectId,
|
|
51
58
|
permissions: [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
SpiceDbProjectPermissions.VIEW,
|
|
60
|
+
SpiceDbProjectPermissions.USE,
|
|
61
|
+
SpiceDbProjectPermissions.EDIT
|
|
55
62
|
],
|
|
56
63
|
subjectType: SpiceDbResourceTypes.USER,
|
|
57
64
|
subjectId: userId
|
|
58
65
|
});
|
|
59
66
|
return c.json({ data: {
|
|
60
|
-
canView: permissions[
|
|
61
|
-
canUse: permissions[
|
|
62
|
-
canEdit: permissions[
|
|
67
|
+
canView: permissions[SpiceDbProjectPermissions.VIEW] ?? false,
|
|
68
|
+
canUse: permissions[SpiceDbProjectPermissions.USE] ?? false,
|
|
69
|
+
canEdit: permissions[SpiceDbProjectPermissions.EDIT] ?? false
|
|
63
70
|
} });
|
|
64
71
|
});
|
|
65
72
|
var projectPermissions_default = app;
|
|
@@ -15,7 +15,7 @@ app.use("/", async (c, next) => {
|
|
|
15
15
|
app.use("/:id", async (c, next) => {
|
|
16
16
|
if (c.req.method === "GET") return requireProjectPermission("view")(c, next);
|
|
17
17
|
if (c.req.method === "PATCH") return requireProjectPermission("edit")(c, next);
|
|
18
|
-
if (c.req.method === "DELETE") return
|
|
18
|
+
if (c.req.method === "DELETE") return requirePermission({ project: ["delete"] })(c, next);
|
|
19
19
|
return next();
|
|
20
20
|
});
|
|
21
21
|
app.openapi(createRoute({
|
|
@@ -45,9 +45,8 @@ app.openapi(createRoute({
|
|
|
45
45
|
const page = Number(c.req.query("page")) || 1;
|
|
46
46
|
const limit = Math.min(Number(c.req.query("limit")) || 10, 100);
|
|
47
47
|
let accessibleIds;
|
|
48
|
-
if (isAuthzEnabled(
|
|
48
|
+
if (isAuthzEnabled() && userId) {
|
|
49
49
|
const result$1 = await listAccessibleProjectIds({
|
|
50
|
-
tenantId,
|
|
51
50
|
userId,
|
|
52
51
|
orgRole: tenantRole
|
|
53
52
|
});
|
|
@@ -149,7 +148,7 @@ app.openapi(createRoute({
|
|
|
149
148
|
tenantId,
|
|
150
149
|
...body
|
|
151
150
|
});
|
|
152
|
-
if (isAuthzEnabled(
|
|
151
|
+
if (isAuthzEnabled()) {
|
|
153
152
|
if (!userId) throw createApiError({
|
|
154
153
|
code: "unauthorized",
|
|
155
154
|
message: "User not found"
|
|
@@ -256,7 +255,7 @@ app.openapi(createRoute({
|
|
|
256
255
|
code: "not_found",
|
|
257
256
|
message: "Project not found"
|
|
258
257
|
});
|
|
259
|
-
if (isAuthzEnabled(
|
|
258
|
+
if (isAuthzEnabled()) try {
|
|
260
259
|
await removeProjectFromSpiceDb({
|
|
261
260
|
tenantId,
|
|
262
261
|
projectId: id
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
|
-
import * as
|
|
3
|
+
import * as hono_types5 from "hono/types";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/signoz.d.ts
|
|
6
6
|
declare const app: Hono<{
|
|
7
7
|
Variables: ManageAppVariables;
|
|
8
|
-
},
|
|
8
|
+
}, hono_types5.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { app as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
2
2
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
3
|
-
import { addUserToOrganization,
|
|
3
|
+
import { addUserToOrganization, getUserOrganizationsFromDb } from "@inkeep/agents-core";
|
|
4
4
|
import { AddUserToOrganizationRequestSchema, AddUserToOrganizationResponseSchema, UserOrganizationsResponseSchema } from "@inkeep/agents-core/auth/validation";
|
|
5
5
|
|
|
6
6
|
//#region src/domains/manage/routes/userOrganizations.ts
|
|
@@ -18,7 +18,7 @@ userOrganizationsRoutes.openapi(createRoute({
|
|
|
18
18
|
} }
|
|
19
19
|
}), async (c) => {
|
|
20
20
|
const { userId } = c.req.valid("param");
|
|
21
|
-
const userOrganizations = (await
|
|
21
|
+
const userOrganizations = (await getUserOrganizationsFromDb(runDbClient_default)(userId)).map((org) => ({
|
|
22
22
|
...org,
|
|
23
23
|
createdAt: org.createdAt.toISOString()
|
|
24
24
|
}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
3
|
+
|
|
4
|
+
//#region src/domains/manage/routes/userProjectMemberships.d.ts
|
|
5
|
+
declare const app: OpenAPIHono<{
|
|
6
|
+
Variables: ManageAppVariables;
|
|
7
|
+
}, {}, "/">;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { app as default };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
|
+
import { ProjectRoles, commonGetErrorResponses, isAuthzEnabled, listUserProjectMembershipsInSpiceDb } from "@inkeep/agents-core";
|
|
3
|
+
|
|
4
|
+
//#region src/domains/manage/routes/userProjectMemberships.ts
|
|
5
|
+
const app = new OpenAPIHono();
|
|
6
|
+
const projectRoleEnum = z.enum([
|
|
7
|
+
ProjectRoles.ADMIN,
|
|
8
|
+
ProjectRoles.MEMBER,
|
|
9
|
+
ProjectRoles.VIEWER
|
|
10
|
+
]);
|
|
11
|
+
const UserProjectMembershipParamsSchema = z.object({
|
|
12
|
+
tenantId: z.string(),
|
|
13
|
+
userId: z.string()
|
|
14
|
+
});
|
|
15
|
+
app.openapi(createRoute({
|
|
16
|
+
method: "get",
|
|
17
|
+
path: "/",
|
|
18
|
+
summary: "List User Project Memberships",
|
|
19
|
+
description: "List all projects a user has explicit access to and their role in each. Requires authz to be enabled.",
|
|
20
|
+
operationId: "list-user-project-memberships",
|
|
21
|
+
tags: ["User Project Memberships"],
|
|
22
|
+
request: { params: UserProjectMembershipParamsSchema },
|
|
23
|
+
responses: {
|
|
24
|
+
200: {
|
|
25
|
+
description: "List of project memberships for the user",
|
|
26
|
+
content: { "application/json": { schema: z.object({ data: z.array(z.object({
|
|
27
|
+
projectId: z.string(),
|
|
28
|
+
role: projectRoleEnum
|
|
29
|
+
})) }) } }
|
|
30
|
+
},
|
|
31
|
+
...commonGetErrorResponses
|
|
32
|
+
}
|
|
33
|
+
}), async (c) => {
|
|
34
|
+
const { tenantId, userId } = c.req.valid("param");
|
|
35
|
+
if (!isAuthzEnabled()) return c.json({ data: [] });
|
|
36
|
+
const memberships = await listUserProjectMembershipsInSpiceDb({
|
|
37
|
+
tenantId,
|
|
38
|
+
userId
|
|
39
|
+
});
|
|
40
|
+
return c.json({ data: memberships });
|
|
41
|
+
});
|
|
42
|
+
var userProjectMemberships_default = app;
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { userProjectMemberships_default as default };
|