@lspeasy/server 1.0.1
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/LICENSE +21 -0
- package/README.md +218 -0
- package/dist/capability-guard.d.ts +56 -0
- package/dist/capability-guard.d.ts.map +1 -0
- package/dist/capability-guard.js +212 -0
- package/dist/capability-guard.js.map +1 -0
- package/dist/capability-proxy.d.ts +19 -0
- package/dist/capability-proxy.d.ts.map +1 -0
- package/dist/capability-proxy.js +121 -0
- package/dist/capability-proxy.js.map +1 -0
- package/dist/dispatcher.d.ts +52 -0
- package/dist/dispatcher.d.ts.map +1 -0
- package/dist/dispatcher.js +174 -0
- package/dist/dispatcher.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle.d.ts +39 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +66 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/progress.d.ts +40 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +50 -0
- package/dist/progress.js.map +1 -0
- package/dist/server.d.ts +176 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +530 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +114 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +24 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +59 -0
- package/dist/validation.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,MAAM,EACN,kBAAkB,EAElB,QAAQ,EACR,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EACjB,MAAM,eAAe,CA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AG,SAAS,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,CAC/D,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,cAAc,KACpB,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,MAAM,GAAG,OAAO,IAAI,CAClD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,mBAAmB,KACzB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAC7D,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,YAAY,kBAAkB;IAC9B,QAAQ,aAAa;CACtB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for @lspeasy/server
|
|
3
|
+
*/
|
|
4
|
+
export { ServerState };
|
|
5
|
+
/**
|
|
6
|
+
* Server state enum
|
|
7
|
+
*/
|
|
8
|
+
var ServerState;
|
|
9
|
+
(function (ServerState) {
|
|
10
|
+
ServerState["Created"] = "created";
|
|
11
|
+
ServerState["Initializing"] = "initializing";
|
|
12
|
+
ServerState["Initialized"] = "initialized";
|
|
13
|
+
ServerState["ShuttingDown"] = "shutting_down";
|
|
14
|
+
ServerState["Shutdown"] = "shutdown";
|
|
15
|
+
})(ServerState || (ServerState = {}));
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;SAkJS,WAAW;AAHvB;;GAEG;AACH,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,4CAA6B,CAAA;IAC7B,0CAA2B,CAAA;IAC3B,6CAA8B,CAAA;IAC9B,oCAAqB,CAAA;AAAA,CACvB,EANY,WAAW,KAAX,WAAW,QAMtB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameter validation using Zod schemas
|
|
3
|
+
*/
|
|
4
|
+
import { z, ZodError } from 'zod';
|
|
5
|
+
import type { RequestContext, NotificationContext } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Schema registry for LSP methods
|
|
8
|
+
* Now using schemas from @lspeasy/core
|
|
9
|
+
*/
|
|
10
|
+
export declare const methodSchemas: Record<string, z.ZodSchema | undefined>;
|
|
11
|
+
/**
|
|
12
|
+
* Validate request parameters
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Validate request/notification parameters
|
|
16
|
+
* @param method - The LSP method name
|
|
17
|
+
* @param params - The parameters to validate
|
|
18
|
+
* @param context - The request/notification context (optional for validation-only calls)
|
|
19
|
+
* @param onValidationError - Optional custom validation error handler
|
|
20
|
+
* @returns Validated parameters
|
|
21
|
+
* @throws ResponseError if validation fails
|
|
22
|
+
*/
|
|
23
|
+
export declare function validateParams(method: string, params: unknown, context?: RequestContext | NotificationContext, onValidationError?: (error: ZodError, context: RequestContext | NotificationContext) => any): unknown;
|
|
24
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAElC,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAkBtE;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,GAAG,SAAS,CAUjE,CAAC;AAEF;;GAEG;AACH;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,cAAc,GAAG,mBAAmB,EAC9C,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,GAAG,mBAAmB,KAAK,GAAG,GAC1F,OAAO,CAyBT"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameter validation using Zod schemas
|
|
3
|
+
*/
|
|
4
|
+
import { z, ZodError } from 'zod';
|
|
5
|
+
import { ResponseError } from '@lspeasy/core';
|
|
6
|
+
/**
|
|
7
|
+
* Zod schemas imported from @lspeasy/core
|
|
8
|
+
* These are comprehensive LSP protocol schemas
|
|
9
|
+
*/
|
|
10
|
+
import { HoverParamsSchema as hoverParamsSchema, CompletionParamsSchema as completionParamsSchema, DefinitionParamsSchema as definitionParamsSchema, ReferenceParamsSchema as referenceParamsSchema, DocumentSymbolParamsSchema as documentSymbolParamsSchema, InitializeParamsSchema as initializeParamsSchema, DidOpenTextDocumentParamsSchema as didOpenTextDocumentParamsSchema, DidChangeTextDocumentParamsSchema as didChangeTextDocumentParamsSchema, DidCloseTextDocumentParamsSchema as didCloseTextDocumentParamsSchema } from '@lspeasy/core';
|
|
11
|
+
/**
|
|
12
|
+
* Schema registry for LSP methods
|
|
13
|
+
* Now using schemas from @lspeasy/core
|
|
14
|
+
*/
|
|
15
|
+
export const methodSchemas = {
|
|
16
|
+
initialize: initializeParamsSchema,
|
|
17
|
+
'textDocument/hover': hoverParamsSchema,
|
|
18
|
+
'textDocument/completion': completionParamsSchema,
|
|
19
|
+
'textDocument/definition': definitionParamsSchema,
|
|
20
|
+
'textDocument/references': referenceParamsSchema,
|
|
21
|
+
'textDocument/documentSymbol': documentSymbolParamsSchema,
|
|
22
|
+
'textDocument/didOpen': didOpenTextDocumentParamsSchema,
|
|
23
|
+
'textDocument/didChange': didChangeTextDocumentParamsSchema,
|
|
24
|
+
'textDocument/didClose': didCloseTextDocumentParamsSchema
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Validate request parameters
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Validate request/notification parameters
|
|
31
|
+
* @param method - The LSP method name
|
|
32
|
+
* @param params - The parameters to validate
|
|
33
|
+
* @param context - The request/notification context (optional for validation-only calls)
|
|
34
|
+
* @param onValidationError - Optional custom validation error handler
|
|
35
|
+
* @returns Validated parameters
|
|
36
|
+
* @throws ResponseError if validation fails
|
|
37
|
+
*/
|
|
38
|
+
export function validateParams(method, params, context, onValidationError) {
|
|
39
|
+
const schema = methodSchemas[method];
|
|
40
|
+
if (!schema) {
|
|
41
|
+
// No schema defined, skip validation
|
|
42
|
+
return params;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
return schema.parse(params);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (error instanceof ZodError) {
|
|
49
|
+
if (onValidationError && context) {
|
|
50
|
+
const errorObj = onValidationError(error, context);
|
|
51
|
+
throw new ResponseError(errorObj.code, errorObj.message, errorObj.data);
|
|
52
|
+
}
|
|
53
|
+
// Default validation error handling
|
|
54
|
+
throw ResponseError.invalidParams(`Invalid params for ${method}: ${error.message}`, error.issues);
|
|
55
|
+
}
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAClC,OA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AQ,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC1E,CAAC;YAED,oCAAoC;YACpC,MAAM,aAAa,CAAC,aAAa,CAC/B,sBAAsB,MAAM,KAAK,KAAK,CAAC,OAAO,EAAE,EAChD,KAAK,CAAC,MAAM,CACb,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AAAA,CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lspeasy/server",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Build LSP servers with simple, typed API",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"lsp",
|
|
7
|
+
"language-server-protocol",
|
|
8
|
+
"lsp-server",
|
|
9
|
+
"language-server"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/pradeepmouli/lspeasy#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/pradeepmouli/lspeasy/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "Pradeep Mouli",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/pradeepmouli/lspeasy.git",
|
|
20
|
+
"directory": "packages/server"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@lspeasy/core": "1.0.1"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"zod": "^3.25.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"typescript": "^5.9.3",
|
|
46
|
+
"vscode-languageserver-protocol": "^3.17.5",
|
|
47
|
+
"zod": "^4.3.6"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=20.0.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsgo --build",
|
|
54
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
55
|
+
"dev": "tsgo --build --watch",
|
|
56
|
+
"type-check": "tsgo --noEmit"
|
|
57
|
+
}
|
|
58
|
+
}
|