feat: add seal session diagnostic tool
This commit is contained in:
1 parent
87725a4ca0
commit
cfffa5f404
5 files changed
+52
No files matched your search
@@ -13,6 +13,8 @@ import {
|
||||
MeData,
|
||||
MeDataSchema,
|
||||
PublishVersionDataSchema,
|
||||
SealSessionData,
|
||||
SealSessionDataSchema,
|
||||
RuleSetVersion,
|
||||
RuleSetVersionSchema
|
||||
} from "./types.js";
|
||||
@@ -26,6 +28,10 @@ export async function getMe(client: KyInstance): Promise<MeData> {
|
||||
return unwrap(await client.get("api/v1/auth/me"), MeDataSchema);
|
||||
}
|
||||
|
||||
export async function getSession(client: KyInstance): Promise<SealSessionData> {
|
||||
return unwrap(await client.get("api/auth/get-session"), SealSessionDataSchema);
|
||||
}
|
||||
|
||||
export async function listApprovalRules(client: KyInstance): Promise<ApprovalRulesData> {
|
||||
return unwrap(await client.get("api/v1/rules"), ApprovalRulesDataSchema);
|
||||
}
|
||||
|
||||
@@ -24,4 +24,9 @@ describe("sealTools", () => {
|
||||
const tool = sealTools.find((item) => item.name === "seal_approval_context_get");
|
||||
expect(tool).toBeDefined();
|
||||
});
|
||||
|
||||
test("includes the session diagnostic tool", () => {
|
||||
const tool = sealTools.find((item) => item.name === "seal_session_get");
|
||||
expect(tool).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -14,6 +14,12 @@ export const sealTools = [
|
||||
parameters: z.object({}),
|
||||
handler: async (client: KyInstance) => api.getMe(client)
|
||||
},
|
||||
{
|
||||
name: "seal_session_get",
|
||||
description: "查询当前 Seal Bearer session、用户和过期时间",
|
||||
parameters: z.object({}),
|
||||
handler: async (client: KyInstance) => api.getSession(client)
|
||||
},
|
||||
{
|
||||
name: "seal_approval_rules_list",
|
||||
description: "列出 Seal 当前草稿审批规则",
|
||||
|
||||
@@ -37,6 +37,39 @@ export const MeDataSchema = z.object({
|
||||
tenant: SealTenantSchema
|
||||
});
|
||||
|
||||
export const SealSessionUserSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
email: z.string().nullable().optional(),
|
||||
emailVerified: z.boolean().optional(),
|
||||
image: z.string().nullable().optional(),
|
||||
tenantId: z.string().optional(),
|
||||
provider: z.string().optional(),
|
||||
providerUserId: z.string().optional(),
|
||||
mobile: z.string().nullable().optional(),
|
||||
status: z.string().optional(),
|
||||
permissions: z.array(z.string()).default([]),
|
||||
isAdmin: z.boolean().default(false),
|
||||
hosecloudStaff: z.unknown().optional()
|
||||
}).passthrough();
|
||||
|
||||
export const SealSessionInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
token: z.string().optional(),
|
||||
expiresAt: z.string(),
|
||||
createdAt: z.string().optional(),
|
||||
updatedAt: z.string().optional(),
|
||||
ipAddress: z.string().optional(),
|
||||
userAgent: z.string().optional(),
|
||||
userId: z.string(),
|
||||
delegationId: z.string().nullable().optional()
|
||||
}).passthrough();
|
||||
|
||||
export const SealSessionDataSchema = z.object({
|
||||
user: SealSessionUserSchema,
|
||||
session: SealSessionInfoSchema
|
||||
});
|
||||
|
||||
export const ApprovalRuleSchema = z.object({
|
||||
id: z.string(),
|
||||
tenantId: z.string().optional(),
|
||||
@@ -143,6 +176,7 @@ export const ApprovalStylePreferencesSchema = z.object({
|
||||
}).passthrough();
|
||||
|
||||
export type MeData = z.infer<typeof MeDataSchema>;
|
||||
export type SealSessionData = z.infer<typeof SealSessionDataSchema>;
|
||||
export type ApprovalRule = z.infer<typeof ApprovalRuleSchema>;
|
||||
export type ApprovalRulesData = z.infer<typeof ApprovalRulesDataSchema>;
|
||||
export type RuleSetVersion = z.infer<typeof RuleSetVersionSchema>;
|
||||
|
||||
Reference in new issue
Block a user