{"version":3,"file":"table.mjs","names":[],"sources":["../../../../src/common/schema/sql/table.ts"],"sourcesContent":["import type { Infer, Type } from '../schema'\n\nexport interface Column<T = unknown> {\n  readonly _table: string\n  readonly _name: string\n  readonly _type: Type<T>\n  readonly __row?: T\n}\n\nexport type TableShape = Record<string, Type<any>>\n\nexport type TableColumns<N extends string, S extends TableShape> = {\n  readonly [K in keyof S & string]: Column<Infer<S[K]>>\n} & {\n  readonly _name: N\n  readonly _shape: S\n}\n\nexport function table<N extends string, S extends TableShape>(\n  name: N,\n  shape: S,\n): TableColumns<N, S> {\n  const out: any = { _name: name, _shape: shape }\n  for (const key of Object.keys(shape)) {\n    out[key] = {\n      _table: name,\n      _name: key,\n      _type: shape[key],\n    }\n  }\n  return out\n}\n\nexport function isColumn(v: any): v is Column {\n  return !!v && typeof v._table === 'string' && typeof v._name === 'string' && v._type\n}\n"],"mappings":";AAkBA,SAAgB,MACd,MACA,OACoB;CACpB,MAAM,MAAW;EAAE,OAAO;EAAM,QAAQ;EAAO;AAC/C,MAAK,MAAM,OAAO,OAAO,KAAK,MAAM,CAClC,KAAI,OAAO;EACT,QAAQ;EACR,OAAO;EACP,OAAO,MAAM;EACd;AAEH,QAAO;;AAGT,SAAgB,SAAS,GAAqB;AAC5C,QAAO,CAAC,CAAC,KAAK,OAAO,EAAE,WAAW,YAAY,OAAO,EAAE,UAAU,YAAY,EAAE"}