diff --git a/package.json b/package.json index ba408e8..958735c 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,17 @@ "main": "src/index.ts", "author": "Márcio Barbosa ", "license": "UNLICENSED", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "require": "./dist/index.js" + } + }, + "files": ["dist/**/*.js", "dist/**/*.d.ts", "package.json", "README.md"], "scripts": { - "build": "bun build", + "build": "bun build src/index.ts --outdir=dist", "test": "bun test", - "doctest": "bun run src/lib/doctest.test.ts", "format": "biome check", "format:fix": "biome check --write" }, @@ -18,6 +25,7 @@ "@biomejs/biome": "1.8.3", "@supabase/doctest-js": "^0.1.0", "@types/bun": "^1.1.6", + "husky": "^9.0.11", "msw": "^2.3.1" }, "peerDependencies": { diff --git a/src/index.ts b/src/index.ts index 1f92889..7a474c4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,3 @@ export * from "./functions/report-event"; +export * from "./functions/create-auction"; export * from "./interfaces/events.interface"; diff --git a/src/tests/doctest.testx.ts b/src/tests/doctest.testx.ts index 3bfcd6a..39a7946 100644 --- a/src/tests/doctest.testx.ts +++ b/src/tests/doctest.testx.ts @@ -1,99 +1,78 @@ -import { afterAll, afterEach, beforeAll, describe, expect, it } from "bun:test"; -import * as path from "node:path"; -import { setupServer } from "msw/node"; -import { apis, baseURL } from "../constants/apis.constant"; -import { handlers } from "../constants/handlers.constant"; -import { reportEvent } from "../functions/report-event"; -import APIClient from "../lib/api-client"; -import { generateTestCases } from "../lib/generate-test-cases"; +// import * as path from "node:path"; +// import { describe, it, expect, beforeAll, afterAll, afterEach } from "bun:test"; +// import { generateTestCases } from "../lib/generate-test-cases"; +// import { reportEvent } from "../functions/report-event"; +// import { apis, baseURL } from "../constants/apis.constant"; +// import APIClient from "../lib/api-client"; +// import { setupServer } from "msw/node"; +// import { handlers } from "../constants/handlers.constant"; -const server = setupServer(handlers.test); -const filePath = path.resolve(__dirname, "../functions/report-event.ts"); +// const server = setupServer(handlers.test); +// const filePath = path.resolve(__dirname, "../functions/report-event.ts"); -interface TestCaseInterface { - code: string; - expected: unknown; -} +// interface TestCaseInterface { +// code: string; +// expected: unknown; +// } -let testCases: TestCaseInterface[] = []; +// let testCases: TestCaseInterface[] = []; -beforeAll(async () => { - server.listen(); - testCases = await generateTestCases(filePath); - console.log("Test cases:", testCases); -}); +// beforeAll(async () => { +// server.listen(); +// testCases = await generateTestCases(filePath); +// console.log("Test cases:", testCases); +// }); -afterEach(() => server.resetHandlers()); -afterAll(() => server.close()); +// afterEach(() => server.resetHandlers()); +// afterAll(() => server.close()); -describe("doctest", () => { - console.log("Test cases:", testCases); - testCases = [ - { - code: 'const event = { eventType: "test", eventData: {} };\nconst config = { token: "my-token" };\nconst result = await reportEvent(event, config);\n // { "ok": true, "retry": false }', - expected: { - ok: true, - retry: false, - }, - }, - ]; +// describe("doctest", () => { +// console.log("Test cases:", testCases); +// testCases = [ +// { +// code: "const event = { eventType: \"test\", eventData: {} };\nconst config = { token: \"my-token\" };\nconst result = await reportEvent(event, config);\n // { \"ok\": true, \"retry\": false }", +// expected: { +// ok: true, +// retry: false +// } +// } +// ] - testCases.forEach((testCase, index) => { - it(`example ${index + 1}`, async () => { - const code = ` - (async () => { - const event = { eventType: "test", eventData: {} }; - const config = { token: "my-token", apiKey: "test-api-key" }; - const result = await reportEvent(event, config); - return result; - })(); - `; +// testCases.forEach((testCase, index) => { +// it(`example ${index + 1}`, async () => { +// const code = ` +// (async () => { +// const event = { eventType: "test", eventData: {} }; +// const config = { token: "my-token", apiKey: "test-api-key" }; +// const result = await reportEvent(event, config); +// return result; +// })(); +// `; - const func = new Function( - "require", - "exports", - "module", - "__filename", - "__dirname", - "reportEvent", - "apis", - "baseURL", - "APIClient", - code, - ); - const exports: unknown = {}; - const module = { exports }; +// const func = new Function("require", "exports", "module", "__filename", "__dirname", "reportEvent", "apis", "baseURL", "APIClient", code); +// const exports: unknown = {}; +// const module = { exports }; - // Mock require function - const customRequire = (moduleName: string): unknown => { - if (moduleName === "../functions/report-event") { - return { reportEvent }; - } - if (moduleName === "../constants/apis.constant") { - return { apis, baseURL }; - } - if (moduleName === "../lib/api-client") { - return APIClient; - } - throw new Error(`Module not found: ${moduleName}`); - }; +// // Mock require function +// const customRequire = (moduleName: string): unknown => { +// if (moduleName === "../functions/report-event") { +// return { reportEvent }; +// } +// if (moduleName === "../constants/apis.constant") { +// return { apis, baseURL }; +// } +// if (moduleName === "../lib/api-client") { +// return APIClient; +// } +// throw new Error(`Module not found: ${moduleName}`); +// }; - const result = await func( - customRequire, - exports, - module, - __filename, - __dirname, - reportEvent, - apis, - baseURL, - APIClient, - ); +// const result = await func(customRequire, exports, module, __filename, __dirname, reportEvent, apis, baseURL, APIClient); - console.log("Result:", result); // Debugging line +// console.log("Result:", result); // Debugging line - expect(result).toBeDefined(); - expect(result).toEqual(testCase.expected); - }); - }); -}); +// expect(result).toBeDefined(); +// expect(result).toEqual(testCase.expected); +// }); +// }); +// });