-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,044 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
!packages/design/.storybook | ||
!packages/design/.storybook | ||
packages/types/types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Update Type Definition | ||
on: | ||
repository_dispatch: | ||
types: [update-types] | ||
jobs: | ||
update-types: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: pnpm/[email protected] | ||
with: | ||
version: "6" | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "16.x" | ||
cache: "pnpm" | ||
|
||
- name: Install Dependencies | ||
run: pnpm install | ||
|
||
- name: Build Type Definition | ||
run: pnpm build:types | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
title: Update Type Definition from bangumi/dev-docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { components } from './types' | ||
|
||
export type Avatar = components['schemas']['Avatar'] | ||
export type Topic = components['schemas']['Topic'] | ||
export type Pagination = Omit<components['schemas']['Paged'], 'data'> | ||
|
||
export interface ResponseWithPagination<T = unknown> extends Pagination { | ||
data: T | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { components } from './types' | ||
|
||
export * from './common' | ||
|
||
export type Group = components['schemas']['Group'] | ||
export type GroupProfile = components['schemas']['GroupProfile'] | ||
export type GroupMember = components['schemas']['GroupMember'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "@bangumi/types", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"private": true, | ||
"scripts": { | ||
"build": "node scripts/build.js" | ||
}, | ||
"devDependencies": { | ||
"js-yaml": "^4.1.0", | ||
"node-fetch": "^3.2.10", | ||
"openapi-typescript": "^5.4.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import path from 'path' | ||
import { fileURLToPath } from 'url' | ||
import { promises as fs } from 'fs' | ||
import openapiTS from 'openapi-typescript' | ||
import fetch from 'node-fetch' | ||
import yaml from 'js-yaml' | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
|
||
const openapiURL = process.env.OPENAPI_URL || 'https://bangumi.github.io/dev-docs/api.yaml' | ||
|
||
async function fetchSchema (url) { | ||
const res = await fetch(url) | ||
const text = await res.text() | ||
return yaml.load(text) | ||
} | ||
const schema = await fetchSchema(openapiURL) | ||
|
||
const data = await openapiTS(schema) | ||
|
||
await fs.writeFile(path.resolve(__dirname, '../types/index.ts'), data) |
Oops, something went wrong.