-
Notifications
You must be signed in to change notification settings - Fork 3
[migrate] upgrade to MobX-Lark 2.8.1, Open-Source-Bazaar/feishu-action@v3 & Vercel CLI 50.x #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,6 @@ | ||
| import { Context } from 'koa'; | ||
| import { LarkPageData, TableRecord, TableRecordData } from 'mobx-lark'; | ||
| import { DataObject } from 'mobx-restful'; | ||
| import { createKoaRouter, withKoaRouter } from 'next-ssr-middleware'; | ||
|
|
||
| import { safeAPI } from '../../../core'; | ||
| import { proxyLark, proxyLarkAll } from '../../core'; | ||
| import { withSafeKoa } from '../../../core'; | ||
| import { proxyLarkAll } from '../../core'; | ||
|
|
||
| export const config = { api: { bodyParser: false } }; | ||
|
|
||
| const router = createKoaRouter(import.meta.url); | ||
|
|
||
| function filterData(fields: DataObject) { | ||
| for (const key of Object.keys(fields)) | ||
| if (!/^\w+$/.test(key)) delete fields[key]; | ||
| } | ||
|
|
||
| router.get( | ||
| '/apps/:app/tables/:table/records/:record', | ||
| safeAPI, | ||
| async (context: Context) => { | ||
| const { status, body } = | ||
| await proxyLark<TableRecordData<DataObject>>(context); | ||
|
|
||
| const { fields } = body!.data!.record; | ||
|
|
||
| filterData(fields); | ||
|
|
||
| context.status = status; | ||
| context.body = body; | ||
| }, | ||
| ); | ||
|
|
||
| router.get( | ||
| '/apps/:app/tables/:table/records', | ||
| safeAPI, | ||
| async (context: Context) => { | ||
| const { status, body } = | ||
| await proxyLark<LarkPageData<TableRecord<DataObject>>>(context); | ||
|
|
||
| const list = body!.data!.items || []; | ||
|
|
||
| for (const { fields } of list) filterData(fields); | ||
|
|
||
| context.status = status; | ||
| context.body = body; | ||
| }, | ||
| ); | ||
|
|
||
| router.all('/(.*)', safeAPI, proxyLarkAll); | ||
|
|
||
| export default withKoaRouter(router); | ||
| export default withSafeKoa(proxyLarkAll); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -18,7 +18,7 @@ export const normalizeMarkdownArray = (list: TableCellText[]) => | |||||
| export const proxyLark = async <T extends LarkData>({ | ||||||
| method, | ||||||
| url, | ||||||
| headers: { host, authorization, ...headers }, | ||||||
| headers: { host, authorization, 'content-length': _, ...headers }, | ||||||
|
||||||
| headers: { host, authorization, 'content-length': _, ...headers }, | |
| headers: { host, authorization, 'content-length': _contentLength, ...headers }, |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import { Context } from 'koa'; | ||
| import { LarkDocumentPathType } from 'mobx-lark'; | ||
| import { createKoaRouter, withKoaRouter } from 'next-ssr-middleware'; | ||
|
|
||
| import { safeAPI, verifyJWT } from '../../../core'; | ||
|
|
@@ -10,13 +11,33 @@ const router = createKoaRouter(import.meta.url); | |
|
|
||
| router.post('/:type/:id', safeAPI, verifyJWT, async (context: Context) => { | ||
| const { type, id } = context.params, | ||
| { name, parentToken } = Reflect.get(context.request, 'body'); | ||
| { name, parentToken, ownerType, ownerId } = Reflect.get( | ||
| context.request, | ||
| 'body', | ||
| ); | ||
|
|
||
| context.body = await lark.copyFile( | ||
| `${type as 'wiki'}/${id}`, | ||
| name, | ||
| parentToken, | ||
| ); | ||
| const copiedFile = | ||
| type === 'wiki' | ||
| ? await lark.copyFile(`${type as 'wiki'}/${id}`, name, parentToken) | ||
| : await lark.copyFile( | ||
| `${type as LarkDocumentPathType}/${id}`, | ||
| name, | ||
| parentToken, | ||
| ); | ||
|
Comment on lines
+19
to
+26
|
||
|
|
||
| const newId = | ||
| 'token' in copiedFile ? copiedFile.token : copiedFile.node_token; | ||
|
|
||
| if (ownerType && ownerId) | ||
| try { | ||
| await lark.driveFileStore.transferOwner(type, newId, { | ||
| member_type: ownerType, | ||
| member_id: ownerId, | ||
| }); | ||
|
Comment on lines
+31
to
+36
|
||
| } catch (error) { | ||
| console.error(JSON.stringify(error, null, 2)); | ||
| } | ||
| context.body = copiedFile; | ||
|
Comment on lines
+31
to
+40
|
||
| }); | ||
|
|
||
| export default withKoaRouter(router); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Vercel deploy step checks for
VERCEL_ORG_ID/VERCEL_PROJECT_ID, but the script never uses them (and there is no.vercel/project linkage in the repo). In CI,vercelcommonly prompts to link/select a project unless--yes/--confirmand project/scope options are provided, which can hang the job. Please pass the org/project explicitly (or commit a.vercel/project.json), and add non-interactive flags so the deployment is deterministic.