/** * Surgical id write-back into quickback.config.ts. * * `quickback deploy` provisions Cloudflare resources (D1 databases, KV * namespaces) and needs to persist the real ids into the USER's providers * block so the next compile emits a wrangler.toml with real ids instead of * placeholders. Unlike the kitchen-sink sentinel splice (config-sync.ts), * these keys live in user-owned code — so this module does string-level * surgery on the provider config object only: * * - existing key → replace just the string literal value * - missing key → insert one new line right after the object's `{`, * matching the surrounding indentation * - existing key with a DIFFERENT real value → conflict (never silently * overwritten; caller decides via `force`) * * Both authoring shapes are supported: * * database: defineDatabase("cloudflare-d1", { ...config... }) * database: { name: "cloudflare-d1", config: { ...config... } } * * Everything outside the located config object is left byte-for-byte * untouched. */ export interface IdUpdate { /** Which provider entry the key belongs to. */ target: 'database' | 'storage'; /** Config key, e.g. `authDatabaseId`, `kvNamespaceId`, `namespaceId`. */ key: string; /** The real Cloudflare resource id. */ value: string; } export interface IdConflict { target: 'database' | 'storage'; key: string; existing: string; incoming: string; } export interface SpliceIdsResult { text: string; /** Updates actually written (inserted or replaced). */ applied: IdUpdate[]; /** Keys already set to the incoming value — nothing to do. */ unchanged: IdUpdate[]; /** Keys whose existing real value differs from Cloudflare's. */ conflicts: IdConflict[]; /** Set when a provider config object could not be located. */ skippedReason?: string; } export declare function spliceProviderIds(source: string, updates: IdUpdate[], options?: { force?: boolean; }): SpliceIdsResult; interface Span { /** Index of the `{` opening the config object. */ open: number; /** Index of the matching `}`. */ close: number; } /** * Locate the provider config object for `database` / `storage`. * Tries the define-call wrapper first (`defineDatabase("...", {…})`), * then the plain-object form (`database: { name: "...", config: {…} }`). */ export declare function findProviderConfigSpan(source: string, target: 'database' | 'storage'): Span | null; /** Index of the `}` matching the `{` at `openIdx`, or null. */ export declare function matchBrace(text: string, openIdx: number): number | null; export {}; //# sourceMappingURL=config-id-splice.d.ts.map