utils.d.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { SQL } from "../sql/sql.js";
  2. import { Subquery } from "../subquery.js";
  3. import { type Check } from "./checks.js";
  4. import type { AnyGelColumn } from "./columns/index.js";
  5. import { type ForeignKey } from "./foreign-keys.js";
  6. import type { Index } from "./indexes.js";
  7. import { GelPolicy } from "./policies.js";
  8. import { type PrimaryKey } from "./primary-keys.js";
  9. import { GelTable } from "./table.js";
  10. import { type UniqueConstraint } from "./unique-constraint.js";
  11. import type { GelViewBase } from "./view-base.js";
  12. import { type GelMaterializedView, type GelView } from "./view.js";
  13. export declare function getTableConfig<TTable extends GelTable>(table: TTable): {
  14. columns: import("./index.js").GelColumn<import("../column.js").ColumnBaseConfig<import("../column-builder.js").ColumnDataType, string>, {}, {}>[];
  15. indexes: Index[];
  16. foreignKeys: ForeignKey[];
  17. checks: Check[];
  18. primaryKeys: PrimaryKey[];
  19. uniqueConstraints: UniqueConstraint[];
  20. name: string;
  21. schema: string | undefined;
  22. policies: GelPolicy[];
  23. enableRLS: boolean;
  24. };
  25. export declare function extractUsedTable(table: GelTable | Subquery | GelViewBase | SQL): string[];
  26. export declare function getViewConfig<TName extends string = string, TExisting extends boolean = boolean>(view: GelView<TName, TExisting>): {
  27. with?: import("./view.js").ViewWithConfig;
  28. name: TName;
  29. originalName: TName;
  30. schema: string | undefined;
  31. selectedFields: import("../sql/sql.js").ColumnsSelection;
  32. isExisting: TExisting;
  33. query: TExisting extends true ? undefined : SQL<unknown>;
  34. isAlias: boolean;
  35. };
  36. export declare function getMaterializedViewConfig<TName extends string = string, TExisting extends boolean = boolean>(view: GelMaterializedView<TName, TExisting>): {
  37. with?: import("./view.js").GelMaterializedViewWithConfig;
  38. using?: string;
  39. tablespace?: string;
  40. withNoData?: boolean;
  41. name: TName;
  42. originalName: TName;
  43. schema: string | undefined;
  44. selectedFields: import("../sql/sql.js").ColumnsSelection;
  45. isExisting: TExisting;
  46. query: TExisting extends true ? undefined : SQL<unknown>;
  47. isAlias: boolean;
  48. };
  49. export type ColumnsWithTable<TTableName extends string, TForeignTableName extends string, TColumns extends AnyGelColumn<{
  50. tableName: TTableName;
  51. }>[]> = {
  52. [Key in keyof TColumns]: AnyGelColumn<{
  53. tableName: TForeignTableName;
  54. }>;
  55. };