feat: add deployable alpha silo

This commit is contained in:
2026-07-11 00:25:45 +08:00
parent 44557da499
commit 9e954790dc
57 changed files with 2792 additions and 400 deletions
+50 -15
View File
@@ -168,16 +168,30 @@ export async function listTeamMembers(
where: { teamId: input.teamId, revokedAt: null },
select: {
createdAt: true,
user: { select: { id: true, feishuOpenId: true, displayName: true } },
user: {
select: {
id: true,
feishuOpenId: true,
displayName: true,
feishuIdentities: {
where: { connection: { organizationId: input.organizationId } },
select: { openId: true },
take: 1,
},
},
},
},
orderBy: { createdAt: "asc" },
});
return rows.map((row) => ({
userId: row.user.id,
feishuOpenId: row.user.feishuOpenId,
displayName: row.user.displayName,
createdAt: row.createdAt.toISOString(),
}));
return rows.map((row) => {
const identity = row.user.feishuIdentities[0];
return {
userId: row.user.id,
feishuOpenId: identity?.openId ?? row.user.feishuOpenId,
displayName: row.user.displayName,
createdAt: row.createdAt.toISOString(),
};
});
}
export async function addTeamMember(
@@ -244,23 +258,44 @@ export async function revokeTeamMember(
async function resolveUser(
prisma: PrismaClient | Prisma.TransactionClient,
input: { readonly userId?: string | undefined; readonly feishuOpenId?: string | undefined },
input: {
readonly organizationId: string;
readonly userId?: string | undefined;
readonly feishuOpenId?: string | undefined;
},
): Promise<{ readonly id: string; readonly feishuOpenId: string; readonly displayName: string }> {
if (input.userId !== undefined && input.userId !== "") {
const user = await prisma.user.findUnique({
where: { id: input.userId },
select: { id: true, feishuOpenId: true, displayName: true },
select: {
id: true,
feishuOpenId: true,
displayName: true,
feishuIdentities: {
where: { connection: { organizationId: input.organizationId } },
select: { openId: true },
take: 1,
},
},
});
if (user === null) throw new Error(`user not found: ${input.userId}`);
return user;
const identity = user.feishuIdentities[0];
return {
id: user.id,
feishuOpenId: identity?.openId ?? user.feishuOpenId,
displayName: user.displayName,
};
}
if (input.feishuOpenId !== undefined && input.feishuOpenId !== "") {
const user = await prisma.user.findUnique({
where: { feishuOpenId: input.feishuOpenId },
select: { id: true, feishuOpenId: true, displayName: true },
const identity = await prisma.feishuUserIdentity.findFirst({
where: {
openId: input.feishuOpenId,
connection: { organizationId: input.organizationId, status: "ACTIVE" },
},
select: { openId: true, user: { select: { id: true, displayName: true } } },
});
if (user === null) throw new Error(`user not found: ${input.feishuOpenId}`);
return user;
if (identity === null) throw new Error(`user not found in organization: ${input.feishuOpenId}`);
return { id: identity.user.id, feishuOpenId: identity.openId, displayName: identity.user.displayName };
}
throw new Error("userId or feishuOpenId is required");
}