Skip to content

Commit

Permalink
feat: add a protocol for generate docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nailiable committed Oct 26, 2024
1 parent 89bc4be commit 7881947
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"build:ioc": "pnpm -F @nailyjs/ioc build",
"build:backend": "pnpm -F @nailyjs/backend build",
"build:rpc": "pnpm -F @nailyjs/rpc build",
"build:rpc-docs-protocol": "pnpm -F @nailyjs/rpc-docs-protocol build",
"build:unplugin-rpc": "pnpm -F unplugin-rpc build",
"play:rpc": "pnpm -F rpc-playground dev",
"play:build": "pnpm -F rpc-playground build",
Expand Down
38 changes: 38 additions & 0 deletions packages/rpc-protocol/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@nailyjs/rpc-docs-protocol",
"type": "module",
"version": "1.0.14",
"description": "Json-RPC 2.0 protocol docs implementation.",
"author": "Naily Zero <[email protected]> (https://naily.cc)",
"keywords": [
"json-rpc",
"rpc",
"naily"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsup",
"watch": "tsup -w"
},
"dependencies": {
"@nailyjs/rpc": "workspace:*",
"@types/json-schema": "^7.0.15",
"json-schema": "^0.4.0",
"zod": "^3.23.8"
},
"devDependencies": {
"tsup": "^8.3.0"
}
}
27 changes: 27 additions & 0 deletions packages/rpc-protocol/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { JSONSchema7 as JSONSchema } from 'json-schema'

export interface JsonRpcParamsObject {
description?: string
name?: string
required?: boolean
schema?: JSONSchema
}

export interface JsonRpcResultObject {
description?: string
schema?: JSONSchema
}

export interface JsonRpcDocsObject {
description?: string
summary?: string
tags?: string[]
params: JsonRpcParamsObject[]
result?: JsonRpcResultObject
}

export interface JsonRpcDoc {
jsonrpc: '2.0'
tags: string[]
docs: Record<string, JsonRpcDocsObject>
}
8 changes: 8 additions & 0 deletions packages/rpc-protocol/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "Bundler"
},
"include": ["src"]
}
11 changes: 11 additions & 0 deletions packages/rpc-protocol/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'tsup'

export default defineConfig({
entry: {
index: './src/index.ts',
},
dts: true,
sourcemap: true,
clean: true,
format: ['cjs', 'esm'],
})
26 changes: 25 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7881947

Please sign in to comment.