import runDbClient_default from "../../../data/db/runDbClient.js";
import { OpenAPIHono, z } from "@hono/zod-openapi";
import { TenantParamsSchema, commonGetErrorResponses, listOrgEntitlements } from "@inkeep/agents-core";
import { createProtectedRoute, inheritedManageTenantAuth } from "@inkeep/agents-core/middleware";

//#region src/domains/manage/routes/entitlements.ts
const EntitlementItemSchema = z.object({
	resourceType: z.string().openapi({ example: "seat:admin" }),
	maxValue: z.number().int().openapi({ example: 10 })
});
const EntitlementsResponseSchema = z.object({ entitlements: z.array(EntitlementItemSchema) });
const app = new OpenAPIHono();
app.openapi(createProtectedRoute({
	method: "get",
	path: "/",
	summary: "List Org Entitlements",
	description: "List all entitlements for the current organization.",
	operationId: "list-org-entitlements",
	tags: ["Entitlements"],
	permission: inheritedManageTenantAuth(),
	request: { params: TenantParamsSchema },
	responses: {
		200: {
			description: "List of entitlements retrieved successfully",
			content: { "application/json": { schema: EntitlementsResponseSchema } }
		},
		...commonGetErrorResponses
	}
}), async (c) => {
	const { tenantId } = c.req.valid("param");
	const entitlements = await listOrgEntitlements(runDbClient_default)(tenantId);
	return c.json({ entitlements });
});
var entitlements_default = app;

//#endregion
export { entitlements_default as default };