初始化
This commit is contained in:
commit
3a4e81a070
43 files changed
+10871
No files matched your search
@@ -0,0 +1,66 @@
|
||||
import request from './request'
|
||||
|
||||
export interface DirectoryRun {
|
||||
runId: string
|
||||
trigger: 'MANUAL' | 'STARTUP'
|
||||
state: 'RUNNING' | 'SUCCEEDED' | 'FAILED'
|
||||
startedAt: string
|
||||
finishedAt: string | null
|
||||
complete: boolean
|
||||
applied: boolean
|
||||
counts: Record<'departments' | 'usersSeen' | 'excluded' | 'created' | 'updated' | 'outOfScope', number>
|
||||
errorCode: string | null
|
||||
errorMessage: string | null
|
||||
}
|
||||
|
||||
export interface DirectoryStatus {
|
||||
configured: boolean
|
||||
running: boolean
|
||||
snapshotState: 'UNAVAILABLE' | 'NEVER_SYNCED' | 'FRESH' | 'STALE' | 'CONTEXT_CHANGED'
|
||||
maxStatusAgeSeconds: number
|
||||
lastSuccessfulRunId: string | null
|
||||
lastSuccessfulAt: string | null
|
||||
snapshotExpiresAt: string | null
|
||||
lastRun: DirectoryRun | null
|
||||
}
|
||||
|
||||
export interface DirectoryDepartment {
|
||||
id: string
|
||||
name: string
|
||||
parentId: string
|
||||
// The backend serializes Feishu's potentially-large integer order as text.
|
||||
// Keep it as text at the API boundary so it cannot lose precision in JS.
|
||||
order: string
|
||||
memberCount: number
|
||||
}
|
||||
|
||||
export interface DirectoryOrganizationUser {
|
||||
openId: string
|
||||
userId: string
|
||||
name: string
|
||||
email: string
|
||||
mobile: string
|
||||
jobTitle: string
|
||||
employeeType: number | null
|
||||
avatarUrl: string
|
||||
employmentStatus: string
|
||||
departmentIds: string[]
|
||||
}
|
||||
|
||||
export interface DirectoryOrganization {
|
||||
snapshotState: DirectoryStatus['snapshotState']
|
||||
lastSuccessfulAt: string | null
|
||||
departments: DirectoryDepartment[]
|
||||
users: DirectoryOrganizationUser[]
|
||||
}
|
||||
|
||||
// Backend elapsed() caps collection at 300s; allow transport/commit headroom.
|
||||
export const DIRECTORY_SYNC_TIMEOUT = 360_000
|
||||
export const feishuDirectoryApi = {
|
||||
sync: (signal?: AbortSignal): Promise<DirectoryRun> =>
|
||||
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 }),
|
||||
}
|
||||