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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ declare type AttributeDictionary = Record<string, string | number | boolean | undefined>;
2
+ declare type TraceFunction = <T>(name: string, fn: (options: {
3
+ setAttributes: (attrs: AttributeDictionary) => void;
4
+ }) => T, options?: AttributeDictionary) => Promise<T>;
5
+
1
6
  declare type FetchImpl = (url: string, init?: {
2
7
  body?: string;
3
8
  headers?: Record<string, string>;
@@ -5,7 +10,11 @@ declare type FetchImpl = (url: string, init?: {
5
10
  }) => Promise<{
6
11
  ok: boolean;
7
12
  status: number;
13
+ url: string;
8
14
  json(): Promise<any>;
15
+ headers?: {
16
+ get(name: string): string | null;
17
+ };
9
18
  }>;
10
19
  declare type WorkspaceApiUrlBuilder = (path: string, pathParams: Record<string, string>) => string;
11
20
  declare type FetcherExtraProps = {
@@ -13,6 +22,7 @@ declare type FetcherExtraProps = {
13
22
  workspacesApiUrl: string | WorkspaceApiUrlBuilder;
14
23
  fetchImpl: FetchImpl;
15
24
  apiKey: string;
25
+ trace: TraceFunction;
16
26
  };
17
27
  declare type ErrorWrapper<TError> = TError | {
18
28
  status: 'unknown';
@@ -20,7 +30,6 @@ declare type ErrorWrapper<TError> = TError | {
20
30
  };
21
31
 
22
32
  interface CacheImpl {
23
- cacheRecords: boolean;
24
33
  defaultQueryTTL: number;
25
34
  getAll(): Promise<Record<string, unknown>>;
26
35
  get: <T>(key: string) => Promise<T | null>;
@@ -30,13 +39,11 @@ interface CacheImpl {
30
39
  }
31
40
  interface SimpleCacheOptions {
32
41
  max?: number;
33
- cacheRecords?: boolean;
34
42
  defaultQueryTTL?: number;
35
43
  }
36
44
  declare class SimpleCache implements CacheImpl {
37
45
  #private;
38
46
  capacity: number;
39
- cacheRecords: boolean;
40
47
  defaultQueryTTL: number;
41
48
  constructor(options?: SimpleCacheOptions);
42
49
  getAll(): Promise<Record<string, unknown>>;
@@ -52,6 +59,7 @@ declare abstract class XataPlugin {
52
59
  declare type XataPluginOptions = {
53
60
  getFetchProps: () => Promise<FetcherExtraProps>;
54
61
  cache: CacheImpl;
62
+ trace?: TraceFunction;
55
63
  };
56
64
 
57
65
  /**
@@ -122,22 +130,32 @@ declare type WorkspaceMembers = {
122
130
  * @pattern ^ik_[a-zA-Z0-9]+
123
131
  */
124
132
  declare type InviteKey = string;
133
+ /**
134
+ * Metadata of databases
135
+ */
136
+ declare type DatabaseMetadata = {
137
+ name: string;
138
+ displayName: string;
139
+ createdAt: DateTime;
140
+ numberOfBranches: number;
141
+ ui?: {
142
+ color?: string;
143
+ };
144
+ };
125
145
  declare type ListDatabasesResponse = {
126
- databases?: {
127
- name: string;
128
- displayName: string;
129
- createdAt: DateTime;
130
- numberOfBranches: number;
131
- ui?: {
132
- color?: string;
133
- };
134
- }[];
146
+ databases?: DatabaseMetadata[];
135
147
  };
136
148
  declare type ListBranchesResponse = {
137
149
  databaseName: string;
138
150
  displayName: string;
139
151
  branches: Branch[];
140
152
  };
153
+ declare type ListGitBranchesResponse = {
154
+ mapping: {
155
+ gitBranch: string;
156
+ xataBranch: string;
157
+ }[];
158
+ };
141
159
  declare type Branch = {
142
160
  name: string;
143
161
  createdAt: DateTime;
@@ -186,7 +204,7 @@ declare type Table = {
186
204
  */
187
205
  declare type Column = {
188
206
  name: string;
189
- type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
207
+ type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object' | 'datetime';
190
208
  link?: {
191
209
  table: string;
192
210
  };
@@ -262,6 +280,21 @@ declare type SortExpression = string[] | {
262
280
  [key: string]: SortOrder;
263
281
  }[];
264
282
  declare type SortOrder = 'asc' | 'desc';
283
+ /**
284
+ * Maximum [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) for the search terms. The Levenshtein
285
+ * distance is the number of one charcter changes needed to make two strings equal. The default is 1, meaning that single
286
+ * character typos per word are tollerated by search. You can set it to 0 to remove the typo tollerance or set it to 2
287
+ * to allow two typos in a word.
288
+ *
289
+ * @default 1
290
+ * @maximum 2
291
+ * @minimum 0
292
+ */
293
+ declare type FuzzinessExpression = number;
294
+ /**
295
+ * 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.
296
+ */
297
+ declare type PrefixExpression = 'phrase' | 'disabled';
265
298
  /**
266
299
  * @minProperties 1
267
300
  */
@@ -275,6 +308,48 @@ declare type FilterExpression = {
275
308
  } & {
276
309
  [key: string]: FilterColumn;
277
310
  };
311
+ declare type HighlightExpression = {
312
+ enabled?: boolean;
313
+ encodeHTML?: boolean;
314
+ };
315
+ /**
316
+ * Booster Expression
317
+ *
318
+ * @x-go-type xata.BoosterExpression
319
+ */
320
+ declare type BoosterExpression = {
321
+ valueBooster?: ValueBooster$1;
322
+ } | {
323
+ numericBooster?: NumericBooster$1;
324
+ } | {
325
+ dateBooster?: DateBooster$1;
326
+ };
327
+ /**
328
+ * Boost records with a particular value for a column.
329
+ */
330
+ declare type ValueBooster$1 = {
331
+ column: string;
332
+ value: string | number | boolean;
333
+ factor: number;
334
+ };
335
+ /**
336
+ * Boost records based on the value of a numeric column.
337
+ */
338
+ declare type NumericBooster$1 = {
339
+ column: string;
340
+ factor: number;
341
+ };
342
+ /**
343
+ * Boost records based on the value of a datetime column. It is configured via "origin", "scale", and "decay". The further away from the "origin",
344
+ * the more the score is decayed. The decay function uses an exponential function. For example if origin is "now", and scale is 10 days and decay is 0.5, it
345
+ * should be interpreted as: a record with a date 10 days before/after origin will score 2 times less than a record with the date at origin.
346
+ */
347
+ declare type DateBooster$1 = {
348
+ column: string;
349
+ origin?: string;
350
+ scale: string;
351
+ decay: number;
352
+ };
278
353
  declare type FilterList = FilterExpression | FilterExpression[];
279
354
  declare type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList;
280
355
  /**
@@ -331,7 +406,24 @@ declare type PageConfig = {
331
406
  size?: number;
332
407
  offset?: number;
333
408
  };
334
- declare type ColumnsFilter = string[];
409
+ declare type ColumnsProjection = string[];
410
+ /**
411
+ * Xata Table Record Metadata
412
+ */
413
+ declare type RecordMeta = {
414
+ id: RecordID;
415
+ xata: {
416
+ version: number;
417
+ table?: string;
418
+ highlight?: {
419
+ [key: string]: string[] | {
420
+ [key: string]: any;
421
+ };
422
+ };
423
+ score?: number;
424
+ warnings?: string[];
425
+ };
426
+ };
335
427
  /**
336
428
  * @pattern [a-zA-Z0-9_-~:]+
337
429
  */
@@ -353,16 +445,9 @@ declare type RecordsMetadata = {
353
445
  };
354
446
  };
355
447
  /**
356
- * Xata Table Record
448
+ * Xata Table Record Metadata
357
449
  */
358
- declare type XataRecord$1 = {
359
- id: RecordID;
360
- xata: {
361
- version: number;
362
- table?: string;
363
- warnings?: string[];
364
- };
365
- } & {
450
+ declare type XataRecord$1 = RecordMeta & {
366
451
  [key: string]: any;
367
452
  };
368
453
 
@@ -380,8 +465,10 @@ type schemas_InviteID = InviteID;
380
465
  type schemas_WorkspaceInvite = WorkspaceInvite;
381
466
  type schemas_WorkspaceMembers = WorkspaceMembers;
382
467
  type schemas_InviteKey = InviteKey;
468
+ type schemas_DatabaseMetadata = DatabaseMetadata;
383
469
  type schemas_ListDatabasesResponse = ListDatabasesResponse;
384
470
  type schemas_ListBranchesResponse = ListBranchesResponse;
471
+ type schemas_ListGitBranchesResponse = ListGitBranchesResponse;
385
472
  type schemas_Branch = Branch;
386
473
  type schemas_BranchMetadata = BranchMetadata;
387
474
  type schemas_DBBranch = DBBranch;
@@ -402,7 +489,11 @@ type schemas_TableMigration = TableMigration;
402
489
  type schemas_ColumnMigration = ColumnMigration;
403
490
  type schemas_SortExpression = SortExpression;
404
491
  type schemas_SortOrder = SortOrder;
492
+ type schemas_FuzzinessExpression = FuzzinessExpression;
493
+ type schemas_PrefixExpression = PrefixExpression;
405
494
  type schemas_FilterExpression = FilterExpression;
495
+ type schemas_HighlightExpression = HighlightExpression;
496
+ type schemas_BoosterExpression = BoosterExpression;
406
497
  type schemas_FilterList = FilterList;
407
498
  type schemas_FilterColumn = FilterColumn;
408
499
  type schemas_FilterColumnIncludes = FilterColumnIncludes;
@@ -412,7 +503,8 @@ type schemas_FilterPredicateRangeOp = FilterPredicateRangeOp;
412
503
  type schemas_FilterRangeValue = FilterRangeValue;
413
504
  type schemas_FilterValue = FilterValue;
414
505
  type schemas_PageConfig = PageConfig;
415
- type schemas_ColumnsFilter = ColumnsFilter;
506
+ type schemas_ColumnsProjection = ColumnsProjection;
507
+ type schemas_RecordMeta = RecordMeta;
416
508
  type schemas_RecordID = RecordID;
417
509
  type schemas_TableRename = TableRename;
418
510
  type schemas_RecordsMetadata = RecordsMetadata;
@@ -432,8 +524,10 @@ declare namespace schemas {
432
524
  schemas_WorkspaceInvite as WorkspaceInvite,
433
525
  schemas_WorkspaceMembers as WorkspaceMembers,
434
526
  schemas_InviteKey as InviteKey,
527
+ schemas_DatabaseMetadata as DatabaseMetadata,
435
528
  schemas_ListDatabasesResponse as ListDatabasesResponse,
436
529
  schemas_ListBranchesResponse as ListBranchesResponse,
530
+ schemas_ListGitBranchesResponse as ListGitBranchesResponse,
437
531
  schemas_Branch as Branch,
438
532
  schemas_BranchMetadata as BranchMetadata,
439
533
  schemas_DBBranch as DBBranch,
@@ -454,7 +548,14 @@ declare namespace schemas {
454
548
  schemas_ColumnMigration as ColumnMigration,
455
549
  schemas_SortExpression as SortExpression,
456
550
  schemas_SortOrder as SortOrder,
551
+ schemas_FuzzinessExpression as FuzzinessExpression,
552
+ schemas_PrefixExpression as PrefixExpression,
457
553
  schemas_FilterExpression as FilterExpression,
554
+ schemas_HighlightExpression as HighlightExpression,
555
+ schemas_BoosterExpression as BoosterExpression,
556
+ ValueBooster$1 as ValueBooster,
557
+ NumericBooster$1 as NumericBooster,
558
+ DateBooster$1 as DateBooster,
458
559
  schemas_FilterList as FilterList,
459
560
  schemas_FilterColumn as FilterColumn,
460
561
  schemas_FilterColumnIncludes as FilterColumnIncludes,
@@ -464,7 +565,8 @@ declare namespace schemas {
464
565
  schemas_FilterRangeValue as FilterRangeValue,
465
566
  schemas_FilterValue as FilterValue,
466
567
  schemas_PageConfig as PageConfig,
467
- schemas_ColumnsFilter as ColumnsFilter,
568
+ schemas_ColumnsProjection as ColumnsProjection,
569
+ schemas_RecordMeta as RecordMeta,
468
570
  schemas_RecordID as RecordID,
469
571
  schemas_TableRename as TableRename,
470
572
  schemas_RecordsMetadata as RecordsMetadata,
@@ -499,11 +601,17 @@ declare type BulkError = {
499
601
  status?: number;
500
602
  }[];
501
603
  };
604
+ declare type BulkInsertResponse = {
605
+ recordIDs: string[];
606
+ } | {
607
+ records: XataRecord$1[];
608
+ };
502
609
  declare type BranchMigrationPlan = {
503
610
  version: number;
504
611
  migration: BranchMigration;
505
612
  };
506
- declare type RecordUpdateResponse = {
613
+ declare type RecordResponse = XataRecord$1;
614
+ declare type RecordUpdateResponse = XataRecord$1 | {
507
615
  id: string;
508
616
  xata: {
509
617
  version: number;
@@ -527,7 +635,9 @@ type responses_SimpleError = SimpleError;
527
635
  type responses_BadRequestError = BadRequestError;
528
636
  type responses_AuthError = AuthError;
529
637
  type responses_BulkError = BulkError;
638
+ type responses_BulkInsertResponse = BulkInsertResponse;
530
639
  type responses_BranchMigrationPlan = BranchMigrationPlan;
640
+ type responses_RecordResponse = RecordResponse;
531
641
  type responses_RecordUpdateResponse = RecordUpdateResponse;
532
642
  type responses_QueryResponse = QueryResponse;
533
643
  type responses_SearchResponse = SearchResponse;
@@ -538,7 +648,9 @@ declare namespace responses {
538
648
  responses_BadRequestError as BadRequestError,
539
649
  responses_AuthError as AuthError,
540
650
  responses_BulkError as BulkError,
651
+ responses_BulkInsertResponse as BulkInsertResponse,
541
652
  responses_BranchMigrationPlan as BranchMigrationPlan,
653
+ responses_RecordResponse as RecordResponse,
542
654
  responses_RecordUpdateResponse as RecordUpdateResponse,
543
655
  responses_QueryResponse as QueryResponse,
544
656
  responses_SearchResponse as SearchResponse,
@@ -844,6 +956,9 @@ declare type InviteWorkspaceMemberError = ErrorWrapper<{
844
956
  } | {
845
957
  status: 404;
846
958
  payload: SimpleError;
959
+ } | {
960
+ status: 409;
961
+ payload: SimpleError;
847
962
  }>;
848
963
  declare type InviteWorkspaceMemberRequestBody = {
849
964
  email: string;
@@ -857,6 +972,34 @@ declare type InviteWorkspaceMemberVariables = {
857
972
  * Invite some user to join the workspace with the given role
858
973
  */
859
974
  declare const inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<WorkspaceInvite>;
975
+ declare type UpdateWorkspaceMemberInvitePathParams = {
976
+ workspaceId: WorkspaceID;
977
+ inviteId: InviteID;
978
+ };
979
+ declare type UpdateWorkspaceMemberInviteError = ErrorWrapper<{
980
+ status: 400;
981
+ payload: BadRequestError;
982
+ } | {
983
+ status: 401;
984
+ payload: AuthError;
985
+ } | {
986
+ status: 404;
987
+ payload: SimpleError;
988
+ } | {
989
+ status: 422;
990
+ payload: SimpleError;
991
+ }>;
992
+ declare type UpdateWorkspaceMemberInviteRequestBody = {
993
+ role: Role;
994
+ };
995
+ declare type UpdateWorkspaceMemberInviteVariables = {
996
+ body: UpdateWorkspaceMemberInviteRequestBody;
997
+ pathParams: UpdateWorkspaceMemberInvitePathParams;
998
+ } & FetcherExtraProps;
999
+ /**
1000
+ * This operation provides a way to update an existing invite. Updates are performed in-place; they do not change the invite link, the expiry time, nor do they re-notify the recipient of the invite.
1001
+ */
1002
+ declare const updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<WorkspaceInvite>;
860
1003
  declare type CancelWorkspaceMemberInvitePathParams = {
861
1004
  workspaceId: WorkspaceID;
862
1005
  inviteId: InviteID;
@@ -1010,6 +1153,184 @@ declare type DeleteDatabaseVariables = {
1010
1153
  * Delete a database and all of its branches and tables permanently.
1011
1154
  */
1012
1155
  declare const deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
1156
+ declare type GetDatabaseMetadataPathParams = {
1157
+ dbName: DBName;
1158
+ workspace: string;
1159
+ };
1160
+ declare type GetDatabaseMetadataError = ErrorWrapper<{
1161
+ status: 400;
1162
+ payload: BadRequestError;
1163
+ } | {
1164
+ status: 401;
1165
+ payload: AuthError;
1166
+ } | {
1167
+ status: 404;
1168
+ payload: SimpleError;
1169
+ }>;
1170
+ declare type GetDatabaseMetadataVariables = {
1171
+ pathParams: GetDatabaseMetadataPathParams;
1172
+ } & FetcherExtraProps;
1173
+ /**
1174
+ * Retrieve metadata of the given database
1175
+ */
1176
+ declare const getDatabaseMetadata: (variables: GetDatabaseMetadataVariables) => Promise<DatabaseMetadata>;
1177
+ declare type GetGitBranchesMappingPathParams = {
1178
+ dbName: DBName;
1179
+ workspace: string;
1180
+ };
1181
+ declare type GetGitBranchesMappingError = ErrorWrapper<{
1182
+ status: 400;
1183
+ payload: BadRequestError;
1184
+ } | {
1185
+ status: 401;
1186
+ payload: AuthError;
1187
+ }>;
1188
+ declare type GetGitBranchesMappingVariables = {
1189
+ pathParams: GetGitBranchesMappingPathParams;
1190
+ } & FetcherExtraProps;
1191
+ /**
1192
+ * Lists all the git branches in the mapping, and their associated Xata branches.
1193
+ *
1194
+ * Example response:
1195
+ *
1196
+ * ```json
1197
+ * {
1198
+ * "mappings": [
1199
+ * {
1200
+ * "gitBranch": "main",
1201
+ * "xataBranch": "main"
1202
+ * },
1203
+ * {
1204
+ * "gitBranch": "gitBranch1",
1205
+ * "xataBranch": "xataBranch1"
1206
+ * }
1207
+ * {
1208
+ * "gitBranch": "xataBranch2",
1209
+ * "xataBranch": "xataBranch2"
1210
+ * }
1211
+ * ]
1212
+ * }
1213
+ * ```
1214
+ */
1215
+ declare const getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
1216
+ declare type AddGitBranchesEntryPathParams = {
1217
+ dbName: DBName;
1218
+ workspace: string;
1219
+ };
1220
+ declare type AddGitBranchesEntryError = ErrorWrapper<{
1221
+ status: 400;
1222
+ payload: BadRequestError;
1223
+ } | {
1224
+ status: 401;
1225
+ payload: AuthError;
1226
+ }>;
1227
+ declare type AddGitBranchesEntryResponse = {
1228
+ warning?: string;
1229
+ };
1230
+ declare type AddGitBranchesEntryRequestBody = {
1231
+ gitBranch: string;
1232
+ xataBranch: BranchName;
1233
+ };
1234
+ declare type AddGitBranchesEntryVariables = {
1235
+ body: AddGitBranchesEntryRequestBody;
1236
+ pathParams: AddGitBranchesEntryPathParams;
1237
+ } & FetcherExtraProps;
1238
+ /**
1239
+ * 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.
1240
+ *
1241
+ * 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.
1242
+ *
1243
+ * Example request:
1244
+ *
1245
+ * ```json
1246
+ * // POST https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches
1247
+ * {
1248
+ * "gitBranch": "fix/bug123",
1249
+ * "xataBranch": "fix_bug"
1250
+ * }
1251
+ * ```
1252
+ */
1253
+ declare const addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
1254
+ declare type RemoveGitBranchesEntryPathParams = {
1255
+ dbName: DBName;
1256
+ workspace: string;
1257
+ };
1258
+ declare type RemoveGitBranchesEntryQueryParams = {
1259
+ gitBranch: string;
1260
+ };
1261
+ declare type RemoveGitBranchesEntryError = ErrorWrapper<{
1262
+ status: 400;
1263
+ payload: BadRequestError;
1264
+ } | {
1265
+ status: 401;
1266
+ payload: AuthError;
1267
+ }>;
1268
+ declare type RemoveGitBranchesEntryVariables = {
1269
+ pathParams: RemoveGitBranchesEntryPathParams;
1270
+ queryParams: RemoveGitBranchesEntryQueryParams;
1271
+ } & FetcherExtraProps;
1272
+ /**
1273
+ * 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.
1274
+ *
1275
+ * Example request:
1276
+ *
1277
+ * ```json
1278
+ * // DELETE https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches?gitBranch=fix%2Fbug123
1279
+ * ```
1280
+ */
1281
+ declare const removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
1282
+ declare type ResolveBranchPathParams = {
1283
+ dbName: DBName;
1284
+ workspace: string;
1285
+ };
1286
+ declare type ResolveBranchQueryParams = {
1287
+ gitBranch?: string;
1288
+ fallbackBranch?: string;
1289
+ };
1290
+ declare type ResolveBranchError = ErrorWrapper<{
1291
+ status: 400;
1292
+ payload: BadRequestError;
1293
+ } | {
1294
+ status: 401;
1295
+ payload: AuthError;
1296
+ }>;
1297
+ declare type ResolveBranchResponse = {
1298
+ branch: string;
1299
+ reason: {
1300
+ code: 'FOUND_IN_MAPPING' | 'BRANCH_EXISTS' | 'FALLBACK_BRANCH' | 'DEFAULT_BRANCH';
1301
+ message: string;
1302
+ };
1303
+ };
1304
+ declare type ResolveBranchVariables = {
1305
+ pathParams: ResolveBranchPathParams;
1306
+ queryParams?: ResolveBranchQueryParams;
1307
+ } & FetcherExtraProps;
1308
+ /**
1309
+ * In order to resolve the database branch, the following algorithm is used:
1310
+ * * 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
1311
+ * * else, if a Xata branch with the exact same name as `gitBranch` exists, return it
1312
+ * * else, if `fallbackBranch` is provided and a branch with that name exists, return it
1313
+ * * else, return the default branch of the DB (`main` or the first branch)
1314
+ *
1315
+ * Example call:
1316
+ *
1317
+ * ```json
1318
+ * // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test&fallbackBranch=tsg
1319
+ * ```
1320
+ *
1321
+ * Example response:
1322
+ *
1323
+ * ```json
1324
+ * {
1325
+ * "branch": "main",
1326
+ * "reason": {
1327
+ * "code": "DEFAULT_BRANCH",
1328
+ * "message": "Default branch for this database (main)"
1329
+ * }
1330
+ * }
1331
+ * ```
1332
+ */
1333
+ declare const resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
1013
1334
  declare type GetBranchDetailsPathParams = {
1014
1335
  dbBranchName: DBBranchName;
1015
1336
  workspace: string;
@@ -1045,6 +1366,10 @@ declare type CreateBranchError = ErrorWrapper<{
1045
1366
  status: 404;
1046
1367
  payload: SimpleError;
1047
1368
  }>;
1369
+ declare type CreateBranchResponse = {
1370
+ databaseName: string;
1371
+ branchName: string;
1372
+ };
1048
1373
  declare type CreateBranchRequestBody = {
1049
1374
  from?: string;
1050
1375
  metadata?: BranchMetadata;
@@ -1054,7 +1379,7 @@ declare type CreateBranchVariables = {
1054
1379
  pathParams: CreateBranchPathParams;
1055
1380
  queryParams?: CreateBranchQueryParams;
1056
1381
  } & FetcherExtraProps;
1057
- declare const createBranch: (variables: CreateBranchVariables) => Promise<undefined>;
1382
+ declare const createBranch: (variables: CreateBranchVariables) => Promise<CreateBranchResponse>;
1058
1383
  declare type DeleteBranchPathParams = {
1059
1384
  dbBranchName: DBBranchName;
1060
1385
  workspace: string;
@@ -1241,13 +1566,17 @@ declare type CreateTableError = ErrorWrapper<{
1241
1566
  status: 422;
1242
1567
  payload: SimpleError;
1243
1568
  }>;
1569
+ declare type CreateTableResponse = {
1570
+ branchName: string;
1571
+ tableName: string;
1572
+ };
1244
1573
  declare type CreateTableVariables = {
1245
1574
  pathParams: CreateTablePathParams;
1246
1575
  } & FetcherExtraProps;
1247
1576
  /**
1248
1577
  * Creates a new table with the given name. Returns 422 if a table with the same name already exists.
1249
1578
  */
1250
- declare const createTable: (variables: CreateTableVariables) => Promise<undefined>;
1579
+ declare const createTable: (variables: CreateTableVariables) => Promise<CreateTableResponse>;
1251
1580
  declare type DeleteTablePathParams = {
1252
1581
  dbBranchName: DBBranchName;
1253
1582
  tableName: TableName;
@@ -1480,6 +1809,9 @@ declare type InsertRecordPathParams = {
1480
1809
  tableName: TableName;
1481
1810
  workspace: string;
1482
1811
  };
1812
+ declare type InsertRecordQueryParams = {
1813
+ columns?: ColumnsProjection;
1814
+ };
1483
1815
  declare type InsertRecordError = ErrorWrapper<{
1484
1816
  status: 400;
1485
1817
  payload: BadRequestError;
@@ -1490,20 +1822,15 @@ declare type InsertRecordError = ErrorWrapper<{
1490
1822
  status: 404;
1491
1823
  payload: SimpleError;
1492
1824
  }>;
1493
- declare type InsertRecordResponse = {
1494
- id: string;
1495
- xata: {
1496
- version: number;
1497
- };
1498
- };
1499
1825
  declare type InsertRecordVariables = {
1500
1826
  body?: Record<string, any>;
1501
1827
  pathParams: InsertRecordPathParams;
1828
+ queryParams?: InsertRecordQueryParams;
1502
1829
  } & FetcherExtraProps;
1503
1830
  /**
1504
1831
  * Insert a new Record into the Table
1505
1832
  */
1506
- declare const insertRecord: (variables: InsertRecordVariables) => Promise<InsertRecordResponse>;
1833
+ declare const insertRecord: (variables: InsertRecordVariables) => Promise<RecordUpdateResponse>;
1507
1834
  declare type InsertRecordWithIDPathParams = {
1508
1835
  dbBranchName: DBBranchName;
1509
1836
  tableName: TableName;
@@ -1511,6 +1838,7 @@ declare type InsertRecordWithIDPathParams = {
1511
1838
  workspace: string;
1512
1839
  };
1513
1840
  declare type InsertRecordWithIDQueryParams = {
1841
+ columns?: ColumnsProjection;
1514
1842
  createOnly?: boolean;
1515
1843
  ifVersion?: number;
1516
1844
  };
@@ -1543,6 +1871,7 @@ declare type UpdateRecordWithIDPathParams = {
1543
1871
  workspace: string;
1544
1872
  };
1545
1873
  declare type UpdateRecordWithIDQueryParams = {
1874
+ columns?: ColumnsProjection;
1546
1875
  ifVersion?: number;
1547
1876
  };
1548
1877
  declare type UpdateRecordWithIDError = ErrorWrapper<{
@@ -1571,6 +1900,7 @@ declare type UpsertRecordWithIDPathParams = {
1571
1900
  workspace: string;
1572
1901
  };
1573
1902
  declare type UpsertRecordWithIDQueryParams = {
1903
+ columns?: ColumnsProjection;
1574
1904
  ifVersion?: number;
1575
1905
  };
1576
1906
  declare type UpsertRecordWithIDError = ErrorWrapper<{
@@ -1598,6 +1928,9 @@ declare type DeleteRecordPathParams = {
1598
1928
  recordId: RecordID;
1599
1929
  workspace: string;
1600
1930
  };
1931
+ declare type DeleteRecordQueryParams = {
1932
+ columns?: ColumnsProjection;
1933
+ };
1601
1934
  declare type DeleteRecordError = ErrorWrapper<{
1602
1935
  status: 400;
1603
1936
  payload: BadRequestError;
@@ -1610,14 +1943,18 @@ declare type DeleteRecordError = ErrorWrapper<{
1610
1943
  }>;
1611
1944
  declare type DeleteRecordVariables = {
1612
1945
  pathParams: DeleteRecordPathParams;
1946
+ queryParams?: DeleteRecordQueryParams;
1613
1947
  } & FetcherExtraProps;
1614
- declare const deleteRecord: (variables: DeleteRecordVariables) => Promise<undefined>;
1948
+ declare const deleteRecord: (variables: DeleteRecordVariables) => Promise<XataRecord$1>;
1615
1949
  declare type GetRecordPathParams = {
1616
1950
  dbBranchName: DBBranchName;
1617
1951
  tableName: TableName;
1618
1952
  recordId: RecordID;
1619
1953
  workspace: string;
1620
1954
  };
1955
+ declare type GetRecordQueryParams = {
1956
+ columns?: ColumnsProjection;
1957
+ };
1621
1958
  declare type GetRecordError = ErrorWrapper<{
1622
1959
  status: 400;
1623
1960
  payload: BadRequestError;
@@ -1628,12 +1965,9 @@ declare type GetRecordError = ErrorWrapper<{
1628
1965
  status: 404;
1629
1966
  payload: SimpleError;
1630
1967
  }>;
1631
- declare type GetRecordRequestBody = {
1632
- columns?: ColumnsFilter;
1633
- };
1634
1968
  declare type GetRecordVariables = {
1635
- body?: GetRecordRequestBody;
1636
1969
  pathParams: GetRecordPathParams;
1970
+ queryParams?: GetRecordQueryParams;
1637
1971
  } & FetcherExtraProps;
1638
1972
  /**
1639
1973
  * Retrieve record by ID
@@ -1644,6 +1978,9 @@ declare type BulkInsertTableRecordsPathParams = {
1644
1978
  tableName: TableName;
1645
1979
  workspace: string;
1646
1980
  };
1981
+ declare type BulkInsertTableRecordsQueryParams = {
1982
+ columns?: ColumnsProjection;
1983
+ };
1647
1984
  declare type BulkInsertTableRecordsError = ErrorWrapper<{
1648
1985
  status: 400;
1649
1986
  payload: BulkError;
@@ -1653,21 +1990,22 @@ declare type BulkInsertTableRecordsError = ErrorWrapper<{
1653
1990
  } | {
1654
1991
  status: 404;
1655
1992
  payload: SimpleError;
1993
+ } | {
1994
+ status: 422;
1995
+ payload: SimpleError;
1656
1996
  }>;
1657
- declare type BulkInsertTableRecordsResponse = {
1658
- recordIDs: string[];
1659
- };
1660
1997
  declare type BulkInsertTableRecordsRequestBody = {
1661
1998
  records: Record<string, any>[];
1662
1999
  };
1663
2000
  declare type BulkInsertTableRecordsVariables = {
1664
2001
  body: BulkInsertTableRecordsRequestBody;
1665
2002
  pathParams: BulkInsertTableRecordsPathParams;
2003
+ queryParams?: BulkInsertTableRecordsQueryParams;
1666
2004
  } & FetcherExtraProps;
1667
2005
  /**
1668
2006
  * Bulk insert records
1669
2007
  */
1670
- declare const bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
2008
+ declare const bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertResponse>;
1671
2009
  declare type QueryTablePathParams = {
1672
2010
  dbBranchName: DBBranchName;
1673
2011
  tableName: TableName;
@@ -1687,7 +2025,7 @@ declare type QueryTableRequestBody = {
1687
2025
  filter?: FilterExpression;
1688
2026
  sort?: SortExpression;
1689
2027
  page?: PageConfig;
1690
- columns?: ColumnsFilter;
2028
+ columns?: ColumnsProjection;
1691
2029
  };
1692
2030
  declare type QueryTableVariables = {
1693
2031
  body?: QueryTableRequestBody;
@@ -1750,7 +2088,11 @@ declare type QueryTableVariables = {
1750
2088
  * "link": {
1751
2089
  * "table": "users"
1752
2090
  * }
1753
- * }
2091
+ * },
2092
+ * {
2093
+ * "name": "foundedDate",
2094
+ * "type": "datetime"
2095
+ * },
1754
2096
  * ]
1755
2097
  * },
1756
2098
  * {
@@ -1897,7 +2239,8 @@ declare type QueryTableVariables = {
1897
2239
  * "version": 0
1898
2240
  * },
1899
2241
  * "name": "first team",
1900
- * "code": "A1"
2242
+ * "code": "A1",
2243
+ * "foundedDate": "2020-03-04T10:43:54.32Z"
1901
2244
  * }
1902
2245
  * }
1903
2246
  * ```
@@ -1912,7 +2255,7 @@ declare type QueryTableVariables = {
1912
2255
  * `$none`, etc.
1913
2256
  *
1914
2257
  * All operators start with an `$` to differentiate them from column names
1915
- * (which are not allowed to start with an dollar sign).
2258
+ * (which are not allowed to start with a dollar sign).
1916
2259
  *
1917
2260
  * #### Exact matching and control operators
1918
2261
  *
@@ -2092,12 +2435,18 @@ declare type QueryTableVariables = {
2092
2435
  * {
2093
2436
  * "filter": {
2094
2437
  * "<column_name>": {
2095
- * "$pattern": "v*alue*"
2438
+ * "$pattern": "v*alu?"
2096
2439
  * }
2097
2440
  * }
2098
2441
  * }
2099
2442
  * ```
2100
2443
  *
2444
+ * The `$pattern` operator accepts two wildcard characters:
2445
+ * * `*` matches zero or more characters
2446
+ * * `?` matches exactly one character
2447
+ *
2448
+ * 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.
2449
+ *
2101
2450
  * We could also have `$endsWith` and `$startsWith` operators:
2102
2451
  *
2103
2452
  * ```json
@@ -2113,7 +2462,7 @@ declare type QueryTableVariables = {
2113
2462
  * }
2114
2463
  * ```
2115
2464
  *
2116
- * #### Numeric ranges
2465
+ * #### Numeric or datetime ranges
2117
2466
  *
2118
2467
  * ```json
2119
2468
  * {
@@ -2125,7 +2474,18 @@ declare type QueryTableVariables = {
2125
2474
  * }
2126
2475
  * }
2127
2476
  * ```
2128
- *
2477
+ * Date ranges support the same operators, with the date using the format defined in
2478
+ * [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339):
2479
+ * ```json
2480
+ * {
2481
+ * "filter": {
2482
+ * "<column_name>": {
2483
+ * "$gt": "2019-10-12T07:20:50.52Z",
2484
+ * "$lt": "2021-10-12T07:20:50.52Z"
2485
+ * }
2486
+ * }
2487
+ * }
2488
+ * ```
2129
2489
  * The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
2130
2490
  *
2131
2491
  * #### Negations
@@ -2393,6 +2753,41 @@ declare type QueryTableVariables = {
2393
2753
  * ```
2394
2754
  */
2395
2755
  declare const queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
2756
+ declare type SearchTablePathParams = {
2757
+ dbBranchName: DBBranchName;
2758
+ tableName: TableName;
2759
+ workspace: string;
2760
+ };
2761
+ declare type SearchTableError = ErrorWrapper<{
2762
+ status: 400;
2763
+ payload: BadRequestError;
2764
+ } | {
2765
+ status: 401;
2766
+ payload: AuthError;
2767
+ } | {
2768
+ status: 404;
2769
+ payload: SimpleError;
2770
+ }>;
2771
+ declare type SearchTableRequestBody = {
2772
+ query: string;
2773
+ fuzziness?: FuzzinessExpression;
2774
+ prefix?: PrefixExpression;
2775
+ filter?: FilterExpression;
2776
+ highlight?: HighlightExpression;
2777
+ boosters?: BoosterExpression[];
2778
+ };
2779
+ declare type SearchTableVariables = {
2780
+ body: SearchTableRequestBody;
2781
+ pathParams: SearchTablePathParams;
2782
+ } & FetcherExtraProps;
2783
+ /**
2784
+ * Run a free text search operation in a particular table.
2785
+ *
2786
+ * 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:
2787
+ * * filters `$contains`, `$startsWith`, `$endsWith` don't work on columns of type `text`
2788
+ * * filtering on columns of type `multiple` is currently unsupported
2789
+ */
2790
+ declare const searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
2396
2791
  declare type SearchBranchPathParams = {
2397
2792
  dbBranchName: DBBranchName;
2398
2793
  workspace: string;
@@ -2408,9 +2803,14 @@ declare type SearchBranchError = ErrorWrapper<{
2408
2803
  payload: SimpleError;
2409
2804
  }>;
2410
2805
  declare type SearchBranchRequestBody = {
2411
- tables?: string[];
2806
+ tables?: (string | {
2807
+ table: string;
2808
+ filter?: FilterExpression;
2809
+ boosters?: BoosterExpression[];
2810
+ })[];
2412
2811
  query: string;
2413
- fuzziness?: number;
2812
+ fuzziness?: FuzzinessExpression;
2813
+ highlight?: HighlightExpression;
2414
2814
  };
2415
2815
  declare type SearchBranchVariables = {
2416
2816
  body: SearchBranchRequestBody;
@@ -2439,6 +2839,7 @@ declare const operationsByTag: {
2439
2839
  updateWorkspaceMemberRole: (variables: UpdateWorkspaceMemberRoleVariables) => Promise<undefined>;
2440
2840
  removeWorkspaceMember: (variables: RemoveWorkspaceMemberVariables) => Promise<undefined>;
2441
2841
  inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<WorkspaceInvite>;
2842
+ updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<WorkspaceInvite>;
2442
2843
  cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
2443
2844
  resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
2444
2845
  acceptWorkspaceMemberInvite: (variables: AcceptWorkspaceMemberInviteVariables) => Promise<undefined>;
@@ -2447,11 +2848,16 @@ declare const operationsByTag: {
2447
2848
  getDatabaseList: (variables: GetDatabaseListVariables) => Promise<ListDatabasesResponse>;
2448
2849
  createDatabase: (variables: CreateDatabaseVariables) => Promise<CreateDatabaseResponse>;
2449
2850
  deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
2851
+ getDatabaseMetadata: (variables: GetDatabaseMetadataVariables) => Promise<DatabaseMetadata>;
2852
+ getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
2853
+ addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
2854
+ removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
2855
+ resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
2450
2856
  };
2451
2857
  branch: {
2452
2858
  getBranchList: (variables: GetBranchListVariables) => Promise<ListBranchesResponse>;
2453
2859
  getBranchDetails: (variables: GetBranchDetailsVariables) => Promise<DBBranch>;
2454
- createBranch: (variables: CreateBranchVariables) => Promise<undefined>;
2860
+ createBranch: (variables: CreateBranchVariables) => Promise<CreateBranchResponse>;
2455
2861
  deleteBranch: (variables: DeleteBranchVariables) => Promise<undefined>;
2456
2862
  updateBranchMetadata: (variables: UpdateBranchMetadataVariables) => Promise<undefined>;
2457
2863
  getBranchMetadata: (variables: GetBranchMetadataVariables) => Promise<BranchMetadata>;
@@ -2461,7 +2867,7 @@ declare const operationsByTag: {
2461
2867
  getBranchStats: (variables: GetBranchStatsVariables) => Promise<GetBranchStatsResponse>;
2462
2868
  };
2463
2869
  table: {
2464
- createTable: (variables: CreateTableVariables) => Promise<undefined>;
2870
+ createTable: (variables: CreateTableVariables) => Promise<CreateTableResponse>;
2465
2871
  deleteTable: (variables: DeleteTableVariables) => Promise<undefined>;
2466
2872
  updateTable: (variables: UpdateTableVariables) => Promise<undefined>;
2467
2873
  getTableSchema: (variables: GetTableSchemaVariables) => Promise<GetTableSchemaResponse>;
@@ -2473,14 +2879,15 @@ declare const operationsByTag: {
2473
2879
  updateColumn: (variables: UpdateColumnVariables) => Promise<MigrationIdResponse>;
2474
2880
  };
2475
2881
  records: {
2476
- insertRecord: (variables: InsertRecordVariables) => Promise<InsertRecordResponse>;
2882
+ insertRecord: (variables: InsertRecordVariables) => Promise<RecordUpdateResponse>;
2477
2883
  insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<RecordUpdateResponse>;
2478
2884
  updateRecordWithID: (variables: UpdateRecordWithIDVariables) => Promise<RecordUpdateResponse>;
2479
2885
  upsertRecordWithID: (variables: UpsertRecordWithIDVariables) => Promise<RecordUpdateResponse>;
2480
- deleteRecord: (variables: DeleteRecordVariables) => Promise<undefined>;
2886
+ deleteRecord: (variables: DeleteRecordVariables) => Promise<XataRecord$1>;
2481
2887
  getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
2482
- bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
2888
+ bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertResponse>;
2483
2889
  queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
2890
+ searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
2484
2891
  searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
2485
2892
  };
2486
2893
  };
@@ -2496,6 +2903,7 @@ interface XataApiClientOptions {
2496
2903
  fetch?: FetchImpl;
2497
2904
  apiKey?: string;
2498
2905
  host?: HostProvider;
2906
+ trace?: TraceFunction;
2499
2907
  }
2500
2908
  declare class XataApiClient {
2501
2909
  #private;
@@ -2529,6 +2937,7 @@ declare class WorkspaceApi {
2529
2937
  updateWorkspaceMemberRole(workspaceId: WorkspaceID, userId: UserID, role: Role): Promise<void>;
2530
2938
  removeWorkspaceMember(workspaceId: WorkspaceID, userId: UserID): Promise<void>;
2531
2939
  inviteWorkspaceMember(workspaceId: WorkspaceID, email: string, role: Role): Promise<WorkspaceInvite>;
2940
+ updateWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID, role: Role): Promise<WorkspaceInvite>;
2532
2941
  cancelWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
2533
2942
  resendWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
2534
2943
  acceptWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteKey: InviteKey): Promise<void>;
@@ -2539,13 +2948,18 @@ declare class DatabaseApi {
2539
2948
  getDatabaseList(workspace: WorkspaceID): Promise<ListDatabasesResponse>;
2540
2949
  createDatabase(workspace: WorkspaceID, dbName: DBName, options?: CreateDatabaseRequestBody): Promise<CreateDatabaseResponse>;
2541
2950
  deleteDatabase(workspace: WorkspaceID, dbName: DBName): Promise<void>;
2951
+ getDatabaseMetadata(workspace: WorkspaceID, dbName: DBName): Promise<DatabaseMetadata>;
2952
+ getGitBranchesMapping(workspace: WorkspaceID, dbName: DBName): Promise<ListGitBranchesResponse>;
2953
+ addGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, body: AddGitBranchesEntryRequestBody): Promise<AddGitBranchesEntryResponse>;
2954
+ removeGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<void>;
2955
+ resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch?: string, fallbackBranch?: string): Promise<ResolveBranchResponse>;
2542
2956
  }
2543
2957
  declare class BranchApi {
2544
2958
  private extraProps;
2545
2959
  constructor(extraProps: FetcherExtraProps);
2546
2960
  getBranchList(workspace: WorkspaceID, dbName: DBName): Promise<ListBranchesResponse>;
2547
2961
  getBranchDetails(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<DBBranch>;
2548
- createBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, from?: string, options?: CreateBranchRequestBody): Promise<void>;
2962
+ createBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, from?: string, options?: CreateBranchRequestBody): Promise<CreateBranchResponse>;
2549
2963
  deleteBranch(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<void>;
2550
2964
  updateBranchMetadata(workspace: WorkspaceID, database: DBName, branch: BranchName, metadata?: BranchMetadata): Promise<void>;
2551
2965
  getBranchMetadata(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<BranchMetadata>;
@@ -2557,7 +2971,7 @@ declare class BranchApi {
2557
2971
  declare class TableApi {
2558
2972
  private extraProps;
2559
2973
  constructor(extraProps: FetcherExtraProps);
2560
- createTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<void>;
2974
+ createTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<CreateTableResponse>;
2561
2975
  deleteTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<void>;
2562
2976
  updateTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, options: UpdateTableRequestBody): Promise<void>;
2563
2977
  getTableSchema(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<GetTableSchemaResponse>;
@@ -2571,14 +2985,15 @@ declare class TableApi {
2571
2985
  declare class RecordsApi {
2572
2986
  private extraProps;
2573
2987
  constructor(extraProps: FetcherExtraProps);
2574
- insertRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, record: Record<string, any>): Promise<InsertRecordResponse>;
2988
+ insertRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, record: Record<string, any>, options?: InsertRecordQueryParams): Promise<RecordUpdateResponse>;
2575
2989
  insertRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: InsertRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
2576
2990
  updateRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: UpdateRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
2577
2991
  upsertRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: UpsertRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
2578
- deleteRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID): Promise<void>;
2579
- getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordRequestBody): Promise<XataRecord$1>;
2580
- bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[]): Promise<BulkInsertTableRecordsResponse>;
2992
+ deleteRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: DeleteRecordQueryParams): Promise<RecordUpdateResponse>;
2993
+ getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordQueryParams): Promise<XataRecord$1>;
2994
+ bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[], options?: BulkInsertTableRecordsQueryParams): Promise<BulkInsertResponse>;
2581
2995
  queryTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: QueryTableRequestBody): Promise<QueryResponse>;
2996
+ searchTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: SearchTableRequestBody): Promise<SearchResponse>;
2582
2997
  searchBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, query: SearchBranchRequestBody): Promise<SearchResponse>;
2583
2998
  }
2584
2999
 
@@ -2592,28 +3007,29 @@ declare type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) ex
2592
3007
  declare type If<Condition, Then, Else> = Condition extends true ? Then : Else;
2593
3008
  declare type IsObject<T> = T extends Record<string, any> ? true : false;
2594
3009
  declare type IsArray<T> = T extends Array<any> ? true : false;
2595
- declare type NonEmptyArray<T> = T[] & {
2596
- 0: T;
2597
- };
2598
3010
  declare type RequiredBy<T, K extends keyof T> = T & {
2599
3011
  [P in K]-?: NonNullable<T[P]>;
2600
3012
  };
2601
3013
  declare type GetArrayInnerType<T extends readonly any[]> = T[number];
2602
3014
  declare type SingleOrArray<T> = T | T[];
2603
- declare type Dictionary<T> = Record<string, T>;
3015
+ declare type OmitBy<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
3016
+ declare type Without<T, U> = {
3017
+ [P in Exclude<keyof T, keyof U>]?: never;
3018
+ };
3019
+ declare type ExclusiveOr<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
2604
3020
 
2605
3021
  declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id' | DataProps<O> | NestedColumns<O, RecursivePath>;
2606
- declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
2607
- [K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord;
3022
+ declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord<O> & UnionToIntersection<Values<{
3023
+ [K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord<O>;
2608
3024
  }>>;
2609
- declare type ValueAtColumn<O, P extends SelectableColumn<O>> = P extends '*' ? Values<O> : P extends 'id' ? string : P extends keyof O ? O[P] : P extends `${infer K}.${infer V}` ? K extends keyof O ? Values<O[K] extends XataRecord ? (V extends SelectableColumn<O[K]> ? {
2610
- V: ValueAtColumn<O[K], V>;
2611
- } : never) : O[K]> : never : never;
3025
+ 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> ? {
3026
+ V: ValueAtColumn<Item, V>;
3027
+ } : never : O[K] : never> : never : never;
2612
3028
  declare type MAX_RECURSION = 5;
2613
3029
  declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
2614
- [K in DataProps<O>]: If<IsArray<NonNullable<O[K]>>, K, // If the property is an array, we stop recursion. We don't support object arrays yet
2615
- If<IsObject<NonNullable<O[K]>>, NonNullable<O[K]> extends XataRecord ? SelectableColumn<NonNullable<O[K]>, [...RecursivePath, O[K]]> extends string ? K | `${K}.${SelectableColumn<NonNullable<O[K]>, [...RecursivePath, O[K]]>}` : never : `${K}.${StringKeys<NonNullable<O[K]>> | '*'}`, // This allows usage of objects that are not links
2616
- K>>;
3030
+ [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
3031
+ 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
3032
+ K>> : never;
2617
3033
  }>, never>;
2618
3034
  declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
2619
3035
  declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
@@ -2640,56 +3056,85 @@ interface BaseData {
2640
3056
  /**
2641
3057
  * Represents a persisted record from the database.
2642
3058
  */
2643
- interface XataRecord extends Identifiable {
3059
+ interface XataRecord<OriginalRecord extends XataRecord<any> = XataRecord<any>> extends Identifiable {
2644
3060
  /**
2645
- * Metadata of this record.
3061
+ * Get metadata of this record.
2646
3062
  */
2647
- xata: {
2648
- /**
2649
- * Number that is increased every time the record is updated.
2650
- */
2651
- version: number;
2652
- };
3063
+ getMetadata(): XataRecordMetadata;
3064
+ /**
3065
+ * Retrieves a refreshed copy of the current record from the database.
3066
+ * @param columns The columns to retrieve. If not specified, all first level properties are retrieved.
3067
+ * @returns The persisted record with the selected columns, null if not found.
3068
+ */
3069
+ read<K extends SelectableColumn<OriginalRecord>>(columns: K[]): Promise<Readonly<SelectedPick<OriginalRecord, typeof columns>> | null>;
2653
3070
  /**
2654
3071
  * Retrieves a refreshed copy of the current record from the database.
3072
+ * @returns The persisted record with all first level properties, null if not found.
2655
3073
  */
2656
- read(): Promise<Readonly<SelectedPick<this, ['*']>> | null>;
3074
+ read(): Promise<Readonly<SelectedPick<OriginalRecord, ['*']>> | null>;
2657
3075
  /**
2658
3076
  * Performs a partial update of the current record. On success a new object is
2659
3077
  * returned and the current object is not mutated.
2660
- * @param data The columns and their values that have to be updated.
2661
- * @returns A new record containing the latest values for all the columns of the current record.
3078
+ * @param partialUpdate The columns and their values that have to be updated.
3079
+ * @param columns The columns to retrieve. If not specified, all first level properties are retrieved.
3080
+ * @returns The persisted record with the selected columns, null if not found.
3081
+ */
3082
+ update<K extends SelectableColumn<OriginalRecord>>(partialUpdate: Partial<EditableData<OriginalRecord>>, columns: K[]): Promise<Readonly<SelectedPick<OriginalRecord, typeof columns>> | null>;
3083
+ /**
3084
+ * Performs a partial update of the current record. On success a new object is
3085
+ * returned and the current object is not mutated.
3086
+ * @param partialUpdate The columns and their values that have to be updated.
3087
+ * @returns The persisted record with all first level properties, null if not found.
2662
3088
  */
2663
- update(partialUpdate: Partial<EditableData<Omit<this, keyof XataRecord>>>): Promise<Readonly<SelectedPick<this, ['*']>>>;
3089
+ update(partialUpdate: Partial<EditableData<OriginalRecord>>): Promise<Readonly<SelectedPick<OriginalRecord, ['*']>> | null>;
2664
3090
  /**
2665
3091
  * Performs a deletion of the current record in the database.
2666
- *
2667
- * @throws If the record was already deleted or if an error happened while performing the deletion.
3092
+ * @param columns The columns to retrieve. If not specified, all first level properties are retrieved.
3093
+ * @returns The deleted record, null if not found.
2668
3094
  */
2669
- delete(): Promise<void>;
3095
+ delete<K extends SelectableColumn<OriginalRecord>>(columns: K[]): Promise<Readonly<SelectedPick<OriginalRecord, typeof columns>> | null>;
3096
+ /**
3097
+ * Performs a deletion of the current record in the database.
3098
+ * @returns The deleted record, null if not found.
3099
+
3100
+ */
3101
+ delete(): Promise<Readonly<SelectedPick<OriginalRecord, ['*']>> | null>;
2670
3102
  }
2671
3103
  declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update'> & {
2672
3104
  /**
2673
3105
  * Retrieves a refreshed copy of the current record from the database.
2674
3106
  */
2675
- read(): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3107
+ read<K extends SelectableColumn<Record>>(columns?: K[]): Promise<Readonly<SelectedPick<Record, typeof columns extends SelectableColumn<Record>[] ? typeof columns : ['*']>> | null>;
2676
3108
  /**
2677
3109
  * Performs a partial update of the current record. On success a new object is
2678
3110
  * returned and the current object is not mutated.
2679
- * @param data The columns and their values that have to be updated.
3111
+ * @param partialUpdate The columns and their values that have to be updated.
2680
3112
  * @returns A new record containing the latest values for all the columns of the current record.
2681
3113
  */
2682
- update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3114
+ update<K extends SelectableColumn<Record>>(partialUpdate: Partial<EditableData<Record>>, columns?: K[]): Promise<Readonly<SelectedPick<Record, typeof columns extends SelectableColumn<Record>[] ? typeof columns : ['*']>>>;
3115
+ /**
3116
+ * Performs a deletion of the current record in the database.
3117
+ *
3118
+ * @throws If the record was already deleted or if an error happened while performing the deletion.
3119
+ */
3120
+ delete(): Promise<void>;
3121
+ };
3122
+ declare type XataRecordMetadata = {
3123
+ /**
3124
+ * Number that is increased every time the record is updated.
3125
+ */
3126
+ version: number;
3127
+ warnings?: string[];
2683
3128
  };
2684
3129
  declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
2685
3130
  declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
2686
- declare type EditableData<O extends BaseData> = {
3131
+ declare type EditableData<O extends XataRecord> = Identifiable & Omit<{
2687
3132
  [K in keyof O]: O[K] extends XataRecord ? {
2688
3133
  id: string;
2689
- } : NonNullable<O[K]> extends XataRecord ? {
3134
+ } | string : NonNullable<O[K]> extends XataRecord ? {
2690
3135
  id: string;
2691
- } | null | undefined : O[K];
2692
- };
3136
+ } | string | null | undefined : O[K];
3137
+ }, keyof XataRecord>;
2693
3138
 
2694
3139
  /**
2695
3140
  * PropertyMatchFilter
@@ -2764,8 +3209,8 @@ declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T e
2764
3209
  ],
2765
3210
  }
2766
3211
  */
2767
- declare type AggregatorFilter<Record> = {
2768
- [key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<Record>>;
3212
+ declare type AggregatorFilter<T> = {
3213
+ [key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<T>>;
2769
3214
  };
2770
3215
  /**
2771
3216
  * Existance filter
@@ -2780,10 +3225,88 @@ declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFi
2780
3225
  * Injects the Api filters on nested properties
2781
3226
  * Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
2782
3227
  */
2783
- declare type NestedApiFilter<T> = T extends Record<string, any> ? {
3228
+ declare type NestedApiFilter<T> = {
2784
3229
  [key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
2785
- } : PropertyFilter<T>;
2786
- declare type Filter<Record> = BaseApiFilter<Record> | NestedApiFilter<Record>;
3230
+ };
3231
+ declare type Filter<T> = T extends Record<string, any> ? T extends (infer ArrayType)[] ? ArrayType | ArrayType[] | ArrayFilter<ArrayType> | ArrayFilter<ArrayType[]> : T extends Date ? PropertyFilter<T> : BaseApiFilter<T> | NestedApiFilter<T> : PropertyFilter<T>;
3232
+
3233
+ declare type DateBooster = {
3234
+ origin?: string;
3235
+ scale: string;
3236
+ decay: number;
3237
+ };
3238
+ declare type NumericBooster = {
3239
+ factor: number;
3240
+ };
3241
+ declare type ValueBooster<T extends string | number | boolean> = {
3242
+ value: T;
3243
+ factor: number;
3244
+ };
3245
+ declare type Boosters<O extends XataRecord> = Values<{
3246
+ [K in SelectableColumn<O>]: NonNullable<ValueAtColumn<O, K>> extends Date ? {
3247
+ dateBooster: {
3248
+ column: K;
3249
+ } & DateBooster;
3250
+ } : NonNullable<ValueAtColumn<O, K>> extends number ? ExclusiveOr<{
3251
+ numericBooster?: {
3252
+ column: K;
3253
+ } & NumericBooster;
3254
+ }, {
3255
+ valueBooster?: {
3256
+ column: K;
3257
+ } & ValueBooster<number>;
3258
+ }> : NonNullable<ValueAtColumn<O, K>> extends string | boolean ? {
3259
+ valueBooster: {
3260
+ column: K;
3261
+ } & ValueBooster<NonNullable<ValueAtColumn<O, K>>>;
3262
+ } : never;
3263
+ }>;
3264
+
3265
+ declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
3266
+ fuzziness?: FuzzinessExpression;
3267
+ prefix?: PrefixExpression;
3268
+ highlight?: HighlightExpression;
3269
+ tables?: Array<Tables | Values<{
3270
+ [Model in GetArrayInnerType<NonNullable<Tables[]>>]: {
3271
+ table: Model;
3272
+ filter?: Filter<SelectedPick<Schemas[Model] & XataRecord, ['*']>>;
3273
+ boosters?: Boosters<Schemas[Model] & XataRecord>[];
3274
+ };
3275
+ }>>;
3276
+ };
3277
+ declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
3278
+ all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
3279
+ [Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]: {
3280
+ table: Model;
3281
+ record: Awaited<SearchXataRecord<SelectedPick<Schemas[Model] & XataRecord, ['*']>>>;
3282
+ };
3283
+ }>[]>;
3284
+ byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
3285
+ [Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]?: Awaited<SearchXataRecord<SelectedPick<Schemas[Model] & XataRecord, ['*']>>[]>;
3286
+ }>;
3287
+ };
3288
+ declare class SearchPlugin<Schemas extends Record<string, XataRecord>> extends XataPlugin {
3289
+ #private;
3290
+ private db;
3291
+ constructor(db: SchemaPluginResult<Schemas>, schemaTables?: Schemas.Table[]);
3292
+ build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
3293
+ }
3294
+ declare type SearchXataRecord<Record extends XataRecord> = Omit<Record, 'getMetadata'> & {
3295
+ getMetadata: () => XataRecordMetadata & SearchExtraProperties;
3296
+ };
3297
+ declare type SearchExtraProperties = {
3298
+ table: string;
3299
+ highlight?: {
3300
+ [key: string]: string[] | {
3301
+ [key: string]: any;
3302
+ };
3303
+ };
3304
+ score?: number;
3305
+ };
3306
+ declare type ReturnTable<Table, Tables> = Table extends Tables ? Table : never;
3307
+ 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 {
3308
+ table: infer Table;
3309
+ } ? ReturnTable<Table, Tables> : never;
2787
3310
 
2788
3311
  declare type SortDirection = 'asc' | 'desc';
2789
3312
  declare type SortFilterExtended<T extends XataRecord> = {
@@ -2795,13 +3318,21 @@ declare type SortFilterBase<T extends XataRecord> = {
2795
3318
  [Key in StringKeys<T>]: SortDirection;
2796
3319
  };
2797
3320
 
2798
- declare type QueryOptions<T extends XataRecord> = {
2799
- page?: PaginationOptions;
2800
- columns?: NonEmptyArray<SelectableColumn<T>>;
3321
+ declare type BaseOptions<T extends XataRecord> = {
3322
+ columns?: SelectableColumn<T>[];
3323
+ cache?: number;
3324
+ };
3325
+ declare type CursorQueryOptions = {
3326
+ pagination?: CursorNavigationOptions & OffsetNavigationOptions;
3327
+ filter?: never;
3328
+ sort?: never;
3329
+ };
3330
+ declare type OffsetQueryOptions<T extends XataRecord> = {
3331
+ pagination?: OffsetNavigationOptions;
2801
3332
  filter?: FilterExpression;
2802
3333
  sort?: SortFilter<T> | SortFilter<T>[];
2803
- cache?: number;
2804
3334
  };
3335
+ declare type QueryOptions<T extends XataRecord> = BaseOptions<T> & (CursorQueryOptions | OffsetQueryOptions<T>);
2805
3336
  /**
2806
3337
  * Query objects contain the information of all filters, sorting, etc. to be included in the database query.
2807
3338
  *
@@ -2811,8 +3342,11 @@ declare type QueryOptions<T extends XataRecord> = {
2811
3342
  declare class Query<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
2812
3343
  #private;
2813
3344
  readonly meta: PaginationQueryMeta;
2814
- readonly records: Result[];
2815
- constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, parent?: Partial<QueryOptions<Record>>);
3345
+ readonly records: RecordArray<Result>;
3346
+ constructor(repository: Repository<Record> | null, table: {
3347
+ name: string;
3348
+ schema?: Table;
3349
+ }, data: Partial<QueryOptions<Record>>, rawParent?: Partial<QueryOptions<Record>>);
2816
3350
  getQueryOptions(): QueryOptions<Record>;
2817
3351
  key(): string;
2818
3352
  /**
@@ -2844,73 +3378,186 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
2844
3378
  *
2845
3379
  * ```
2846
3380
  * query.filter("columnName", columnValue)
2847
- * query.filter({
2848
- * "columnName": columnValue
2849
- * })
3381
+ * query.filter("columnName", operator(columnValue)) // Use gt, gte, lt, lte, startsWith,...
3382
+ * ```
3383
+ *
3384
+ * @param column The name of the column to filter.
3385
+ * @param value The value to filter.
3386
+ * @returns A new Query object.
3387
+ */
3388
+ filter<F extends SelectableColumn<Record>>(column: F, value: Filter<NonNullable<ValueAtColumn<Record, F>>>): Query<Record, Result>;
3389
+ /**
3390
+ * Builds a new query object adding one or more constraints. Examples:
3391
+ *
3392
+ * ```
3393
+ * query.filter({ "columnName": columnValue })
2850
3394
  * query.filter({
2851
3395
  * "columnName": operator(columnValue) // Use gt, gte, lt, lte, startsWith,...
2852
3396
  * })
2853
3397
  * ```
2854
3398
  *
3399
+ * @param filters A filter object
2855
3400
  * @returns A new Query object.
2856
3401
  */
2857
- filter(filters: Filter<Record>): Query<Record, Result>;
2858
- filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
3402
+ filter(filters?: Filter<Record>): Query<Record, Result>;
3403
+ defaultFilter<T>(column: string, value: T): T | {
3404
+ $includes: (T & string) | (T & string[]);
3405
+ };
2859
3406
  /**
2860
3407
  * Builds a new query with a new sort option.
2861
3408
  * @param column The column name.
2862
3409
  * @param direction The direction. Either ascending or descending.
2863
3410
  * @returns A new Query object.
2864
3411
  */
2865
- sort<F extends SelectableColumn<Record>>(column: F, direction: SortDirection): Query<Record, Result>;
3412
+ sort<F extends SelectableColumn<Record>>(column: F, direction?: SortDirection): Query<Record, Result>;
2866
3413
  /**
2867
3414
  * Builds a new query specifying the set of columns to be returned in the query response.
2868
3415
  * @param columns Array of column names to be returned by the query.
2869
3416
  * @returns A new Query object.
2870
3417
  */
2871
- select<K extends SelectableColumn<Record>>(columns: NonEmptyArray<K>): Query<Record, SelectedPick<Record, NonEmptyArray<K>>>;
3418
+ select<K extends SelectableColumn<Record>>(columns: K[]): Query<Record, SelectedPick<Record, K[]>>;
3419
+ /**
3420
+ * Get paginated results
3421
+ *
3422
+ * @returns A page of results
3423
+ */
2872
3424
  getPaginated(): Promise<Page<Record, Result>>;
2873
- getPaginated(options: Omit<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
3425
+ /**
3426
+ * Get paginated results
3427
+ *
3428
+ * @param options Pagination options
3429
+ * @returns A page of results
3430
+ */
3431
+ getPaginated(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
3432
+ /**
3433
+ * Get paginated results
3434
+ *
3435
+ * @param options Pagination options
3436
+ * @returns A page of results
3437
+ */
2874
3438
  getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
3439
+ /**
3440
+ * Get results in an iterator
3441
+ *
3442
+ * @async
3443
+ * @returns Async interable of results
3444
+ */
2875
3445
  [Symbol.asyncIterator](): AsyncIterableIterator<Result>;
2876
- getIterator(chunk: number): AsyncGenerator<Result[]>;
2877
- getIterator(chunk: number, options: Omit<QueryOptions<Record>, 'columns' | 'page'>): AsyncGenerator<Result[]>;
2878
- getIterator<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(chunk: number, options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
3446
+ /**
3447
+ * Build an iterator of results
3448
+ *
3449
+ * @returns Async generator of results array
3450
+ */
3451
+ getIterator(): AsyncGenerator<Result[]>;
3452
+ /**
3453
+ * Build an iterator of results
3454
+ *
3455
+ * @param options Pagination options with batchSize
3456
+ * @returns Async generator of results array
3457
+ */
3458
+ getIterator(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3459
+ batchSize?: number;
3460
+ }): AsyncGenerator<Result[]>;
3461
+ /**
3462
+ * Build an iterator of results
3463
+ *
3464
+ * @param options Pagination options with batchSize
3465
+ * @returns Async generator of results array
3466
+ */
3467
+ getIterator<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3468
+ batchSize?: number;
3469
+ }>(options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
3470
+ /**
3471
+ * Performs the query in the database and returns a set of results.
3472
+ * @returns An array of records from the database.
3473
+ */
3474
+ getMany(): Promise<RecordArray<Result>>;
2879
3475
  /**
2880
3476
  * Performs the query in the database and returns a set of results.
2881
3477
  * @param options Additional options to be used when performing the query.
2882
3478
  * @returns An array of records from the database.
2883
3479
  */
2884
- getMany(): Promise<Result[]>;
2885
- getMany(options: Omit<QueryOptions<Record>, 'columns'>): Promise<Result[]>;
2886
- getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3480
+ getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<RecordArray<SelectedPick<Record, typeof options['columns']>>>;
3481
+ /**
3482
+ * Performs the query in the database and returns a set of results.
3483
+ * @param options Additional options to be used when performing the query.
3484
+ * @returns An array of records from the database.
3485
+ */
3486
+ getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<RecordArray<Result>>;
3487
+ /**
3488
+ * Performs the query in the database and returns all the results.
3489
+ * Warning: If there are a large number of results, this method can have performance implications.
3490
+ * @returns An array of records from the database.
3491
+ */
3492
+ getAll(): Promise<Result[]>;
3493
+ /**
3494
+ * Performs the query in the database and returns all the results.
3495
+ * Warning: If there are a large number of results, this method can have performance implications.
3496
+ * @param options Additional options to be used when performing the query.
3497
+ * @returns An array of records from the database.
3498
+ */
3499
+ getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3500
+ batchSize?: number;
3501
+ }>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
2887
3502
  /**
2888
3503
  * Performs the query in the database and returns all the results.
2889
3504
  * Warning: If there are a large number of results, this method can have performance implications.
2890
3505
  * @param options Additional options to be used when performing the query.
2891
3506
  * @returns An array of records from the database.
2892
3507
  */
2893
- getAll(chunk?: number): Promise<Result[]>;
2894
- getAll(chunk: number | undefined, options: Omit<QueryOptions<Record>, 'columns' | 'page'>): Promise<Result[]>;
2895
- getAll<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(chunk: number | undefined, options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3508
+ getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3509
+ batchSize?: number;
3510
+ }): Promise<Result[]>;
2896
3511
  /**
2897
3512
  * Performs the query in the database and returns the first result.
2898
- * @param options Additional options to be used when performing the query.
2899
3513
  * @returns The first record that matches the query, or null if no record matched the query.
2900
3514
  */
2901
3515
  getFirst(): Promise<Result | null>;
2902
- getFirst(options: Omit<QueryOptions<Record>, 'columns' | 'page'>): Promise<Result | null>;
2903
- getFirst<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3516
+ /**
3517
+ * Performs the query in the database and returns the first result.
3518
+ * @param options Additional options to be used when performing the query.
3519
+ * @returns The first record that matches the query, or null if no record matched the query.
3520
+ */
3521
+ getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3522
+ /**
3523
+ * Performs the query in the database and returns the first result.
3524
+ * @param options Additional options to be used when performing the query.
3525
+ * @returns The first record that matches the query, or null if no record matched the query.
3526
+ */
3527
+ getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
2904
3528
  /**
2905
3529
  * Builds a new query object adding a cache TTL in milliseconds.
2906
3530
  * @param ttl The cache TTL in milliseconds.
2907
3531
  * @returns A new Query object.
2908
3532
  */
2909
3533
  cache(ttl: number): Query<Record, Result>;
3534
+ /**
3535
+ * Retrieve next page of records
3536
+ *
3537
+ * @returns A new page object.
3538
+ */
2910
3539
  nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3540
+ /**
3541
+ * Retrieve previous page of records
3542
+ *
3543
+ * @returns A new page object
3544
+ */
2911
3545
  previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3546
+ /**
3547
+ * Retrieve first page of records
3548
+ *
3549
+ * @returns A new page object
3550
+ */
2912
3551
  firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3552
+ /**
3553
+ * Retrieve last page of records
3554
+ *
3555
+ * @returns A new page object
3556
+ */
2913
3557
  lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3558
+ /**
3559
+ * @returns Boolean indicating if there is a next page
3560
+ */
2914
3561
  hasNextPage(): boolean;
2915
3562
  }
2916
3563
 
@@ -2922,7 +3569,7 @@ declare type PaginationQueryMeta = {
2922
3569
  };
2923
3570
  interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
2924
3571
  meta: PaginationQueryMeta;
2925
- records: Result[];
3572
+ records: RecordArray<Result>;
2926
3573
  nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
2927
3574
  previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
2928
3575
  firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
@@ -2942,7 +3589,7 @@ declare class Page<Record extends XataRecord, Result extends XataRecord = Record
2942
3589
  /**
2943
3590
  * The set of results for this page.
2944
3591
  */
2945
- readonly records: Result[];
3592
+ readonly records: RecordArray<Result>;
2946
3593
  constructor(query: Query<Record, Result>, meta: PaginationQueryMeta, records?: Result[]);
2947
3594
  /**
2948
3595
  * Retrieves the next page of results.
@@ -2990,103 +3637,273 @@ declare type OffsetNavigationOptions = {
2990
3637
  size?: number;
2991
3638
  offset?: number;
2992
3639
  };
2993
- declare type PaginationOptions = CursorNavigationOptions & OffsetNavigationOptions;
2994
3640
  declare const PAGINATION_MAX_SIZE = 200;
2995
- declare const PAGINATION_DEFAULT_SIZE = 200;
3641
+ declare const PAGINATION_DEFAULT_SIZE = 20;
2996
3642
  declare const PAGINATION_MAX_OFFSET = 800;
2997
3643
  declare const PAGINATION_DEFAULT_OFFSET = 0;
3644
+ declare function isCursorPaginationOptions(options: Record<string, unknown> | undefined | null): options is CursorNavigationOptions;
3645
+ declare class RecordArray<Result extends XataRecord> extends Array<Result> {
3646
+ #private;
3647
+ constructor(page: Paginable<any, Result>, overrideRecords?: Result[]);
3648
+ static parseConstructorParams(...args: any[]): any[];
3649
+ toArray(): Result[];
3650
+ map<U>(callbackfn: (value: Result, index: number, array: Result[]) => U, thisArg?: any): U[];
3651
+ /**
3652
+ * Retrieve next page of records
3653
+ *
3654
+ * @returns A new array of objects
3655
+ */
3656
+ nextPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3657
+ /**
3658
+ * Retrieve previous page of records
3659
+ *
3660
+ * @returns A new array of objects
3661
+ */
3662
+ previousPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3663
+ /**
3664
+ * Retrieve first page of records
3665
+ *
3666
+ * @returns A new array of objects
3667
+ */
3668
+ firstPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3669
+ /**
3670
+ * Retrieve last page of records
3671
+ *
3672
+ * @returns A new array of objects
3673
+ */
3674
+ lastPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3675
+ /**
3676
+ * @returns Boolean indicating if there is a next page
3677
+ */
3678
+ hasNextPage(): boolean;
3679
+ }
2998
3680
 
2999
- declare type TableLink = string[];
3000
- declare type LinkDictionary = Dictionary<TableLink[]>;
3001
3681
  /**
3002
3682
  * Common interface for performing operations on a table.
3003
3683
  */
3004
- declare abstract class Repository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, Readonly<SelectedPick<Record, ['*']>>> {
3005
- abstract create(object: EditableData<Data> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3684
+ declare abstract class Repository<Record extends XataRecord> extends Query<Record, Readonly<SelectedPick<Record, ['*']>>> {
3685
+ abstract create<K extends SelectableColumn<Record>>(object: Omit<EditableData<Record>, 'id'> & Partial<Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3686
+ abstract create(object: Omit<EditableData<Record>, 'id'> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3006
3687
  /**
3007
3688
  * Creates a single record in the table with a unique id.
3008
3689
  * @param id The unique id.
3009
3690
  * @param object Object containing the column names with their values to be stored in the table.
3691
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3010
3692
  * @returns The full persisted record.
3011
3693
  */
3012
- abstract create(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3694
+ abstract create<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Record>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3695
+ /**
3696
+ * Creates a single record in the table with a unique id.
3697
+ * @param id The unique id.
3698
+ * @param object Object containing the column names with their values to be stored in the table.
3699
+ * @returns The full persisted record.
3700
+ */
3701
+ abstract create(id: string, object: Omit<EditableData<Record>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3013
3702
  /**
3014
3703
  * Creates multiple records in the table.
3015
3704
  * @param objects Array of objects with the column names and the values to be stored in the table.
3016
- * @returns Array of the persisted records.
3705
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3706
+ * @returns Array of the persisted records in order.
3707
+ */
3708
+ abstract create<K extends SelectableColumn<Record>>(objects: Array<Omit<EditableData<Record>, 'id'> & Partial<Identifiable>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3709
+ /**
3710
+ * Creates multiple records in the table.
3711
+ * @param objects Array of objects with the column names and the values to be stored in the table.
3712
+ * @returns Array of the persisted records in order.
3713
+ */
3714
+ abstract create(objects: Array<Omit<EditableData<Record>, 'id'> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3715
+ /**
3716
+ * Queries a single record from the table given its unique id.
3717
+ * @param id The unique id.
3718
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3719
+ * @returns The persisted record for the given id or null if the record could not be found.
3017
3720
  */
3018
- abstract create(objects: Array<EditableData<Data> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3721
+ abstract read<K extends SelectableColumn<Record>>(id: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns> | null>>;
3019
3722
  /**
3020
3723
  * Queries a single record from the table given its unique id.
3021
3724
  * @param id The unique id.
3022
3725
  * @returns The persisted record for the given id or null if the record could not be found.
3023
3726
  */
3024
3727
  abstract read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3728
+ /**
3729
+ * Queries multiple records from the table given their unique id.
3730
+ * @param ids The unique ids array.
3731
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3732
+ * @returns The persisted records for the given ids in order (if a record could not be found null is returned).
3733
+ */
3734
+ abstract read<K extends SelectableColumn<Record>>(ids: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3735
+ /**
3736
+ * Queries multiple records from the table given their unique id.
3737
+ * @param ids The unique ids array.
3738
+ * @returns The persisted records for the given ids in order (if a record could not be found null is returned).
3739
+ */
3740
+ abstract read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3741
+ /**
3742
+ * Queries a single record from the table by the id in the object.
3743
+ * @param object Object containing the id of the record.
3744
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3745
+ * @returns The persisted record for the given id or null if the record could not be found.
3746
+ */
3747
+ abstract read<K extends SelectableColumn<Record>>(object: Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns> | null>>;
3748
+ /**
3749
+ * Queries a single record from the table by the id in the object.
3750
+ * @param object Object containing the id of the record.
3751
+ * @returns The persisted record for the given id or null if the record could not be found.
3752
+ */
3753
+ abstract read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3754
+ /**
3755
+ * Queries multiple records from the table by the ids in the objects.
3756
+ * @param objects Array of objects containing the ids of the records.
3757
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3758
+ * @returns The persisted records for the given ids in order (if a record could not be found null is returned).
3759
+ */
3760
+ abstract read<K extends SelectableColumn<Record>>(objects: Identifiable[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3761
+ /**
3762
+ * Queries multiple records from the table by the ids in the objects.
3763
+ * @param objects Array of objects containing the ids of the records.
3764
+ * @returns The persisted records for the given ids in order (if a record could not be found null is returned).
3765
+ */
3766
+ abstract read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3025
3767
  /**
3026
3768
  * Partially update a single record.
3027
3769
  * @param object An object with its id and the columns to be updated.
3028
- * @returns The full persisted record.
3770
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3771
+ * @returns The full persisted record, null if the record could not be found.
3029
3772
  */
3030
- abstract update(object: Partial<EditableData<Data>> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3773
+ abstract update<K extends SelectableColumn<Record>>(object: Partial<EditableData<Record>> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3774
+ /**
3775
+ * Partially update a single record.
3776
+ * @param object An object with its id and the columns to be updated.
3777
+ * @returns The full persisted record, null if the record could not be found.
3778
+ */
3779
+ abstract update(object: Partial<EditableData<Record>> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3031
3780
  /**
3032
3781
  * Partially update a single record given its unique id.
3033
3782
  * @param id The unique id.
3034
3783
  * @param object The column names and their values that have to be updated.
3035
- * @returns The full persisted record.
3784
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3785
+ * @returns The full persisted record, null if the record could not be found.
3036
3786
  */
3037
- abstract update(id: string, object: Partial<EditableData<Data>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3787
+ abstract update<K extends SelectableColumn<Record>>(id: string, object: Partial<EditableData<Record>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3788
+ /**
3789
+ * Partially update a single record given its unique id.
3790
+ * @param id The unique id.
3791
+ * @param object The column names and their values that have to be updated.
3792
+ * @returns The full persisted record, null if the record could not be found.
3793
+ */
3794
+ abstract update(id: string, object: Partial<EditableData<Record>>): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3038
3795
  /**
3039
3796
  * Partially updates multiple records.
3040
3797
  * @param objects An array of objects with their ids and columns to be updated.
3041
- * @returns Array of the persisted records.
3798
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3799
+ * @returns Array of the persisted records in order (if a record could not be found null is returned).
3800
+ */
3801
+ abstract update<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Record>> & Identifiable>, columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3802
+ /**
3803
+ * Partially updates multiple records.
3804
+ * @param objects An array of objects with their ids and columns to be updated.
3805
+ * @returns Array of the persisted records in order (if a record could not be found null is returned).
3806
+ */
3807
+ abstract update(objects: Array<Partial<EditableData<Record>> & Identifiable>): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3808
+ /**
3809
+ * Creates or updates a single record. If a record exists with the given id,
3810
+ * it will be update, otherwise a new record will be created.
3811
+ * @param object Object containing the column names with their values to be persisted in the table.
3812
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3813
+ * @returns The full persisted record.
3042
3814
  */
3043
- abstract update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3815
+ abstract createOrUpdate<K extends SelectableColumn<Record>>(object: EditableData<Record> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3044
3816
  /**
3045
3817
  * Creates or updates a single record. If a record exists with the given id,
3046
3818
  * it will be update, otherwise a new record will be created.
3047
3819
  * @param object Object containing the column names with their values to be persisted in the table.
3048
3820
  * @returns The full persisted record.
3049
3821
  */
3050
- abstract createOrUpdate(object: EditableData<Data> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3822
+ abstract createOrUpdate(object: EditableData<Record> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3051
3823
  /**
3052
3824
  * Creates or updates a single record. If a record exists with the given id,
3053
3825
  * it will be update, otherwise a new record will be created.
3054
3826
  * @param id A unique id.
3055
3827
  * @param object The column names and the values to be persisted.
3828
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3056
3829
  * @returns The full persisted record.
3057
3830
  */
3058
- abstract createOrUpdate(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3831
+ abstract createOrUpdate<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Record>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3832
+ /**
3833
+ * Creates or updates a single record. If a record exists with the given id,
3834
+ * it will be update, otherwise a new record will be created.
3835
+ * @param id A unique id.
3836
+ * @param object The column names and the values to be persisted.
3837
+ * @returns The full persisted record.
3838
+ */
3839
+ abstract createOrUpdate(id: string, object: Omit<EditableData<Record>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3059
3840
  /**
3060
3841
  * Creates or updates a single record. If a record exists with the given id,
3061
3842
  * it will be update, otherwise a new record will be created.
3062
3843
  * @param objects Array of objects with the column names and the values to be stored in the table.
3844
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3063
3845
  * @returns Array of the persisted records.
3064
3846
  */
3065
- abstract createOrUpdate(objects: Array<EditableData<Data> & Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3847
+ abstract createOrUpdate<K extends SelectableColumn<Record>>(objects: Array<EditableData<Record> & Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3848
+ /**
3849
+ * Creates or updates a single record. If a record exists with the given id,
3850
+ * it will be update, otherwise a new record will be created.
3851
+ * @param objects Array of objects with the column names and the values to be stored in the table.
3852
+ * @returns Array of the persisted records.
3853
+ */
3854
+ abstract createOrUpdate(objects: Array<EditableData<Record> & Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3066
3855
  /**
3067
3856
  * Deletes a record given its unique id.
3068
- * @param id The unique id.
3069
- * @throws If the record could not be found or there was an error while performing the deletion.
3857
+ * @param object An object with a unique id.
3858
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3859
+ * @returns The deleted record, null if the record could not be found.
3070
3860
  */
3071
- abstract delete(id: string): Promise<void>;
3861
+ abstract delete<K extends SelectableColumn<Record>>(object: Identifiable & Partial<EditableData<Record>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3072
3862
  /**
3073
3863
  * Deletes a record given its unique id.
3074
- * @param id An object with a unique id.
3075
- * @throws If the record could not be found or there was an error while performing the deletion.
3864
+ * @param object An object with a unique id.
3865
+ * @returns The deleted record, null if the record could not be found.
3866
+ */
3867
+ abstract delete(object: Identifiable & Partial<EditableData<Record>>): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3868
+ /**
3869
+ * Deletes a record given a unique id.
3870
+ * @param id The unique id.
3871
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3872
+ * @returns The deleted record, null if the record could not be found.
3873
+ */
3874
+ abstract delete<K extends SelectableColumn<Record>>(id: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3875
+ /**
3876
+ * Deletes a record given a unique id.
3877
+ * @param id The unique id.
3878
+ * @returns The deleted record, null if the record could not be found.
3879
+ */
3880
+ abstract delete(id: string): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3881
+ /**
3882
+ * Deletes multiple records given an array of objects with ids.
3883
+ * @param objects An array of objects with unique ids.
3884
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3885
+ * @returns Array of the deleted records in order (if a record could not be found null is returned).
3886
+ */
3887
+ abstract delete<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Record>> & Identifiable>, columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3888
+ /**
3889
+ * Deletes multiple records given an array of objects with ids.
3890
+ * @param objects An array of objects with unique ids.
3891
+ * @returns Array of the deleted records in order (if a record could not be found null is returned).
3076
3892
  */
3077
- abstract delete(id: Identifiable): Promise<void>;
3893
+ abstract delete(objects: Array<Partial<EditableData<Record>> & Identifiable>): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3078
3894
  /**
3079
- * Deletes a record given a list of unique ids.
3080
- * @param ids The array of unique ids.
3081
- * @throws If the record could not be found or there was an error while performing the deletion.
3895
+ * Deletes multiple records given an array of unique ids.
3896
+ * @param objects An array of ids.
3897
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3898
+ * @returns Array of the deleted records in order (if a record could not be found null is returned).
3082
3899
  */
3083
- abstract delete(ids: string[]): Promise<void>;
3900
+ abstract delete<K extends SelectableColumn<Record>>(objects: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3084
3901
  /**
3085
- * Deletes a record given a list of unique ids.
3086
- * @param ids An array of objects with unique ids.
3087
- * @throws If the record could not be found or there was an error while performing the deletion.
3902
+ * Deletes multiple records given an array of unique ids.
3903
+ * @param objects An array of ids.
3904
+ * @returns Array of the deleted records in order (if a record could not be found null is returned).
3088
3905
  */
3089
- abstract delete(ids: Identifiable[]): Promise<void>;
3906
+ abstract delete(objects: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3090
3907
  /**
3091
3908
  * Search for records in the table.
3092
3909
  * @param query The query to search for.
@@ -3094,36 +3911,123 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3094
3911
  * @returns The found records.
3095
3912
  */
3096
3913
  abstract search(query: string, options?: {
3097
- fuzziness?: number;
3098
- }): Promise<SelectedPick<Record, ['*']>[]>;
3914
+ fuzziness?: FuzzinessExpression;
3915
+ prefix?: PrefixExpression;
3916
+ highlight?: HighlightExpression;
3917
+ filter?: Filter<Record>;
3918
+ boosters?: Boosters<Record>[];
3919
+ }): Promise<SearchXataRecord<SelectedPick<Record, ['*']>>[]>;
3099
3920
  abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
3100
3921
  }
3101
- declare class RestRepository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, SelectedPick<Record, ['*']>> implements Repository<Data, Record> {
3922
+ declare class RestRepository<Record extends XataRecord> extends Query<Record, SelectedPick<Record, ['*']>> implements Repository<Record> {
3102
3923
  #private;
3103
- db: SchemaPluginResult<any>;
3104
3924
  constructor(options: {
3105
3925
  table: string;
3106
- links?: LinkDictionary;
3107
3926
  db: SchemaPluginResult<any>;
3108
3927
  pluginOptions: XataPluginOptions;
3928
+ schemaTables?: Table[];
3109
3929
  });
3110
- create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3111
- create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3112
- create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
3113
- read(recordId: string): Promise<SelectedPick<Record, ['*']> | null>;
3114
- update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
3115
- update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
3116
- update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
3117
- createOrUpdate(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3118
- createOrUpdate(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3119
- createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
3120
- delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
3930
+ create<K extends SelectableColumn<Record>>(object: EditableData<Record> & Partial<Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3931
+ create(object: EditableData<Record> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3932
+ create<K extends SelectableColumn<Record>>(id: string, object: EditableData<Record>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3933
+ create(id: string, object: EditableData<Record>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3934
+ create<K extends SelectableColumn<Record>>(objects: Array<EditableData<Record> & Partial<Identifiable>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3935
+ create(objects: Array<EditableData<Record> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3936
+ read<K extends SelectableColumn<Record>>(id: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns> | null>>;
3937
+ read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3938
+ read<K extends SelectableColumn<Record>>(ids: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3939
+ read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3940
+ read<K extends SelectableColumn<Record>>(object: Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns> | null>>;
3941
+ read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3942
+ read<K extends SelectableColumn<Record>>(objects: Identifiable[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3943
+ read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3944
+ update<K extends SelectableColumn<Record>>(object: Partial<EditableData<Record>> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3945
+ update(object: Partial<EditableData<Record>> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3946
+ update<K extends SelectableColumn<Record>>(id: string, object: Partial<EditableData<Record>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3947
+ update(id: string, object: Partial<EditableData<Record>>): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3948
+ update<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Record>> & Identifiable>, columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3949
+ update(objects: Array<Partial<EditableData<Record>> & Identifiable>): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3950
+ createOrUpdate<K extends SelectableColumn<Record>>(object: EditableData<Record> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3951
+ createOrUpdate(object: EditableData<Record> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3952
+ createOrUpdate<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Record>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3953
+ createOrUpdate(id: string, object: Omit<EditableData<Record>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3954
+ createOrUpdate<K extends SelectableColumn<Record>>(objects: Array<EditableData<Record> & Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3955
+ createOrUpdate(objects: Array<EditableData<Record> & Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3956
+ delete<K extends SelectableColumn<Record>>(object: Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3957
+ delete(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3958
+ delete<K extends SelectableColumn<Record>>(id: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3959
+ delete(id: string): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3960
+ delete<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Record>> & Identifiable>, columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3961
+ delete(objects: Array<Partial<EditableData<Record>> & Identifiable>): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3962
+ delete<K extends SelectableColumn<Record>>(objects: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3963
+ delete(objects: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3121
3964
  search(query: string, options?: {
3122
- fuzziness?: number;
3123
- }): Promise<SelectedPick<Record, ['*']>[]>;
3965
+ fuzziness?: FuzzinessExpression;
3966
+ prefix?: PrefixExpression;
3967
+ highlight?: HighlightExpression;
3968
+ filter?: Filter<Record>;
3969
+ boosters?: Boosters<Record>[];
3970
+ }): Promise<any>;
3124
3971
  query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
3125
3972
  }
3126
3973
 
3974
+ declare type BaseSchema = {
3975
+ name: string;
3976
+ columns: readonly ({
3977
+ name: string;
3978
+ type: Column['type'];
3979
+ } | {
3980
+ name: string;
3981
+ type: 'link';
3982
+ link: {
3983
+ table: string;
3984
+ };
3985
+ } | {
3986
+ name: string;
3987
+ type: 'object';
3988
+ columns: {
3989
+ name: string;
3990
+ type: string;
3991
+ }[];
3992
+ })[];
3993
+ };
3994
+ declare type SchemaInference<T extends readonly BaseSchema[]> = T extends never[] ? Record<string, Record<string, any>> : T extends readonly unknown[] ? T[number] extends {
3995
+ name: string;
3996
+ columns: readonly unknown[];
3997
+ } ? {
3998
+ [K in T[number]['name']]: TableType<T[number], K>;
3999
+ } : never : never;
4000
+ declare type TableType<Tables, TableName> = Tables & {
4001
+ name: TableName;
4002
+ } extends infer Table ? Table extends {
4003
+ name: string;
4004
+ columns: infer Columns;
4005
+ } ? Columns extends readonly unknown[] ? Columns[number] extends {
4006
+ name: string;
4007
+ type: string;
4008
+ } ? Identifiable & {
4009
+ [K in Columns[number]['name']]?: PropertyType<Tables, Columns[number], K>;
4010
+ } : never : never : never : never;
4011
+ declare type PropertyType<Tables, Properties, PropertyName> = Properties & {
4012
+ name: PropertyName;
4013
+ } extends infer Property ? Property extends {
4014
+ name: string;
4015
+ type: infer Type;
4016
+ link?: {
4017
+ table: infer LinkedTable;
4018
+ };
4019
+ columns?: infer ObjectColumns;
4020
+ } ? (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 {
4021
+ name: string;
4022
+ type: string;
4023
+ } ? {
4024
+ [K in ObjectColumns[number]['name']]?: PropertyType<Tables, ObjectColumns[number], K>;
4025
+ } : never : never : Type extends 'link' ? TableType<Tables, LinkedTable> & XataRecord : never) | null : never : never;
4026
+
4027
+ /**
4028
+ * Operator to restrict results to only values that are greater than the given value.
4029
+ */
4030
+ declare const greaterThan: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
3127
4031
  /**
3128
4032
  * Operator to restrict results to only values that are greater than the given value.
3129
4033
  */
@@ -3131,15 +4035,35 @@ declare const gt: <T extends ComparableType>(value: T) => ComparableTypeFilter<T
3131
4035
  /**
3132
4036
  * Operator to restrict results to only values that are greater than or equal to the given value.
3133
4037
  */
3134
- declare const ge: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
4038
+ declare const greaterThanEquals: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
4039
+ /**
4040
+ * Operator to restrict results to only values that are greater than or equal to the given value.
4041
+ */
4042
+ declare const greaterEquals: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
3135
4043
  /**
3136
4044
  * Operator to restrict results to only values that are greater than or equal to the given value.
3137
4045
  */
3138
4046
  declare const gte: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
4047
+ /**
4048
+ * Operator to restrict results to only values that are greater than or equal to the given value.
4049
+ */
4050
+ declare const ge: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
4051
+ /**
4052
+ * Operator to restrict results to only values that are lower than the given value.
4053
+ */
4054
+ declare const lessThan: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
3139
4055
  /**
3140
4056
  * Operator to restrict results to only values that are lower than the given value.
3141
4057
  */
3142
4058
  declare const lt: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
4059
+ /**
4060
+ * Operator to restrict results to only values that are lower than or equal to the given value.
4061
+ */
4062
+ declare const lessThanEquals: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
4063
+ /**
4064
+ * Operator to restrict results to only values that are lower than or equal to the given value.
4065
+ */
4066
+ declare const lessEquals: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
3143
4067
  /**
3144
4068
  * Operator to restrict results to only values that are lower than or equal to the given value.
3145
4069
  */
@@ -3172,6 +4096,10 @@ declare const pattern: (value: string) => StringTypeFilter;
3172
4096
  * Operator to restrict results to only values that are equal to the given value.
3173
4097
  */
3174
4098
  declare const is: <T>(value: T) => PropertyFilter<T>;
4099
+ /**
4100
+ * Operator to restrict results to only values that are equal to the given value.
4101
+ */
4102
+ declare const equals: <T>(value: T) => PropertyFilter<T>;
3175
4103
  /**
3176
4104
  * Operator to restrict results to only values that are not equal to the given value.
3177
4105
  */
@@ -3199,47 +4127,16 @@ declare const includesAny: <T>(value: T) => ArrayFilter<T>;
3199
4127
 
3200
4128
  declare type SchemaDefinition = {
3201
4129
  table: string;
3202
- links?: LinkDictionary;
3203
4130
  };
3204
- declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
4131
+ declare type SchemaPluginResult<Schemas extends Record<string, XataRecord>> = {
3205
4132
  [Key in keyof Schemas]: Repository<Schemas[Key]>;
3206
4133
  };
3207
- declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
4134
+ declare class SchemaPlugin<Schemas extends Record<string, XataRecord>> extends XataPlugin {
3208
4135
  #private;
3209
- private links?;
3210
- private tableNames?;
3211
- constructor(links?: LinkDictionary | undefined, tableNames?: string[] | undefined);
4136
+ constructor(schemaTables?: Schemas.Table[]);
3212
4137
  build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
3213
4138
  }
3214
4139
 
3215
- declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
3216
- fuzziness?: number;
3217
- tables?: Tables[];
3218
- };
3219
- declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
3220
- all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
3221
- [Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]: {
3222
- table: Model;
3223
- record: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
3224
- };
3225
- }>[]>;
3226
- byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
3227
- [Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
3228
- }>;
3229
- };
3230
- declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3231
- #private;
3232
- private db;
3233
- private links;
3234
- constructor(db: SchemaPluginResult<Schemas>, links: LinkDictionary);
3235
- build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
3236
- }
3237
- declare type SearchXataRecord = XataRecord & {
3238
- xata: {
3239
- table: string;
3240
- };
3241
- };
3242
-
3243
4140
  declare type BranchStrategyValue = string | undefined | null;
3244
4141
  declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
3245
4142
  declare type BranchStrategy = BranchStrategyValue | BranchStrategyBuilder;
@@ -3251,20 +4148,35 @@ declare type BaseClientOptions = {
3251
4148
  databaseURL?: string;
3252
4149
  branch?: BranchStrategyOption;
3253
4150
  cache?: CacheImpl;
4151
+ trace?: TraceFunction;
3254
4152
  };
3255
4153
  declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
3256
4154
  interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
3257
- new <Schemas extends Record<string, BaseData>>(options?: Partial<BaseClientOptions>, links?: LinkDictionary): Omit<{
4155
+ new <Schemas extends Record<string, XataRecord> = {}>(options?: Partial<BaseClientOptions>, schemaTables?: readonly BaseSchema[]): Omit<{
3258
4156
  db: Awaited<ReturnType<SchemaPlugin<Schemas>['build']>>;
3259
4157
  search: Awaited<ReturnType<SearchPlugin<Schemas>['build']>>;
3260
4158
  }, keyof Plugins> & {
3261
4159
  [Key in StringKeys<NonNullable<Plugins>>]: Awaited<ReturnType<NonNullable<Plugins>[Key]['build']>>;
4160
+ } & {
4161
+ getConfig(): Promise<{
4162
+ databaseURL: string;
4163
+ branch: string;
4164
+ }>;
3262
4165
  };
3263
4166
  }
3264
4167
  declare const BaseClient_base: ClientConstructor<{}>;
3265
4168
  declare class BaseClient extends BaseClient_base<Record<string, any>> {
3266
4169
  }
3267
4170
 
4171
+ declare class Serializer {
4172
+ classes: Record<string, any>;
4173
+ add(clazz: any): void;
4174
+ toJSON<T>(data: T): string;
4175
+ fromJSON<T>(json: string): T;
4176
+ }
4177
+ declare const serialize: <T>(data: T) => string;
4178
+ declare const deserialize: <T>(json: string) => T;
4179
+
3268
4180
  declare type BranchResolutionOptions = {
3269
4181
  databaseURL?: string;
3270
4182
  apiKey?: string;
@@ -3276,9 +4188,89 @@ declare function getDatabaseURL(): string | undefined;
3276
4188
 
3277
4189
  declare function getAPIKey(): string | undefined;
3278
4190
 
4191
+ interface Body {
4192
+ arrayBuffer(): Promise<ArrayBuffer>;
4193
+ blob(): Promise<Blob>;
4194
+ formData(): Promise<FormData>;
4195
+ json(): Promise<any>;
4196
+ text(): Promise<string>;
4197
+ }
4198
+ interface Blob {
4199
+ readonly size: number;
4200
+ readonly type: string;
4201
+ arrayBuffer(): Promise<ArrayBuffer>;
4202
+ slice(start?: number, end?: number, contentType?: string): Blob;
4203
+ text(): Promise<string>;
4204
+ }
4205
+ /** Provides information about files and allows JavaScript in a web page to access their content. */
4206
+ interface File extends Blob {
4207
+ readonly lastModified: number;
4208
+ readonly name: string;
4209
+ readonly webkitRelativePath: string;
4210
+ }
4211
+ declare type FormDataEntryValue = File | string;
4212
+ /** Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data". */
4213
+ interface FormData {
4214
+ append(name: string, value: string | Blob, fileName?: string): void;
4215
+ delete(name: string): void;
4216
+ get(name: string): FormDataEntryValue | null;
4217
+ getAll(name: string): FormDataEntryValue[];
4218
+ has(name: string): boolean;
4219
+ set(name: string, value: string | Blob, fileName?: string): void;
4220
+ forEach(callbackfn: (value: FormDataEntryValue, key: string, parent: FormData) => void, thisArg?: any): void;
4221
+ }
4222
+ /** This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence. */
4223
+ interface Headers {
4224
+ append(name: string, value: string): void;
4225
+ delete(name: string): void;
4226
+ get(name: string): string | null;
4227
+ has(name: string): boolean;
4228
+ set(name: string, value: string): void;
4229
+ forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void;
4230
+ }
4231
+ interface Request extends Body {
4232
+ /** Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. */
4233
+ readonly cache: 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload';
4234
+ /** Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. */
4235
+ readonly credentials: 'include' | 'omit' | 'same-origin';
4236
+ /** Returns the kind of resource requested by request, e.g., "document" or "script". */
4237
+ readonly destination: '' | 'audio' | 'audioworklet' | 'document' | 'embed' | 'font' | 'frame' | 'iframe' | 'image' | 'manifest' | 'object' | 'paintworklet' | 'report' | 'script' | 'sharedworker' | 'style' | 'track' | 'video' | 'worker' | 'xslt';
4238
+ /** Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header. */
4239
+ readonly headers: Headers;
4240
+ /** Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI] */
4241
+ readonly integrity: string;
4242
+ /** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
4243
+ readonly keepalive: boolean;
4244
+ /** Returns request's HTTP method, which is "GET" by default. */
4245
+ readonly method: string;
4246
+ /** Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs. */
4247
+ readonly mode: 'cors' | 'navigate' | 'no-cors' | 'same-origin';
4248
+ /** Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. */
4249
+ readonly redirect: 'error' | 'follow' | 'manual';
4250
+ /** Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made. */
4251
+ readonly referrer: string;
4252
+ /** Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer. */
4253
+ readonly referrerPolicy: '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
4254
+ /** Returns the URL of request as a string. */
4255
+ readonly url: string;
4256
+ clone(): Request;
4257
+ }
4258
+
4259
+ declare type XataWorkerContext<XataClient> = {
4260
+ xata: XataClient;
4261
+ request: Request;
4262
+ env: Record<string, string | undefined>;
4263
+ };
4264
+ declare type RemoveFirst<T> = T extends [any, ...infer U] ? U : never;
4265
+ declare type WorkerRunnerConfig = {
4266
+ workspace: string;
4267
+ worker: string;
4268
+ };
4269
+ declare function buildWorkerRunner<XataClient>(config: WorkerRunnerConfig): <WorkerFunction extends (ctx: XataWorkerContext<XataClient>, ...args: any[]) => any>(name: string, _worker: WorkerFunction) => (...args: RemoveFirst<Parameters<WorkerFunction>>) => Promise<Awaited<ReturnType<WorkerFunction>>>;
4270
+
3279
4271
  declare class XataError extends Error {
3280
4272
  readonly status: number;
3281
4273
  constructor(message: string, status: number);
3282
4274
  }
3283
4275
 
3284
- export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, CacheImpl, CancelWorkspaceMemberInviteError, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchError, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchVariables, CreateDatabaseError, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTableError, CreateTablePathParams, CreateTableVariables, CreateUserAPIKeyError, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceError, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchError, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnError, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabaseError, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordError, DeleteRecordPathParams, DeleteRecordVariables, DeleteTableError, DeleteTablePathParams, DeleteTableVariables, DeleteUserAPIKeyError, DeleteUserAPIKeyPathParams, DeleteUserAPIKeyVariables, DeleteUserError, DeleteUserVariables, DeleteWorkspaceError, DeleteWorkspacePathParams, DeleteWorkspaceVariables, EditableData, ExecuteBranchMigrationPlanError, ExecuteBranchMigrationPlanPathParams, ExecuteBranchMigrationPlanRequestBody, ExecuteBranchMigrationPlanVariables, FetchImpl, FetcherExtraProps, GetBranchDetailsError, GetBranchDetailsPathParams, GetBranchDetailsVariables, GetBranchListError, GetBranchListPathParams, GetBranchListVariables, GetBranchMetadataError, GetBranchMetadataPathParams, GetBranchMetadataVariables, GetBranchMigrationHistoryError, GetBranchMigrationHistoryPathParams, GetBranchMigrationHistoryRequestBody, GetBranchMigrationHistoryResponse, GetBranchMigrationHistoryVariables, GetBranchMigrationPlanError, GetBranchMigrationPlanPathParams, GetBranchMigrationPlanVariables, GetBranchStatsError, GetBranchStatsPathParams, GetBranchStatsResponse, GetBranchStatsVariables, GetColumnError, GetColumnPathParams, GetColumnVariables, GetDatabaseListError, GetDatabaseListPathParams, GetDatabaseListVariables, GetRecordError, GetRecordPathParams, GetRecordRequestBody, GetRecordVariables, GetTableColumnsError, GetTableColumnsPathParams, GetTableColumnsResponse, GetTableColumnsVariables, GetTableSchemaError, GetTableSchemaPathParams, GetTableSchemaResponse, GetTableSchemaVariables, GetUserAPIKeysError, GetUserAPIKeysResponse, GetUserAPIKeysVariables, GetUserError, GetUserVariables, GetWorkspaceError, GetWorkspaceMembersListError, GetWorkspaceMembersListPathParams, GetWorkspaceMembersListVariables, GetWorkspacePathParams, GetWorkspaceVariables, GetWorkspacesListError, GetWorkspacesListResponse, GetWorkspacesListVariables, Identifiable, InsertRecordError, InsertRecordPathParams, InsertRecordResponse, InsertRecordVariables, InsertRecordWithIDError, InsertRecordWithIDPathParams, InsertRecordWithIDQueryParams, InsertRecordWithIDVariables, InviteWorkspaceMemberError, InviteWorkspaceMemberPathParams, InviteWorkspaceMemberRequestBody, InviteWorkspaceMemberVariables, LinkDictionary, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationOptions, PaginationQueryMeta, Query, QueryTableError, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RemoveWorkspaceMemberError, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInviteError, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchError, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchOptions, SearchPlugin, SearchPluginResult, SelectableColumn, SelectedPick, SetTableSchemaError, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, SimpleCache, SimpleCacheOptions, UpdateBranchMetadataError, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnError, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDError, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTableError, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserError, UpdateUserVariables, UpdateWorkspaceError, UpdateWorkspaceMemberRoleError, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDError, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeWorkspaceMember, resendWorkspaceMemberInvite, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
4276
+ export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddGitBranchesEntryError, AddGitBranchesEntryPathParams, AddGitBranchesEntryRequestBody, AddGitBranchesEntryResponse, AddGitBranchesEntryVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BaseSchema, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsQueryParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsVariables, CacheImpl, CancelWorkspaceMemberInviteError, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchError, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchResponse, CreateBranchVariables, CreateDatabaseError, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTableError, CreateTablePathParams, CreateTableResponse, CreateTableVariables, CreateUserAPIKeyError, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceError, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchError, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnError, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabaseError, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordError, DeleteRecordPathParams, DeleteRecordQueryParams, 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, GetDatabaseMetadataError, GetDatabaseMetadataPathParams, GetDatabaseMetadataVariables, GetGitBranchesMappingError, GetGitBranchesMappingPathParams, GetGitBranchesMappingVariables, GetRecordError, GetRecordPathParams, GetRecordQueryParams, 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, InsertRecordQueryParams, 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, SearchXataRecord, SelectableColumn, SelectedPick, Serializer, 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, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };