@yuhere/js-jsonrpc2 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.js +4 -4
- package/dist/cli/demo-methods.d.ts +1 -1
- package/dist/cli/demo-methods.js +1 -1
- package/dist/cli/express.js +2 -2
- package/dist/cli/stdio.js +1 -1
- package/dist/core/Repository.d.ts +2 -2
- package/dist/core/Repository.js +9 -9
- package/dist/core/convert.d.ts +2 -2
- package/dist/core/convert.js +2 -2
- package/dist/core/descriptor.d.ts +3 -3
- package/dist/core/descriptor.js +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +2 -2
- package/dist/core/permission.d.ts +2 -2
- package/dist/core/permission.js +2 -2
- package/dist/core/spec-check.d.ts +1 -1
- package/dist/core/spec-check.js +3 -3
- package/dist/core/system-methods.d.ts +1 -1
- package/dist/core/system-methods.js +4 -4
- package/dist/errors/{RpcError.d.ts → RPCError.d.ts} +1 -1
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.js +2 -2
- package/dist/index.d.ts +11 -11
- package/dist/index.js +8 -8
- package/dist/schema/json/index.d.ts +16 -16
- package/dist/schema/json/index.js +4 -4
- package/dist/schema/json/marker.d.ts +1 -1
- package/dist/schema/z/protocol.d.ts +5 -5
- package/dist/schema/z/protocol.js +1 -1
- package/dist/schema/z/register.d.ts +1 -1
- package/dist/schema/z/register.js +1 -1
- package/dist/transport/express/body.js +2 -2
- package/dist/transport/express/index.d.ts +2 -2
- package/dist/transport/express/index.js +1 -1
- package/dist/transport/express/middleware.d.ts +2 -2
- package/dist/transport/express/middleware.js +5 -5
- package/dist/transport/express/respond.d.ts +1 -1
- package/dist/transport/express/respond.js +1 -1
- package/dist/transport/stdio/index.d.ts +1 -1
- package/dist/transport/stdio/index.js +1 -1
- package/dist/transport/stdio/middleware.d.ts +2 -2
- package/dist/transport/stdio/middleware.js +4 -4
- package/dist/transport/ws/index.d.ts +2 -2
- package/dist/transport/ws/index.js +2 -2
- package/dist/transport/ws/middleware.d.ts +2 -2
- package/dist/transport/ws/middleware.js +3 -3
- package/dist/transport/ws/standalone.d.ts +1 -1
- package/dist/transport/ws/standalone.js +2 -2
- package/dist/types.d.ts +4 -4
- package/htdoc/assets/{index-CQr-lnlD.js → index-BEVUmX2-.js} +170 -20
- package/htdoc/assets/index-BEVUmX2-.js.map +1 -0
- package/htdoc/index.html +1 -1
- package/package.json +4 -3
- package/webui/src/App.tsx +30 -3
- package/webui/src/api/docGen.ts +188 -0
- package/webui/src/components/SchemaForm.tsx +0 -1
- package/webui/src/components/Toolbar.tsx +13 -1
- package/dist/schema/index.d.ts +0 -4
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/index.js +0 -4
- package/dist/schema/index.js.map +0 -1
- package/dist/schema/primitives.d.ts +0 -25
- package/dist/schema/primitives.d.ts.map +0 -1
- package/dist/schema/primitives.js +0 -153
- package/dist/schema/primitives.js.map +0 -1
- package/dist/schema/rpc.d.ts +0 -21
- package/dist/schema/rpc.d.ts.map +0 -1
- package/dist/schema/rpc.js +0 -17
- package/dist/schema/rpc.js.map +0 -1
- package/dist/stream/index.d.ts +0 -3
- package/dist/stream/index.d.ts.map +0 -1
- package/dist/stream/index.js +0 -2
- package/dist/stream/index.js.map +0 -1
- package/dist/stream/stringify.d.ts +0 -19
- package/dist/stream/stringify.d.ts.map +0 -1
- package/dist/stream/stringify.js +0 -217
- package/dist/stream/stringify.js.map +0 -1
- package/htdoc/assets/index-CQr-lnlD.js.map +0 -1
- /package/dist/errors/{RpcError.d.ts.map → RPCError.d.ts.map} +0 -0
- /package/dist/errors/{RpcError.js → RPCError.js} +0 -0
- /package/dist/errors/{RpcError.js.map → RPCError.js.map} +0 -0
package/dist/cli/cli.js
CHANGED
|
@@ -14,10 +14,10 @@ import { existsSync } from 'node:fs';
|
|
|
14
14
|
import path from 'node:path';
|
|
15
15
|
import { fileURLToPath } from 'node:url';
|
|
16
16
|
import express from 'express';
|
|
17
|
-
import { createRepository } from '../core/Repository';
|
|
18
|
-
import { installDemoMethods } from './demo-methods';
|
|
19
|
-
import { createExpressRouter } from '../transport/express';
|
|
20
|
-
import { attachWebSocket } from '../transport/ws';
|
|
17
|
+
import { createRepository } from '../core/Repository.js';
|
|
18
|
+
import { installDemoMethods } from './demo-methods.js';
|
|
19
|
+
import { createExpressRouter } from '../transport/express/index.js';
|
|
20
|
+
import { attachWebSocket } from '../transport/ws/index.js';
|
|
21
21
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
22
22
|
function htdocDir() {
|
|
23
23
|
// dist/cli.js → 包根/htdoc
|
package/dist/cli/demo-methods.js
CHANGED
package/dist/cli/express.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createServer } from 'node:http';
|
|
2
2
|
import express from 'express';
|
|
3
|
-
import { attachWebSocket, createRepository, createExpressRouter } from '
|
|
4
|
-
import { installDemoMethods } from './demo-methods';
|
|
3
|
+
import { attachWebSocket, createRepository, createExpressRouter } from '../index.js';
|
|
4
|
+
import { installDemoMethods } from './demo-methods.js';
|
|
5
5
|
const app = express();
|
|
6
6
|
const repository = createRepository({ withSystemMethods: true });
|
|
7
7
|
installDemoMethods(repository);
|
package/dist/cli/stdio.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRepository, serveStdio, s } from '
|
|
1
|
+
import { createRepository, serveStdio, s } from '../index.js';
|
|
2
2
|
const repository = createRepository();
|
|
3
3
|
repository.register({ namespace: 'echo', signature: [s.string(), s.string()] }, (v) => v);
|
|
4
4
|
await serveStdio({ repository, framing: 'lines' });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MethodDescriptor } from './descriptor';
|
|
2
|
-
import type { RPCDescriptor, RPCHandler, RPCResponse, InvokeOptions, RepositoryOptions } from '../types';
|
|
1
|
+
import type { MethodDescriptor } from './descriptor.js';
|
|
2
|
+
import type { RPCDescriptor, RPCHandler, RPCResponse, InvokeOptions, RepositoryOptions } from '../types.js';
|
|
3
3
|
export declare class Repository {
|
|
4
4
|
private readonly methods;
|
|
5
5
|
constructor(options?: RepositoryOptions);
|
package/dist/core/Repository.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { RPCError } from '../errors/RPCError';
|
|
2
|
-
import { INTERNAL_ERROR, INVALID_REQUEST } from '../errors/codes';
|
|
3
|
-
import { buildDescriptor, lookup, signatureOf } from './descriptor';
|
|
4
|
-
import { convertParams } from './convert';
|
|
5
|
-
import { checkPermission } from './permission';
|
|
6
|
-
import { validateRequest } from './spec-check';
|
|
7
|
-
import { registerSystemMethods } from './system-methods';
|
|
8
|
-
import { registerSchema } from '../schema/z/register';
|
|
9
|
-
import { RPCVersion } from "../schema/z/protocol";
|
|
1
|
+
import { RPCError } from '../errors/RPCError.js';
|
|
2
|
+
import { INTERNAL_ERROR, INVALID_REQUEST } from '../errors/codes.js';
|
|
3
|
+
import { buildDescriptor, lookup, signatureOf } from './descriptor.js';
|
|
4
|
+
import { convertParams } from './convert.js';
|
|
5
|
+
import { checkPermission } from './permission.js';
|
|
6
|
+
import { validateRequest } from './spec-check.js';
|
|
7
|
+
import { registerSystemMethods } from './system-methods.js';
|
|
8
|
+
import { registerSchema } from '../schema/z/register.js';
|
|
9
|
+
import { RPCVersion } from "../schema/z/protocol.js";
|
|
10
10
|
function formatRegisterIssues(error) {
|
|
11
11
|
return error.issues
|
|
12
12
|
.map((issue) => {
|
package/dist/core/convert.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MethodDescriptor } from './descriptor';
|
|
2
|
-
import type { Injectables } from '../types';
|
|
1
|
+
import type { MethodDescriptor } from './descriptor.js';
|
|
2
|
+
import type { Injectables } from '../types.js';
|
|
3
3
|
export declare function convertParams(descriptor: MethodDescriptor, params: unknown, injections: Injectables): Promise<unknown[]>;
|
|
4
4
|
//# sourceMappingURL=convert.d.ts.map
|
package/dist/core/convert.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RPCError } from '../errors/RPCError';
|
|
2
|
-
import { INVALID_PARAMS } from '../errors/codes';
|
|
1
|
+
import { RPCError } from '../errors/RPCError.js';
|
|
2
|
+
import { INVALID_PARAMS } from '../errors/codes.js';
|
|
3
3
|
export async function convertParams(descriptor, params, injections) {
|
|
4
4
|
let raw = params;
|
|
5
5
|
if (raw === undefined || raw === null)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RPCError } from '../errors/RPCError';
|
|
2
|
-
import { Schema } from '../schema/json';
|
|
3
|
-
import type { RPCDescriptor, RPCHandler, RPCSignature } from '../types';
|
|
1
|
+
import { RPCError } from '../errors/RPCError.js';
|
|
2
|
+
import { Schema } from '../schema/json/index.js';
|
|
3
|
+
import type { RPCDescriptor, RPCHandler, RPCSignature } from '../types.js';
|
|
4
4
|
export interface IndexedParam {
|
|
5
5
|
schema: Schema<unknown>;
|
|
6
6
|
originalIndex: number;
|
package/dist/core/descriptor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { METHOD_NOT_FOUND, INVALID_PARAMS } from '../errors/codes';
|
|
2
|
-
import { RPCError } from '../errors/RPCError';
|
|
3
|
-
import { InjectableMarker, VoidMarker, StreamMarker, Schema } from '../schema/json';
|
|
1
|
+
import { METHOD_NOT_FOUND, INVALID_PARAMS } from '../errors/codes.js';
|
|
2
|
+
import { RPCError } from '../errors/RPCError.js';
|
|
3
|
+
import { InjectableMarker, VoidMarker, StreamMarker, Schema } from '../schema/json/index.js';
|
|
4
4
|
function normalizeGrantTo(grantTo) {
|
|
5
5
|
if (grantTo === undefined)
|
|
6
6
|
return undefined;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Repository, createRepository } from './Repository';
|
|
2
|
-
export type { MethodDescriptor } from './descriptor';
|
|
3
|
-
export { validateRequest } from './spec-check';
|
|
1
|
+
export { Repository, createRepository } from './Repository.js';
|
|
2
|
+
export type { MethodDescriptor } from './descriptor.js';
|
|
3
|
+
export { validateRequest } from './spec-check.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { Repository, createRepository } from './Repository';
|
|
2
|
-
export { validateRequest } from './spec-check';
|
|
1
|
+
export { Repository, createRepository } from './Repository.js';
|
|
2
|
+
export { validateRequest } from './spec-check.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MethodDescriptor } from './descriptor';
|
|
2
|
-
import type { Injectables } from '../types';
|
|
1
|
+
import type { MethodDescriptor } from './descriptor.js';
|
|
2
|
+
import type { Injectables } from '../types.js';
|
|
3
3
|
export declare function checkPermission(descriptor: MethodDescriptor, injections: Injectables): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=permission.d.ts.map
|
package/dist/core/permission.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RPCError } from '../errors/RPCError';
|
|
2
|
-
import { PERMISSION_DENIED } from '../errors/codes';
|
|
1
|
+
import { RPCError } from '../errors/RPCError.js';
|
|
2
|
+
import { PERMISSION_DENIED } from '../errors/codes.js';
|
|
3
3
|
export async function checkPermission(descriptor, injections) {
|
|
4
4
|
const grantTo = descriptor.grantTo;
|
|
5
5
|
if (!grantTo || grantTo.length === 0)
|
package/dist/core/spec-check.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RPCRequestSchema } from '../schema/z/protocol';
|
|
2
|
-
import { RPCError } from '../errors/RPCError';
|
|
3
|
-
import { INVALID_REQUEST } from '../errors/codes';
|
|
1
|
+
import { RPCRequestSchema } from '../schema/z/protocol.js';
|
|
2
|
+
import { RPCError } from '../errors/RPCError.js';
|
|
3
|
+
import { INVALID_REQUEST } from '../errors/codes.js';
|
|
4
4
|
export function validateRequest(input) {
|
|
5
5
|
const result = RPCRequestSchema.safeParse(input);
|
|
6
6
|
if (!result.success) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/core/system-methods.ts
|
|
2
|
-
import { RPCError } from '../errors/RPCError';
|
|
3
|
-
import { METHOD_NOT_FOUND, PERMISSION_DENIED } from '../errors/codes';
|
|
4
|
-
import { checkPermission } from './permission';
|
|
5
|
-
import { s } from '../schema/json';
|
|
2
|
+
import { RPCError } from '../errors/RPCError.js';
|
|
3
|
+
import { METHOD_NOT_FOUND, PERMISSION_DENIED } from '../errors/codes.js';
|
|
4
|
+
import { checkPermission } from './permission.js';
|
|
5
|
+
import { s } from '../schema/json/index.js';
|
|
6
6
|
function notFound(namespace) {
|
|
7
7
|
return new RPCError(METHOD_NOT_FOUND, 'Method not found', `Method not found.[${namespace}]`);
|
|
8
8
|
}
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { RPCError } from './RPCError';
|
|
2
|
-
export * from './codes';
|
|
1
|
+
export { RPCError } from './RPCError.js';
|
|
2
|
+
export * from './codes.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/errors/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { RPCError } from './RPCError';
|
|
2
|
-
export * from './codes';
|
|
1
|
+
export { RPCError } from './RPCError.js';
|
|
2
|
+
export * from './codes.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Repository, createRepository } from './core/Repository';
|
|
2
|
-
import { RPCError } from './errors/RPCError';
|
|
3
|
-
import * as codes from './errors/codes';
|
|
4
|
-
import { s } from './schema/json';
|
|
1
|
+
import { Repository, createRepository } from './core/Repository.js';
|
|
2
|
+
import { RPCError } from './errors/RPCError.js';
|
|
3
|
+
import * as codes from './errors/codes.js';
|
|
4
|
+
import { s } from './schema/json/index.js';
|
|
5
5
|
export { Repository, createRepository };
|
|
6
6
|
export { RPCError };
|
|
7
7
|
export { codes };
|
|
8
8
|
export { s };
|
|
9
|
-
export * from './types';
|
|
10
|
-
import { createExpressRouter } from './transport/express';
|
|
9
|
+
export * from './types.js';
|
|
10
|
+
import { createExpressRouter } from './transport/express/index.js';
|
|
11
11
|
export { createExpressRouter };
|
|
12
|
-
import { attachWebSocket, createWebSocketServer } from './transport/ws';
|
|
13
|
-
import { serveStdio } from './transport/stdio';
|
|
12
|
+
import { attachWebSocket, createWebSocketServer } from './transport/ws/index.js';
|
|
13
|
+
import { serveStdio } from './transport/stdio/index.js';
|
|
14
14
|
export { attachWebSocket, createWebSocketServer, serveStdio };
|
|
15
|
-
export type { WSOptions, StandaloneWsOptions, StandaloneWsHandle } from './transport/ws';
|
|
16
|
-
export type { StdioOptions } from './transport/stdio';
|
|
17
|
-
export type { ExpressOptions } from './transport/express';
|
|
15
|
+
export type { WSOptions, StandaloneWsOptions, StandaloneWsHandle } from './transport/ws/index.js';
|
|
16
|
+
export type { StdioOptions } from './transport/stdio/index.js';
|
|
17
|
+
export type { ExpressOptions } from './transport/express/index.js';
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Repository, createRepository } from './core/Repository';
|
|
2
|
-
import { RPCError } from './errors/RPCError';
|
|
3
|
-
import * as codes from './errors/codes';
|
|
4
|
-
import { s } from './schema/json';
|
|
1
|
+
import { Repository, createRepository } from './core/Repository.js';
|
|
2
|
+
import { RPCError } from './errors/RPCError.js';
|
|
3
|
+
import * as codes from './errors/codes.js';
|
|
4
|
+
import { s } from './schema/json/index.js';
|
|
5
5
|
export { Repository, createRepository };
|
|
6
6
|
export { RPCError };
|
|
7
7
|
export { codes };
|
|
8
8
|
export { s };
|
|
9
|
-
export * from './types';
|
|
9
|
+
export * from './types.js';
|
|
10
10
|
// ################
|
|
11
|
-
import { createExpressRouter } from './transport/express';
|
|
11
|
+
import { createExpressRouter } from './transport/express/index.js';
|
|
12
12
|
export { createExpressRouter };
|
|
13
13
|
// ################
|
|
14
|
-
import { attachWebSocket, createWebSocketServer } from './transport/ws';
|
|
15
|
-
import { serveStdio } from './transport/stdio';
|
|
14
|
+
import { attachWebSocket, createWebSocketServer } from './transport/ws/index.js';
|
|
15
|
+
import { serveStdio } from './transport/stdio/index.js';
|
|
16
16
|
export { attachWebSocket, createWebSocketServer, serveStdio };
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export * from "./primitives";
|
|
2
|
-
export * from "./marker";
|
|
1
|
+
export * from "./primitives.js";
|
|
2
|
+
export * from "./marker.js";
|
|
3
3
|
export declare const s: {
|
|
4
|
-
string: () => import("./primitives").StringSchema<"string">;
|
|
5
|
-
number: () => import("./primitives").NumberSchema;
|
|
6
|
-
boolean: () => import("./primitives").BooleanSchema;
|
|
7
|
-
literal: <const T extends import("./primitives").LiteralValue>(value: T) => import("./primitives").LiteralSchema<T>;
|
|
8
|
-
array: <T>(item: import("./primitives").Schema<T>) => import("./primitives").ArraySchema<T>;
|
|
9
|
-
object: <S extends import("./primitives").ObjectShape>(shape: S) => import("./primitives").ObjectSchema<S, false>;
|
|
10
|
-
record: <T>(value: import("./primitives").Schema<T>) => import("./primitives").RecordSchema<T>;
|
|
11
|
-
union: <const S extends readonly [import("./primitives").Schema<unknown>, ...import("./primitives").Schema<unknown>[]]>(schemas: S) => import("./primitives").UnionSchema<S>;
|
|
12
|
-
tuple: <const S extends readonly [import("./primitives").Schema<unknown>, ...import("./primitives").Schema<unknown>[]]>(schemas: S) => import("./primitives").TupleSchema<S>;
|
|
13
|
-
enum: <const T extends readonly [string, ...string[]]>(values: T) => import("./primitives").EnumSchema<T>;
|
|
14
|
-
unknown: () => import("./primitives").UnknownSchema;
|
|
15
|
-
void: () => import("./marker").VoidMarker;
|
|
16
|
-
injectable: <const K extends string>(key: K) => import("./marker").InjectableMarker<K>;
|
|
17
|
-
stream: <T>(inner: import("./primitives").Schema<T>) => import("./marker").StreamMarker<T>;
|
|
4
|
+
string: () => import("./primitives.js").StringSchema<"string">;
|
|
5
|
+
number: () => import("./primitives.js").NumberSchema;
|
|
6
|
+
boolean: () => import("./primitives.js").BooleanSchema;
|
|
7
|
+
literal: <const T extends import("./primitives.js").LiteralValue>(value: T) => import("./primitives.js").LiteralSchema<T>;
|
|
8
|
+
array: <T>(item: import("./primitives.js").Schema<T>) => import("./primitives.js").ArraySchema<T>;
|
|
9
|
+
object: <S extends import("./primitives.js").ObjectShape>(shape: S) => import("./primitives.js").ObjectSchema<S, false>;
|
|
10
|
+
record: <T>(value: import("./primitives.js").Schema<T>) => import("./primitives.js").RecordSchema<T>;
|
|
11
|
+
union: <const S extends readonly [import("./primitives.js").Schema<unknown>, ...import("./primitives.js").Schema<unknown>[]]>(schemas: S) => import("./primitives.js").UnionSchema<S>;
|
|
12
|
+
tuple: <const S extends readonly [import("./primitives.js").Schema<unknown>, ...import("./primitives.js").Schema<unknown>[]]>(schemas: S) => import("./primitives.js").TupleSchema<S>;
|
|
13
|
+
enum: <const T extends readonly [string, ...string[]]>(values: T) => import("./primitives.js").EnumSchema<T>;
|
|
14
|
+
unknown: () => import("./primitives.js").UnknownSchema;
|
|
15
|
+
void: () => import("./marker.js").VoidMarker;
|
|
16
|
+
injectable: <const K extends string>(key: K) => import("./marker.js").InjectableMarker<K>;
|
|
17
|
+
stream: <T>(inner: import("./primitives.js").Schema<T>) => import("./marker.js").StreamMarker<T>;
|
|
18
18
|
};
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { primitives } from "./primitives";
|
|
2
|
-
import { markers } from "./marker";
|
|
3
|
-
export * from "./primitives";
|
|
4
|
-
export * from "./marker";
|
|
1
|
+
import { primitives } from "./primitives.js";
|
|
2
|
+
import { markers } from "./marker.js";
|
|
3
|
+
export * from "./primitives.js";
|
|
4
|
+
export * from "./marker.js";
|
|
5
5
|
export const s = { ...primitives, ...markers };
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare const RPCVersion = "2.0";
|
|
2
2
|
export type RPCVersion = '2.0';
|
|
3
|
-
export declare const RPCRequestSchema: import("../json").ObjectSchema<{
|
|
4
|
-
jsonrpc: import("../json").LiteralSchema<"2.0">;
|
|
5
|
-
method: import("../json").StringSchema<"string">;
|
|
6
|
-
params: import("../json").NullableSchema<import("../json").JSONValue[]>;
|
|
7
|
-
id: import("../json").UnionSchema<readonly [import("../json").StringSchema<"string">, import("../json").NumberSchema]>;
|
|
3
|
+
export declare const RPCRequestSchema: import("../json/index.js").ObjectSchema<{
|
|
4
|
+
jsonrpc: import("../json/index.js").LiteralSchema<"2.0">;
|
|
5
|
+
method: import("../json/index.js").StringSchema<"string">;
|
|
6
|
+
params: import("../json/index.js").NullableSchema<import("../json/index.js").JSONValue[]>;
|
|
7
|
+
id: import("../json/index.js").UnionSchema<readonly [import("../json/index.js").StringSchema<"string">, import("../json/index.js").NumberSchema]>;
|
|
8
8
|
}, true>;
|
|
9
9
|
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { Schema, VoidMarker, InjectableMarker, StreamMarker } from "../json";
|
|
2
|
+
import { Schema, VoidMarker, InjectableMarker, StreamMarker } from "../json/index.js";
|
|
3
3
|
export declare const registerSchema: z.ZodTuple<[z.ZodObject<{
|
|
4
4
|
namespace: z.ZodString;
|
|
5
5
|
document: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { Schema, VoidMarker, InjectableMarker, StreamMarker, } from "../json";
|
|
2
|
+
import { Schema, VoidMarker, InjectableMarker, StreamMarker, } from "../json/index.js";
|
|
3
3
|
const schemaInstance = z.instanceof(Schema);
|
|
4
4
|
const voidMarker = z.instanceof(VoidMarker);
|
|
5
5
|
const injectableMarker = z.instanceof(InjectableMarker);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import bodyParser from 'body-parser';
|
|
2
|
-
import { RPCError } from '../../errors/RPCError';
|
|
3
|
-
import { PARSE_ERROR } from '../../errors/codes';
|
|
2
|
+
import { RPCError } from '../../errors/RPCError.js';
|
|
3
|
+
import { PARSE_ERROR } from '../../errors/codes.js';
|
|
4
4
|
export function createJsonParser(options = {}) {
|
|
5
5
|
return bodyParser.json({
|
|
6
6
|
limit: options.limit ?? '1mb',
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createExpressRouter } from './middleware';
|
|
2
|
-
export type { ExpressOptions } from './middleware';
|
|
1
|
+
export { createExpressRouter } from './middleware.js';
|
|
2
|
+
export type { ExpressOptions } from './middleware.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createExpressRouter } from './middleware';
|
|
1
|
+
export { createExpressRouter } from './middleware.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Router } from 'express';
|
|
2
|
-
import { Repository } from '../../core/Repository';
|
|
3
|
-
import type { InjectableFactory, RPCResponse, RPCErrorTransform } from '../../types';
|
|
2
|
+
import { Repository } from '../../core/Repository.js';
|
|
3
|
+
import type { InjectableFactory, RPCResponse, RPCErrorTransform } from '../../types.js';
|
|
4
4
|
export interface ExpressOptions {
|
|
5
5
|
mkInjectable?: InjectableFactory;
|
|
6
6
|
errorTransform?: RPCErrorTransform;
|
|
@@ -2,11 +2,11 @@ import path from 'node:path';
|
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import express from 'express';
|
|
4
4
|
import typeIs from 'type-is';
|
|
5
|
-
import { RPCError } from '../../errors/RPCError';
|
|
6
|
-
import { INTERNAL_ERROR } from '../../errors/codes';
|
|
7
|
-
import { createJsonParser, readJson } from './body';
|
|
8
|
-
import { respond } from './respond';
|
|
9
|
-
import { RPCVersion } from "../../schema/z/protocol";
|
|
5
|
+
import { RPCError } from '../../errors/RPCError.js';
|
|
6
|
+
import { INTERNAL_ERROR } from '../../errors/codes.js';
|
|
7
|
+
import { createJsonParser, readJson } from './body.js';
|
|
8
|
+
import { respond } from './respond.js';
|
|
9
|
+
import { RPCVersion } from "../../schema/z/protocol.js";
|
|
10
10
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
11
11
|
const defaultStaticDir = path.resolve(here, '..', '..', '..', 'htdoc');
|
|
12
12
|
export function createExpressRouter(repository, { mkInjectable = undefined, errorTransform = undefined, bodyLimit = '1mb', useHtdoc = process.env['NODE_ENV'] !== 'production', } = {}) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Response } from 'express';
|
|
2
|
-
import type { RPCResponse } from '../../types';
|
|
2
|
+
import type { RPCResponse } from '../../types.js';
|
|
3
3
|
export declare function respond(res: Response, payload: RPCResponse | undefined): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=respond.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { serveStdio, type StdioOptions } from './middleware';
|
|
1
|
+
export { serveStdio, type StdioOptions } from './middleware.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { serveStdio } from './middleware';
|
|
1
|
+
export { serveStdio } from './middleware.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Readable, Writable } from 'node:stream';
|
|
2
|
-
import { Repository } from '../../core/Repository';
|
|
3
|
-
import type { InjectableFactory, RPCErrorTransform, RPCResponse } from '../../types';
|
|
2
|
+
import { Repository } from '../../core/Repository.js';
|
|
3
|
+
import type { InjectableFactory, RPCErrorTransform, RPCResponse } from '../../types.js';
|
|
4
4
|
export interface StdioOptions {
|
|
5
5
|
repository?: Repository;
|
|
6
6
|
/** Input stream (default: `process.stdin`). */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StringDecoder } from 'node:string_decoder';
|
|
2
|
-
import { Repository } from '../../core/Repository';
|
|
3
|
-
import { INTERNAL_ERROR, PARSE_ERROR } from '../../errors/codes';
|
|
4
|
-
import { RPCVersion } from '../../schema/z/protocol';
|
|
5
|
-
import { stringify } from '../../stream/stringify-stream';
|
|
2
|
+
import { Repository } from '../../core/Repository.js';
|
|
3
|
+
import { INTERNAL_ERROR, PARSE_ERROR } from '../../errors/codes.js';
|
|
4
|
+
import { RPCVersion } from '../../schema/z/protocol.js';
|
|
5
|
+
import { stringify } from '../../stream/stringify-stream.js';
|
|
6
6
|
function isStreamSuccess(payload) {
|
|
7
7
|
return (!!payload &&
|
|
8
8
|
typeof payload === 'object' &&
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { attachWebSocket, type WSOptions } from './middleware';
|
|
2
|
-
export { createWebSocketServer, type StandaloneWsOptions, type StandaloneWsHandle, } from './standalone';
|
|
1
|
+
export { attachWebSocket, type WSOptions } from './middleware.js';
|
|
2
|
+
export { createWebSocketServer, type StandaloneWsOptions, type StandaloneWsHandle, } from './standalone.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { attachWebSocket } from './middleware';
|
|
2
|
-
export { createWebSocketServer, } from './standalone';
|
|
1
|
+
export { attachWebSocket } from './middleware.js';
|
|
2
|
+
export { createWebSocketServer, } from './standalone.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IncomingMessage, Server } from 'node:http';
|
|
2
2
|
import { WebSocketServer, WebSocket } from 'ws';
|
|
3
|
-
import { Repository } from '../../core/Repository';
|
|
4
|
-
import type { InjectableFactory, RPCErrorTransform } from '../../types';
|
|
3
|
+
import { Repository } from '../../core/Repository.js';
|
|
4
|
+
import type { InjectableFactory, RPCErrorTransform } from '../../types.js';
|
|
5
5
|
export interface WSOptions {
|
|
6
6
|
/** Build injectables for a WS connection. */
|
|
7
7
|
mkInjectable?: InjectableFactory;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WebSocketServer, WebSocket } from 'ws';
|
|
2
|
-
import { INTERNAL_ERROR, PARSE_ERROR } from '../../errors/codes';
|
|
3
|
-
import { stringify } from "../../stream/stringify-stream";
|
|
4
|
-
import { RPCVersion } from '../../schema/z/protocol';
|
|
2
|
+
import { INTERNAL_ERROR, PARSE_ERROR } from '../../errors/codes.js';
|
|
3
|
+
import { stringify } from "../../stream/stringify-stream.js";
|
|
4
|
+
import { RPCVersion } from '../../schema/z/protocol.js';
|
|
5
5
|
function isStreamSuccess(payload) {
|
|
6
6
|
return (!!payload &&
|
|
7
7
|
typeof payload === 'object' &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Server } from 'node:http';
|
|
2
2
|
import { WebSocketServer } from 'ws';
|
|
3
|
-
import { type WSOptions } from './middleware';
|
|
3
|
+
import { type WSOptions } from './middleware.js';
|
|
4
4
|
export interface StandaloneWsOptions extends WSOptions {
|
|
5
5
|
/** Existing HTTP server to attach to. If omitted, one is created. */
|
|
6
6
|
server?: Server;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createServer } from 'node:http';
|
|
2
|
-
import { Repository } from '../../core/Repository';
|
|
3
|
-
import { attachWebSocket } from './middleware';
|
|
2
|
+
import { Repository } from '../../core/Repository.js';
|
|
3
|
+
import { attachWebSocket } from './middleware.js';
|
|
4
4
|
/**
|
|
5
5
|
* Create a standalone HTTP server (unless one is provided) and attach the
|
|
6
6
|
* JSON-RPC WebSocket endpoint. Returns a handle for clean shutdown.
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RPCError } from './errors/RPCError';
|
|
2
|
-
import * as s from "./schema/json";
|
|
3
|
-
import type { RPCVersion } from "./schema/z/protocol";
|
|
1
|
+
import { RPCError } from './errors/RPCError.js';
|
|
2
|
+
import * as s from "./schema/json/index.js";
|
|
3
|
+
import type { RPCVersion } from "./schema/z/protocol.js";
|
|
4
4
|
export type RPCReturnSlot = s.Schema<unknown> | s.VoidMarker | s.StreamMarker<unknown>;
|
|
5
5
|
export type RPCParamSlot = s.Schema<unknown> | s.InjectableMarker;
|
|
6
6
|
export type RPCSignature = [RPCReturnSlot, ...RPCParamSlot[]];
|
|
@@ -11,7 +11,7 @@ export type RPCDescriptor = {
|
|
|
11
11
|
grantTo?: string[];
|
|
12
12
|
signature: RPCSignature;
|
|
13
13
|
};
|
|
14
|
-
import { Repository } from "./core/Repository";
|
|
14
|
+
import { Repository } from "./core/Repository.js";
|
|
15
15
|
export type RPCHandler = (...args: any[]) => unknown;
|
|
16
16
|
export type RPCRegisterArgs = [RPCDescriptor, RPCHandler];
|
|
17
17
|
export type RPCReqId = string | number;
|