@xata.io/client 0.0.0-alpha.vfb4a018 → 0.0.0-alpha.vfd6aaf3

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
@@ -6,6 +6,9 @@ declare type FetchImpl = (url: string, init?: {
6
6
  ok: boolean;
7
7
  status: number;
8
8
  json(): Promise<any>;
9
+ headers?: {
10
+ get(name: string): string | null;
11
+ };
9
12
  }>;
10
13
  declare type WorkspaceApiUrlBuilder = (path: string, pathParams: Record<string, string>) => string;
11
14
  declare type FetcherExtraProps = {
@@ -268,6 +271,21 @@ declare type SortExpression = string[] | {
268
271
  [key: string]: SortOrder;
269
272
  }[];
270
273
  declare type SortOrder = 'asc' | 'desc';
274
+ /**
275
+ * Maximum [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) for the search terms. The Levenshtein
276
+ * distance is the number of one charcter changes needed to make two strings equal. The default is 1, meaning that single
277
+ * character typos per word are tollerated by search. You can set it to 0 to remove the typo tollerance or set it to 2
278
+ * to allow two typos in a word.
279
+ *
280
+ * @default 1
281
+ * @maximum 2
282
+ * @minimum 0
283
+ */
284
+ declare type FuzzinessExpression = number;
285
+ /**
286
+ * If the prefix type is set to "disabled" (the default), the search only matches full words. If the prefix type is set to "phrase", the search will return results that match prefixes of the search phrase.
287
+ */
288
+ declare type PrefixExpression = 'phrase' | 'disabled';
271
289
  /**
272
290
  * @minProperties 1
273
291
  */
@@ -281,6 +299,10 @@ declare type FilterExpression = {
281
299
  } & {
282
300
  [key: string]: FilterColumn;
283
301
  };
302
+ declare type HighlightExpression = {
303
+ enabled?: boolean;
304
+ encodeHTML?: boolean;
305
+ };
284
306
  declare type FilterList = FilterExpression | FilterExpression[];
285
307
  declare type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList;
286
308
  /**
@@ -366,6 +388,11 @@ declare type XataRecord$1 = {
366
388
  xata: {
367
389
  version: number;
368
390
  table?: string;
391
+ highlight?: {
392
+ [key: string]: string[] | {
393
+ [key: string]: any;
394
+ };
395
+ };
369
396
  warnings?: string[];
370
397
  };
371
398
  } & {
@@ -409,7 +436,10 @@ type schemas_TableMigration = TableMigration;
409
436
  type schemas_ColumnMigration = ColumnMigration;
410
437
  type schemas_SortExpression = SortExpression;
411
438
  type schemas_SortOrder = SortOrder;
439
+ type schemas_FuzzinessExpression = FuzzinessExpression;
440
+ type schemas_PrefixExpression = PrefixExpression;
412
441
  type schemas_FilterExpression = FilterExpression;
442
+ type schemas_HighlightExpression = HighlightExpression;
413
443
  type schemas_FilterList = FilterList;
414
444
  type schemas_FilterColumn = FilterColumn;
415
445
  type schemas_FilterColumnIncludes = FilterColumnIncludes;
@@ -462,7 +492,10 @@ declare namespace schemas {
462
492
  schemas_ColumnMigration as ColumnMigration,
463
493
  schemas_SortExpression as SortExpression,
464
494
  schemas_SortOrder as SortOrder,
495
+ schemas_FuzzinessExpression as FuzzinessExpression,
496
+ schemas_PrefixExpression as PrefixExpression,
465
497
  schemas_FilterExpression as FilterExpression,
498
+ schemas_HighlightExpression as HighlightExpression,
466
499
  schemas_FilterList as FilterList,
467
500
  schemas_FilterColumn as FilterColumn,
468
501
  schemas_FilterColumnIncludes as FilterColumnIncludes,
@@ -1151,14 +1184,15 @@ declare type ResolveBranchVariables = {
1151
1184
  } & FetcherExtraProps;
1152
1185
  /**
1153
1186
  * In order to resolve the database branch, the following algorithm is used:
1154
- * * if the `gitBranch` is found in the [git branches mapping](), the associated Xata branch is returned
1187
+ * * 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
1155
1188
  * * else, if a Xata branch with the exact same name as `gitBranch` exists, return it
1156
- * * else, return the default branch of the DB (currently `main` or the first branch)
1189
+ * * else, if `fallbackBranch` is provided and a branch with that name exists, return it
1190
+ * * else, return the default branch of the DB (`main` or the first branch)
1157
1191
  *
1158
1192
  * Example call:
1159
1193
  *
1160
1194
  * ```json
1161
- * // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test?fallbackBranch=tsg
1195
+ * // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test&fallbackBranch=tsg
1162
1196
  * ```
1163
1197
  *
1164
1198
  * Example response:
@@ -1458,8 +1492,9 @@ declare type UpdateTableVariables = {
1458
1492
  *
1459
1493
  * In the example below, we rename a table from “users” to “people”:
1460
1494
  *
1461
- * ```jsx
1462
- * PATCH /db/test:main/tables/users
1495
+ * ```json
1496
+ * // PATCH /db/test:main/tables/users
1497
+ *
1463
1498
  * {
1464
1499
  * "name": "people"
1465
1500
  * }
@@ -1867,7 +1902,7 @@ declare type QueryTableVariables = {
1867
1902
  * {
1868
1903
  * "columns": [...],
1869
1904
  * "filter": {
1870
- * "$all": [...]
1905
+ * "$all": [...],
1871
1906
  * "$any": [...]
1872
1907
  * ...
1873
1908
  * },
@@ -2005,7 +2040,7 @@ declare type QueryTableVariables = {
2005
2040
  * {
2006
2041
  * "name": "Kilian",
2007
2042
  * "address": {
2008
- * "street": "New street",
2043
+ * "street": "New street"
2009
2044
  * }
2010
2045
  * }
2011
2046
  * ```
@@ -2014,10 +2049,7 @@ declare type QueryTableVariables = {
2014
2049
  *
2015
2050
  * ```json
2016
2051
  * {
2017
- * "columns": [
2018
- * "*",
2019
- * "team.name"
2020
- * ]
2052
+ * "columns": ["*", "team.name"]
2021
2053
  * }
2022
2054
  * ```
2023
2055
  *
@@ -2035,7 +2067,7 @@ declare type QueryTableVariables = {
2035
2067
  * "team": {
2036
2068
  * "id": "XX",
2037
2069
  * "xata": {
2038
- * "version": 0,
2070
+ * "version": 0
2039
2071
  * },
2040
2072
  * "name": "first team"
2041
2073
  * }
@@ -2046,10 +2078,7 @@ declare type QueryTableVariables = {
2046
2078
  *
2047
2079
  * ```json
2048
2080
  * {
2049
- * "columns": [
2050
- * "*",
2051
- * "team.*"
2052
- * ]
2081
+ * "columns": ["*", "team.*"]
2053
2082
  * }
2054
2083
  * ```
2055
2084
  *
@@ -2067,7 +2096,7 @@ declare type QueryTableVariables = {
2067
2096
  * "team": {
2068
2097
  * "id": "XX",
2069
2098
  * "xata": {
2070
- * "version": 0,
2099
+ * "version": 0
2071
2100
  * },
2072
2101
  * "name": "first team",
2073
2102
  * "code": "A1",
@@ -2117,7 +2146,7 @@ declare type QueryTableVariables = {
2117
2146
  * ```json
2118
2147
  * {
2119
2148
  * "filter": {
2120
- * "name": "r2",
2149
+ * "name": "r2"
2121
2150
  * }
2122
2151
  * }
2123
2152
  * ```
@@ -2139,7 +2168,7 @@ declare type QueryTableVariables = {
2139
2168
  * ```json
2140
2169
  * {
2141
2170
  * "filter": {
2142
- * "settings.plan": "free",
2171
+ * "settings.plan": "free"
2143
2172
  * }
2144
2173
  * }
2145
2174
  * ```
@@ -2149,8 +2178,8 @@ declare type QueryTableVariables = {
2149
2178
  * "filter": {
2150
2179
  * "settings": {
2151
2180
  * "plan": "free"
2152
- * },
2153
- * },
2181
+ * }
2182
+ * }
2154
2183
  * }
2155
2184
  * ```
2156
2185
  *
@@ -2159,8 +2188,8 @@ declare type QueryTableVariables = {
2159
2188
  * ```json
2160
2189
  * {
2161
2190
  * "filter": {
2162
- * "settings.plan": {"$any": ["free", "paid"]}
2163
- * },
2191
+ * "settings.plan": { "$any": ["free", "paid"] }
2192
+ * }
2164
2193
  * }
2165
2194
  * ```
2166
2195
  *
@@ -2169,9 +2198,9 @@ declare type QueryTableVariables = {
2169
2198
  * ```json
2170
2199
  * {
2171
2200
  * "filter": {
2172
- * "settings.dark": true,
2173
- * "settings.plan": "free",
2174
- * },
2201
+ * "settings.dark": true,
2202
+ * "settings.plan": "free"
2203
+ * }
2175
2204
  * }
2176
2205
  * ```
2177
2206
  *
@@ -2182,11 +2211,11 @@ declare type QueryTableVariables = {
2182
2211
  * ```json
2183
2212
  * {
2184
2213
  * "filter": {
2185
- * "$any": {
2186
- * "settings.dark": true,
2187
- * "settings.plan": "free"
2188
- * }
2189
- * },
2214
+ * "$any": {
2215
+ * "settings.dark": true,
2216
+ * "settings.plan": "free"
2217
+ * }
2218
+ * }
2190
2219
  * }
2191
2220
  * ```
2192
2221
  *
@@ -2197,10 +2226,10 @@ declare type QueryTableVariables = {
2197
2226
  * "filter": {
2198
2227
  * "$any": [
2199
2228
  * {
2200
- * "name": "r1",
2229
+ * "name": "r1"
2201
2230
  * },
2202
2231
  * {
2203
- * "name": "r2",
2232
+ * "name": "r2"
2204
2233
  * }
2205
2234
  * ]
2206
2235
  * }
@@ -2212,7 +2241,7 @@ declare type QueryTableVariables = {
2212
2241
  * ```json
2213
2242
  * {
2214
2243
  * "filter": {
2215
- * "$exists": "settings",
2244
+ * "$exists": "settings"
2216
2245
  * }
2217
2246
  * }
2218
2247
  * ```
@@ -2224,10 +2253,10 @@ declare type QueryTableVariables = {
2224
2253
  * "filter": {
2225
2254
  * "$all": [
2226
2255
  * {
2227
- * "$exists": "settings",
2256
+ * "$exists": "settings"
2228
2257
  * },
2229
2258
  * {
2230
- * "$exists": "name",
2259
+ * "$exists": "name"
2231
2260
  * }
2232
2261
  * ]
2233
2262
  * }
@@ -2239,7 +2268,7 @@ declare type QueryTableVariables = {
2239
2268
  * ```json
2240
2269
  * {
2241
2270
  * "filter": {
2242
- * "$notExists": "settings",
2271
+ * "$notExists": "settings"
2243
2272
  * }
2244
2273
  * }
2245
2274
  * ```
@@ -2266,22 +2295,28 @@ declare type QueryTableVariables = {
2266
2295
  * {
2267
2296
  * "filter": {
2268
2297
  * "<column_name>": {
2269
- * "$pattern": "v*alue*"
2298
+ * "$pattern": "v*alu?"
2270
2299
  * }
2271
2300
  * }
2272
2301
  * }
2273
2302
  * ```
2274
2303
  *
2304
+ * The `$pattern` operator accepts two wildcard characters:
2305
+ * * `*` matches zero or more characters
2306
+ * * `?` matches exactly one character
2307
+ *
2308
+ * 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.
2309
+ *
2275
2310
  * We could also have `$endsWith` and `$startsWith` operators:
2276
2311
  *
2277
2312
  * ```json
2278
2313
  * {
2279
2314
  * "filter": {
2280
2315
  * "<column_name>": {
2281
- * "$endsWith": ".gz"
2316
+ * "$endsWith": ".gz"
2282
2317
  * },
2283
2318
  * "<column_name>": {
2284
- * "$startsWith": "tmp-"
2319
+ * "$startsWith": "tmp-"
2285
2320
  * }
2286
2321
  * }
2287
2322
  * }
@@ -2292,10 +2327,10 @@ declare type QueryTableVariables = {
2292
2327
  * ```json
2293
2328
  * {
2294
2329
  * "filter": {
2295
- * "<column_name>": {
2296
- * "$ge": 0,
2297
- * "$lt": 100
2298
- * }
2330
+ * "<column_name>": {
2331
+ * "$ge": 0,
2332
+ * "$lt": 100
2333
+ * }
2299
2334
  * }
2300
2335
  * }
2301
2336
  * ```
@@ -2313,7 +2348,6 @@ declare type QueryTableVariables = {
2313
2348
  * ```
2314
2349
  * The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
2315
2350
  *
2316
- *
2317
2351
  * #### Negations
2318
2352
  *
2319
2353
  * A general `$not` operator can inverse any operation.
@@ -2338,15 +2372,21 @@ declare type QueryTableVariables = {
2338
2372
  * {
2339
2373
  * "filter": {
2340
2374
  * "$not": {
2341
- * "$any": [{
2342
- * "<column_name1>": "value1"
2343
- * }, {
2344
- * "$all": [{
2345
- * "<column_name2>": "value2"
2346
- * }, {
2347
- * "<column_name3>": "value3"
2348
- * }]
2349
- * }]
2375
+ * "$any": [
2376
+ * {
2377
+ * "<column_name1>": "value1"
2378
+ * },
2379
+ * {
2380
+ * "$all": [
2381
+ * {
2382
+ * "<column_name2>": "value2"
2383
+ * },
2384
+ * {
2385
+ * "<column_name3>": "value3"
2386
+ * }
2387
+ * ]
2388
+ * }
2389
+ * ]
2350
2390
  * }
2351
2391
  * }
2352
2392
  * }
@@ -2401,8 +2441,8 @@ declare type QueryTableVariables = {
2401
2441
  * "<array name>": {
2402
2442
  * "$includes": {
2403
2443
  * "$all": [
2404
- * {"$contains": "label"},
2405
- * {"$not": {"$endsWith": "-debug"}}
2444
+ * { "$contains": "label" },
2445
+ * { "$not": { "$endsWith": "-debug" } }
2406
2446
  * ]
2407
2447
  * }
2408
2448
  * }
@@ -2422,9 +2462,7 @@ declare type QueryTableVariables = {
2422
2462
  * {
2423
2463
  * "filter": {
2424
2464
  * "settings.labels": {
2425
- * "$includesAll": [
2426
- * {"$contains": "label"},
2427
- * ]
2465
+ * "$includesAll": [{ "$contains": "label" }]
2428
2466
  * }
2429
2467
  * }
2430
2468
  * }
@@ -2472,7 +2510,6 @@ declare type QueryTableVariables = {
2472
2510
  * }
2473
2511
  * ```
2474
2512
  *
2475
- *
2476
2513
  * ### Pagination
2477
2514
  *
2478
2515
  * We offer cursor pagination and offset pagination. The offset pagination is limited
@@ -2538,8 +2575,8 @@ declare type QueryTableVariables = {
2538
2575
  * can be queried by update `page.after` to the returned cursor while keeping the
2539
2576
  * `page.before` cursor from the first range query.
2540
2577
  *
2541
- * The `filter` , `columns`, `sort` , and `page.size` configuration will be
2542
- * encoded with the cursor. The pagination request will be invalid if
2578
+ * The `filter` , `columns`, `sort` , and `page.size` configuration will be
2579
+ * encoded with the cursor. The pagination request will be invalid if
2543
2580
  * `filter` or `sort` is set. The columns returned and page size can be changed
2544
2581
  * anytime by passing the `columns` or `page.size` settings to the next query.
2545
2582
  *
@@ -2576,6 +2613,40 @@ declare type QueryTableVariables = {
2576
2613
  * ```
2577
2614
  */
2578
2615
  declare const queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
2616
+ declare type SearchTablePathParams = {
2617
+ dbBranchName: DBBranchName;
2618
+ tableName: TableName;
2619
+ workspace: string;
2620
+ };
2621
+ declare type SearchTableError = ErrorWrapper<{
2622
+ status: 400;
2623
+ payload: BadRequestError;
2624
+ } | {
2625
+ status: 401;
2626
+ payload: AuthError;
2627
+ } | {
2628
+ status: 404;
2629
+ payload: SimpleError;
2630
+ }>;
2631
+ declare type SearchTableRequestBody = {
2632
+ query: string;
2633
+ fuzziness?: FuzzinessExpression;
2634
+ prefix?: PrefixExpression;
2635
+ filter?: FilterExpression;
2636
+ highlight?: HighlightExpression;
2637
+ };
2638
+ declare type SearchTableVariables = {
2639
+ body: SearchTableRequestBody;
2640
+ pathParams: SearchTablePathParams;
2641
+ } & FetcherExtraProps;
2642
+ /**
2643
+ * Run a free text search operation in a particular table.
2644
+ *
2645
+ * 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:
2646
+ * * filters `$contains`, `$startsWith`, `$endsWith` don't work on columns of type `text`
2647
+ * * filtering on columns of type `multiple` is currently unsupported
2648
+ */
2649
+ declare const searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
2579
2650
  declare type SearchBranchPathParams = {
2580
2651
  dbBranchName: DBBranchName;
2581
2652
  workspace: string;
@@ -2591,9 +2662,13 @@ declare type SearchBranchError = ErrorWrapper<{
2591
2662
  payload: SimpleError;
2592
2663
  }>;
2593
2664
  declare type SearchBranchRequestBody = {
2594
- tables?: string[];
2665
+ tables?: (string | {
2666
+ table: string;
2667
+ filter?: FilterExpression;
2668
+ })[];
2595
2669
  query: string;
2596
- fuzziness?: number;
2670
+ fuzziness?: FuzzinessExpression;
2671
+ highlight?: HighlightExpression;
2597
2672
  };
2598
2673
  declare type SearchBranchVariables = {
2599
2674
  body: SearchBranchRequestBody;
@@ -2668,6 +2743,7 @@ declare const operationsByTag: {
2668
2743
  getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
2669
2744
  bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
2670
2745
  queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
2746
+ searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
2671
2747
  searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
2672
2748
  };
2673
2749
  };
@@ -2732,7 +2808,7 @@ declare class DatabaseApi {
2732
2808
  getGitBranchesMapping(workspace: WorkspaceID, dbName: DBName): Promise<ListGitBranchesResponse>;
2733
2809
  addGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, body: AddGitBranchesEntryRequestBody): Promise<AddGitBranchesEntryResponse>;
2734
2810
  removeGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<void>;
2735
- resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<ResolveBranchResponse>;
2811
+ resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch?: string, fallbackBranch?: string): Promise<ResolveBranchResponse>;
2736
2812
  }
2737
2813
  declare class BranchApi {
2738
2814
  private extraProps;
@@ -2773,6 +2849,7 @@ declare class RecordsApi {
2773
2849
  getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordRequestBody): Promise<XataRecord$1>;
2774
2850
  bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[]): Promise<BulkInsertTableRecordsResponse>;
2775
2851
  queryTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: QueryTableRequestBody): Promise<QueryResponse>;
2852
+ searchTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: SearchTableRequestBody): Promise<SearchResponse>;
2776
2853
  searchBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, query: SearchBranchRequestBody): Promise<SearchResponse>;
2777
2854
  }
2778
2855
 
@@ -2794,20 +2871,20 @@ declare type RequiredBy<T, K extends keyof T> = T & {
2794
2871
  };
2795
2872
  declare type GetArrayInnerType<T extends readonly any[]> = T[number];
2796
2873
  declare type SingleOrArray<T> = T | T[];
2797
- declare type Dictionary<T> = Record<string, T>;
2874
+ declare type OmitBy<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
2798
2875
 
2799
2876
  declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id' | DataProps<O> | NestedColumns<O, RecursivePath>;
2800
2877
  declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
2801
2878
  [K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord;
2802
2879
  }>>;
2803
- 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]> ? {
2804
- V: ValueAtColumn<O[K], V>;
2805
- } : never) : O[K]> : never : never;
2880
+ 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<NonNullable<O[K]> extends infer Item ? Item extends Record<string, any> ? V extends SelectableColumn<Item> ? {
2881
+ V: ValueAtColumn<Item, V>;
2882
+ } : never : O[K] : never> : never : never;
2806
2883
  declare type MAX_RECURSION = 5;
2807
2884
  declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
2808
- [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
2809
- 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
2810
- K>>;
2885
+ [K in DataProps<O>]: NonNullable<O[K]> extends infer Item ? If<IsArray<Item>, K, // If the property is an array, we stop recursion. We don't support object arrays yet
2886
+ If<IsObject<Item>, Item extends XataRecord ? SelectableColumn<Item, [...RecursivePath, Item]> extends infer Column ? Column extends string ? K | `${K}.${Column}` : never : never : Item extends Date ? K : `${K}.${StringKeys<Item> | '*'}`, // This allows usage of objects that are not links
2887
+ K>> : never;
2811
2888
  }>, never>;
2812
2889
  declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
2813
2890
  declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
@@ -2834,16 +2911,11 @@ interface BaseData {
2834
2911
  /**
2835
2912
  * Represents a persisted record from the database.
2836
2913
  */
2837
- interface XataRecord extends Identifiable {
2914
+ interface XataRecord<ExtraMetadata extends Record<string, unknown> = Record<string, unknown>> extends Identifiable {
2838
2915
  /**
2839
- * Metadata of this record.
2916
+ * Get metadata of this record.
2840
2917
  */
2841
- xata: {
2842
- /**
2843
- * Number that is increased every time the record is updated.
2844
- */
2845
- version: number;
2846
- };
2918
+ getMetadata(): XataRecordMetadata & ExtraMetadata;
2847
2919
  /**
2848
2920
  * Retrieves a refreshed copy of the current record from the database.
2849
2921
  */
@@ -2851,7 +2923,7 @@ interface XataRecord extends Identifiable {
2851
2923
  /**
2852
2924
  * Performs a partial update of the current record. On success a new object is
2853
2925
  * returned and the current object is not mutated.
2854
- * @param data The columns and their values that have to be updated.
2926
+ * @param partialUpdate The columns and their values that have to be updated.
2855
2927
  * @returns A new record containing the latest values for all the columns of the current record.
2856
2928
  */
2857
2929
  update(partialUpdate: Partial<EditableData<Omit<this, keyof XataRecord>>>): Promise<Readonly<SelectedPick<this, ['*']>>>;
@@ -2870,19 +2942,26 @@ declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update
2870
2942
  /**
2871
2943
  * Performs a partial update of the current record. On success a new object is
2872
2944
  * returned and the current object is not mutated.
2873
- * @param data The columns and their values that have to be updated.
2945
+ * @param partialUpdate The columns and their values that have to be updated.
2874
2946
  * @returns A new record containing the latest values for all the columns of the current record.
2875
2947
  */
2876
2948
  update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
2877
2949
  };
2950
+ declare type XataRecordMetadata = {
2951
+ /**
2952
+ * Number that is increased every time the record is updated.
2953
+ */
2954
+ version: number;
2955
+ warnings?: string[];
2956
+ };
2878
2957
  declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
2879
2958
  declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
2880
2959
  declare type EditableData<O extends BaseData> = {
2881
2960
  [K in keyof O]: O[K] extends XataRecord ? {
2882
2961
  id: string;
2883
- } : NonNullable<O[K]> extends XataRecord ? {
2962
+ } | string : NonNullable<O[K]> extends XataRecord ? {
2884
2963
  id: string;
2885
- } | null | undefined : O[K];
2964
+ } | string | null | undefined : O[K];
2886
2965
  };
2887
2966
 
2888
2967
  /**
@@ -2958,8 +3037,8 @@ declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T e
2958
3037
  ],
2959
3038
  }
2960
3039
  */
2961
- declare type AggregatorFilter<Record> = {
2962
- [key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<Record>>;
3040
+ declare type AggregatorFilter<T> = {
3041
+ [key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<T>>;
2963
3042
  };
2964
3043
  /**
2965
3044
  * Existance filter
@@ -2974,10 +3053,10 @@ declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFi
2974
3053
  * Injects the Api filters on nested properties
2975
3054
  * Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
2976
3055
  */
2977
- declare type NestedApiFilter<T> = T extends Record<string, any> ? {
3056
+ declare type NestedApiFilter<T> = {
2978
3057
  [key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
2979
- } : PropertyFilter<T>;
2980
- declare type Filter<Record> = BaseApiFilter<Record> | NestedApiFilter<Record>;
3058
+ };
3059
+ declare type Filter<T> = T extends Record<string, any> ? BaseApiFilter<T> | NestedApiFilter<T> : PropertyFilter<T>;
2981
3060
 
2982
3061
  declare type SortDirection = 'asc' | 'desc';
2983
3062
  declare type SortFilterExtended<T extends XataRecord> = {
@@ -2989,13 +3068,21 @@ declare type SortFilterBase<T extends XataRecord> = {
2989
3068
  [Key in StringKeys<T>]: SortDirection;
2990
3069
  };
2991
3070
 
2992
- declare type QueryOptions<T extends XataRecord> = {
2993
- page?: PaginationOptions;
3071
+ declare type BaseOptions<T extends XataRecord> = {
2994
3072
  columns?: NonEmptyArray<SelectableColumn<T>>;
3073
+ cache?: number;
3074
+ };
3075
+ declare type CursorQueryOptions = {
3076
+ pagination?: CursorNavigationOptions & OffsetNavigationOptions;
3077
+ filter?: never;
3078
+ sort?: never;
3079
+ };
3080
+ declare type OffsetQueryOptions<T extends XataRecord> = {
3081
+ pagination?: OffsetNavigationOptions;
2995
3082
  filter?: FilterExpression;
2996
3083
  sort?: SortFilter<T> | SortFilter<T>[];
2997
- cache?: number;
2998
3084
  };
3085
+ declare type QueryOptions<T extends XataRecord> = BaseOptions<T> & (CursorQueryOptions | OffsetQueryOptions<T>);
2999
3086
  /**
3000
3087
  * Query objects contain the information of all filters, sorting, etc. to be included in the database query.
3001
3088
  *
@@ -3005,8 +3092,8 @@ declare type QueryOptions<T extends XataRecord> = {
3005
3092
  declare class Query<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
3006
3093
  #private;
3007
3094
  readonly meta: PaginationQueryMeta;
3008
- readonly records: Result[];
3009
- constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, parent?: Partial<QueryOptions<Record>>);
3095
+ readonly records: RecordArray<Result>;
3096
+ constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, rawParent?: Partial<QueryOptions<Record>>);
3010
3097
  getQueryOptions(): QueryOptions<Record>;
3011
3098
  key(): string;
3012
3099
  /**
@@ -3038,18 +3125,28 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
3038
3125
  *
3039
3126
  * ```
3040
3127
  * query.filter("columnName", columnValue)
3041
- * query.filter({
3042
- * "columnName": columnValue
3043
- * })
3128
+ * query.filter("columnName", operator(columnValue)) // Use gt, gte, lt, lte, startsWith,...
3129
+ * ```
3130
+ *
3131
+ * @param column The name of the column to filter.
3132
+ * @param value The value to filter.
3133
+ * @returns A new Query object.
3134
+ */
3135
+ filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
3136
+ /**
3137
+ * Builds a new query object adding one or more constraints. Examples:
3138
+ *
3139
+ * ```
3140
+ * query.filter({ "columnName": columnValue })
3044
3141
  * query.filter({
3045
3142
  * "columnName": operator(columnValue) // Use gt, gte, lt, lte, startsWith,...
3046
3143
  * })
3047
3144
  * ```
3048
3145
  *
3146
+ * @param filters A filter object
3049
3147
  * @returns A new Query object.
3050
3148
  */
3051
3149
  filter(filters: Filter<Record>): Query<Record, Result>;
3052
- filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
3053
3150
  /**
3054
3151
  * Builds a new query with a new sort option.
3055
3152
  * @param column The column name.
@@ -3063,56 +3160,148 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
3063
3160
  * @returns A new Query object.
3064
3161
  */
3065
3162
  select<K extends SelectableColumn<Record>>(columns: NonEmptyArray<K>): Query<Record, SelectedPick<Record, NonEmptyArray<K>>>;
3163
+ /**
3164
+ * Get paginated results
3165
+ *
3166
+ * @returns A page of results
3167
+ */
3066
3168
  getPaginated(): Promise<Page<Record, Result>>;
3067
- getPaginated(options: Omit<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
3169
+ /**
3170
+ * Get paginated results
3171
+ *
3172
+ * @param options Pagination options
3173
+ * @returns A page of results
3174
+ */
3175
+ getPaginated(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
3176
+ /**
3177
+ * Get paginated results
3178
+ *
3179
+ * @param options Pagination options
3180
+ * @returns A page of results
3181
+ */
3068
3182
  getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
3183
+ /**
3184
+ * Get results in an iterator
3185
+ *
3186
+ * @async
3187
+ * @returns Async interable of results
3188
+ */
3069
3189
  [Symbol.asyncIterator](): AsyncIterableIterator<Result>;
3190
+ /**
3191
+ * Build an iterator of results
3192
+ *
3193
+ * @returns Async generator of results array
3194
+ */
3070
3195
  getIterator(): AsyncGenerator<Result[]>;
3071
- getIterator(options: Omit<QueryOptions<Record>, 'columns' | 'page'> & {
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: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3072
3203
  batchSize?: number;
3073
3204
  }): AsyncGenerator<Result[]>;
3074
- getIterator<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'> & {
3205
+ /**
3206
+ * Build an iterator of results
3207
+ *
3208
+ * @param options Pagination options with batchSize
3209
+ * @returns Async generator of results array
3210
+ */
3211
+ getIterator<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3075
3212
  batchSize?: number;
3076
3213
  }>(options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
3214
+ /**
3215
+ * Performs the query in the database and returns a set of results.
3216
+ * @returns An array of records from the database.
3217
+ */
3218
+ getMany(): Promise<RecordArray<Result>>;
3219
+ /**
3220
+ * Performs the query in the database and returns a set of results.
3221
+ * @param options Additional options to be used when performing the query.
3222
+ * @returns An array of records from the database.
3223
+ */
3224
+ getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<RecordArray<Result>>;
3077
3225
  /**
3078
3226
  * Performs the query in the database and returns a set of results.
3079
3227
  * @param options Additional options to be used when performing the query.
3080
3228
  * @returns An array of records from the database.
3081
3229
  */
3082
- getMany(): Promise<Result[]>;
3083
- getMany(options: Omit<QueryOptions<Record>, 'columns'>): Promise<Result[]>;
3084
- getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3230
+ getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<RecordArray<SelectedPick<Record, typeof options['columns']>>>;
3085
3231
  /**
3086
3232
  * Performs the query in the database and returns all the results.
3087
3233
  * Warning: If there are a large number of results, this method can have performance implications.
3088
- * @param options Additional options to be used when performing the query.
3089
3234
  * @returns An array of records from the database.
3090
3235
  */
3091
3236
  getAll(): Promise<Result[]>;
3092
- getAll(options: Omit<QueryOptions<Record>, 'columns' | 'page'> & {
3237
+ /**
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.
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: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3093
3244
  batchSize?: number;
3094
3245
  }): Promise<Result[]>;
3095
- getAll<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'> & {
3246
+ /**
3247
+ * Performs the query in the database and returns all the results.
3248
+ * Warning: If there are a large number of results, this method can have performance implications.
3249
+ * @param options Additional options to be used when performing the query.
3250
+ * @returns An array of records from the database.
3251
+ */
3252
+ getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3096
3253
  batchSize?: number;
3097
3254
  }>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3098
3255
  /**
3099
3256
  * Performs the query in the database and returns the first result.
3100
- * @param options Additional options to be used when performing the query.
3101
3257
  * @returns The first record that matches the query, or null if no record matched the query.
3102
3258
  */
3103
3259
  getFirst(): Promise<Result | null>;
3104
- getFirst(options: Omit<QueryOptions<Record>, 'columns' | 'page'>): Promise<Result | null>;
3105
- getFirst<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3260
+ /**
3261
+ * Performs the query in the database and returns the first result.
3262
+ * @param options Additional options to be used when performing the query.
3263
+ * @returns The first record that matches the query, or null if no record matched the query.
3264
+ */
3265
+ getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
3266
+ /**
3267
+ * Performs the query in the database and returns the first result.
3268
+ * @param options Additional options to be used when performing the query.
3269
+ * @returns The first record that matches the query, or null if no record matched the query.
3270
+ */
3271
+ getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3106
3272
  /**
3107
3273
  * Builds a new query object adding a cache TTL in milliseconds.
3108
3274
  * @param ttl The cache TTL in milliseconds.
3109
3275
  * @returns A new Query object.
3110
3276
  */
3111
3277
  cache(ttl: number): Query<Record, Result>;
3278
+ /**
3279
+ * Retrieve next page of records
3280
+ *
3281
+ * @returns A new page object.
3282
+ */
3112
3283
  nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3284
+ /**
3285
+ * Retrieve previous page of records
3286
+ *
3287
+ * @returns A new page object
3288
+ */
3113
3289
  previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3290
+ /**
3291
+ * Retrieve first page of records
3292
+ *
3293
+ * @returns A new page object
3294
+ */
3114
3295
  firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3296
+ /**
3297
+ * Retrieve last page of records
3298
+ *
3299
+ * @returns A new page object
3300
+ */
3115
3301
  lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3302
+ /**
3303
+ * @returns Boolean indicating if there is a next page
3304
+ */
3116
3305
  hasNextPage(): boolean;
3117
3306
  }
3118
3307
 
@@ -3124,7 +3313,7 @@ declare type PaginationQueryMeta = {
3124
3313
  };
3125
3314
  interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
3126
3315
  meta: PaginationQueryMeta;
3127
- records: Result[];
3316
+ records: RecordArray<Result>;
3128
3317
  nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3129
3318
  previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3130
3319
  firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
@@ -3144,7 +3333,7 @@ declare class Page<Record extends XataRecord, Result extends XataRecord = Record
3144
3333
  /**
3145
3334
  * The set of results for this page.
3146
3335
  */
3147
- readonly records: Result[];
3336
+ readonly records: RecordArray<Result>;
3148
3337
  constructor(query: Query<Record, Result>, meta: PaginationQueryMeta, records?: Result[]);
3149
3338
  /**
3150
3339
  * Retrieves the next page of results.
@@ -3192,14 +3381,45 @@ declare type OffsetNavigationOptions = {
3192
3381
  size?: number;
3193
3382
  offset?: number;
3194
3383
  };
3195
- declare type PaginationOptions = CursorNavigationOptions & OffsetNavigationOptions;
3196
3384
  declare const PAGINATION_MAX_SIZE = 200;
3197
- declare const PAGINATION_DEFAULT_SIZE = 200;
3385
+ declare const PAGINATION_DEFAULT_SIZE = 20;
3198
3386
  declare const PAGINATION_MAX_OFFSET = 800;
3199
3387
  declare const PAGINATION_DEFAULT_OFFSET = 0;
3388
+ declare function isCursorPaginationOptions(options: Record<string, unknown> | undefined | null): options is CursorNavigationOptions;
3389
+ declare class RecordArray<Result extends XataRecord> extends Array<Result> {
3390
+ #private;
3391
+ constructor(page: Paginable<any, Result>, overrideRecords?: Result[]);
3392
+ static parseConstructorParams(...args: any[]): any[];
3393
+ /**
3394
+ * Retrieve next page of records
3395
+ *
3396
+ * @returns A new array of objects
3397
+ */
3398
+ nextPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3399
+ /**
3400
+ * Retrieve previous page of records
3401
+ *
3402
+ * @returns A new array of objects
3403
+ */
3404
+ previousPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3405
+ /**
3406
+ * Retrieve first page of records
3407
+ *
3408
+ * @returns A new array of objects
3409
+ */
3410
+ firstPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3411
+ /**
3412
+ * Retrieve last page of records
3413
+ *
3414
+ * @returns A new array of objects
3415
+ */
3416
+ lastPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3417
+ /**
3418
+ * @returns Boolean indicating if there is a next page
3419
+ */
3420
+ hasNextPage(): boolean;
3421
+ }
3200
3422
 
3201
- declare type TableLink = string[];
3202
- declare type LinkDictionary = Dictionary<TableLink[]>;
3203
3423
  /**
3204
3424
  * Common interface for performing operations on a table.
3205
3425
  */
@@ -3224,6 +3444,24 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3224
3444
  * @returns The persisted record for the given id or null if the record could not be found.
3225
3445
  */
3226
3446
  abstract read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3447
+ /**
3448
+ * Queries multiple records from the table given their unique id.
3449
+ * @param ids The unique ids array.
3450
+ * @returns The persisted records for the given ids (if a record could not be found it is not returned).
3451
+ */
3452
+ abstract read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3453
+ /**
3454
+ * Queries a single record from the table by the id in the object.
3455
+ * @param object Object containing the id of the record.
3456
+ * @returns The persisted record for the given id or null if the record could not be found.
3457
+ */
3458
+ abstract read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3459
+ /**
3460
+ * Queries multiple records from the table by the ids in the objects.
3461
+ * @param objects Array of objects containing the ids of the records.
3462
+ * @returns The persisted records for the given ids (if a record could not be found it is not returned).
3463
+ */
3464
+ abstract read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3227
3465
  /**
3228
3466
  * Partially update a single record.
3229
3467
  * @param object An object with its id and the columns to be updated.
@@ -3296,7 +3534,9 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3296
3534
  * @returns The found records.
3297
3535
  */
3298
3536
  abstract search(query: string, options?: {
3299
- fuzziness?: number;
3537
+ fuzziness?: FuzzinessExpression;
3538
+ highlight?: HighlightExpression;
3539
+ filter?: Filter<Record>;
3300
3540
  }): Promise<SelectedPick<Record, ['*']>[]>;
3301
3541
  abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
3302
3542
  }
@@ -3305,7 +3545,6 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
3305
3545
  db: SchemaPluginResult<any>;
3306
3546
  constructor(options: {
3307
3547
  table: string;
3308
- links?: LinkDictionary;
3309
3548
  db: SchemaPluginResult<any>;
3310
3549
  pluginOptions: XataPluginOptions;
3311
3550
  });
@@ -3313,6 +3552,9 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
3313
3552
  create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3314
3553
  create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
3315
3554
  read(recordId: string): Promise<SelectedPick<Record, ['*']> | null>;
3555
+ read(recordIds: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3556
+ read(object: Identifiable): Promise<SelectedPick<Record, ['*']> | null>;
3557
+ read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3316
3558
  update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
3317
3559
  update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
3318
3560
  update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
@@ -3321,7 +3563,9 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
3321
3563
  createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
3322
3564
  delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
3323
3565
  search(query: string, options?: {
3324
- fuzziness?: number;
3566
+ fuzziness?: FuzzinessExpression;
3567
+ highlight?: HighlightExpression;
3568
+ filter?: Filter<Record>;
3325
3569
  }): Promise<SelectedPick<Record, ['*']>[]>;
3326
3570
  query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
3327
3571
  }
@@ -3401,7 +3645,6 @@ declare const includesAny: <T>(value: T) => ArrayFilter<T>;
3401
3645
 
3402
3646
  declare type SchemaDefinition = {
3403
3647
  table: string;
3404
- links?: LinkDictionary;
3405
3648
  };
3406
3649
  declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
3407
3650
  [Key in keyof Schemas]: Repository<Schemas[Key]>;
@@ -3410,39 +3653,51 @@ declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
3410
3653
  };
3411
3654
  declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3412
3655
  #private;
3413
- private links?;
3414
3656
  private tableNames?;
3415
- constructor(links?: LinkDictionary | undefined, tableNames?: string[] | undefined);
3657
+ constructor(tableNames?: string[] | undefined);
3416
3658
  build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
3417
3659
  }
3418
3660
 
3419
3661
  declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
3420
- fuzziness?: number;
3421
- tables?: Tables[];
3662
+ fuzziness?: FuzzinessExpression;
3663
+ highlight?: HighlightExpression;
3664
+ tables?: Array<Tables | Values<{
3665
+ [Model in GetArrayInnerType<NonNullable<Tables[]>>]: {
3666
+ table: Model;
3667
+ filter?: Filter<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
3668
+ };
3669
+ }>>;
3422
3670
  };
3423
3671
  declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
3424
3672
  all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
3425
- [Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]: {
3673
+ [Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]: {
3426
3674
  table: Model;
3427
3675
  record: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
3428
3676
  };
3429
3677
  }>[]>;
3430
3678
  byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
3431
- [Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
3679
+ [Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
3432
3680
  }>;
3433
3681
  };
3434
3682
  declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3435
3683
  #private;
3436
3684
  private db;
3437
- private links;
3438
- constructor(db: SchemaPluginResult<Schemas>, links: LinkDictionary);
3685
+ constructor(db: SchemaPluginResult<Schemas>);
3439
3686
  build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
3440
3687
  }
3441
- declare type SearchXataRecord = XataRecord & {
3442
- xata: {
3443
- table: string;
3688
+ declare type SearchXataRecord = XataRecord<SearchExtraProperties>;
3689
+ declare type SearchExtraProperties = {
3690
+ table: string;
3691
+ highlight?: {
3692
+ [key: string]: string[] | {
3693
+ [key: string]: any;
3694
+ };
3444
3695
  };
3445
3696
  };
3697
+ declare type ReturnTable<Table, Tables> = Table extends Tables ? Table : never;
3698
+ 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 {
3699
+ table: infer Table;
3700
+ } ? ReturnTable<Table, Tables> : never;
3446
3701
 
3447
3702
  declare type BranchStrategyValue = string | undefined | null;
3448
3703
  declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
@@ -3458,7 +3713,7 @@ declare type BaseClientOptions = {
3458
3713
  };
3459
3714
  declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
3460
3715
  interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
3461
- new <Schemas extends Record<string, BaseData> = {}>(options?: Partial<BaseClientOptions>, links?: LinkDictionary): Omit<{
3716
+ new <Schemas extends Record<string, BaseData> = {}>(options?: Partial<BaseClientOptions>, tables?: string[]): Omit<{
3462
3717
  db: Awaited<ReturnType<SchemaPlugin<Schemas>['build']>>;
3463
3718
  search: Awaited<ReturnType<SearchPlugin<Schemas>['build']>>;
3464
3719
  }, keyof Plugins> & {
@@ -3485,4 +3740,4 @@ declare class XataError extends Error {
3485
3740
  constructor(message: string, status: number);
3486
3741
  }
3487
3742
 
3488
- 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, 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, 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, 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, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
3743
+ 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 };