{"version":3,"sources":["../src/backend/postgres/pglite-store-impl.ts"],"names":["createPostgresTables","createLocalPgliteBackend","createStoreWithSchema","closeAfterFailure"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAS,sBACP,gBAAA,EACsC;AACtC,EAAA,IAAI,gBAAA,KAAqB,MAAA,EAAW,OAAO,EAAC;AAC5C,EAAA,MAAM,EAAE,MAAA,EAAQ,QAAA,EAAU,GAAG,MAAK,GAChC,gBAAA;AAEF,EAAA,OAAO,IAAA;AACT;AAGA,eAAsB,0BAAA,CACpB,OACA,OAAA,EAC4D;AAC5D,EAAA,MAAM,MAAA,GACJ,OAAA,CAAQ,KAAA,EAAO,MAAA,KAAW,MAAA,GACxB,SACAA,sCAAA,CAAqB,OAAA,CAAQ,KAAA,CAAM,MAAA,CAAO,MAAM,CAAA;AACpD,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,MAAMC,0CAAA,CAAyB;AAAA,IACjD,GAAI,QAAQ,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACpE,GAAI,QAAQ,MAAA,KAAW,KAAA,GAAQ,EAAE,MAAA,EAAQ,KAAA,KAAmB,EAAC;AAAA,IAC7D,GAAI,QAAQ,QAAA,KAAa,MAAA,GAAY,EAAC,GAAI,EAAE,QAAA,EAAU,OAAA,CAAQ,QAAA,EAAS;AAAA,IACvE,GAAI,MAAA,KAAW,MAAA,GAAY,EAAC,GAAI,EAAE,MAAA;AAAO,GAC1C,CAAA;AACD,EAAA,IAAI;AACF,IAAA,MAAM,CAAC,KAAK,CAAA,GAAI,MAAMC,uCAAA,CAAsB,OAAO,OAAA,EAAS;AAAA,MAC1D,GAAG,OAAA,CAAQ,KAAA;AAAA;AAAA;AAAA;AAAA,MAIX,GAAG,qBAAA,CAAsB,OAAA,CAAQ,gBAAgB;AAAA,KAClD,CAAA;AACD,IAAA,OAAO,KAAA;AAAA,EACT,SAAS,KAAA,EAAO;AACd,IAAA,OAAOC,mCAAA,CAAkB,SAAS,KAAK,CAAA;AAAA,EACzC;AACF","file":"pglite-store-impl-KDS4NRMC.cjs","sourcesContent":["/**\n * `createLocalPgliteStore`'s implementation body, loaded behind a dynamic\n * import from `./pglite-store.ts` so a missing `drizzle-orm` peer surfaces as\n * a typed refusal rather than a bare module-resolution stack (design §4.4b).\n *\n * This module owns every value import that reaches `drizzle-orm` for this\n * entrypoint. `pglite-store.ts` must hold no static reference to this module\n * — only the `import(\"./pglite-store-impl\")` expression inside its factory —\n * so the dynamic import survives into its own chunk in both the ESM and CJS\n * shipped artifacts (I12).\n */\nimport { type GraphDef } from \"../../core/define-graph\";\nimport { type SchemaManagerOptions } from \"../../schema/manager\";\nimport {\n  createStoreWithSchema,\n  type HistoryStore,\n  type RecordedReadStore,\n  type Store,\n} from \"../../store/store\";\nimport { createPostgresTables } from \"../drizzle/schema/postgres\";\nimport { closeAfterFailure } from \"../types\";\nimport { createLocalPgliteBackend } from \"./pglite\";\n// Type-only import: the option types are defined in `pglite-store.ts`, which\n// is this module's ONLY caller. A static value import in the other direction\n// would give `collectModuleEdges` a real edge from the store module to this\n// one, turning I12's `load` verdict dirty; a type-only import is erased at\n// runtime (no `verbatimModuleSyntax` in `tsconfig.base.json`), so this\n// back-edge never becomes a value cycle — the same precedent documented at\n// `src/errors/index.ts:26-29`.\nimport type { LocalPgliteStoreOptions } from \"./pglite-store\";\n\n/**\n * Drops a smuggled `schema` from the nested schema-management options: the\n * effective `SqlSchema` has exactly one source (`store.schema`), which also\n * drives physical table provisioning in this constructor.\n */\nfunction withoutSchemaOverride(\n  schemaManagement: Omit<SchemaManagerOptions, \"schema\"> | undefined,\n): Omit<SchemaManagerOptions, \"schema\"> {\n  if (schemaManagement === undefined) return {};\n  const { schema: smuggled, ...rest } =\n    schemaManagement as SchemaManagerOptions;\n  void smuggled;\n  return rest;\n}\n\n/** {@link createLocalPgliteStore}'s implementation body, verbatim from before the split. */\nexport async function createLocalPgliteStoreImpl<G extends GraphDef>(\n  graph: G,\n  options: LocalPgliteStoreOptions,\n): Promise<Store<G> | HistoryStore<G> | RecordedReadStore<G>> {\n  const tables =\n    options.store?.schema === undefined ?\n      undefined\n    : createPostgresTables(options.store.schema.tables);\n  const { backend } = await createLocalPgliteBackend({\n    ...(options.dataDir === undefined ? {} : { dataDir: options.dataDir }),\n    ...(options.vector === false ? { vector: false as const } : {}),\n    ...(options.fulltext === undefined ? {} : { fulltext: options.fulltext }),\n    ...(tables === undefined ? {} : { tables }),\n  });\n  try {\n    const [store] = await createStoreWithSchema(graph, backend, {\n      ...options.store,\n      // The type already excludes `schema` here; the runtime strip guards\n      // untyped callers, so the provisioned schema (or the default tables)\n      // can never diverge from the one the Store reads.\n      ...withoutSchemaOverride(options.schemaManagement),\n    });\n    return store;\n  } catch (error) {\n    return closeAfterFailure(backend, error);\n  }\n}\n"]}