@xata.io/client 0.0.0-alpha.vf4b92f1 → 0.0.0-alpha.vf5ce72f

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