Skip to content

Commit

Permalink
feat: setup event scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 18, 2025
1 parent b5c351e commit d2a0b4d
Showing 1 changed file with 42 additions and 9 deletions.
51 changes: 42 additions & 9 deletions adapters/lark/scripts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ interface Response<T = any> {
data: T
}

export interface ApiMeta {
export const enum MetaType {
API = 1,
EVENT = 2,
}

export interface Meta {
Name: string
Project: string
Resource: string
Type: 1
Type: MetaType
Version: string
}

Expand All @@ -27,7 +32,7 @@ interface Api {
fullPath: string
id: string
isCharge: boolean
meta: ApiMeta
meta: Meta
name: string
orderMark: string
supportAppTypes: string[]
Expand All @@ -36,6 +41,22 @@ interface Api {
url: string
}

interface Event {
bizTag: string
detail: string
fullDose: boolean
fullPath: string
id: string
meta: Meta
name: string
orderMark: string
supportAppTypes: string[]
tags: string[]
updateTime: number
url: string
version: string
}

interface BizInfo {
desc: string
name: string
Expand All @@ -46,6 +67,11 @@ interface ApiList {
bizInfos: BizInfo[]
}

interface EventList {
events: Event[]
bizInfos: BizInfo[]
}

export interface Schema {
name: string
type: string
Expand Down Expand Up @@ -248,23 +274,30 @@ interface Project {

async function start() {
await mkdir(new URL('../temp/api', import.meta.url), { recursive: true })
await mkdir(new URL('../temp/event', import.meta.url), { recursive: true })
await mkdir(new URL('../src/types', import.meta.url), { recursive: true })

// https://open.feishu.cn/document/server-docs/api-call-guide/server-api-list
const data = await request<ApiList>('https://open.feishu.cn/api/tools/server-side-api/list')
data.apis = data.apis.filter(api => api.meta.Version !== 'old')
await writeFile(new URL('../temp/apis.json', import.meta.url), JSON.stringify(data))
const details = await pMap(data.apis, getDetail, {
let { apis } = await request<ApiList>('https://open.feishu.cn/api/tools/server-side-api/list')
apis = apis.filter(api => api.meta.Version !== 'old')
await writeFile(new URL('../temp/apis.json', import.meta.url), JSON.stringify(apis))
const details = await pMap(apis, getDetail, {
concurrency: 10,
})

// https://open.feishu.cn/document/server-docs/event-subscription-guide/event-list
let { events } = await request<EventList>('https://open.feishu.cn/api/tools/server-side-event/list')
events = events.filter(api => api.meta.Version !== 'old')
await writeFile(new URL('../temp/events.json', import.meta.url), JSON.stringify(events))

const projectVersions: Record<string, Set<string>> = {}
data.apis.forEach(api => {
apis.forEach(api => {
(projectVersions[api.meta.Project] ??= new Set()).add(api.meta.Version)
})
console.log(projectVersions)

details.forEach((detail, index) => {
const summary = data.apis[index]
const summary = apis[index]
const project = projects[detail.project] ||= {
methods: [],
interfaces: [],
Expand Down

0 comments on commit d2a0b4d

Please sign in to comment.