ebay-api-mcp-server-node-local 1.0.0

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.
@@ -0,0 +1,140 @@
1
+ import {afterAll, beforeAll, describe, expect, it} from "vitest";
2
+ import {Client} from "@modelcontextprotocol/sdk/client/index.js";
3
+ import {StdioClientTransport} from "@modelcontextprotocol/sdk/client/stdio.js";
4
+ import * as path from "path";
5
+ import * as fs from "fs";
6
+
7
+ // Define interfaces for type safety
8
+ interface ContentPart {
9
+ type: string;
10
+ text: string;
11
+ }
12
+
13
+ interface CallToolResponse {
14
+ content: ContentPart[];
15
+ isError?: boolean;
16
+ }
17
+
18
+ describe("MCP Server Integration Tests", () => {
19
+ let client: Client;
20
+ let transport: StdioClientTransport;
21
+
22
+ // Only setup the test environment if we're not skipping tests
23
+ beforeAll(async () => {
24
+ try {
25
+ console.log("Setting up test client...");
26
+
27
+ // Use the correct path to your server script
28
+ // Make sure we're using node with the compiled JS file instead of ts-node
29
+ const serverScriptPath = path.join(process.cwd(), "src", "index.ts");
30
+
31
+ // Check if the file exists
32
+ if (!fs.existsSync(serverScriptPath)) {
33
+ throw new Error(`Server script not found at: ${serverScriptPath}`);
34
+ }
35
+
36
+ console.log(`Server script found at: ${serverScriptPath}`);
37
+
38
+ // Create the transport with the correct path to the server
39
+ transport = new StdioClientTransport({
40
+ command: "node",
41
+ args: [
42
+ "--loader", "ts-node/esm",
43
+ "--experimental-specifier-resolution=node",
44
+ serverScriptPath,
45
+ ],
46
+ });
47
+
48
+ // Initialize the client
49
+ client = new Client({
50
+ name: "test-client",
51
+ version: "1.0.0",
52
+ });
53
+
54
+ console.log("Connecting to MCP server...");
55
+
56
+ // Add a timeout to the connection attempt
57
+ const connectionPromise = client.connect(transport);
58
+ const timeoutPromise = new Promise((_, reject) => {
59
+ setTimeout(() => reject(new Error("Connection timed out after 15 seconds")), 15000);
60
+ });
61
+
62
+ await Promise.race([connectionPromise, timeoutPromise]);
63
+ console.log("✅ Client connected successfully");
64
+
65
+ } catch (error) {
66
+ console.error("❌ Error during test setup:", error);
67
+ // Explicitly failing the test setup
68
+ throw error;
69
+ }
70
+ });
71
+
72
+ afterAll(async () => {
73
+ try {
74
+ if (client) {
75
+ console.log("Closing client connection...");
76
+ await client.close();
77
+ console.log("✅ Client closed successfully");
78
+ }
79
+ } catch (error) {
80
+ console.error("❌ Error during test cleanup:", error);
81
+ }
82
+ });
83
+
84
+
85
+ it("test list tools", async () => {
86
+ const result = await client.listTools();
87
+ console.log("Available tools:", result.tools.map(tool => tool.name));
88
+ expect(result.tools.length).toBeGreaterThan(1);
89
+ });
90
+
91
+ it("test query api", async () => {
92
+ const response = await client.callTool({
93
+ name: "queryAPI",
94
+ arguments: {
95
+ prompt : "i wanna order api",
96
+ },
97
+ }) as CallToolResponse;
98
+
99
+ expect(response).toBeDefined();
100
+ expect(response.content).toBeDefined();
101
+ expect(response.content.length).toBeGreaterThan(0);
102
+ });
103
+
104
+ it("test invoke api", async () => {
105
+ const response = await client.callTool({
106
+ name: "invokeAPI",
107
+ arguments: {
108
+ url: "https://api.sandbox.ebay.com/commerce/notification/v1/topic/MARKETPLACE_ACCOUNT_DELETION",
109
+ method: "GET",
110
+ headers: {},
111
+ urlVariables: {},
112
+ requestBody: {},
113
+ token : process.env.EBAY_CLIENT_TOKEN
114
+ },
115
+ }) as CallToolResponse;
116
+
117
+ expect(response).toBeDefined();
118
+ expect(response.content).toBeDefined();
119
+ expect(response.content.length).toBeGreaterThan(0);
120
+ });
121
+
122
+ it("test invoke api with pathVals", async () => {
123
+ const response = await client.callTool({
124
+ name: "invokeAPI",
125
+ arguments: {
126
+ url: "https://api.sandbox.ebay.com/commerce/notification/v1/subscription/{subscription_id}/test",
127
+ method: "POST",
128
+ headers: {},
129
+ urlVariables: {"subscription_id":"1000"},
130
+ requestBody: {},
131
+ token: process.env.EBAY_CLIENT_TOKEN
132
+ },
133
+ }) as CallToolResponse;
134
+
135
+ expect(response).toBeDefined();
136
+ expect(response.content).toBeDefined();
137
+ expect(response.content.length).toBeGreaterThan(0);
138
+ });
139
+
140
+ });
@@ -0,0 +1,243 @@
1
+ /**
2
+ * OpenAPI service for registering tools with MCP server
3
+ */
4
+ import { type McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
+ import { type OpenAPIV3 } from "openapi-types";
6
+ import { type RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
7
+ import { type ServerNotification, type ServerRequest } from "@modelcontextprotocol/sdk/types.js";
8
+ import { z, type ZodTypeAny } from "zod";
9
+ import axios from "axios";
10
+ import util from "util";
11
+ import { RECALL_SPEC_BY_PROMPT_URL, RECALL_SPEC_WITH_FIELD_URL, SUPPORTED_CALLING_METHODS, findApiEnvironmentByValue } from "../constant/constants.js";
12
+ import { getOpenApiDocumentsFromConfigFile, parseOpenApiDoc, buildOperationSchema, buildZodSchema } from "../helper/openapi-helper.js";
13
+ import { validateRequestParameters as validateRequestParametersFromHelper } from "../helper/validation-helper.js";
14
+ import { buildHeadersFromInput, buildFinalUrl, replaceDomainNameByEnvironment, formatAxiosError, buildBaseUrlFromOpenApi, prepareRequestData } from "../helper/http-helper.js";
15
+
16
+ const USER_ENVIRONMENT = findApiEnvironmentByValue(process.env.EBAY_API_ENV || "");
17
+ const QUERY_API_TOOL_DISCRIPTION = "Send user prompt to remote service and return recommended API spec info (GET, query param, path...). " +
18
+ "Only output the tool response. Don't add any unnecessary text to it.";
19
+ const INVOKE_API_TOOL_DISCRIPTION = "this tool requires the prior invocation of tool queryAPI to ensure proper context, please ensure tool queryAPI has been successfully executed before using this tool." +
20
+ "the output of tool queryAPI will be used to generate input parameter of this tool. please ensure each field type of input parameter complies with the specifications required by the api spec." +
21
+ "after validation , this tool will invoke eBay OpenAPI and return the result." +
22
+ "if the tool return error, please check the error info and give advice or fix it.";
23
+
24
+
25
+ /**
26
+ * Register OpenAPI tools with MCP server
27
+ */
28
+ export async function registerOpenApiTools(server: McpServer): Promise<void> {
29
+ // Load OpenAPI document
30
+ const openapis = await getOpenApiDocumentsFromConfigFile();
31
+ for (const doc of openapis) {
32
+ registerOpenApiDynamicTools(server, doc);
33
+ }
34
+ registerCustomTools(server);
35
+ }
36
+
37
+ /**
38
+ * register OpenAPI tools dynamically based on the OpenAPI document
39
+ */
40
+ function registerOpenApiDynamicTools(server: McpServer, openapi: OpenAPIV3.Document): void {
41
+ const baseUrl = buildBaseUrlFromOpenApi(openapi);
42
+
43
+ Object.entries(openapi.paths || {})
44
+ .filter(([_, pathItem]) => pathItem !== undefined)
45
+ .forEach(([path, pathItem]) => registerPathOperations(server, baseUrl, path, pathItem!));
46
+ }
47
+
48
+
49
+ /**
50
+ * Register tools for operations in a specific path
51
+ */
52
+ function registerPathOperations(
53
+ server: McpServer,
54
+ baseUrl: string,
55
+ path: string,
56
+ pathItem: OpenAPIV3.PathItemObject,
57
+ ): void {
58
+ const supportedMethods = Object.keys(pathItem)
59
+ .filter(method => SUPPORTED_CALLING_METHODS[USER_ENVIRONMENT].includes(method));
60
+
61
+ supportedMethods.forEach(method => {
62
+ const operation = pathItem[method as keyof typeof pathItem] as OpenAPIV3.OperationObject;
63
+ if (operation && operation.operationId) {
64
+ registerOperation(server, baseUrl, path, method, operation);
65
+ }
66
+ });
67
+ }
68
+
69
+ /**
70
+ * Register tool for a single API operation
71
+ */
72
+ function registerOperation(
73
+ server: McpServer,
74
+ baseUrl: string,
75
+ path: string,
76
+ method: string,
77
+ operation: OpenAPIV3.OperationObject,
78
+ ): void {
79
+ const properties = buildOperationSchema(operation);
80
+ const zodProperties = buildZodSchema(properties);
81
+ server.tool(
82
+ operation.operationId || "unknownOperation",
83
+ operation.description || "No description",
84
+ zodProperties,
85
+ async (input:Record<string, unknown>, _extra) => {
86
+ try {
87
+ const { resolvedPath, headers, params, data } = prepareRequestData(input, operation, path);
88
+ const url = baseUrl + resolvedPath;
89
+ const resp = await axios.request({
90
+ url,
91
+ method,
92
+ headers,
93
+ params,
94
+ data,
95
+ httpsAgent: new (await import("https")).Agent({
96
+ rejectUnauthorized: false,
97
+ })
98
+ });
99
+ return {
100
+ content: [
101
+ { type: "text" as const, text: typeof resp.data === "string" ? resp.data : JSON.stringify(resp.data, null, 2) },
102
+ ],
103
+ };
104
+ } catch (error) {
105
+ return {
106
+ content: [
107
+ { type: "text" as const, text: `Error in invokeOpenAPI tool: ${formatAxiosError(error)}` },
108
+ ],
109
+ isError: true,
110
+ };
111
+ }
112
+ },
113
+ );
114
+ }
115
+
116
+ /**
117
+ * Register custom API tools to enable interaction with eBay OpenAPI services
118
+ * This function registers two primary tools:
119
+ * 1. queryAPI - For discovering API specifications
120
+ * 2. invokeAPI - For executing API calls with validation
121
+ */
122
+ function registerCustomTools(server: McpServer): void {
123
+ registerQueryApiTool(server);
124
+ registerInvokeApiTool(server);
125
+ }
126
+
127
+ /**
128
+ * Register a tool for querying API specifications based on natural language prompts
129
+ * Only registered when no custom API doc URL file is provided
130
+ */
131
+ function registerQueryApiTool(server: McpServer): void {
132
+ const hasCustomDoc = process.env.EBAY_API_DOC_URL_FILE;
133
+ if (hasCustomDoc) {return;}
134
+
135
+ server.tool(
136
+ "queryAPI",
137
+ QUERY_API_TOOL_DISCRIPTION,
138
+ { prompt: z.string() },
139
+ async (input) => {
140
+ try {
141
+ const url = util.format(RECALL_SPEC_BY_PROMPT_URL, encodeURIComponent(input.prompt));
142
+ const resp = await axios.get(url, {
143
+ httpsAgent: new (await import("https")).Agent({
144
+ rejectUnauthorized: false,
145
+ }),
146
+ });
147
+ return {
148
+ content: [
149
+ { type: "text" as const, text: resp.data ? (typeof resp.data === "string" ? resp.data : JSON.stringify(resp.data, null, 2)) : "No response body" }
150
+ ],
151
+ };
152
+ } catch (error) {
153
+ return {
154
+ content: [
155
+ { type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` },
156
+ ],
157
+ isError: true,
158
+ };
159
+ }
160
+ },
161
+ );
162
+ }
163
+
164
+ /**
165
+ * Register a tool for executing API calls with proper validation and error handling
166
+ */
167
+ function registerInvokeApiTool(server: McpServer): void {
168
+ server.tool(
169
+ "invokeAPI",
170
+ INVOKE_API_TOOL_DISCRIPTION,
171
+ getInvokeApiSchema(),
172
+ async (input, _extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => {
173
+ try {
174
+ // Build headers
175
+ const headers = buildHeadersFromInput(input.headers);
176
+ // query and parse apiSpec by specTitle and operationId
177
+ const openApiDoc = await parseOpenApiDoc(input.specTitle, input.operationId, RECALL_SPEC_WITH_FIELD_URL);
178
+ const replacedDomainUrl = replaceDomainNameByEnvironment(input.url);
179
+
180
+ // Validate req parameters against OpenAPI spec
181
+ const reqParamValidation = validateRequestParametersFromHelper(replacedDomainUrl, openApiDoc, input.method, {
182
+ urlVariables: input.urlVariables,
183
+ urlQueryParams: input.urlQueryParams,
184
+ headers,
185
+ requestBody: input.requestBody,
186
+ });
187
+ if (!reqParamValidation.isValid) {
188
+ return {
189
+ content: [
190
+ { type: "text" as const, text: "Request validation failed:" },
191
+ { type: "text" as const, text: reqParamValidation.errors.join("\n") },
192
+ ],
193
+ isError: true,
194
+ };
195
+ }
196
+
197
+ // Make the API request
198
+ const resp = await axios.request({
199
+ url : buildFinalUrl(replacedDomainUrl, input.urlVariables),
200
+ method: input.method,
201
+ headers,
202
+ params: input.urlQueryParams,
203
+ data : input.requestBody,
204
+ httpsAgent: new (await import("https")).Agent({
205
+ rejectUnauthorized: false,
206
+ }),
207
+ });
208
+
209
+ return {
210
+ content: [
211
+ { type: "text" as const, text: resp.data ? (typeof resp.data === "string" ? resp.data : JSON.stringify(resp.data, null, 2)) : "No response body" },
212
+ ],
213
+ };
214
+ } catch (error) {
215
+ return {
216
+ content: [
217
+ { type: "text" as const, text: `Error in invokeOpenAPI tool: ${formatAxiosError(error)}` },
218
+ ],
219
+ isError: true,
220
+ };
221
+ }
222
+ },
223
+ );
224
+ }
225
+
226
+ /**
227
+ * Define the schema for invokeAPI tool parameters
228
+ */
229
+ function getInvokeApiSchema(): Record<string, ZodTypeAny> {
230
+ return {
231
+ url: z.string().describe("The complete request API URL, url and basePath need to be put in together. don't replace path variables, maintain variables such as {item_id}, the variable will be replaced by urlVariables input in tool."),
232
+ method: z.string().describe("The request API method (GET, POST, PUT, DELETE, ...)"),
233
+ headers: z.record(z.string(), z.array(z.string())).optional().describe("The API header params"),
234
+ urlVariables: z.record(z.string(), z.any()).optional().describe("The API path variables"),
235
+ urlQueryParams: z.record(z.string(), z.string()).optional().describe("The API query parameters"),
236
+ requestBody: z.record(z.string(), z.any()).optional().describe("The API request body"),
237
+ specTitle: z.string().describe("The OpenAPI spec title from info.title"),
238
+ operationId: z.string().describe("The OpenAPI operationId"),
239
+ };
240
+ }
241
+
242
+
243
+
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist"
6
+ },
7
+ "include": ["src/**/*.ts"],
8
+ "exclude": ["src/test", "src/test/**/*", "**/*.test.ts", "**/*.spec.ts"]
9
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,115 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
17
+ // "libReplacement": true, /* Enable lib replacement. */
18
+ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
19
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
20
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
21
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
22
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
23
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
24
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
25
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
26
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
27
+
28
+ /* Modules */
29
+ "module": "NodeNext", /* Specify what module code is generated. */
30
+ "moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */
31
+ "rootDir": "./src", /* Specify the root folder within your source files. */
32
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
34
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
35
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
36
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
37
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
38
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
39
+ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
40
+ // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
41
+ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
42
+ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
43
+ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
44
+ // "noUncheckedSideEffectImports": true, /* Check side effect imports. */
45
+ "resolveJsonModule": true, /* Enable importing .json files. */
46
+ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
47
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
48
+
49
+ /* JavaScript Support */
50
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
51
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
52
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
53
+
54
+ /* Emit */
55
+ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
56
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
57
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
58
+ "sourceMap": true, /* Create source map files for emitted JavaScript files. */
59
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
60
+ // "noEmit": true, /* Disable emitting files from a compilation. */
61
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
62
+ "outDir": "./dist", /* Specify an output folder for all emitted files. */
63
+ // "removeComments": true, /* Disable emitting comments. */
64
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
65
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
66
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
67
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
68
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
69
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
70
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
71
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
72
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
73
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
74
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
75
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
76
+
77
+ /* Interop Constraints */
78
+ "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
79
+ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
80
+ // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
81
+ // "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
82
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
83
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
84
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
85
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
86
+
87
+ /* Type Checking */
88
+ "strict": true, /* Enable all strict type-checking options. */
89
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
90
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
91
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
92
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
93
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
94
+ // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
95
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
96
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
97
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
98
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
99
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
100
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
101
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
102
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
103
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
104
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
105
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
106
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
107
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
108
+
109
+ /* Completeness */
110
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
111
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
112
+ },
113
+ "include": ["src/**/*"],
114
+ "exclude": ["node_modules"]
115
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "ts-node": {
4
+ "esm": true,
5
+ "experimentalSpecifierResolution": "node"
6
+ }
7
+ }
@@ -0,0 +1,20 @@
1
+ import { defineConfig } from "vitest/config";
2
+ import { resolve } from "path";
3
+
4
+ export default defineConfig({
5
+ test: {
6
+ environment: "node",
7
+ include: ["src/**/*.test.ts"],
8
+ globals: true,
9
+ setupFiles: ["./vitest.setup.ts"],
10
+ alias: {
11
+ // This mimics the moduleNameMapper in your Jest config
12
+ "~/(.*)": resolve(__dirname, "src/$1"),
13
+ },
14
+ coverage: {
15
+ provider: "v8",
16
+ reporter: ["text", "json", "html"],
17
+ exclude: ["**/node_modules/**", "**/dist/**", "**/src/test/**"],
18
+ },
19
+ },
20
+ });
@@ -0,0 +1,6 @@
1
+ import { config } from "dotenv";
2
+
3
+ // Load environment variables from .env file
4
+ config();
5
+
6
+ // You can add other setup code for tests here