pqb 0.15.1 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as orchid_core from 'orchid-core';
2
- import { QueryResultRow, AdapterBase, QueryInput, Sql, ColumnTypesBase, ColumnShapeOutput, DefaultSelectColumns, DbBase, QueryThen, QueryCatch, TransactionState, SQLQueryArgs, QueryBaseCommon, ColumnsShapeBase, QueryInternal, QueryMetaBase, EmptyObject, Expression, ColumnTypeBase, MaybeArray, TemplateLiteralArgs, ColumnsParsers, getValueKey, StringKey, NullableColumn, EmptyTuple, SetOptional, MergeObjects, RawSQLBase, RawSQLValues, RawSQLArgs, Spread, ColumnOperatorBase, ColumnOperatorFnBase, Code, ArrayMethodsData, arrayMethods, JSONTypeAny, record, BaseStringData, PrimaryKeyColumn, ForeignKeyTable, name, ColumnNameOfTable, BaseNumberData, ColumnWithDefault, numberTypeMethods, DateTypeMethods, DateColumnData, EncodeColumn, ParseColumn, ColumnDataBase, ValidationContext, MessageParam } from 'orchid-core';
2
+ import { QueryResultRow, AdapterBase, QueryInput, Sql, ColumnTypesBase, ColumnShapeOutput, DefaultSelectColumns, DbBase, QueryThen, QueryCatch, TransactionState, SQLQueryArgs, QueryBaseCommon, ColumnsShapeBase, QueryInternal, QueryMetaBase, EmptyObject, Expression, ColumnTypeBase, MaybeArray, TemplateLiteralArgs, ColumnsParsers, getValueKey, StringKey, NullableColumn, EmptyTuple, SetOptional, MergeObjects, RawSQLBase, RawSQLValues, RawSQLArgs, Spread, ColumnOperatorBase, ColumnOperatorFnBase, Code, ArrayMethodsData, arrayTypeMethods, JSONType, JSONUnknown, JSONTypes, StringTypeData, PrimaryKeyColumn, stringTypeMethods, ForeignKeyTable, name, ColumnNameOfTable, BaseNumberData, NumberTypeMethods, ColumnWithDefault, DateTypeMethods, DateColumnData, EncodeColumn, ParseColumn, ValidationContext, ErrorMessage, ColumnDataBase } from 'orchid-core';
3
3
  import { PoolConfig, Pool, PoolClient } from 'pg';
4
4
  import { inspect } from 'util';
5
5
  import { AsyncLocalStorage } from 'node:async_hooks';
@@ -123,6 +123,7 @@ type DbTableOptions = {
123
123
  autoPreparedStatements?: boolean;
124
124
  noPrimaryKey?: NoPrimaryKeyOption;
125
125
  snakeCase?: boolean;
126
+ language?: string;
126
127
  } & QueryLogOptions;
127
128
  declare const anyShape: Record<string, ColumnType<unknown, BaseOperators, unknown>>;
128
129
  interface Db<Table extends string | undefined = undefined, Shape extends ColumnsShape = Record<string, never>, Relations extends Query['relations'] = Query['relations'], CT extends ColumnTypesBase = DefaultColumnTypes, Data = Pick<ColumnShapeOutput<Shape>, DefaultSelectColumns<Shape>[number]>[]> extends DbBase<Adapter, Table, Shape, CT>, QueryMethods<CT> {
@@ -403,6 +404,38 @@ type JsonItem<As extends string = string, Type extends ColumnTypeBase = ColumnTy
403
404
  type SelectItem = string | RelationQuery | {
404
405
  selectAs: Record<string, string | Query | Expression>;
405
406
  } | JsonItem | Expression;
407
+ type OrderTsQueryConfig = true | {
408
+ coverDensity?: boolean;
409
+ weights?: number[];
410
+ normalization?: number;
411
+ dir?: SortDir;
412
+ };
413
+ type QuerySourceItem = {
414
+ queryAs: string;
415
+ as?: string;
416
+ textSQL?: MaybeArray<string>;
417
+ langSQL?: string;
418
+ vectorSQL?: string;
419
+ order?: OrderTsQueryConfig;
420
+ } & ({
421
+ language?: string;
422
+ } | {
423
+ languageColumn: string;
424
+ }) & ({
425
+ text: string | Expression;
426
+ } | {
427
+ in: MaybeArray<string> | Record<string, SearchWeight>;
428
+ } | {
429
+ vector: string;
430
+ }) & ({
431
+ query: string | Expression;
432
+ } | {
433
+ plainQuery: string | Expression;
434
+ } | {
435
+ phraseQuery: string | Expression;
436
+ } | {
437
+ tsQuery: string | Expression;
438
+ });
406
439
  type JoinItem = SimpleJoinItem | JoinLateralItem;
407
440
  type SimpleJoinItem = {
408
441
  type: string;
@@ -429,6 +462,7 @@ type WhereItem = (Omit<Record<string, unknown | Record<string, unknown | Query |
429
462
  IN?: MaybeArray<WhereInItem>;
430
463
  EXISTS?: MaybeArray<SimpleJoinItem['args']>;
431
464
  ON?: WhereOnItem | WhereJsonPathEqualsItem;
465
+ SEARCH?: MaybeArray<WhereSearchItem>;
432
466
  }) | ((q: unknown) => QueryBase) | Query | Expression;
433
467
  type WhereInItem = {
434
468
  columns: string[];
@@ -451,6 +485,11 @@ type WhereOnJoinItem = {
451
485
  as?: string;
452
486
  };
453
487
  } | string;
488
+ type SearchWeight = 'A' | 'B' | 'C' | 'D';
489
+ type WhereSearchItem = {
490
+ as: string;
491
+ vectorSQL: string;
492
+ };
454
493
  type SortDir = 'ASC' | 'DESC' | 'ASC NULLS FIRST' | 'DESC NULLS LAST';
455
494
  type OrderItem = string | Record<string, SortDir> | Expression;
456
495
  type ColumnOperators<S extends SelectableBase, Column extends keyof S> = {
@@ -494,6 +533,7 @@ type CommonQueryData = {
494
533
  select?: SelectItem[];
495
534
  as?: string;
496
535
  from?: string | Query | Expression;
536
+ sources?: Record<string, QuerySourceItem>;
497
537
  and?: WhereItem[];
498
538
  or?: WhereItem[][];
499
539
  coalesceValue?: unknown | Expression;
@@ -519,6 +559,7 @@ type CommonQueryData = {
519
559
  autoPreparedStatements?: boolean;
520
560
  [toSqlCacheKey]?: Sql;
521
561
  transform?: ((input: unknown) => unknown)[];
562
+ language?: string;
522
563
  };
523
564
  type SelectQueryData = CommonQueryData & {
524
565
  type: undefined;
@@ -665,16 +706,19 @@ declare class FnExpression<Q extends Query, T extends ColumnTypeBase> extends Ex
665
706
  })[];
666
707
  options: AggregateOptions<Q>;
667
708
  _type: T;
709
+ _mods: unknown[];
668
710
  constructor(q: Q, fn: string, args: (SelectableOrExpression<Q> | {
669
711
  pairs: Record<string, SelectableOrExpression<Q>>;
670
712
  } | {
671
713
  value: unknown;
672
714
  })[], options: AggregateOptions<Q>, _type: T);
715
+ modifySQL(sql: string, ctx: ToSqlCtx, quotedAs?: string): string;
673
716
  toSQL(ctx: ToSqlCtx, quotedAs?: string): string;
674
717
  }
675
718
  type ColumnExpression<C extends ColumnTypeBase, Ops extends BaseOperators = C['operators']> = Expression<C> & {
676
719
  [K in keyof Ops]: (arg: Parameters<Ops[K]>[1]) => ColumnExpression<BooleanNullable>;
677
720
  };
721
+ declare const makeColumnFnClass: <T extends ColumnType<unknown, BaseOperators, unknown>>(column: T) => typeof FnExpression;
678
722
  type FnExpressionArg<Q extends Query> = SelectableOrExpression<Q> | {
679
723
  pairs: Record<string, SelectableOrExpression<Q>>;
680
724
  } | {
@@ -691,7 +735,6 @@ type NullableJSONObject<T extends Query, Obj extends Record<string, SelectableOr
691
735
  }>>;
692
736
  type NullableText = NullableColumn<TextColumn>;
693
737
  declare class SelectAggMethods<T extends Query = Query> {
694
- _qbFor: Query;
695
738
  /**
696
739
  * `fn` allows to call an arbitrary SQL function.
697
740
  *
@@ -1464,16 +1507,315 @@ declare class OnQueryBuilder<S extends QueryBase = QueryBase, J extends QueryBas
1464
1507
  _onJsonPathEquals<T extends OnQueryBuilder>(this: T, ...args: OnJsonPathEqualsArgs<T>): T;
1465
1508
  }
1466
1509
 
1467
- type WhereArg<T extends QueryBase> = (Omit<{
1468
- [K in keyof T['selectable']]?: T['selectable'][K]['column']['type'] | null | ColumnOperators<T['selectable'], K> | Expression;
1469
- }, 'NOT' | 'OR' | 'IN' | 'EXISTS'> & {
1470
- NOT?: MaybeArray<WhereArg<T>>;
1471
- OR?: MaybeArray<WhereArg<T>>[];
1472
- IN?: MaybeArray<{
1510
+ declare module './aggregate' {
1511
+ interface SelectAggMethods<T extends Query> {
1512
+ /**
1513
+ * Give the `as` alias for the search, and it becomes possible to select a text with highlights of the matching words or phrases:
1514
+ *
1515
+ * ```ts
1516
+ * db.table
1517
+ * .search({
1518
+ * as: 'search',
1519
+ * in: 'body',
1520
+ * query: 'query',
1521
+ * })
1522
+ * .select({
1523
+ * highlightedText: (q) => q.headline('search'),
1524
+ * });
1525
+ * ```
1526
+ *
1527
+ * When searching in the generated `tsvector` column, need to provide a text source to the `headline`:
1528
+ *
1529
+ * ```ts
1530
+ * db.table
1531
+ * .search({
1532
+ * as: 'search',
1533
+ * vector: 'textVector',
1534
+ * query: 'query',
1535
+ * })
1536
+ * .select({
1537
+ * // `body` is a column name
1538
+ * highlightedText: (q) => q.headline('search', { text: 'body' }),
1539
+ * });
1540
+ * ```
1541
+ *
1542
+ * `text` can be a raw SQL, here we are joining multiple columns:
1543
+ *
1544
+ * ```ts
1545
+ * import { raw } from 'orchid-orm';
1546
+ *
1547
+ * db.table
1548
+ * .search({
1549
+ * as: 'search',
1550
+ * vector: 'titleAndBodyVector',
1551
+ * query: 'query',
1552
+ * })
1553
+ * .select({
1554
+ * highlightedText: (q) =>
1555
+ * q.headline('search', { text: raw`concat_ws(' ', title, body)` }),
1556
+ * });
1557
+ * ```
1558
+ *
1559
+ * `headline` supports a string for `options`, see details [in Postgres doc](https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE).
1560
+ *
1561
+ * Provide a simple string or a raw SQL:
1562
+ *
1563
+ * ```ts
1564
+ * db.table
1565
+ * .search({
1566
+ * as: 'search',
1567
+ * in: 'body',
1568
+ * query: 'query',
1569
+ * })
1570
+ * .select({
1571
+ * highlightedText: (q) =>
1572
+ * q.headline('search', {
1573
+ * options:
1574
+ * 'MaxFragments=10, MaxWords=7, MinWords=3, StartSel=<<, StopSel=>>',
1575
+ * }),
1576
+ * });
1577
+ * ```
1578
+ *
1579
+ * @param search - name of the search to use the query from
1580
+ * @param options - `text` for a text source, `options` for `ts_headline` options
1581
+ */
1582
+ headline(search: string | undefined extends T['meta']['tsQuery'] ? never : Exclude<T['meta']['tsQuery'], undefined>, options?: {
1583
+ text?: SelectableOrExpressionOfType<T, TextColumn>;
1584
+ options?: string | Expression;
1585
+ }): ColumnExpression<TextColumn>;
1586
+ }
1587
+ }
1588
+ type SearchArg<T extends QueryBase, As extends string> = {
1589
+ as?: As;
1590
+ order?: OrderTsQueryConfig;
1591
+ } & ({
1592
+ language?: string | Expression;
1593
+ } | {
1594
+ languageColumn?: keyof T['selectable'];
1595
+ }) & ({
1596
+ text: string | Expression;
1597
+ } | {
1598
+ in: MaybeArray<keyof T['selectable']> | {
1599
+ [K in keyof T['selectable']]?: SearchWeight;
1600
+ };
1601
+ } | {
1602
+ vector: {
1603
+ [K in keyof T['selectable']]: T['selectable'][K]['column']['dataType'] extends 'tsvector' ? K : never;
1604
+ }[keyof T['selectable']];
1605
+ }) & ({
1606
+ query: string | Expression;
1607
+ } | {
1608
+ plainQuery: string | Expression;
1609
+ } | {
1610
+ phraseQuery: string | Expression;
1611
+ } | {
1612
+ tsQuery: string | Expression;
1613
+ });
1614
+ type WhereSearchResult<T extends QueryBase, As extends string> = T & {
1615
+ meta: {
1616
+ tsQuery: string extends As ? never : As;
1617
+ };
1618
+ };
1619
+ declare const saveSearchAlias: (q: QueryBase, as: string) => string;
1620
+ declare class SearchMethods {
1621
+ /**
1622
+ * ## language
1623
+ *
1624
+ * By default, the search language is English.
1625
+ *
1626
+ * You can set a different default language in the `createBaseTable` config:
1627
+ *
1628
+ * ```ts
1629
+ * import { createBaseTable } from 'orchid-orm';
1630
+ *
1631
+ * export const BaseTable = createBaseTable({
1632
+ * language: 'swedish',
1633
+ * });
1634
+ * ```
1635
+ *
1636
+ * See the list of supported language configs with the SQL:
1637
+ *
1638
+ * ```sql
1639
+ * SELECT cfgname FROM pg_ts_config;
1640
+ * ```
1641
+ *
1642
+ * When performing a search, you can override the default language:
1643
+ *
1644
+ * ```ts
1645
+ * db.table.search({
1646
+ * language: 'finnish',
1647
+ * in: 'body',
1648
+ * query: 'query',
1649
+ * });
1650
+ * ```
1651
+ *
1652
+ * `language` also accepts a raw SQL.
1653
+ *
1654
+ * The language can be stored in the column of this table, then you can use `languageColumn` to use this column for the search:
1655
+ *
1656
+ * ```ts
1657
+ * db.table.search({
1658
+ * // the table has `lang` column, use it for the search
1659
+ * languageColumn: 'lang',
1660
+ * in: 'body',
1661
+ * query: 'query',
1662
+ * });
1663
+ * ```
1664
+ *
1665
+ * ## text vector to search in
1666
+ *
1667
+ * The text to search in can be a simple string, or a raw SQL, or a text column, or multiple columns:
1668
+ *
1669
+ * ```ts
1670
+ * db.table.search({
1671
+ * // search in the given string
1672
+ * text: 'simply a string to search in',
1673
+ * query: 'query',
1674
+ * });
1675
+ *
1676
+ * import { raw } from 'orchid-orm';
1677
+ *
1678
+ * db.table.search({
1679
+ * // raw SQL: join text columns with space
1680
+ * text: raw`concat_ws(' ', title, body)`,
1681
+ * query: 'query',
1682
+ * });
1683
+ *
1684
+ * db.table.search({
1685
+ * // search in a single text column
1686
+ * in: 'body',
1687
+ * query: 'query',
1688
+ * });
1689
+ *
1690
+ * db.table.search({
1691
+ * // search in multiple columns, they are concatenated with `concat_ws` as shown above
1692
+ * in: ['title', 'body'],
1693
+ * query: 'query',
1694
+ * });
1695
+ *
1696
+ * db.table.search({
1697
+ * // search in multiple columns with different weights. Weight can be A, B, C, or D
1698
+ * in: {
1699
+ * title: 'A',
1700
+ * body: 'B',
1701
+ * },
1702
+ * query: 'query',
1703
+ * });
1704
+ * ```
1705
+ *
1706
+ * For better performance, define a [generated](/guide/migration-column-methods.html#generated) column of `tsvector` type, and use it in the search with `vector` keyword:
1707
+ *
1708
+ * ```ts
1709
+ * db.table.search({
1710
+ * vector: 'titleAndBodyVector',
1711
+ * query: 'query',
1712
+ * });
1713
+ * ```
1714
+ *
1715
+ * ## search query
1716
+ *
1717
+ * Read about different search queries in [this Postgres doc](https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES).
1718
+ *
1719
+ * `search` method can accept one of the following queries:
1720
+ *
1721
+ * - `query`: corresponds to `websearch_to_tsquery` in Postgres, good to use by default
1722
+ * - `plainQuery`: corresponds to `plainto_tsquery`
1723
+ * - `phraseQuery`: corresponds to `phraseto_tsquery`
1724
+ * - `tsQuery`: corresponds to `to_tsquery`
1725
+ *
1726
+ * The `query` (`websearch_to_tsquery`) can work with any user input, while other query kinds require a specific format and will fail for invalid input.
1727
+ *
1728
+ * Each query kind accepts a string or a raw SQL.
1729
+ *
1730
+ * ```ts
1731
+ * import { raw } from 'orchid-orm';
1732
+ *
1733
+ * db.table.search({
1734
+ * vector: 'titleAndBodyVector',
1735
+ * // can accept raw SQL:
1736
+ * phraseQuery: raw`'The Fat Rats'`,
1737
+ * });
1738
+ * ```
1739
+ *
1740
+ * ## order by search rank
1741
+ *
1742
+ * Read about search ranking in [this Postgres doc](https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-RANKING).
1743
+ *
1744
+ * Set `order: true` to order results by the search rank:
1745
+ *
1746
+ * ```ts
1747
+ * db.table.search({
1748
+ * in: 'body',
1749
+ * query: 'query',
1750
+ * // will add ORDER BY ts_rank(to_tsvector('english', body)) DESC
1751
+ * order: true,
1752
+ * });
1753
+ * ```
1754
+ *
1755
+ * To order with `ts_rank_cd` instead of `ts_rank`, set `coverDensity: true`:
1756
+ *
1757
+ * ```ts
1758
+ * db.table.search({
1759
+ * in: 'body',
1760
+ * query: 'query',
1761
+ * // will add ORDER BY ts_rank_cd(to_tsvector('english', body)) DESC
1762
+ * order: {
1763
+ * coverDensity: true,
1764
+ * },
1765
+ * });
1766
+ * ```
1767
+ *
1768
+ * Other options are:
1769
+ *
1770
+ * ```ts
1771
+ * db.table.search({
1772
+ * in: 'body',
1773
+ * query: 'query',
1774
+ * order: {
1775
+ * // weights for D, C, B, A:
1776
+ * weights: [0.1, 0.2, 0.4, 1],
1777
+ * // by default, rank ignores the document length
1778
+ * // change rank behavior by providing here a special number
1779
+ * normalization: 32,
1780
+ * // it's possible to change the order direction:
1781
+ * dir: 'ASC', // DESC by default
1782
+ * },
1783
+ * });
1784
+ * ```
1785
+ *
1786
+ * Giving the `as` alias for the search allows to set the ordering in the `order` method:
1787
+ *
1788
+ * ```ts
1789
+ * db.table
1790
+ * .search({
1791
+ * as: 'search',
1792
+ * in: 'body',
1793
+ * query: 'query',
1794
+ * })
1795
+ * .order({
1796
+ * // can be `search: true` for defaults
1797
+ * search: {
1798
+ * // same options as above
1799
+ * coverDensity: true,
1800
+ * weights: [0.1, 0.2, 0.4, 1.0],
1801
+ * normalization: 32,
1802
+ * dir: 'ASC',
1803
+ * },
1804
+ * });
1805
+ * ```
1806
+ *
1807
+ * @param arg - search config
1808
+ */
1809
+ search<T extends Query, As extends string>(this: T, arg: SearchArg<T, As>): WhereSearchResult<T, As>;
1810
+ _search<T extends Query, As extends string>(this: T, arg: SearchArg<T, As>): WhereSearchResult<T, As>;
1811
+ }
1812
+
1813
+ type WhereArg<T extends QueryBase> = {
1814
+ [K in keyof T['selectable'] | 'NOT' | 'OR' | 'IN' | 'EXISTS' | 'SEARCH']?: K extends 'NOT' ? MaybeArray<WhereArg<T>> : K extends 'OR' ? MaybeArray<WhereArg<T>>[] : K extends 'IN' ? MaybeArray<{
1473
1815
  columns: (keyof T['selectable'])[];
1474
1816
  values: unknown[][] | Query | Expression;
1475
- }>;
1476
- }) | QueryBase | Expression | ((q: WhereQueryBuilder<T>) => WhereQueryBuilder);
1817
+ }> : K extends 'SEARCH' ? MaybeArray<SearchArg<T, never>> : K extends keyof T['selectable'] ? T['selectable'][K]['column']['type'] | null | ColumnOperators<T['selectable'], K> | Expression : never;
1818
+ } | QueryBase | Expression | ((q: WhereQueryBuilder<T>) => WhereQueryBuilder);
1477
1819
  type WhereArgs<T extends QueryBase> = WhereArg<T>[] | TemplateLiteralArgs;
1478
1820
  type WhereInColumn<T extends QueryBase> = keyof T['selectable'] | [keyof T['selectable'], ...(keyof T['selectable'])[]];
1479
1821
  type WhereInValues<T extends QueryBase, Column extends WhereInColumn<T>> = Column extends keyof T['selectable'] ? T['selectable'][Column]['column']['type'][] | Query | Expression : ({
@@ -1491,7 +1833,7 @@ type WhereResult<T extends QueryBase> = T & {
1491
1833
  type WhereInArg<T extends Pick<Query, 'selectable'>> = {
1492
1834
  [K in keyof T['selectable']]?: T['selectable'][K]['column']['type'][] | Query | Expression;
1493
1835
  };
1494
- declare const addWhere: <T extends Where>(q: T, args: WhereArgs<T>) => WhereResult<T>;
1836
+ declare const addWhere: <T extends QueryBase>(q: T, args: WhereArgs<T>) => WhereResult<T>;
1495
1837
  declare const addWhereNot: <T extends QueryBase>(q: T, args: WhereArgs<T>) => WhereResult<T>;
1496
1838
  declare const addOr: <T extends QueryBase>(q: T, args: WhereArg<T>[]) => WhereResult<T>;
1497
1839
  declare const addOrNot: <T extends QueryBase>(q: T, args: WhereArg<T>[]) => WhereResult<T>;
@@ -3342,39 +3684,24 @@ declare const raw: <T = unknown>(...args: RawSQLArgs) => RawSQL<ColumnTypeBase<T
3342
3684
  tsquery(): TsQueryColumn;
3343
3685
  uuid(): UUIDColumn;
3344
3686
  xml(): XMLColumn;
3345
- json<Type extends orchid_core.JSONTypeAny>(schemaOrFn: Type | ((j: {
3346
- set: <Value extends orchid_core.JSONTypeAny>(valueType: Value) => orchid_core.JSONSet<Value>;
3347
- tuple: <T_6 extends [] | orchid_core.JSONTupleItems, Rest extends orchid_core.JSONTypeAny | null = null>(items: T_6, rest?: Rest) => orchid_core.JSONTuple<T_6, Rest>;
3348
- union: <T_7 extends [orchid_core.JSONTypeAny, orchid_core.JSONTypeAny, ...orchid_core.JSONTypeAny[]]>(types: T_7) => orchid_core.JSONUnion<T_7>;
3349
- any: () => orchid_core.JSONAny;
3350
- bigint: () => orchid_core.JSONBigInt;
3687
+ json<Type extends orchid_core.JSONType<unknown, {}> = orchid_core.JSONUnknown>(schemaOrFn?: Type | ((j: {
3688
+ unknown: () => orchid_core.JSONUnknown;
3351
3689
  boolean: () => orchid_core.JSONBoolean;
3352
- date: () => orchid_core.JSONDate;
3353
- nan: () => orchid_core.JSONNaN;
3354
- never: () => orchid_core.JSONNever;
3355
3690
  null: () => orchid_core.JSONNull;
3356
3691
  number: () => orchid_core.JSONNumber;
3357
3692
  string: () => orchid_core.JSONString;
3358
- unknown: () => orchid_core.JSONUnknown;
3359
- array: <Type_1 extends orchid_core.JSONTypeAny>(element: Type_1) => orchid_core.JSONArray<Type_1, "many">;
3360
- discriminatedUnion: <Discriminator extends string, DiscriminatorValue extends orchid_core.Primitive, Types extends [orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, ...orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>[]]>(discriminator: Discriminator, options: Types) => orchid_core.JSONDiscriminatedUnion<Discriminator, DiscriminatorValue, Types>;
3361
- enum: <U_1 extends string, T_8 extends [U_1, ...U_1[]]>(options: T_8) => orchid_core.JSONEnum<U_1, T_8>;
3362
- instanceOf: <T_9 extends new (...args: any[]) => any>(cls: T_9) => orchid_core.JSONInstanceOf<T_9>;
3363
- intersection: <Left extends orchid_core.JSONTypeAny, Right extends orchid_core.JSONTypeAny>(left: Left, right: Right) => orchid_core.JSONIntersection<Left, Right>;
3364
- lazy: <T_10 extends orchid_core.JSONTypeAny>(fn: () => T_10) => orchid_core.JSONLazy<T_10>;
3365
- literal: <T_11 extends orchid_core.Primitive>(value: T_11) => orchid_core.JSONLiteral<T_11>;
3366
- map: <Key extends orchid_core.JSONTypeAny, Value_1 extends orchid_core.JSONTypeAny>(keyType: Key, valueType: Value_1) => orchid_core.JSONMap<Key, Value_1>;
3367
- nativeEnum: <T_12 extends orchid_core.EnumLike>(givenEnum: T_12) => orchid_core.JSONNativeEnum<T_12>;
3368
- nullable: <T_13 extends orchid_core.JSONTypeAny>(type: T_13) => orchid_core.JSONNullable<T_13>;
3369
- nullish: <T_14 extends orchid_core.JSONTypeAny>(type: T_14) => orchid_core.JSONNullish<T_14>;
3370
- object: <T_15 extends orchid_core.JSONObjectShape, UnknownKeys extends orchid_core.UnknownKeysParam = "strip", Catchall extends orchid_core.JSONTypeAny = orchid_core.JSONTypeAny>(shape: T_15) => orchid_core.JSONObject<T_15, UnknownKeys, Catchall, orchid_core.JSONTypeAny extends Catchall ? orchid_core.addQuestionMarks<{ [k_1 in keyof T_15]: T_15[k_1]["type"]; }> extends infer T_16 extends object ? { [k in keyof T_16]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_15]: T_15[k_1]["type"]; }>[k]; } : never : (orchid_core.addQuestionMarks<{ [k_1 in keyof T_15]: T_15[k_1]["type"]; }> extends infer T_19 extends object ? { [k in keyof T_19]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_15]: T_15[k_1]["type"]; }>[k]; } : never) & {
3371
- [k: string]: Catchall["type"];
3372
- } extends infer T_17 extends object ? { [k_2 in keyof T_17]: ((orchid_core.addQuestionMarks<{ [k_1 in keyof T_15]: T_15[k_1]["type"]; }> extends infer T_18 extends object ? { [k in keyof T_18]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_15]: T_15[k_1]["type"]; }>[k]; } : never) & {
3373
- [k: string]: Catchall["type"];
3374
- })[k_2]; } : never>;
3375
- optional: <T_20 extends orchid_core.JSONTypeAny>(type: T_20) => orchid_core.JSONOptional<T_20>;
3376
- record: typeof orchid_core.record;
3377
- }) => Type)): JSONColumn<Type>;
3693
+ array: <T_6 extends orchid_core.JSONType<unknown, {}>>(item: T_6) => orchid_core.JSONArray<T_6, "many">;
3694
+ object: <Shape extends orchid_core.JSONObjectShape>(shape: Shape) => orchid_core.JSONObject<Shape, "strip", orchid_core.JSONType<unknown, {}>>;
3695
+ literal: <T_7 extends orchid_core.JSONPrimitive>(value: T_7) => orchid_core.JSONLiteral<T_7>;
3696
+ discriminatedUnion: <Discriminator extends string, Types extends orchid_core.JSONDiscriminatedUnionArg<Discriminator>>(discriminator: Discriminator, types: Types) => orchid_core.JSONDiscriminatedUnion<Discriminator, Types>;
3697
+ enum: <U_1 extends string, T_8 extends [U_1, ...U_1[]]>(options: T_8) => orchid_core.JSONEnum<string, T_8>;
3698
+ intersection: <Left extends orchid_core.JSONType<unknown, {}>, Right extends orchid_core.JSONType<unknown, {}>>(left: Left, right: Right) => orchid_core.JSONIntersection<Left, Right>;
3699
+ lazy: <T_9 extends orchid_core.JSONType<unknown, {}>>(fn: () => T_9) => orchid_core.JSONLazy<T_9>;
3700
+ nativeEnum: <T_10 extends orchid_core.EnumLike>(type: T_10) => orchid_core.JSONNativeEnum<T_10>;
3701
+ record: <Key extends orchid_core.JSONNumber | orchid_core.JSONString, Value extends orchid_core.JSONType<unknown, {}>>(...args: [value: Value] | [key: Key, value: Value]) => orchid_core.JSONRecord<Key, Value>;
3702
+ tuple: <T_11 extends orchid_core.JSONTupleItems, Rest extends orchid_core.JSONType<unknown, {}> | undefined = undefined>(items: T_11, rest?: Rest | undefined) => orchid_core.JSONTuple<T_11, Rest>;
3703
+ union: <T_12 extends orchid_core.JSONUnionArgs>(...types: T_12) => orchid_core.JSONUnion<T_12>;
3704
+ }) => Type) | undefined): JSONColumn<Type>;
3378
3705
  jsonText(): JSONTextColumn;
3379
3706
  array<Item extends ColumnType<unknown, BaseOperators, unknown>>(item: Item): ArrayColumn<Item>;
3380
3707
  type(dataType: string): CustomTypeColumn;
@@ -3383,7 +3710,8 @@ declare const raw: <T = unknown>(...args: RawSQLArgs) => RawSQL<ColumnTypeBase<T
3383
3710
  name?: string | undefined;
3384
3711
  } | undefined): {};
3385
3712
  index(columns: orchid_core.MaybeArray<string | IndexColumnOptions>, options?: IndexOptions): {};
3386
- unique(columns: orchid_core.MaybeArray<string | IndexColumnOptions>, options?: IndexOptions): {};
3713
+ unique(columns: orchid_core.MaybeArray<string | IndexColumnOptions>, options?: IndexOptions | undefined): {};
3714
+ searchIndex(columns: orchid_core.MaybeArray<string | IndexColumnOptions>, options?: IndexOptions | undefined): {};
3387
3715
  constraint<Table extends string | (() => orchid_core.ForeignKeyTable), Columns extends Table extends () => orchid_core.ForeignKeyTable ? [orchid_core.ColumnNameOfTable<ReturnType<Table>>, ...orchid_core.ColumnNameOfTable<ReturnType<Table>>[]] : [string, ...string[]]>({ name, references, check, dropMode, }: {
3388
3716
  name?: string | undefined;
3389
3717
  references?: [columns: string[], fnOrTable: Table, foreignColumns: Columns, options?: ForeignKeyOptions | undefined] | undefined;
@@ -3629,17 +3957,17 @@ type WindowArgDeclaration<T extends Query = Query> = {
3629
3957
  type WindowResult<T extends Query, W extends WindowArg<T>> = T & {
3630
3958
  windows: Record<keyof W, true>;
3631
3959
  };
3632
- type OrderArg<T extends Query, Key extends PropertyKey = keyof T['selectable'] | {
3960
+ type OrderArg<T extends Query, TsQuery extends PropertyKey = string | undefined extends T['meta']['tsQuery'] ? never : Exclude<T['meta']['tsQuery'], undefined>, Key extends PropertyKey = keyof T['selectable'] | {
3633
3961
  [K in keyof T['result']]: T['result'][K]['dataType'] extends 'array' | 'object' ? never : K;
3634
- }[keyof T['result']]> = Key | {
3635
- [K in Key]?: SortDir;
3962
+ }[keyof T['result']] | TsQuery> = Key | {
3963
+ [K in Key]?: K extends TsQuery ? OrderTsQueryConfig : SortDir;
3636
3964
  } | Expression;
3637
3965
  type OrderArgs<T extends Query> = OrderArg<T>[] | TemplateLiteralArgs;
3638
3966
  type FindArgs<T extends Query> = [T['shape'][T['singlePrimaryKey']]['type'] | Expression] | TemplateLiteralArgs;
3639
3967
  type QueryHelper<T extends Query, Args extends unknown[], Result> = <Q extends {
3640
3968
  [K in keyof T]: K extends 'then' ? QueryThen<unknown> : K extends 'result' ? ColumnsShapeBase : T[K];
3641
3969
  }>(q: Q, ...args: Args) => Result extends Query ? MergeQuery<Q, Result> : Result;
3642
- interface QueryMethods<CT extends ColumnTypesBase> extends Omit<AsMethods, 'result'>, AggregateMethods, Select, From, Join, With, Union, Omit<JsonModifiers, 'result'>, JsonMethods, Create, Update, Delete, Transaction, For, ColumnInfoMethods, Omit<Where, 'result'>, Clear, Having, Then, QueryLog, Omit<QueryHooks, 'result'>, QueryUpsertOrCreate, QueryGet, MergeQueryMethods, RawSqlMethods<CT>, CopyMethods, TransformMethods {
3970
+ interface QueryMethods<CT extends ColumnTypesBase> extends Omit<AsMethods, 'result'>, AggregateMethods, Select, From, Join, With, Union, Omit<JsonModifiers, 'result'>, JsonMethods, Create, Update, Delete, Transaction, For, ColumnInfoMethods, Omit<Where, 'result'>, SearchMethods, Clear, Having, Then, QueryLog, Omit<QueryHooks, 'result'>, QueryUpsertOrCreate, QueryGet, MergeQueryMethods, RawSqlMethods<CT>, CopyMethods, TransformMethods {
3643
3971
  }
3644
3972
  declare class QueryMethods<CT extends ColumnTypesBase> {
3645
3973
  /**
@@ -4235,7 +4563,7 @@ declare class DomainColumn extends CustomTypeColumn {
4235
4563
  type ArrayData<Item extends ColumnTypeBase> = ColumnData & ArrayMethodsData & {
4236
4564
  item: Item;
4237
4565
  };
4238
- type ArrayMethods = typeof arrayMethods;
4566
+ type ArrayMethods = typeof arrayTypeMethods;
4239
4567
  interface ArrayColumn<Item extends ColumnTypeBase> extends ColumnType<Item['type'][], typeof Operators.array>, ArrayMethods {
4240
4568
  }
4241
4569
  declare class ArrayColumn<Item extends ColumnTypeBase> extends ColumnType<Item['type'][], typeof Operators.array> {
@@ -4255,41 +4583,7 @@ declare class ArrayColumn<Item extends ColumnTypeBase> extends ColumnType<Item['
4255
4583
  };
4256
4584
  }
4257
4585
 
4258
- type JSONTypes = typeof jsonTypes;
4259
- declare const jsonTypes: {
4260
- set: <Value extends JSONTypeAny>(valueType: Value) => orchid_core.JSONSet<Value>;
4261
- tuple: <T extends [] | orchid_core.JSONTupleItems, Rest extends JSONTypeAny | null = null>(items: T, rest?: Rest) => orchid_core.JSONTuple<T, Rest>;
4262
- union: <T_1 extends [JSONTypeAny, JSONTypeAny, ...JSONTypeAny[]]>(types: T_1) => orchid_core.JSONUnion<T_1>;
4263
- any: () => orchid_core.JSONAny;
4264
- bigint: () => orchid_core.JSONBigInt;
4265
- boolean: () => orchid_core.JSONBoolean;
4266
- date: () => orchid_core.JSONDate;
4267
- nan: () => orchid_core.JSONNaN;
4268
- never: () => orchid_core.JSONNever;
4269
- null: () => orchid_core.JSONNull;
4270
- number: () => orchid_core.JSONNumber;
4271
- string: () => orchid_core.JSONString;
4272
- unknown: () => orchid_core.JSONUnknown;
4273
- array: <Type extends JSONTypeAny>(element: Type) => orchid_core.JSONArray<Type, "many">;
4274
- discriminatedUnion: <Discriminator extends string, DiscriminatorValue extends orchid_core.Primitive, Types extends [orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, ...orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>[]]>(discriminator: Discriminator, options: Types) => orchid_core.JSONDiscriminatedUnion<Discriminator, DiscriminatorValue, Types>;
4275
- enum: <U extends string, T_2 extends [U, ...U[]]>(options: T_2) => orchid_core.JSONEnum<U, T_2>;
4276
- instanceOf: <T_3 extends new (...args: any[]) => any>(cls: T_3) => orchid_core.JSONInstanceOf<T_3>;
4277
- intersection: <Left extends JSONTypeAny, Right extends JSONTypeAny>(left: Left, right: Right) => orchid_core.JSONIntersection<Left, Right>;
4278
- lazy: <T_4 extends JSONTypeAny>(fn: () => T_4) => orchid_core.JSONLazy<T_4>;
4279
- literal: <T_5 extends orchid_core.Primitive>(value: T_5) => orchid_core.JSONLiteral<T_5>;
4280
- map: <Key extends JSONTypeAny, Value_1 extends JSONTypeAny>(keyType: Key, valueType: Value_1) => orchid_core.JSONMap<Key, Value_1>;
4281
- nativeEnum: <T_6 extends orchid_core.EnumLike>(givenEnum: T_6) => orchid_core.JSONNativeEnum<T_6>;
4282
- nullable: <T_7 extends JSONTypeAny>(type: T_7) => orchid_core.JSONNullable<T_7>;
4283
- nullish: <T_8 extends JSONTypeAny>(type: T_8) => orchid_core.JSONNullish<T_8>;
4284
- object: <T_9 extends orchid_core.JSONObjectShape, UnknownKeys extends orchid_core.UnknownKeysParam = "strip", Catchall extends JSONTypeAny = JSONTypeAny>(shape: T_9) => orchid_core.JSONObject<T_9, UnknownKeys, Catchall, JSONTypeAny extends Catchall ? orchid_core.addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }> extends infer T_10 extends object ? { [k in keyof T_10]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }>[k]; } : never : (orchid_core.addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }> extends infer T_13 extends object ? { [k in keyof T_13]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }>[k]; } : never) & {
4285
- [k: string]: Catchall["type"];
4286
- } extends infer T_11 extends object ? { [k_2 in keyof T_11]: ((orchid_core.addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }> extends infer T_12 extends object ? { [k in keyof T_12]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }>[k]; } : never) & {
4287
- [k: string]: Catchall["type"];
4288
- })[k_2]; } : never>;
4289
- optional: <T_14 extends JSONTypeAny>(type: T_14) => orchid_core.JSONOptional<T_14>;
4290
- record: typeof record;
4291
- };
4292
- declare class JSONColumn<Type extends JSONTypeAny = JSONTypeAny> extends ColumnType<Type['type'], typeof Operators.json> {
4586
+ declare class JSONColumn<Type extends JSONType = JSONUnknown> extends ColumnType<Type['type'], typeof Operators.json> {
4293
4587
  dataType: "jsonb";
4294
4588
  operators: {
4295
4589
  jsonPath: Operator<[path: string, op: string, value: unknown]>;
@@ -4355,205 +4649,8 @@ declare class BooleanColumn extends ColumnType<boolean, typeof Operators.boolean
4355
4649
  type BooleanNullable = NullableColumn<BooleanColumn>;
4356
4650
 
4357
4651
  type StringColumn = ColumnType<string, typeof Operators.text>;
4358
- type TextColumnData = BaseStringData;
4359
- type TextMethods = typeof textMethods;
4360
- declare const textMethods: {
4361
- email<T extends {
4362
- data: {
4363
- email?: boolean | undefined;
4364
- };
4365
- }>(this: T, params?: orchid_core.MessageParam | undefined): Omit<T, "data"> & {
4366
- data: Omit<T["data"], "email"> & {
4367
- email: boolean;
4368
- };
4369
- };
4370
- url<T_1 extends {
4371
- data: {
4372
- url?: boolean | undefined;
4373
- };
4374
- }>(this: T_1, params?: orchid_core.MessageParam | undefined): Omit<T_1, "data"> & {
4375
- data: Omit<T_1["data"], "url"> & {
4376
- url: boolean;
4377
- };
4378
- };
4379
- emoji<T_2 extends {
4380
- data: {
4381
- emoji?: boolean | undefined;
4382
- };
4383
- }>(this: T_2, params?: orchid_core.MessageParam | undefined): Omit<T_2, "data"> & {
4384
- data: Omit<T_2["data"], "emoji"> & {
4385
- emoji: boolean;
4386
- };
4387
- };
4388
- uuid<T_3 extends {
4389
- data: {
4390
- uuid?: boolean | undefined;
4391
- };
4392
- }>(this: T_3, params?: orchid_core.MessageParam | undefined): Omit<T_3, "data"> & {
4393
- data: Omit<T_3["data"], "uuid"> & {
4394
- uuid: boolean;
4395
- };
4396
- };
4397
- cuid<T_4 extends {
4398
- data: {
4399
- cuid?: boolean | undefined;
4400
- };
4401
- }>(this: T_4, params?: orchid_core.MessageParam | undefined): Omit<T_4, "data"> & {
4402
- data: Omit<T_4["data"], "cuid"> & {
4403
- cuid: boolean;
4404
- };
4405
- };
4406
- cuid2<T_5 extends {
4407
- data: {
4408
- cuid2?: boolean | undefined;
4409
- };
4410
- }>(this: T_5, params?: orchid_core.MessageParam | undefined): Omit<T_5, "data"> & {
4411
- data: Omit<T_5["data"], "cuid2"> & {
4412
- cuid2: boolean;
4413
- };
4414
- };
4415
- ulid<T_6 extends {
4416
- data: {
4417
- ulid?: boolean | undefined;
4418
- };
4419
- }>(this: T_6, params?: orchid_core.MessageParam | undefined): Omit<T_6, "data"> & {
4420
- data: Omit<T_6["data"], "ulid"> & {
4421
- ulid: boolean;
4422
- };
4423
- };
4424
- regex<T_7 extends {
4425
- data: {
4426
- regex?: RegExp | undefined;
4427
- };
4428
- }, Value extends RegExp>(this: T_7, value: Value, params?: orchid_core.MessageParam | undefined): Omit<T_7, "data"> & {
4429
- data: Omit<T_7["data"], "regex"> & {
4430
- regex: Value;
4431
- };
4432
- };
4433
- includes<T_8 extends {
4434
- data: {
4435
- includes?: string | undefined;
4436
- };
4437
- }, Value_1 extends string>(this: T_8, value: Value_1, params?: orchid_core.MessageParam | undefined): Omit<T_8, "data"> & {
4438
- data: Omit<T_8["data"], "includes"> & {
4439
- includes: Value_1;
4440
- };
4441
- };
4442
- startsWith<T_9 extends {
4443
- data: {
4444
- startsWith?: string | undefined;
4445
- };
4446
- }, Value_2 extends string>(this: T_9, value: Value_2, params?: orchid_core.MessageParam | undefined): Omit<T_9, "data"> & {
4447
- data: Omit<T_9["data"], "startsWith"> & {
4448
- startsWith: Value_2;
4449
- };
4450
- };
4451
- endsWith<T_10 extends {
4452
- data: {
4453
- endsWith?: string | undefined;
4454
- };
4455
- }, Value_3 extends string>(this: T_10, value: Value_3, params?: orchid_core.MessageParam | undefined): Omit<T_10, "data"> & {
4456
- data: Omit<T_10["data"], "endsWith"> & {
4457
- endsWith: Value_3;
4458
- };
4459
- };
4460
- datetime<T_11 extends {
4461
- data: {
4462
- datetime?: {
4463
- offset?: boolean | undefined;
4464
- precision?: number | undefined;
4465
- } | undefined;
4466
- };
4467
- }>(this: T_11, params?: {
4468
- offset?: boolean | undefined;
4469
- precision?: number | undefined;
4470
- } & {
4471
- message?: string | undefined;
4472
- }): Omit<T_11, "data"> & {
4473
- data: Omit<T_11["data"], "datetime"> & {
4474
- datetime: {
4475
- offset?: boolean | undefined;
4476
- precision?: number | undefined;
4477
- } & {
4478
- message?: string | undefined;
4479
- };
4480
- };
4481
- };
4482
- ip<T_12 extends {
4483
- data: {
4484
- ip?: {
4485
- version?: "v4" | "v6" | undefined;
4486
- } | undefined;
4487
- };
4488
- }>(this: T_12, params?: {
4489
- version?: "v4" | "v6" | undefined;
4490
- } & {
4491
- message?: string | undefined;
4492
- }): Omit<T_12, "data"> & {
4493
- data: Omit<T_12["data"], "ip"> & {
4494
- ip: {
4495
- version?: "v4" | "v6" | undefined;
4496
- } & {
4497
- message?: string | undefined;
4498
- };
4499
- };
4500
- };
4501
- trim<T_13 extends {
4502
- data: {
4503
- trim?: boolean | undefined;
4504
- };
4505
- }>(this: T_13, params?: orchid_core.MessageParam | undefined): Omit<T_13, "data"> & {
4506
- data: Omit<T_13["data"], "trim"> & {
4507
- trim: boolean;
4508
- };
4509
- };
4510
- toLowerCase<T_14 extends {
4511
- data: {
4512
- toLowerCase?: boolean | undefined;
4513
- };
4514
- }>(this: T_14, params?: orchid_core.MessageParam | undefined): Omit<T_14, "data"> & {
4515
- data: Omit<T_14["data"], "toLowerCase"> & {
4516
- toLowerCase: boolean;
4517
- };
4518
- };
4519
- toUpperCase<T_15 extends {
4520
- data: {
4521
- toUpperCase?: boolean | undefined;
4522
- };
4523
- }>(this: T_15, params?: orchid_core.MessageParam | undefined): Omit<T_15, "data"> & {
4524
- data: Omit<T_15["data"], "toUpperCase"> & {
4525
- toUpperCase: boolean;
4526
- };
4527
- };
4528
- min: <T_16 extends {
4529
- data: {
4530
- min?: number | undefined;
4531
- };
4532
- }, Value_4 extends number>(this: T_16, value: Value_4, params?: orchid_core.MessageParam | undefined) => Omit<T_16, "data"> & {
4533
- data: Omit<T_16["data"], "min"> & {
4534
- min: Value_4;
4535
- };
4536
- };
4537
- max: <T_17 extends {
4538
- data: {
4539
- max?: number | undefined;
4540
- };
4541
- }, Value_5 extends number>(this: T_17, value: Value_5, params?: orchid_core.MessageParam | undefined) => Omit<T_17, "data"> & {
4542
- data: Omit<T_17["data"], "max"> & {
4543
- max: Value_5;
4544
- };
4545
- };
4546
- length: <T_18 extends {
4547
- data: {
4548
- length?: number | undefined;
4549
- };
4550
- }, Value_6 extends number>(this: T_18, value: Value_6, params?: orchid_core.MessageParam | undefined) => Omit<T_18, "data"> & {
4551
- data: Omit<T_18["data"], "length"> & {
4552
- length: Value_6;
4553
- };
4554
- };
4555
- nonEmpty: <T_19 extends orchid_core.NonEmptyBase>(this: T_19, params?: orchid_core.MessageParam | undefined) => orchid_core.NonEmptyResult<T_19>;
4556
- };
4652
+ type TextColumnData = StringTypeData;
4653
+ type TextMethods = typeof stringTypeMethods;
4557
4654
  interface TextBaseColumn extends ColumnType<string, typeof Operators.text>, TextMethods {
4558
4655
  }
4559
4656
  declare abstract class TextBaseColumn extends ColumnType<string, typeof Operators.text> {
@@ -4587,6 +4684,7 @@ declare class CharColumn<Limit extends number | undefined = undefined> extends L
4587
4684
  toCode(t: string): Code;
4588
4685
  }
4589
4686
  declare class TextColumn extends TextBaseColumn {
4687
+ static instance: TextColumn;
4590
4688
  dataType: "text";
4591
4689
  data: TextColumnData & {
4592
4690
  minArg?: number;
@@ -4836,7 +4934,9 @@ declare class BitVaryingColumn<Length extends number | undefined = undefined> ex
4836
4934
  toCode(t: string): Code;
4837
4935
  toSQL(): string;
4838
4936
  }
4937
+ type TsVectorGeneratedColumns = string[] | Record<string, SearchWeight>;
4839
4938
  declare class TsVectorColumn extends ColumnType<string, typeof Operators.text> {
4939
+ defaultLanguage: string;
4840
4940
  dataType: "tsvector";
4841
4941
  operators: {
4842
4942
  contains: Operator<string | orchid_core.Expression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>> | Query>;
@@ -4850,7 +4950,33 @@ declare class TsVectorColumn extends ColumnType<string, typeof Operators.text> {
4850
4950
  in: Operator<string[] | orchid_core.Expression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>> | Query>;
4851
4951
  notIn: Operator<string[] | orchid_core.Expression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>> | Query>;
4852
4952
  };
4953
+ constructor(defaultLanguage?: string);
4853
4954
  toCode(t: string): Code;
4955
+ /**
4956
+ * For `tsvector` column type, it can also accept language (optional) and columns:
4957
+ *
4958
+ * ```ts
4959
+ * import { change } from '../dbScript';
4960
+ *
4961
+ * change(async (db) => {
4962
+ * await db.createTable('post', (t) => ({
4963
+ * id: t.id(),
4964
+ * title: t.text(),
4965
+ * body: t.text(),
4966
+ * // join title and body into a single ts_vector
4967
+ * generatedTsVector: t.tsvector().generated(['title', 'body']).searchIndex(),
4968
+ * // with language:
4969
+ * spanishTsVector: t
4970
+ * .tsvector()
4971
+ * .generated('spanish', ['title', 'body'])
4972
+ * .searchIndex(),
4973
+ * }));
4974
+ * });
4975
+ * ```
4976
+ *
4977
+ * @param args
4978
+ */
4979
+ generated<T extends ColumnType>(this: T, ...args: RawSQLArgs | [language: string, columns: TsVectorGeneratedColumns] | [columns: TsVectorGeneratedColumns]): T;
4854
4980
  }
4855
4981
  declare class TsQueryColumn extends ColumnType<string, typeof Operators.text> {
4856
4982
  dataType: "tsquery";
@@ -4990,7 +5116,7 @@ declare const getConstraintKind: (it: TableData.Constraint) => 'constraint' | 'f
4990
5116
  declare const newTableData: () => TableData;
4991
5117
  declare const getTableData: () => TableData;
4992
5118
  declare const resetTableData: (data?: TableData) => void;
4993
- declare const getColumnTypes: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>, Shape extends ColumnsShape>(types: CT, fn: (t: CT) => Shape, nowSQL: string | undefined, data?: TableData) => Shape;
5119
+ declare const getColumnTypes: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>, Shape extends ColumnsShape>(types: CT, fn: (t: CT) => Shape, nowSQL: string | undefined, language: string | undefined, data?: TableData) => Shape;
4994
5120
  declare function text(min: number, max: number): TextColumn;
4995
5121
  declare function sql(sql: TemplateStringsArray, ...values: unknown[]): RawSQLBase;
4996
5122
  declare function sql(sql: string): RawSQLBase;
@@ -5086,7 +5212,7 @@ declare const columnTypes: {
5086
5212
  tsquery(): TsQueryColumn;
5087
5213
  uuid(): UUIDColumn;
5088
5214
  xml(): XMLColumn;
5089
- json<Type extends JSONTypeAny>(schemaOrFn: Type | ((j: JSONTypes) => Type)): JSONColumn<Type>;
5215
+ json<Type extends JSONType<unknown, {}> = JSONUnknown>(schemaOrFn?: Type | ((j: JSONTypes) => Type) | undefined): JSONColumn<Type>;
5090
5216
  jsonText(): JSONTextColumn;
5091
5217
  array<Item extends ColumnType<unknown, BaseOperators, unknown>>(item: Item): ArrayColumn<Item>;
5092
5218
  type(dataType: string): CustomTypeColumn;
@@ -5096,6 +5222,10 @@ declare const columnTypes: {
5096
5222
  }): {};
5097
5223
  index(columns: MaybeArray<string | IndexColumnOptions>, options?: IndexOptions): {};
5098
5224
  unique(columns: MaybeArray<string | IndexColumnOptions>, options?: IndexOptions): {};
5225
+ /**
5226
+ * See {@link ColumnType.searchIndex}
5227
+ */
5228
+ searchIndex(columns: MaybeArray<string | IndexColumnOptions>, options?: IndexOptions): {};
5099
5229
  constraint<Table extends string | (() => ForeignKeyTable), Columns extends Table extends () => ForeignKeyTable ? [ColumnNameOfTable<ReturnType<Table>>, ...ColumnNameOfTable<ReturnType<Table>>[]] : [string, ...string[]]>({ name, references, check, dropMode, }: {
5100
5230
  name?: string | undefined;
5101
5231
  references?: [columns: string[], fnOrTable: Table, foreignColumns: Columns, options?: ForeignKeyOptions | undefined] | undefined;
@@ -5116,8 +5246,7 @@ type NumberColumnData = BaseNumberData & {
5116
5246
  type SerialColumnData = NumberColumnData & {
5117
5247
  default: Expression;
5118
5248
  };
5119
- type NumberMethods = typeof numberTypeMethods;
5120
- interface NumberBaseColumn extends ColumnType<number, typeof Operators.number>, NumberMethods {
5249
+ interface NumberBaseColumn extends ColumnType<number, typeof Operators.number>, NumberTypeMethods {
5121
5250
  }
5122
5251
  declare abstract class NumberBaseColumn extends ColumnType<number, typeof Operators.number> {
5123
5252
  data: NumberColumnData;
@@ -5313,6 +5442,7 @@ type ColumnData = ColumnDataBase & {
5313
5442
  compression?: string;
5314
5443
  foreignKeys?: ForeignKey<string, string[]>[];
5315
5444
  identity?: TableData.Identity;
5445
+ generated?: RawSQLBase;
5316
5446
  };
5317
5447
  type ForeignKeyMatch = 'FULL' | 'PARTIAL' | 'SIMPLE';
5318
5448
  type ForeignKeyAction = 'NO ACTION' | 'RESTRICT' | 'CASCADE' | 'SET NULL' | 'SET DEFAULT';
@@ -5346,6 +5476,7 @@ type IndexColumnOptions = ({
5346
5476
  collate?: string;
5347
5477
  opclass?: string;
5348
5478
  order?: string;
5479
+ weight?: SearchWeight;
5349
5480
  };
5350
5481
  type IndexOptions = {
5351
5482
  name?: string;
@@ -5357,6 +5488,9 @@ type IndexOptions = {
5357
5488
  tablespace?: string;
5358
5489
  where?: string;
5359
5490
  dropMode?: 'CASCADE' | 'RESTRICT';
5491
+ language?: string | RawSQLBase;
5492
+ languageColumn?: string;
5493
+ tsVector?: boolean;
5360
5494
  };
5361
5495
  type SingleColumnIndexOptions = IndexColumnOptions & IndexOptions;
5362
5496
  type ColumnFromDbParams = {
@@ -5374,12 +5508,12 @@ declare const simplifyColumnDefault: (value?: string) => RawSQL<ColumnTypeBase<u
5374
5508
  };
5375
5509
  timestamp(): T;
5376
5510
  timestampsSnakeCase(): {
5377
- createdAt: orchid_core.ColumnWithDefault<T, orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5378
- updatedAt: orchid_core.ColumnWithDefault<T, orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5511
+ createdAt: orchid_core.ColumnWithDefault<T, RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5512
+ updatedAt: orchid_core.ColumnWithDefault<T, RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5379
5513
  };
5380
5514
  }): {
5381
- createdAt: orchid_core.ColumnWithDefault<T, orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5382
- updatedAt: orchid_core.ColumnWithDefault<T, orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5515
+ createdAt: orchid_core.ColumnWithDefault<T, RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5516
+ updatedAt: orchid_core.ColumnWithDefault<T, RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5383
5517
  };
5384
5518
  timestampsSnakeCase<T_1 extends ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>>(this: {
5385
5519
  name(name: string): {
@@ -5387,8 +5521,8 @@ declare const simplifyColumnDefault: (value?: string) => RawSQL<ColumnTypeBase<u
5387
5521
  };
5388
5522
  timestamp(): T_1;
5389
5523
  }): {
5390
- createdAt: orchid_core.ColumnWithDefault<T_1, orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5391
- updatedAt: orchid_core.ColumnWithDefault<T_1, orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5524
+ createdAt: orchid_core.ColumnWithDefault<T_1, RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5525
+ updatedAt: orchid_core.ColumnWithDefault<T_1, RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5392
5526
  };
5393
5527
  timestampsNoTZ<T_2 extends ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>>(this: {
5394
5528
  name(name: string): {
@@ -5396,12 +5530,12 @@ declare const simplifyColumnDefault: (value?: string) => RawSQL<ColumnTypeBase<u
5396
5530
  };
5397
5531
  timestampNoTZ(): T_2;
5398
5532
  timestampsNoTZSnakeCase(): {
5399
- createdAt: orchid_core.ColumnWithDefault<T_2, orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5400
- updatedAt: orchid_core.ColumnWithDefault<T_2, orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5533
+ createdAt: orchid_core.ColumnWithDefault<T_2, RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5534
+ updatedAt: orchid_core.ColumnWithDefault<T_2, RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5401
5535
  };
5402
5536
  }): {
5403
- createdAt: orchid_core.ColumnWithDefault<T_2, orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5404
- updatedAt: orchid_core.ColumnWithDefault<T_2, orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5537
+ createdAt: orchid_core.ColumnWithDefault<T_2, RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5538
+ updatedAt: orchid_core.ColumnWithDefault<T_2, RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5405
5539
  };
5406
5540
  timestampsNoTZSnakeCase<T_3 extends ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>>(this: {
5407
5541
  name(name: string): {
@@ -5409,15 +5543,15 @@ declare const simplifyColumnDefault: (value?: string) => RawSQL<ColumnTypeBase<u
5409
5543
  };
5410
5544
  timestampNoTZ(): T_3;
5411
5545
  }): {
5412
- createdAt: orchid_core.ColumnWithDefault<T_3, orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5413
- updatedAt: orchid_core.ColumnWithDefault<T_3, orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5546
+ createdAt: orchid_core.ColumnWithDefault<T_3, RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5547
+ updatedAt: orchid_core.ColumnWithDefault<T_3, RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>>;
5414
5548
  };
5415
5549
  name: typeof orchid_core.name;
5416
5550
  sql: {
5417
- (sql: TemplateStringsArray, ...values: unknown[]): orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>;
5418
- (sql: string): orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>;
5419
- (values: Record<string, unknown>, sql: string): orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>;
5420
- (values: Record<string, unknown>): (strings: TemplateStringsArray, ...values: unknown[]) => orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>;
5551
+ (sql: TemplateStringsArray, ...values: unknown[]): RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>;
5552
+ (sql: string): RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>;
5553
+ (values: Record<string, unknown>, sql: string): RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>;
5554
+ (values: Record<string, unknown>): (strings: TemplateStringsArray, ...values: unknown[]) => RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>;
5421
5555
  };
5422
5556
  smallint(): SmallIntColumn;
5423
5557
  integer(): IntegerColumn;
@@ -5461,39 +5595,24 @@ declare const simplifyColumnDefault: (value?: string) => RawSQL<ColumnTypeBase<u
5461
5595
  tsquery(): TsQueryColumn;
5462
5596
  uuid(): UUIDColumn;
5463
5597
  xml(): XMLColumn;
5464
- json<Type extends orchid_core.JSONTypeAny>(schemaOrFn: Type | ((j: {
5465
- set: <Value extends orchid_core.JSONTypeAny>(valueType: Value) => orchid_core.JSONSet<Value>;
5466
- tuple: <T_5 extends [] | orchid_core.JSONTupleItems, Rest extends orchid_core.JSONTypeAny | null = null>(items: T_5, rest?: Rest) => orchid_core.JSONTuple<T_5, Rest>;
5467
- union: <T_6 extends [orchid_core.JSONTypeAny, orchid_core.JSONTypeAny, ...orchid_core.JSONTypeAny[]]>(types: T_6) => orchid_core.JSONUnion<T_6>;
5468
- any: () => orchid_core.JSONAny;
5469
- bigint: () => orchid_core.JSONBigInt;
5598
+ json<Type extends orchid_core.JSONType<unknown, {}> = orchid_core.JSONUnknown>(schemaOrFn?: Type | ((j: {
5599
+ unknown: () => orchid_core.JSONUnknown;
5470
5600
  boolean: () => orchid_core.JSONBoolean;
5471
- date: () => orchid_core.JSONDate;
5472
- nan: () => orchid_core.JSONNaN;
5473
- never: () => orchid_core.JSONNever;
5474
5601
  null: () => orchid_core.JSONNull;
5475
5602
  number: () => orchid_core.JSONNumber;
5476
5603
  string: () => orchid_core.JSONString;
5477
- unknown: () => orchid_core.JSONUnknown;
5478
- array: <Type_1 extends orchid_core.JSONTypeAny>(element: Type_1) => orchid_core.JSONArray<Type_1, "many">;
5479
- discriminatedUnion: <Discriminator extends string, DiscriminatorValue extends orchid_core.Primitive, Types extends [orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, ...orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>[]]>(discriminator: Discriminator, options: Types) => orchid_core.JSONDiscriminatedUnion<Discriminator, DiscriminatorValue, Types>;
5480
- enum: <U_1 extends string, T_7 extends [U_1, ...U_1[]]>(options: T_7) => orchid_core.JSONEnum<U_1, T_7>;
5481
- instanceOf: <T_8 extends new (...args: any[]) => any>(cls: T_8) => orchid_core.JSONInstanceOf<T_8>;
5482
- intersection: <Left extends orchid_core.JSONTypeAny, Right extends orchid_core.JSONTypeAny>(left: Left, right: Right) => orchid_core.JSONIntersection<Left, Right>;
5483
- lazy: <T_9 extends orchid_core.JSONTypeAny>(fn: () => T_9) => orchid_core.JSONLazy<T_9>;
5484
- literal: <T_10 extends orchid_core.Primitive>(value: T_10) => orchid_core.JSONLiteral<T_10>;
5485
- map: <Key extends orchid_core.JSONTypeAny, Value_1 extends orchid_core.JSONTypeAny>(keyType: Key, valueType: Value_1) => orchid_core.JSONMap<Key, Value_1>;
5486
- nativeEnum: <T_11 extends orchid_core.EnumLike>(givenEnum: T_11) => orchid_core.JSONNativeEnum<T_11>;
5487
- nullable: <T_12 extends orchid_core.JSONTypeAny>(type: T_12) => orchid_core.JSONNullable<T_12>;
5488
- nullish: <T_13 extends orchid_core.JSONTypeAny>(type: T_13) => orchid_core.JSONNullish<T_13>;
5489
- object: <T_14 extends orchid_core.JSONObjectShape, UnknownKeys extends orchid_core.UnknownKeysParam = "strip", Catchall extends orchid_core.JSONTypeAny = orchid_core.JSONTypeAny>(shape: T_14) => orchid_core.JSONObject<T_14, UnknownKeys, Catchall, orchid_core.JSONTypeAny extends Catchall ? orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }> extends infer T_15 extends object ? { [k in keyof T_15]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }>[k]; } : never : (orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }> extends infer T_18 extends object ? { [k in keyof T_18]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }>[k]; } : never) & {
5490
- [k: string]: Catchall["type"];
5491
- } extends infer T_16 extends object ? { [k_2 in keyof T_16]: ((orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }> extends infer T_17 extends object ? { [k in keyof T_17]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }>[k]; } : never) & {
5492
- [k: string]: Catchall["type"];
5493
- })[k_2]; } : never>;
5494
- optional: <T_19 extends orchid_core.JSONTypeAny>(type: T_19) => orchid_core.JSONOptional<T_19>;
5495
- record: typeof orchid_core.record;
5496
- }) => Type)): JSONColumn<Type>;
5604
+ array: <T_5 extends orchid_core.JSONType<unknown, {}>>(item: T_5) => orchid_core.JSONArray<T_5, "many">;
5605
+ object: <Shape extends orchid_core.JSONObjectShape>(shape: Shape) => orchid_core.JSONObject<Shape, "strip", orchid_core.JSONType<unknown, {}>>;
5606
+ literal: <T_6 extends orchid_core.JSONPrimitive>(value: T_6) => orchid_core.JSONLiteral<T_6>;
5607
+ discriminatedUnion: <Discriminator extends string, Types extends orchid_core.JSONDiscriminatedUnionArg<Discriminator>>(discriminator: Discriminator, types: Types) => orchid_core.JSONDiscriminatedUnion<Discriminator, Types>;
5608
+ enum: <U_1 extends string, T_7 extends [U_1, ...U_1[]]>(options: T_7) => orchid_core.JSONEnum<string, T_7>;
5609
+ intersection: <Left extends orchid_core.JSONType<unknown, {}>, Right extends orchid_core.JSONType<unknown, {}>>(left: Left, right: Right) => orchid_core.JSONIntersection<Left, Right>;
5610
+ lazy: <T_8 extends orchid_core.JSONType<unknown, {}>>(fn: () => T_8) => orchid_core.JSONLazy<T_8>;
5611
+ nativeEnum: <T_9 extends orchid_core.EnumLike>(type: T_9) => orchid_core.JSONNativeEnum<T_9>;
5612
+ record: <Key extends orchid_core.JSONNumber | orchid_core.JSONString, Value extends orchid_core.JSONType<unknown, {}>>(...args: [value: Value] | [key: Key, value: Value]) => orchid_core.JSONRecord<Key, Value>;
5613
+ tuple: <T_10 extends orchid_core.JSONTupleItems, Rest extends orchid_core.JSONType<unknown, {}> | undefined = undefined>(items: T_10, rest?: Rest | undefined) => orchid_core.JSONTuple<T_10, Rest>;
5614
+ union: <T_11 extends orchid_core.JSONUnionArgs>(...types: T_11) => orchid_core.JSONUnion<T_11>;
5615
+ }) => Type) | undefined): JSONColumn<Type>;
5497
5616
  jsonText(): JSONTextColumn;
5498
5617
  array<Item extends ColumnType<unknown, BaseOperators, unknown>>(item: Item): ArrayColumn<Item>;
5499
5618
  type(dataType: string): CustomTypeColumn;
@@ -5502,18 +5621,19 @@ declare const simplifyColumnDefault: (value?: string) => RawSQL<ColumnTypeBase<u
5502
5621
  name?: string | undefined;
5503
5622
  } | undefined): {};
5504
5623
  index(columns: MaybeArray<string | IndexColumnOptions>, options?: IndexOptions): {};
5505
- unique(columns: MaybeArray<string | IndexColumnOptions>, options?: IndexOptions): {};
5624
+ unique(columns: MaybeArray<string | IndexColumnOptions>, options?: IndexOptions | undefined): {};
5625
+ searchIndex(columns: MaybeArray<string | IndexColumnOptions>, options?: IndexOptions | undefined): {};
5506
5626
  constraint<Table extends string | (() => ForeignKeyTable), Columns extends Table extends () => ForeignKeyTable ? [ColumnNameOfTable<ReturnType<Table>>, ...ColumnNameOfTable<ReturnType<Table>>[]] : [string, ...string[]]>({ name, references, check, dropMode, }: {
5507
5627
  name?: string | undefined;
5508
5628
  references?: [columns: string[], fnOrTable: Table, foreignColumns: Columns, options?: ForeignKeyOptions | undefined] | undefined;
5509
- check?: orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}> | undefined;
5629
+ check?: RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}> | undefined;
5510
5630
  dropMode?: DropMode | undefined;
5511
5631
  }): {};
5512
5632
  foreignKey<Table_1 extends string | (() => ForeignKeyTable), Columns_1 extends Table_1 extends () => ForeignKeyTable ? [ColumnNameOfTable<ReturnType<Table_1>>, ...ColumnNameOfTable<ReturnType<Table_1>>[]] : [string, ...string[]]>(columns: string[], fnOrTable: Table_1, foreignColumns: Columns_1, options?: (ForeignKeyOptions & {
5513
5633
  name?: string | undefined;
5514
5634
  dropMode?: DropMode | undefined;
5515
5635
  }) | undefined): {};
5516
- check(check: orchid_core.RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>): {};
5636
+ check(check: RawSQLBase<ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, ColumnDataBase>, {}>): {};
5517
5637
  }> | undefined;
5518
5638
  declare const instantiateColumn: (klass: new (...args: never[]) => ColumnType, params: ColumnFromDbParams) => ColumnType;
5519
5639
  declare abstract class ColumnType<Type = unknown, Ops extends BaseOperators = BaseOperators, InputType = Type> extends ColumnTypeBase<Type, Ops, InputType, ColumnData> {
@@ -5526,6 +5646,54 @@ declare abstract class ColumnType<Type = unknown, Ops extends BaseOperators = Ba
5526
5646
  };
5527
5647
  toSQL(): string;
5528
5648
  index<T extends ColumnType>(this: T, options?: Omit<SingleColumnIndexOptions, 'column'>): T;
5649
+ /**
5650
+ * `searchIndex` is designed for full text search.
5651
+ *
5652
+ * It can accept the same options as a regular `index`, but it is `USING GIN` by default, and it is concatenating columns into a `tsvector`.
5653
+ *
5654
+ * ```ts
5655
+ * import { change } from '../dbScript';
5656
+ *
5657
+ * change(async (db) => {
5658
+ * await db.createTable('table', (t) => ({
5659
+ * id: t.identity().primaryKey(),
5660
+ * title: t.string(),
5661
+ * body: t.string(),
5662
+ * ...t.searchIndex(['title', 'body']),
5663
+ * }));
5664
+ * });
5665
+ * ```
5666
+ *
5667
+ * Produces the following index ('english' is a default language, see [full text search](/guide/text-search.html#language) for changing it):
5668
+ *
5669
+ * ```sql
5670
+ * CREATE INDEX "table_title_body_idx" ON "table" USING GIN (to_tsvector('english', concat_ws(' ', "title", "body")))
5671
+ * ```
5672
+ *
5673
+ * Also, it works well with a generated `tsvector` column:
5674
+ *
5675
+ * ```ts
5676
+ * import { change } from '../dbScript';
5677
+ *
5678
+ * change(async (db) => {
5679
+ * await db.createTable('table', (t) => ({
5680
+ * id: t.identity().primaryKey(),
5681
+ * title: t.string(),
5682
+ * body: t.string(),
5683
+ * generatedTsVector: t.tsvector().generated(['title', 'body']).searchIndex(),
5684
+ * }));
5685
+ * });
5686
+ * ```
5687
+ *
5688
+ * Produces the following index:
5689
+ *
5690
+ * ```sql
5691
+ * CREATE INDEX "table_generatedTsVector_idx" ON "table" USING GIN ("generatedTsVector")
5692
+ * ```
5693
+ *
5694
+ * @param options - index options
5695
+ */
5696
+ searchIndex<T extends ColumnType>(this: T, options?: Omit<SingleColumnIndexOptions, 'tsVector'>): T;
5529
5697
  unique<T extends ColumnType>(this: T, options?: Omit<SingleColumnIndexOptions, 'column' | 'unique'>): T;
5530
5698
  comment<T extends ColumnType>(this: T, comment: string): T;
5531
5699
  validationDefault<T extends ColumnType>(this: T, value: T['type']): T;
@@ -5536,26 +5704,28 @@ declare abstract class ColumnType<Type = unknown, Ops extends BaseOperators = Ba
5536
5704
  type: Transformed;
5537
5705
  };
5538
5706
  to<T extends ColumnType, ToType extends ColumnType>(this: T, fn: (input: T['type']) => ToType['type'] | undefined, type: ToType): ToType;
5539
- refine<T extends ColumnType, RefinedOutput extends T['type']>(this: T, check: (arg: T['type']) => unknown, params?: MessageParam): T & {
5707
+ refine<T extends ColumnType, RefinedOutput extends T['type']>(this: T, check: (arg: T['type']) => unknown, params?: ErrorMessage): T & {
5540
5708
  type: RefinedOutput;
5541
5709
  };
5542
5710
  superRefine<T extends ColumnType, RefinedOutput extends T['type']>(this: T, check: (arg: T['type'], ctx: ValidationContext) => unknown): T & {
5543
5711
  type: RefinedOutput;
5544
5712
  };
5545
- }
5546
-
5547
- declare const cloneInstance: <T>(instance: T) => T;
5548
- declare const assignMethodsToClass: <Methods extends Record<string, unknown>>(klass: {
5549
- prototype: unknown;
5550
- }, methods: Methods) => void;
5551
-
5552
- declare const utils_assignMethodsToClass: typeof assignMethodsToClass;
5553
- declare const utils_cloneInstance: typeof cloneInstance;
5554
- declare namespace utils {
5555
- export {
5556
- utils_assignMethodsToClass as assignMethodsToClass,
5557
- utils_cloneInstance as cloneInstance,
5558
- };
5713
+ /**
5714
+ * Define a generated column. `generated` accepts a raw SQL.
5715
+ *
5716
+ * ```ts
5717
+ * import { change } from '../dbScript';
5718
+ *
5719
+ * change(async (db) => {
5720
+ * await db.createTable('table', (t) => ({
5721
+ * two: t.integer().generated`1 + 1`,
5722
+ * }));
5723
+ * });
5724
+ * ```
5725
+ *
5726
+ * @param args - raw SQL
5727
+ */
5728
+ generated<T extends ColumnType>(this: T, ...args: RawSQLArgs): T;
5559
5729
  }
5560
5730
 
5561
5731
  declare abstract class VirtualColumn extends ColumnType<unknown, typeof Operators.any> {
@@ -5643,4 +5813,4 @@ declare const testTransaction: {
5643
5813
  close(arg: Arg): Promise<void>;
5644
5814
  };
5645
5815
 
5646
- export { Adapter, AdapterConfig, AdapterOptions, AddQuerySelect, AddQueryWith, AfterHook, AggregateMethods, AggregateOptions, AliasOrTable, ArrayColumn, ArrayData, ArrayOfColumnsObjects, AsMethods, BaseOperators, BaseRelation, BelongsToRelation, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BooleanNullable, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, CitextColumn, Clear, ClearStatement, ColumnData, ColumnExpression, ColumnFromDbParams, ColumnInfo, ColumnInfoMethods, ColumnInfoQueryData, ColumnOperators, ColumnType, ColumnTypes, ColumnsObject, ColumnsShape, CommonQueryData, CopyMethods, CopyOptions, CopyQueryData, Create, CreateCtx, CreateData, CreateKind, CreateMethodsNames, CustomTypeColumn, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeTzBaseClass, Db, DbOptions, DbResult, DbTableOptions, DecimalBaseColumn, DecimalColumn, DefaultColumnTypes, Delete, DeleteMethodsNames, DeleteQueryData, DomainColumn, DoublePrecisionColumn, DropMode, EnumColumn, ExpressionOutput, FnExpression, FnExpressionArg, For, ForeignKey, ForeignKeyAction, ForeignKeyMatch, ForeignKeyOptions, From, FromArgs, FromResult, GetArg, GetQueryResult, GetStringArg, HasAndBelongsToManyRelation, HasManyRelation, HasOneRelation, Having, HavingItem, HookAction, HookSelect, IdentityColumn, IndexColumnOptions, IndexOptions, InetColumn, InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, IsolationLevel, JSONColumn, JSONTextColumn, JSONTypes, Join, JoinArgs, JoinCallback, JoinFirstArg, JoinItem, JoinLateralCallback, JoinLateralItem, JoinLateralResult, JoinOverrides, JoinResult, JoinedParsers, JoinedShapes, JsonItem, JsonMethods, JsonModifiers, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MergeQuery, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NoPrimaryKeyOption, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, NumberColumn, NumberColumnData, OnConflictItem, OnConflictMergeUpdate, OnConflictQueryBuilder, OnQueryBuilder, Operator, Operators, OrchidOrmError, OrchidOrmInternalError, OrderArg, OrderArgs, OrderItem, Over, PathColumn, PluckResultColumnType, PointColumn, PolygonColumn, Query, QueryAfterHook, QueryArraysResult, QueryBase, QueryBeforeHook, QueryData, QueryError, QueryErrorName, QueryGet, QueryHookSelect, QueryHooks, QueryLog, QueryLogObject, QueryLogOptions, QueryLogger, QueryMethods, QueryResult, QueryReturnType, QueryReturnsAll, QueryTransform, QueryTransformFn, QueryUpsertOrCreate, QueryWithTable, RawSQL, RawSqlMethods, RealColumn, Relation, RelationQuery, RelationQueryBase, RelationQueryData, RelationsBase, Select, SelectAggMethods, SelectArg, SelectItem, SelectQueryBuilder, SelectQueryData, Selectable, SelectableBase, SelectableFromShape, SelectableOfType, SelectableOrExpression, SelectableOrExpressionOfType, SerialColumn, SerialColumnData, SetQueryReturns, SetQueryReturnsAll, SetQueryReturnsColumn, SetQueryReturnsColumnInfo, SetQueryReturnsColumnOptional, SetQueryReturnsOne, SetQueryReturnsOneOptional, SetQueryReturnsPluck, SetQueryReturnsRowCount, SetQueryReturnsRows, SetQueryReturnsValue, SetQueryReturnsValueOptional, SetQueryReturnsVoid, SetQueryTableAlias, SetQueryWith, SimpleJoinItem, SingleColumnIndexOptions, SmallIntColumn, SmallSerialColumn, SortDir, StringColumn, TableData, TextBaseColumn, TextColumn, TextColumnData, Then, TimeColumn, TimeInterval, TimestampColumn, TimestampTZColumn, ToSqlCtx, ToSqlOptions, Transaction, TransactionAdapter, TransactionOptions, TransformMethods, TruncateQueryData, TsQueryColumn, TsVectorColumn, TypeParsers, UUIDColumn, UnhandledTypeError, Union, UnionArg, UnionItem, UnionKind, UnknownColumn, Update, UpdateCtx, UpdateData, UpdateQueryData, UpdateQueryDataItem, UpdateQueryDataObject, UpdatedAtDataInjector, UpsertCreateArg, UpsertData, UpsertResult, UpsertThis, VarCharColumn, VirtualColumn, Where, WhereArg, WhereArgs, WhereInArg, WhereInColumn, WhereInItem, WhereInValues, WhereItem, WhereJsonPathEqualsItem, WhereOnItem, WhereOnJoinItem, WhereQueryBuilder, WhereResult, WindowArg, WindowArgDeclaration, WindowDeclaration, WindowItem, With, WithDataBase, WithDataItem, WithItem, WithOptions, XMLColumn, addOr, addOrNot, addParserForRawExpression, addParserForSelectItem, addQueryOn, addQueryOrOn, addWhere, addWhereIn, addWhereNot, anyShape, checkIfASimpleQuery, cloneQueryArrays, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnTypes, utils as columnUtils, columnsByType, columnsShapeToCode, constraintPropsToCode, constraintToCode, createDb, createOperator, foreignKeyArgumentToCode, getClonedQueryData, getColumnTypes, getConstraintKind, getQueryAs, getSelectQueryBuilder, getShapeFromSelect, getTableData, handleResult, identityToCode, indexToCode, instantiateColumn, isQueryReturnsAll, isRequiredRelationKey, isSelectingCount, joinSubQuery, jsonTypes, logColors, logParamToLogObject, makeColumnFn, makeRegexToFindInSql, makeSql, newTableData, parseRecord, parseResult, primaryKeyToCode, processSelectArg, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, queryMethodByReturnType, queryTypeWithLimitOne, quote, quoteString, raw, referencesArgsToCode, relationQueryKey, resetTableData, resolveSubQueryCallback, setQueryObjectValue, simplifyColumnDefault, templateLiteralToSQL, testTransaction, throwIfNoWhere, toSql, toSqlCacheKey };
5816
+ export { Adapter, AdapterConfig, AdapterOptions, AddQuerySelect, AddQueryWith, AfterHook, AggregateMethods, AggregateOptions, AliasOrTable, ArrayColumn, ArrayData, ArrayOfColumnsObjects, AsMethods, BaseOperators, BaseRelation, BelongsToRelation, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BooleanNullable, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, CitextColumn, Clear, ClearStatement, ColumnData, ColumnExpression, ColumnFromDbParams, ColumnInfo, ColumnInfoMethods, ColumnInfoQueryData, ColumnOperators, ColumnType, ColumnTypes, ColumnsObject, ColumnsShape, CommonQueryData, CopyMethods, CopyOptions, CopyQueryData, Create, CreateCtx, CreateData, CreateKind, CreateMethodsNames, CustomTypeColumn, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeTzBaseClass, Db, DbOptions, DbResult, DbTableOptions, DecimalBaseColumn, DecimalColumn, DefaultColumnTypes, Delete, DeleteMethodsNames, DeleteQueryData, DomainColumn, DoublePrecisionColumn, DropMode, EnumColumn, ExpressionOutput, FnExpression, FnExpressionArg, For, ForeignKey, ForeignKeyAction, ForeignKeyMatch, ForeignKeyOptions, From, FromArgs, FromResult, GetArg, GetQueryResult, GetStringArg, HasAndBelongsToManyRelation, HasManyRelation, HasOneRelation, Having, HavingItem, HookAction, HookSelect, IdentityColumn, IndexColumnOptions, IndexOptions, InetColumn, InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, IsolationLevel, JSONColumn, JSONTextColumn, Join, JoinArgs, JoinCallback, JoinFirstArg, JoinItem, JoinLateralCallback, JoinLateralItem, JoinLateralResult, JoinOverrides, JoinResult, JoinedParsers, JoinedShapes, JsonItem, JsonMethods, JsonModifiers, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MergeQuery, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NoPrimaryKeyOption, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, NumberColumn, NumberColumnData, OnConflictItem, OnConflictMergeUpdate, OnConflictQueryBuilder, OnQueryBuilder, Operator, Operators, OrchidOrmError, OrchidOrmInternalError, OrderArg, OrderArgs, OrderItem, OrderTsQueryConfig, Over, PathColumn, PluckResultColumnType, PointColumn, PolygonColumn, Query, QueryAfterHook, QueryArraysResult, QueryBase, QueryBeforeHook, QueryData, QueryError, QueryErrorName, QueryGet, QueryHookSelect, QueryHooks, QueryLog, QueryLogObject, QueryLogOptions, QueryLogger, QueryMethods, QueryResult, QueryReturnType, QueryReturnsAll, QuerySourceItem, QueryTransform, QueryTransformFn, QueryUpsertOrCreate, QueryWithTable, RawSQL, RawSqlMethods, RealColumn, Relation, RelationQuery, RelationQueryBase, RelationQueryData, RelationsBase, SearchArg, SearchMethods, SearchWeight, Select, SelectAggMethods, SelectArg, SelectItem, SelectQueryBuilder, SelectQueryData, Selectable, SelectableBase, SelectableFromShape, SelectableOfType, SelectableOrExpression, SelectableOrExpressionOfType, SerialColumn, SerialColumnData, SetQueryReturns, SetQueryReturnsAll, SetQueryReturnsColumn, SetQueryReturnsColumnInfo, SetQueryReturnsColumnOptional, SetQueryReturnsOne, SetQueryReturnsOneOptional, SetQueryReturnsPluck, SetQueryReturnsRowCount, SetQueryReturnsRows, SetQueryReturnsValue, SetQueryReturnsValueOptional, SetQueryReturnsVoid, SetQueryTableAlias, SetQueryWith, SimpleJoinItem, SingleColumnIndexOptions, SmallIntColumn, SmallSerialColumn, SortDir, StringColumn, TableData, TextBaseColumn, TextColumn, TextColumnData, Then, TimeColumn, TimeInterval, TimestampColumn, TimestampTZColumn, ToSqlCtx, ToSqlOptions, Transaction, TransactionAdapter, TransactionOptions, TransformMethods, TruncateQueryData, TsQueryColumn, TsVectorColumn, TypeParsers, UUIDColumn, UnhandledTypeError, Union, UnionArg, UnionItem, UnionKind, UnknownColumn, Update, UpdateCtx, UpdateData, UpdateQueryData, UpdateQueryDataItem, UpdateQueryDataObject, UpdatedAtDataInjector, UpsertCreateArg, UpsertData, UpsertResult, UpsertThis, VarCharColumn, VirtualColumn, Where, WhereArg, WhereArgs, WhereInArg, WhereInColumn, WhereInItem, WhereInValues, WhereItem, WhereJsonPathEqualsItem, WhereOnItem, WhereOnJoinItem, WhereQueryBuilder, WhereResult, WhereSearchItem, WhereSearchResult, WindowArg, WindowArgDeclaration, WindowDeclaration, WindowItem, With, WithDataBase, WithDataItem, WithItem, WithOptions, XMLColumn, addOr, addOrNot, addParserForRawExpression, addParserForSelectItem, addQueryOn, addQueryOrOn, addWhere, addWhereIn, addWhereNot, anyShape, checkIfASimpleQuery, cloneQueryArrays, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnTypes, columnsByType, columnsShapeToCode, constraintPropsToCode, constraintToCode, createDb, createOperator, foreignKeyArgumentToCode, getClonedQueryData, getColumnTypes, getConstraintKind, getQueryAs, getSelectQueryBuilder, getShapeFromSelect, getTableData, handleResult, identityToCode, indexToCode, instantiateColumn, isQueryReturnsAll, isRequiredRelationKey, isSelectingCount, joinSubQuery, logColors, logParamToLogObject, makeColumnFn, makeColumnFnClass, makeRegexToFindInSql, makeSql, newTableData, parseRecord, parseResult, primaryKeyToCode, processSelectArg, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, queryMethodByReturnType, queryTypeWithLimitOne, quote, quoteString, raw, referencesArgsToCode, relationQueryKey, resetTableData, resolveSubQueryCallback, saveSearchAlias, setQueryObjectValue, simplifyColumnDefault, templateLiteralToSQL, testTransaction, throwIfNoWhere, toSql, toSqlCacheKey };