import path from "node:path"; import { type IntegrationInfo } from "./extract-api-integrations.mjs"; type SdkApiEntry = { entryPoint: string; exportName?: string; integrations?: IntegrationInfo[]; unresolvedIntegrations?: string[]; }; export type CollectSdkApisOptions = { onUnresolvedIntegrations?: (apiName: string, entryPoint: string, unresolvedKeys: string[]) => void; onExtractionError?: (apiName: string, entryPoint: string, error: unknown) => void; }; type SdkApisResult = Record; type CollectSdkApisFs = { pathExists: (p: string) => Promise; readFile: (p: string, encoding: "utf-8") => Promise; /** * Used to canonicalize symlinks for app-root containment checks. An * in-root path can lexically pass `resolveContainedPath` while being a * symlink whose real target lives outside `root`; when `realpath` is * provided, `resolveContainedRealPath` re-verifies containment against * the canonicalized (symlink-resolved) path before it is read. When * omitted, containment falls back to the lexical check only. */ realpath?: (p: string) => Promise; }; /** * Resolves `relativePath` against `root` and returns the resolved absolute * path only if it stays contained within `root`; returns `undefined` * otherwise (including for a path that resolves to exactly `root` plus a * differently-cased or malformed suffix — only exact containment counts). * * Defense in depth against path traversal: the extractor * (extract-api-integrations.ts) already filters `..`-prefixed candidates * before ever proposing them, but that filtering is posix-only. `pathImpl` * defaults to the real `node:path` (win32 semantics on Windows, posix * elsewhere), so this re-verifies containment using whichever path * semantics actually apply at runtime — a `relativePath` the extractor * considered safe on POSIX could still escape `root` here on Windows, where * backslashes are separators. Also protects against any future extractor * change that stops filtering candidates. `pathImpl` is overridable so * win32 containment semantics can be exercised directly in tests on a POSIX * runner, independent of the host OS. */ export declare function resolveContainedPath(root: string, relativePath: string, pathImpl?: typeof path): string | undefined; /** * Like `resolveContainedPath`, but also canonicalizes symlinks before * asserting containment, so an in-root path that is a symlink pointing * outside `root` is rejected rather than silently followed. * * First runs the cheap lexical `resolveContainedPath` check; if that already * fails, returns `undefined` without touching the filesystem. If * `deps.realpath` is not provided, returns the lexical result unchanged — * containment falls back to the lexical check only (documented fallback, * e.g. for callers/tests that don't need symlink defense). If `realpath` is * provided, both `root` and the lexically-resolved path are canonicalized * and the same containment check is re-run against the canonical values; * the canonical resolved path is returned only if it is still contained. * If `realpath` throws (e.g. the path does not exist), returns `undefined` * rather than throwing. */ export declare function resolveContainedRealPath(root: string, relativePath: string, deps: { realpath?: (p: string) => Promise; pathImpl?: typeof path; }): Promise; /** * Collect SDK API entry points and declared integrations from the app's registry * at server/apis/index.ts. Keys match Object.keys(registry.default) so * useApi("Key") works in both edit and deployed modes. * * @param root - App root directory * @param fs - File system operations (pathExists, readFile) * @param options - Optional callbacks: onUnresolvedIntegrations for * reporting integration keys that could not be resolved to a plugin/id, and * onExtractionError for reporting when a registered API's source file could * not be read or parsed (the entry point is still emitted bare in that case). * @returns Map of API name → { entryPoint, exportName?, integrations?, * unresolvedIntegrations? } or empty object if no registry exists */ export declare function collectSdkApisFromRegistry(root: string, fs: CollectSdkApisFs, options?: CollectSdkApisOptions): Promise; export {}; //# sourceMappingURL=collect-sdk-apis.d.mts.map