{"version":3,"file":"native-clock.mjs","names":[],"sources":["../../src/drizzle/native-clock.ts"],"sourcesContent":["import type { ProofClock, SqlExpression } from \"@yielded/auth-persistence/Adapter\";\nimport { is, SQL, sql } from \"drizzle-orm\";\n\nexport type MappedClock = ProofClock<SQL> | ProofClock<SqlExpression>;\nexport type ClockMapping<M> = Omit<M, \"clock\"> & { readonly clock: MappedClock };\n\n/** Shared storage mappings already accept native expressions. Only a clock\n * declared with a real Drizzle SQL expression needs the foreign parameter bridge.\n * Never probe callbacks by executing and retrying them with another representation. */\nexport const nativeClock = (clock: MappedClock): ProofClock<SqlExpression> => {\n  if (!is(clock.engineNowMillis, SQL)) return clock as ProofClock<SqlExpression>;\n  // The physical expression identifies the callback family. This erases only\n  // foreign compiler variance; persisted times still use the declared codecs.\n  const drizzle = clock as ProofClock<SQL>;\n\n  return {\n    ...drizzle,\n    toMillis: (value) => drizzle.toMillis(sql`${sql.param(value)}`),\n    fromMillis: (value) => drizzle.fromMillis(sql`${sql.param(value)}`),\n  };\n};\n"],"mappings":";;;;;AASA,MAAa,eAAe,UAAkD;CAC5E,IAAI,CAAC,GAAG,MAAM,iBAAiB,GAAG,GAAG,OAAO;CAG5C,MAAM,UAAU;CAEhB,OAAO;EACL,GAAG;EACH,WAAW,UAAU,QAAQ,SAAS,GAAG,GAAG,IAAI,MAAM,KAAK,GAAG;EAC9D,aAAa,UAAU,QAAQ,WAAW,GAAG,GAAG,IAAI,MAAM,KAAK,GAAG;CACpE;AACF"}