@xata.io/client 0.0.0-alpha.vf38f30b → 0.0.0-alpha.vf4789c2

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 = {
@@ -19,11 +22,39 @@ declare type ErrorWrapper<TError> = TError | {
19
22
  payload: string;
20
23
  };
21
24
 
25
+ interface CacheImpl {
26
+ cacheRecords: boolean;
27
+ defaultQueryTTL: number;
28
+ getAll(): Promise<Record<string, unknown>>;
29
+ get: <T>(key: string) => Promise<T | null>;
30
+ set: <T>(key: string, value: T) => Promise<void>;
31
+ delete: (key: string) => Promise<void>;
32
+ clear: () => Promise<void>;
33
+ }
34
+ interface SimpleCacheOptions {
35
+ max?: number;
36
+ cacheRecords?: boolean;
37
+ defaultQueryTTL?: number;
38
+ }
39
+ declare class SimpleCache implements CacheImpl {
40
+ #private;
41
+ capacity: number;
42
+ cacheRecords: boolean;
43
+ defaultQueryTTL: number;
44
+ constructor(options?: SimpleCacheOptions);
45
+ getAll(): Promise<Record<string, unknown>>;
46
+ get<T>(key: string): Promise<T | null>;
47
+ set<T>(key: string, value: T): Promise<void>;
48
+ delete(key: string): Promise<void>;
49
+ clear(): Promise<void>;
50
+ }
51
+
22
52
  declare abstract class XataPlugin {
23
53
  abstract build(options: XataPluginOptions): unknown | Promise<unknown>;
24
54
  }
25
55
  declare type XataPluginOptions = {
26
56
  getFetchProps: () => Promise<FetcherExtraProps>;
57
+ cache: CacheImpl;
27
58
  };
28
59
 
29
60
  /**
@@ -110,6 +141,12 @@ declare type ListBranchesResponse = {
110
141
  displayName: string;
111
142
  branches: Branch[];
112
143
  };
144
+ declare type ListGitBranchesResponse = {
145
+ mapping: {
146
+ gitBranch: string;
147
+ xataBranch: string;
148
+ }[];
149
+ };
113
150
  declare type Branch = {
114
151
  name: string;
115
152
  createdAt: DateTime;
@@ -158,7 +195,7 @@ declare type Table = {
158
195
  */
159
196
  declare type Column = {
160
197
  name: string;
161
- type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
198
+ type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object' | 'datetime';
162
199
  link?: {
163
200
  table: string;
164
201
  };
@@ -234,6 +271,21 @@ declare type SortExpression = string[] | {
234
271
  [key: string]: SortOrder;
235
272
  }[];
236
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';
237
289
  /**
238
290
  * @minProperties 1
239
291
  */
@@ -247,6 +299,10 @@ declare type FilterExpression = {
247
299
  } & {
248
300
  [key: string]: FilterColumn;
249
301
  };
302
+ declare type HighlightExpression = {
303
+ enabled?: boolean;
304
+ encodeHTML?: boolean;
305
+ };
250
306
  declare type FilterList = FilterExpression | FilterExpression[];
251
307
  declare type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList;
252
308
  /**
@@ -332,6 +388,11 @@ declare type XataRecord$1 = {
332
388
  xata: {
333
389
  version: number;
334
390
  table?: string;
391
+ highlight?: {
392
+ [key: string]: string[] | {
393
+ [key: string]: any;
394
+ };
395
+ };
335
396
  warnings?: string[];
336
397
  };
337
398
  } & {
@@ -354,6 +415,7 @@ type schemas_WorkspaceMembers = WorkspaceMembers;
354
415
  type schemas_InviteKey = InviteKey;
355
416
  type schemas_ListDatabasesResponse = ListDatabasesResponse;
356
417
  type schemas_ListBranchesResponse = ListBranchesResponse;
418
+ type schemas_ListGitBranchesResponse = ListGitBranchesResponse;
357
419
  type schemas_Branch = Branch;
358
420
  type schemas_BranchMetadata = BranchMetadata;
359
421
  type schemas_DBBranch = DBBranch;
@@ -374,7 +436,10 @@ type schemas_TableMigration = TableMigration;
374
436
  type schemas_ColumnMigration = ColumnMigration;
375
437
  type schemas_SortExpression = SortExpression;
376
438
  type schemas_SortOrder = SortOrder;
439
+ type schemas_FuzzinessExpression = FuzzinessExpression;
440
+ type schemas_PrefixExpression = PrefixExpression;
377
441
  type schemas_FilterExpression = FilterExpression;
442
+ type schemas_HighlightExpression = HighlightExpression;
378
443
  type schemas_FilterList = FilterList;
379
444
  type schemas_FilterColumn = FilterColumn;
380
445
  type schemas_FilterColumnIncludes = FilterColumnIncludes;
@@ -406,6 +471,7 @@ declare namespace schemas {
406
471
  schemas_InviteKey as InviteKey,
407
472
  schemas_ListDatabasesResponse as ListDatabasesResponse,
408
473
  schemas_ListBranchesResponse as ListBranchesResponse,
474
+ schemas_ListGitBranchesResponse as ListGitBranchesResponse,
409
475
  schemas_Branch as Branch,
410
476
  schemas_BranchMetadata as BranchMetadata,
411
477
  schemas_DBBranch as DBBranch,
@@ -426,7 +492,10 @@ declare namespace schemas {
426
492
  schemas_ColumnMigration as ColumnMigration,
427
493
  schemas_SortExpression as SortExpression,
428
494
  schemas_SortOrder as SortOrder,
495
+ schemas_FuzzinessExpression as FuzzinessExpression,
496
+ schemas_PrefixExpression as PrefixExpression,
429
497
  schemas_FilterExpression as FilterExpression,
498
+ schemas_HighlightExpression as HighlightExpression,
430
499
  schemas_FilterList as FilterList,
431
500
  schemas_FilterColumn as FilterColumn,
432
501
  schemas_FilterColumnIncludes as FilterColumnIncludes,
@@ -816,6 +885,9 @@ declare type InviteWorkspaceMemberError = ErrorWrapper<{
816
885
  } | {
817
886
  status: 404;
818
887
  payload: SimpleError;
888
+ } | {
889
+ status: 409;
890
+ payload: SimpleError;
819
891
  }>;
820
892
  declare type InviteWorkspaceMemberRequestBody = {
821
893
  email: string;
@@ -829,6 +901,35 @@ declare type InviteWorkspaceMemberVariables = {
829
901
  * Invite some user to join the workspace with the given role
830
902
  */
831
903
  declare const inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<WorkspaceInvite>;
904
+ declare type UpdateWorkspaceMemberInvitePathParams = {
905
+ workspaceId: WorkspaceID;
906
+ inviteId: InviteID;
907
+ };
908
+ declare type UpdateWorkspaceMemberInviteError = ErrorWrapper<{
909
+ status: 400;
910
+ payload: BadRequestError;
911
+ } | {
912
+ status: 401;
913
+ payload: AuthError;
914
+ } | {
915
+ status: 404;
916
+ payload: SimpleError;
917
+ } | {
918
+ status: 422;
919
+ payload: SimpleError;
920
+ }>;
921
+ declare type UpdateWorkspaceMemberInviteRequestBody = {
922
+ role: Role;
923
+ };
924
+ declare type UpdateWorkspaceMemberInviteVariables = {
925
+ body: UpdateWorkspaceMemberInviteRequestBody;
926
+ pathParams: UpdateWorkspaceMemberInvitePathParams;
927
+ } & FetcherExtraProps;
928
+ /**
929
+ * This operation provides a way to update an existing invite. Updates are performed in-place; they do not
930
+ * change the invite link, the expiry time, nor do they re-notify the recipient of the invite.
931
+ */
932
+ declare const updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<WorkspaceInvite>;
832
933
  declare type CancelWorkspaceMemberInvitePathParams = {
833
934
  workspaceId: WorkspaceID;
834
935
  inviteId: InviteID;
@@ -982,6 +1083,163 @@ declare type DeleteDatabaseVariables = {
982
1083
  * Delete a database and all of its branches and tables permanently.
983
1084
  */
984
1085
  declare const deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
1086
+ declare type GetGitBranchesMappingPathParams = {
1087
+ dbName: DBName;
1088
+ workspace: string;
1089
+ };
1090
+ declare type GetGitBranchesMappingError = ErrorWrapper<{
1091
+ status: 400;
1092
+ payload: BadRequestError;
1093
+ } | {
1094
+ status: 401;
1095
+ payload: AuthError;
1096
+ }>;
1097
+ declare type GetGitBranchesMappingVariables = {
1098
+ pathParams: GetGitBranchesMappingPathParams;
1099
+ } & FetcherExtraProps;
1100
+ /**
1101
+ * Lists all the git branches in the mapping, and their associated Xata branches.
1102
+ *
1103
+ * Example response:
1104
+ *
1105
+ * ```json
1106
+ * {
1107
+ * "mappings": [
1108
+ * {
1109
+ * "gitBranch": "main",
1110
+ * "xataBranch": "main"
1111
+ * },
1112
+ * {
1113
+ * "gitBranch": "gitBranch1",
1114
+ * "xataBranch": "xataBranch1"
1115
+ * }
1116
+ * {
1117
+ * "gitBranch": "xataBranch2",
1118
+ * "xataBranch": "xataBranch2"
1119
+ * }
1120
+ * ]
1121
+ * }
1122
+ * ```
1123
+ */
1124
+ declare const getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
1125
+ declare type AddGitBranchesEntryPathParams = {
1126
+ dbName: DBName;
1127
+ workspace: string;
1128
+ };
1129
+ declare type AddGitBranchesEntryError = ErrorWrapper<{
1130
+ status: 400;
1131
+ payload: BadRequestError;
1132
+ } | {
1133
+ status: 401;
1134
+ payload: AuthError;
1135
+ }>;
1136
+ declare type AddGitBranchesEntryResponse = {
1137
+ warning?: string;
1138
+ };
1139
+ declare type AddGitBranchesEntryRequestBody = {
1140
+ gitBranch: string;
1141
+ xataBranch: BranchName;
1142
+ };
1143
+ declare type AddGitBranchesEntryVariables = {
1144
+ body: AddGitBranchesEntryRequestBody;
1145
+ pathParams: AddGitBranchesEntryPathParams;
1146
+ } & FetcherExtraProps;
1147
+ /**
1148
+ * 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.
1149
+ *
1150
+ * 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.
1151
+ *
1152
+ * Example request:
1153
+ *
1154
+ * ```json
1155
+ * // POST https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches
1156
+ * {
1157
+ * "gitBranch": "fix/bug123",
1158
+ * "xataBranch": "fix_bug"
1159
+ * }
1160
+ * ```
1161
+ */
1162
+ declare const addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
1163
+ declare type RemoveGitBranchesEntryPathParams = {
1164
+ dbName: DBName;
1165
+ workspace: string;
1166
+ };
1167
+ declare type RemoveGitBranchesEntryQueryParams = {
1168
+ gitBranch: string;
1169
+ };
1170
+ declare type RemoveGitBranchesEntryError = ErrorWrapper<{
1171
+ status: 400;
1172
+ payload: BadRequestError;
1173
+ } | {
1174
+ status: 401;
1175
+ payload: AuthError;
1176
+ }>;
1177
+ declare type RemoveGitBranchesEntryVariables = {
1178
+ pathParams: RemoveGitBranchesEntryPathParams;
1179
+ queryParams: RemoveGitBranchesEntryQueryParams;
1180
+ } & FetcherExtraProps;
1181
+ /**
1182
+ * 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.
1183
+ *
1184
+ * Example request:
1185
+ *
1186
+ * ```json
1187
+ * // DELETE https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches?gitBranch=fix%2Fbug123
1188
+ * ```
1189
+ */
1190
+ declare const removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
1191
+ declare type ResolveBranchPathParams = {
1192
+ dbName: DBName;
1193
+ workspace: string;
1194
+ };
1195
+ declare type ResolveBranchQueryParams = {
1196
+ gitBranch?: string;
1197
+ fallbackBranch?: string;
1198
+ };
1199
+ declare type ResolveBranchError = ErrorWrapper<{
1200
+ status: 400;
1201
+ payload: BadRequestError;
1202
+ } | {
1203
+ status: 401;
1204
+ payload: AuthError;
1205
+ }>;
1206
+ declare type ResolveBranchResponse = {
1207
+ branch: string;
1208
+ reason: {
1209
+ code: 'FOUND_IN_MAPPING' | 'BRANCH_EXISTS' | 'FALLBACK_BRANCH' | 'DEFAULT_BRANCH';
1210
+ message: string;
1211
+ };
1212
+ };
1213
+ declare type ResolveBranchVariables = {
1214
+ pathParams: ResolveBranchPathParams;
1215
+ queryParams?: ResolveBranchQueryParams;
1216
+ } & FetcherExtraProps;
1217
+ /**
1218
+ * In order to resolve the database branch, the following algorithm is used:
1219
+ * * 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
1220
+ * * else, if a Xata branch with the exact same name as `gitBranch` exists, return it
1221
+ * * else, if `fallbackBranch` is provided and a branch with that name exists, return it
1222
+ * * else, return the default branch of the DB (`main` or the first branch)
1223
+ *
1224
+ * Example call:
1225
+ *
1226
+ * ```json
1227
+ * // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test&fallbackBranch=tsg
1228
+ * ```
1229
+ *
1230
+ * Example response:
1231
+ *
1232
+ * ```json
1233
+ * {
1234
+ * "branch": "main",
1235
+ * "reason": {
1236
+ * "code": "DEFAULT_BRANCH",
1237
+ * "message": "Default branch for this database (main)"
1238
+ * }
1239
+ * }
1240
+ * ```
1241
+ */
1242
+ declare const resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
985
1243
  declare type GetBranchDetailsPathParams = {
986
1244
  dbBranchName: DBBranchName;
987
1245
  workspace: string;
@@ -1266,8 +1524,9 @@ declare type UpdateTableVariables = {
1266
1524
  *
1267
1525
  * In the example below, we rename a table from “users” to “people”:
1268
1526
  *
1269
- * ```jsx
1270
- * PATCH /db/test:main/tables/users
1527
+ * ```json
1528
+ * // PATCH /db/test:main/tables/users
1529
+ *
1271
1530
  * {
1272
1531
  * "name": "people"
1273
1532
  * }
@@ -1624,6 +1883,9 @@ declare type BulkInsertTableRecordsError = ErrorWrapper<{
1624
1883
  } | {
1625
1884
  status: 404;
1626
1885
  payload: SimpleError;
1886
+ } | {
1887
+ status: 422;
1888
+ payload: SimpleError;
1627
1889
  }>;
1628
1890
  declare type BulkInsertTableRecordsResponse = {
1629
1891
  recordIDs: string[];
@@ -1675,7 +1937,7 @@ declare type QueryTableVariables = {
1675
1937
  * {
1676
1938
  * "columns": [...],
1677
1939
  * "filter": {
1678
- * "$all": [...]
1940
+ * "$all": [...],
1679
1941
  * "$any": [...]
1680
1942
  * ...
1681
1943
  * },
@@ -1721,7 +1983,11 @@ declare type QueryTableVariables = {
1721
1983
  * "link": {
1722
1984
  * "table": "users"
1723
1985
  * }
1724
- * }
1986
+ * },
1987
+ * {
1988
+ * "name": "foundedDate",
1989
+ * "type": "datetime"
1990
+ * },
1725
1991
  * ]
1726
1992
  * },
1727
1993
  * {
@@ -1809,7 +2075,7 @@ declare type QueryTableVariables = {
1809
2075
  * {
1810
2076
  * "name": "Kilian",
1811
2077
  * "address": {
1812
- * "street": "New street",
2078
+ * "street": "New street"
1813
2079
  * }
1814
2080
  * }
1815
2081
  * ```
@@ -1818,10 +2084,7 @@ declare type QueryTableVariables = {
1818
2084
  *
1819
2085
  * ```json
1820
2086
  * {
1821
- * "columns": [
1822
- * "*",
1823
- * "team.name"
1824
- * ]
2087
+ * "columns": ["*", "team.name"]
1825
2088
  * }
1826
2089
  * ```
1827
2090
  *
@@ -1839,7 +2102,7 @@ declare type QueryTableVariables = {
1839
2102
  * "team": {
1840
2103
  * "id": "XX",
1841
2104
  * "xata": {
1842
- * "version": 0,
2105
+ * "version": 0
1843
2106
  * },
1844
2107
  * "name": "first team"
1845
2108
  * }
@@ -1850,10 +2113,7 @@ declare type QueryTableVariables = {
1850
2113
  *
1851
2114
  * ```json
1852
2115
  * {
1853
- * "columns": [
1854
- * "*",
1855
- * "team.*"
1856
- * ]
2116
+ * "columns": ["*", "team.*"]
1857
2117
  * }
1858
2118
  * ```
1859
2119
  *
@@ -1871,10 +2131,11 @@ declare type QueryTableVariables = {
1871
2131
  * "team": {
1872
2132
  * "id": "XX",
1873
2133
  * "xata": {
1874
- * "version": 0,
2134
+ * "version": 0
1875
2135
  * },
1876
2136
  * "name": "first team",
1877
- * "code": "A1"
2137
+ * "code": "A1",
2138
+ * "foundedDate": "2020-03-04T10:43:54.32Z"
1878
2139
  * }
1879
2140
  * }
1880
2141
  * ```
@@ -1889,7 +2150,7 @@ declare type QueryTableVariables = {
1889
2150
  * `$none`, etc.
1890
2151
  *
1891
2152
  * All operators start with an `$` to differentiate them from column names
1892
- * (which are not allowed to start with an dollar sign).
2153
+ * (which are not allowed to start with a dollar sign).
1893
2154
  *
1894
2155
  * #### Exact matching and control operators
1895
2156
  *
@@ -1920,7 +2181,7 @@ declare type QueryTableVariables = {
1920
2181
  * ```json
1921
2182
  * {
1922
2183
  * "filter": {
1923
- * "name": "r2",
2184
+ * "name": "r2"
1924
2185
  * }
1925
2186
  * }
1926
2187
  * ```
@@ -1942,7 +2203,7 @@ declare type QueryTableVariables = {
1942
2203
  * ```json
1943
2204
  * {
1944
2205
  * "filter": {
1945
- * "settings.plan": "free",
2206
+ * "settings.plan": "free"
1946
2207
  * }
1947
2208
  * }
1948
2209
  * ```
@@ -1952,8 +2213,8 @@ declare type QueryTableVariables = {
1952
2213
  * "filter": {
1953
2214
  * "settings": {
1954
2215
  * "plan": "free"
1955
- * },
1956
- * },
2216
+ * }
2217
+ * }
1957
2218
  * }
1958
2219
  * ```
1959
2220
  *
@@ -1962,8 +2223,8 @@ declare type QueryTableVariables = {
1962
2223
  * ```json
1963
2224
  * {
1964
2225
  * "filter": {
1965
- * "settings.plan": {"$any": ["free", "paid"]}
1966
- * },
2226
+ * "settings.plan": { "$any": ["free", "paid"] }
2227
+ * }
1967
2228
  * }
1968
2229
  * ```
1969
2230
  *
@@ -1972,9 +2233,9 @@ declare type QueryTableVariables = {
1972
2233
  * ```json
1973
2234
  * {
1974
2235
  * "filter": {
1975
- * "settings.dark": true,
1976
- * "settings.plan": "free",
1977
- * },
2236
+ * "settings.dark": true,
2237
+ * "settings.plan": "free"
2238
+ * }
1978
2239
  * }
1979
2240
  * ```
1980
2241
  *
@@ -1985,11 +2246,11 @@ declare type QueryTableVariables = {
1985
2246
  * ```json
1986
2247
  * {
1987
2248
  * "filter": {
1988
- * "$any": {
1989
- * "settings.dark": true,
1990
- * "settings.plan": "free"
1991
- * }
1992
- * },
2249
+ * "$any": {
2250
+ * "settings.dark": true,
2251
+ * "settings.plan": "free"
2252
+ * }
2253
+ * }
1993
2254
  * }
1994
2255
  * ```
1995
2256
  *
@@ -2000,10 +2261,10 @@ declare type QueryTableVariables = {
2000
2261
  * "filter": {
2001
2262
  * "$any": [
2002
2263
  * {
2003
- * "name": "r1",
2264
+ * "name": "r1"
2004
2265
  * },
2005
2266
  * {
2006
- * "name": "r2",
2267
+ * "name": "r2"
2007
2268
  * }
2008
2269
  * ]
2009
2270
  * }
@@ -2015,7 +2276,7 @@ declare type QueryTableVariables = {
2015
2276
  * ```json
2016
2277
  * {
2017
2278
  * "filter": {
2018
- * "$exists": "settings",
2279
+ * "$exists": "settings"
2019
2280
  * }
2020
2281
  * }
2021
2282
  * ```
@@ -2027,10 +2288,10 @@ declare type QueryTableVariables = {
2027
2288
  * "filter": {
2028
2289
  * "$all": [
2029
2290
  * {
2030
- * "$exists": "settings",
2291
+ * "$exists": "settings"
2031
2292
  * },
2032
2293
  * {
2033
- * "$exists": "name",
2294
+ * "$exists": "name"
2034
2295
  * }
2035
2296
  * ]
2036
2297
  * }
@@ -2042,7 +2303,7 @@ declare type QueryTableVariables = {
2042
2303
  * ```json
2043
2304
  * {
2044
2305
  * "filter": {
2045
- * "$notExists": "settings",
2306
+ * "$notExists": "settings"
2046
2307
  * }
2047
2308
  * }
2048
2309
  * ```
@@ -2069,43 +2330,59 @@ declare type QueryTableVariables = {
2069
2330
  * {
2070
2331
  * "filter": {
2071
2332
  * "<column_name>": {
2072
- * "$pattern": "v*alue*"
2333
+ * "$pattern": "v*alu?"
2073
2334
  * }
2074
2335
  * }
2075
2336
  * }
2076
2337
  * ```
2077
2338
  *
2339
+ * The `$pattern` operator accepts two wildcard characters:
2340
+ * * `*` matches zero or more characters
2341
+ * * `?` matches exactly one character
2342
+ *
2343
+ * 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.
2344
+ *
2078
2345
  * We could also have `$endsWith` and `$startsWith` operators:
2079
2346
  *
2080
2347
  * ```json
2081
2348
  * {
2082
2349
  * "filter": {
2083
2350
  * "<column_name>": {
2084
- * "$endsWith": ".gz"
2351
+ * "$endsWith": ".gz"
2085
2352
  * },
2086
2353
  * "<column_name>": {
2087
- * "$startsWith": "tmp-"
2354
+ * "$startsWith": "tmp-"
2088
2355
  * }
2089
2356
  * }
2090
2357
  * }
2091
2358
  * ```
2092
2359
  *
2093
- * #### Numeric ranges
2360
+ * #### Numeric or datetime ranges
2094
2361
  *
2095
2362
  * ```json
2096
2363
  * {
2097
2364
  * "filter": {
2098
- * "<column_name>": {
2099
- * "$ge": 0,
2100
- * "$lt": 100
2101
- * }
2365
+ * "<column_name>": {
2366
+ * "$ge": 0,
2367
+ * "$lt": 100
2368
+ * }
2369
+ * }
2370
+ * }
2371
+ * ```
2372
+ * Date ranges support the same operators, with the date using the format defined in
2373
+ * [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339):
2374
+ * ```json
2375
+ * {
2376
+ * "filter": {
2377
+ * "<column_name>": {
2378
+ * "$gt": "2019-10-12T07:20:50.52Z",
2379
+ * "$lt": "2021-10-12T07:20:50.52Z"
2380
+ * }
2102
2381
  * }
2103
2382
  * }
2104
2383
  * ```
2105
- *
2106
2384
  * The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
2107
2385
  *
2108
- *
2109
2386
  * #### Negations
2110
2387
  *
2111
2388
  * A general `$not` operator can inverse any operation.
@@ -2130,15 +2407,21 @@ declare type QueryTableVariables = {
2130
2407
  * {
2131
2408
  * "filter": {
2132
2409
  * "$not": {
2133
- * "$any": [{
2134
- * "<column_name1>": "value1"
2135
- * }, {
2136
- * "$all": [{
2137
- * "<column_name2>": "value2"
2138
- * }, {
2139
- * "<column_name3>": "value3"
2140
- * }]
2141
- * }]
2410
+ * "$any": [
2411
+ * {
2412
+ * "<column_name1>": "value1"
2413
+ * },
2414
+ * {
2415
+ * "$all": [
2416
+ * {
2417
+ * "<column_name2>": "value2"
2418
+ * },
2419
+ * {
2420
+ * "<column_name3>": "value3"
2421
+ * }
2422
+ * ]
2423
+ * }
2424
+ * ]
2142
2425
  * }
2143
2426
  * }
2144
2427
  * }
@@ -2193,8 +2476,8 @@ declare type QueryTableVariables = {
2193
2476
  * "<array name>": {
2194
2477
  * "$includes": {
2195
2478
  * "$all": [
2196
- * {"$contains": "label"},
2197
- * {"$not": {"$endsWith": "-debug"}}
2479
+ * { "$contains": "label" },
2480
+ * { "$not": { "$endsWith": "-debug" } }
2198
2481
  * ]
2199
2482
  * }
2200
2483
  * }
@@ -2214,9 +2497,7 @@ declare type QueryTableVariables = {
2214
2497
  * {
2215
2498
  * "filter": {
2216
2499
  * "settings.labels": {
2217
- * "$includesAll": [
2218
- * {"$contains": "label"},
2219
- * ]
2500
+ * "$includesAll": [{ "$contains": "label" }]
2220
2501
  * }
2221
2502
  * }
2222
2503
  * }
@@ -2264,7 +2545,6 @@ declare type QueryTableVariables = {
2264
2545
  * }
2265
2546
  * ```
2266
2547
  *
2267
- *
2268
2548
  * ### Pagination
2269
2549
  *
2270
2550
  * We offer cursor pagination and offset pagination. The offset pagination is limited
@@ -2330,8 +2610,8 @@ declare type QueryTableVariables = {
2330
2610
  * can be queried by update `page.after` to the returned cursor while keeping the
2331
2611
  * `page.before` cursor from the first range query.
2332
2612
  *
2333
- * The `filter` , `columns`, `sort` , and `page.size` configuration will be
2334
- * encoded with the cursor. The pagination request will be invalid if
2613
+ * The `filter` , `columns`, `sort` , and `page.size` configuration will be
2614
+ * encoded with the cursor. The pagination request will be invalid if
2335
2615
  * `filter` or `sort` is set. The columns returned and page size can be changed
2336
2616
  * anytime by passing the `columns` or `page.size` settings to the next query.
2337
2617
  *
@@ -2368,6 +2648,40 @@ declare type QueryTableVariables = {
2368
2648
  * ```
2369
2649
  */
2370
2650
  declare const queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
2651
+ declare type SearchTablePathParams = {
2652
+ dbBranchName: DBBranchName;
2653
+ tableName: TableName;
2654
+ workspace: string;
2655
+ };
2656
+ declare type SearchTableError = ErrorWrapper<{
2657
+ status: 400;
2658
+ payload: BadRequestError;
2659
+ } | {
2660
+ status: 401;
2661
+ payload: AuthError;
2662
+ } | {
2663
+ status: 404;
2664
+ payload: SimpleError;
2665
+ }>;
2666
+ declare type SearchTableRequestBody = {
2667
+ query: string;
2668
+ fuzziness?: FuzzinessExpression;
2669
+ prefix?: PrefixExpression;
2670
+ filter?: FilterExpression;
2671
+ highlight?: HighlightExpression;
2672
+ };
2673
+ declare type SearchTableVariables = {
2674
+ body: SearchTableRequestBody;
2675
+ pathParams: SearchTablePathParams;
2676
+ } & FetcherExtraProps;
2677
+ /**
2678
+ * Run a free text search operation in a particular table.
2679
+ *
2680
+ * 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:
2681
+ * * filters `$contains`, `$startsWith`, `$endsWith` don't work on columns of type `text`
2682
+ * * filtering on columns of type `multiple` is currently unsupported
2683
+ */
2684
+ declare const searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
2371
2685
  declare type SearchBranchPathParams = {
2372
2686
  dbBranchName: DBBranchName;
2373
2687
  workspace: string;
@@ -2383,9 +2697,13 @@ declare type SearchBranchError = ErrorWrapper<{
2383
2697
  payload: SimpleError;
2384
2698
  }>;
2385
2699
  declare type SearchBranchRequestBody = {
2386
- tables?: string[];
2700
+ tables?: (string | {
2701
+ table: string;
2702
+ filter?: FilterExpression;
2703
+ })[];
2387
2704
  query: string;
2388
- fuzziness?: number;
2705
+ fuzziness?: FuzzinessExpression;
2706
+ highlight?: HighlightExpression;
2389
2707
  };
2390
2708
  declare type SearchBranchVariables = {
2391
2709
  body: SearchBranchRequestBody;
@@ -2414,6 +2732,7 @@ declare const operationsByTag: {
2414
2732
  updateWorkspaceMemberRole: (variables: UpdateWorkspaceMemberRoleVariables) => Promise<undefined>;
2415
2733
  removeWorkspaceMember: (variables: RemoveWorkspaceMemberVariables) => Promise<undefined>;
2416
2734
  inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<WorkspaceInvite>;
2735
+ updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<WorkspaceInvite>;
2417
2736
  cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
2418
2737
  resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
2419
2738
  acceptWorkspaceMemberInvite: (variables: AcceptWorkspaceMemberInviteVariables) => Promise<undefined>;
@@ -2422,6 +2741,10 @@ declare const operationsByTag: {
2422
2741
  getDatabaseList: (variables: GetDatabaseListVariables) => Promise<ListDatabasesResponse>;
2423
2742
  createDatabase: (variables: CreateDatabaseVariables) => Promise<CreateDatabaseResponse>;
2424
2743
  deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
2744
+ getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
2745
+ addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
2746
+ removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
2747
+ resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
2425
2748
  };
2426
2749
  branch: {
2427
2750
  getBranchList: (variables: GetBranchListVariables) => Promise<ListBranchesResponse>;
@@ -2456,6 +2779,7 @@ declare const operationsByTag: {
2456
2779
  getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
2457
2780
  bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
2458
2781
  queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
2782
+ searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
2459
2783
  searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
2460
2784
  };
2461
2785
  };
@@ -2472,6 +2796,9 @@ interface XataApiClientOptions {
2472
2796
  apiKey?: string;
2473
2797
  host?: HostProvider;
2474
2798
  }
2799
+ /**
2800
+ * @deprecated Use XataApiPlugin instead
2801
+ */
2475
2802
  declare class XataApiClient {
2476
2803
  #private;
2477
2804
  constructor(options?: XataApiClientOptions);
@@ -2504,6 +2831,7 @@ declare class WorkspaceApi {
2504
2831
  updateWorkspaceMemberRole(workspaceId: WorkspaceID, userId: UserID, role: Role): Promise<void>;
2505
2832
  removeWorkspaceMember(workspaceId: WorkspaceID, userId: UserID): Promise<void>;
2506
2833
  inviteWorkspaceMember(workspaceId: WorkspaceID, email: string, role: Role): Promise<WorkspaceInvite>;
2834
+ updateWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID, role: Role): Promise<WorkspaceInvite>;
2507
2835
  cancelWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
2508
2836
  resendWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
2509
2837
  acceptWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteKey: InviteKey): Promise<void>;
@@ -2514,6 +2842,10 @@ declare class DatabaseApi {
2514
2842
  getDatabaseList(workspace: WorkspaceID): Promise<ListDatabasesResponse>;
2515
2843
  createDatabase(workspace: WorkspaceID, dbName: DBName, options?: CreateDatabaseRequestBody): Promise<CreateDatabaseResponse>;
2516
2844
  deleteDatabase(workspace: WorkspaceID, dbName: DBName): Promise<void>;
2845
+ getGitBranchesMapping(workspace: WorkspaceID, dbName: DBName): Promise<ListGitBranchesResponse>;
2846
+ addGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, body: AddGitBranchesEntryRequestBody): Promise<AddGitBranchesEntryResponse>;
2847
+ removeGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<void>;
2848
+ resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch?: string, fallbackBranch?: string): Promise<ResolveBranchResponse>;
2517
2849
  }
2518
2850
  declare class BranchApi {
2519
2851
  private extraProps;
@@ -2554,6 +2886,7 @@ declare class RecordsApi {
2554
2886
  getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordRequestBody): Promise<XataRecord$1>;
2555
2887
  bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[]): Promise<BulkInsertTableRecordsResponse>;
2556
2888
  queryTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: QueryTableRequestBody): Promise<QueryResponse>;
2889
+ searchTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: SearchTableRequestBody): Promise<SearchResponse>;
2557
2890
  searchBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, query: SearchBranchRequestBody): Promise<SearchResponse>;
2558
2891
  }
2559
2892
 
@@ -2575,20 +2908,20 @@ declare type RequiredBy<T, K extends keyof T> = T & {
2575
2908
  };
2576
2909
  declare type GetArrayInnerType<T extends readonly any[]> = T[number];
2577
2910
  declare type SingleOrArray<T> = T | T[];
2578
- declare type Dictionary<T> = Record<string, T>;
2911
+ declare type OmitBy<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
2579
2912
 
2580
2913
  declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id' | DataProps<O> | NestedColumns<O, RecursivePath>;
2581
2914
  declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
2582
2915
  [K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord;
2583
2916
  }>>;
2584
- 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]> ? {
2585
- V: ValueAtColumn<O[K], V>;
2586
- } : never) : O[K]> : never : never;
2917
+ 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> ? {
2918
+ V: ValueAtColumn<Item, V>;
2919
+ } : never : O[K] : never> : never : never;
2587
2920
  declare type MAX_RECURSION = 5;
2588
2921
  declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
2589
- [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
2590
- 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
2591
- K>>;
2922
+ [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
2923
+ 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
2924
+ K>> : never;
2592
2925
  }>, never>;
2593
2926
  declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
2594
2927
  declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
@@ -2615,16 +2948,11 @@ interface BaseData {
2615
2948
  /**
2616
2949
  * Represents a persisted record from the database.
2617
2950
  */
2618
- interface XataRecord extends Identifiable {
2951
+ interface XataRecord<ExtraMetadata extends Record<string, unknown> = Record<string, unknown>> extends Identifiable {
2619
2952
  /**
2620
- * Metadata of this record.
2953
+ * Get metadata of this record.
2621
2954
  */
2622
- xata: {
2623
- /**
2624
- * Number that is increased every time the record is updated.
2625
- */
2626
- version: number;
2627
- };
2955
+ getMetadata(): XataRecordMetadata & ExtraMetadata;
2628
2956
  /**
2629
2957
  * Retrieves a refreshed copy of the current record from the database.
2630
2958
  */
@@ -2632,7 +2960,7 @@ interface XataRecord extends Identifiable {
2632
2960
  /**
2633
2961
  * Performs a partial update of the current record. On success a new object is
2634
2962
  * returned and the current object is not mutated.
2635
- * @param data The columns and their values that have to be updated.
2963
+ * @param partialUpdate The columns and their values that have to be updated.
2636
2964
  * @returns A new record containing the latest values for all the columns of the current record.
2637
2965
  */
2638
2966
  update(partialUpdate: Partial<EditableData<Omit<this, keyof XataRecord>>>): Promise<Readonly<SelectedPick<this, ['*']>>>;
@@ -2651,19 +2979,26 @@ declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update
2651
2979
  /**
2652
2980
  * Performs a partial update of the current record. On success a new object is
2653
2981
  * returned and the current object is not mutated.
2654
- * @param data The columns and their values that have to be updated.
2982
+ * @param partialUpdate The columns and their values that have to be updated.
2655
2983
  * @returns A new record containing the latest values for all the columns of the current record.
2656
2984
  */
2657
2985
  update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
2658
2986
  };
2987
+ declare type XataRecordMetadata = {
2988
+ /**
2989
+ * Number that is increased every time the record is updated.
2990
+ */
2991
+ version: number;
2992
+ warnings?: string[];
2993
+ };
2659
2994
  declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
2660
2995
  declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
2661
2996
  declare type EditableData<O extends BaseData> = {
2662
2997
  [K in keyof O]: O[K] extends XataRecord ? {
2663
2998
  id: string;
2664
- } : NonNullable<O[K]> extends XataRecord ? {
2999
+ } | string : NonNullable<O[K]> extends XataRecord ? {
2665
3000
  id: string;
2666
- } | null | undefined : O[K];
3001
+ } | string | null | undefined : O[K];
2667
3002
  };
2668
3003
 
2669
3004
  /**
@@ -2739,8 +3074,8 @@ declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T e
2739
3074
  ],
2740
3075
  }
2741
3076
  */
2742
- declare type AggregatorFilter<Record> = {
2743
- [key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<Record>>;
3077
+ declare type AggregatorFilter<T> = {
3078
+ [key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<T>>;
2744
3079
  };
2745
3080
  /**
2746
3081
  * Existance filter
@@ -2755,10 +3090,10 @@ declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFi
2755
3090
  * Injects the Api filters on nested properties
2756
3091
  * Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
2757
3092
  */
2758
- declare type NestedApiFilter<T> = T extends Record<string, any> ? {
3093
+ declare type NestedApiFilter<T> = {
2759
3094
  [key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
2760
- } : PropertyFilter<T>;
2761
- declare type Filter<Record> = BaseApiFilter<Record> | NestedApiFilter<Record>;
3095
+ };
3096
+ declare type Filter<T> = T extends Record<string, any> ? BaseApiFilter<T> | NestedApiFilter<T> : PropertyFilter<T>;
2762
3097
 
2763
3098
  declare type SortDirection = 'asc' | 'desc';
2764
3099
  declare type SortFilterExtended<T extends XataRecord> = {
@@ -2770,12 +3105,21 @@ declare type SortFilterBase<T extends XataRecord> = {
2770
3105
  [Key in StringKeys<T>]: SortDirection;
2771
3106
  };
2772
3107
 
2773
- declare type QueryOptions<T extends XataRecord> = {
2774
- page?: PaginationOptions;
3108
+ declare type BaseOptions<T extends XataRecord> = {
2775
3109
  columns?: NonEmptyArray<SelectableColumn<T>>;
3110
+ cache?: number;
3111
+ };
3112
+ declare type CursorQueryOptions = {
3113
+ pagination?: CursorNavigationOptions & OffsetNavigationOptions;
3114
+ filter?: never;
3115
+ sort?: never;
3116
+ };
3117
+ declare type OffsetQueryOptions<T extends XataRecord> = {
3118
+ pagination?: OffsetNavigationOptions;
2776
3119
  filter?: FilterExpression;
2777
3120
  sort?: SortFilter<T> | SortFilter<T>[];
2778
3121
  };
3122
+ declare type QueryOptions<T extends XataRecord> = BaseOptions<T> & (CursorQueryOptions | OffsetQueryOptions<T>);
2779
3123
  /**
2780
3124
  * Query objects contain the information of all filters, sorting, etc. to be included in the database query.
2781
3125
  *
@@ -2785,9 +3129,10 @@ declare type QueryOptions<T extends XataRecord> = {
2785
3129
  declare class Query<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
2786
3130
  #private;
2787
3131
  readonly meta: PaginationQueryMeta;
2788
- readonly records: Result[];
2789
- constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, parent?: Partial<QueryOptions<Record>>);
3132
+ readonly records: RecordArray<Result>;
3133
+ constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, rawParent?: Partial<QueryOptions<Record>>);
2790
3134
  getQueryOptions(): QueryOptions<Record>;
3135
+ key(): string;
2791
3136
  /**
2792
3137
  * Builds a new query object representing a logical OR between the given subqueries.
2793
3138
  * @param queries An array of subqueries.
@@ -2817,18 +3162,28 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
2817
3162
  *
2818
3163
  * ```
2819
3164
  * query.filter("columnName", columnValue)
2820
- * query.filter({
2821
- * "columnName": columnValue
2822
- * })
3165
+ * query.filter("columnName", operator(columnValue)) // Use gt, gte, lt, lte, startsWith,...
3166
+ * ```
3167
+ *
3168
+ * @param column The name of the column to filter.
3169
+ * @param value The value to filter.
3170
+ * @returns A new Query object.
3171
+ */
3172
+ filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
3173
+ /**
3174
+ * Builds a new query object adding one or more constraints. Examples:
3175
+ *
3176
+ * ```
3177
+ * query.filter({ "columnName": columnValue })
2823
3178
  * query.filter({
2824
3179
  * "columnName": operator(columnValue) // Use gt, gte, lt, lte, startsWith,...
2825
3180
  * })
2826
3181
  * ```
2827
3182
  *
3183
+ * @param filters A filter object
2828
3184
  * @returns A new Query object.
2829
3185
  */
2830
3186
  filter(filters: Filter<Record>): Query<Record, Result>;
2831
- filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
2832
3187
  /**
2833
3188
  * Builds a new query with a new sort option.
2834
3189
  * @param column The column name.
@@ -2842,42 +3197,148 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
2842
3197
  * @returns A new Query object.
2843
3198
  */
2844
3199
  select<K extends SelectableColumn<Record>>(columns: NonEmptyArray<K>): Query<Record, SelectedPick<Record, NonEmptyArray<K>>>;
3200
+ /**
3201
+ * Get paginated results
3202
+ *
3203
+ * @returns A page of results
3204
+ */
2845
3205
  getPaginated(): Promise<Page<Record, Result>>;
2846
- getPaginated(options: Omit<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
3206
+ /**
3207
+ * Get paginated results
3208
+ *
3209
+ * @param options Pagination options
3210
+ * @returns A page of results
3211
+ */
3212
+ getPaginated(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
3213
+ /**
3214
+ * Get paginated results
3215
+ *
3216
+ * @param options Pagination options
3217
+ * @returns A page of results
3218
+ */
2847
3219
  getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
3220
+ /**
3221
+ * Get results in an iterator
3222
+ *
3223
+ * @async
3224
+ * @returns Async interable of results
3225
+ */
2848
3226
  [Symbol.asyncIterator](): AsyncIterableIterator<Result>;
2849
- getIterator(chunk: number): AsyncGenerator<Result[]>;
2850
- getIterator(chunk: number, options: Omit<QueryOptions<Record>, 'columns' | 'page'>): AsyncGenerator<Result[]>;
2851
- getIterator<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(chunk: number, options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
3227
+ /**
3228
+ * Build an iterator of results
3229
+ *
3230
+ * @returns Async generator of results array
3231
+ */
3232
+ getIterator(): AsyncGenerator<Result[]>;
3233
+ /**
3234
+ * Build an iterator of results
3235
+ *
3236
+ * @param options Pagination options with batchSize
3237
+ * @returns Async generator of results array
3238
+ */
3239
+ getIterator(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3240
+ batchSize?: number;
3241
+ }): AsyncGenerator<Result[]>;
3242
+ /**
3243
+ * Build an iterator of results
3244
+ *
3245
+ * @param options Pagination options with batchSize
3246
+ * @returns Async generator of results array
3247
+ */
3248
+ getIterator<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3249
+ batchSize?: number;
3250
+ }>(options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
3251
+ /**
3252
+ * Performs the query in the database and returns a set of results.
3253
+ * @returns An array of records from the database.
3254
+ */
3255
+ getMany(): Promise<RecordArray<Result>>;
3256
+ /**
3257
+ * Performs the query in the database and returns a set of results.
3258
+ * @param options Additional options to be used when performing the query.
3259
+ * @returns An array of records from the database.
3260
+ */
3261
+ getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<RecordArray<SelectedPick<Record, typeof options['columns']>>>;
2852
3262
  /**
2853
3263
  * Performs the query in the database and returns a set of results.
2854
3264
  * @param options Additional options to be used when performing the query.
2855
3265
  * @returns An array of records from the database.
2856
3266
  */
2857
- getMany(): Promise<Result[]>;
2858
- getMany(options: Omit<QueryOptions<Record>, 'columns'>): Promise<Result[]>;
2859
- getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3267
+ getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<RecordArray<Result>>;
3268
+ /**
3269
+ * Performs the query in the database and returns all the results.
3270
+ * Warning: If there are a large number of results, this method can have performance implications.
3271
+ * @returns An array of records from the database.
3272
+ */
3273
+ getAll(): Promise<Result[]>;
3274
+ /**
3275
+ * Performs the query in the database and returns all the results.
3276
+ * Warning: If there are a large number of results, this method can have performance implications.
3277
+ * @param options Additional options to be used when performing the query.
3278
+ * @returns An array of records from the database.
3279
+ */
3280
+ getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3281
+ batchSize?: number;
3282
+ }>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
2860
3283
  /**
2861
3284
  * Performs the query in the database and returns all the results.
2862
3285
  * Warning: If there are a large number of results, this method can have performance implications.
2863
3286
  * @param options Additional options to be used when performing the query.
2864
3287
  * @returns An array of records from the database.
2865
3288
  */
2866
- getAll(chunk?: number): Promise<Result[]>;
2867
- getAll(chunk: number | undefined, options: Omit<QueryOptions<Record>, 'columns' | 'page'>): Promise<Result[]>;
2868
- getAll<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(chunk: number | undefined, options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3289
+ getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3290
+ batchSize?: number;
3291
+ }): Promise<Result[]>;
3292
+ /**
3293
+ * Performs the query in the database and returns the first result.
3294
+ * @returns The first record that matches the query, or null if no record matched the query.
3295
+ */
3296
+ getFirst(): Promise<Result | null>;
2869
3297
  /**
2870
3298
  * Performs the query in the database and returns the first result.
2871
3299
  * @param options Additional options to be used when performing the query.
2872
3300
  * @returns The first record that matches the query, or null if no record matched the query.
2873
3301
  */
2874
- getOne(): Promise<Result | null>;
2875
- getOne(options: Omit<QueryOptions<Record>, 'columns' | 'page'>): Promise<Result | null>;
2876
- getOne<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3302
+ getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3303
+ /**
3304
+ * Performs the query in the database and returns the first result.
3305
+ * @param options Additional options to be used when performing the query.
3306
+ * @returns The first record that matches the query, or null if no record matched the query.
3307
+ */
3308
+ getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
3309
+ /**
3310
+ * Builds a new query object adding a cache TTL in milliseconds.
3311
+ * @param ttl The cache TTL in milliseconds.
3312
+ * @returns A new Query object.
3313
+ */
3314
+ cache(ttl: number): Query<Record, Result>;
3315
+ /**
3316
+ * Retrieve next page of records
3317
+ *
3318
+ * @returns A new page object.
3319
+ */
2877
3320
  nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3321
+ /**
3322
+ * Retrieve previous page of records
3323
+ *
3324
+ * @returns A new page object
3325
+ */
2878
3326
  previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3327
+ /**
3328
+ * Retrieve first page of records
3329
+ *
3330
+ * @returns A new page object
3331
+ */
2879
3332
  firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3333
+ /**
3334
+ * Retrieve last page of records
3335
+ *
3336
+ * @returns A new page object
3337
+ */
2880
3338
  lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3339
+ /**
3340
+ * @returns Boolean indicating if there is a next page
3341
+ */
2881
3342
  hasNextPage(): boolean;
2882
3343
  }
2883
3344
 
@@ -2889,7 +3350,7 @@ declare type PaginationQueryMeta = {
2889
3350
  };
2890
3351
  interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
2891
3352
  meta: PaginationQueryMeta;
2892
- records: Result[];
3353
+ records: RecordArray<Result>;
2893
3354
  nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
2894
3355
  previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
2895
3356
  firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
@@ -2909,7 +3370,7 @@ declare class Page<Record extends XataRecord, Result extends XataRecord = Record
2909
3370
  /**
2910
3371
  * The set of results for this page.
2911
3372
  */
2912
- readonly records: Result[];
3373
+ readonly records: RecordArray<Result>;
2913
3374
  constructor(query: Query<Record, Result>, meta: PaginationQueryMeta, records?: Result[]);
2914
3375
  /**
2915
3376
  * Retrieves the next page of results.
@@ -2957,38 +3418,89 @@ declare type OffsetNavigationOptions = {
2957
3418
  size?: number;
2958
3419
  offset?: number;
2959
3420
  };
2960
- declare type PaginationOptions = CursorNavigationOptions & OffsetNavigationOptions;
2961
3421
  declare const PAGINATION_MAX_SIZE = 200;
2962
- declare const PAGINATION_DEFAULT_SIZE = 200;
3422
+ declare const PAGINATION_DEFAULT_SIZE = 20;
2963
3423
  declare const PAGINATION_MAX_OFFSET = 800;
2964
3424
  declare const PAGINATION_DEFAULT_OFFSET = 0;
3425
+ declare function isCursorPaginationOptions(options: Record<string, unknown> | undefined | null): options is CursorNavigationOptions;
3426
+ declare class RecordArray<Result extends XataRecord> extends Array<Result> {
3427
+ #private;
3428
+ constructor(page: Paginable<any, Result>, overrideRecords?: Result[]);
3429
+ static parseConstructorParams(...args: any[]): any[];
3430
+ toArray(): Result[];
3431
+ map<U>(callbackfn: (value: Result, index: number, array: Result[]) => U, thisArg?: any): U[];
3432
+ /**
3433
+ * Retrieve next page of records
3434
+ *
3435
+ * @returns A new array of objects
3436
+ */
3437
+ nextPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3438
+ /**
3439
+ * Retrieve previous page of records
3440
+ *
3441
+ * @returns A new array of objects
3442
+ */
3443
+ previousPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3444
+ /**
3445
+ * Retrieve first page of records
3446
+ *
3447
+ * @returns A new array of objects
3448
+ */
3449
+ firstPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3450
+ /**
3451
+ * Retrieve last page of records
3452
+ *
3453
+ * @returns A new array of objects
3454
+ */
3455
+ lastPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3456
+ /**
3457
+ * @returns Boolean indicating if there is a next page
3458
+ */
3459
+ hasNextPage(): boolean;
3460
+ }
2965
3461
 
2966
- declare type TableLink = string[];
2967
- declare type LinkDictionary = Dictionary<TableLink[]>;
2968
3462
  /**
2969
3463
  * Common interface for performing operations on a table.
2970
3464
  */
2971
3465
  declare abstract class Repository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, Readonly<SelectedPick<Record, ['*']>>> {
2972
- abstract create(object: EditableData<Data> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3466
+ abstract create(object: Omit<EditableData<Data>, 'id'> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
2973
3467
  /**
2974
3468
  * Creates a single record in the table with a unique id.
2975
3469
  * @param id The unique id.
2976
3470
  * @param object Object containing the column names with their values to be stored in the table.
2977
3471
  * @returns The full persisted record.
2978
3472
  */
2979
- abstract create(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3473
+ abstract create(id: string, object: Omit<EditableData<Data>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
2980
3474
  /**
2981
3475
  * Creates multiple records in the table.
2982
3476
  * @param objects Array of objects with the column names and the values to be stored in the table.
2983
3477
  * @returns Array of the persisted records.
2984
3478
  */
2985
- abstract create(objects: Array<EditableData<Data> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3479
+ abstract create(objects: Array<Omit<EditableData<Data>, 'id'> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
2986
3480
  /**
2987
3481
  * Queries a single record from the table given its unique id.
2988
3482
  * @param id The unique id.
2989
3483
  * @returns The persisted record for the given id or null if the record could not be found.
2990
3484
  */
2991
3485
  abstract read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3486
+ /**
3487
+ * Queries multiple records from the table given their unique id.
3488
+ * @param ids The unique ids array.
3489
+ * @returns The persisted records for the given ids (if a record could not be found it is not returned).
3490
+ */
3491
+ abstract read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3492
+ /**
3493
+ * Queries a single record from the table by the id in the object.
3494
+ * @param object Object containing the id of the record.
3495
+ * @returns The persisted record for the given id or null if the record could not be found.
3496
+ */
3497
+ abstract read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3498
+ /**
3499
+ * Queries multiple records from the table by the ids in the objects.
3500
+ * @param objects Array of objects containing the ids of the records.
3501
+ * @returns The persisted records for the given ids (if a record could not be found it is not returned).
3502
+ */
3503
+ abstract read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
2992
3504
  /**
2993
3505
  * Partially update a single record.
2994
3506
  * @param object An object with its id and the columns to be updated.
@@ -3022,7 +3534,7 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3022
3534
  * @param object The column names and the values to be persisted.
3023
3535
  * @returns The full persisted record.
3024
3536
  */
3025
- abstract createOrUpdate(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3537
+ abstract createOrUpdate(id: string, object: Omit<EditableData<Data>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3026
3538
  /**
3027
3539
  * Creates or updates a single record. If a record exists with the given id,
3028
3540
  * it will be update, otherwise a new record will be created.
@@ -3061,7 +3573,9 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3061
3573
  * @returns The found records.
3062
3574
  */
3063
3575
  abstract search(query: string, options?: {
3064
- fuzziness?: number;
3576
+ fuzziness?: FuzzinessExpression;
3577
+ highlight?: HighlightExpression;
3578
+ filter?: Filter<Record>;
3065
3579
  }): Promise<SelectedPick<Record, ['*']>[]>;
3066
3580
  abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
3067
3581
  }
@@ -3070,27 +3584,85 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
3070
3584
  db: SchemaPluginResult<any>;
3071
3585
  constructor(options: {
3072
3586
  table: string;
3073
- links?: LinkDictionary;
3074
- getFetchProps: () => Promise<FetcherExtraProps>;
3075
3587
  db: SchemaPluginResult<any>;
3588
+ pluginOptions: XataPluginOptions;
3589
+ schemaTables?: Table[];
3076
3590
  });
3077
- create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3078
- create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3079
- create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
3591
+ create(object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3592
+ create(recordId: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3593
+ create(objects: EditableData<Data>[]): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3080
3594
  read(recordId: string): Promise<SelectedPick<Record, ['*']> | null>;
3595
+ read(recordIds: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3596
+ read(object: Identifiable): Promise<SelectedPick<Record, ['*']> | null>;
3597
+ read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3081
3598
  update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
3082
3599
  update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
3083
3600
  update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
3084
3601
  createOrUpdate(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3085
3602
  createOrUpdate(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3086
3603
  createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
3087
- delete(recordId: string | Identifiable | Array<string | Identifiable>): Promise<void>;
3604
+ delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
3088
3605
  search(query: string, options?: {
3089
- fuzziness?: number;
3606
+ fuzziness?: FuzzinessExpression;
3607
+ highlight?: HighlightExpression;
3608
+ filter?: Filter<Record>;
3090
3609
  }): Promise<SelectedPick<Record, ['*']>[]>;
3091
3610
  query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
3092
3611
  }
3093
3612
 
3613
+ declare type BaseSchema = {
3614
+ name: string;
3615
+ columns: readonly ({
3616
+ name: string;
3617
+ type: Column['type'];
3618
+ } | {
3619
+ name: string;
3620
+ type: 'link';
3621
+ link: {
3622
+ table: string;
3623
+ };
3624
+ } | {
3625
+ name: string;
3626
+ type: 'object';
3627
+ columns: {
3628
+ name: string;
3629
+ type: string;
3630
+ }[];
3631
+ })[];
3632
+ };
3633
+ declare type SchemaInference<T extends readonly BaseSchema[]> = T extends never[] ? Record<string, Record<string, any>> : T extends readonly unknown[] ? T[number] extends {
3634
+ name: string;
3635
+ columns: readonly unknown[];
3636
+ } ? {
3637
+ [K in T[number]['name']]: TableType<T[number], K>;
3638
+ } : never : never;
3639
+ declare type TableType<Tables, TableName> = Tables & {
3640
+ name: TableName;
3641
+ } extends infer Table ? Table extends {
3642
+ name: string;
3643
+ columns: infer Columns;
3644
+ } ? Columns extends readonly unknown[] ? Columns[number] extends {
3645
+ name: string;
3646
+ type: string;
3647
+ } ? Identifiable & {
3648
+ [K in Columns[number]['name']]?: PropertyType<Tables, Columns[number], K>;
3649
+ } : never : never : never : never;
3650
+ declare type PropertyType<Tables, Properties, PropertyName> = Properties & {
3651
+ name: PropertyName;
3652
+ } extends infer Property ? Property extends {
3653
+ name: string;
3654
+ type: infer Type;
3655
+ link?: {
3656
+ table: infer LinkedTable;
3657
+ };
3658
+ columns?: infer ObjectColumns;
3659
+ } ? (Type extends 'string' | 'text' | 'email' ? string : Type extends 'int' | 'float' ? number : Type extends 'bool' ? boolean : Type extends 'datetime' ? Date : Type extends 'multiple' ? string[] : Type extends 'object' ? ObjectColumns extends readonly unknown[] ? ObjectColumns[number] extends {
3660
+ name: string;
3661
+ type: string;
3662
+ } ? {
3663
+ [K in ObjectColumns[number]['name']]?: PropertyType<Tables, ObjectColumns[number], K>;
3664
+ } : never : never : Type extends 'link' ? TableType<Tables, LinkedTable> & XataRecord : never) | null : never : never;
3665
+
3094
3666
  /**
3095
3667
  * Operator to restrict results to only values that are greater than the given value.
3096
3668
  */
@@ -3166,46 +3738,58 @@ declare const includesAny: <T>(value: T) => ArrayFilter<T>;
3166
3738
 
3167
3739
  declare type SchemaDefinition = {
3168
3740
  table: string;
3169
- links?: LinkDictionary;
3170
3741
  };
3171
3742
  declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
3172
3743
  [Key in keyof Schemas]: Repository<Schemas[Key]>;
3744
+ } & {
3745
+ [key: string]: Repository<XataRecord$1>;
3173
3746
  };
3174
3747
  declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3175
3748
  #private;
3176
- private links?;
3177
- private tableNames?;
3178
- constructor(links?: LinkDictionary | undefined, tableNames?: string[] | undefined);
3179
- build(options: XataPluginOptions): SchemaPluginResult<Schemas>;
3749
+ constructor(schemaTables?: Schemas.Table[]);
3750
+ build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
3180
3751
  }
3181
3752
 
3182
3753
  declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
3183
- fuzziness?: number;
3184
- tables?: Tables[];
3754
+ fuzziness?: FuzzinessExpression;
3755
+ highlight?: HighlightExpression;
3756
+ tables?: Array<Tables | Values<{
3757
+ [Model in GetArrayInnerType<NonNullable<Tables[]>>]: {
3758
+ table: Model;
3759
+ filter?: Filter<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
3760
+ };
3761
+ }>>;
3185
3762
  };
3186
3763
  declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
3187
3764
  all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
3188
- [Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]: {
3765
+ [Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]: {
3189
3766
  table: Model;
3190
3767
  record: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
3191
3768
  };
3192
3769
  }>[]>;
3193
3770
  byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
3194
- [Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
3771
+ [Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
3195
3772
  }>;
3196
3773
  };
3197
3774
  declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3198
3775
  #private;
3199
3776
  private db;
3200
- private links;
3201
- constructor(db: SchemaPluginResult<Schemas>, links: LinkDictionary);
3777
+ constructor(db: SchemaPluginResult<Schemas>, schemaTables?: Schemas.Table[]);
3202
3778
  build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
3203
3779
  }
3204
- declare type SearchXataRecord = XataRecord & {
3205
- xata: {
3206
- table: string;
3780
+ declare type SearchXataRecord = XataRecord<SearchExtraProperties>;
3781
+ declare type SearchExtraProperties = {
3782
+ table: string;
3783
+ highlight?: {
3784
+ [key: string]: string[] | {
3785
+ [key: string]: any;
3786
+ };
3207
3787
  };
3208
3788
  };
3789
+ declare type ReturnTable<Table, Tables> = Table extends Tables ? Table : never;
3790
+ 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 {
3791
+ table: infer Table;
3792
+ } ? ReturnTable<Table, Tables> : never;
3209
3793
 
3210
3794
  declare type BranchStrategyValue = string | undefined | null;
3211
3795
  declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
@@ -3217,18 +3801,19 @@ declare type BaseClientOptions = {
3217
3801
  apiKey?: string;
3218
3802
  databaseURL?: string;
3219
3803
  branch?: BranchStrategyOption;
3804
+ cache?: CacheImpl;
3220
3805
  };
3221
3806
  declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
3222
3807
  interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
3223
- new <Schemas extends Record<string, BaseData>>(options?: Partial<BaseClientOptions>, links?: LinkDictionary): Omit<{
3224
- db: Awaited<ReturnType<SchemaPlugin<Schemas>['build']>>;
3225
- search: Awaited<ReturnType<SearchPlugin<Schemas>['build']>>;
3808
+ new <T extends readonly BaseSchema[]>(options?: Partial<BaseClientOptions>, schemaTables?: T): Omit<{
3809
+ db: Awaited<ReturnType<SchemaPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
3810
+ search: Awaited<ReturnType<SearchPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
3226
3811
  }, keyof Plugins> & {
3227
3812
  [Key in StringKeys<NonNullable<Plugins>>]: Awaited<ReturnType<NonNullable<Plugins>[Key]['build']>>;
3228
3813
  };
3229
3814
  }
3230
3815
  declare const BaseClient_base: ClientConstructor<{}>;
3231
- declare class BaseClient extends BaseClient_base<Record<string, any>> {
3816
+ declare class BaseClient extends BaseClient_base<[]> {
3232
3817
  }
3233
3818
 
3234
3819
  declare type BranchResolutionOptions = {
@@ -3236,7 +3821,7 @@ declare type BranchResolutionOptions = {
3236
3821
  apiKey?: string;
3237
3822
  fetchImpl?: FetchImpl;
3238
3823
  };
3239
- declare function getCurrentBranchName(options?: BranchResolutionOptions): Promise<string | undefined>;
3824
+ declare function getCurrentBranchName(options?: BranchResolutionOptions): Promise<string>;
3240
3825
  declare function getCurrentBranchDetails(options?: BranchResolutionOptions): Promise<DBBranch | null>;
3241
3826
  declare function getDatabaseURL(): string | undefined;
3242
3827
 
@@ -3247,4 +3832,4 @@ declare class XataError extends Error {
3247
3832
  constructor(message: string, status: number);
3248
3833
  }
3249
3834
 
3250
- export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, 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, 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 };
3835
+ export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddGitBranchesEntryError, AddGitBranchesEntryPathParams, AddGitBranchesEntryRequestBody, AddGitBranchesEntryResponse, AddGitBranchesEntryVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BaseSchema, 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, Link, 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, SchemaInference, 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, UpdateWorkspaceMemberInviteError, UpdateWorkspaceMemberInvitePathParams, UpdateWorkspaceMemberInviteRequestBody, UpdateWorkspaceMemberInviteVariables, 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, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };