@lspeasy/client 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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +589 -0
  3. package/dist/capability-guard.d.ts +62 -0
  4. package/dist/capability-guard.d.ts.map +1 -0
  5. package/dist/capability-guard.js +230 -0
  6. package/dist/capability-guard.js.map +1 -0
  7. package/dist/capability-proxy.d.ts +16 -0
  8. package/dist/capability-proxy.d.ts.map +1 -0
  9. package/dist/capability-proxy.js +69 -0
  10. package/dist/capability-proxy.js.map +1 -0
  11. package/dist/client.d.ts +184 -0
  12. package/dist/client.d.ts.map +1 -0
  13. package/dist/client.js +692 -0
  14. package/dist/client.js.map +1 -0
  15. package/dist/connection/health.d.ts +14 -0
  16. package/dist/connection/health.d.ts.map +1 -0
  17. package/dist/connection/health.js +77 -0
  18. package/dist/connection/health.js.map +1 -0
  19. package/dist/connection/heartbeat.d.ts +18 -0
  20. package/dist/connection/heartbeat.d.ts.map +1 -0
  21. package/dist/connection/heartbeat.js +57 -0
  22. package/dist/connection/heartbeat.js.map +1 -0
  23. package/dist/connection/index.d.ts +5 -0
  24. package/dist/connection/index.d.ts.map +1 -0
  25. package/dist/connection/index.js +4 -0
  26. package/dist/connection/index.js.map +1 -0
  27. package/dist/connection/types.d.ts +32 -0
  28. package/dist/connection/types.d.ts.map +1 -0
  29. package/dist/connection/types.js +9 -0
  30. package/dist/connection/types.js.map +1 -0
  31. package/dist/index.d.ts +12 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +8 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/notifications/index.d.ts +3 -0
  36. package/dist/notifications/index.d.ts.map +1 -0
  37. package/dist/notifications/index.js +2 -0
  38. package/dist/notifications/index.js.map +1 -0
  39. package/dist/notifications/wait.d.ts +19 -0
  40. package/dist/notifications/wait.d.ts.map +1 -0
  41. package/dist/notifications/wait.js +46 -0
  42. package/dist/notifications/wait.js.map +1 -0
  43. package/dist/progress.d.ts +54 -0
  44. package/dist/progress.d.ts.map +1 -0
  45. package/dist/progress.js +52 -0
  46. package/dist/progress.js.map +1 -0
  47. package/dist/types.d.ts +82 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +5 -0
  50. package/dist/types.js.map +1 -0
  51. package/dist/validation.d.ts +43 -0
  52. package/dist/validation.d.ts.map +1 -0
  53. package/dist/validation.js +56 -0
  54. package/dist/validation.js.map +1 -0
  55. package/package.json +58 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Response validation utilities for LSP client
3
+ * Validates server responses against expected schemas
4
+ */
5
+ import { z } from 'zod';
6
+ import type { LSPRequestMethod } from '@lspeasy/core';
7
+ /**
8
+ * Validation error thrown when server response doesn't match expected schema
9
+ */
10
+ export declare class ResponseValidationError extends Error {
11
+ readonly method: string;
12
+ readonly errors: z.ZodError;
13
+ readonly response: unknown;
14
+ constructor(method: string, errors: z.ZodError, response: unknown);
15
+ }
16
+ /**
17
+ * Validates a response against a Zod schema
18
+ * @param method - LSP method name for error reporting
19
+ * @param schema - Zod schema to validate against
20
+ * @param response - Response data to validate
21
+ * @returns Validated and typed response
22
+ * @throws ResponseValidationError if validation fails
23
+ */
24
+ export declare function validateResponse<T>(method: LSPRequestMethod, schema: z.ZodSchema<T>, response: unknown): T;
25
+ /**
26
+ * Options for response validation
27
+ */
28
+ export interface ValidationOptions {
29
+ /**
30
+ * Whether to validate responses (default: true)
31
+ */
32
+ enabled?: boolean;
33
+ /**
34
+ * Custom error handler for validation failures
35
+ * If not provided, throws ResponseValidationError
36
+ */
37
+ onValidationError?: (error: ResponseValidationError) => void;
38
+ }
39
+ /**
40
+ * Creates a response validator with custom options
41
+ */
42
+ export declare function createValidator(options?: ValidationOptions): <T>(method: "callHierarchy/incomingCalls" | "callHierarchy/outgoingCalls" | "client/registerCapability" | "client/unregisterCapability" | "codeAction/resolve" | "codeLens/resolve" | "completionItem/resolve" | "documentLink/resolve" | "initialize" | "inlayHint/resolve" | "shutdown" | "textDocument/codeAction" | "textDocument/codeLens" | "textDocument/colorPresentation" | "textDocument/completion" | "textDocument/declaration" | "textDocument/definition" | "textDocument/diagnostic" | "textDocument/documentColor" | "textDocument/documentHighlight" | "textDocument/documentLink" | "textDocument/documentSymbol" | "textDocument/foldingRange" | "textDocument/formatting" | "textDocument/hover" | "textDocument/implementation" | "textDocument/inlayHint" | "textDocument/inlineValue" | "textDocument/linkedEditingRange" | "textDocument/moniker" | "textDocument/onTypeFormatting" | "textDocument/prepareCallHierarchy" | "textDocument/prepareRename" | "textDocument/prepareTypeHierarchy" | "textDocument/rangeFormatting" | "textDocument/references" | "textDocument/rename" | "textDocument/selectionRange" | "textDocument/semanticTokens/full" | "textDocument/semanticTokens/full/delta" | "textDocument/semanticTokens/range" | "textDocument/signatureHelp" | "textDocument/typeDefinition" | "textDocument/willSaveWaitUntil" | "typeHierarchy/subtypes" | "typeHierarchy/supertypes" | "window/showDocument" | "window/showMessageRequest" | "window/workDoneProgress/create" | "workspace/applyEdit" | "workspace/codeLens/refresh" | "workspace/configuration" | "workspace/diagnostic" | "workspace/diagnostic/refresh" | "workspace/executeCommand" | "workspace/inlayHint/refresh" | "workspace/inlineValue/refresh" | "workspace/semanticTokens/refresh" | "workspace/symbol" | "workspace/willCreateFiles" | "workspace/willDeleteFiles" | "workspace/willRenameFiles" | "workspace/workspaceFolders" | "workspaceSymbol/resolve", schema: z.ZodType<T, unknown, z.core.$ZodTypeInternals<T, unknown>>, response: unknown) => T;
43
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;aAE9B,MAAM,EAAE,MAAM;aACd,MAAM,EAAE,CAAC,CAAC,QAAQ;aAClB,QAAQ,EAAE,OAAO;IAHnC,YACkB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,CAAC,QAAQ,EAClB,QAAQ,EAAE,OAAO,EAIlC;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACtB,QAAQ,EAAE,OAAO,GAChB,CAAC,CAQH;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAC9D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,iBAAsB,IAGpC,CAAC,48DAkB3B"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Response validation utilities for LSP client
3
+ * Validates server responses against expected schemas
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Validation error thrown when server response doesn't match expected schema
8
+ */
9
+ export class ResponseValidationError extends Error {
10
+ method;
11
+ errors;
12
+ response;
13
+ constructor(method, errors, response) {
14
+ super(`Response validation failed for ${method}: ${errors.message}`);
15
+ this.method = method;
16
+ this.errors = errors;
17
+ this.response = response;
18
+ this.name = 'ResponseValidationError';
19
+ }
20
+ }
21
+ /**
22
+ * Validates a response against a Zod schema
23
+ * @param method - LSP method name for error reporting
24
+ * @param schema - Zod schema to validate against
25
+ * @param response - Response data to validate
26
+ * @returns Validated and typed response
27
+ * @throws ResponseValidationError if validation fails
28
+ */
29
+ export function validateResponse(method, schema, response) {
30
+ const result = schema.safeParse(response);
31
+ if (!result.success) {
32
+ throw new ResponseValidationError(String(method), result.error, response);
33
+ }
34
+ return result.data;
35
+ }
36
+ /**
37
+ * Creates a response validator with custom options
38
+ */
39
+ export function createValidator(options = {}) {
40
+ const { enabled = true, onValidationError } = options;
41
+ return function validate(method, schema, response) {
42
+ if (!enabled) {
43
+ return response;
44
+ }
45
+ try {
46
+ return validateResponse(method, schema, response);
47
+ }
48
+ catch (error) {
49
+ if (error instanceof ResponseValidationError && onValidationError) {
50
+ onValidationError(error);
51
+ }
52
+ throw error;
53
+ }
54
+ };
55
+ }
56
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAE9B,MAAM;IACN,MAAM;IACN,QAAQ;IAH1B,YACkB,MAAc,EACd,MAAkB,EAClB,QAAiB,EACjC;QACA,KAAK,CAAC,kCAAkC,MAAM,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;sBAJrD,MAAM;sBACN,MAAM;wBACN,QAAQ;QAGxB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IAAA,CACvC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAwB,EACxB,MAAsB,EACtB,QAAiB,EACd;IACH,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAE1C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,uBAAuB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC;AAAA,CACpB;AAkBD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,OAAO,GAAsB,EAAE,EAAE;IAC/D,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;IAEtD,OAAO,SAAS,QAAQ,CACtB,MAAwB,EACxB,MAAsB,EACtB,QAAiB,EACd;QACH,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,QAAa,CAAC;QACvB,CAAC;QAED,IAAI,CAAC;YACH,OAAO,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,uBAAuB,IAAI,iBAAiB,EAAE,CAAC;gBAClE,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IAAA,CACF,CAAC;AAAA,CACH"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@lspeasy/client",
3
+ "version": "1.0.1",
4
+ "description": "Connect to LSP servers with typed client API",
5
+ "keywords": [
6
+ "lsp",
7
+ "language-server-protocol",
8
+ "lsp-client",
9
+ "language-client"
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/client"
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
+ }