import { MockAigatewayOptions, mockAigateway } from "./mocks/aigateway.mjs"; import { MockAuthconnectionOptions, mockAuthconnection } from "./mocks/authconnection.mjs"; import { MockFileOptions, mockFile } from "./mocks/file.mjs"; import { MockIconvOptions, mockIconv } from "./mocks/iconv.mjs"; import { MockIdpOptions, mockIdp } from "./mocks/idp.mjs"; import { MockLoggerOptions, mockLogger } from "./mocks/logger.mjs"; import { MockSecretmanagerOptions, mockSecretmanager } from "./mocks/secretmanager.mjs"; import { MockTailordbOptions, QueryBehavior, QueryMatch, QueryMatcher, mockTailordb } from "./mocks/tailordb.mjs"; import { mockWorkflow } from "./mocks/workflow.mjs"; import "./mock.mjs"; import { PGliteClient, PGliteQueryResult, Unmigrated, createKyselyPGlite } from "./pglite-kysely.mjs"; import { ExecutedPGliteQuery, MockTailordbPGliteOptions, mockTailordbWithPGlite } from "./mocks/tailordb-pglite.mjs"; import { RunWorkflowLocallyOptions, runWorkflowLocally } from "./workflow-local.mjs"; import { ExecutedQuery, KyselyMock, createKyselyMock } from "./mock-kysely.mjs"; import { Plugin } from "vitest/config"; //#region src/vitest/index.d.ts /** * Creates Vitest plugins that emulate the Tailor Platform function runtime environment. * * **Beta:** This API may change in future releases. * * ## What it does * * 1. **Node.js module blocking** (transform hook) — Imports of `node:*` modules * (and bare builtins like `crypto`, `fs`) in non-test source files are replaced * with code that throws an error with a suggestion for the Web Standard API alternative. * Test files are exempt and can use `node:*` freely. Test file patterns are read * from the resolved Vitest config (`test.include`). * * 2. **Node.js globals removal** (environment) — Only globals available in the * Tailor Platform runtime are kept (whitelist: ECMAScript standard, Web Standard APIs * from bootstrap.js, platform mocks). All others (`Buffer`, `global`, `setImmediate`, * `__dirname`, `__filename`, etc.) are removed. * * 3. **Platform API mocks** (environment) — All platform APIs are auto-injected with * control objects: `mockTailordb`, `mockWorkflow`, `mockSecretmanager`, * `mockAuthconnection`, `mockIdp`, `mockFile`, `mockIconv`, `mockAigateway`, * `mockLogger`. Each * provides response configuration, call recording, and reset. * * 4. **Environment resolution** — Rewrites `environment: "tailor-runtime"` to the * absolute path of the bundled environment module via the config hook. * * ## Known limitations * * - **`process`** and **`require`** are NOT removed or blocked. Vitest's internal * runner depends on them. On the real Tailor Platform runtime, they do not exist. * - **Dynamic `import()`** of bundled files bypasses the transform hook since * those files are loaded through Node.js native loader. * ## Options * * - **`config`** — Path to `tailor.config.ts`. Loads `defineSecretManager()` values * into `mockSecretmanager` so `getSecret()` returns the configured values. * @example * ```typescript * // vitest.config.ts * import { defineConfig } from "vitest/config"; * import { tailorRuntime } from "@tailor-platform/sdk/vitest"; * * export default defineConfig({ * plugins: [tailorRuntime({ config: "./tailor.config.ts" })], * test: { * environment: "tailor-runtime", * }, * }); * ``` * @param options - Optional configuration * @param options.config - Path to tailor.config.ts to load SecretManager values into mock * @returns Array of Vite plugins */ export declare function tailorRuntime(options?: { config?: string; }): Plugin[]; //#endregion export { type ExecutedPGliteQuery, type ExecutedQuery, type KyselyMock, type MockAigatewayOptions, type MockAuthconnectionOptions, type MockFileOptions, type MockIconvOptions, type MockIdpOptions, type MockLoggerOptions, type MockSecretmanagerOptions, type MockTailordbOptions, type MockTailordbPGliteOptions, type PGliteClient, type PGliteQueryResult, type QueryBehavior, type QueryMatch, type QueryMatcher, type RunWorkflowLocallyOptions, type Unmigrated, createKyselyMock, createKyselyPGlite, mockAigateway, mockAuthconnection, mockFile, mockIconv, mockIdp, mockLogger, mockSecretmanager, mockTailordb, mockTailordbWithPGlite, mockWorkflow, runWorkflowLocally };