优化第一次

This commit is contained in:
Weiming committed 2026-10-09 16:36:02 +08:00
1 parent 3a4e81a070
commit 459339719d
83 files changed
+7001 -1767

No files matched your search

+38 -11
View File
@@ -1,10 +1,34 @@
import request from './request'
export type DirectorySnapshotState = 'UNAVAILABLE' | 'NEVER_SYNCED' | 'FRESH' | 'STALE' | 'CONTEXT_CHANGED'
export type DirectoryAvailabilityState = 'AVAILABLE' | 'NEVER_SYNCED' | 'UNAVAILABLE'
export type DirectoryContextState = 'MATCH' | 'CHANGED' | 'UNKNOWN'
export interface DirectoryAvailabilityContract {
snapshotState: DirectorySnapshotState
/** Additive fields are optional for rolling compatibility with older nodes. */
availabilityState?: DirectoryAvailabilityState | null
additionsAllowed?: boolean
currentRevision?: string | null
contextState?: DirectoryContextState | null
}
export const directoryAvailability = (value: DirectoryAvailabilityContract): DirectoryAvailabilityState => {
if (value.availabilityState === 'AVAILABLE' || value.availabilityState === 'NEVER_SYNCED' || value.availabilityState === 'UNAVAILABLE') {
return value.availabilityState
}
// Older backends did not expose availability. Only their FRESH state is safe
// to treat as usable; all other legacy states deliberately fail closed.
return value.snapshotState === 'FRESH'
? 'AVAILABLE'
: value.snapshotState === 'NEVER_SYNCED' ? 'NEVER_SYNCED' : 'UNAVAILABLE'
}
export interface DirectoryRun {
runId: string
trigger: 'MANUAL' | 'STARTUP'
trigger: 'MANUAL' | 'STARTUP' | 'SCHEDULED'
state: 'RUNNING' | 'SUCCEEDED' | 'FAILED'
startedAt: string
startedAt: string | null
finishedAt: string | null
complete: boolean
applied: boolean
@@ -13,10 +37,9 @@ export interface DirectoryRun {
errorMessage: string | null
}
export interface DirectoryStatus {
export interface DirectoryStatus extends DirectoryAvailabilityContract {
configured: boolean
running: boolean
snapshotState: 'UNAVAILABLE' | 'NEVER_SYNCED' | 'FRESH' | 'STALE' | 'CONTEXT_CHANGED'
maxStatusAgeSeconds: number
lastSuccessfulRunId: string | null
lastSuccessfulAt: string | null
@@ -36,19 +59,16 @@ export interface DirectoryDepartment {
export interface DirectoryOrganizationUser {
openId: string
userId: string
userId: string | null
name: string
email: string
mobile: string
jobTitle: string
employeeType: number | null
avatarUrl: string
employmentStatus: string
departmentIds: string[]
}
export interface DirectoryOrganization {
snapshotState: DirectoryStatus['snapshotState']
export interface DirectoryOrganization extends DirectoryAvailabilityContract {
lastSuccessfulAt: string | null
departments: DirectoryDepartment[]
users: DirectoryOrganizationUser[]
@@ -61,6 +81,13 @@ export const feishuDirectoryApi = {
request.post('/feishu/directory/sync', undefined, { timeout: DIRECTORY_SYNC_TIMEOUT, signal }),
status: (signal?: AbortSignal): Promise<DirectoryStatus> =>
request.get('/feishu/directory/status', { signal }),
organization: (signal?: AbortSignal): Promise<DirectoryOrganization> =>
request.get('/feishu/directory/organization', { signal }),
/** Departments (+ optional full users). Default omits users so the shell paints quickly. */
organization: (signal?: AbortSignal, includeUsers = false): Promise<DirectoryOrganization> =>
request.get('/feishu/directory/organization', { signal, params: { includeUsers } }),
/** Members for one department tree; used after the organization shell is ready. */
organizationMembers: (departmentId: string, signal?: AbortSignal, includeDescendants = true): Promise<DirectoryOrganization> =>
request.get('/feishu/directory/organization/members', {
signal,
params: { departmentId, includeDescendants },
}),
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.