import { Connection } from "@1c-odata/client"; //#region src/config.d.ts /** * A single codegen target — a {@link Connection} plus build-only options. The * connection is the same runtime descriptor the application uses; the target * *wraps* it with codegen settings rather than dissolving its fields, so * runtime/secret config and build config stay separable. * * @public */ interface CodegenTarget { /** * Runtime connection descriptor for this base. Used by `1c-odata fetch` to * download `$metadata`; its `shape` is baked into the emitted * `__metadata.json` by `1c-odata generate`. */ connection: Connection; /** Whitelist of entity-type names. Globs supported (`Catalog_*`). Closure auto-expands. */ include?: string[]; /** Per-target override of `fetchTimeout` (ms) for `1c-odata fetch`. */ fetchTimeout?: number; } /** * Top-level codegen config — what `1c-odata.config.ts` exports. Consumed only * by the `1c-odata` CLI (`fetch` + `generate`). The application runtime builds * its {@link Connection}s directly (e.g. via `defineConnection`) and never * imports this file, so build-time settings and secrets stay out of the * runtime graph. * * @public */ interface CodegenConfig { /** Directory for `.xml` snapshots. Default: `./metadata`. */ metadataDir?: string; /** Directory for generated TS files. Default: `./generated`. */ generatedDir?: string; /** Default timeout for `1c-odata fetch` (ms). Default: `120_000`. */ fetchTimeout?: number; /** Map of target name → codegen target. */ targets: Record; } /** * Identity helper for a type-safe `1c-odata.config.ts`. Preserves literal * types via `const` inference, so `targets` keeps its keys narrow. * * @example * ```ts * import { defineCodegenConfig } from '@1c-odata/cli' * import { parseConnectionUrl } from '@1c-odata/client' * * const url = process.env.ONEC_URL * if (!url) throw new Error('Set ONEC_URL env var') * * export default defineCodegenConfig({ * targets: { * trade: { * connection: { ...parseConnectionUrl(url), serverTimezone: 'Europe/Moscow' }, * include: ['Catalog_*', 'Document_*'], * }, * }, * }) * ``` * * @public */ declare function defineCodegenConfig(c: C): C; interface LoadResult { config: CodegenConfig; configFile: string; cwd: string; } /** * Load `1c-odata.config.ts` from the project root using c12. * * Auto-sources `.env` then `.env.local` (relative to `cwd`) before evaluating * the user's config file, so `process.env.ONEC__URL` is available when * the config file calls `parseConnectionUrl(process.env.ONEC__URL)`. * * Validates that: * - a config file is present * - `targets` is a non-empty object * - each `target.connection` passes `validateConnection` (baseUrl without * userinfo, non-empty auth, valid IANA serverTimezone) * * Connection.serverTimezone is required (no default applied). Wrong timezone * produces silent DateTime parse drift, so the library forces an explicit * choice rather than guessing. */ declare function loadConfig(opts: { cwd: string; configFile?: string; }): Promise; //#endregion //#region src/commands/fetch.d.ts interface RunFetchOptions { cwd: string; config: CodegenConfig; target?: string; } /** Run `1c-odata fetch` — download `$metadata` for one or all targets, writing each to `/.xml`. */ declare function runFetch(opts: RunFetchOptions): Promise; //#endregion //#region src/commands/generate.d.ts interface RunGenerateOptions { cwd: string; config: CodegenConfig; target?: string; /** * `@1c-odata/cli` package version. Embedded in `__metadata.json` as part * of the input-hash triple used by smart-skip — a version bump invalidates * the cache. The CLI bin reads this from `package.json` and threads it * through; programmatic callers must supply it. */ cliVersion: string; /** Bypass the input-hash cache check; regenerate every selected target. */ force?: boolean; /** * Emit only `__metadata.json` (no TypeScript files). Part of the * options-hash, so switching modes invalidates the smart-skip cache. */ metadataOnly?: boolean; } /** Run `1c-odata generate` — read metadata XML for one or all targets, call codegen, write the resulting files under `//`. */ declare function runGenerate(opts: RunGenerateOptions): Promise; //#endregion export { type CodegenConfig, type CodegenTarget, type LoadResult, type RunFetchOptions, type RunGenerateOptions, defineCodegenConfig, loadConfig, runFetch, runGenerate }; //# sourceMappingURL=index.d.ts.map