@xata.io/client 0.0.0-alpha.vf2696e7 → 0.0.0-alpha.vf344dbc

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
@@ -138,6 +138,12 @@ declare type ListBranchesResponse = {
138
138
  displayName: string;
139
139
  branches: Branch[];
140
140
  };
141
+ declare type ListGitBranchesResponse = {
142
+ mapping: {
143
+ gitBranch: string;
144
+ xataBranch: string;
145
+ }[];
146
+ };
141
147
  declare type Branch = {
142
148
  name: string;
143
149
  createdAt: DateTime;
@@ -186,7 +192,7 @@ declare type Table = {
186
192
  */
187
193
  declare type Column = {
188
194
  name: string;
189
- type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
195
+ type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object' | 'datetime';
190
196
  link?: {
191
197
  table: string;
192
198
  };
@@ -262,6 +268,17 @@ declare type SortExpression = string[] | {
262
268
  [key: string]: SortOrder;
263
269
  }[];
264
270
  declare type SortOrder = 'asc' | 'desc';
271
+ /**
272
+ * Maximum [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) for the search terms. The Levenshtein
273
+ * distance is the number of one charcter changes needed to make two strings equal. The default is 1, meaning that single
274
+ * character typos per word are tollerated by search. You can set it to 0 to remove the typo tollerance or set it to 2
275
+ * to allow two typos in a word.
276
+ *
277
+ * @default 1
278
+ * @maximum 2
279
+ * @minimum 0
280
+ */
281
+ declare type FuzzinessExpression = number;
265
282
  /**
266
283
  * @minProperties 1
267
284
  */
@@ -275,6 +292,10 @@ declare type FilterExpression = {
275
292
  } & {
276
293
  [key: string]: FilterColumn;
277
294
  };
295
+ declare type HighlightExpression = {
296
+ enabled?: boolean;
297
+ encodeHTML?: boolean;
298
+ };
278
299
  declare type FilterList = FilterExpression | FilterExpression[];
279
300
  declare type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList;
280
301
  /**
@@ -360,6 +381,11 @@ declare type XataRecord$1 = {
360
381
  xata: {
361
382
  version: number;
362
383
  table?: string;
384
+ highlight?: {
385
+ [key: string]: string[] | {
386
+ [key: string]: any;
387
+ };
388
+ };
363
389
  warnings?: string[];
364
390
  };
365
391
  } & {
@@ -382,6 +408,7 @@ type schemas_WorkspaceMembers = WorkspaceMembers;
382
408
  type schemas_InviteKey = InviteKey;
383
409
  type schemas_ListDatabasesResponse = ListDatabasesResponse;
384
410
  type schemas_ListBranchesResponse = ListBranchesResponse;
411
+ type schemas_ListGitBranchesResponse = ListGitBranchesResponse;
385
412
  type schemas_Branch = Branch;
386
413
  type schemas_BranchMetadata = BranchMetadata;
387
414
  type schemas_DBBranch = DBBranch;
@@ -402,7 +429,9 @@ type schemas_TableMigration = TableMigration;
402
429
  type schemas_ColumnMigration = ColumnMigration;
403
430
  type schemas_SortExpression = SortExpression;
404
431
  type schemas_SortOrder = SortOrder;
432
+ type schemas_FuzzinessExpression = FuzzinessExpression;
405
433
  type schemas_FilterExpression = FilterExpression;
434
+ type schemas_HighlightExpression = HighlightExpression;
406
435
  type schemas_FilterList = FilterList;
407
436
  type schemas_FilterColumn = FilterColumn;
408
437
  type schemas_FilterColumnIncludes = FilterColumnIncludes;
@@ -434,6 +463,7 @@ declare namespace schemas {
434
463
  schemas_InviteKey as InviteKey,
435
464
  schemas_ListDatabasesResponse as ListDatabasesResponse,
436
465
  schemas_ListBranchesResponse as ListBranchesResponse,
466
+ schemas_ListGitBranchesResponse as ListGitBranchesResponse,
437
467
  schemas_Branch as Branch,
438
468
  schemas_BranchMetadata as BranchMetadata,
439
469
  schemas_DBBranch as DBBranch,
@@ -454,7 +484,9 @@ declare namespace schemas {
454
484
  schemas_ColumnMigration as ColumnMigration,
455
485
  schemas_SortExpression as SortExpression,
456
486
  schemas_SortOrder as SortOrder,
487
+ schemas_FuzzinessExpression as FuzzinessExpression,
457
488
  schemas_FilterExpression as FilterExpression,
489
+ schemas_HighlightExpression as HighlightExpression,
458
490
  schemas_FilterList as FilterList,
459
491
  schemas_FilterColumn as FilterColumn,
460
492
  schemas_FilterColumnIncludes as FilterColumnIncludes,
@@ -1010,6 +1042,163 @@ declare type DeleteDatabaseVariables = {
1010
1042
  * Delete a database and all of its branches and tables permanently.
1011
1043
  */
1012
1044
  declare const deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
1045
+ declare type GetGitBranchesMappingPathParams = {
1046
+ dbName: DBName;
1047
+ workspace: string;
1048
+ };
1049
+ declare type GetGitBranchesMappingError = ErrorWrapper<{
1050
+ status: 400;
1051
+ payload: BadRequestError;
1052
+ } | {
1053
+ status: 401;
1054
+ payload: AuthError;
1055
+ }>;
1056
+ declare type GetGitBranchesMappingVariables = {
1057
+ pathParams: GetGitBranchesMappingPathParams;
1058
+ } & FetcherExtraProps;
1059
+ /**
1060
+ * Lists all the git branches in the mapping, and their associated Xata branches.
1061
+ *
1062
+ * Example response:
1063
+ *
1064
+ * ```json
1065
+ * {
1066
+ * "mappings": [
1067
+ * {
1068
+ * "gitBranch": "main",
1069
+ * "xataBranch": "main"
1070
+ * },
1071
+ * {
1072
+ * "gitBranch": "gitBranch1",
1073
+ * "xataBranch": "xataBranch1"
1074
+ * }
1075
+ * {
1076
+ * "gitBranch": "xataBranch2",
1077
+ * "xataBranch": "xataBranch2"
1078
+ * }
1079
+ * ]
1080
+ * }
1081
+ * ```
1082
+ */
1083
+ declare const getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
1084
+ declare type AddGitBranchesEntryPathParams = {
1085
+ dbName: DBName;
1086
+ workspace: string;
1087
+ };
1088
+ declare type AddGitBranchesEntryError = ErrorWrapper<{
1089
+ status: 400;
1090
+ payload: BadRequestError;
1091
+ } | {
1092
+ status: 401;
1093
+ payload: AuthError;
1094
+ }>;
1095
+ declare type AddGitBranchesEntryResponse = {
1096
+ warning?: string;
1097
+ };
1098
+ declare type AddGitBranchesEntryRequestBody = {
1099
+ gitBranch: string;
1100
+ xataBranch: BranchName;
1101
+ };
1102
+ declare type AddGitBranchesEntryVariables = {
1103
+ body: AddGitBranchesEntryRequestBody;
1104
+ pathParams: AddGitBranchesEntryPathParams;
1105
+ } & FetcherExtraProps;
1106
+ /**
1107
+ * Adds an entry to the mapping of git branches to Xata branches. The git branch and the Xata branch must be present in the body of the request. If the Xata branch doesn't exist, a 400 error is returned.
1108
+ *
1109
+ * If the git branch is already present in the mapping, the old entry is overwritten, and a warning message is included in the response. If the git branch is added and didn't exist before, the response code is 204. If the git branch existed and it was overwritten, the response code is 201.
1110
+ *
1111
+ * Example request:
1112
+ *
1113
+ * ```json
1114
+ * // POST https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches
1115
+ * {
1116
+ * "gitBranch": "fix/bug123",
1117
+ * "xataBranch": "fix_bug"
1118
+ * }
1119
+ * ```
1120
+ */
1121
+ declare const addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
1122
+ declare type RemoveGitBranchesEntryPathParams = {
1123
+ dbName: DBName;
1124
+ workspace: string;
1125
+ };
1126
+ declare type RemoveGitBranchesEntryQueryParams = {
1127
+ gitBranch: string;
1128
+ };
1129
+ declare type RemoveGitBranchesEntryError = ErrorWrapper<{
1130
+ status: 400;
1131
+ payload: BadRequestError;
1132
+ } | {
1133
+ status: 401;
1134
+ payload: AuthError;
1135
+ }>;
1136
+ declare type RemoveGitBranchesEntryVariables = {
1137
+ pathParams: RemoveGitBranchesEntryPathParams;
1138
+ queryParams: RemoveGitBranchesEntryQueryParams;
1139
+ } & FetcherExtraProps;
1140
+ /**
1141
+ * Removes an entry from the mapping of git branches to Xata branches. The name of the git branch must be passed as a query parameter. If the git branch is not found, the endpoint returns a 404 status code.
1142
+ *
1143
+ * Example request:
1144
+ *
1145
+ * ```json
1146
+ * // DELETE https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches?gitBranch=fix%2Fbug123
1147
+ * ```
1148
+ */
1149
+ declare const removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
1150
+ declare type ResolveBranchPathParams = {
1151
+ dbName: DBName;
1152
+ workspace: string;
1153
+ };
1154
+ declare type ResolveBranchQueryParams = {
1155
+ gitBranch?: string;
1156
+ fallbackBranch?: string;
1157
+ };
1158
+ declare type ResolveBranchError = ErrorWrapper<{
1159
+ status: 400;
1160
+ payload: BadRequestError;
1161
+ } | {
1162
+ status: 401;
1163
+ payload: AuthError;
1164
+ }>;
1165
+ declare type ResolveBranchResponse = {
1166
+ branch: string;
1167
+ reason: {
1168
+ code: 'FOUND_IN_MAPPING' | 'BRANCH_EXISTS' | 'FALLBACK_BRANCH' | 'DEFAULT_BRANCH';
1169
+ message: string;
1170
+ };
1171
+ };
1172
+ declare type ResolveBranchVariables = {
1173
+ pathParams: ResolveBranchPathParams;
1174
+ queryParams?: ResolveBranchQueryParams;
1175
+ } & FetcherExtraProps;
1176
+ /**
1177
+ * In order to resolve the database branch, the following algorithm is used:
1178
+ * * if the `gitBranch` was provided and is found in the [git branches mapping](/api-reference/dbs/db_name/gitBranches), the associated Xata branch is returned
1179
+ * * else, if a Xata branch with the exact same name as `gitBranch` exists, return it
1180
+ * * else, if `fallbackBranch` is provided and a branch with that name exists, return it
1181
+ * * else, return the default branch of the DB (`main` or the first branch)
1182
+ *
1183
+ * Example call:
1184
+ *
1185
+ * ```json
1186
+ * // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test&fallbackBranch=tsg
1187
+ * ```
1188
+ *
1189
+ * Example response:
1190
+ *
1191
+ * ```json
1192
+ * {
1193
+ * "branch": "main",
1194
+ * "reason": {
1195
+ * "code": "DEFAULT_BRANCH",
1196
+ * "message": "Default branch for this database (main)"
1197
+ * }
1198
+ * }
1199
+ * ```
1200
+ */
1201
+ declare const resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
1013
1202
  declare type GetBranchDetailsPathParams = {
1014
1203
  dbBranchName: DBBranchName;
1015
1204
  workspace: string;
@@ -1750,7 +1939,11 @@ declare type QueryTableVariables = {
1750
1939
  * "link": {
1751
1940
  * "table": "users"
1752
1941
  * }
1753
- * }
1942
+ * },
1943
+ * {
1944
+ * "name": "foundedDate",
1945
+ * "type": "datetime"
1946
+ * },
1754
1947
  * ]
1755
1948
  * },
1756
1949
  * {
@@ -1897,7 +2090,8 @@ declare type QueryTableVariables = {
1897
2090
  * "version": 0
1898
2091
  * },
1899
2092
  * "name": "first team",
1900
- * "code": "A1"
2093
+ * "code": "A1",
2094
+ * "foundedDate": "2020-03-04T10:43:54.32Z"
1901
2095
  * }
1902
2096
  * }
1903
2097
  * ```
@@ -1912,7 +2106,7 @@ declare type QueryTableVariables = {
1912
2106
  * `$none`, etc.
1913
2107
  *
1914
2108
  * All operators start with an `$` to differentiate them from column names
1915
- * (which are not allowed to start with an dollar sign).
2109
+ * (which are not allowed to start with a dollar sign).
1916
2110
  *
1917
2111
  * #### Exact matching and control operators
1918
2112
  *
@@ -2092,12 +2286,18 @@ declare type QueryTableVariables = {
2092
2286
  * {
2093
2287
  * "filter": {
2094
2288
  * "<column_name>": {
2095
- * "$pattern": "v*alue*"
2289
+ * "$pattern": "v*alu?"
2096
2290
  * }
2097
2291
  * }
2098
2292
  * }
2099
2293
  * ```
2100
2294
  *
2295
+ * The `$pattern` operator accepts two wildcard characters:
2296
+ * * `*` matches zero or more characters
2297
+ * * `?` matches exactly one character
2298
+ *
2299
+ * If you want to match a string that contains a wildcard character, you can escape them using a backslash (`\`). You can escape a backslash by usign another backslash.
2300
+ *
2101
2301
  * We could also have `$endsWith` and `$startsWith` operators:
2102
2302
  *
2103
2303
  * ```json
@@ -2113,7 +2313,7 @@ declare type QueryTableVariables = {
2113
2313
  * }
2114
2314
  * ```
2115
2315
  *
2116
- * #### Numeric ranges
2316
+ * #### Numeric or datetime ranges
2117
2317
  *
2118
2318
  * ```json
2119
2319
  * {
@@ -2125,7 +2325,18 @@ declare type QueryTableVariables = {
2125
2325
  * }
2126
2326
  * }
2127
2327
  * ```
2128
- *
2328
+ * Date ranges support the same operators, with the date using the format defined in
2329
+ * [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339):
2330
+ * ```json
2331
+ * {
2332
+ * "filter": {
2333
+ * "<column_name>": {
2334
+ * "$gt": "2019-10-12T07:20:50.52Z",
2335
+ * "$lt": "2021-10-12T07:20:50.52Z"
2336
+ * }
2337
+ * }
2338
+ * }
2339
+ * ```
2129
2340
  * The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
2130
2341
  *
2131
2342
  * #### Negations
@@ -2393,6 +2604,39 @@ declare type QueryTableVariables = {
2393
2604
  * ```
2394
2605
  */
2395
2606
  declare const queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
2607
+ declare type SearchTablePathParams = {
2608
+ dbBranchName: DBBranchName;
2609
+ tableName: TableName;
2610
+ workspace: string;
2611
+ };
2612
+ declare type SearchTableError = ErrorWrapper<{
2613
+ status: 400;
2614
+ payload: BadRequestError;
2615
+ } | {
2616
+ status: 401;
2617
+ payload: AuthError;
2618
+ } | {
2619
+ status: 404;
2620
+ payload: SimpleError;
2621
+ }>;
2622
+ declare type SearchTableRequestBody = {
2623
+ query: string;
2624
+ fuzziness?: FuzzinessExpression;
2625
+ filter?: FilterExpression;
2626
+ highlight?: HighlightExpression;
2627
+ };
2628
+ declare type SearchTableVariables = {
2629
+ body: SearchTableRequestBody;
2630
+ pathParams: SearchTablePathParams;
2631
+ } & FetcherExtraProps;
2632
+ /**
2633
+ * Run a free text search operation in a particular table.
2634
+ *
2635
+ * The endpoint accepts a `query` parameter that is used for the free text search and a set of structured filters (via the `filter` parameter) that are applied before the search. The `filter` parameter uses the same syntax as the [query endpoint](/api-reference/db/db_branch_name/tables/table_name/) with the following exceptions:
2636
+ * * filters `$contains`, `$startsWith`, `$endsWith` don't work on columns of type `text`
2637
+ * * filtering on columns of type `multiple` is currently unsupported
2638
+ */
2639
+ declare const searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
2396
2640
  declare type SearchBranchPathParams = {
2397
2641
  dbBranchName: DBBranchName;
2398
2642
  workspace: string;
@@ -2408,9 +2652,13 @@ declare type SearchBranchError = ErrorWrapper<{
2408
2652
  payload: SimpleError;
2409
2653
  }>;
2410
2654
  declare type SearchBranchRequestBody = {
2411
- tables?: string[];
2655
+ tables?: (string | {
2656
+ table: string;
2657
+ filter?: FilterExpression;
2658
+ })[];
2412
2659
  query: string;
2413
- fuzziness?: number;
2660
+ fuzziness?: FuzzinessExpression;
2661
+ highlight?: HighlightExpression;
2414
2662
  };
2415
2663
  declare type SearchBranchVariables = {
2416
2664
  body: SearchBranchRequestBody;
@@ -2447,6 +2695,10 @@ declare const operationsByTag: {
2447
2695
  getDatabaseList: (variables: GetDatabaseListVariables) => Promise<ListDatabasesResponse>;
2448
2696
  createDatabase: (variables: CreateDatabaseVariables) => Promise<CreateDatabaseResponse>;
2449
2697
  deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
2698
+ getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
2699
+ addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
2700
+ removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
2701
+ resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
2450
2702
  };
2451
2703
  branch: {
2452
2704
  getBranchList: (variables: GetBranchListVariables) => Promise<ListBranchesResponse>;
@@ -2481,6 +2733,7 @@ declare const operationsByTag: {
2481
2733
  getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
2482
2734
  bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
2483
2735
  queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
2736
+ searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
2484
2737
  searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
2485
2738
  };
2486
2739
  };
@@ -2497,6 +2750,9 @@ interface XataApiClientOptions {
2497
2750
  apiKey?: string;
2498
2751
  host?: HostProvider;
2499
2752
  }
2753
+ /**
2754
+ * @deprecated Use XataApiPlugin instead
2755
+ */
2500
2756
  declare class XataApiClient {
2501
2757
  #private;
2502
2758
  constructor(options?: XataApiClientOptions);
@@ -2539,6 +2795,10 @@ declare class DatabaseApi {
2539
2795
  getDatabaseList(workspace: WorkspaceID): Promise<ListDatabasesResponse>;
2540
2796
  createDatabase(workspace: WorkspaceID, dbName: DBName, options?: CreateDatabaseRequestBody): Promise<CreateDatabaseResponse>;
2541
2797
  deleteDatabase(workspace: WorkspaceID, dbName: DBName): Promise<void>;
2798
+ getGitBranchesMapping(workspace: WorkspaceID, dbName: DBName): Promise<ListGitBranchesResponse>;
2799
+ addGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, body: AddGitBranchesEntryRequestBody): Promise<AddGitBranchesEntryResponse>;
2800
+ removeGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<void>;
2801
+ resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<ResolveBranchResponse>;
2542
2802
  }
2543
2803
  declare class BranchApi {
2544
2804
  private extraProps;
@@ -2579,6 +2839,7 @@ declare class RecordsApi {
2579
2839
  getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordRequestBody): Promise<XataRecord$1>;
2580
2840
  bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[]): Promise<BulkInsertTableRecordsResponse>;
2581
2841
  queryTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: QueryTableRequestBody): Promise<QueryResponse>;
2842
+ searchTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: SearchTableRequestBody): Promise<SearchResponse>;
2582
2843
  searchBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, query: SearchBranchRequestBody): Promise<SearchResponse>;
2583
2844
  }
2584
2845
 
@@ -2600,30 +2861,31 @@ declare type RequiredBy<T, K extends keyof T> = T & {
2600
2861
  };
2601
2862
  declare type GetArrayInnerType<T extends readonly any[]> = T[number];
2602
2863
  declare type SingleOrArray<T> = T | T[];
2603
- declare type Dictionary<T> = Record<string, T>;
2864
+ declare type OmitBy<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
2604
2865
 
2605
2866
  declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id' | DataProps<O> | NestedColumns<O, RecursivePath>;
2606
2867
  declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
2607
2868
  [K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord;
2608
2869
  }>>;
2609
- declare type ValueAtColumn<O, P extends SelectableColumn<O>> = P extends '*' ? Values<O> : P extends 'id' ? string : P extends keyof O ? O[P] : P extends `${infer K}.${infer V}` ? K extends keyof O ? Values<O[K] extends XataRecord ? (V extends SelectableColumn<O[K]> ? {
2610
- V: ValueAtColumn<O[K], V>;
2611
- } : never) : O[K]> : never : never;
2870
+ declare type ValueAtColumn<O, P extends SelectableColumn<O>> = P extends '*' ? Values<O> : P extends 'id' ? string : P extends keyof O ? O[P] : P extends `${infer K}.${infer V}` ? K extends keyof O ? Values<RemoveNullable<O[K]> extends Record<string, any> ? V extends SelectableColumn<RemoveNullable<O[K]>> ? {
2871
+ V: ValueAtColumn<RemoveNullable<O[K]>, V>;
2872
+ } : never : O[K]> : never : never;
2612
2873
  declare type MAX_RECURSION = 5;
2613
2874
  declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
2614
- [K in DataProps<O>]: If<IsArray<NonNullable<O[K]>>, K, // If the property is an array, we stop recursion. We don't support object arrays yet
2615
- If<IsObject<NonNullable<O[K]>>, NonNullable<O[K]> extends XataRecord ? SelectableColumn<NonNullable<O[K]>, [...RecursivePath, O[K]]> extends string ? K | `${K}.${SelectableColumn<NonNullable<O[K]>, [...RecursivePath, O[K]]>}` : never : `${K}.${StringKeys<NonNullable<O[K]>> | '*'}`, // This allows usage of objects that are not links
2875
+ [K in DataProps<O>]: If<IsArray<RemoveNullable<O[K]>>, K, // If the property is an array, we stop recursion. We don't support object arrays yet
2876
+ If<IsObject<RemoveNullable<O[K]>>, RemoveNullable<O[K]> extends XataRecord ? SelectableColumn<RemoveNullable<O[K]>, [...RecursivePath, O[K]]> extends infer Column ? Column extends string ? K | `${K}.${Column}` : never : never : `${K}.${StringKeys<RemoveNullable<O[K]>> | '*'}`, // This allows usage of objects that are not links
2616
2877
  K>>;
2617
2878
  }>, never>;
2618
2879
  declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
2619
2880
  declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
2620
- [K in N]: M extends SelectableColumn<NonNullable<O[K]>> ? NonNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], NestedValueAtColumn<NonNullable<O[K]>, M> & XataRecord> : ForwardNullable<O[K], NestedValueAtColumn<NonNullable<O[K]>, M>> : unknown;
2881
+ [K in N]: M extends SelectableColumn<RemoveNullable<O[K]>> ? RemoveNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], NestedValueAtColumn<RemoveNullable<O[K]>, M> & XataRecord> : ForwardNullable<O[K], NestedValueAtColumn<RemoveNullable<O[K]>, M>> : unknown;
2621
2882
  } : unknown : Key extends DataProps<O> ? {
2622
- [K in Key]: NonNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], SelectedPick<NonNullable<O[K]>, ['*']>> : O[K];
2883
+ [K in Key]: RemoveNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], SelectedPick<RemoveNullable<O[K]>, ['*']>> : O[K];
2623
2884
  } : Key extends '*' ? {
2624
- [K in StringKeys<O>]: NonNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], Link<NonNullable<O[K]>>> : O[K];
2885
+ [K in StringKeys<O>]: RemoveNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], Link<RemoveNullable<O[K]>>> : O[K];
2625
2886
  } : unknown;
2626
- declare type ForwardNullable<T, R> = T extends NonNullable<T> ? R : R | null;
2887
+ declare type RemoveNullable<T> = T extends null | undefined ? never : T;
2888
+ declare type ForwardNullable<T, R> = T extends RemoveNullable<T> ? R : R | null;
2627
2889
 
2628
2890
  /**
2629
2891
  * Represents an identifiable record from the database.
@@ -2640,16 +2902,11 @@ interface BaseData {
2640
2902
  /**
2641
2903
  * Represents a persisted record from the database.
2642
2904
  */
2643
- interface XataRecord extends Identifiable {
2905
+ interface XataRecord<ExtraMetadata extends Record<string, unknown> = Record<string, unknown>> extends Identifiable {
2644
2906
  /**
2645
- * Metadata of this record.
2907
+ * Get metadata of this record.
2646
2908
  */
2647
- xata: {
2648
- /**
2649
- * Number that is increased every time the record is updated.
2650
- */
2651
- version: number;
2652
- };
2909
+ getMetadata(): XataRecordMetadata & ExtraMetadata;
2653
2910
  /**
2654
2911
  * Retrieves a refreshed copy of the current record from the database.
2655
2912
  */
@@ -2657,7 +2914,7 @@ interface XataRecord extends Identifiable {
2657
2914
  /**
2658
2915
  * Performs a partial update of the current record. On success a new object is
2659
2916
  * returned and the current object is not mutated.
2660
- * @param data The columns and their values that have to be updated.
2917
+ * @param partialUpdate The columns and their values that have to be updated.
2661
2918
  * @returns A new record containing the latest values for all the columns of the current record.
2662
2919
  */
2663
2920
  update(partialUpdate: Partial<EditableData<Omit<this, keyof XataRecord>>>): Promise<Readonly<SelectedPick<this, ['*']>>>;
@@ -2676,11 +2933,18 @@ declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update
2676
2933
  /**
2677
2934
  * Performs a partial update of the current record. On success a new object is
2678
2935
  * returned and the current object is not mutated.
2679
- * @param data The columns and their values that have to be updated.
2936
+ * @param partialUpdate The columns and their values that have to be updated.
2680
2937
  * @returns A new record containing the latest values for all the columns of the current record.
2681
2938
  */
2682
2939
  update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
2683
2940
  };
2941
+ declare type XataRecordMetadata = {
2942
+ /**
2943
+ * Number that is increased every time the record is updated.
2944
+ */
2945
+ version: number;
2946
+ warnings?: string[];
2947
+ };
2684
2948
  declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
2685
2949
  declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
2686
2950
  declare type EditableData<O extends BaseData> = {
@@ -2764,8 +3028,8 @@ declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T e
2764
3028
  ],
2765
3029
  }
2766
3030
  */
2767
- declare type AggregatorFilter<Record> = {
2768
- [key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<Record>>;
3031
+ declare type AggregatorFilter<T> = {
3032
+ [key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<T>>;
2769
3033
  };
2770
3034
  /**
2771
3035
  * Existance filter
@@ -2780,10 +3044,10 @@ declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFi
2780
3044
  * Injects the Api filters on nested properties
2781
3045
  * Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
2782
3046
  */
2783
- declare type NestedApiFilter<T> = T extends Record<string, any> ? {
3047
+ declare type NestedApiFilter<T> = {
2784
3048
  [key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
2785
- } : PropertyFilter<T>;
2786
- declare type Filter<Record> = BaseApiFilter<Record> | NestedApiFilter<Record>;
3049
+ };
3050
+ declare type Filter<T> = T extends Record<string, any> ? BaseApiFilter<T> | NestedApiFilter<T> : PropertyFilter<T>;
2787
3051
 
2788
3052
  declare type SortDirection = 'asc' | 'desc';
2789
3053
  declare type SortFilterExtended<T extends XataRecord> = {
@@ -2795,13 +3059,21 @@ declare type SortFilterBase<T extends XataRecord> = {
2795
3059
  [Key in StringKeys<T>]: SortDirection;
2796
3060
  };
2797
3061
 
2798
- declare type QueryOptions<T extends XataRecord> = {
2799
- page?: PaginationOptions;
3062
+ declare type BaseOptions<T extends XataRecord> = {
2800
3063
  columns?: NonEmptyArray<SelectableColumn<T>>;
3064
+ cache?: number;
3065
+ };
3066
+ declare type CursorQueryOptions = {
3067
+ pagination?: CursorNavigationOptions & OffsetNavigationOptions;
3068
+ filter?: never;
3069
+ sort?: never;
3070
+ };
3071
+ declare type OffsetQueryOptions<T extends XataRecord> = {
3072
+ pagination?: OffsetNavigationOptions;
2801
3073
  filter?: FilterExpression;
2802
3074
  sort?: SortFilter<T> | SortFilter<T>[];
2803
- cache?: number;
2804
3075
  };
3076
+ declare type QueryOptions<T extends XataRecord> = BaseOptions<T> & (CursorQueryOptions | OffsetQueryOptions<T>);
2805
3077
  /**
2806
3078
  * Query objects contain the information of all filters, sorting, etc. to be included in the database query.
2807
3079
  *
@@ -2811,8 +3083,8 @@ declare type QueryOptions<T extends XataRecord> = {
2811
3083
  declare class Query<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
2812
3084
  #private;
2813
3085
  readonly meta: PaginationQueryMeta;
2814
- readonly records: Result[];
2815
- constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, parent?: Partial<QueryOptions<Record>>);
3086
+ readonly records: RecordArray<Result>;
3087
+ constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, rawParent?: Partial<QueryOptions<Record>>);
2816
3088
  getQueryOptions(): QueryOptions<Record>;
2817
3089
  key(): string;
2818
3090
  /**
@@ -2844,18 +3116,28 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
2844
3116
  *
2845
3117
  * ```
2846
3118
  * query.filter("columnName", columnValue)
2847
- * query.filter({
2848
- * "columnName": columnValue
2849
- * })
3119
+ * query.filter("columnName", operator(columnValue)) // Use gt, gte, lt, lte, startsWith,...
3120
+ * ```
3121
+ *
3122
+ * @param column The name of the column to filter.
3123
+ * @param value The value to filter.
3124
+ * @returns A new Query object.
3125
+ */
3126
+ filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
3127
+ /**
3128
+ * Builds a new query object adding one or more constraints. Examples:
3129
+ *
3130
+ * ```
3131
+ * query.filter({ "columnName": columnValue })
2850
3132
  * query.filter({
2851
3133
  * "columnName": operator(columnValue) // Use gt, gte, lt, lte, startsWith,...
2852
3134
  * })
2853
3135
  * ```
2854
3136
  *
3137
+ * @param filters A filter object
2855
3138
  * @returns A new Query object.
2856
3139
  */
2857
3140
  filter(filters: Filter<Record>): Query<Record, Result>;
2858
- filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
2859
3141
  /**
2860
3142
  * Builds a new query with a new sort option.
2861
3143
  * @param column The column name.
@@ -2869,48 +3151,148 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
2869
3151
  * @returns A new Query object.
2870
3152
  */
2871
3153
  select<K extends SelectableColumn<Record>>(columns: NonEmptyArray<K>): Query<Record, SelectedPick<Record, NonEmptyArray<K>>>;
3154
+ /**
3155
+ * Get paginated results
3156
+ *
3157
+ * @returns A page of results
3158
+ */
2872
3159
  getPaginated(): Promise<Page<Record, Result>>;
2873
- getPaginated(options: Omit<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
3160
+ /**
3161
+ * Get paginated results
3162
+ *
3163
+ * @param options Pagination options
3164
+ * @returns A page of results
3165
+ */
3166
+ getPaginated(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
3167
+ /**
3168
+ * Get paginated results
3169
+ *
3170
+ * @param options Pagination options
3171
+ * @returns A page of results
3172
+ */
2874
3173
  getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
3174
+ /**
3175
+ * Get results in an iterator
3176
+ *
3177
+ * @async
3178
+ * @returns Async interable of results
3179
+ */
2875
3180
  [Symbol.asyncIterator](): AsyncIterableIterator<Result>;
2876
- getIterator(chunk: number): AsyncGenerator<Result[]>;
2877
- getIterator(chunk: number, options: Omit<QueryOptions<Record>, 'columns' | 'page'>): AsyncGenerator<Result[]>;
2878
- getIterator<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(chunk: number, options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
3181
+ /**
3182
+ * Build an iterator of results
3183
+ *
3184
+ * @returns Async generator of results array
3185
+ */
3186
+ getIterator(): AsyncGenerator<Result[]>;
3187
+ /**
3188
+ * Build an iterator of results
3189
+ *
3190
+ * @param options Pagination options with batchSize
3191
+ * @returns Async generator of results array
3192
+ */
3193
+ getIterator(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3194
+ batchSize?: number;
3195
+ }): AsyncGenerator<Result[]>;
3196
+ /**
3197
+ * Build an iterator of results
3198
+ *
3199
+ * @param options Pagination options with batchSize
3200
+ * @returns Async generator of results array
3201
+ */
3202
+ getIterator<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3203
+ batchSize?: number;
3204
+ }>(options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
3205
+ /**
3206
+ * Performs the query in the database and returns a set of results.
3207
+ * @returns An array of records from the database.
3208
+ */
3209
+ getMany(): Promise<RecordArray<Result>>;
3210
+ /**
3211
+ * Performs the query in the database and returns a set of results.
3212
+ * @param options Additional options to be used when performing the query.
3213
+ * @returns An array of records from the database.
3214
+ */
3215
+ getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<RecordArray<Result>>;
2879
3216
  /**
2880
3217
  * Performs the query in the database and returns a set of results.
2881
3218
  * @param options Additional options to be used when performing the query.
2882
3219
  * @returns An array of records from the database.
2883
3220
  */
2884
- getMany(): Promise<Result[]>;
2885
- getMany(options: Omit<QueryOptions<Record>, 'columns'>): Promise<Result[]>;
2886
- getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3221
+ getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<RecordArray<SelectedPick<Record, typeof options['columns']>>>;
3222
+ /**
3223
+ * Performs the query in the database and returns all the results.
3224
+ * Warning: If there are a large number of results, this method can have performance implications.
3225
+ * @returns An array of records from the database.
3226
+ */
3227
+ getAll(): Promise<Result[]>;
2887
3228
  /**
2888
3229
  * Performs the query in the database and returns all the results.
2889
3230
  * Warning: If there are a large number of results, this method can have performance implications.
2890
3231
  * @param options Additional options to be used when performing the query.
2891
3232
  * @returns An array of records from the database.
2892
3233
  */
2893
- getAll(chunk?: number): Promise<Result[]>;
2894
- getAll(chunk: number | undefined, options: Omit<QueryOptions<Record>, 'columns' | 'page'>): Promise<Result[]>;
2895
- getAll<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(chunk: number | undefined, options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3234
+ getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3235
+ batchSize?: number;
3236
+ }): Promise<Result[]>;
2896
3237
  /**
2897
- * Performs the query in the database and returns the first result.
3238
+ * Performs the query in the database and returns all the results.
3239
+ * Warning: If there are a large number of results, this method can have performance implications.
2898
3240
  * @param options Additional options to be used when performing the query.
3241
+ * @returns An array of records from the database.
3242
+ */
3243
+ getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3244
+ batchSize?: number;
3245
+ }>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3246
+ /**
3247
+ * Performs the query in the database and returns the first result.
2899
3248
  * @returns The first record that matches the query, or null if no record matched the query.
2900
3249
  */
2901
3250
  getFirst(): Promise<Result | null>;
2902
- getFirst(options: Omit<QueryOptions<Record>, 'columns' | 'page'>): Promise<Result | null>;
2903
- getFirst<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3251
+ /**
3252
+ * Performs the query in the database and returns the first result.
3253
+ * @param options Additional options to be used when performing the query.
3254
+ * @returns The first record that matches the query, or null if no record matched the query.
3255
+ */
3256
+ getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
3257
+ /**
3258
+ * Performs the query in the database and returns the first result.
3259
+ * @param options Additional options to be used when performing the query.
3260
+ * @returns The first record that matches the query, or null if no record matched the query.
3261
+ */
3262
+ getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
2904
3263
  /**
2905
3264
  * Builds a new query object adding a cache TTL in milliseconds.
2906
3265
  * @param ttl The cache TTL in milliseconds.
2907
3266
  * @returns A new Query object.
2908
3267
  */
2909
3268
  cache(ttl: number): Query<Record, Result>;
3269
+ /**
3270
+ * Retrieve next page of records
3271
+ *
3272
+ * @returns A new page object.
3273
+ */
2910
3274
  nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3275
+ /**
3276
+ * Retrieve previous page of records
3277
+ *
3278
+ * @returns A new page object
3279
+ */
2911
3280
  previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3281
+ /**
3282
+ * Retrieve first page of records
3283
+ *
3284
+ * @returns A new page object
3285
+ */
2912
3286
  firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3287
+ /**
3288
+ * Retrieve last page of records
3289
+ *
3290
+ * @returns A new page object
3291
+ */
2913
3292
  lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3293
+ /**
3294
+ * @returns Boolean indicating if there is a next page
3295
+ */
2914
3296
  hasNextPage(): boolean;
2915
3297
  }
2916
3298
 
@@ -2922,7 +3304,7 @@ declare type PaginationQueryMeta = {
2922
3304
  };
2923
3305
  interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
2924
3306
  meta: PaginationQueryMeta;
2925
- records: Result[];
3307
+ records: RecordArray<Result>;
2926
3308
  nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
2927
3309
  previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
2928
3310
  firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
@@ -2942,7 +3324,7 @@ declare class Page<Record extends XataRecord, Result extends XataRecord = Record
2942
3324
  /**
2943
3325
  * The set of results for this page.
2944
3326
  */
2945
- readonly records: Result[];
3327
+ readonly records: RecordArray<Result>;
2946
3328
  constructor(query: Query<Record, Result>, meta: PaginationQueryMeta, records?: Result[]);
2947
3329
  /**
2948
3330
  * Retrieves the next page of results.
@@ -2990,14 +3372,44 @@ declare type OffsetNavigationOptions = {
2990
3372
  size?: number;
2991
3373
  offset?: number;
2992
3374
  };
2993
- declare type PaginationOptions = CursorNavigationOptions & OffsetNavigationOptions;
2994
3375
  declare const PAGINATION_MAX_SIZE = 200;
2995
- declare const PAGINATION_DEFAULT_SIZE = 200;
3376
+ declare const PAGINATION_DEFAULT_SIZE = 20;
2996
3377
  declare const PAGINATION_MAX_OFFSET = 800;
2997
3378
  declare const PAGINATION_DEFAULT_OFFSET = 0;
3379
+ declare function isCursorPaginationOptions(options: Record<string, unknown> | undefined | null): options is CursorNavigationOptions;
3380
+ declare class RecordArray<Result extends XataRecord> extends Array<Result> {
3381
+ #private;
3382
+ constructor(page: Paginable<any, Result>, overrideRecords?: Result[]);
3383
+ /**
3384
+ * Retrieve next page of records
3385
+ *
3386
+ * @returns A new array of objects
3387
+ */
3388
+ nextPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3389
+ /**
3390
+ * Retrieve previous page of records
3391
+ *
3392
+ * @returns A new array of objects
3393
+ */
3394
+ previousPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3395
+ /**
3396
+ * Retrieve first page of records
3397
+ *
3398
+ * @returns A new array of objects
3399
+ */
3400
+ firstPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3401
+ /**
3402
+ * Retrieve last page of records
3403
+ *
3404
+ * @returns A new array of objects
3405
+ */
3406
+ lastPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3407
+ /**
3408
+ * @returns Boolean indicating if there is a next page
3409
+ */
3410
+ hasNextPage(): boolean;
3411
+ }
2998
3412
 
2999
- declare type TableLink = string[];
3000
- declare type LinkDictionary = Dictionary<TableLink[]>;
3001
3413
  /**
3002
3414
  * Common interface for performing operations on a table.
3003
3415
  */
@@ -3022,6 +3434,12 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3022
3434
  * @returns The persisted record for the given id or null if the record could not be found.
3023
3435
  */
3024
3436
  abstract read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3437
+ /**
3438
+ * Queries multiple records from the table given their unique id.
3439
+ * @param ids The unique ids array.
3440
+ * @returns The persisted records for the given ids (if a record could not be found it is not returned).
3441
+ */
3442
+ abstract read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3025
3443
  /**
3026
3444
  * Partially update a single record.
3027
3445
  * @param object An object with its id and the columns to be updated.
@@ -3094,7 +3512,9 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3094
3512
  * @returns The found records.
3095
3513
  */
3096
3514
  abstract search(query: string, options?: {
3097
- fuzziness?: number;
3515
+ fuzziness?: FuzzinessExpression;
3516
+ highlight?: HighlightExpression;
3517
+ filter?: Filter<Record>;
3098
3518
  }): Promise<SelectedPick<Record, ['*']>[]>;
3099
3519
  abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
3100
3520
  }
@@ -3103,7 +3523,6 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
3103
3523
  db: SchemaPluginResult<any>;
3104
3524
  constructor(options: {
3105
3525
  table: string;
3106
- links?: LinkDictionary;
3107
3526
  db: SchemaPluginResult<any>;
3108
3527
  pluginOptions: XataPluginOptions;
3109
3528
  });
@@ -3111,6 +3530,7 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
3111
3530
  create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3112
3531
  create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
3113
3532
  read(recordId: string): Promise<SelectedPick<Record, ['*']> | null>;
3533
+ read(recordIds: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3114
3534
  update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
3115
3535
  update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
3116
3536
  update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
@@ -3119,7 +3539,9 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
3119
3539
  createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
3120
3540
  delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
3121
3541
  search(query: string, options?: {
3122
- fuzziness?: number;
3542
+ fuzziness?: FuzzinessExpression;
3543
+ highlight?: HighlightExpression;
3544
+ filter?: Filter<Record>;
3123
3545
  }): Promise<SelectedPick<Record, ['*']>[]>;
3124
3546
  query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
3125
3547
  }
@@ -3199,46 +3621,59 @@ declare const includesAny: <T>(value: T) => ArrayFilter<T>;
3199
3621
 
3200
3622
  declare type SchemaDefinition = {
3201
3623
  table: string;
3202
- links?: LinkDictionary;
3203
3624
  };
3204
3625
  declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
3205
3626
  [Key in keyof Schemas]: Repository<Schemas[Key]>;
3627
+ } & {
3628
+ [key: string]: Repository<XataRecord$1>;
3206
3629
  };
3207
3630
  declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3208
3631
  #private;
3209
- private links?;
3210
3632
  private tableNames?;
3211
- constructor(links?: LinkDictionary | undefined, tableNames?: string[] | undefined);
3633
+ constructor(tableNames?: string[] | undefined);
3212
3634
  build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
3213
3635
  }
3214
3636
 
3215
3637
  declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
3216
- fuzziness?: number;
3217
- tables?: Tables[];
3638
+ fuzziness?: FuzzinessExpression;
3639
+ highlight?: HighlightExpression;
3640
+ tables?: Array<Tables | Values<{
3641
+ [Model in GetArrayInnerType<NonNullable<Tables[]>>]: {
3642
+ table: Model;
3643
+ filter?: Filter<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
3644
+ };
3645
+ }>>;
3218
3646
  };
3219
3647
  declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
3220
3648
  all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
3221
- [Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]: {
3649
+ [Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]: {
3222
3650
  table: Model;
3223
3651
  record: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
3224
3652
  };
3225
3653
  }>[]>;
3226
3654
  byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
3227
- [Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
3655
+ [Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
3228
3656
  }>;
3229
3657
  };
3230
3658
  declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3231
3659
  #private;
3232
3660
  private db;
3233
- private links;
3234
- constructor(db: SchemaPluginResult<Schemas>, links: LinkDictionary);
3661
+ constructor(db: SchemaPluginResult<Schemas>);
3235
3662
  build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
3236
3663
  }
3237
- declare type SearchXataRecord = XataRecord & {
3238
- xata: {
3239
- table: string;
3664
+ declare type SearchXataRecord = XataRecord<SearchExtraProperties>;
3665
+ declare type SearchExtraProperties = {
3666
+ table: string;
3667
+ highlight?: {
3668
+ [key: string]: string[] | {
3669
+ [key: string]: any;
3670
+ };
3240
3671
  };
3241
3672
  };
3673
+ declare type ReturnTable<Table, Tables> = Table extends Tables ? Table : never;
3674
+ declare type ExtractTables<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>, TableOptions extends GetArrayInnerType<NonNullable<NonNullable<SearchOptions<Schemas, Tables>>['tables']>>> = TableOptions extends `${infer Table}` ? ReturnTable<Table, Tables> : TableOptions extends {
3675
+ table: infer Table;
3676
+ } ? ReturnTable<Table, Tables> : never;
3242
3677
 
3243
3678
  declare type BranchStrategyValue = string | undefined | null;
3244
3679
  declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
@@ -3254,7 +3689,7 @@ declare type BaseClientOptions = {
3254
3689
  };
3255
3690
  declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
3256
3691
  interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
3257
- new <Schemas extends Record<string, BaseData>>(options?: Partial<BaseClientOptions>, links?: LinkDictionary): Omit<{
3692
+ new <Schemas extends Record<string, BaseData> = {}>(options?: Partial<BaseClientOptions>, tables?: string[]): Omit<{
3258
3693
  db: Awaited<ReturnType<SchemaPlugin<Schemas>['build']>>;
3259
3694
  search: Awaited<ReturnType<SearchPlugin<Schemas>['build']>>;
3260
3695
  }, keyof Plugins> & {
@@ -3281,4 +3716,4 @@ declare class XataError extends Error {
3281
3716
  constructor(message: string, status: number);
3282
3717
  }
3283
3718
 
3284
- export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, CacheImpl, CancelWorkspaceMemberInviteError, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchError, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchVariables, CreateDatabaseError, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTableError, CreateTablePathParams, CreateTableVariables, CreateUserAPIKeyError, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceError, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchError, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnError, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabaseError, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordError, DeleteRecordPathParams, DeleteRecordVariables, DeleteTableError, DeleteTablePathParams, DeleteTableVariables, DeleteUserAPIKeyError, DeleteUserAPIKeyPathParams, DeleteUserAPIKeyVariables, DeleteUserError, DeleteUserVariables, DeleteWorkspaceError, DeleteWorkspacePathParams, DeleteWorkspaceVariables, EditableData, ExecuteBranchMigrationPlanError, ExecuteBranchMigrationPlanPathParams, ExecuteBranchMigrationPlanRequestBody, ExecuteBranchMigrationPlanVariables, FetchImpl, FetcherExtraProps, GetBranchDetailsError, GetBranchDetailsPathParams, GetBranchDetailsVariables, GetBranchListError, GetBranchListPathParams, GetBranchListVariables, GetBranchMetadataError, GetBranchMetadataPathParams, GetBranchMetadataVariables, GetBranchMigrationHistoryError, GetBranchMigrationHistoryPathParams, GetBranchMigrationHistoryRequestBody, GetBranchMigrationHistoryResponse, GetBranchMigrationHistoryVariables, GetBranchMigrationPlanError, GetBranchMigrationPlanPathParams, GetBranchMigrationPlanVariables, GetBranchStatsError, GetBranchStatsPathParams, GetBranchStatsResponse, GetBranchStatsVariables, GetColumnError, GetColumnPathParams, GetColumnVariables, GetDatabaseListError, GetDatabaseListPathParams, GetDatabaseListVariables, GetRecordError, GetRecordPathParams, GetRecordRequestBody, GetRecordVariables, GetTableColumnsError, GetTableColumnsPathParams, GetTableColumnsResponse, GetTableColumnsVariables, GetTableSchemaError, GetTableSchemaPathParams, GetTableSchemaResponse, GetTableSchemaVariables, GetUserAPIKeysError, GetUserAPIKeysResponse, GetUserAPIKeysVariables, GetUserError, GetUserVariables, GetWorkspaceError, GetWorkspaceMembersListError, GetWorkspaceMembersListPathParams, GetWorkspaceMembersListVariables, GetWorkspacePathParams, GetWorkspaceVariables, GetWorkspacesListError, GetWorkspacesListResponse, GetWorkspacesListVariables, Identifiable, InsertRecordError, InsertRecordPathParams, InsertRecordResponse, InsertRecordVariables, InsertRecordWithIDError, InsertRecordWithIDPathParams, InsertRecordWithIDQueryParams, InsertRecordWithIDVariables, InviteWorkspaceMemberError, InviteWorkspaceMemberPathParams, InviteWorkspaceMemberRequestBody, InviteWorkspaceMemberVariables, LinkDictionary, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationOptions, PaginationQueryMeta, Query, QueryTableError, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RemoveWorkspaceMemberError, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInviteError, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchError, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchOptions, SearchPlugin, SearchPluginResult, SelectableColumn, SelectedPick, SetTableSchemaError, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, SimpleCache, SimpleCacheOptions, UpdateBranchMetadataError, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnError, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDError, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTableError, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserError, UpdateUserVariables, UpdateWorkspaceError, UpdateWorkspaceMemberRoleError, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDError, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeWorkspaceMember, resendWorkspaceMemberInvite, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
3719
+ export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddGitBranchesEntryError, AddGitBranchesEntryPathParams, AddGitBranchesEntryRequestBody, AddGitBranchesEntryResponse, AddGitBranchesEntryVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, CacheImpl, CancelWorkspaceMemberInviteError, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchError, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchVariables, CreateDatabaseError, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTableError, CreateTablePathParams, CreateTableVariables, CreateUserAPIKeyError, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceError, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchError, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnError, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabaseError, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordError, DeleteRecordPathParams, DeleteRecordVariables, DeleteTableError, DeleteTablePathParams, DeleteTableVariables, DeleteUserAPIKeyError, DeleteUserAPIKeyPathParams, DeleteUserAPIKeyVariables, DeleteUserError, DeleteUserVariables, DeleteWorkspaceError, DeleteWorkspacePathParams, DeleteWorkspaceVariables, EditableData, ExecuteBranchMigrationPlanError, ExecuteBranchMigrationPlanPathParams, ExecuteBranchMigrationPlanRequestBody, ExecuteBranchMigrationPlanVariables, FetchImpl, FetcherExtraProps, GetBranchDetailsError, GetBranchDetailsPathParams, GetBranchDetailsVariables, GetBranchListError, GetBranchListPathParams, GetBranchListVariables, GetBranchMetadataError, GetBranchMetadataPathParams, GetBranchMetadataVariables, GetBranchMigrationHistoryError, GetBranchMigrationHistoryPathParams, GetBranchMigrationHistoryRequestBody, GetBranchMigrationHistoryResponse, GetBranchMigrationHistoryVariables, GetBranchMigrationPlanError, GetBranchMigrationPlanPathParams, GetBranchMigrationPlanVariables, GetBranchStatsError, GetBranchStatsPathParams, GetBranchStatsResponse, GetBranchStatsVariables, GetColumnError, GetColumnPathParams, GetColumnVariables, GetDatabaseListError, GetDatabaseListPathParams, GetDatabaseListVariables, GetGitBranchesMappingError, GetGitBranchesMappingPathParams, GetGitBranchesMappingVariables, GetRecordError, GetRecordPathParams, GetRecordRequestBody, GetRecordVariables, GetTableColumnsError, GetTableColumnsPathParams, GetTableColumnsResponse, GetTableColumnsVariables, GetTableSchemaError, GetTableSchemaPathParams, GetTableSchemaResponse, GetTableSchemaVariables, GetUserAPIKeysError, GetUserAPIKeysResponse, GetUserAPIKeysVariables, GetUserError, GetUserVariables, GetWorkspaceError, GetWorkspaceMembersListError, GetWorkspaceMembersListPathParams, GetWorkspaceMembersListVariables, GetWorkspacePathParams, GetWorkspaceVariables, GetWorkspacesListError, GetWorkspacesListResponse, GetWorkspacesListVariables, Identifiable, InsertRecordError, InsertRecordPathParams, InsertRecordResponse, InsertRecordVariables, InsertRecordWithIDError, InsertRecordWithIDPathParams, InsertRecordWithIDQueryParams, InsertRecordWithIDVariables, InviteWorkspaceMemberError, InviteWorkspaceMemberPathParams, InviteWorkspaceMemberRequestBody, InviteWorkspaceMemberVariables, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationQueryMeta, Query, QueryTableError, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RecordArray, RemoveGitBranchesEntryError, RemoveGitBranchesEntryPathParams, RemoveGitBranchesEntryQueryParams, RemoveGitBranchesEntryVariables, RemoveWorkspaceMemberError, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInviteError, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, ResolveBranchError, ResolveBranchPathParams, ResolveBranchQueryParams, ResolveBranchResponse, ResolveBranchVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchError, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchOptions, SearchPlugin, SearchPluginResult, SearchTableError, SearchTablePathParams, SearchTableRequestBody, SearchTableVariables, SelectableColumn, SelectedPick, SetTableSchemaError, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, SimpleCache, SimpleCacheOptions, UpdateBranchMetadataError, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnError, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDError, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTableError, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserError, UpdateUserVariables, UpdateWorkspaceError, UpdateWorkspaceMemberRoleError, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDError, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };