diff --git a/package.json b/package.json index 6fd0dfe..784fece 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/rpc-protocol/package.json b/packages/rpc-protocol/package.json new file mode 100644 index 0000000..280f490 --- /dev/null +++ b/packages/rpc-protocol/package.json @@ -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 (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" + } +} diff --git a/packages/rpc-protocol/src/index.ts b/packages/rpc-protocol/src/index.ts new file mode 100644 index 0000000..5159f08 --- /dev/null +++ b/packages/rpc-protocol/src/index.ts @@ -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 +} diff --git a/packages/rpc-protocol/tsconfig.json b/packages/rpc-protocol/tsconfig.json new file mode 100644 index 0000000..551ed97 --- /dev/null +++ b/packages/rpc-protocol/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ES2022", + "moduleResolution": "Bundler" + }, + "include": ["src"] +} diff --git a/packages/rpc-protocol/tsup.config.ts b/packages/rpc-protocol/tsup.config.ts new file mode 100644 index 0000000..31fd75b --- /dev/null +++ b/packages/rpc-protocol/tsup.config.ts @@ -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'], +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 04bd2ab..3f6fccd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -138,6 +138,25 @@ importers: specifier: ^8.3.0 version: 8.3.0(@swc/core@1.7.39(@swc/helpers@0.5.13))(jiti@2.3.3)(postcss@8.4.47)(tsx@4.19.1)(typescript@5.6.3)(yaml@2.6.0) + packages/rpc-protocol: + dependencies: + '@nailyjs/rpc': + specifier: workspace:* + version: link:../rpc + '@types/json-schema': + specifier: ^7.0.15 + version: 7.0.15 + json-schema: + specifier: ^0.4.0 + version: 0.4.0 + zod: + specifier: ^3.23.8 + version: 3.23.8 + devDependencies: + tsup: + specifier: ^8.3.0 + version: 8.3.0(@swc/core@1.7.39(@swc/helpers@0.5.13))(jiti@2.3.3)(postcss@8.4.47)(tsx@4.19.1)(typescript@5.6.3)(yaml@2.6.0) + packages/unplugin-rpc: dependencies: '@farmfe/core': @@ -1577,7 +1596,7 @@ packages: '@vitest/eslint-plugin@1.1.7': resolution: {integrity: sha512-pTWGW3y6lH2ukCuuffpan6kFxG6nIuoesbhMiQxskyQMRcCN5t9SXsKrNHvEw3p8wcCsgJoRqFZVkOTn6TjclA==} peerDependencies: - '@typescript-eslint/utils': ^8.2.0 + '@typescript-eslint/utils': '>= 8.0' eslint: '>= 8.57.0' typescript: '>= 5.0.0' vitest: '*' @@ -3448,6 +3467,9 @@ packages: json-schema-traverse@0.4.1: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} + json-schema@0.4.0: + resolution: {integrity: sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==} + json-stable-stringify-without-jsonify@1.0.1: resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} @@ -9186,6 +9208,8 @@ snapshots: json-schema-traverse@0.4.1: {} + json-schema@0.4.0: {} + json-stable-stringify-without-jsonify@1.0.1: {} json5@2.2.3: {}